From 21f25a360ca49e42f9ba65d9df61e7124a7d8def Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 2 Jan 2024 07:26:32 +0100 Subject: [PATCH 001/403] OpenSoar.config - increase version to 7.41.21.1 --- OpenSoar-News.md | 6 +++++- OpenSoar.config | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/OpenSoar-News.md b/OpenSoar-News.md index 8da04a2b088..d01777c5581 100644 --- a/OpenSoar-News.md +++ b/OpenSoar-News.md @@ -1,6 +1,10 @@ +OpenSoar Version 7.41.21.1 - not yet released +--------------- +* start with OpenVarioMenu + OpenSoar Version 7.41.21 - 2023/12/28 --------------- -* (xcsoar-)bugfix with dead QuickMenu button solved +* (xcsoar-)bugfix with dead QuickMenu button * CMake - reenable MinGW - update Clang (but not succesful) diff --git a/OpenSoar.config b/OpenSoar.config index bb62db75495..e9034cb8372 100644 --- a/OpenSoar.config +++ b/OpenSoar.config @@ -1,4 +1,4 @@ PROGRAM_NAME=OpenSoar -PROGRAM_VERSION=7.41.21 +PROGRAM_VERSION=7.41.21.1 ANDROID_VERSIONCODE=21 ANDROID_PACKAGE=de.opensoar From bdcd197bc3975826a29e6d5883a63c48c7b0b84d Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 2 Jan 2024 07:27:19 +0100 Subject: [PATCH 002/403] OpenVarioMenu.cpp - add button Start OpenSoar --- src/OV/OpenVarioMenu.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index 53c1402d74d..9d162f1cacb 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -293,6 +293,12 @@ class MainMenuWidget final const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; Run("/usr/bin/xcsoar", "-fly"); } + void StartOpenSoar() noexcept { + const UI::ScopeDropMaster drop_master{display}; + const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; + Run("/usr/bin/OpenSoar", "-fly"); + // Run("/usr/bin/OpenSoar", "-fly", "-datapath=/home/root/data/OpenSoarData"); + } void ScheduleTimer() noexcept { assert(remaining_seconds > 0); @@ -367,6 +373,11 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { + AddButton("Start OpenSoar", [this](){ + CancelTimer(); + StartOpenSoar(); + }); + AddButton("Start XCSoar", [this](){ CancelTimer(); StartXCSoar(); From 3ecf1b0333988fbabe4a9b3b5ce90f79448f6338 Mon Sep 17 00:00:00 2001 From: Stefan Schumann Date: Sun, 14 May 2023 22:26:35 +0200 Subject: [PATCH 003/403] OV/System: swap PORTRAIT and REVERSE_PORTRAIT rotation values The screen was rotated the wrong way after restart for both portrait orientations. --- src/OV/System.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/OV/System.cpp b/src/OV/System.cpp index 4e9268cfb57..eb8eb70b0d9 100644 --- a/src/OV/System.cpp +++ b/src/OV/System.cpp @@ -77,9 +77,9 @@ OpenvarioGetRotation() switch (result) { case 0: return DisplayOrientation::LANDSCAPE; - case 1: return DisplayOrientation::PORTRAIT; + case 1: return DisplayOrientation::REVERSE_PORTRAIT; case 2: return DisplayOrientation::REVERSE_LANDSCAPE; - case 3: return DisplayOrientation::REVERSE_PORTRAIT; + case 3: return DisplayOrientation::PORTRAIT; default: return DisplayOrientation::DEFAULT; } } @@ -96,13 +96,13 @@ OpenvarioSetRotation(DisplayOrientation orientation) case DisplayOrientation::DEFAULT: case DisplayOrientation::LANDSCAPE: break; - case DisplayOrientation::PORTRAIT: + case DisplayOrientation::REVERSE_PORTRAIT: rotation = 1; break; case DisplayOrientation::REVERSE_LANDSCAPE: rotation = 2; break; - case DisplayOrientation::REVERSE_PORTRAIT: + case DisplayOrientation::PORTRAIT: rotation = 3; break; }; From 5b803e422c58def25f6078b7e1b57ff419a584e1 Mon Sep 17 00:00:00 2001 From: Blaubart Date: Thu, 20 Apr 2023 18:29:33 +0200 Subject: [PATCH 004/403] OV/OpenVarioMenu: set initial display rotation on startup --- src/OV/OpenVarioMenu.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index 9d162f1cacb..7ac063975ce 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -28,6 +28,7 @@ #include "util/PrintException.hxx" #include "util/ScopeExit.hxx" #include "LocalPath.hpp" +#include "System.hpp" #include #include @@ -455,6 +456,12 @@ Main() UI::TopWindowStyle main_style; main_style.Resizable(); + DisplayOrientation orientation = DisplayOrientation::DEFAULT; + try { + orientation = OpenvarioGetRotation(); + } catch (...) {} + main_style.InitialOrientation(orientation); + UI::SingleWindow main_window{screen_init.GetDisplay()}; main_window.Create(_T("XCSoar/OpenVarioMenu"), {600, 800}, main_style); main_window.Show(); From 00299f82bdf6685a5d5b24b9c151800a3c60b336 Mon Sep 17 00:00:00 2001 From: Martin Kaiser <14329350+mk-it-easy@users.noreply.github.com> Date: Sun, 7 May 2023 23:04:18 +0200 Subject: [PATCH 005/403] OV/OpenVarioMenu: wait on startup to fix display rotation timing problem --- src/OV/OpenVarioMenu.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index 7ac063975ce..91ea99fdfb1 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -32,6 +32,7 @@ #include #include +#include enum Buttons { LAUNCH_SHELL = 100, @@ -480,6 +481,9 @@ Main() int main() { + /*the x-menu is waiting a second to solve timing problem with display rotation */ + std::this_thread::sleep_for(std::chrono::seconds(1)); + try { InitialiseDataPath(); have_data_path = true; From 1d7297bbe79e7dd6fb67efac03b24cdc962004dd Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 2 Jan 2024 10:28:29 +0100 Subject: [PATCH 006/403] [CMake] - add OpenVarioMenu to project --- CMakeLists.txt | 2 ++ src/OV/CMakeLists.txt | 52 ++++++++++++++++++++++++++++++++++++++++ src/OV/CMakeSource.cmake | 8 +++++++ 3 files changed, 62 insertions(+) create mode 100644 src/OV/CMakeLists.txt create mode 100644 src/OV/CMakeSource.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 26b5356eccd..985b7dfa9d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -358,6 +358,8 @@ endif() add_subdirectory(src/lib) add_subdirectory(src) # libOpenSoar! +add_subdirectory(src/OV) # libOpenSoar! + list(APPEND SOURCE_FILES "src/OpenSoar.cpp") # list(APPEND SOURCE_FILES "src/Version.cpp") ## configure_file( diff --git a/src/OV/CMakeLists.txt b/src/OV/CMakeLists.txt new file mode 100644 index 00000000000..fdc14b53dce --- /dev/null +++ b/src/OV/CMakeLists.txt @@ -0,0 +1,52 @@ +cmake_minimum_required(VERSION 3.15) +if (SHOW_SUBPROJECTS) + message(STATUS "+++ Start CMake ${CMAKE_CURRENT_SOURCE_DIR}!") +endif() + + get_filename_component(TARGET_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME_WE) + +include(CMakeSource.cmake) +# organize the files in subdirectories +set(SOURCE_FILES ) +foreach(source_file ${_SOURCES}) + string(REPLACE "${TARGET_NAME}/" "" source_file ${source_file}) + list(APPEND SOURCE_FILES ${source_file}) + get_filename_component(src_path ${source_file} DIRECTORY) + if (src_path) + string(REPLACE "/" "\\" src_path ${src_path}) + endif() + source_group("Source\\${src_path}" FILES ${source_file}) + # message(STATUS "### ${src_path} --- ${source_file}") +endforeach() + +if(NOT HEADER_FILES) # STREQUAL "" +file(GLOB_RECURSE HEADER_FILES_TEMP "${CMAKE_CURRENT_SOURCE_DIR}/*.h*") # ;../*.hxx;../*.h +# message(FATAL_ERROR "### ### Header-Liste --- ${HEADER_FILES_TEMP}" ) +set(HEADER_FILES) +foreach(header_file ${HEADER_FILES_TEMP}) + string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" header_file ${header_file}) + list(APPEND HEADER_FILES ${header_file}) + get_filename_component(src_path ${header_file} DIRECTORY) + if (src_path) + string(REPLACE "/" "\\" src_path ${src_path}) + endif() + source_group("Header\\${src_path}" FILES ${header_file}) + ## message(STATUS "### ### ${src_path} --- ${header_file}" ) +endforeach() +# message(FATAL_ERROR "### ### Header-Liste --- ${HEADER_FILES}" ) +endif() + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + +# add_library(${TARGET_NAME} ${XCSOAR_LIB_TYPE} +add_executable(${TARGET_NAME} # ${XCSOAR_LIB_TYPE} + ${SOURCE_FILES} + ${HEADER_FILES} + ${SCRIPT_FILES} +) +target_link_libraries(${TARGET_NAME} PUBLIC Logger) + + # message(FATAL_ERROR "Stop!") +set_target_properties(${TARGET_NAME} PROPERTIES FOLDER OpenVario) + +add_dependencies(${TARGET_NAME} util) diff --git a/src/OV/CMakeSource.cmake b/src/OV/CMakeSource.cmake new file mode 100644 index 00000000000..b310e59cd58 --- /dev/null +++ b/src/OV/CMakeSource.cmake @@ -0,0 +1,8 @@ +set(_SOURCES + OV/System.cpp + OV/OpenVarioMenu.cpp +) + +set(SCRIPT_FILES + CMakeSource.cmake +) From 4e999cb262030428f401f5c867226ca776d617e7 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 2 Jan 2024 10:29:19 +0100 Subject: [PATCH 007/403] OpenVarioMenu.cpp - add Contol-Enum for OpenSoar --- src/OV/OpenVarioMenu.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index 91ea99fdfb1..0026f03f9a2 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -256,6 +256,7 @@ class MainMenuWidget final : public RowFormWidget { enum Controls { + OPENSOAR, XCSOAR, LOGBOOK, FILE, From 36e9bb365effc1e0195765e9959c9446bd28bcc9 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 2 Jan 2024 11:01:08 +0100 Subject: [PATCH 008/403] OpenVarioMenu.cpp - switch to HOME path --- src/OV/OpenVarioMenu.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index 0026f03f9a2..a028b9bb748 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -33,6 +33,7 @@ #include #include #include +#include enum Buttons { LAUNCH_SHELL = 100, @@ -482,6 +483,7 @@ Main() int main() { + std::filesystem::current_path("/home/root"); // setting path /*the x-menu is waiting a second to solve timing problem with display rotation */ std::this_thread::sleep_for(std::chrono::seconds(1)); From 98a94ee00b0d9876ac786331725cdef05dd513d4 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 2 Jan 2024 12:02:54 +0100 Subject: [PATCH 009/403] OpenVarioMenu.cpp - 'Call Shell' only exit to shell with value 100 --- src/OV/OpenVarioMenu.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index a028b9bb748..5e31b93b915 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -504,10 +504,7 @@ int main() switch (action) { case LAUNCH_SHELL: - execl("/bin/bash", "bash", "--login", nullptr); - execl("/bin/ash", "-ash", nullptr); - execl("/bin/ash", "-sh", nullptr); - perror("Failed to launch shell"); + exit(100); return EXIT_FAILURE; } From ae26df1489a52dddca18318cc4c72a9f2d64fa57 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 2 Jan 2024 18:29:50 +0100 Subject: [PATCH 010/403] OpenVarioMenu.cpp - add Button "Start OpenSoar (Club), OpenSoar = Main app --- src/OV/OpenVarioMenu.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index 5e31b93b915..f9b74d8535a 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -258,6 +258,8 @@ class MainMenuWidget final { enum Controls { OPENSOAR, + OPENSOAR_CLUB, + OPENSOAR_CLUB2, XCSOAR, LOGBOOK, FILE, @@ -276,7 +278,8 @@ class MainMenuWidget final UI::Timer timer{[this](){ if (--remaining_seconds == 0) { HideRow(Controls::TIMER); - StartXCSoar(); + // StartXCSoar(); + StartOpenSoar(); } else { ScheduleTimer(); } @@ -300,8 +303,8 @@ class MainMenuWidget final void StartOpenSoar() noexcept { const UI::ScopeDropMaster drop_master{display}; const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; - Run("/usr/bin/OpenSoar", "-fly"); - // Run("/usr/bin/OpenSoar", "-fly", "-datapath=/home/root/data/OpenSoarData"); + // Run("/usr/bin/OpenSoar", "-fly"); + Run("/usr/bin/OpenSoar", "-fly", "-datapath=/home/root/data/OpenSoarData"); } void ScheduleTimer() noexcept { @@ -382,6 +385,16 @@ MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, StartOpenSoar(); }); + AddButton("Start OpenSoar (Club)", [this](){ + CancelTimer(); + StartOpenSoar(); + }); + + AddButton("Start OpenSoar (Club2)", [this](){ + CancelTimer(); + StartOpenSoar(); + }); + AddButton("Start XCSoar", [this](){ CancelTimer(); StartXCSoar(); @@ -430,6 +443,8 @@ MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, }); AddReadOnly(""); + + HideRow(Controls::OPENSOAR_CLUB); } static int From 3b899bd2aeff537edc215fd31fd3f0688333eebb Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 2 Jan 2024 20:24:59 +0100 Subject: [PATCH 011/403] OpenVarioMenu - add Settings.cpp, move settings functions to this --- src/OV/OpenVarioMenu.cpp | 70 ++++++++++++------------------------- src/OV/Settings.cpp | 74 ++++++++++++++++++++++++++++++++++++++++ src/OV/Settings.hpp | 34 ++++++++++++++++++ 3 files changed, 129 insertions(+), 49 deletions(-) create mode 100644 src/OV/Settings.cpp create mode 100644 src/OV/Settings.hpp diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index f9b74d8535a..937b6991edf 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -28,7 +28,8 @@ #include "util/PrintException.hxx" #include "util/ScopeExit.hxx" #include "LocalPath.hpp" -#include "System.hpp" +#include "OV/System.hpp" +#include "OV/Settings.hpp" #include #include @@ -41,31 +42,6 @@ enum Buttons { static bool have_data_path = false; -static DialogSettings dialog_settings; -static UI::SingleWindow *global_main_window; -static DialogLook *global_dialog_look; - -const DialogSettings & -UIGlobals::GetDialogSettings() -{ - return dialog_settings; -} - -const DialogLook & -UIGlobals::GetDialogLook() -{ - assert(global_dialog_look != nullptr); - - return *global_dialog_look; -} - -UI::SingleWindow & -UIGlobals::GetMainWindow() -{ - assert(global_main_window != nullptr); - - return *global_main_window; -} class FileMenuWidget final : public RowFormWidget @@ -116,23 +92,23 @@ FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, }); } -class SystemMenuWidget final - : public RowFormWidget -{ - UI::Display &display; - UI::EventQueue &event_queue; - -public: - SystemMenuWidget(UI::Display &_display, UI::EventQueue &_event_queue, - const DialogLook &look) noexcept - :RowFormWidget(look), - display(_display), event_queue(_event_queue) {} - -private: - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, - const PixelRect &rc) noexcept override; -}; +// class SystemMenuWidget final +// : public RowFormWidget +// { +// UI::Display &display; +// UI::EventQueue &event_queue; +// +// public: +// SystemMenuWidget(UI::Display &_display, UI::EventQueue &_event_queue, +// const DialogLook &look) noexcept +// :RowFormWidget(look), +// display(_display), event_queue(_event_queue) {} +// +// private: +// /* virtual methods from class Widget */ +// void Prepare(ContainerWindow &parent, +// const PixelRect &rc) noexcept override; +// }; static void CalibrateSensors() noexcept @@ -209,6 +185,7 @@ try { ShowError(std::current_exception(), "Calibrate Sensors"); } +#if 0 void SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept @@ -252,6 +229,7 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, Run("/usr/lib/openvario/libexec/system_info.sh"); }); } +#endif class MainMenuWidget final : public RowFormWidget @@ -259,7 +237,6 @@ class MainMenuWidget final enum Controls { OPENSOAR, OPENSOAR_CLUB, - OPENSOAR_CLUB2, XCSOAR, LOGBOOK, FILE, @@ -390,11 +367,6 @@ MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, StartOpenSoar(); }); - AddButton("Start OpenSoar (Club2)", [this](){ - CancelTimer(); - StartOpenSoar(); - }); - AddButton("Start XCSoar", [this](){ CancelTimer(); StartXCSoar(); diff --git a/src/OV/Settings.cpp b/src/OV/Settings.cpp new file mode 100644 index 00000000000..416fe005321 --- /dev/null +++ b/src/OV/Settings.cpp @@ -0,0 +1,74 @@ + +#include "OV/Settings.hpp" + +static DialogSettings dialog_settings; +static UI::SingleWindow *global_main_window; +static DialogLook *global_dialog_look; + +const DialogSettings & +UIGlobals::GetDialogSettings() +{ + return dialog_settings; +} + +const DialogLook & +UIGlobals::GetDialogLook() +{ + assert(global_dialog_look != nullptr); + + return *global_dialog_look; +} + +UI::SingleWindow & +UIGlobals::GetMainWindow() +{ + assert(global_main_window != nullptr); + + return *global_main_window; +} + + + +void +SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, + [[maybe_unused]] const PixelRect &rc) noexcept +{ + AddButton("Update System", [](){ + static constexpr const char *argv[] = { + "/usr/bin/update-system.sh", nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Update System", argv); + }); + + AddButton("Update Maps", [](){ + static constexpr const char *argv[] = { + "/usr/bin/update-maps.sh", nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Update Maps", argv); + }); + + AddButton("Calibrate Sensors", CalibrateSensors); + AddButton("Calibrate Touch", [this](){ + const UI::ScopeDropMaster drop_master{display}; + const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; + Run("/usr/bin/ov-calibrate-ts.sh"); + }); + + AddButton("System Settings", [this](){ + const UI::ScopeDropMaster drop_master{display}; + const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; + Run("/usr/lib/openvario/libexec/system_settings.sh"); + }); + + AddButton("System Info", [this](){ + const UI::ScopeDropMaster drop_master{display}; + const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; + Run("/usr/lib/openvario/libexec/system_info.sh"); + }); +} diff --git a/src/OV/Settings.hpp b/src/OV/Settings.hpp new file mode 100644 index 00000000000..15641f4c6d5 --- /dev/null +++ b/src/OV/Settings.hpp @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project + +#pragma once + +#include "Widget/RowFormWidget.hpp" +#include "UIGlobals.hpp" +#include "ui/event/Queue.hpp" +#include "ui/display/Display.hpp" +#include "Look/DialogLook.hpp" + +// static DialogSettings dialog_settings; +// static UI::SingleWindow *global_main_window; +// static DialogLook *global_dialog_look; + +// const DialogSettings &UIGlobals::GetDialogSettings(); +// const DialogLook &UIGlobals::GetDialogLook(); +// UI::SingleWindow &UIGlobals::GetMainWindow(); + + + +class SystemMenuWidget final : public RowFormWidget { + UI::Display &display; + UI::EventQueue &event_queue; + +public: + SystemMenuWidget(UI::Display &_display, UI::EventQueue &_event_queue, + const DialogLook &look) noexcept + : RowFormWidget(look), display(_display), event_queue(_event_queue) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept override; +}; From 4def0c50322274edd81a0755de29a76696fa72e4 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 15 Apr 2024 11:37:03 +0200 Subject: [PATCH 012/403] [build] OpenVarioMenu - add Settings.cpp, move settings functions to this --- build/ov.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/build/ov.mk b/build/ov.mk index bc672150e6e..a8a47732d73 100644 --- a/build/ov.mk +++ b/build/ov.mk @@ -33,6 +33,7 @@ OV_MENU_SOURCES = \ $(TEST_SRC_DIR)/FakeLogFile.cpp \ $(SRC)/Kobo/FakeSymbols.cpp \ $(SRC)/OV/System.cpp \ + $(SRC)/OV/Settings.cpp \ $(SRC)/OV/OpenVarioMenu.cpp OV_MENU_DEPENDS = DBUS WIDGET FORM DATA_FIELD SCREEN EVENT RESOURCE ASYNC LIBNET OS IO THREAD TIME MATH UTIL OV_MENU_STRIP = y From 0c8ec62417219c130748f799ad59d3193d8ad161 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 15 Apr 2024 11:37:36 +0200 Subject: [PATCH 013/403] [CMake] OpenVarioMenu - add Settings.cpp, move settings functions to this --- src/OV/CMakeSource.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/OV/CMakeSource.cmake b/src/OV/CMakeSource.cmake index b310e59cd58..9935a60c13b 100644 --- a/src/OV/CMakeSource.cmake +++ b/src/OV/CMakeSource.cmake @@ -1,6 +1,7 @@ set(_SOURCES - OV/System.cpp OV/OpenVarioMenu.cpp + OV/System.cpp + OV/Settings.cpp ) set(SCRIPT_FILES From 5788a0db50fb8803cecb23bcc2f31c0d3875aa79 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 8 Feb 2024 13:04:51 +0100 Subject: [PATCH 014/403] OV/System.cpp - split between _WIN32 and other OS --- src/OV/System.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/OV/System.cpp b/src/OV/System.cpp index eb8eb70b0d9..a30b8f5f700 100644 --- a/src/OV/System.cpp +++ b/src/OV/System.cpp @@ -2,9 +2,11 @@ // Copyright The XCSoar Project #include "System.hpp" +#ifndef _WIN32 #include "lib/dbus/Connection.hxx" #include "lib/dbus/ScopeMatch.hxx" #include "lib/dbus/Systemd.hxx" +#endif #include "system/FileUtil.hpp" #include "system/Path.hpp" #include "io/KeyValueFileReader.hpp" @@ -15,8 +17,10 @@ #include "DisplayOrientation.hpp" #include "Hardware/RotateDisplay.hpp" +#ifndef _WIN32 #include #include +#endif #include #include From 97791659292c1dc542b9161990394f5b5978c6a2 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 8 Feb 2024 13:06:11 +0100 Subject: [PATCH 015/403] OV/Settings - disable the external code --- src/OV/OpenVarioMenu.cpp | 87 ++++++++++++++++++++++++------------ src/OV/Settings.cpp | 95 ++++++++++++++++++++++++++++++++++++++++ src/OV/Settings.hpp | 6 +++ 3 files changed, 160 insertions(+), 28 deletions(-) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index 937b6991edf..915075e8a6a 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -42,6 +42,34 @@ enum Buttons { static bool have_data_path = false; +#if !OV_SETTINGS +static DialogSettings dialog_settings; +static UI::SingleWindow *global_main_window; +static DialogLook *global_dialog_look; + +const DialogSettings & +UIGlobals::GetDialogSettings() +{ + return dialog_settings; +} + +const DialogLook & +UIGlobals::GetDialogLook() +{ + assert(global_dialog_look != nullptr); + + return *global_dialog_look; +} + +UI::SingleWindow & +UIGlobals::GetMainWindow() +{ + assert(global_main_window != nullptr); + + return *global_main_window; +} +#endif + class FileMenuWidget final : public RowFormWidget @@ -92,23 +120,25 @@ FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, }); } -// class SystemMenuWidget final -// : public RowFormWidget -// { -// UI::Display &display; -// UI::EventQueue &event_queue; -// -// public: -// SystemMenuWidget(UI::Display &_display, UI::EventQueue &_event_queue, -// const DialogLook &look) noexcept -// :RowFormWidget(look), -// display(_display), event_queue(_event_queue) {} -// -// private: -// /* virtual methods from class Widget */ -// void Prepare(ContainerWindow &parent, -// const PixelRect &rc) noexcept override; -// }; +#if !OV_SETTINGS +class SystemMenuWidget final + : public RowFormWidget +{ + UI::Display &display; + UI::EventQueue &event_queue; + +public: + SystemMenuWidget(UI::Display &_display, UI::EventQueue &_event_queue, + const DialogLook &look) noexcept + :RowFormWidget(look), + display(_display), event_queue(_event_queue) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, + const PixelRect &rc) noexcept override; +}; +#endif static void CalibrateSensors() noexcept @@ -185,7 +215,7 @@ try { ShowError(std::current_exception(), "Calibrate Sensors"); } -#if 0 +#if !OV_SETTINGS void SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept @@ -200,15 +230,15 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, "Update System", argv); }); - AddButton("Update Maps", [](){ - static constexpr const char *argv[] = { - "/usr/bin/update-maps.sh", nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - "Update Maps", argv); - }); +// AddButton("Update Maps", [](){ +// static constexpr const char *argv[] = { +// "/usr/bin/update-maps.sh", nullptr +// }; +// +// RunProcessDialog(UIGlobals::GetMainWindow(), +// UIGlobals::GetDialogLook(), +// "Update Maps", argv); +// }); AddButton("Calibrate Sensors", CalibrateSensors); AddButton("Calibrate Touch", [this](){ @@ -226,7 +256,8 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, AddButton("System Info", [this](){ const UI::ScopeDropMaster drop_master{display}; const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; - Run("/usr/lib/openvario/libexec/system_info.sh"); + // Run("/usr/lib/openvario/libexec/system_info.sh"); + Run("/usr/bin/system_info.sh"); }); } #endif diff --git a/src/OV/Settings.cpp b/src/OV/Settings.cpp index 416fe005321..30c099c9f3c 100644 --- a/src/OV/Settings.cpp +++ b/src/OV/Settings.cpp @@ -1,5 +1,12 @@ #include "OV/Settings.hpp" +#include "OV/System.hpp" +#include "Widget/RowFormWidget.hpp" + +#include +#include + +#if OV_SETTINGS static DialogSettings dialog_settings; static UI::SingleWindow *global_main_window; @@ -72,3 +79,91 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, Run("/usr/lib/openvario/libexec/system_info.sh"); }); } + +#endif + +#if OV_SETTINGS + +#include "Profile/File.hpp" +#include "system/FileUtil.hpp" + +class ScreenBrightnessWidget final + : public RowFormWidget +{ + UI::Display &display; + UI::EventQueue &event_queue; + +public: + ScreenBrightnessWidget(UI::Display &_display, UI::EventQueue &_event_queue, + const DialogLook &look) noexcept + :RowFormWidget(look), + display(_display), event_queue(_event_queue) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, + const PixelRect &rc) noexcept override; + + uint_least8_t brightness = 10; + void SaveBrightness(const string &brightness); +}; + +void +ScreenBrightnessWidget::SaveBrightness(const string &brightness) +{ + File::WriteExisting(Path("/sys/class/backlight/lcd/brightness"), (brightness).c_str()); +} + +void +ScreenBrightnessWidget::Prepare([[maybe_unused]] ContainerWindow &parent, + [[maybe_unused]] const PixelRect &rc) noexcept +{ +#if 0 + for (unsigned i = 1; i <= 10; i++) { + // char buffer[10]; + // sprintf // (buffer, "%d", i * 10); + brightness = i; + AddButton(fmt::format_int{i*10}.c_str(), [this]() { + OpenvarioSetBrightness(brightness); // i); + // SaveBrightness("2"); + }); + } +#else + AddButton("20", [this](){ + SaveBrightness("2"); + }); + + AddButton("30", [this](){ + SaveBrightness("3"); + }); + + AddButton("40", [this](){ + SaveBrightness("4"); + }); + + AddButton("50", [this](){ + SaveBrightness("5"); + }); + + AddButton("60", [this](){ + SaveBrightness("6"); + }); + + AddButton("70", [this](){ + SaveBrightness("7"); + }); + + AddButton("80", [this](){ + SaveBrightness("8"); + }); + + AddButton("90", [this](){ + SaveBrightness("9"); + }); + + AddButton("100", [this](){ + SaveBrightness("10"); + }); +#endif +} +#endif diff --git a/src/OV/Settings.hpp b/src/OV/Settings.hpp index 15641f4c6d5..11bd8ee7ac4 100644 --- a/src/OV/Settings.hpp +++ b/src/OV/Settings.hpp @@ -3,6 +3,10 @@ #pragma once +#define OV_SETTINGS 0 + +#if OV_SETTINGS + #include "Widget/RowFormWidget.hpp" #include "UIGlobals.hpp" #include "ui/event/Queue.hpp" @@ -32,3 +36,5 @@ class SystemMenuWidget final : public RowFormWidget { /* virtual methods from class Widget */ void Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept override; }; + +#endif \ No newline at end of file From 6052f86545ddb7ff63594e538b09c4c7e6b02756 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 3 Jan 2024 08:50:29 +0100 Subject: [PATCH 016/403] OpenVarioMenu.cpp - add button 'Firmware Upgrade' - and change buttons 'OpenSoar' with 'OpenSoarClub' --- src/OV/OpenVarioMenu.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index 915075e8a6a..12e1cda48c5 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -220,6 +220,16 @@ void SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { + AddButton("Upgrade Firmware", [](){ + static constexpr const char *argv[] = { + "/usr/bin/fw-upgrade.sh", nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Upgrade Firmware", argv); + }); + AddButton("Update System", [](){ static constexpr const char *argv[] = { "/usr/bin/update-system.sh", nullptr @@ -266,8 +276,8 @@ class MainMenuWidget final : public RowFormWidget { enum Controls { - OPENSOAR, OPENSOAR_CLUB, + OPENSOAR, XCSOAR, LOGBOOK, FILE, @@ -388,12 +398,12 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { - AddButton("Start OpenSoar", [this](){ + AddButton("Start OpenSoar (Club)", [this]() { CancelTimer(); StartOpenSoar(); }); - AddButton("Start OpenSoar (Club)", [this](){ + AddButton("Start OpenSoar", [this]() { CancelTimer(); StartOpenSoar(); }); From 88e8e6426a49d654485493c0abbcec840650d124 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 3 Jan 2024 08:54:22 +0100 Subject: [PATCH 017/403] OpenVarioMenu.cpp - correction Upload button --- src/OV/OpenVarioMenu.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index 12e1cda48c5..2f8a174683c 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -109,9 +109,9 @@ FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, "Downloading files", argv); }); - AddButton("Upload files from USB to XCSoar", [](){ + AddButton("Upload files from USB to OpenSoar", [](){ static constexpr const char *argv[] = { - "/usr/bin/upload-xcsoar.sh", nullptr + "/usr/bin/transfers.sh upload-data OpenSoar", nullptr }; RunProcessDialog(UIGlobals::GetMainWindow(), From 87d496e01943dba57ee54c72e7e12c3b8b50b08a Mon Sep 17 00:00:00 2001 From: Blaubart Date: Thu, 20 Apr 2023 18:22:25 +0200 Subject: [PATCH 018/403] [build] ov.mk add necessary files --- build/ov.mk | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/build/ov.mk b/build/ov.mk index a8a47732d73..ef0aa0487bd 100644 --- a/build/ov.mk +++ b/build/ov.mk @@ -1,13 +1,12 @@ OV_MENU_SOURCES = \ $(SRC)/Version.cpp \ $(SRC)/Asset.cpp \ - $(SRC)/LocalPath.cpp \ - $(SRC)/FlightInfo.cpp \ $(SRC)/Formatter/HexColor.cpp \ $(SRC)/Formatter/TimeFormatter.cpp \ $(SRC)/Hardware/CPU.cpp \ $(SRC)/Hardware/DisplayDPI.cpp \ $(SRC)/Hardware/RotateDisplay.cpp \ + $(SRC)/Hardware/DisplayGlue.cpp \ $(SRC)/Screen/Layout.cpp \ $(SRC)/ui/control/TerminalWindow.cpp \ $(SRC)/Look/TerminalLook.cpp \ @@ -15,8 +14,6 @@ OV_MENU_SOURCES = \ $(SRC)/Look/ButtonLook.cpp \ $(SRC)/Look/CheckBoxLook.cpp \ $(SRC)/Renderer/TwoTextRowsRenderer.cpp \ - $(SRC)/Renderer/FlightListRenderer.cpp \ - $(SRC)/Logger/FlightParser.cpp \ $(SRC)/Gauge/LogoView.cpp \ $(SRC)/Dialogs/DialogSettings.cpp \ $(SRC)/Dialogs/WidgetDialog.cpp \ @@ -27,15 +24,15 @@ OV_MENU_SOURCES = \ $(SRC)/Dialogs/KnobTextEntry.cpp \ $(SRC)/Dialogs/TouchTextEntry.cpp \ $(SRC)/Dialogs/ProcessDialog.cpp \ - $(SRC)/Dialogs/Error.cpp \ + $(SRC)/Profile/Map.cpp \ + $(SRC)/Profile/File.cpp \ + $(SRC)/Profile/NumericValue.cpp \ $(TEST_SRC_DIR)/Fonts.cpp \ $(TEST_SRC_DIR)/FakeLanguage.cpp \ $(TEST_SRC_DIR)/FakeLogFile.cpp \ $(SRC)/Kobo/FakeSymbols.cpp \ - $(SRC)/OV/System.cpp \ - $(SRC)/OV/Settings.cpp \ $(SRC)/OV/OpenVarioMenu.cpp -OV_MENU_DEPENDS = DBUS WIDGET FORM DATA_FIELD SCREEN EVENT RESOURCE ASYNC LIBNET OS IO THREAD TIME MATH UTIL +OV_MENU_DEPENDS = WIDGET FORM DATA_FIELD SCREEN EVENT RESOURCE ASYNC LIBNET OS IO THREAD TIME MATH UTIL OV_MENU_STRIP = y $(eval $(call link-program,OpenVarioMenu,OV_MENU)) From 791a0a05f076af745e20c8c972736364e28aa7d4 Mon Sep 17 00:00:00 2001 From: Blaubart Date: Thu, 20 Apr 2023 18:24:35 +0200 Subject: [PATCH 019/403] change command to exit to shell # Conflicts: # src/OV/OpenVarioMenu.cpp --- src/OV/OpenVarioMenu.cpp | 184 +++++++-------------------------------- 1 file changed, 33 insertions(+), 151 deletions(-) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index 2f8a174683c..26186c05642 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -5,44 +5,25 @@ #include "Dialogs/Message.hpp" #include "Dialogs/WidgetDialog.hpp" #include "Dialogs/ProcessDialog.hpp" -#include "Dialogs/Error.hpp" -#include "Widget/DrawWidget.hpp" #include "Widget/RowFormWidget.hpp" -#include "Renderer/FlightListRenderer.hpp" #include "UIGlobals.hpp" #include "Look/DialogLook.hpp" #include "Screen/Layout.hpp" #include "../test/src/Fonts.hpp" -#include "ui/canvas/Canvas.hpp" #include "ui/window/Init.hpp" #include "ui/window/SingleWindow.hpp" #include "ui/event/Queue.hpp" #include "ui/event/Timer.hpp" -#include "Logger/FlightParser.hpp" #include "Language/Language.hpp" -#include "lib/dbus/Connection.hxx" -#include "lib/dbus/ScopeMatch.hxx" -#include "lib/dbus/Systemd.hxx" #include "system/Process.hpp" -#include "io/FileLineReader.hpp" -#include "util/PrintException.hxx" #include "util/ScopeExit.hxx" -#include "LocalPath.hpp" -#include "OV/System.hpp" -#include "OV/Settings.hpp" #include -#include -#include -#include enum Buttons { LAUNCH_SHELL = 100, }; -static bool have_data_path = false; - -#if !OV_SETTINGS static DialogSettings dialog_settings; static UI::SingleWindow *global_main_window; static DialogLook *global_dialog_look; @@ -68,8 +49,6 @@ UIGlobals::GetMainWindow() return *global_main_window; } -#endif - class FileMenuWidget final : public RowFormWidget @@ -109,9 +88,9 @@ FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, "Downloading files", argv); }); - AddButton("Upload files from USB to OpenSoar", [](){ + AddButton("Upload files from USB to XCSoar", [](){ static constexpr const char *argv[] = { - "/usr/bin/transfers.sh upload-data OpenSoar", nullptr + "/usr/bin/upload-xcsoar.sh", nullptr }; RunProcessDialog(UIGlobals::GetMainWindow(), @@ -120,7 +99,6 @@ FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, }); } -#if !OV_SETTINGS class SystemMenuWidget final : public RowFormWidget { @@ -138,30 +116,32 @@ class SystemMenuWidget final void Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept override; }; -#endif static void CalibrateSensors() noexcept -try { +{ /* make sure sensord is stopped while calibrating sensors */ - auto connection = ODBus::Connection::GetSystem(); - const ODBus::ScopeMatch job_removed_match{connection, Systemd::job_removed_match}; - - bool has_sensord = false; - - if (Systemd::IsUnitActive(connection, "sensord.socket")) { - has_sensord = true; + static constexpr const char *start_sensord[] = { + "/bin/systemctl", "start", "sensord.service", nullptr + }; + static constexpr const char *stop_sensord[] = { + "/bin/systemctl", "stop", "sensord.service", nullptr + }; - try { - Systemd::StopUnit(connection, "sensord.socket"); - } catch (...) { - std::throw_with_nested(std::runtime_error{"Failed to stop sensord"}); - } - } + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Calibrate Sensors", stop_sensord, + [](int status){ + return status == EXIT_SUCCESS ? mrOK : 0; + }); - AtScopeExit(&connection, has_sensord){ - if (has_sensord) - Systemd::StartUnit(connection, "sensord.socket"); + AtScopeExit(){ + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Calibrate Sensors", start_sensord, + [](int status){ + return status == EXIT_SUCCESS ? mrOK : 0; + }); }; /* calibrate the sensors */ @@ -211,45 +191,32 @@ try { ? RESULT_BOARD_NOT_INITIALISED : 0; }); -} catch (...) { - ShowError(std::current_exception(), "Calibrate Sensors"); } -#if !OV_SETTINGS void SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { - AddButton("Upgrade Firmware", [](){ + AddButton("Update System", [](){ static constexpr const char *argv[] = { - "/usr/bin/fw-upgrade.sh", nullptr + "/usr/bin/update-system.sh", nullptr }; RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "Upgrade Firmware", argv); + "Update System", argv); }); - AddButton("Update System", [](){ + AddButton("Update Maps", [](){ static constexpr const char *argv[] = { - "/usr/bin/update-system.sh", nullptr + "/usr/bin/update-maps.sh", nullptr }; RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "Update System", argv); + "Update Maps", argv); }); -// AddButton("Update Maps", [](){ -// static constexpr const char *argv[] = { -// "/usr/bin/update-maps.sh", nullptr -// }; -// -// RunProcessDialog(UIGlobals::GetMainWindow(), -// UIGlobals::GetDialogLook(), -// "Update Maps", argv); -// }); - AddButton("Calibrate Sensors", CalibrateSensors); AddButton("Calibrate Touch", [this](){ const UI::ScopeDropMaster drop_master{display}; @@ -266,20 +233,15 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, AddButton("System Info", [this](){ const UI::ScopeDropMaster drop_master{display}; const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; - // Run("/usr/lib/openvario/libexec/system_info.sh"); - Run("/usr/bin/system_info.sh"); + Run("/usr/lib/openvario/libexec/system_info.sh"); }); } -#endif class MainMenuWidget final : public RowFormWidget { enum Controls { - OPENSOAR_CLUB, - OPENSOAR, XCSOAR, - LOGBOOK, FILE, SYSTEM, SHELL, @@ -296,8 +258,7 @@ class MainMenuWidget final UI::Timer timer{[this](){ if (--remaining_seconds == 0) { HideRow(Controls::TIMER); - // StartXCSoar(); - StartOpenSoar(); + StartXCSoar(); } else { ScheduleTimer(); } @@ -318,12 +279,6 @@ class MainMenuWidget final const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; Run("/usr/bin/xcsoar", "-fly"); } - void StartOpenSoar() noexcept { - const UI::ScopeDropMaster drop_master{display}; - const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; - // Run("/usr/bin/OpenSoar", "-fly"); - Run("/usr/bin/OpenSoar", "-fly", "-datapath=/home/root/data/OpenSoarData"); - } void ScheduleTimer() noexcept { assert(remaining_seconds > 0); @@ -364,69 +319,21 @@ class MainMenuWidget final } }; -static void -ShowLogbook() noexcept -{ - const auto &look = UIGlobals::GetDialogLook(); - FlightListRenderer renderer{look.text_font, look.bold_font}; - - try { - FileLineReaderA file(LocalPath("flights.log")); - - FlightParser parser{file}; - FlightInfo flight; - while (parser.Read(flight)) - renderer.AddFlight(flight); - } catch (...) { - ShowError(std::current_exception(), "Logbook"); - return; - } - - TWidgetDialog - sub_dialog(WidgetDialog::Full{}, UIGlobals::GetMainWindow(), - look, "Logbook"); - - sub_dialog.SetWidget([&renderer](Canvas &canvas, const PixelRect &rc){ - renderer.Draw(canvas, rc); - }); - - sub_dialog.AddButton(_("Close"), mrOK); - sub_dialog.ShowModal(); -} - void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { - AddButton("Start OpenSoar (Club)", [this]() { - CancelTimer(); - StartOpenSoar(); - }); - - AddButton("Start OpenSoar", [this]() { - CancelTimer(); - StartOpenSoar(); - }); - AddButton("Start XCSoar", [this](){ CancelTimer(); StartXCSoar(); }); - if (have_data_path) - AddButton("Logbook", [this](){ - CancelTimer(); - ShowLogbook(); - }); - else - AddDummy(); - - AddButton("Files", [this](){ + AddButton("File", [this](){ CancelTimer(); TWidgetDialog sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), "OpenVario Files"); + GetLook(), "OpenVario File"); sub_dialog.SetWidget(display, event_queue, GetLook()); sub_dialog.AddButton(_("Close"), mrOK); return sub_dialog.ShowModal(); @@ -456,8 +363,6 @@ MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, }); AddReadOnly(""); - - HideRow(Controls::OPENSOAR_CLUB); } static int @@ -487,14 +392,8 @@ Main() UI::TopWindowStyle main_style; main_style.Resizable(); - DisplayOrientation orientation = DisplayOrientation::DEFAULT; - try { - orientation = OpenvarioGetRotation(); - } catch (...) {} - main_style.InitialOrientation(orientation); - UI::SingleWindow main_window{screen_init.GetDisplay()}; - main_window.Create(_T("XCSoar/OpenVarioMenu"), {600, 800}, main_style); + main_window.Create(_T("XCSoar/KoboMenu"), {600, 800}, main_style); main_window.Show(); global_dialog_look = &dialog_look; @@ -511,23 +410,6 @@ Main() int main() { - std::filesystem::current_path("/home/root"); // setting path - /*the x-menu is waiting a second to solve timing problem with display rotation */ - std::this_thread::sleep_for(std::chrono::seconds(1)); - - try { - InitialiseDataPath(); - have_data_path = true; - } catch (...) { - fprintf(stderr, "Failed to locate data path: "); - PrintException(std::current_exception()); - } - - AtScopeExit() { - if (have_data_path) - DeinitialiseDataPath(); - }; - int action = Main(); switch (action) { From 1e2293c1736636b124675e3b6a1c7e279f419067 Mon Sep 17 00:00:00 2001 From: Blaubart Date: Thu, 20 Apr 2023 18:27:27 +0200 Subject: [PATCH 020/403] remove timing problem when starting menu when the menu starts, the display rotates incorrectly every now and then. This is fixed by the 1s wait time on startup. --- src/OV/OpenVarioMenu.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index 26186c05642..001b3937fd7 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -410,6 +410,14 @@ Main() int main() { + /*the x-menu is waiting a second to solve timing problem with display rotation */ + std::chrono::high_resolution_clock hrc; + auto start = hrc.now(); + while(std::chrono::duration_cast(hrc.now() - start).count() < 1000) + { + //I'm just waiting ;-) + } + int action = Main(); switch (action) { From 7bb3e62ca258d84641af184fb91a8c77ec8713e2 Mon Sep 17 00:00:00 2001 From: Blaubart Date: Thu, 20 Apr 2023 18:29:33 +0200 Subject: [PATCH 021/403] initial display rotation The menu rotates correctly on startup --- src/OV/OpenVarioMenu.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index 001b3937fd7..f859b852b81 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -391,6 +391,7 @@ Main() UI::TopWindowStyle main_style; main_style.Resizable(); + main_style.InitialOrientation(Display::DetectInitialOrientation()); UI::SingleWindow main_window{screen_init.GetDisplay()}; main_window.Create(_T("XCSoar/KoboMenu"), {600, 800}, main_style); From 561ae4cf0f962a9e79f3d3a7088f7d4da6725043 Mon Sep 17 00:00:00 2001 From: Blaubart Date: Thu, 20 Apr 2023 18:30:51 +0200 Subject: [PATCH 022/403] change button label from file to files --- src/OV/OpenVarioMenu.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index f859b852b81..7eb2e4a3f2d 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -328,12 +328,12 @@ MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, StartXCSoar(); }); - AddButton("File", [this](){ + AddButton("Files", [this](){ CancelTimer(); TWidgetDialog sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), "OpenVario File"); + GetLook(), "OpenVario Files"); sub_dialog.SetWidget(display, event_queue, GetLook()); sub_dialog.AddButton(_("Close"), mrOK); return sub_dialog.ShowModal(); From 042bc71e1a55ddf66c068c8f55c793f806d9c4d6 Mon Sep 17 00:00:00 2001 From: Blaubart Date: Thu, 20 Apr 2023 18:32:49 +0200 Subject: [PATCH 023/403] new button "Logbook" the logbook is currently a test version based on a shell script. This still has to be implemented with functions already integrated in XCSoar. It's on the to-do list --- src/OV/OpenVarioMenu.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index 7eb2e4a3f2d..bf9201be682 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -328,6 +328,17 @@ MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, StartXCSoar(); }); + AddButton("Logbook", [this](){ + CancelTimer(); + static constexpr const char *argv[] = { + "/usr/bin/logbook.sh", nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Logbook", argv); + }); + AddButton("Files", [this](){ CancelTimer(); From db0d2740023192e7d59f69456b3e5e1abc2fb031 Mon Sep 17 00:00:00 2001 From: Blaubart Date: Thu, 20 Apr 2023 18:35:16 +0200 Subject: [PATCH 024/403] ignore the ESC key in the top menu level ignore the ESC key in the top menu level. Previously the menu was closed by pressing the ESC key and restarted --- src/OV/OpenVarioMenu.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index bf9201be682..6c299bfe462 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -315,7 +315,14 @@ class MainMenuWidget final bool KeyPress(unsigned key_code) noexcept override { CancelTimer(); - return RowFormWidget::KeyPress(key_code); + + /* ignore escape key at first menu page */ + if (key_code != KEY_ESCAPE) { + return RowFormWidget::KeyPress(key_code); + } + else { + return true; + } } }; From 2fc4fd21489903117cc66c0185cdbbb2ce3a6d35 Mon Sep 17 00:00:00 2001 From: Blaubart Date: Thu, 20 Apr 2023 18:36:18 +0200 Subject: [PATCH 025/403] [Bugfix] - start XCSoar if timeout is 0s XCSoar didn't start, if timeout was set to immediately --- src/OV/OpenVarioMenu.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index 6c299bfe462..59259cc810f 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -304,8 +304,13 @@ class MainMenuWidget final void Show(const PixelRect &rc) noexcept override { RowFormWidget::Show(rc); - if (remaining_seconds > 0) + if (remaining_seconds > 0) { ScheduleTimer(); + } + else { + HideRow(Controls::TIMER); + StartXCSoar(); + } } void Hide() noexcept override { From cacfe1bc752dd92f593b1705ac21e7c89621a9d4 Mon Sep 17 00:00:00 2001 From: Blaubart Date: Thu, 20 Apr 2023 18:40:18 +0200 Subject: [PATCH 026/403] changes for the timeout value - Load the timeout value from the config - furthermore, remaining_seconds is defined as an integer --- src/OV/OpenVarioMenu.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index 59259cc810f..ec9f3eed8ea 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -240,6 +240,8 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, class MainMenuWidget final : public RowFormWidget { + int remaining_seconds = 3; + enum Controls { XCSOAR, FILE, @@ -264,14 +266,15 @@ class MainMenuWidget final } }}; - unsigned remaining_seconds = 3; - public: MainMenuWidget(UI::Display &_display, UI::EventQueue &_event_queue, WndForm &_dialog) noexcept :RowFormWidget(_dialog.GetLook()), display(_display), event_queue(_event_queue), - dialog(_dialog) {} + dialog(_dialog) + { + GetConfigInt("timeout", remaining_seconds, "/boot/config.uEnv"); + } private: void StartXCSoar() noexcept { From 5a3c2720a2037c39d1ae920d2ca94424e4520fd8 Mon Sep 17 00:00:00 2001 From: Blaubart Date: Thu, 20 Apr 2023 18:42:05 +0200 Subject: [PATCH 027/403] "System Info" button loads the correct script --- src/OV/OpenVarioMenu.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index ec9f3eed8ea..0b1ced34e3c 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -230,10 +230,14 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, Run("/usr/lib/openvario/libexec/system_settings.sh"); }); - AddButton("System Info", [this](){ - const UI::ScopeDropMaster drop_master{display}; - const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; - Run("/usr/lib/openvario/libexec/system_info.sh"); + AddButton("System Info", [](){ + static constexpr const char *argv[] = { + "/usr/bin/system-info.sh", nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "System Info", argv); }); } From fd986249ca107fec1e1961c6ef74cef4c91bd64a Mon Sep 17 00:00:00 2001 From: Blaubart Date: Thu, 20 Apr 2023 18:44:01 +0200 Subject: [PATCH 028/403] "System Settings" button changed it will now bring up the newly created "System Settings" submenu --- src/OV/OpenVarioMenu.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index 0b1ced34e3c..dec05070a6a 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -225,10 +225,14 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, }); AddButton("System Settings", [this](){ - const UI::ScopeDropMaster drop_master{display}; - const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; - Run("/usr/lib/openvario/libexec/system_settings.sh"); - }); + + TWidgetDialog + sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), + GetLook(), "OpenVario System Settings"); + sub_dialog.SetWidget(display, event_queue, sub_dialog); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); + }); AddButton("System Info", [](){ static constexpr const char *argv[] = { From 1f567fc0f953bc7bf3b93cf80d09b2641041efd1 Mon Sep 17 00:00:00 2001 From: Blaubart Date: Thu, 20 Apr 2023 18:46:37 +0200 Subject: [PATCH 029/403] Removed "Update Maps" from the system menu this submenu belongs to the submenu "Files" --- src/OV/OpenVarioMenu.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index dec05070a6a..3160ae78748 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -207,16 +207,6 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, "Update System", argv); }); - AddButton("Update Maps", [](){ - static constexpr const char *argv[] = { - "/usr/bin/update-maps.sh", nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - "Update Maps", argv); - }); - AddButton("Calibrate Sensors", CalibrateSensors); AddButton("Calibrate Touch", [this](){ const UI::ScopeDropMaster drop_master{display}; From f88f7c3b656c87025a06555260d1cd3f56089cf8 Mon Sep 17 00:00:00 2001 From: Blaubart Date: Thu, 20 Apr 2023 18:48:36 +0200 Subject: [PATCH 030/403] "WiFi Settings" button created this is a placeholder. The corresponding menu still has to be programmed. It's on the to-do list --- src/OV/OpenVarioMenu.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index 3160ae78748..e5b0cd0d26e 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -197,6 +197,18 @@ void SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { + AddButton("WiFi Settings", [](){ + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "printf '\nWiFi-Settings are not implemented, yet!! \n\nIf you are interessted to help with this, write me an email: dirk@freevario.de'", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "WiFi Settings", argv); + }); + AddButton("Update System", [](){ static constexpr const char *argv[] = { "/usr/bin/update-system.sh", nullptr From b39e92d2c60c529a58df06ff4372e2a81db0ed0c Mon Sep 17 00:00:00 2001 From: Blaubart Date: Thu, 20 Apr 2023 18:50:29 +0200 Subject: [PATCH 031/403] Adjustments for the Settings menu so that the submenus are loaded correctly --- src/OV/OpenVarioMenu.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index e5b0cd0d26e..b244973aacb 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -105,11 +105,14 @@ class SystemMenuWidget final UI::Display &display; UI::EventQueue &event_queue; + WndForm &dialog; + public: SystemMenuWidget(UI::Display &_display, UI::EventQueue &_event_queue, - const DialogLook &look) noexcept - :RowFormWidget(look), - display(_display), event_queue(_event_queue) {} + WndForm &_dialog) noexcept + :RowFormWidget(_dialog.GetLook()), + display(_display), event_queue(_event_queue), + dialog(_dialog) {} private: /* virtual methods from class Widget */ From 0b38e81d2ee2b16afc4571daa3c84a9afd1bc156 Mon Sep 17 00:00:00 2001 From: Blaubart Date: Thu, 20 Apr 2023 18:54:07 +0200 Subject: [PATCH 032/403] [OV] insert SubMenu "SystemSettings" --- src/OV/OpenVarioMenu.cpp | 89 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index b244973aacb..740d73fe8b1 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -99,6 +99,95 @@ FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, }); } +class SystemSettingsWidget final + : public RowFormWidget +{ + UI::Display &display; + UI::EventQueue &event_queue; + + WndForm &dialog; + +public: + SystemSettingsWidget(UI::Display &_display, UI::EventQueue &_event_queue, + WndForm &_dialog) noexcept + :RowFormWidget(_dialog.GetLook()), + display(_display), event_queue(_event_queue), + dialog(_dialog) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, + const PixelRect &rc) noexcept override; +}; + +void +SystemSettingsWidget::Prepare([[maybe_unused]] ContainerWindow &parent, + [[maybe_unused]] const PixelRect &rc) noexcept +{ + AddButton("Screen Rotation", [this](){ + TWidgetDialog + sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), + GetLook(), "Display Rotation Settings"); + sub_dialog.SetWidget(display, event_queue, GetLook()); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); + }); + + AddButton("Screen Brightness", [this](){ + TWidgetDialog + sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), + GetLook(), "Display Brightness Settings"); + sub_dialog.SetWidget(display, event_queue, GetLook()); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); + }); + + AddButton("Language", [this](){ + TWidgetDialog + sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), + GetLook(), "Language Settings"); + sub_dialog.SetWidget(display, event_queue, GetLook()); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); + }); + + AddButton("Autostart Timeout", [this](){ + TWidgetDialog + sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), + GetLook(), "Autostart Timeout"); + sub_dialog.SetWidget(display, event_queue, GetLook()); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); + }); + + AddButton("SSH", [this](){ + TWidgetDialog + sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), + GetLook(), "Enable or Disable SSH"); + sub_dialog.SetWidget(display, event_queue, GetLook()); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); + }); + + AddButton("Variod", [this](){ + TWidgetDialog + sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), + GetLook(), "Enable or Disable Variod"); + sub_dialog.SetWidget(display, event_queue, GetLook()); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); + }); + + AddButton("Sensord", [this](){ + TWidgetDialog + sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), + GetLook(), "Enable or Disable Sensord"); + sub_dialog.SetWidget(display, event_queue, GetLook()); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); + }); +} + class SystemMenuWidget final : public RowFormWidget { From b7632db7eb919aa198fc3f733cc6e1c1ccf51c83 Mon Sep 17 00:00:00 2001 From: Blaubart Date: Thu, 20 Apr 2023 18:57:00 +0200 Subject: [PATCH 033/403] Menu for activating or deactivating SSH, variod, sensord --- src/OV/OpenVarioMenu.cpp | 95 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index 740d73fe8b1..09a190c4045 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -99,6 +99,101 @@ FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, }); } +class ScreenSSHWidget final + : public RowFormWidget +{ + UI::Display &display; + UI::EventQueue &event_queue; + +public: + ScreenSSHWidget(UI::Display &_display, UI::EventQueue &_event_queue, + const DialogLook &look) noexcept + :RowFormWidget(look), + display(_display), event_queue(_event_queue) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, + const PixelRect &rc) noexcept override; +}; + +void +ScreenSSHWidget::Prepare([[maybe_unused]] ContainerWindow &parent, + [[maybe_unused]] const PixelRect &rc) noexcept +{ + AddButton("Enable", [](){ + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "systemctl enable dropbear.socket && printf '\nSSH has been enabled'", + + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Enable", argv); + }); + + AddButton("Disable", [](){ + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "systemctl disable dropbear.socket && printf '\nSSH has been disabled'", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Disable", argv); + }); +} + +class ScreenVariodWidget final + : public RowFormWidget +{ + UI::Display &display; + UI::EventQueue &event_queue; + +public: + ScreenVariodWidget(UI::Display &_display, UI::EventQueue &_event_queue, + const DialogLook &look) noexcept + :RowFormWidget(look), + display(_display), event_queue(_event_queue) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, + const PixelRect &rc) noexcept override; +}; + +void +ScreenVariodWidget::Prepare([[maybe_unused]] ContainerWindow &parent, + [[maybe_unused]] const PixelRect &rc) noexcept +{ + AddButton("Enable", [](){ + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "systemctl enable variod && printf '\nvariod has been enabled'", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Enable", argv); + }); + + AddButton("Disable", [](){ + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "systemctl disable variod && printf '\nvariod has been disabled'", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Disable", argv); + }); +} + class SystemSettingsWidget final : public RowFormWidget { From d3db27f42511790acbc2e4888750de12eec60b66 Mon Sep 17 00:00:00 2001 From: Blaubart Date: Thu, 20 Apr 2023 18:58:11 +0200 Subject: [PATCH 034/403] Added the submenu for setting the timeout value --- src/OV/OpenVarioMenu.cpp | 109 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index 09a190c4045..d63c492de7f 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -99,6 +99,115 @@ FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, }); } +class ScreenTimeoutWidget final + : public RowFormWidget +{ + UI::Display &display; + UI::EventQueue &event_queue; + +public: + ScreenTimeoutWidget(UI::Display &_display, UI::EventQueue &_event_queue, + const DialogLook &look) noexcept + :RowFormWidget(look), + display(_display), event_queue(_event_queue) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, + const PixelRect &rc) noexcept override; + void SaveTimeout(int timeoutvalue); +}; + +void +ScreenTimeoutWidget::SaveTimeout(int timeoutInt) +{ + ChangeConfigInt("timeout", timeoutInt, "/boot/config.uEnv"); +} + +void +ScreenTimeoutWidget::Prepare([[maybe_unused]] ContainerWindow &parent, + [[maybe_unused]] const PixelRect &rc) noexcept + +{ + AddButton("immediately", [this](){ + SaveTimeout(0); + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "echo Automatic timeout was set to 0s", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "immediately", argv); + }); + + AddButton("1s", [this](){ + SaveTimeout(1); + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "echo Automatic timeout was set to 1s", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "1s", argv); + }); + + AddButton("3s", [this](){ + SaveTimeout(3); + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "echo Automatic timeout was set to 3s", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "3s", argv); + }); + + AddButton("5s", [this](){ + SaveTimeout(5); + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "echo Automatic timeout was set to 5s", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "5s", argv); + }); + + AddButton("10s", [this](){ + SaveTimeout(10); + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "echo Automatic timeout was set to 10s", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "10s", argv); + }); + + AddButton("30s", [this](){ + SaveTimeout(30); + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "echo Automatic timeout was set to 30s", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "30s", argv); + }); +} + class ScreenSSHWidget final : public RowFormWidget { From 1384665ec90c720578bd405141d1dca37be054d7 Mon Sep 17 00:00:00 2001 From: Blaubart Date: Thu, 20 Apr 2023 19:00:31 +0200 Subject: [PATCH 035/403] Implementation of the submenu for setting the language this is a pre-release. In the future, this must be implemented with a correct menu using XCSoar's onboard methods (DataFieldEnum). It's on the to-do list --- src/OV/OpenVarioMenu.cpp | 180 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 180 insertions(+) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index d63c492de7f..2fd324a81d6 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -99,6 +99,186 @@ FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, }); } +class ScreenLanguageWidget final + : public RowFormWidget +{ + UI::Display &display; + UI::EventQueue &event_queue; + +public: + ScreenLanguageWidget(UI::Display &_display, UI::EventQueue &_event_queue, + const DialogLook &look) noexcept + :RowFormWidget(look), + display(_display), event_queue(_event_queue) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, + const PixelRect &rc) noexcept override; + +}; + +void +ScreenLanguageWidget::Prepare([[maybe_unused]] ContainerWindow &parent, + [[maybe_unused]] const PixelRect &rc) noexcept +{ + AddButton("English", [this](){ + ChangeConfigString("LANG", "en_EN.UTF-8", "/etc/locale.conf"); + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "echo The language has been set to English", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Englisch", argv); + }); + + AddButton("Deutsch", [this](){ + ChangeConfigString("LANG", "de_DE.UTF-8", "/etc/locale.conf"); + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "echo The language has been set to German", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Deutsch", argv); + }); + + AddButton("Français", [this](){ + ChangeConfigString("LANG", "fr_FR.UTF-8", "/etc/locale.conf"); + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "echo The language has been set to French", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Français", argv); + }); + + AddButton("Italiano", [this](){ + ChangeConfigString("LANG", "it_IT.UTF-8", "/etc/locale.conf"); + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "echo The language has been set to Italian", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Italiano", argv); + }); + + AddButton("Magyar", [this](){; + ChangeConfigString("LANG", "hu_HU.UTF-8", "/etc/locale.conf"); + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "echo The language has been set to Hungarian", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Magyar", argv); + }); + + AddButton("Polski", [this](){ + ChangeConfigString("LANG", "pl_PL.UTF-8", "/etc/locale.conf"); + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "echo The language has been set to Polish", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Polski", argv); + }); + + AddButton("ÄŒeÅ¡tina", [this](){ + ChangeConfigString("LANG", "cs_CZ.UTF-8", "/etc/locale.conf"); + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "echo The language has been set to Czech", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "ÄŒeÅ¡tina", argv); + }); + + AddButton("SlovenÄina", [this](){ + ChangeConfigString("LANG", "sk_SK.UTF-8", "/etc/locale.conf"); + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "echo The language has been set to Slovak", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "SlovenÄina", argv); + }); + + AddButton("Lietuvių", [this](){ + ChangeConfigString("LANG", "lt_LT.UTF-8", "/etc/locale.conf"); + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "echo The language has been set to Lithuanian", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Lietuvių", argv); + }); + + AddButton("РуÑÑкий", [this](){ + ChangeConfigString("LANG", "ru_RU.UTF-8", "/etc/locale.conf"); + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "echo The language has been set to Russian", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "РуÑÑкий", argv); + }); + + AddButton("Español", [this](){ + ChangeConfigString("LANG", "es_ES.UTF-8", "/etc/locale.conf"); + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "echo The language has been set to Spanish", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Español", argv); + }); + + AddButton("Dutch", [this](){ + ChangeConfigString("LANG", "nl_NL.UTF-8", "/etc/locale.conf"); + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "echo The language has been set to Dutch", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Dutch", argv); + }); +} + class ScreenTimeoutWidget final : public RowFormWidget { From 3c5f5af3f38c26a88df933f97cc62bb215b763fb Mon Sep 17 00:00:00 2001 From: Blaubart Date: Thu, 20 Apr 2023 19:01:41 +0200 Subject: [PATCH 036/403] build in the submenu for setting the display brightness --- src/OV/OpenVarioMenu.cpp | 67 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index 2fd324a81d6..d283e959fa5 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -99,6 +99,73 @@ FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, }); } +class ScreenBrightnessWidget final + : public RowFormWidget +{ + UI::Display &display; + UI::EventQueue &event_queue; + +public: + ScreenBrightnessWidget(UI::Display &_display, UI::EventQueue &_event_queue, + const DialogLook &look) noexcept + :RowFormWidget(look), + display(_display), event_queue(_event_queue) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, + const PixelRect &rc) noexcept override; + +void SaveBrightness(const string &brightness); +}; + +void +ScreenBrightnessWidget::SaveBrightness(const string &brightness) +{ + File::WriteExisting(Path("/sys/class/backlight/lcd/brightness"), (brightness).c_str()); +} + +void +ScreenBrightnessWidget::Prepare([[maybe_unused]] ContainerWindow &parent, + [[maybe_unused]] const PixelRect &rc) noexcept +{ + AddButton("20", [this](){ + SaveBrightness("2"); + }); + + AddButton("30", [this](){ + SaveBrightness("3"); + }); + + AddButton("40", [this](){ + SaveBrightness("4"); + }); + + AddButton("50", [this](){ + SaveBrightness("5"); + }); + + AddButton("60", [this](){ + SaveBrightness("6"); + }); + + AddButton("70", [this](){ + SaveBrightness("7"); + }); + + AddButton("80", [this](){ + SaveBrightness("8"); + }); + + AddButton("90", [this](){ + SaveBrightness("9"); + }); + + AddButton("100", [this](){ + SaveBrightness("10"); + }); +} + class ScreenLanguageWidget final : public RowFormWidget { From 7a096b86c8167ce8371b20e015697d5cddcf780b Mon Sep 17 00:00:00 2001 From: Blaubart Date: Thu, 20 Apr 2023 19:02:28 +0200 Subject: [PATCH 037/403] build in the submenu for setting the display rotation --- src/OV/OpenVarioMenu.cpp | 54 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index d283e959fa5..62b67edf7e8 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -99,6 +99,60 @@ FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, }); } +class ScreenRotationWidget final + : public RowFormWidget +{ + UI::Display &display; + UI::EventQueue &event_queue; + +public: + ScreenRotationWidget(UI::Display &_display, UI::EventQueue &_event_queue, + const DialogLook &look) noexcept + :RowFormWidget(look), + display(_display), event_queue(_event_queue) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, + const PixelRect &rc) noexcept override; + void SaveRotation(const string &rotationvalue); +}; + +/* x-menu writes the value for the display rotation to /sys because the value is also required for the console in the OpenVario. +In addition, the display rotation is saved in /boot/config.uEnv so that the Openvario sets the correct rotation again when it is restarted.*/ +void +ScreenRotationWidget::SaveRotation(const string &rotationString) +{ + File::WriteExisting(Path("/sys/class/graphics/fbcon/rotate"), (rotationString).c_str()); + int rotationInt = stoi(rotationString); + ChangeConfigInt("rotation", rotationInt, "/boot/config.uEnv"); +} + +void +ScreenRotationWidget::Prepare([[maybe_unused]] ContainerWindow &parent, + [[maybe_unused]] const PixelRect &rc) noexcept +{ + AddButton("Landscape", [this](){ + SaveRotation("0"); + Display::Rotate(DisplayOrientation::LANDSCAPE); + }); + + AddButton("Portrait (90°)", [this](){ + SaveRotation("1"); + Display::Rotate(DisplayOrientation::REVERSE_PORTRAIT); + }); + + AddButton("Landscape (180°)", [this](){ + SaveRotation("2"); + Display::Rotate(DisplayOrientation::REVERSE_LANDSCAPE); + }); + + AddButton("Portrait (270°)", [this](){ + SaveRotation("3"); + Display::Rotate(DisplayOrientation::PORTRAIT); + }); +} + class ScreenBrightnessWidget final : public RowFormWidget { From 4569adc289b8ddbd0facb643cf8d61793fedab37 Mon Sep 17 00:00:00 2001 From: Blaubart Date: Thu, 20 Apr 2023 19:03:43 +0200 Subject: [PATCH 038/403] The "Files" submenu has been revised and adapted to the new backup/restore script --- src/OV/OpenVarioMenu.cpp | 54 +++++++++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 9 deletions(-) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index 62b67edf7e8..ea5bc08136f 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -66,39 +66,75 @@ class FileMenuWidget final /* virtual methods from class Widget */ void Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept override; + }; void FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { - AddButton("Download XCSoar IGC files to USB", [this](){ - const UI::ScopeDropMaster drop_master{display}; - const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; - Run("/usr/bin/download-igc.sh"); + AddButton("Download XCSoar IGC files to USB", [](){ + static constexpr const char *argv[] = { + "/usr/bin/download-igc.sh", nullptr + }; + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Download IGC Files", argv); }); - AddButton("Download XCSoar to USB", [](){ + AddButton("Update Maps", [](){ static constexpr const char *argv[] = { - "/usr/bin/download-all.sh", nullptr + "/usr/bin/update-maps.sh", nullptr }; RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "Downloading files", argv); + "Update Maps", argv); }); - AddButton("Upload files from USB to XCSoar", [](){ + AddButton("Update or upload XCSoar files from USB", [](){ static constexpr const char *argv[] = { "/usr/bin/upload-xcsoar.sh", nullptr }; RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "Uploading files", argv); + "Update/Upload files", argv); + }); + + AddButton("System Backup: OpenVario and XCSoar settings to USB", [](){ + static constexpr const char *argv[] = { + "/usr/bin/backup-system.sh", nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Backup System", argv); + }); + + AddButton("System Restore: OpenVario and XCSoar settings from USB", [](){ + static constexpr const char *argv[] = { + "/usr/bin/restore-system.sh", nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Restore XCSoar and System", argv); + Display::Rotate(Display::DetectInitialOrientation()); + }); + + AddButton("XCSoar Restore: Only XCSoar settings from USB", [](){ + static constexpr const char *argv[] = { + "/usr/bin/restore-xcsoar.sh", nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Restore XCSoar", argv); }); } + class ScreenRotationWidget final : public RowFormWidget { From 306359f6b03975d444f325f3d669411f660df10c Mon Sep 17 00:00:00 2001 From: Blaubart Date: Thu, 20 Apr 2023 19:05:14 +0200 Subject: [PATCH 039/403] integration of the functions for writing and reading the config values --- src/OV/OpenVarioMenu.cpp | 43 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index ea5bc08136f..f41b4de6b88 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -20,6 +20,48 @@ #include +using namespace std; + +static void GetConfigInt(const string &keyvalue, int &value, const string &path) +{ + const Path ConfigPath(path.c_str()); + + ProfileMap configuration; + Profile::LoadFile(configuration, ConfigPath); + configuration.Get(keyvalue.c_str(), value); +} + +static void ChangeConfigInt(const string &keyvalue, int value, const string &path) +{ + const Path ConfigPath(path.c_str()); + + ProfileMap configuration; + + try { + Profile::LoadFile(configuration, ConfigPath); + } catch (exception &e) { + Profile::SaveFile(configuration, ConfigPath); + } + configuration.Set(keyvalue.c_str(), value); + Profile::SaveFile(configuration, ConfigPath); +} + +template +static void ChangeConfigString(const string &keyvalue, T value, const string &path) +{ + const Path ConfigPath(path.c_str()); + + ProfileMap configuration; + + try { + Profile::LoadFile(configuration, ConfigPath); + } catch (exception &e) { + Profile::SaveFile(configuration, ConfigPath); + } + configuration.Set(keyvalue.c_str(), value); + Profile::SaveFile(configuration, ConfigPath); +} + enum Buttons { LAUNCH_SHELL = 100, }; @@ -134,7 +176,6 @@ FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, }); } - class ScreenRotationWidget final : public RowFormWidget { From c6e4932ad3cabc038047401621ae52527d3caba0 Mon Sep 17 00:00:00 2001 From: Blaubart Date: Thu, 20 Apr 2023 19:05:47 +0200 Subject: [PATCH 040/403] include necessary files --- src/OV/OpenVarioMenu.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index f41b4de6b88..b0fbf6b67d2 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -14,11 +14,21 @@ #include "ui/window/SingleWindow.hpp" #include "ui/event/Queue.hpp" #include "ui/event/Timer.hpp" +#include "ui/event/KeyCode.hpp" #include "Language/Language.hpp" #include "system/Process.hpp" #include "util/ScopeExit.hxx" +#include "system/FileUtil.hpp" +#include "Profile/File.hpp" +#include "Profile/Map.hpp" +#include "DisplayOrientation.hpp" +#include "Hardware/DisplayGlue.hpp" +#include "Hardware/DisplayDPI.hpp" +#include "Hardware/RotateDisplay.hpp" #include +#include +#include using namespace std; From 67aeea93662f7a86e4afdeea0fde762ffbaadfe2 Mon Sep 17 00:00:00 2001 From: Blaubart Date: Thu, 20 Apr 2023 19:20:37 +0200 Subject: [PATCH 041/403] Added the missing button to enable or disable sendord --- src/OV/OpenVarioMenu.cpp | 47 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index b0fbf6b67d2..89e532dfe45 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -691,6 +691,53 @@ ScreenVariodWidget::Prepare([[maybe_unused]] ContainerWindow &parent, }); } +class ScreenSensordWidget final + : public RowFormWidget +{ + UI::Display &display; + UI::EventQueue &event_queue; + +public: + ScreenSensordWidget(UI::Display &_display, UI::EventQueue &_event_queue, + const DialogLook &look) noexcept + :RowFormWidget(look), + display(_display), event_queue(_event_queue) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, + const PixelRect &rc) noexcept override; +}; + +void +ScreenSensordWidget::Prepare([[maybe_unused]] ContainerWindow &parent, + [[maybe_unused]] const PixelRect &rc) noexcept +{ + AddButton("Enable", [](){ + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "systemctl enable sensord && printf '\nsensord has been enabled'", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Enable", argv); + }); + + AddButton("Disable", [](){ + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "systemctl disable sensord && printf '\nsensord has been disabled'", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Disable", argv); + }); +} + class SystemSettingsWidget final : public RowFormWidget { From 40d00b9932c20e3431a42d9c7e2006f1b8960e52 Mon Sep 17 00:00:00 2001 From: Blaubart Date: Thu, 20 Apr 2023 19:22:11 +0200 Subject: [PATCH 042/403] adding missing button "Logbook" and changed Label of menu page - adding missing button "Logbook" - changed label and function of menu page OpenVario System --- src/OV/OpenVarioMenu.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index 89e532dfe45..b53751b0466 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -985,6 +985,7 @@ class MainMenuWidget final enum Controls { XCSOAR, + LOGBOOK, FILE, SYSTEM, SHELL, @@ -1111,8 +1112,8 @@ MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, TWidgetDialog sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), "OpenVario System"); - sub_dialog.SetWidget(display, event_queue, GetLook()); + GetLook(), "OpenVario System Settings"); + sub_dialog.SetWidget(display, event_queue, sub_dialog); sub_dialog.AddButton(_("Close"), mrOK); return sub_dialog.ShowModal(); }); From 0dd667401b49e0f412df0676b17c780c2470e0da Mon Sep 17 00:00:00 2001 From: Blaubart Date: Fri, 5 May 2023 23:19:40 +0200 Subject: [PATCH 043/403] removing logbook from menu --- src/OV/OpenVarioMenu.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index b53751b0466..baa2f5951c7 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -985,7 +985,6 @@ class MainMenuWidget final enum Controls { XCSOAR, - LOGBOOK, FILE, SYSTEM, SHELL, @@ -1085,17 +1084,6 @@ MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, StartXCSoar(); }); - AddButton("Logbook", [this](){ - CancelTimer(); - static constexpr const char *argv[] = { - "/usr/bin/logbook.sh", nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - "Logbook", argv); - }); - AddButton("Files", [this](){ CancelTimer(); From ba75692c3fc155587b8911b057f1a969f37a2e69 Mon Sep 17 00:00:00 2001 From: Blaubart Date: Sat, 6 May 2023 00:03:40 +0200 Subject: [PATCH 044/403] fixed bad or broken Indentation --- src/OV/OpenVarioMenu.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index baa2f5951c7..6e15753b141 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -263,7 +263,7 @@ void SaveBrightness(const string &brightness); void ScreenBrightnessWidget::SaveBrightness(const string &brightness) { - File::WriteExisting(Path("/sys/class/backlight/lcd/brightness"), (brightness).c_str()); + File::WriteExisting(Path("/sys/class/backlight/lcd/brightness"), (brightness).c_str()); } void @@ -1012,8 +1012,7 @@ class MainMenuWidget final WndForm &_dialog) noexcept :RowFormWidget(_dialog.GetLook()), display(_display), event_queue(_event_queue), - dialog(_dialog) - { + dialog(_dialog) { GetConfigInt("timeout", remaining_seconds, "/boot/config.uEnv"); } @@ -1052,9 +1051,9 @@ class MainMenuWidget final ScheduleTimer(); } else { - HideRow(Controls::TIMER); + HideRow(Controls::TIMER); StartXCSoar(); - } + } } void Hide() noexcept override { @@ -1067,11 +1066,11 @@ class MainMenuWidget final /* ignore escape key at first menu page */ if (key_code != KEY_ESCAPE) { - return RowFormWidget::KeyPress(key_code); - } - else { + return RowFormWidget::KeyPress(key_code); + } + else { return true; - } + } } }; From 2b7e201acacd06dc8274475daef2091fdc3951e1 Mon Sep 17 00:00:00 2001 From: Blaubart Date: Sat, 6 May 2023 00:51:58 +0200 Subject: [PATCH 045/403] changed remaining_seconds from int to unsigned --- src/OV/OpenVarioMenu.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index 6e15753b141..e669f9bbe75 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -32,7 +32,7 @@ using namespace std; -static void GetConfigInt(const string &keyvalue, int &value, const string &path) +static void GetConfigInt(const string &keyvalue, unsigned &value, const string &path) { const Path ConfigPath(path.c_str()); @@ -981,7 +981,7 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, class MainMenuWidget final : public RowFormWidget { - int remaining_seconds = 3; + unsigned remaining_seconds = 3; enum Controls { XCSOAR, From 02330cda8d84912bbff7fe5ce04a83dc5bc1818f Mon Sep 17 00:00:00 2001 From: Blaubart Date: Sat, 6 May 2023 00:58:14 +0200 Subject: [PATCH 046/403] Revert "Removed "Update Maps" from the system menu" This reverts commit 38151bfac5ba86c3a4e7b3886c6e6fc278cf148a. --- src/OV/OpenVarioMenu.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index e669f9bbe75..87bc3397505 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -950,6 +950,16 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, "Update System", argv); }); + AddButton("Update Maps", [](){ + static constexpr const char *argv[] = { + "/usr/bin/update-maps.sh", nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Update Maps", argv); + }); + AddButton("Calibrate Sensors", CalibrateSensors); AddButton("Calibrate Touch", [this](){ const UI::ScopeDropMaster drop_master{display}; From 01d61dab730e5d4957828016b197da20310e8e92 Mon Sep 17 00:00:00 2001 From: Blaubart Date: Sat, 6 May 2023 01:02:04 +0200 Subject: [PATCH 047/403] Revert "The "Files" submenu has been revised and adapted to the new backup/restore script" This reverts commit 21bb94768af6fa1c59d4d26eb2b1110c40141a1e. --- src/OV/OpenVarioMenu.cpp | 53 +++++++--------------------------------- 1 file changed, 9 insertions(+), 44 deletions(-) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index 87bc3397505..176f410ba1c 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -118,71 +118,36 @@ class FileMenuWidget final /* virtual methods from class Widget */ void Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept override; - }; void FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { - AddButton("Download XCSoar IGC files to USB", [](){ - static constexpr const char *argv[] = { - "/usr/bin/download-igc.sh", nullptr - }; - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - "Download IGC Files", argv); + AddButton("Download XCSoar IGC files to USB", [this](){ + const UI::ScopeDropMaster drop_master{display}; + const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; + Run("/usr/bin/download-igc.sh"); }); - AddButton("Update Maps", [](){ + AddButton("Download XCSoar to USB", [](){ static constexpr const char *argv[] = { - "/usr/bin/update-maps.sh", nullptr + "/usr/bin/download-all.sh", nullptr }; RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "Update Maps", argv); + "Downloading files", argv); }); - AddButton("Update or upload XCSoar files from USB", [](){ + AddButton("Upload files from USB to XCSoar", [](){ static constexpr const char *argv[] = { "/usr/bin/upload-xcsoar.sh", nullptr }; RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "Update/Upload files", argv); - }); - - AddButton("System Backup: OpenVario and XCSoar settings to USB", [](){ - static constexpr const char *argv[] = { - "/usr/bin/backup-system.sh", nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - "Backup System", argv); - }); - - AddButton("System Restore: OpenVario and XCSoar settings from USB", [](){ - static constexpr const char *argv[] = { - "/usr/bin/restore-system.sh", nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - "Restore XCSoar and System", argv); - Display::Rotate(Display::DetectInitialOrientation()); - }); - - AddButton("XCSoar Restore: Only XCSoar settings from USB", [](){ - static constexpr const char *argv[] = { - "/usr/bin/restore-xcsoar.sh", nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - "Restore XCSoar", argv); + "Uploading files", argv); }); } From 7e267968d6ec8c05820d62124f6d77b23834b6dc Mon Sep 17 00:00:00 2001 From: Blaubart Date: Sat, 6 May 2023 01:07:12 +0200 Subject: [PATCH 048/403] modify submenu "Files" and move submenu "Update Maps" - submenu "Files" has been revised and adapted to the new backup/restore script - Removed "Update Maps" from the system menu, because it belongs to the submenu "Files" --- src/OV/OpenVarioMenu.cpp | 63 ++++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 19 deletions(-) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index 176f410ba1c..e669f9bbe75 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -118,36 +118,71 @@ class FileMenuWidget final /* virtual methods from class Widget */ void Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept override; + }; void FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { - AddButton("Download XCSoar IGC files to USB", [this](){ - const UI::ScopeDropMaster drop_master{display}; - const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; - Run("/usr/bin/download-igc.sh"); + AddButton("Download XCSoar IGC files to USB", [](){ + static constexpr const char *argv[] = { + "/usr/bin/download-igc.sh", nullptr + }; + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Download IGC Files", argv); }); - AddButton("Download XCSoar to USB", [](){ + AddButton("Update Maps", [](){ static constexpr const char *argv[] = { - "/usr/bin/download-all.sh", nullptr + "/usr/bin/update-maps.sh", nullptr }; RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "Downloading files", argv); + "Update Maps", argv); }); - AddButton("Upload files from USB to XCSoar", [](){ + AddButton("Update or upload XCSoar files from USB", [](){ static constexpr const char *argv[] = { "/usr/bin/upload-xcsoar.sh", nullptr }; RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "Uploading files", argv); + "Update/Upload files", argv); + }); + + AddButton("System Backup: OpenVario and XCSoar settings to USB", [](){ + static constexpr const char *argv[] = { + "/usr/bin/backup-system.sh", nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Backup System", argv); + }); + + AddButton("System Restore: OpenVario and XCSoar settings from USB", [](){ + static constexpr const char *argv[] = { + "/usr/bin/restore-system.sh", nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Restore XCSoar and System", argv); + Display::Rotate(Display::DetectInitialOrientation()); + }); + + AddButton("XCSoar Restore: Only XCSoar settings from USB", [](){ + static constexpr const char *argv[] = { + "/usr/bin/restore-xcsoar.sh", nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Restore XCSoar", argv); }); } @@ -915,16 +950,6 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, "Update System", argv); }); - AddButton("Update Maps", [](){ - static constexpr const char *argv[] = { - "/usr/bin/update-maps.sh", nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - "Update Maps", argv); - }); - AddButton("Calibrate Sensors", CalibrateSensors); AddButton("Calibrate Touch", [this](){ const UI::ScopeDropMaster drop_master{display}; From 819d14d874ecf6e30d388433e3c6e176ebd00226 Mon Sep 17 00:00:00 2001 From: Martin Kaiser <14329350+mk-it-easy@users.noreply.github.com> Date: Sun, 7 May 2023 23:04:18 +0200 Subject: [PATCH 049/403] use thread to wait for timing problem with display rotation --- src/OV/OpenVarioMenu.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index e669f9bbe75..721e45705c4 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -29,6 +29,7 @@ #include #include #include +#include using namespace std; @@ -1167,12 +1168,7 @@ Main() int main() { /*the x-menu is waiting a second to solve timing problem with display rotation */ - std::chrono::high_resolution_clock hrc; - auto start = hrc.now(); - while(std::chrono::duration_cast(hrc.now() - start).count() < 1000) - { - //I'm just waiting ;-) - } + std::this_thread::sleep_for(std::chrono::seconds(1)); int action = Main(); From c2410ee597abdad35d9fdd79afb77d3007e4e2ff Mon Sep 17 00:00:00 2001 From: Martin Kaiser <14329350+mk-it-easy@users.noreply.github.com> Date: Thu, 11 May 2023 22:25:39 +0200 Subject: [PATCH 050/403] [OV] refactor code for readability, FileMenuWidget --- src/OV/FileMenuWidget.cpp | 70 +++++++++++++++++++++++++++++++ src/OV/FileMenuWidget.h | 27 ++++++++++++ src/OV/OpenVarioMenu.cpp | 87 +-------------------------------------- 3 files changed, 99 insertions(+), 85 deletions(-) create mode 100644 src/OV/FileMenuWidget.cpp create mode 100644 src/OV/FileMenuWidget.h diff --git a/src/OV/FileMenuWidget.cpp b/src/OV/FileMenuWidget.cpp new file mode 100644 index 00000000000..98240745e2e --- /dev/null +++ b/src/OV/FileMenuWidget.cpp @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project +#include "FileMenuWidget.h" +#include "Dialogs/ProcessDialog.hpp" +#include "Hardware/DisplayGlue.hpp" + +void +FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, + [[maybe_unused]] const PixelRect &rc) noexcept +{ +AddButton("Download XCSoar IGC files to USB", [](){ +static constexpr const char *argv[] = { + "/usr/bin/download-igc.sh", nullptr +}; +RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), +"Download IGC Files", argv); +}); + +AddButton("Update Maps", [](){ +static constexpr const char *argv[] = { + "/usr/bin/update-maps.sh", nullptr +}; + +RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), +"Update Maps", argv); +}); + +AddButton("Update or upload XCSoar files from USB", [](){ +static constexpr const char *argv[] = { + "/usr/bin/upload-xcsoar.sh", nullptr +}; + +RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), +"Update/Upload files", argv); +}); + +AddButton("System Backup: OpenVario and XCSoar settings to USB", [](){ +static constexpr const char *argv[] = { + "/usr/bin/backup-system.sh", nullptr +}; + +RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), +"Backup System", argv); +}); + +AddButton("System Restore: OpenVario and XCSoar settings from USB", [](){ +static constexpr const char *argv[] = { + "/usr/bin/restore-system.sh", nullptr +}; + +RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), +"Restore XCSoar and System", argv); +Display::Rotate(Display::DetectInitialOrientation()); +}); + +AddButton("XCSoar Restore: Only XCSoar settings from USB", [](){ +static constexpr const char *argv[] = { + "/usr/bin/restore-xcsoar.sh", nullptr +}; + +RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), +"Restore XCSoar", argv); +}); +} \ No newline at end of file diff --git a/src/OV/FileMenuWidget.h b/src/OV/FileMenuWidget.h new file mode 100644 index 00000000000..b463275c6b8 --- /dev/null +++ b/src/OV/FileMenuWidget.h @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project +#pragma once +#include "UIGlobals.hpp" +#include "ui/event/Globals.hpp" +#include "ui/display/Display.hpp" +#include "Widget/RowFormWidget.hpp" +#include "Hardware/RotateDisplay.hpp" + +class FileMenuWidget final + : public RowFormWidget +{ + UI::Display &display; + UI::EventQueue &event_queue; + +public: + FileMenuWidget(UI::Display &_display, UI::EventQueue &_event_queue, + const DialogLook &look) noexcept + :RowFormWidget(look), + display(_display), event_queue(_event_queue) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, + const PixelRect &rc) noexcept override; + +}; diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index 721e45705c4..bcfefe2754a 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -25,6 +25,7 @@ #include "Hardware/DisplayGlue.hpp" #include "Hardware/DisplayDPI.hpp" #include "Hardware/RotateDisplay.hpp" +#include "FileMenuWidget.h" #include #include @@ -103,90 +104,6 @@ UIGlobals::GetMainWindow() return *global_main_window; } -class FileMenuWidget final - : public RowFormWidget -{ - UI::Display &display; - UI::EventQueue &event_queue; - -public: - FileMenuWidget(UI::Display &_display, UI::EventQueue &_event_queue, - const DialogLook &look) noexcept - :RowFormWidget(look), - display(_display), event_queue(_event_queue) {} - -private: - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, - const PixelRect &rc) noexcept override; - -}; - -void -FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, - [[maybe_unused]] const PixelRect &rc) noexcept -{ - AddButton("Download XCSoar IGC files to USB", [](){ - static constexpr const char *argv[] = { - "/usr/bin/download-igc.sh", nullptr - }; - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - "Download IGC Files", argv); - }); - - AddButton("Update Maps", [](){ - static constexpr const char *argv[] = { - "/usr/bin/update-maps.sh", nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - "Update Maps", argv); - }); - - AddButton("Update or upload XCSoar files from USB", [](){ - static constexpr const char *argv[] = { - "/usr/bin/upload-xcsoar.sh", nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - "Update/Upload files", argv); - }); - - AddButton("System Backup: OpenVario and XCSoar settings to USB", [](){ - static constexpr const char *argv[] = { - "/usr/bin/backup-system.sh", nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - "Backup System", argv); - }); - - AddButton("System Restore: OpenVario and XCSoar settings from USB", [](){ - static constexpr const char *argv[] = { - "/usr/bin/restore-system.sh", nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - "Restore XCSoar and System", argv); - Display::Rotate(Display::DetectInitialOrientation()); - }); - - AddButton("XCSoar Restore: Only XCSoar settings from USB", [](){ - static constexpr const char *argv[] = { - "/usr/bin/restore-xcsoar.sh", nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - "Restore XCSoar", argv); - }); -} - class ScreenRotationWidget final : public RowFormWidget { @@ -238,7 +155,7 @@ ScreenRotationWidget::Prepare([[maybe_unused]] ContainerWindow &parent, AddButton("Portrait (270°)", [this](){ SaveRotation("3"); Display::Rotate(DisplayOrientation::PORTRAIT); - }); + }); } class ScreenBrightnessWidget final From 29ab0154cca28aa34f33aaab9d1ba965eeb6f06c Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 15 Apr 2024 10:07:51 +0200 Subject: [PATCH 051/403] [build] ov.mk - add FileMenuWidget.cpp --- build/ov.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/build/ov.mk b/build/ov.mk index ef0aa0487bd..4040c11c904 100644 --- a/build/ov.mk +++ b/build/ov.mk @@ -31,6 +31,7 @@ OV_MENU_SOURCES = \ $(TEST_SRC_DIR)/FakeLanguage.cpp \ $(TEST_SRC_DIR)/FakeLogFile.cpp \ $(SRC)/Kobo/FakeSymbols.cpp \ + $(SRC)/OV/FileMenuWidget.cpp\ $(SRC)/OV/OpenVarioMenu.cpp OV_MENU_DEPENDS = WIDGET FORM DATA_FIELD SCREEN EVENT RESOURCE ASYNC LIBNET OS IO THREAD TIME MATH UTIL OV_MENU_STRIP = y From 0cc578c00abe07fa91accb31fc6eab8525b44d4f Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 3 Jan 2024 10:33:30 +0100 Subject: [PATCH 052/403] [CMake/OV] - add FileMenuWidget --- src/OV/CMakeLists.txt | 2 +- src/OV/CMakeSource.cmake | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/OV/CMakeLists.txt b/src/OV/CMakeLists.txt index fdc14b53dce..892a1d442fe 100644 --- a/src/OV/CMakeLists.txt +++ b/src/OV/CMakeLists.txt @@ -39,7 +39,7 @@ endif() include_directories(${CMAKE_CURRENT_SOURCE_DIR}) # add_library(${TARGET_NAME} ${XCSOAR_LIB_TYPE} -add_executable(${TARGET_NAME} # ${XCSOAR_LIB_TYPE} +add_executable(${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES} ${SCRIPT_FILES} diff --git a/src/OV/CMakeSource.cmake b/src/OV/CMakeSource.cmake index 9935a60c13b..5c7ac403679 100644 --- a/src/OV/CMakeSource.cmake +++ b/src/OV/CMakeSource.cmake @@ -2,8 +2,10 @@ set(_SOURCES OV/OpenVarioMenu.cpp OV/System.cpp OV/Settings.cpp + OV/FileMenuWidget.cpp ) set(SCRIPT_FILES CMakeSource.cmake + ../../build/ov.mk ) From cc712e23eb9fd868e6f722fdf36571c45149fcd1 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 3 Jan 2024 10:57:04 +0100 Subject: [PATCH 053/403] FileMenuWidget.cpp - remove Update Maps, code style --- src/OV/FileMenuWidget.cpp | 108 +++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 59 deletions(-) diff --git a/src/OV/FileMenuWidget.cpp b/src/OV/FileMenuWidget.cpp index 98240745e2e..133d9e101c5 100644 --- a/src/OV/FileMenuWidget.cpp +++ b/src/OV/FileMenuWidget.cpp @@ -8,63 +8,53 @@ void FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { -AddButton("Download XCSoar IGC files to USB", [](){ -static constexpr const char *argv[] = { - "/usr/bin/download-igc.sh", nullptr -}; -RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), -"Download IGC Files", argv); -}); - -AddButton("Update Maps", [](){ -static constexpr const char *argv[] = { - "/usr/bin/update-maps.sh", nullptr -}; - -RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), -"Update Maps", argv); -}); - -AddButton("Update or upload XCSoar files from USB", [](){ -static constexpr const char *argv[] = { - "/usr/bin/upload-xcsoar.sh", nullptr -}; - -RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), -"Update/Upload files", argv); -}); - -AddButton("System Backup: OpenVario and XCSoar settings to USB", [](){ -static constexpr const char *argv[] = { - "/usr/bin/backup-system.sh", nullptr -}; - -RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), -"Backup System", argv); -}); - -AddButton("System Restore: OpenVario and XCSoar settings from USB", [](){ -static constexpr const char *argv[] = { - "/usr/bin/restore-system.sh", nullptr -}; - -RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), -"Restore XCSoar and System", argv); -Display::Rotate(Display::DetectInitialOrientation()); -}); - -AddButton("XCSoar Restore: Only XCSoar settings from USB", [](){ -static constexpr const char *argv[] = { - "/usr/bin/restore-xcsoar.sh", nullptr -}; - -RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), -"Restore XCSoar", argv); -}); + AddButton("Download XCSoar IGC files to USB", [](){ + static constexpr const char *argv[] = { + "/usr/bin/download-igc.sh", nullptr + }; + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Download IGC Files", argv); + }); + + AddButton("Update or upload XCSoar files from USB", [](){ + static constexpr const char *argv[] = { + "/usr/bin/upload-xcsoar.sh", nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Update/Upload files", argv); + }); + + AddButton("System Backup: OpenVario and XCSoar settings to USB", [](){ + static constexpr const char *argv[] = { + "/usr/bin/backup-system.sh", nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Backup System", argv); + }); + + AddButton("System Restore: OpenVario and XCSoar settings from USB", [](){ + static constexpr const char *argv[] = { + "/usr/bin/restore-system.sh", nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Restore XCSoar and System", argv); + Display::Rotate(Display::DetectInitialOrientation()); + }); + + AddButton("XCSoar Restore: Only XCSoar settings from USB", [](){ + static constexpr const char *argv[] = { + "/usr/bin/restore-xcsoar.sh", nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + "Restore XCSoar", argv); + }); } \ No newline at end of file From d8d0825e8731fa79c9537eee35a6bdbf5ca615e8 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 3 Jan 2024 13:37:09 +0100 Subject: [PATCH 054/403] FileMenuWidget.cpp - rebuild with TCHAR and main_app --- src/OV/FileMenuWidget.cpp | 45 +++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/src/OV/FileMenuWidget.cpp b/src/OV/FileMenuWidget.cpp index 133d9e101c5..aeee5c2355b 100644 --- a/src/OV/FileMenuWidget.cpp +++ b/src/OV/FileMenuWidget.cpp @@ -3,58 +3,75 @@ #include "FileMenuWidget.h" #include "Dialogs/ProcessDialog.hpp" #include "Hardware/DisplayGlue.hpp" +#include "Language/Language.hpp" -void +#include + +constexpr const char *opensoar = "OpenSoar"; +constexpr const char *xcsoar = "XCSoar"; +// std::string +constexpr const char *main_app = opensoar; + + void FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { - AddButton("Download XCSoar IGC files to USB", [](){ + StaticString<60> title; + title.Format(_("Download %s IGC files to USB"),main_app); + AddButton(title, [](){ static constexpr const char *argv[] = { "/usr/bin/download-igc.sh", nullptr }; RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "Download IGC Files", argv); + _("Download IGC Files"), argv); }); - AddButton("Update or upload XCSoar files from USB", [](){ + + title.Format(_("Update or upload %s files from USB"), main_app); + AddButton(title, []() { static constexpr const char *argv[] = { - "/usr/bin/upload-xcsoar.sh", nullptr + "/usr/bin/transfers.sh", "download-data", "main_app.c_str()", nullptr }; RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "Update/Upload files", argv); + _("Update/Upload files"), argv); }); - AddButton("System Backup: OpenVario and XCSoar settings to USB", [](){ + title.Format(_("System Backup: OpenVario and %s settings to USB"), main_app); + AddButton(title, []() { static constexpr const char *argv[] = { "/usr/bin/backup-system.sh", nullptr }; RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "Backup System", argv); + _("Backup System"), argv); }); - AddButton("System Restore: OpenVario and XCSoar settings from USB", [](){ + title.Format(_("System Restore: OpenVario and %s settings from USB"), + main_app); + AddButton(title, []() { static constexpr const char *argv[] = { "/usr/bin/restore-system.sh", nullptr }; RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "Restore XCSoar and System", argv); + _("Restore XCSoar and System"), argv); Display::Rotate(Display::DetectInitialOrientation()); }); - AddButton("XCSoar Restore: Only XCSoar settings from USB", [](){ + title.Format(_("%s Restore: Only %s settings from USB"), main_app, + main_app ); + AddButton(title, []() { static constexpr const char *argv[] = { - "/usr/bin/restore-xcsoar.sh", nullptr + "/usr/bin/transfers.sh", "upload-data", main_app, nullptr }; RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "Restore XCSoar", argv); - }); + _("Restore XCSoar"), argv); + }); } \ No newline at end of file From 64c0a1902d9398c1ab8acb084d9cb5e2e0580b1d Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 3 Jan 2024 14:16:00 +0100 Subject: [PATCH 055/403] FileMenuWidget.cpp - remove system backup / restore --- src/OV/FileMenuWidget.cpp | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/OV/FileMenuWidget.cpp b/src/OV/FileMenuWidget.cpp index aeee5c2355b..b082d47614c 100644 --- a/src/OV/FileMenuWidget.cpp +++ b/src/OV/FileMenuWidget.cpp @@ -9,7 +9,6 @@ constexpr const char *opensoar = "OpenSoar"; constexpr const char *xcsoar = "XCSoar"; -// std::string constexpr const char *main_app = opensoar; void @@ -17,7 +16,7 @@ FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { StaticString<60> title; - title.Format(_("Download %s IGC files to USB"),main_app); + title.Format(_("Download %s IGC files to USB (WIP)"),main_app); AddButton(title, [](){ static constexpr const char *argv[] = { "/usr/bin/download-igc.sh", nullptr @@ -28,7 +27,7 @@ FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, }); - title.Format(_("Update or upload %s files from USB"), main_app); + title.Format(_("Download %s data files from OV to USB"), main_app); AddButton(title, []() { static constexpr const char *argv[] = { "/usr/bin/transfers.sh", "download-data", "main_app.c_str()", nullptr @@ -36,10 +35,21 @@ FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _("Update/Upload files"), argv); + _("Download files"), argv); }); - title.Format(_("System Backup: OpenVario and %s settings to USB"), main_app); + title.Format(_("Restore %s data files from USB"), main_app); + AddButton(title, []() { + static constexpr const char *argv[] = {"/usr/bin/transfers.sh", + "upload-data", main_app, nullptr}; + + StaticString<32> dialog_title; + dialog_title.Format(_("Restore %s"), main_app); + RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), + dialog_title, argv); + }); +#if 0 + title.Format(_("System Backup: OpenVario and %s settings to USB"), main_app); AddButton(title, []() { static constexpr const char *argv[] = { "/usr/bin/backup-system.sh", nullptr @@ -62,16 +72,5 @@ FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, _("Restore XCSoar and System"), argv); Display::Rotate(Display::DetectInitialOrientation()); }); - - title.Format(_("%s Restore: Only %s settings from USB"), main_app, - main_app ); - AddButton(title, []() { - static constexpr const char *argv[] = { - "/usr/bin/transfers.sh", "upload-data", main_app, nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _("Restore XCSoar"), argv); - }); +#endif } \ No newline at end of file From a3d2f9a1c4a155ae82801b83221953180a5e8691 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 3 Jan 2024 19:23:46 +0100 Subject: [PATCH 056/403] FileMenuWidget.cpp - re-add the system backup and restor from Blaubart --- src/OV/FileMenuWidget.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/OV/FileMenuWidget.cpp b/src/OV/FileMenuWidget.cpp index b082d47614c..246973f0ae9 100644 --- a/src/OV/FileMenuWidget.cpp +++ b/src/OV/FileMenuWidget.cpp @@ -48,11 +48,13 @@ FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), dialog_title, argv); }); -#if 0 + + AddReadOnly(_T("System:")); + title.Format(_("System Backup: OpenVario and %s settings to USB"), main_app); AddButton(title, []() { static constexpr const char *argv[] = { - "/usr/bin/backup-system.sh", nullptr + "/usr/bin/transfer-system.sh", "backup", main_app, nullptr }; RunProcessDialog(UIGlobals::GetMainWindow(), @@ -64,13 +66,12 @@ FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, main_app); AddButton(title, []() { static constexpr const char *argv[] = { - "/usr/bin/restore-system.sh", nullptr + "/usr/bin/transfer-system.sh", "restore", main_app, nullptr }; RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _("Restore XCSoar and System"), argv); + _("Restore System"), argv); Display::Rotate(Display::DetectInitialOrientation()); }); -#endif } \ No newline at end of file From e41b7a3d7ccce4eab7a8c0fdcdcb1c46ebc08bc5 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 3 Jan 2024 10:35:09 +0100 Subject: [PATCH 057/403] Settings.cpp - remove Update Maps, add Upgrade Firmware --- src/OV/Settings.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/OV/Settings.cpp b/src/OV/Settings.cpp index 30c099c9f3c..ca2e9617c3a 100644 --- a/src/OV/Settings.cpp +++ b/src/OV/Settings.cpp @@ -40,24 +40,24 @@ void SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { - AddButton("Update System", [](){ + AddButton("Upgrade Firmware", [](){ static constexpr const char *argv[] = { - "/usr/bin/update-system.sh", nullptr + "/usr/bin/fw-upgrade.sh", nullptr }; RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "Update System", argv); + "Upgrade Firmware", argv); }); - AddButton("Update Maps", [](){ + AddButton("Update System", [](){ static constexpr const char *argv[] = { - "/usr/bin/update-maps.sh", nullptr + "/usr/bin/update-system.sh", nullptr }; RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "Update Maps", argv); + "Update System", argv); }); AddButton("Calibrate Sensors", CalibrateSensors); From 0b15d3b0108d1270f77fa6d83ed7139170141f42 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 3 Jan 2024 10:54:29 +0100 Subject: [PATCH 058/403] OpenVarioMenu.cpp - change call shell, upgrade firmware, auto start OpenSoar --- src/OV/OpenVarioMenu.cpp | 42 ++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index bcfefe2754a..c7d2470e539 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -76,6 +76,7 @@ static void ChangeConfigString(const string &keyvalue, T value, const string &pa enum Buttons { LAUNCH_SHELL = 100, + START_UPGRADE = 111, }; static DialogSettings dialog_settings; @@ -858,6 +859,11 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, "WiFi Settings", argv); }); + + AddButton("Upgrade Firmware", [this](){ + dialog.SetModalResult(START_UPGRADE); + }); + AddButton("Update System", [](){ static constexpr const char *argv[] = { "/usr/bin/update-system.sh", nullptr @@ -902,6 +908,8 @@ class MainMenuWidget final unsigned remaining_seconds = 3; enum Controls { + OPENSOAR_CLUB, + OPENSOAR, XCSOAR, FILE, SYSTEM, @@ -919,7 +927,8 @@ class MainMenuWidget final UI::Timer timer{[this](){ if (--remaining_seconds == 0) { HideRow(Controls::TIMER); - StartXCSoar(); + StartOpenSoar(); + // StartXCSoar(); } else { ScheduleTimer(); } @@ -935,6 +944,12 @@ class MainMenuWidget final } private: + void StartOpenSoar() noexcept { + const UI::ScopeDropMaster drop_master{display}; + const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; + Run("/usr/bin/OpenSoar", "-fly", "-datapath=/home/root/data/OpenSoarData"); + } + void StartXCSoar() noexcept { const UI::ScopeDropMaster drop_master{display}; const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; @@ -970,7 +985,8 @@ class MainMenuWidget final } else { HideRow(Controls::TIMER); - StartXCSoar(); + StartOpenSoar(); + // StartXCSoar(); } } @@ -996,7 +1012,17 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { - AddButton("Start XCSoar", [this](){ + AddButton("Start OpenSoar (Club)", [this]() { + CancelTimer(); + StartOpenSoar(); + }); + + AddButton("Start OpenSoar", [this]() { + CancelTimer(); + StartOpenSoar(); + }); + + AddButton("Start XCSoar", [this]() { CancelTimer(); StartXCSoar(); }); @@ -1036,6 +1062,8 @@ MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, }); AddReadOnly(""); + + HideRow(Controls::OPENSOAR_CLUB); } static int @@ -1088,12 +1116,6 @@ int main() std::this_thread::sleep_for(std::chrono::seconds(1)); int action = Main(); - - switch (action) { - case LAUNCH_SHELL: - exit(100); - return EXIT_FAILURE; - } - + // save in LogFormat? return action; } From 4f168ec29ebc75ab4d26b55c27e8ca67962cfda4 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 3 Jan 2024 11:29:23 +0100 Subject: [PATCH 059/403] OpenVarioMenu.cpp - test with 'Upgrade Firmware' (2 times), remove Language Upgrade Firmeware (1): add to Main Menu, so SetModalResult is correct Upgrade Firmeware (2): use in SystemMenu the direct exit() option Language: setting make no sense, because it is only responsible for the 'Default' language in OpenSoar/XCSoar Please set the language inside the program (OpenSoar, XCSoar) --- src/OV/OpenVarioMenu.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index c7d2470e539..0873e9bd8d9 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -700,15 +700,6 @@ SystemSettingsWidget::Prepare([[maybe_unused]] ContainerWindow &parent, return sub_dialog.ShowModal(); }); - AddButton("Language", [this](){ - TWidgetDialog - sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), "Language Settings"); - sub_dialog.SetWidget(display, event_queue, GetLook()); - sub_dialog.AddButton(_("Close"), mrOK); - return sub_dialog.ShowModal(); - }); - AddButton("Autostart Timeout", [this](){ TWidgetDialog sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), @@ -861,7 +852,8 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, AddButton("Upgrade Firmware", [this](){ - dialog.SetModalResult(START_UPGRADE); + // dialog.SetModalResult(START_UPGRADE); + exit(START_UPGRADE); }); AddButton("Update System", [](){ @@ -916,6 +908,7 @@ class MainMenuWidget final SHELL, REBOOT, SHUTDOWN, + UPGRADE, TIMER, }; @@ -1049,7 +1042,7 @@ MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, return sub_dialog.ShowModal(); }); - AddButton("Shell", [this](){ + AddButton("Shell", [this](){ dialog.SetModalResult(LAUNCH_SHELL); }); @@ -1061,6 +1054,10 @@ MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, Run("/sbin/poweroff"); }); + AddButton("Upgrade Firmware", [this](){ + dialog.SetModalResult(START_UPGRADE); + }); + AddReadOnly(""); HideRow(Controls::OPENSOAR_CLUB); From f95d29e1501b2665469e1fa2dc8a8f79be43d382 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 3 Jan 2024 12:23:01 +0100 Subject: [PATCH 060/403] OpenVarioMenu.cpp - remove button 'Upgrade Firmware' from MainMenu --- src/OV/OpenVarioMenu.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index 0873e9bd8d9..45960442424 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -908,7 +908,6 @@ class MainMenuWidget final SHELL, REBOOT, SHUTDOWN, - UPGRADE, TIMER, }; @@ -946,7 +945,7 @@ class MainMenuWidget final void StartXCSoar() noexcept { const UI::ScopeDropMaster drop_master{display}; const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; - Run("/usr/bin/xcsoar", "-fly"); + Run("/usr/bin/xcsoar", "-fly", "-datapath=/home/root/data/XCSoarData"); } void ScheduleTimer() noexcept { @@ -1054,10 +1053,6 @@ MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, Run("/sbin/poweroff"); }); - AddButton("Upgrade Firmware", [this](){ - dialog.SetModalResult(START_UPGRADE); - }); - AddReadOnly(""); HideRow(Controls::OPENSOAR_CLUB); From 300af035e947d8ba655443549750d21e5f3121aa Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 3 Jan 2024 13:36:01 +0100 Subject: [PATCH 061/403] OpenVarioMenu.cpp - remove unnecessary ScreenLanguageWidget --- src/OV/OpenVarioMenu.cpp | 179 --------------------------------------- 1 file changed, 179 deletions(-) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index 45960442424..ad79eb5793f 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -226,185 +226,6 @@ ScreenBrightnessWidget::Prepare([[maybe_unused]] ContainerWindow &parent, }); } -class ScreenLanguageWidget final - : public RowFormWidget -{ - UI::Display &display; - UI::EventQueue &event_queue; - -public: - ScreenLanguageWidget(UI::Display &_display, UI::EventQueue &_event_queue, - const DialogLook &look) noexcept - :RowFormWidget(look), - display(_display), event_queue(_event_queue) {} - -private: - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, - const PixelRect &rc) noexcept override; - -}; - -void -ScreenLanguageWidget::Prepare([[maybe_unused]] ContainerWindow &parent, - [[maybe_unused]] const PixelRect &rc) noexcept -{ - AddButton("English", [this](){ - ChangeConfigString("LANG", "en_EN.UTF-8", "/etc/locale.conf"); - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "echo The language has been set to English", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - "Englisch", argv); - }); - - AddButton("Deutsch", [this](){ - ChangeConfigString("LANG", "de_DE.UTF-8", "/etc/locale.conf"); - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "echo The language has been set to German", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - "Deutsch", argv); - }); - - AddButton("Français", [this](){ - ChangeConfigString("LANG", "fr_FR.UTF-8", "/etc/locale.conf"); - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "echo The language has been set to French", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - "Français", argv); - }); - - AddButton("Italiano", [this](){ - ChangeConfigString("LANG", "it_IT.UTF-8", "/etc/locale.conf"); - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "echo The language has been set to Italian", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - "Italiano", argv); - }); - - AddButton("Magyar", [this](){; - ChangeConfigString("LANG", "hu_HU.UTF-8", "/etc/locale.conf"); - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "echo The language has been set to Hungarian", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - "Magyar", argv); - }); - - AddButton("Polski", [this](){ - ChangeConfigString("LANG", "pl_PL.UTF-8", "/etc/locale.conf"); - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "echo The language has been set to Polish", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - "Polski", argv); - }); - - AddButton("ÄŒeÅ¡tina", [this](){ - ChangeConfigString("LANG", "cs_CZ.UTF-8", "/etc/locale.conf"); - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "echo The language has been set to Czech", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - "ÄŒeÅ¡tina", argv); - }); - - AddButton("SlovenÄina", [this](){ - ChangeConfigString("LANG", "sk_SK.UTF-8", "/etc/locale.conf"); - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "echo The language has been set to Slovak", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - "SlovenÄina", argv); - }); - - AddButton("Lietuvių", [this](){ - ChangeConfigString("LANG", "lt_LT.UTF-8", "/etc/locale.conf"); - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "echo The language has been set to Lithuanian", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - "Lietuvių", argv); - }); - - AddButton("РуÑÑкий", [this](){ - ChangeConfigString("LANG", "ru_RU.UTF-8", "/etc/locale.conf"); - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "echo The language has been set to Russian", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - "РуÑÑкий", argv); - }); - - AddButton("Español", [this](){ - ChangeConfigString("LANG", "es_ES.UTF-8", "/etc/locale.conf"); - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "echo The language has been set to Spanish", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - "Español", argv); - }); - - AddButton("Dutch", [this](){ - ChangeConfigString("LANG", "nl_NL.UTF-8", "/etc/locale.conf"); - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "echo The language has been set to Dutch", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - "Dutch", argv); - }); -} class ScreenTimeoutWidget final : public RowFormWidget From a899736017367dc49f7ef693e7fb67926ab03f4a Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 3 Jan 2024 15:29:45 +0100 Subject: [PATCH 062/403] OpenVarioMenu.cpp - w/o using explicit namespace std, using of TCHAR* instead.. of char* if needed --- src/OV/OpenVarioMenu.cpp | 207 ++++++++++++++++++++------------------- 1 file changed, 105 insertions(+), 102 deletions(-) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index ad79eb5793f..ae509e9772a 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -32,26 +32,24 @@ #include #include -using namespace std; - -static void GetConfigInt(const string &keyvalue, unsigned &value, const string &path) -{ - const Path ConfigPath(path.c_str()); +static void GetConfigInt(const std::string &keyvalue, unsigned &value, + const TCHAR* path) { + const Path ConfigPath(path); ProfileMap configuration; Profile::LoadFile(configuration, ConfigPath); configuration.Get(keyvalue.c_str(), value); } -static void ChangeConfigInt(const string &keyvalue, int value, const string &path) -{ - const Path ConfigPath(path.c_str()); +static void ChangeConfigInt(const std::string &keyvalue, int value, + const TCHAR *path) { + const Path ConfigPath(path); ProfileMap configuration; try { Profile::LoadFile(configuration, ConfigPath); - } catch (exception &e) { + } catch (std::exception &e) { Profile::SaveFile(configuration, ConfigPath); } configuration.Set(keyvalue.c_str(), value); @@ -59,15 +57,15 @@ static void ChangeConfigInt(const string &keyvalue, int value, const string &pat } template -static void ChangeConfigString(const string &keyvalue, T value, const string &path) -{ +static void ChangeConfigString(const std::string &keyvalue, T value, + const std::string &path) { const Path ConfigPath(path.c_str()); ProfileMap configuration; try { Profile::LoadFile(configuration, ConfigPath); - } catch (exception &e) { + } catch (std::exception &e) { Profile::SaveFile(configuration, ConfigPath); } configuration.Set(keyvalue.c_str(), value); @@ -121,39 +119,39 @@ class ScreenRotationWidget final /* virtual methods from class Widget */ void Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept override; - void SaveRotation(const string &rotationvalue); + void SaveRotation(const std::string &rotationvalue); }; /* x-menu writes the value for the display rotation to /sys because the value is also required for the console in the OpenVario. In addition, the display rotation is saved in /boot/config.uEnv so that the Openvario sets the correct rotation again when it is restarted.*/ void -ScreenRotationWidget::SaveRotation(const string &rotationString) +ScreenRotationWidget::SaveRotation(const std::string &rotationString) { - File::WriteExisting(Path("/sys/class/graphics/fbcon/rotate"), (rotationString).c_str()); + File::WriteExisting(Path(_T("/sys/class/graphics/fbcon/rotate")), (rotationString).c_str()); int rotationInt = stoi(rotationString); - ChangeConfigInt("rotation", rotationInt, "/boot/config.uEnv"); + ChangeConfigInt("rotation", rotationInt, _T("/boot/config.uEnv")); } void ScreenRotationWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { - AddButton("Landscape", [this](){ + AddButton(_T("Landscape"), [this](){ SaveRotation("0"); Display::Rotate(DisplayOrientation::LANDSCAPE); }); - AddButton("Portrait (90°)", [this](){ + AddButton(_T("Portrait (90°)"), [this](){ SaveRotation("1"); Display::Rotate(DisplayOrientation::REVERSE_PORTRAIT); }); - AddButton("Landscape (180°)", [this](){ + AddButton(_T("Landscape (180°)"), [this](){ SaveRotation("2"); Display::Rotate(DisplayOrientation::REVERSE_LANDSCAPE); }); - AddButton("Portrait (270°)", [this](){ + AddButton(_T("Portrait (270°)"), [this](){ SaveRotation("3"); Display::Rotate(DisplayOrientation::PORTRAIT); }); @@ -176,52 +174,53 @@ class ScreenBrightnessWidget final void Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept override; -void SaveBrightness(const string &brightness); +void SaveBrightness(const std::string &brightness); }; void -ScreenBrightnessWidget::SaveBrightness(const string &brightness) +ScreenBrightnessWidget::SaveBrightness(const std::string &brightness) { - File::WriteExisting(Path("/sys/class/backlight/lcd/brightness"), (brightness).c_str()); +File::WriteExisting(Path(_T("/sys/class/backlight/lcd/brightness")), + (brightness).c_str()); } void ScreenBrightnessWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { - AddButton("20", [this](){ + AddButton(_T("20"), [this](){ SaveBrightness("2"); }); - AddButton("30", [this](){ + AddButton(_T("30"), [this](){ SaveBrightness("3"); }); - AddButton("40", [this](){ + AddButton(_T("40"), [this](){ SaveBrightness("4"); }); - AddButton("50", [this](){ + AddButton(_T("50"), [this](){ SaveBrightness("5"); }); - AddButton("60", [this](){ + AddButton(_T("60"), [this](){ SaveBrightness("6"); }); - AddButton("70", [this](){ + AddButton(_T("70"), [this](){ SaveBrightness("7"); }); - AddButton("80", [this](){ + AddButton(_T("80"), [this](){ SaveBrightness("8"); }); - AddButton("90", [this](){ + AddButton(_T("90"), [this](){ SaveBrightness("9"); }); - AddButton("100", [this](){ + AddButton(_T("100"), [this](){ SaveBrightness("10"); }); } @@ -249,7 +248,7 @@ class ScreenTimeoutWidget final void ScreenTimeoutWidget::SaveTimeout(int timeoutInt) { - ChangeConfigInt("timeout", timeoutInt, "/boot/config.uEnv"); + ChangeConfigInt("timeout", timeoutInt, _T("/boot/config.uEnv")); } void @@ -257,7 +256,7 @@ ScreenTimeoutWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { - AddButton("immediately", [this](){ + AddButton(_T("immediately"), [this](){ SaveTimeout(0); static constexpr const char *argv[] = { "/bin/sh", "-c", @@ -267,10 +266,10 @@ ScreenTimeoutWidget::Prepare([[maybe_unused]] ContainerWindow &parent, RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "immediately", argv); + _T("immediately"), argv); }); - AddButton("1s", [this](){ + AddButton(_T("1s"), [this](){ SaveTimeout(1); static constexpr const char *argv[] = { "/bin/sh", "-c", @@ -280,10 +279,10 @@ ScreenTimeoutWidget::Prepare([[maybe_unused]] ContainerWindow &parent, RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "1s", argv); + _T("1s"), argv); }); - AddButton("3s", [this](){ + AddButton(_T("3s"), [this](){ SaveTimeout(3); static constexpr const char *argv[] = { "/bin/sh", "-c", @@ -293,10 +292,10 @@ ScreenTimeoutWidget::Prepare([[maybe_unused]] ContainerWindow &parent, RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "3s", argv); + _T("3s"), argv); }); - AddButton("5s", [this](){ + AddButton(_T("5s"), [this](){ SaveTimeout(5); static constexpr const char *argv[] = { "/bin/sh", "-c", @@ -306,10 +305,10 @@ ScreenTimeoutWidget::Prepare([[maybe_unused]] ContainerWindow &parent, RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "5s", argv); + _T("5s"), argv); }); - AddButton("10s", [this](){ + AddButton(_T("10s"), [this](){ SaveTimeout(10); static constexpr const char *argv[] = { "/bin/sh", "-c", @@ -319,10 +318,10 @@ ScreenTimeoutWidget::Prepare([[maybe_unused]] ContainerWindow &parent, RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "10s", argv); + _T("10s"), argv); }); - AddButton("30s", [this](){ + AddButton(_T("30s"), [this](){ SaveTimeout(30); static constexpr const char *argv[] = { "/bin/sh", "-c", @@ -332,7 +331,7 @@ ScreenTimeoutWidget::Prepare([[maybe_unused]] ContainerWindow &parent, RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "30s", argv); + _T("30s"), argv); }); } @@ -358,7 +357,7 @@ void ScreenSSHWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { - AddButton("Enable", [](){ + AddButton(_T("Enable") , [](){ static constexpr const char *argv[] = { "/bin/sh", "-c", "systemctl enable dropbear.socket && printf '\nSSH has been enabled'", @@ -368,10 +367,10 @@ ScreenSSHWidget::Prepare([[maybe_unused]] ContainerWindow &parent, RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "Enable", argv); + _T("Enable"), argv); }); - AddButton("Disable", [](){ + AddButton(_T("Disable") , [](){ static constexpr const char *argv[] = { "/bin/sh", "-c", "systemctl disable dropbear.socket && printf '\nSSH has been disabled'", @@ -380,7 +379,7 @@ ScreenSSHWidget::Prepare([[maybe_unused]] ContainerWindow &parent, RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "Disable", argv); + _T("Disable"), argv); }); } @@ -406,7 +405,7 @@ void ScreenVariodWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { - AddButton("Enable", [](){ + AddButton(_T("Enable") , [](){ static constexpr const char *argv[] = { "/bin/sh", "-c", "systemctl enable variod && printf '\nvariod has been enabled'", @@ -415,10 +414,10 @@ ScreenVariodWidget::Prepare([[maybe_unused]] ContainerWindow &parent, RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "Enable", argv); + _T("Enable"), argv); }); - AddButton("Disable", [](){ + AddButton(_T("Disable"), [](){ static constexpr const char *argv[] = { "/bin/sh", "-c", "systemctl disable variod && printf '\nvariod has been disabled'", @@ -427,7 +426,7 @@ ScreenVariodWidget::Prepare([[maybe_unused]] ContainerWindow &parent, RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "Disable", argv); + _T("Disable"), argv); }); } @@ -453,7 +452,7 @@ void ScreenSensordWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { - AddButton("Enable", [](){ + AddButton(_T("Enable"), [](){ static constexpr const char *argv[] = { "/bin/sh", "-c", "systemctl enable sensord && printf '\nsensord has been enabled'", @@ -462,10 +461,10 @@ ScreenSensordWidget::Prepare([[maybe_unused]] ContainerWindow &parent, RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "Enable", argv); + _T("Enable"), argv); }); - AddButton("Disable", [](){ + AddButton(_T("Disable"), [](){ static constexpr const char *argv[] = { "/bin/sh", "-c", "systemctl disable sensord && printf '\nsensord has been disabled'", @@ -474,7 +473,7 @@ ScreenSensordWidget::Prepare([[maybe_unused]] ContainerWindow &parent, RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "Disable", argv); + _T("Disable"), argv); }); } @@ -503,55 +502,55 @@ void SystemSettingsWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { - AddButton("Screen Rotation", [this](){ + AddButton(_("Screen Rotation"), [this](){ TWidgetDialog sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), "Display Rotation Settings"); + GetLook(), _T("Display Rotation Settings")); sub_dialog.SetWidget(display, event_queue, GetLook()); sub_dialog.AddButton(_("Close"), mrOK); return sub_dialog.ShowModal(); }); - AddButton("Screen Brightness", [this](){ + AddButton(_("Screen Brightness"), [this](){ TWidgetDialog sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), "Display Brightness Settings"); + GetLook(), _T("Display Brightness Settings")); sub_dialog.SetWidget(display, event_queue, GetLook()); sub_dialog.AddButton(_("Close"), mrOK); return sub_dialog.ShowModal(); }); - AddButton("Autostart Timeout", [this](){ + AddButton(_("Autostart Timeout"), [this](){ TWidgetDialog sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), "Autostart Timeout"); + GetLook(), _T("Autostart Timeout")); sub_dialog.SetWidget(display, event_queue, GetLook()); sub_dialog.AddButton(_("Close"), mrOK); return sub_dialog.ShowModal(); }); - AddButton("SSH", [this](){ + AddButton(_("SSH"), [this](){ TWidgetDialog sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), "Enable or Disable SSH"); + GetLook(), _T("Enable or Disable SSH")); sub_dialog.SetWidget(display, event_queue, GetLook()); sub_dialog.AddButton(_("Close"), mrOK); return sub_dialog.ShowModal(); }); - AddButton("Variod", [this](){ + AddButton(_("Variod"), [this](){ TWidgetDialog sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), "Enable or Disable Variod"); + GetLook(), _T("Enable or Disable Variod")); sub_dialog.SetWidget(display, event_queue, GetLook()); sub_dialog.AddButton(_("Close"), mrOK); return sub_dialog.ShowModal(); }); - AddButton("Sensord", [this](){ + AddButton(_("Sensord"), [this](){ TWidgetDialog sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), "Enable or Disable Sensord"); + GetLook(), _T("Enable or Disable Sensord")); sub_dialog.SetWidget(display, event_queue, GetLook()); sub_dialog.AddButton(_("Close"), mrOK); return sub_dialog.ShowModal(); @@ -592,7 +591,7 @@ CalibrateSensors() noexcept RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "Calibrate Sensors", stop_sensord, + _T("Calibrate Sensors"), stop_sensord, [](int status){ return status == EXIT_SUCCESS ? mrOK : 0; }); @@ -600,7 +599,7 @@ CalibrateSensors() noexcept AtScopeExit(){ RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "Calibrate Sensors", start_sensord, + _T("Calibrate Sensors"), start_sensord, [](int status){ return status == EXIT_SUCCESS ? mrOK : 0; }); @@ -615,7 +614,7 @@ CalibrateSensors() noexcept static constexpr int RESULT_BOARD_NOT_INITIALISED = 100; int result = RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "Calibrate Sensors", calibrate_sensors, + _T("Calibrate Sensors"), calibrate_sensors, [](int status){ return status == STATUS_BOARD_NOT_INITIALISED ? RESULT_BOARD_NOT_INITIALISED @@ -625,8 +624,8 @@ CalibrateSensors() noexcept return; /* initialise the sensors? */ - if (ShowMessageBox("Sensorboard is virgin. Do you want to initialise it?", - "Calibrate Sensors", MB_YESNO) != IDYES) + if (ShowMessageBox(_T("Sensorboard is virgin. Do you want to initialise it?"), + _T("Calibrate Sensors"), MB_YESNO) != IDYES) return; static constexpr const char *init_sensors[] = { @@ -635,7 +634,7 @@ CalibrateSensors() noexcept result = RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "Calibrate Sensors", init_sensors, + _T("Calibrate Sensors"), init_sensors, [](int status){ return status == EXIT_SUCCESS ? mrOK @@ -647,7 +646,7 @@ CalibrateSensors() noexcept /* calibrate again */ RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "Calibrate Sensors", calibrate_sensors, + _T("Calibrate Sensors"), calibrate_sensors, [](int status){ return status == STATUS_BOARD_NOT_INITIALISED ? RESULT_BOARD_NOT_INITIALISED @@ -659,7 +658,7 @@ void SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { - AddButton("WiFi Settings", [](){ + AddButton(_("WiFi Settings"), [](){ static constexpr const char *argv[] = { "/bin/sh", "-c", "printf '\nWiFi-Settings are not implemented, yet!! \n\nIf you are interessted to help with this, write me an email: dirk@freevario.de'", @@ -668,50 +667,50 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "WiFi Settings", argv); + _T("WiFi Settings"), argv); }); - AddButton("Upgrade Firmware", [this](){ + AddButton(_("Upgrade Firmware"), [this](){ // dialog.SetModalResult(START_UPGRADE); exit(START_UPGRADE); }); - AddButton("Update System", [](){ + AddButton(_("Update System"), [](){ static constexpr const char *argv[] = { "/usr/bin/update-system.sh", nullptr }; RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "Update System", argv); + _T("Update System"), argv); }); - AddButton("Calibrate Sensors", CalibrateSensors); - AddButton("Calibrate Touch", [this](){ + AddButton(_("Calibrate Sensors"), CalibrateSensors); + AddButton(_("Calibrate Touch"), [this](){ const UI::ScopeDropMaster drop_master{display}; const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; Run("/usr/bin/ov-calibrate-ts.sh"); }); - AddButton("System Settings", [this](){ + AddButton(_("System Settings"), [this](){ TWidgetDialog sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), "OpenVario System Settings"); + GetLook(), _T("OpenVario System Settings")); sub_dialog.SetWidget(display, event_queue, sub_dialog); sub_dialog.AddButton(_("Close"), mrOK); return sub_dialog.ShowModal(); }); - AddButton("System Info", [](){ + AddButton(_("System Info"), [](){ static constexpr const char *argv[] = { "/usr/bin/system-info.sh", nullptr }; RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - "System Info", argv); + _T("System Info"), argv); }); } @@ -753,7 +752,7 @@ class MainMenuWidget final :RowFormWidget(_dialog.GetLook()), display(_display), event_queue(_event_queue), dialog(_dialog) { - GetConfigInt("timeout", remaining_seconds, "/boot/config.uEnv"); + GetConfigInt("timeout", remaining_seconds, _T("/boot/config.uEnv")); } private: @@ -774,8 +773,8 @@ class MainMenuWidget final timer.Schedule(std::chrono::seconds{1}); - char buffer[256]; - snprintf(buffer, sizeof(buffer), "Starting XCSoar in %u seconds (press any key to cancel)", + StaticString<256> buffer; + buffer.Format(_T("Starting XCSoar in %u seconds (press any key to cancel)"), remaining_seconds); SetText(Controls::TIMER, buffer); } @@ -825,56 +824,58 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { - AddButton("Start OpenSoar (Club)", [this]() { + AddButton(_("Start OpenSoar (Club)"), [this]() { CancelTimer(); StartOpenSoar(); }); - AddButton("Start OpenSoar", [this]() { + AddButton(_("Start OpenSoar"), [this]() { CancelTimer(); StartOpenSoar(); }); - AddButton("Start XCSoar", [this]() { + AddButton(_("Start XCSoar"), [this]() { CancelTimer(); StartXCSoar(); }); - AddButton("Files", [this](){ + AddButton(_("Files"), [this](){ CancelTimer(); TWidgetDialog sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), "OpenVario Files"); + GetLook(), _T("OpenVario Files")); sub_dialog.SetWidget(display, event_queue, GetLook()); sub_dialog.AddButton(_("Close"), mrOK); return sub_dialog.ShowModal(); }); - AddButton("System", [this](){ + AddButton(_("System"), [this](){ CancelTimer(); TWidgetDialog sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), "OpenVario System Settings"); + GetLook(), _T("OpenVario System Settings")); sub_dialog.SetWidget(display, event_queue, sub_dialog); sub_dialog.AddButton(_("Close"), mrOK); return sub_dialog.ShowModal(); }); - AddButton("Shell", [this](){ + AddReadOnly(_T("System")); + + AddButton(_T("Shell"), [this]() { dialog.SetModalResult(LAUNCH_SHELL); }); - AddButton("Reboot", [](){ + AddButton(_T("Reboot"), [](){ Run("/sbin/reboot"); }); - AddButton("Power off", [](){ + AddButton(_T("Power off") , [](){ Run("/sbin/poweroff"); }); - AddReadOnly(""); + AddReadOnly(_T("")); HideRow(Controls::OPENSOAR_CLUB); } @@ -885,7 +886,7 @@ Main(UI::EventQueue &event_queue, UI::SingleWindow &main_window, { TWidgetDialog dialog(WidgetDialog::Full{}, main_window, - dialog_look, "OpenVario"); + dialog_look, _T("OpenVario")); dialog.SetWidget(main_window.GetDisplay(), event_queue, dialog); return dialog.ShowModal(); @@ -905,7 +906,9 @@ Main() UI::TopWindowStyle main_style; main_style.Resizable(); + #ifndef _WIN32 main_style.InitialOrientation(Display::DetectInitialOrientation()); + #endif UI::SingleWindow main_window{screen_init.GetDisplay()}; main_window.Create(_T("XCSoar/KoboMenu"), {600, 800}, main_style); From 293e2feab33f848ecc897c3a0958b0de9786c969 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 3 Jan 2024 21:43:17 +0100 Subject: [PATCH 063/403] OpenVarioMenu.cpp - add ReadOnly button to split system commands from other --- src/OV/OpenVarioMenu.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index ae509e9772a..6b9070ee623 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -725,10 +725,12 @@ class MainMenuWidget final XCSOAR, FILE, SYSTEM, + READONLY_1, SHELL, REBOOT, SHUTDOWN, TIMER, + READONLY_2, }; UI::Display &display; @@ -861,7 +863,7 @@ MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, return sub_dialog.ShowModal(); }); - AddReadOnly(_T("System")); + AddReadOnly(_T("")); AddButton(_T("Shell"), [this]() { dialog.SetModalResult(LAUNCH_SHELL); @@ -875,7 +877,7 @@ MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, Run("/sbin/poweroff"); }); - AddReadOnly(_T("")); + AddReadOnly(_T("")); // Timer-Progress HideRow(Controls::OPENSOAR_CLUB); } From 13a4e0dba641ce45a20629715dfe7bad8c9c2dd8 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 3 Jan 2024 15:33:02 +0100 Subject: [PATCH 064/403] [CMake] - add target link libraries XCSOAR_LINK_LIBRARIES --- src/OV/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/OV/CMakeLists.txt b/src/OV/CMakeLists.txt index 892a1d442fe..ea6f2d5a7ea 100644 --- a/src/OV/CMakeLists.txt +++ b/src/OV/CMakeLists.txt @@ -49,4 +49,5 @@ target_link_libraries(${TARGET_NAME} PUBLIC Logger) # message(FATAL_ERROR "Stop!") set_target_properties(${TARGET_NAME} PROPERTIES FOLDER OpenVario) -add_dependencies(${TARGET_NAME} util) +target_link_libraries(${TARGET_NAME} PUBLIC Dialogs Math ${XCSOAR_LINK_LIBRARIES}) +add_dependencies(${TARGET_NAME} util Data) From 583fd32eb1289c3ce3ab9f945d137fa158812d78 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 3 Jan 2024 15:36:10 +0100 Subject: [PATCH 065/403] system/Process - prepare this component for _WIN32 Run returned with exit value and save output in file if wanted Run is extended with output file to save the output massage return value of Run is return value of argv[0] processadd a log for system call use a lot of Log lines to debug the Run process use exception handler for Run() command log the call sequence and show call parameter in stdout too --- src/system/Process.cpp | 138 ++++++++++++++++++++++++++++++++++++----- src/system/Process.hpp | 33 ++++++++-- 2 files changed, 153 insertions(+), 18 deletions(-) diff --git a/src/system/Process.cpp b/src/system/Process.cpp index cbc077c30a1..dc23e352c4a 100644 --- a/src/system/Process.cpp +++ b/src/system/Process.cpp @@ -11,6 +11,29 @@ #include #include +#include +#include + +#include +#endif + +#include "LogFile.hpp" +#include "system/FileUtil.hpp" + +#include + +#include +#include +#include + +// static std::filesystem::path output; +// static Path output = Path(_T("")); +static Path output; + +#include +#include + +#ifdef HAVE_POSIX static bool UnblockAllSignals() noexcept { @@ -22,36 +45,54 @@ UnblockAllSignals() noexcept static pid_t ForkExec(const char *const*argv) noexcept { + LogFormat("ForkExec: Call '%s'", argv[0]); const pid_t pid = fork(); if (pid == 0) { UnblockAllSignals(); + if (!output.empty()) { + auto fd = open(output.ToUTF8().c_str(), O_WRONLY | O_CREAT, + 0666); // open the file + dup2(fd, STDOUT_FILENO); // replace standard output with output file + } + // exec or die: execv(argv[0], const_cast(argv)); - _exit(1); + // ...die: + LogFormat("ForkExec: After execv => FAIL?"); + _exit(EXIT_FAILURE); } - + LogFormat("ForkExec: pid = %d > 0", pid); return pid; - } -static bool +static int Wait(pid_t pid) noexcept { + LogFormat("Process.cpp - Wait: pid = %d (for assert)", pid); assert(pid > 0); int status; pid_t pid2 = waitpid(pid, &status, 0); + LogFormat("Process.cpp - Wait: pid2 = %d ", pid2); if (pid2 <= 0) - return false; + return -1; - if (WIFSIGNALED(status) || !WIFEXITED(status) || WEXITSTATUS(status) != 0) - return false; + if (WIFSIGNALED(status) || !WIFEXITED(status)) + return -1; - return true; + if (!output.empty()) { + auto fd = dup(STDOUT_FILENO); + close(fd); + } + int ret_value = WEXITSTATUS(status); + LogFormat("Process.cpp - Wait: return %d", ret_value); + return ret_value; } +#endif bool -Start(const char *const*argv) noexcept +Start(const char *const *argv) noexcept { +#ifdef HAVE_POSIX /* double fork to detach from this process */ const pid_t pid = fork(); if (pid < 0) [[unlikely]] @@ -60,14 +101,83 @@ Start(const char *const*argv) noexcept if (pid == 0) _exit(ForkExec(argv) ? 0 : 1); - return Wait(pid); + return Wait(pid) == 0; +#elif defined(_WIN32) + return false; +#else + error "Unknown system" +#endif } -bool -Run(const char *const*argv) noexcept -{ +int Run(const char *const *argv) noexcept; + +int +Run(const char *const *argv) noexcept +try { +#if 1 // def DEBUG_OPENVARIO + std::cout << "Start Run with:" << std::endl; + if (!output.empty()) + LogFormat(_T("Process.cpp - Run with output: %s"), output.c_str()); + else + LogFormat("Process.cpp - Run w/o output"); + std::stringstream ss; + + for (unsigned count = 0; argv[count] != nullptr; count++) { + ss << argv[count] << ' '; + std::cout << argv[count] << ' '; + } + std::cout << '!' << std::endl; + LogFormat("Process.cpp: %s", ss.str().c_str()); +#endif + + int ret_value = -1; +#ifdef HAVE_POSIX const pid_t pid = ForkExec(argv); - return pid > 0 && Wait(pid); + if (pid > 0) + ret_value = Wait(pid); +#elif defined(_WIN32) + ret_value = system(ss.str().c_str()); +#else + error "Unknown system" +#endif + if (!output.empty()) + output = Path(); // for the next call.. + return ret_value; +} catch (std::exception &e) { + LogFormat("Process.cpp - exception: %s", e.what()); + return -1; } +#if 0 +int +// Run(std::filesystem::path output_path, const char *const *argv) noexcept { +// Run(const Path &output_path, const char *argv, ...) noexcept { +Run(const Path &output_path, const char *argv, ...) noexcept { + output = output_path; +#if 1 + const char *arglist[0x10]; + va_list argptr; + const char *arg = argv; + va_start(argptr, argv); + unsigned idx = 0; + while (arg != nullptr) { + arglist[idx++] = arg; + arg = va_arg(argptr, const char *); + } + // _Result = _vfprintf_l(stdout, argv, nullptr, _ArgList); + va_end(argptr); + arglist[idx] = nullptr; // finally +#else + const char *const arglist[]{argv, nullptr}; #endif + return Run(arglist); + +} +#else +int +Run(const Path &output_path, const char *const *argv) noexcept +{ + output = output_path; + return Run(argv); +} +#endif \ No newline at end of file diff --git a/src/system/Process.hpp b/src/system/Process.hpp index 1fbcb33c987..8a6cafb53ae 100644 --- a/src/system/Process.hpp +++ b/src/system/Process.hpp @@ -3,7 +3,7 @@ #pragma once -#ifdef HAVE_POSIX +#include /** * Launch a child process but don't wait for it to exit. @@ -22,15 +22,40 @@ Start(const char *path, Args... args) noexcept /** * Launch a child process and wait for it to exit. */ -bool +class Path; + +int Run(const char *const*argv) noexcept; +int +Run(const Path &output, const char *const *argv) noexcept; template -static inline bool +static inline int Run(const char *path, Args... args) noexcept { const char *const argv[]{path, args..., nullptr}; return Run(argv); } -#endif +template +static inline int +Run(const Path &output, const char *path, Args... args) noexcept +{ + const char *const argv[]{path, args..., nullptr}; + return Run(output, argv); +} + +// int +// Run(const Path &output, const char *path, ...) noexcept; + +// static inline +// int +// RunX(const std::filesystem::path output, const char *path) noexcept +// { + +// int +// RunX(const Path &output, const char *path) noexcept +// { +// const char *const argv[]{path, nullptr}; +// return Run(output, argv); +// } From b3926b6150c26f58e29f959ed0d1187f3e2874d5 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 3 Jan 2024 15:38:06 +0100 Subject: [PATCH 066/403] OV/System.cpp - use TCHAR* for Path - and disable all DBUS functions for _WIN32 --- src/OV/System.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/OV/System.cpp b/src/OV/System.cpp index a30b8f5f700..492a4e84eb9 100644 --- a/src/OV/System.cpp +++ b/src/OV/System.cpp @@ -54,7 +54,7 @@ OpenvarioGetBrightness() noexcept char line[4]; int result = 10; - if (File::ReadString(Path("/sys/class/backlight/lcd/brightness"), line, sizeof(line))) { + if (File::ReadString(Path(_T("/sys/class/backlight/lcd/brightness")), line, sizeof(line))) { result = atoi(line); } @@ -67,14 +67,14 @@ OpenvarioSetBrightness(uint_least8_t value) noexcept if (value < 1) { value = 1; } if (value > 10) { value = 10; } - File::WriteExisting(Path("/sys/class/backlight/lcd/brightness"), fmt::format_int{value}.c_str()); + File::WriteExisting(Path(_T("/sys/class/backlight/lcd/brightness")), fmt::format_int{value}.c_str()); } DisplayOrientation OpenvarioGetRotation() { std::map> map; - LoadConfigFile(map, Path("/boot/config.uEnv")); + LoadConfigFile(map, Path(_T("/boot/config.uEnv"))); uint_least8_t result; result = map.contains("rotation") ? std::stoi(map.find("rotation")->second) : 0; @@ -111,13 +111,14 @@ OpenvarioSetRotation(DisplayOrientation orientation) break; }; - File::WriteExisting(Path("/sys/class/graphics/fbcon/rotate"), fmt::format_int{rotation}.c_str()); + File::WriteExisting(Path(_T("/sys/class/graphics/fbcon/rotate")), fmt::format_int{rotation}.c_str()); - LoadConfigFile(map, Path("/boot/config.uEnv")); + LoadConfigFile(map, Path(_T("/boot/config.uEnv"))); map.insert_or_assign("rotation", fmt::format_int{rotation}.c_str()); - WriteConfigFile(map, Path("/boot/config.uEnv")); + WriteConfigFile(map, Path(_T("/boot/config.uEnv"))); } +#ifndef _WIN32 SSHStatus OpenvarioGetSSHStatus() { @@ -155,3 +156,4 @@ OpenvarioDisableSSH() Systemd::DisableUnitFile(connection, "dropbear.socket"); Systemd::StopUnit(connection, "dropbear.socket"); } +#endif // _WIN32 From 81004a8e9de1d02f4a6277c100dbc9c13057a48d Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 3 Jan 2024 21:44:42 +0100 Subject: [PATCH 067/403] FileMenuWidget.cpp - add ReadOnly button to split normal file commands from system backup and recovery --- src/OV/FileMenuWidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OV/FileMenuWidget.cpp b/src/OV/FileMenuWidget.cpp index 246973f0ae9..3d67a41ce51 100644 --- a/src/OV/FileMenuWidget.cpp +++ b/src/OV/FileMenuWidget.cpp @@ -49,7 +49,7 @@ FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, dialog_title, argv); }); - AddReadOnly(_T("System:")); + AddReadOnly(_T("--- System: ---")); title.Format(_("System Backup: OpenVario and %s settings to USB"), main_app); AddButton(title, []() { From f9059c68d83294e00b218f7be4a848acf545f2e7 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 4 Jan 2024 14:55:41 +0100 Subject: [PATCH 068/403] OpenVarioMenu.cpp - moved a lot of code to System.cpp --- src/OV/OpenVarioMenu.cpp | 661 +-------------------------------------- 1 file changed, 15 insertions(+), 646 deletions(-) diff --git a/src/OV/OpenVarioMenu.cpp b/src/OV/OpenVarioMenu.cpp index 6b9070ee623..d9c8779ef24 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OV/OpenVarioMenu.cpp @@ -2,22 +2,23 @@ // Copyright The XCSoar Project #include "Dialogs/DialogSettings.hpp" -#include "Dialogs/Message.hpp" +// #include "Dialogs/Message.hpp" #include "Dialogs/WidgetDialog.hpp" -#include "Dialogs/ProcessDialog.hpp" +// #include "Dialogs/ProcessDialog.hpp" #include "Widget/RowFormWidget.hpp" #include "UIGlobals.hpp" #include "Look/DialogLook.hpp" #include "Screen/Layout.hpp" -#include "../test/src/Fonts.hpp" +// #include "../test/src/Fonts.hpp" +// #include "Fonts.hpp" #include "ui/window/Init.hpp" #include "ui/window/SingleWindow.hpp" -#include "ui/event/Queue.hpp" +// #include "ui/event/Queue.hpp" #include "ui/event/Timer.hpp" #include "ui/event/KeyCode.hpp" #include "Language/Language.hpp" #include "system/Process.hpp" -#include "util/ScopeExit.hxx" +// #include "util/ScopeExit.hxx" #include "system/FileUtil.hpp" #include "Profile/File.hpp" #include "Profile/Map.hpp" @@ -25,37 +26,15 @@ #include "Hardware/DisplayGlue.hpp" #include "Hardware/DisplayDPI.hpp" #include "Hardware/RotateDisplay.hpp" -#include "FileMenuWidget.h" + +#include "OV/FileMenuWidget.h" +#include "OV/System.hpp" #include #include #include #include -static void GetConfigInt(const std::string &keyvalue, unsigned &value, - const TCHAR* path) { - const Path ConfigPath(path); - - ProfileMap configuration; - Profile::LoadFile(configuration, ConfigPath); - configuration.Get(keyvalue.c_str(), value); -} - -static void ChangeConfigInt(const std::string &keyvalue, int value, - const TCHAR *path) { - const Path ConfigPath(path); - - ProfileMap configuration; - - try { - Profile::LoadFile(configuration, ConfigPath); - } catch (std::exception &e) { - Profile::SaveFile(configuration, ConfigPath); - } - configuration.Set(keyvalue.c_str(), value); - Profile::SaveFile(configuration, ConfigPath); -} - template static void ChangeConfigString(const std::string &keyvalue, T value, const std::string &path) { @@ -72,10 +51,10 @@ static void ChangeConfigString(const std::string &keyvalue, T value, Profile::SaveFile(configuration, ConfigPath); } -enum Buttons { - LAUNCH_SHELL = 100, - START_UPGRADE = 111, -}; +// enum Buttons { +// LAUNCH_SHELL = 100, +// START_UPGRADE = 111, +// }; static DialogSettings dialog_settings; static UI::SingleWindow *global_main_window; @@ -103,616 +82,6 @@ UIGlobals::GetMainWindow() return *global_main_window; } -class ScreenRotationWidget final - : public RowFormWidget -{ - UI::Display &display; - UI::EventQueue &event_queue; - -public: - ScreenRotationWidget(UI::Display &_display, UI::EventQueue &_event_queue, - const DialogLook &look) noexcept - :RowFormWidget(look), - display(_display), event_queue(_event_queue) {} - -private: - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, - const PixelRect &rc) noexcept override; - void SaveRotation(const std::string &rotationvalue); -}; - -/* x-menu writes the value for the display rotation to /sys because the value is also required for the console in the OpenVario. -In addition, the display rotation is saved in /boot/config.uEnv so that the Openvario sets the correct rotation again when it is restarted.*/ -void -ScreenRotationWidget::SaveRotation(const std::string &rotationString) -{ - File::WriteExisting(Path(_T("/sys/class/graphics/fbcon/rotate")), (rotationString).c_str()); - int rotationInt = stoi(rotationString); - ChangeConfigInt("rotation", rotationInt, _T("/boot/config.uEnv")); -} - -void -ScreenRotationWidget::Prepare([[maybe_unused]] ContainerWindow &parent, - [[maybe_unused]] const PixelRect &rc) noexcept -{ - AddButton(_T("Landscape"), [this](){ - SaveRotation("0"); - Display::Rotate(DisplayOrientation::LANDSCAPE); - }); - - AddButton(_T("Portrait (90°)"), [this](){ - SaveRotation("1"); - Display::Rotate(DisplayOrientation::REVERSE_PORTRAIT); - }); - - AddButton(_T("Landscape (180°)"), [this](){ - SaveRotation("2"); - Display::Rotate(DisplayOrientation::REVERSE_LANDSCAPE); - }); - - AddButton(_T("Portrait (270°)"), [this](){ - SaveRotation("3"); - Display::Rotate(DisplayOrientation::PORTRAIT); - }); -} - -class ScreenBrightnessWidget final - : public RowFormWidget -{ - UI::Display &display; - UI::EventQueue &event_queue; - -public: - ScreenBrightnessWidget(UI::Display &_display, UI::EventQueue &_event_queue, - const DialogLook &look) noexcept - :RowFormWidget(look), - display(_display), event_queue(_event_queue) {} - -private: - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, - const PixelRect &rc) noexcept override; - -void SaveBrightness(const std::string &brightness); -}; - -void -ScreenBrightnessWidget::SaveBrightness(const std::string &brightness) -{ -File::WriteExisting(Path(_T("/sys/class/backlight/lcd/brightness")), - (brightness).c_str()); -} - -void -ScreenBrightnessWidget::Prepare([[maybe_unused]] ContainerWindow &parent, - [[maybe_unused]] const PixelRect &rc) noexcept -{ - AddButton(_T("20"), [this](){ - SaveBrightness("2"); - }); - - AddButton(_T("30"), [this](){ - SaveBrightness("3"); - }); - - AddButton(_T("40"), [this](){ - SaveBrightness("4"); - }); - - AddButton(_T("50"), [this](){ - SaveBrightness("5"); - }); - - AddButton(_T("60"), [this](){ - SaveBrightness("6"); - }); - - AddButton(_T("70"), [this](){ - SaveBrightness("7"); - }); - - AddButton(_T("80"), [this](){ - SaveBrightness("8"); - }); - - AddButton(_T("90"), [this](){ - SaveBrightness("9"); - }); - - AddButton(_T("100"), [this](){ - SaveBrightness("10"); - }); -} - - -class ScreenTimeoutWidget final - : public RowFormWidget -{ - UI::Display &display; - UI::EventQueue &event_queue; - -public: - ScreenTimeoutWidget(UI::Display &_display, UI::EventQueue &_event_queue, - const DialogLook &look) noexcept - :RowFormWidget(look), - display(_display), event_queue(_event_queue) {} - -private: - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, - const PixelRect &rc) noexcept override; - void SaveTimeout(int timeoutvalue); -}; - -void -ScreenTimeoutWidget::SaveTimeout(int timeoutInt) -{ - ChangeConfigInt("timeout", timeoutInt, _T("/boot/config.uEnv")); -} - -void -ScreenTimeoutWidget::Prepare([[maybe_unused]] ContainerWindow &parent, - [[maybe_unused]] const PixelRect &rc) noexcept - -{ - AddButton(_T("immediately"), [this](){ - SaveTimeout(0); - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "echo Automatic timeout was set to 0s", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("immediately"), argv); - }); - - AddButton(_T("1s"), [this](){ - SaveTimeout(1); - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "echo Automatic timeout was set to 1s", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("1s"), argv); - }); - - AddButton(_T("3s"), [this](){ - SaveTimeout(3); - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "echo Automatic timeout was set to 3s", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("3s"), argv); - }); - - AddButton(_T("5s"), [this](){ - SaveTimeout(5); - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "echo Automatic timeout was set to 5s", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("5s"), argv); - }); - - AddButton(_T("10s"), [this](){ - SaveTimeout(10); - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "echo Automatic timeout was set to 10s", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("10s"), argv); - }); - - AddButton(_T("30s"), [this](){ - SaveTimeout(30); - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "echo Automatic timeout was set to 30s", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("30s"), argv); - }); -} - -class ScreenSSHWidget final - : public RowFormWidget -{ - UI::Display &display; - UI::EventQueue &event_queue; - -public: - ScreenSSHWidget(UI::Display &_display, UI::EventQueue &_event_queue, - const DialogLook &look) noexcept - :RowFormWidget(look), - display(_display), event_queue(_event_queue) {} - -private: - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, - const PixelRect &rc) noexcept override; -}; - -void -ScreenSSHWidget::Prepare([[maybe_unused]] ContainerWindow &parent, - [[maybe_unused]] const PixelRect &rc) noexcept -{ - AddButton(_T("Enable") , [](){ - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "systemctl enable dropbear.socket && printf '\nSSH has been enabled'", - - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("Enable"), argv); - }); - - AddButton(_T("Disable") , [](){ - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "systemctl disable dropbear.socket && printf '\nSSH has been disabled'", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("Disable"), argv); - }); -} - -class ScreenVariodWidget final - : public RowFormWidget -{ - UI::Display &display; - UI::EventQueue &event_queue; - -public: - ScreenVariodWidget(UI::Display &_display, UI::EventQueue &_event_queue, - const DialogLook &look) noexcept - :RowFormWidget(look), - display(_display), event_queue(_event_queue) {} - -private: - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, - const PixelRect &rc) noexcept override; -}; - -void -ScreenVariodWidget::Prepare([[maybe_unused]] ContainerWindow &parent, - [[maybe_unused]] const PixelRect &rc) noexcept -{ - AddButton(_T("Enable") , [](){ - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "systemctl enable variod && printf '\nvariod has been enabled'", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("Enable"), argv); - }); - - AddButton(_T("Disable"), [](){ - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "systemctl disable variod && printf '\nvariod has been disabled'", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("Disable"), argv); - }); -} - -class ScreenSensordWidget final - : public RowFormWidget -{ - UI::Display &display; - UI::EventQueue &event_queue; - -public: - ScreenSensordWidget(UI::Display &_display, UI::EventQueue &_event_queue, - const DialogLook &look) noexcept - :RowFormWidget(look), - display(_display), event_queue(_event_queue) {} - -private: - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, - const PixelRect &rc) noexcept override; -}; - -void -ScreenSensordWidget::Prepare([[maybe_unused]] ContainerWindow &parent, - [[maybe_unused]] const PixelRect &rc) noexcept -{ - AddButton(_T("Enable"), [](){ - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "systemctl enable sensord && printf '\nsensord has been enabled'", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("Enable"), argv); - }); - - AddButton(_T("Disable"), [](){ - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "systemctl disable sensord && printf '\nsensord has been disabled'", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("Disable"), argv); - }); -} - -class SystemSettingsWidget final - : public RowFormWidget -{ - UI::Display &display; - UI::EventQueue &event_queue; - - WndForm &dialog; - -public: - SystemSettingsWidget(UI::Display &_display, UI::EventQueue &_event_queue, - WndForm &_dialog) noexcept - :RowFormWidget(_dialog.GetLook()), - display(_display), event_queue(_event_queue), - dialog(_dialog) {} - -private: - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, - const PixelRect &rc) noexcept override; -}; - -void -SystemSettingsWidget::Prepare([[maybe_unused]] ContainerWindow &parent, - [[maybe_unused]] const PixelRect &rc) noexcept -{ - AddButton(_("Screen Rotation"), [this](){ - TWidgetDialog - sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), _T("Display Rotation Settings")); - sub_dialog.SetWidget(display, event_queue, GetLook()); - sub_dialog.AddButton(_("Close"), mrOK); - return sub_dialog.ShowModal(); - }); - - AddButton(_("Screen Brightness"), [this](){ - TWidgetDialog - sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), _T("Display Brightness Settings")); - sub_dialog.SetWidget(display, event_queue, GetLook()); - sub_dialog.AddButton(_("Close"), mrOK); - return sub_dialog.ShowModal(); - }); - - AddButton(_("Autostart Timeout"), [this](){ - TWidgetDialog - sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), _T("Autostart Timeout")); - sub_dialog.SetWidget(display, event_queue, GetLook()); - sub_dialog.AddButton(_("Close"), mrOK); - return sub_dialog.ShowModal(); - }); - - AddButton(_("SSH"), [this](){ - TWidgetDialog - sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), _T("Enable or Disable SSH")); - sub_dialog.SetWidget(display, event_queue, GetLook()); - sub_dialog.AddButton(_("Close"), mrOK); - return sub_dialog.ShowModal(); - }); - - AddButton(_("Variod"), [this](){ - TWidgetDialog - sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), _T("Enable or Disable Variod")); - sub_dialog.SetWidget(display, event_queue, GetLook()); - sub_dialog.AddButton(_("Close"), mrOK); - return sub_dialog.ShowModal(); - }); - - AddButton(_("Sensord"), [this](){ - TWidgetDialog - sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), _T("Enable or Disable Sensord")); - sub_dialog.SetWidget(display, event_queue, GetLook()); - sub_dialog.AddButton(_("Close"), mrOK); - return sub_dialog.ShowModal(); - }); -} - -class SystemMenuWidget final - : public RowFormWidget -{ - UI::Display &display; - UI::EventQueue &event_queue; - - WndForm &dialog; - -public: - SystemMenuWidget(UI::Display &_display, UI::EventQueue &_event_queue, - WndForm &_dialog) noexcept - :RowFormWidget(_dialog.GetLook()), - display(_display), event_queue(_event_queue), - dialog(_dialog) {} - -private: - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, - const PixelRect &rc) noexcept override; -}; - -static void -CalibrateSensors() noexcept -{ - /* make sure sensord is stopped while calibrating sensors */ - static constexpr const char *start_sensord[] = { - "/bin/systemctl", "start", "sensord.service", nullptr - }; - static constexpr const char *stop_sensord[] = { - "/bin/systemctl", "stop", "sensord.service", nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("Calibrate Sensors"), stop_sensord, - [](int status){ - return status == EXIT_SUCCESS ? mrOK : 0; - }); - - AtScopeExit(){ - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("Calibrate Sensors"), start_sensord, - [](int status){ - return status == EXIT_SUCCESS ? mrOK : 0; - }); - }; - - /* calibrate the sensors */ - static constexpr const char *calibrate_sensors[] = { - "/opt/bin/sensorcal", "-c", nullptr - }; - - static constexpr int STATUS_BOARD_NOT_INITIALISED = 2; - static constexpr int RESULT_BOARD_NOT_INITIALISED = 100; - int result = RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("Calibrate Sensors"), calibrate_sensors, - [](int status){ - return status == STATUS_BOARD_NOT_INITIALISED - ? RESULT_BOARD_NOT_INITIALISED - : 0; - }); - if (result != RESULT_BOARD_NOT_INITIALISED) - return; - - /* initialise the sensors? */ - if (ShowMessageBox(_T("Sensorboard is virgin. Do you want to initialise it?"), - _T("Calibrate Sensors"), MB_YESNO) != IDYES) - return; - - static constexpr const char *init_sensors[] = { - "/opt/bin/sensorcal", "-i", nullptr - }; - - result = RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("Calibrate Sensors"), init_sensors, - [](int status){ - return status == EXIT_SUCCESS - ? mrOK - : 0; - }); - if (result != mrOK) - return; - - /* calibrate again */ - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("Calibrate Sensors"), calibrate_sensors, - [](int status){ - return status == STATUS_BOARD_NOT_INITIALISED - ? RESULT_BOARD_NOT_INITIALISED - : 0; - }); -} - -void -SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, - [[maybe_unused]] const PixelRect &rc) noexcept -{ - AddButton(_("WiFi Settings"), [](){ - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "printf '\nWiFi-Settings are not implemented, yet!! \n\nIf you are interessted to help with this, write me an email: dirk@freevario.de'", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("WiFi Settings"), argv); - }); - - - AddButton(_("Upgrade Firmware"), [this](){ - // dialog.SetModalResult(START_UPGRADE); - exit(START_UPGRADE); - }); - - AddButton(_("Update System"), [](){ - static constexpr const char *argv[] = { - "/usr/bin/update-system.sh", nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("Update System"), argv); - }); - - AddButton(_("Calibrate Sensors"), CalibrateSensors); - AddButton(_("Calibrate Touch"), [this](){ - const UI::ScopeDropMaster drop_master{display}; - const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; - Run("/usr/bin/ov-calibrate-ts.sh"); - }); - - AddButton(_("System Settings"), [this](){ - - TWidgetDialog - sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), _T("OpenVario System Settings")); - sub_dialog.SetWidget(display, event_queue, sub_dialog); - sub_dialog.AddButton(_("Close"), mrOK); - return sub_dialog.ShowModal(); - }); - - AddButton(_("System Info"), [](){ - static constexpr const char *argv[] = { - "/usr/bin/system-info.sh", nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("System Info"), argv); - }); -} class MainMenuWidget final : public RowFormWidget @@ -901,7 +270,7 @@ Main() ScreenGlobalInit screen_init; Layout::Initialise(screen_init.GetDisplay(), {600, 800}); - InitialiseFonts(); + // InitialiseFonts(); DialogLook dialog_look; dialog_look.Initialise(); @@ -923,7 +292,7 @@ Main() main_window.Destroy(); - DeinitialiseFonts(); + // DeinitialiseFonts(); return action; } From c6e64b0e0495c444f7723ea8a675f94ac0cae556 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sat, 6 Jan 2024 10:50:14 +0100 Subject: [PATCH 069/403] System.cpp - receive a lot of code --- src/OV/System.cpp | 649 +++++++++++++++++++++++++++++++++++++++++++++- src/OV/System.hpp | 81 ++++++ 2 files changed, 723 insertions(+), 7 deletions(-) diff --git a/src/OV/System.cpp b/src/OV/System.cpp index 492a4e84eb9..6c1e8f9f04b 100644 --- a/src/OV/System.cpp +++ b/src/OV/System.cpp @@ -3,19 +3,67 @@ #include "System.hpp" #ifndef _WIN32 -#include "lib/dbus/Connection.hxx" -#include "lib/dbus/ScopeMatch.hxx" -#include "lib/dbus/Systemd.hxx" +# include "lib/dbus/Connection.hxx" +# include "lib/dbus/ScopeMatch.hxx" +# include "lib/dbus/Systemd.hxx" #endif + +// #include "../test/src/Fonts.hpp" +/* +#include "Dialogs/DialogSettings.hpp" +#include "Dialogs/Message.hpp" +#include "Dialogs/ProcessDialog.hpp" +#include "Dialogs/WidgetDialog.hpp" +#include "DisplayOrientation.hpp" +#include "FileMenuWidget.h" +#include "Hardware/DisplayDPI.hpp" +#include "Hardware/DisplayGlue.hpp" +#include "Hardware/RotateDisplay.hpp" +#include "Look/DialogLook.hpp" +#include "Profile/File.hpp" +#include "Profile/Map.hpp" +#include "Screen/Layout.hpp" +#include "UIGlobals.hpp" +#include "Widget/RowFormWidget.hpp" #include "system/FileUtil.hpp" -#include "system/Path.hpp" +#include "system/Process.hpp" +#include "ui/event/KeyCode.hpp" +#include "ui/event/Queue.hpp" +#include "ui/event/Timer.hpp" +#include "ui/window/Init.hpp" +#include "ui/window/SingleWindow.hpp" +*/ +#include "util/ScopeExit.hxx" + +// #include "system/FileUtil.hpp" +// #include "system/Path.hpp" #include "io/KeyValueFileReader.hpp" #include "io/FileOutputStream.hxx" #include "io/BufferedOutputStream.hxx" #include "io/FileLineReader.hpp" -#include "Dialogs/Error.hpp" -#include "DisplayOrientation.hpp" -#include "Hardware/RotateDisplay.hpp" +// #include "Dialogs/Error.hpp" +// #include "DisplayOrientation.hpp" +// #include "Hardware/RotateDisplay.hpp" +// +// #include "Dialogs/DialogSettings.hpp" +// #include "Dialogs/Message.hpp" +// #include "Dialogs/WidgetDialog.hpp" +// #include "Dialogs/ProcessDialog.hpp" +// #include "Widget/RowFormWidget.hpp" +// #include "UIGlobals.hpp" +// #include "Look/DialogLook.hpp" +// #include "Screen/Layout.hpp" +// +// #include "ui/event/KeyCode.hpp" +// #include "ui/event/Queue.hpp" +// #include "ui/event/Timer.hpp" +// #include "ui/window/Init.hpp" +// #include "ui/window/SingleWindow.hpp" +// #include "Language/Language.hpp" +// #include "system/Process.hpp" +// #include "util/ScopeExit.hxx" + +#include "OV/System.hpp" #ifndef _WIN32 #include @@ -157,3 +205,590 @@ OpenvarioDisableSSH() Systemd::StopUnit(connection, "dropbear.socket"); } #endif // _WIN32 + + +void GetConfigInt(const std::string &keyvalue, unsigned &value, + const TCHAR* path) { + const Path ConfigPath(path); + + ProfileMap configuration; + Profile::LoadFile(configuration, ConfigPath); + configuration.Get(keyvalue.c_str(), value); +} + +void ChangeConfigInt(const std::string &keyvalue, int value, + const TCHAR *path) { + const Path ConfigPath(path); + + ProfileMap configuration; + + try { + Profile::LoadFile(configuration, ConfigPath); + } catch (std::exception &e) { + Profile::SaveFile(configuration, ConfigPath); + } + configuration.Set(keyvalue.c_str(), value); + Profile::SaveFile(configuration, ConfigPath); +} + + +static void CalibrateSensors() noexcept { + /* make sure sensord is stopped while calibrating sensors */ + static constexpr const char *start_sensord[] = {"/bin/systemctl", "start", + "sensord.service", nullptr}; + static constexpr const char *stop_sensord[] = {"/bin/systemctl", "stop", + "sensord.service", nullptr}; + + RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), + _T("Calibrate Sensors"), stop_sensord, [](int status) { + return status == EXIT_SUCCESS ? mrOK : 0; + }); + + AtScopeExit() { + RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), + _T("Calibrate Sensors"), start_sensord, [](int status) { + return status == EXIT_SUCCESS ? mrOK : 0; + }); + }; + + /* calibrate the sensors */ + static constexpr const char *calibrate_sensors[] = {"/opt/bin/sensorcal", + "-c", nullptr}; + + static constexpr int STATUS_BOARD_NOT_INITIALISED = 2; + static constexpr int RESULT_BOARD_NOT_INITIALISED = 100; + int result = RunProcessDialog( + UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), + _T("Calibrate Sensors"), calibrate_sensors, [](int status) { + return status == STATUS_BOARD_NOT_INITIALISED + ? RESULT_BOARD_NOT_INITIALISED + : 0; + }); + if (result != RESULT_BOARD_NOT_INITIALISED) + return; + + /* initialise the sensors? */ + if (ShowMessageBox(_T("Sensorboard is virgin. Do you want to initialise it?"), + _T("Calibrate Sensors"), MB_YESNO) != IDYES) + return; + + static constexpr const char *init_sensors[] = {"/opt/bin/sensorcal", "-i", + nullptr}; + + result = + RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), + _T("Calibrate Sensors"), init_sensors, [](int status) { + return status == EXIT_SUCCESS ? mrOK : 0; + }); + if (result != mrOK) + return; + + /* calibrate again */ + RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), + _T("Calibrate Sensors"), calibrate_sensors, [](int status) { + return status == STATUS_BOARD_NOT_INITIALISED + ? RESULT_BOARD_NOT_INITIALISED + : 0; + }); +} + +void +SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, + [[maybe_unused]] const PixelRect &rc) noexcept +{ + AddButton(_("WiFi Settings"), [](){ + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "printf '\nWiFi-Settings are not implemented, yet!! \n\nIf you are interessted to help with this, write me an email: dirk@freevario.de'", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _T("WiFi Settings"), argv); + }); + + + AddButton(_("Upgrade Firmware"), [this](){ + // dialog.SetModalResult(START_UPGRADE); + exit(START_UPGRADE); + }); + + AddButton(_("Update System"), [](){ + static constexpr const char *argv[] = { + "/usr/bin/update-system.sh", nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _T("Update System"), argv); + }); + + AddButton(_("Calibrate Sensors"), CalibrateSensors); + AddButton(_("Calibrate Touch"), [this](){ + const UI::ScopeDropMaster drop_master{display}; + const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; + Run("/usr/bin/ov-calibrate-ts.sh"); + }); + + AddButton(_("System Settings"), [this](){ + + TWidgetDialog + sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), + GetLook(), _T("OpenVario System Settings")); + sub_dialog.SetWidget(display, event_queue, sub_dialog); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); + }); + + AddButton(_("System Info"), [](){ + static constexpr const char *argv[] = { + "/usr/bin/system-info.sh", nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _T("System Info"), argv); + }); +} + +//---------------------------------------------------------- +//---------------------------------------------------------- +//---------------------------------------------------------- + +class ScreenRotationWidget final + : public RowFormWidget +{ + UI::Display &display; + UI::EventQueue &event_queue; + +public: + ScreenRotationWidget(UI::Display &_display, UI::EventQueue &_event_queue, + const DialogLook &look) noexcept + :RowFormWidget(look), + display(_display), event_queue(_event_queue) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, + const PixelRect &rc) noexcept override; + void SaveRotation(const std::string &rotationvalue); +}; + +/* x-menu writes the value for the display rotation to /sys because the value is also required for the console in the OpenVario. +In addition, the display rotation is saved in /boot/config.uEnv so that the Openvario sets the correct rotation again when it is restarted.*/ +void +ScreenRotationWidget::SaveRotation(const std::string &rotationString) +{ + File::WriteExisting(Path(_T("/sys/class/graphics/fbcon/rotate")), (rotationString).c_str()); + int rotationInt = stoi(rotationString); + ChangeConfigInt("rotation", rotationInt, _T("/boot/config.uEnv")); +} + +void +ScreenRotationWidget::Prepare([[maybe_unused]] ContainerWindow &parent, + [[maybe_unused]] const PixelRect &rc) noexcept +{ + AddButton(_T("Landscape"), [this](){ + SaveRotation("0"); + Display::Rotate(DisplayOrientation::LANDSCAPE); + }); + + AddButton(_T("Portrait (90°)"), [this](){ + SaveRotation("1"); + Display::Rotate(DisplayOrientation::REVERSE_PORTRAIT); + }); + + AddButton(_T("Landscape (180°)"), [this](){ + SaveRotation("2"); + Display::Rotate(DisplayOrientation::REVERSE_LANDSCAPE); + }); + + AddButton(_T("Portrait (270°)"), [this](){ + SaveRotation("3"); + Display::Rotate(DisplayOrientation::PORTRAIT); + }); +} + +class ScreenBrightnessWidget final + : public RowFormWidget +{ + UI::Display &display; + UI::EventQueue &event_queue; + +public: + ScreenBrightnessWidget(UI::Display &_display, UI::EventQueue &_event_queue, + const DialogLook &look) noexcept + :RowFormWidget(look), + display(_display), event_queue(_event_queue) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, + const PixelRect &rc) noexcept override; + +void SaveBrightness(const std::string &brightness); +}; + +void +ScreenBrightnessWidget::SaveBrightness(const std::string &brightness) +{ +File::WriteExisting(Path(_T("/sys/class/backlight/lcd/brightness")), + (brightness).c_str()); +} + +void +ScreenBrightnessWidget::Prepare([[maybe_unused]] ContainerWindow &parent, + [[maybe_unused]] const PixelRect &rc) noexcept +{ + AddButton(_T("20"), [this](){ + SaveBrightness("2"); + }); + + AddButton(_T("30"), [this](){ + SaveBrightness("3"); + }); + + AddButton(_T("40"), [this](){ + SaveBrightness("4"); + }); + + AddButton(_T("50"), [this](){ + SaveBrightness("5"); + }); + + AddButton(_T("60"), [this](){ + SaveBrightness("6"); + }); + + AddButton(_T("70"), [this](){ + SaveBrightness("7"); + }); + + AddButton(_T("80"), [this](){ + SaveBrightness("8"); + }); + + AddButton(_T("90"), [this](){ + SaveBrightness("9"); + }); + + AddButton(_T("100"), [this](){ + SaveBrightness("10"); + }); +} + + +class ScreenTimeoutWidget final + : public RowFormWidget +{ + UI::Display &display; + UI::EventQueue &event_queue; + +public: + ScreenTimeoutWidget(UI::Display &_display, UI::EventQueue &_event_queue, + const DialogLook &look) noexcept + :RowFormWidget(look), + display(_display), event_queue(_event_queue) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, + const PixelRect &rc) noexcept override; + void SaveTimeout(int timeoutvalue); +}; + +void +ScreenTimeoutWidget::SaveTimeout(int timeoutInt) +{ + ChangeConfigInt("timeout", timeoutInt, _T("/boot/config.uEnv")); +} + +void +ScreenTimeoutWidget::Prepare([[maybe_unused]] ContainerWindow &parent, + [[maybe_unused]] const PixelRect &rc) noexcept + +{ + AddButton(_T("immediately"), [this](){ + SaveTimeout(0); + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "echo Automatic timeout was set to 0s", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _T("immediately"), argv); + }); + + AddButton(_T("1s"), [this](){ + SaveTimeout(1); + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "echo Automatic timeout was set to 1s", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _T("1s"), argv); + }); + + AddButton(_T("3s"), [this](){ + SaveTimeout(3); + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "echo Automatic timeout was set to 3s", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _T("3s"), argv); + }); + + AddButton(_T("5s"), [this](){ + SaveTimeout(5); + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "echo Automatic timeout was set to 5s", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _T("5s"), argv); + }); + + AddButton(_T("10s"), [this](){ + SaveTimeout(10); + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "echo Automatic timeout was set to 10s", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _T("10s"), argv); + }); + + AddButton(_T("30s"), [this](){ + SaveTimeout(30); + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "echo Automatic timeout was set to 30s", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _T("30s"), argv); + }); +} + +class ScreenSSHWidget final + : public RowFormWidget +{ + UI::Display &display; + UI::EventQueue &event_queue; + +public: + ScreenSSHWidget(UI::Display &_display, UI::EventQueue &_event_queue, + const DialogLook &look) noexcept + :RowFormWidget(look), + display(_display), event_queue(_event_queue) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, + const PixelRect &rc) noexcept override; +}; + +void +ScreenSSHWidget::Prepare([[maybe_unused]] ContainerWindow &parent, + [[maybe_unused]] const PixelRect &rc) noexcept +{ + AddButton(_T("Enable") , [](){ + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "systemctl enable dropbear.socket && printf '\nSSH has been enabled'", + + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _T("Enable"), argv); + }); + + AddButton(_T("Disable") , [](){ + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "systemctl disable dropbear.socket && printf '\nSSH has been disabled'", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _T("Disable"), argv); + }); +} + +class ScreenVariodWidget final + : public RowFormWidget +{ + UI::Display &display; + UI::EventQueue &event_queue; + +public: + ScreenVariodWidget(UI::Display &_display, UI::EventQueue &_event_queue, + const DialogLook &look) noexcept + :RowFormWidget(look), + display(_display), event_queue(_event_queue) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, + const PixelRect &rc) noexcept override; +}; + +void +ScreenVariodWidget::Prepare([[maybe_unused]] ContainerWindow &parent, + [[maybe_unused]] const PixelRect &rc) noexcept +{ + AddButton(_T("Enable") , [](){ + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "systemctl enable variod && printf '\nvariod has been enabled'", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _T("Enable"), argv); + }); + + AddButton(_T("Disable"), [](){ + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "systemctl disable variod && printf '\nvariod has been disabled'", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _T("Disable"), argv); + }); +} + +class ScreenSensordWidget final + : public RowFormWidget +{ + UI::Display &display; + UI::EventQueue &event_queue; + +public: + ScreenSensordWidget(UI::Display &_display, UI::EventQueue &_event_queue, + const DialogLook &look) noexcept + :RowFormWidget(look), + display(_display), event_queue(_event_queue) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, + const PixelRect &rc) noexcept override; +}; + +void +ScreenSensordWidget::Prepare([[maybe_unused]] ContainerWindow &parent, + [[maybe_unused]] const PixelRect &rc) noexcept +{ + AddButton(_T("Enable"), [](){ + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "systemctl enable sensord && printf '\nsensord has been enabled'", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _T("Enable"), argv); + }); + + AddButton(_T("Disable"), [](){ + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "systemctl disable sensord && printf '\nsensord has been disabled'", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _T("Disable"), argv); + }); +} +//---------------------------------------------------------- +//---------------------------------------------------------- +//---------------------------------------------------------- + +void +SystemSettingsWidget::Prepare([[maybe_unused]] ContainerWindow &parent, + [[maybe_unused]] const PixelRect &rc) noexcept +{ + AddButton(_("Screen Rotation"), [this](){ + TWidgetDialog + sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), + GetLook(), _T("Display Rotation Settings")); + sub_dialog.SetWidget(display, event_queue, GetLook()); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); + }); + + AddButton(_("Screen Brightness"), [this](){ + TWidgetDialog + sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), + GetLook(), _T("Display Brightness Settings")); + sub_dialog.SetWidget(display, event_queue, GetLook()); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); + }); + + AddButton(_("Autostart Timeout"), [this](){ + TWidgetDialog + sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), + GetLook(), _T("Autostart Timeout")); + sub_dialog.SetWidget(display, event_queue, GetLook()); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); + }); + + AddButton(_("SSH"), [this](){ + TWidgetDialog + sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), + GetLook(), _T("Enable or Disable SSH")); + sub_dialog.SetWidget(display, event_queue, GetLook()); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); + }); + + AddButton(_("Variod"), [this](){ + TWidgetDialog + sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), + GetLook(), _T("Enable or Disable Variod")); + sub_dialog.SetWidget(display, event_queue, GetLook()); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); + }); + + AddButton(_("Sensord"), [this](){ + TWidgetDialog + sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), + GetLook(), _T("Enable or Disable Sensord")); + sub_dialog.SetWidget(display, event_queue, GetLook()); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); + }); +} + diff --git a/src/OV/System.hpp b/src/OV/System.hpp index 070fcb800e4..92d9b0c1358 100644 --- a/src/OV/System.hpp +++ b/src/OV/System.hpp @@ -3,7 +3,31 @@ #pragma once +#include "Dialogs/DialogSettings.hpp" +#include "Dialogs/Message.hpp" +#include "Dialogs/ProcessDialog.hpp" +#include "Dialogs/WidgetDialog.hpp" #include "DisplayOrientation.hpp" +#include "FileMenuWidget.h" +#include "Hardware/DisplayDPI.hpp" +#include "Hardware/DisplayGlue.hpp" +#include "Hardware/RotateDisplay.hpp" +#include "Look/DialogLook.hpp" +#include "Profile/File.hpp" +#include "Profile/Map.hpp" +#include "Screen/Layout.hpp" +#include "UIGlobals.hpp" +#include "Widget/RowFormWidget.hpp" +#include "system/FileUtil.hpp" +#include "system/Process.hpp" +#include "ui/event/KeyCode.hpp" +#include "ui/event/Queue.hpp" +#include "ui/event/Timer.hpp" +#include "ui/window/Init.hpp" +#include "ui/window/SingleWindow.hpp" + +#include "Language/Language.hpp" + #include #include @@ -15,6 +39,12 @@ enum class SSHStatus { DISABLED, TEMPORARY, }; + +enum Buttons { + LAUNCH_SHELL = 100, + START_UPGRADE = 111, +}; + /** * Load a system config file and put its variables into a map */ @@ -46,3 +76,54 @@ OpenvarioEnableSSH(bool temporary); void OpenvarioDisableSSH(); + +void GetConfigInt(const std::string &keyvalue, unsigned &value, + const TCHAR *path); + +void ChangeConfigInt(const std::string &keyvalue, int value, + const TCHAR *path); + + +class SystemMenuWidget final + : public RowFormWidget +{ + UI::Display &display; + UI::EventQueue &event_queue; + + WndForm &dialog; + +public: + SystemMenuWidget(UI::Display &_display, UI::EventQueue &_event_queue, + WndForm &_dialog) noexcept + :RowFormWidget(_dialog.GetLook()), + display(_display), event_queue(_event_queue), + dialog(_dialog) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, + const PixelRect &rc) noexcept override; +}; + + +class SystemSettingsWidget final + : public RowFormWidget +{ + UI::Display &display; + UI::EventQueue &event_queue; + + WndForm &dialog; + +public: + SystemSettingsWidget(UI::Display &_display, UI::EventQueue &_event_queue, + WndForm &_dialog) noexcept + :RowFormWidget(_dialog.GetLook()), + display(_display), event_queue(_event_queue), + dialog(_dialog) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, + const PixelRect &rc) noexcept override; +}; + From ed3b80846a1a334187e14611059449b2bfadf51f Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 4 Jan 2024 15:07:06 +0100 Subject: [PATCH 070/403] OV/System.cpp - remove dbus includes from system --- src/OV/System.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/OV/System.cpp b/src/OV/System.cpp index 6c1e8f9f04b..1f28b49d583 100644 --- a/src/OV/System.cpp +++ b/src/OV/System.cpp @@ -166,7 +166,8 @@ OpenvarioSetRotation(DisplayOrientation orientation) WriteConfigFile(map, Path(_T("/boot/config.uEnv"))); } -#ifndef _WIN32 +// #ifndef _WIN32 +#if 0 SSHStatus OpenvarioGetSSHStatus() { From 6a24658f2f0494900217924facf2645871bb59f4 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sat, 6 Jan 2024 10:51:27 +0100 Subject: [PATCH 071/403] [build] ov.mk - add System and Setting --- build/ov.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/ov.mk b/build/ov.mk index 4040c11c904..877ff97b407 100644 --- a/build/ov.mk +++ b/build/ov.mk @@ -32,6 +32,8 @@ OV_MENU_SOURCES = \ $(TEST_SRC_DIR)/FakeLogFile.cpp \ $(SRC)/Kobo/FakeSymbols.cpp \ $(SRC)/OV/FileMenuWidget.cpp\ + $(SRC)/OV/Settings.cpp\ + $(SRC)/OV/System.cpp\ $(SRC)/OV/OpenVarioMenu.cpp OV_MENU_DEPENDS = WIDGET FORM DATA_FIELD SCREEN EVENT RESOURCE ASYNC LIBNET OS IO THREAD TIME MATH UTIL OV_MENU_STRIP = y From c871dbbd0e801ca097d3e25fd17f9cb58ed93816 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sat, 6 Jan 2024 10:52:34 +0100 Subject: [PATCH 072/403] Settings.cpp - prepare for add to ov.mk --- src/OV/Settings.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/OV/Settings.cpp b/src/OV/Settings.cpp index ca2e9617c3a..0c366fa73dc 100644 --- a/src/OV/Settings.cpp +++ b/src/OV/Settings.cpp @@ -1,7 +1,15 @@ -#include "OV/Settings.hpp" -#include "OV/System.hpp" +#include "Dialogs/DialogSettings.hpp" +#include "Dialogs/Message.hpp" +#include "Dialogs/WidgetDialog.hpp" +#include "Dialogs/ProcessDialog.hpp" #include "Widget/RowFormWidget.hpp" +// #include "UIGlobals.hpp" +// #include "Look/DialogLook.hpp" +// #include "Screen/Layout.hpp" + +#include "OV/System.hpp" +#include "OV/Settings.hpp" #include #include From dfc432cbd7b4fb13b0b10f832e42e12a9d43470c Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 4 Jan 2024 16:15:50 +0100 Subject: [PATCH 073/403] OpenVarioMenu - start a complete reorganize rename FileMenuWidget rename OV in OpenVario --- src/OV/Settings.cpp | 177 ---------- src/OV/Settings.hpp | 40 --- src/OV/System.hpp | 129 ------- src/{OV => OpenVario}/FileMenuWidget.cpp | 0 src/{OV => OpenVario}/FileMenuWidget.h | 0 src/{OV => OpenVario}/OpenVarioMenu.cpp | 5 +- src/OpenVario/System/System.cpp | 212 ++++++++++++ src/OpenVario/System/System.hpp | 67 ++++ src/OpenVario/System/SystemMenuWidget.cpp | 158 +++++++++ src/OpenVario/System/SystemMenuWidget.hpp | 32 ++ .../System/SystemSettingsWidget.cpp} | 322 +----------------- src/OpenVario/System/SystemSettingsWidget.hpp | 30 ++ 12 files changed, 512 insertions(+), 660 deletions(-) delete mode 100644 src/OV/Settings.cpp delete mode 100644 src/OV/Settings.hpp delete mode 100644 src/OV/System.hpp rename src/{OV => OpenVario}/FileMenuWidget.cpp (100%) rename src/{OV => OpenVario}/FileMenuWidget.h (100%) rename src/{OV => OpenVario}/OpenVarioMenu.cpp (98%) create mode 100644 src/OpenVario/System/System.cpp create mode 100644 src/OpenVario/System/System.hpp create mode 100644 src/OpenVario/System/SystemMenuWidget.cpp create mode 100644 src/OpenVario/System/SystemMenuWidget.hpp rename src/{OV/System.cpp => OpenVario/System/SystemSettingsWidget.cpp} (59%) create mode 100644 src/OpenVario/System/SystemSettingsWidget.hpp diff --git a/src/OV/Settings.cpp b/src/OV/Settings.cpp deleted file mode 100644 index 0c366fa73dc..00000000000 --- a/src/OV/Settings.cpp +++ /dev/null @@ -1,177 +0,0 @@ - -#include "Dialogs/DialogSettings.hpp" -#include "Dialogs/Message.hpp" -#include "Dialogs/WidgetDialog.hpp" -#include "Dialogs/ProcessDialog.hpp" -#include "Widget/RowFormWidget.hpp" -// #include "UIGlobals.hpp" -// #include "Look/DialogLook.hpp" -// #include "Screen/Layout.hpp" - -#include "OV/System.hpp" -#include "OV/Settings.hpp" - -#include -#include - -#if OV_SETTINGS - -static DialogSettings dialog_settings; -static UI::SingleWindow *global_main_window; -static DialogLook *global_dialog_look; - -const DialogSettings & -UIGlobals::GetDialogSettings() -{ - return dialog_settings; -} - -const DialogLook & -UIGlobals::GetDialogLook() -{ - assert(global_dialog_look != nullptr); - - return *global_dialog_look; -} - -UI::SingleWindow & -UIGlobals::GetMainWindow() -{ - assert(global_main_window != nullptr); - - return *global_main_window; -} - - - -void -SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, - [[maybe_unused]] const PixelRect &rc) noexcept -{ - AddButton("Upgrade Firmware", [](){ - static constexpr const char *argv[] = { - "/usr/bin/fw-upgrade.sh", nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - "Upgrade Firmware", argv); - }); - - AddButton("Update System", [](){ - static constexpr const char *argv[] = { - "/usr/bin/update-system.sh", nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - "Update System", argv); - }); - - AddButton("Calibrate Sensors", CalibrateSensors); - AddButton("Calibrate Touch", [this](){ - const UI::ScopeDropMaster drop_master{display}; - const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; - Run("/usr/bin/ov-calibrate-ts.sh"); - }); - - AddButton("System Settings", [this](){ - const UI::ScopeDropMaster drop_master{display}; - const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; - Run("/usr/lib/openvario/libexec/system_settings.sh"); - }); - - AddButton("System Info", [this](){ - const UI::ScopeDropMaster drop_master{display}; - const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; - Run("/usr/lib/openvario/libexec/system_info.sh"); - }); -} - -#endif - -#if OV_SETTINGS - -#include "Profile/File.hpp" -#include "system/FileUtil.hpp" - -class ScreenBrightnessWidget final - : public RowFormWidget -{ - UI::Display &display; - UI::EventQueue &event_queue; - -public: - ScreenBrightnessWidget(UI::Display &_display, UI::EventQueue &_event_queue, - const DialogLook &look) noexcept - :RowFormWidget(look), - display(_display), event_queue(_event_queue) {} - -private: - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, - const PixelRect &rc) noexcept override; - - uint_least8_t brightness = 10; - void SaveBrightness(const string &brightness); -}; - -void -ScreenBrightnessWidget::SaveBrightness(const string &brightness) -{ - File::WriteExisting(Path("/sys/class/backlight/lcd/brightness"), (brightness).c_str()); -} - -void -ScreenBrightnessWidget::Prepare([[maybe_unused]] ContainerWindow &parent, - [[maybe_unused]] const PixelRect &rc) noexcept -{ -#if 0 - for (unsigned i = 1; i <= 10; i++) { - // char buffer[10]; - // sprintf // (buffer, "%d", i * 10); - brightness = i; - AddButton(fmt::format_int{i*10}.c_str(), [this]() { - OpenvarioSetBrightness(brightness); // i); - // SaveBrightness("2"); - }); - } -#else - AddButton("20", [this](){ - SaveBrightness("2"); - }); - - AddButton("30", [this](){ - SaveBrightness("3"); - }); - - AddButton("40", [this](){ - SaveBrightness("4"); - }); - - AddButton("50", [this](){ - SaveBrightness("5"); - }); - - AddButton("60", [this](){ - SaveBrightness("6"); - }); - - AddButton("70", [this](){ - SaveBrightness("7"); - }); - - AddButton("80", [this](){ - SaveBrightness("8"); - }); - - AddButton("90", [this](){ - SaveBrightness("9"); - }); - - AddButton("100", [this](){ - SaveBrightness("10"); - }); -#endif -} -#endif diff --git a/src/OV/Settings.hpp b/src/OV/Settings.hpp deleted file mode 100644 index 11bd8ee7ac4..00000000000 --- a/src/OV/Settings.hpp +++ /dev/null @@ -1,40 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -// Copyright The XCSoar Project - -#pragma once - -#define OV_SETTINGS 0 - -#if OV_SETTINGS - -#include "Widget/RowFormWidget.hpp" -#include "UIGlobals.hpp" -#include "ui/event/Queue.hpp" -#include "ui/display/Display.hpp" -#include "Look/DialogLook.hpp" - -// static DialogSettings dialog_settings; -// static UI::SingleWindow *global_main_window; -// static DialogLook *global_dialog_look; - -// const DialogSettings &UIGlobals::GetDialogSettings(); -// const DialogLook &UIGlobals::GetDialogLook(); -// UI::SingleWindow &UIGlobals::GetMainWindow(); - - - -class SystemMenuWidget final : public RowFormWidget { - UI::Display &display; - UI::EventQueue &event_queue; - -public: - SystemMenuWidget(UI::Display &_display, UI::EventQueue &_event_queue, - const DialogLook &look) noexcept - : RowFormWidget(look), display(_display), event_queue(_event_queue) {} - -private: - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept override; -}; - -#endif \ No newline at end of file diff --git a/src/OV/System.hpp b/src/OV/System.hpp deleted file mode 100644 index 92d9b0c1358..00000000000 --- a/src/OV/System.hpp +++ /dev/null @@ -1,129 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -// Copyright The XCSoar Project - -#pragma once - -#include "Dialogs/DialogSettings.hpp" -#include "Dialogs/Message.hpp" -#include "Dialogs/ProcessDialog.hpp" -#include "Dialogs/WidgetDialog.hpp" -#include "DisplayOrientation.hpp" -#include "FileMenuWidget.h" -#include "Hardware/DisplayDPI.hpp" -#include "Hardware/DisplayGlue.hpp" -#include "Hardware/RotateDisplay.hpp" -#include "Look/DialogLook.hpp" -#include "Profile/File.hpp" -#include "Profile/Map.hpp" -#include "Screen/Layout.hpp" -#include "UIGlobals.hpp" -#include "Widget/RowFormWidget.hpp" -#include "system/FileUtil.hpp" -#include "system/Process.hpp" -#include "ui/event/KeyCode.hpp" -#include "ui/event/Queue.hpp" -#include "ui/event/Timer.hpp" -#include "ui/window/Init.hpp" -#include "ui/window/SingleWindow.hpp" - -#include "Language/Language.hpp" - - -#include -#include - -class Path; - -enum class SSHStatus { - ENABLED, - DISABLED, - TEMPORARY, -}; - -enum Buttons { - LAUNCH_SHELL = 100, - START_UPGRADE = 111, -}; - -/** - * Load a system config file and put its variables into a map -*/ -void -LoadConfigFile(std::map> &map, Path path); -/** - * Save a map of config variables to a system config file -*/ -void -WriteConfigFile(std::map> &map, Path path); - -uint_least8_t -OpenvarioGetBrightness() noexcept; - -void -OpenvarioSetBrightness(uint_least8_t value) noexcept; - -DisplayOrientation -OpenvarioGetRotation(); - -void -OpenvarioSetRotation(DisplayOrientation orientation); - -SSHStatus -OpenvarioGetSSHStatus(); - -void -OpenvarioEnableSSH(bool temporary); - -void -OpenvarioDisableSSH(); - -void GetConfigInt(const std::string &keyvalue, unsigned &value, - const TCHAR *path); - -void ChangeConfigInt(const std::string &keyvalue, int value, - const TCHAR *path); - - -class SystemMenuWidget final - : public RowFormWidget -{ - UI::Display &display; - UI::EventQueue &event_queue; - - WndForm &dialog; - -public: - SystemMenuWidget(UI::Display &_display, UI::EventQueue &_event_queue, - WndForm &_dialog) noexcept - :RowFormWidget(_dialog.GetLook()), - display(_display), event_queue(_event_queue), - dialog(_dialog) {} - -private: - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, - const PixelRect &rc) noexcept override; -}; - - -class SystemSettingsWidget final - : public RowFormWidget -{ - UI::Display &display; - UI::EventQueue &event_queue; - - WndForm &dialog; - -public: - SystemSettingsWidget(UI::Display &_display, UI::EventQueue &_event_queue, - WndForm &_dialog) noexcept - :RowFormWidget(_dialog.GetLook()), - display(_display), event_queue(_event_queue), - dialog(_dialog) {} - -private: - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, - const PixelRect &rc) noexcept override; -}; - diff --git a/src/OV/FileMenuWidget.cpp b/src/OpenVario/FileMenuWidget.cpp similarity index 100% rename from src/OV/FileMenuWidget.cpp rename to src/OpenVario/FileMenuWidget.cpp diff --git a/src/OV/FileMenuWidget.h b/src/OpenVario/FileMenuWidget.h similarity index 100% rename from src/OV/FileMenuWidget.h rename to src/OpenVario/FileMenuWidget.h diff --git a/src/OV/OpenVarioMenu.cpp b/src/OpenVario/OpenVarioMenu.cpp similarity index 98% rename from src/OV/OpenVarioMenu.cpp rename to src/OpenVario/OpenVarioMenu.cpp index d9c8779ef24..e12b0dbfd0b 100644 --- a/src/OV/OpenVarioMenu.cpp +++ b/src/OpenVario/OpenVarioMenu.cpp @@ -27,8 +27,9 @@ #include "Hardware/DisplayDPI.hpp" #include "Hardware/RotateDisplay.hpp" -#include "OV/FileMenuWidget.h" -#include "OV/System.hpp" +#include "OpenVario/System/System.hpp" +#include "OpenVario/FileMenuWidget.h" +#include "OpenVario/System/SystemMenuWidget.hpp" #include #include diff --git a/src/OpenVario/System/System.cpp b/src/OpenVario/System/System.cpp new file mode 100644 index 00000000000..188ddf82c4f --- /dev/null +++ b/src/OpenVario/System/System.cpp @@ -0,0 +1,212 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project + +#if !defined(_WIN32) && 0 +# define DBUS_FUNCTIONS 1 +#endif + +#include "OpenVario/System/System.hpp" +#ifdef DBUS_FUNCTIONS +#include "lib/dbus/Connection.hxx" +#include "lib/dbus/ScopeMatch.hxx" +#include "lib/dbus/Systemd.hxx" +#endif + +#include "system/Process.hpp" +#include "system/FileUtil.hpp" +#include "system/Path.hpp" +#include "io/KeyValueFileReader.hpp" +#include "io/FileOutputStream.hxx" +#include "io/BufferedOutputStream.hxx" +#include "io/FileLineReader.hpp" +#include "Dialogs/Error.hpp" +#include "Hardware/RotateDisplay.hpp" + +#include "Profile/File.hpp" +#include "Profile/Map.hpp" + +#include "OpenVario/System/System.hpp" + +#ifndef _WIN32 +#include +#include +#endif +#include + +#include +#include + + +#ifndef __MSVC__ +#include +#include +#endif +#include + +#include + +//---------------------------------------------------------- +void +LoadConfigFile(std::map> &map, Path path) +{ + FileLineReaderA reader(path); + KeyValueFileReader kvreader(reader); + KeyValuePair pair; + while (kvreader.Read(pair)) + map.emplace(pair.key, pair.value); +} + +//---------------------------------------------------------- +void +WriteConfigFile(std::map> &map, Path path) +{ + FileOutputStream file(path); + BufferedOutputStream buffered(file); + + for (const auto &i : map) + buffered.Fmt("{}={}\n", i.first, i.second); + + buffered.Flush(); + file.Commit(); +} + +//---------------------------------------------------------- +void +GetConfigInt(const std::string &keyvalue, unsigned &value, + const TCHAR* path) +{ + const Path ConfigPath(path); + + ProfileMap configuration; + Profile::LoadFile(configuration, ConfigPath); + configuration.Get(keyvalue.c_str(), value); +} + +void ChangeConfigInt(const std::string &keyvalue, int value, + const TCHAR *path) { + const Path ConfigPath(path); + + ProfileMap configuration; + + try { + Profile::LoadFile(configuration, ConfigPath); + } catch (std::exception &e) { + Profile::SaveFile(configuration, ConfigPath); + } + configuration.Set(keyvalue.c_str(), value); + Profile::SaveFile(configuration, ConfigPath); +} + + +//---------------------------------------------------------- +uint_least8_t +OpenvarioGetBrightness() noexcept +{ + char line[4]; + int result = 10; + + if (File::ReadString(Path(_T("/sys/class/backlight/lcd/brightness")), line, sizeof(line))) { + result = atoi(line); + } + + return result; +} + +void +OpenvarioSetBrightness(uint_least8_t value) noexcept +{ + if (value < 1) { value = 1; } + if (value > 10) { value = 10; } + + File::WriteExisting(Path(_T("/sys/class/backlight/lcd/brightness")), fmt::format_int{value}.c_str()); +} + +DisplayOrientation +OpenvarioGetRotation() +{ + std::map> map; + LoadConfigFile(map, Path(_T("/boot/config.uEnv"))); + + uint_least8_t result; + result = map.contains("rotation") ? std::stoi(map.find("rotation")->second) : 0; + + switch (result) { + case 0: return DisplayOrientation::LANDSCAPE; + case 1: return DisplayOrientation::REVERSE_PORTRAIT; + case 2: return DisplayOrientation::REVERSE_LANDSCAPE; + case 3: return DisplayOrientation::PORTRAIT; + default: return DisplayOrientation::DEFAULT; + } +} + +void +OpenvarioSetRotation(DisplayOrientation orientation) +{ + std::map> map; + + Display::Rotate(orientation); + + int rotation = 0; + switch (orientation) { + case DisplayOrientation::DEFAULT: + case DisplayOrientation::LANDSCAPE: + break; + case DisplayOrientation::REVERSE_PORTRAIT: + rotation = 1; + break; + case DisplayOrientation::REVERSE_LANDSCAPE: + rotation = 2; + break; + case DisplayOrientation::PORTRAIT: + rotation = 3; + break; + }; + + File::WriteExisting(Path(_T("/sys/class/graphics/fbcon/rotate")), fmt::format_int{rotation}.c_str()); + + LoadConfigFile(map, Path(_T("/boot/config.uEnv"))); + map.insert_or_assign("rotation", fmt::format_int{rotation}.c_str()); + WriteConfigFile(map, Path(_T("/boot/config.uEnv"))); +} + +#ifdef DBUS_FUNCTIONS +SSHStatus +OpenvarioGetSSHStatus() +{ + auto connection = ODBus::Connection::GetSystem(); + + if (Systemd::IsUnitEnabled(connection, "dropbear.socket")) { + return SSHStatus::ENABLED; + } else if (Systemd::IsUnitActive(connection, "dropbear.socket")) { + return SSHStatus::TEMPORARY; + } else { + return SSHStatus::DISABLED; + } +} + +void +OpenvarioEnableSSH(bool temporary) +{ + auto connection = ODBus::Connection::GetSystem(); + const ODBus::ScopeMatch job_removed_match{connection, Systemd::job_removed_match}; + + if (temporary) + Systemd::DisableUnitFile(connection, "dropbear.socket"); + else + Systemd::EnableUnitFile(connection, "dropbear.socket"); + + Systemd::StartUnit(connection, "dropbear.socket"); +} + +void +OpenvarioDisableSSH() +{ + auto connection = ODBus::Connection::GetSystem(); + const ODBus::ScopeMatch job_removed_match{connection, Systemd::job_removed_match}; + + Systemd::DisableUnitFile(connection, "dropbear.socket"); + Systemd::StopUnit(connection, "dropbear.socket"); +} +#endif // _WIN32 +//---------------------------------------------------------- + diff --git a/src/OpenVario/System/System.hpp b/src/OpenVario/System/System.hpp new file mode 100644 index 00000000000..29c581e0797 --- /dev/null +++ b/src/OpenVario/System/System.hpp @@ -0,0 +1,67 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project + +#pragma once + +#include "DisplayOrientation.hpp" +#include "Language/Language.hpp" + +#include + +#include +#include + + +class Path; + +enum class SSHStatus { + ENABLED, + DISABLED, + TEMPORARY, +}; + +enum Buttons { + LAUNCH_SHELL = 100, + START_UPGRADE = 111, +}; + +/** + * Load a system config file and put its variables into a map +*/ +void +LoadConfigFile(std::map> &map, Path path); +/** + * Save a map of config variables to a system config file +*/ +void +WriteConfigFile(std::map> &map, Path path); + +uint_least8_t +OpenvarioGetBrightness() noexcept; + +void +OpenvarioSetBrightness(uint_least8_t value) noexcept; + +DisplayOrientation +OpenvarioGetRotation(); + +void +OpenvarioSetRotation(DisplayOrientation orientation); + +SSHStatus +OpenvarioGetSSHStatus(); + +void +OpenvarioEnableSSH(bool temporary); + +void +OpenvarioDisableSSH(); + +void +GetConfigInt(const std::string &keyvalue, unsigned &value, + const TCHAR *path); + +void +ChangeConfigInt(const std::string &keyvalue, int value, + const TCHAR *path); + diff --git a/src/OpenVario/System/SystemMenuWidget.cpp b/src/OpenVario/System/SystemMenuWidget.cpp new file mode 100644 index 00000000000..03e187e9092 --- /dev/null +++ b/src/OpenVario/System/SystemMenuWidget.cpp @@ -0,0 +1,158 @@ + +#include "Dialogs/DialogSettings.hpp" +#include "Dialogs/Message.hpp" +#include "Dialogs/ProcessDialog.hpp" +#include "Dialogs/WidgetDialog.hpp" +#include "DisplayOrientation.hpp" +#include "Hardware/DisplayDPI.hpp" +#include "Hardware/DisplayGlue.hpp" +#include "Hardware/RotateDisplay.hpp" +#include "Look/DialogLook.hpp" +#include "Profile/File.hpp" +#include "Profile/Map.hpp" +#include "Screen/Layout.hpp" +#include "UIGlobals.hpp" +// #include "Widget/RowFormWidget.hpp" +#include "system/FileUtil.hpp" +#include "system/Process.hpp" +#include "ui/event/KeyCode.hpp" +// #include "ui/event/Queue.hpp" +#include "ui/event/Timer.hpp" +#include "ui/window/Init.hpp" +// #include "ui/window/SingleWindow.hpp" +#include "util/ScopeExit.hxx" + +#include "OpenVario/FileMenuWidget.h" +#include "OpenVario/System/System.hpp" +#include "OpenVario/System/SystemSettingsWidget.hpp" +#include "OpenVario/System/SystemMenuWidget.hpp" + +#include +#include + +// void +// SystemMenuWidget::CalibrateSensors() noexcept +static void +CalibrateSensors() noexcept +{ + /* make sure sensord is stopped while calibrating sensors */ + static constexpr const char *start_sensord[] = {"/bin/systemctl", "start", + "sensord.service", nullptr}; + static constexpr const char *stop_sensord[] = {"/bin/systemctl", "stop", + "sensord.service", nullptr}; + + RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), + _T("Calibrate Sensors"), stop_sensord, [](int status) { + return status == EXIT_SUCCESS ? mrOK : 0; + }); + + AtScopeExit() { + RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), + _T("Calibrate Sensors"), start_sensord, [](int status) { + return status == EXIT_SUCCESS ? mrOK : 0; + }); + }; + + /* calibrate the sensors */ + static constexpr const char *calibrate_sensors[] = {"/opt/bin/sensorcal", + "-c", nullptr}; + + static constexpr int STATUS_BOARD_NOT_INITIALISED = 2; + static constexpr int RESULT_BOARD_NOT_INITIALISED = 100; + int result = RunProcessDialog( + UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), + _T("Calibrate Sensors"), calibrate_sensors, [](int status) { + return status == STATUS_BOARD_NOT_INITIALISED + ? RESULT_BOARD_NOT_INITIALISED + : 0; + }); + if (result != RESULT_BOARD_NOT_INITIALISED) + return; + + /* initialise the sensors? */ + if (ShowMessageBox(_T("Sensorboard is virgin. Do you want to initialise it?"), + _T("Calibrate Sensors"), MB_YESNO) != IDYES) + return; + + static constexpr const char *init_sensors[] = {"/opt/bin/sensorcal", "-i", + nullptr}; + + result = + RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), + _T("Calibrate Sensors"), init_sensors, [](int status) { + return status == EXIT_SUCCESS ? mrOK : 0; + }); + if (result != mrOK) + return; + + /* calibrate again */ + RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), + _T("Calibrate Sensors"), calibrate_sensors, [](int status) { + return status == STATUS_BOARD_NOT_INITIALISED + ? RESULT_BOARD_NOT_INITIALISED + : 0; + }); +} + +//----------------------------------------------------------------------------- +void +SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, + [[maybe_unused]] const PixelRect &rc) noexcept +{ + AddButton(_("Upgrade Firmware"), [this]() { + // dialog.SetModalResult(START_UPGRADE); + exit(START_UPGRADE); + }); + + AddButton(_("WiFi Settings"), []() { + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "printf '\\nWiFi-Settings are not implemented, yet!! \\n\\nIf you are " + "interessted to help with this, write me an email: dirk@freevario.de'", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _T("WiFi Settings"), argv); + }); + + + AddButton(_("Update System"), [](){ + static constexpr const char *argv[] = { + "/usr/bin/update-system.sh", nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _T("Update System"), argv); + }); + + AddButton(_("Calibrate Sensors"), CalibrateSensors); + AddButton(_("Calibrate Touch"), [this](){ + const UI::ScopeDropMaster drop_master{display}; + const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; + Run("/usr/bin/ov-calibrate-ts.sh"); + }); + + AddButton(_("System Settings"), [this](){ + + TWidgetDialog + sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), + GetLook(), _T("OpenVario System Settings")); + sub_dialog.SetWidget(display, event_queue, sub_dialog); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); + }); + + AddButton(_("System Info"), [](){ + static constexpr const char *argv[] = { + "/usr/bin/system-info.sh", nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _T("System Info"), argv); + }); +} + diff --git a/src/OpenVario/System/SystemMenuWidget.hpp b/src/OpenVario/System/SystemMenuWidget.hpp new file mode 100644 index 00000000000..d86c733123e --- /dev/null +++ b/src/OpenVario/System/SystemMenuWidget.hpp @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project + +#pragma once + +#define OV_SETTINGS 0 + +#include "Widget/RowFormWidget.hpp" +#include "ui/event/Queue.hpp" +#include "ui/window/SingleWindow.hpp" + +class SystemMenuWidget final + : public RowFormWidget +{ + UI::Display &display; + UI::EventQueue &event_queue; + + WndForm &dialog; + +public: + SystemMenuWidget(UI::Display &_display, UI::EventQueue &_event_queue, + WndForm &_dialog) noexcept + :RowFormWidget(_dialog.GetLook()), + display(_display), event_queue(_event_queue), + dialog(_dialog) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, + const PixelRect &rc) noexcept override; + // void CalibrateSensors() noexcept; +}; diff --git a/src/OV/System.cpp b/src/OpenVario/System/SystemSettingsWidget.cpp similarity index 59% rename from src/OV/System.cpp rename to src/OpenVario/System/SystemSettingsWidget.cpp index 1f28b49d583..dfa123dc248 100644 --- a/src/OV/System.cpp +++ b/src/OpenVario/System/SystemSettingsWidget.cpp @@ -8,14 +8,11 @@ # include "lib/dbus/Systemd.hxx" #endif -// #include "../test/src/Fonts.hpp" -/* #include "Dialogs/DialogSettings.hpp" #include "Dialogs/Message.hpp" #include "Dialogs/ProcessDialog.hpp" #include "Dialogs/WidgetDialog.hpp" #include "DisplayOrientation.hpp" -#include "FileMenuWidget.h" #include "Hardware/DisplayDPI.hpp" #include "Hardware/DisplayGlue.hpp" #include "Hardware/RotateDisplay.hpp" @@ -24,46 +21,26 @@ #include "Profile/Map.hpp" #include "Screen/Layout.hpp" #include "UIGlobals.hpp" -#include "Widget/RowFormWidget.hpp" +// #include "Widget/RowFormWidget.hpp" #include "system/FileUtil.hpp" #include "system/Process.hpp" #include "ui/event/KeyCode.hpp" -#include "ui/event/Queue.hpp" +// #include "ui/event/Queue.hpp" #include "ui/event/Timer.hpp" #include "ui/window/Init.hpp" -#include "ui/window/SingleWindow.hpp" -*/ -#include "util/ScopeExit.hxx" +// #include "ui/window/SingleWindow.hpp" + +#include "Language/Language.hpp" -// #include "system/FileUtil.hpp" -// #include "system/Path.hpp" #include "io/KeyValueFileReader.hpp" #include "io/FileOutputStream.hxx" #include "io/BufferedOutputStream.hxx" #include "io/FileLineReader.hpp" -// #include "Dialogs/Error.hpp" -// #include "DisplayOrientation.hpp" -// #include "Hardware/RotateDisplay.hpp" -// -// #include "Dialogs/DialogSettings.hpp" -// #include "Dialogs/Message.hpp" -// #include "Dialogs/WidgetDialog.hpp" -// #include "Dialogs/ProcessDialog.hpp" -// #include "Widget/RowFormWidget.hpp" -// #include "UIGlobals.hpp" -// #include "Look/DialogLook.hpp" -// #include "Screen/Layout.hpp" -// -// #include "ui/event/KeyCode.hpp" -// #include "ui/event/Queue.hpp" -// #include "ui/event/Timer.hpp" -// #include "ui/window/Init.hpp" -// #include "ui/window/SingleWindow.hpp" -// #include "Language/Language.hpp" -// #include "system/Process.hpp" -// #include "util/ScopeExit.hxx" -#include "OV/System.hpp" +#include "OpenVario/FileMenuWidget.h" +#include "OpenVario/System/System.hpp" +#include "OpenVario/System/SystemSettingsWidget.hpp" +#include "OpenVario/System/SystemMenuWidget.hpp" #ifndef _WIN32 #include @@ -72,286 +49,7 @@ #include #include - -void -LoadConfigFile(std::map> &map, Path path) -{ - FileLineReaderA reader(path); - KeyValueFileReader kvreader(reader); - KeyValuePair pair; - while (kvreader.Read(pair)) - map.emplace(pair.key, pair.value); -} - -void -WriteConfigFile(std::map> &map, Path path) -{ - FileOutputStream file(path); - BufferedOutputStream buffered(file); - - for (const auto &i : map) - buffered.Fmt("{}={}\n", i.first, i.second); - - buffered.Flush(); - file.Commit(); -} - -uint_least8_t -OpenvarioGetBrightness() noexcept -{ - char line[4]; - int result = 10; - - if (File::ReadString(Path(_T("/sys/class/backlight/lcd/brightness")), line, sizeof(line))) { - result = atoi(line); - } - - return result; -} - -void -OpenvarioSetBrightness(uint_least8_t value) noexcept -{ - if (value < 1) { value = 1; } - if (value > 10) { value = 10; } - - File::WriteExisting(Path(_T("/sys/class/backlight/lcd/brightness")), fmt::format_int{value}.c_str()); -} - -DisplayOrientation -OpenvarioGetRotation() -{ - std::map> map; - LoadConfigFile(map, Path(_T("/boot/config.uEnv"))); - - uint_least8_t result; - result = map.contains("rotation") ? std::stoi(map.find("rotation")->second) : 0; - - switch (result) { - case 0: return DisplayOrientation::LANDSCAPE; - case 1: return DisplayOrientation::REVERSE_PORTRAIT; - case 2: return DisplayOrientation::REVERSE_LANDSCAPE; - case 3: return DisplayOrientation::PORTRAIT; - default: return DisplayOrientation::DEFAULT; - } -} - -void -OpenvarioSetRotation(DisplayOrientation orientation) -{ - std::map> map; - - Display::Rotate(orientation); - - int rotation = 0; - switch (orientation) { - case DisplayOrientation::DEFAULT: - case DisplayOrientation::LANDSCAPE: - break; - case DisplayOrientation::REVERSE_PORTRAIT: - rotation = 1; - break; - case DisplayOrientation::REVERSE_LANDSCAPE: - rotation = 2; - break; - case DisplayOrientation::PORTRAIT: - rotation = 3; - break; - }; - - File::WriteExisting(Path(_T("/sys/class/graphics/fbcon/rotate")), fmt::format_int{rotation}.c_str()); - - LoadConfigFile(map, Path(_T("/boot/config.uEnv"))); - map.insert_or_assign("rotation", fmt::format_int{rotation}.c_str()); - WriteConfigFile(map, Path(_T("/boot/config.uEnv"))); -} - -// #ifndef _WIN32 -#if 0 -SSHStatus -OpenvarioGetSSHStatus() -{ - auto connection = ODBus::Connection::GetSystem(); - - if (Systemd::IsUnitEnabled(connection, "dropbear.socket")) { - return SSHStatus::ENABLED; - } else if (Systemd::IsUnitActive(connection, "dropbear.socket")) { - return SSHStatus::TEMPORARY; - } else { - return SSHStatus::DISABLED; - } -} - -void -OpenvarioEnableSSH(bool temporary) -{ - auto connection = ODBus::Connection::GetSystem(); - const ODBus::ScopeMatch job_removed_match{connection, Systemd::job_removed_match}; - - if (temporary) - Systemd::DisableUnitFile(connection, "dropbear.socket"); - else - Systemd::EnableUnitFile(connection, "dropbear.socket"); - - Systemd::StartUnit(connection, "dropbear.socket"); -} - -void -OpenvarioDisableSSH() -{ - auto connection = ODBus::Connection::GetSystem(); - const ODBus::ScopeMatch job_removed_match{connection, Systemd::job_removed_match}; - - Systemd::DisableUnitFile(connection, "dropbear.socket"); - Systemd::StopUnit(connection, "dropbear.socket"); -} -#endif // _WIN32 - - -void GetConfigInt(const std::string &keyvalue, unsigned &value, - const TCHAR* path) { - const Path ConfigPath(path); - - ProfileMap configuration; - Profile::LoadFile(configuration, ConfigPath); - configuration.Get(keyvalue.c_str(), value); -} - -void ChangeConfigInt(const std::string &keyvalue, int value, - const TCHAR *path) { - const Path ConfigPath(path); - - ProfileMap configuration; - - try { - Profile::LoadFile(configuration, ConfigPath); - } catch (std::exception &e) { - Profile::SaveFile(configuration, ConfigPath); - } - configuration.Set(keyvalue.c_str(), value); - Profile::SaveFile(configuration, ConfigPath); -} - - -static void CalibrateSensors() noexcept { - /* make sure sensord is stopped while calibrating sensors */ - static constexpr const char *start_sensord[] = {"/bin/systemctl", "start", - "sensord.service", nullptr}; - static constexpr const char *stop_sensord[] = {"/bin/systemctl", "stop", - "sensord.service", nullptr}; - - RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T("Calibrate Sensors"), stop_sensord, [](int status) { - return status == EXIT_SUCCESS ? mrOK : 0; - }); - - AtScopeExit() { - RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T("Calibrate Sensors"), start_sensord, [](int status) { - return status == EXIT_SUCCESS ? mrOK : 0; - }); - }; - - /* calibrate the sensors */ - static constexpr const char *calibrate_sensors[] = {"/opt/bin/sensorcal", - "-c", nullptr}; - - static constexpr int STATUS_BOARD_NOT_INITIALISED = 2; - static constexpr int RESULT_BOARD_NOT_INITIALISED = 100; - int result = RunProcessDialog( - UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T("Calibrate Sensors"), calibrate_sensors, [](int status) { - return status == STATUS_BOARD_NOT_INITIALISED - ? RESULT_BOARD_NOT_INITIALISED - : 0; - }); - if (result != RESULT_BOARD_NOT_INITIALISED) - return; - - /* initialise the sensors? */ - if (ShowMessageBox(_T("Sensorboard is virgin. Do you want to initialise it?"), - _T("Calibrate Sensors"), MB_YESNO) != IDYES) - return; - - static constexpr const char *init_sensors[] = {"/opt/bin/sensorcal", "-i", - nullptr}; - - result = - RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T("Calibrate Sensors"), init_sensors, [](int status) { - return status == EXIT_SUCCESS ? mrOK : 0; - }); - if (result != mrOK) - return; - - /* calibrate again */ - RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T("Calibrate Sensors"), calibrate_sensors, [](int status) { - return status == STATUS_BOARD_NOT_INITIALISED - ? RESULT_BOARD_NOT_INITIALISED - : 0; - }); -} - -void -SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, - [[maybe_unused]] const PixelRect &rc) noexcept -{ - AddButton(_("WiFi Settings"), [](){ - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "printf '\nWiFi-Settings are not implemented, yet!! \n\nIf you are interessted to help with this, write me an email: dirk@freevario.de'", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("WiFi Settings"), argv); - }); - - - AddButton(_("Upgrade Firmware"), [this](){ - // dialog.SetModalResult(START_UPGRADE); - exit(START_UPGRADE); - }); - - AddButton(_("Update System"), [](){ - static constexpr const char *argv[] = { - "/usr/bin/update-system.sh", nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("Update System"), argv); - }); - - AddButton(_("Calibrate Sensors"), CalibrateSensors); - AddButton(_("Calibrate Touch"), [this](){ - const UI::ScopeDropMaster drop_master{display}; - const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; - Run("/usr/bin/ov-calibrate-ts.sh"); - }); - - AddButton(_("System Settings"), [this](){ - - TWidgetDialog - sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), _T("OpenVario System Settings")); - sub_dialog.SetWidget(display, event_queue, sub_dialog); - sub_dialog.AddButton(_("Close"), mrOK); - return sub_dialog.ShowModal(); - }); - - AddButton(_("System Info"), [](){ - static constexpr const char *argv[] = { - "/usr/bin/system-info.sh", nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("System Info"), argv); - }); -} +#include //---------------------------------------------------------- //---------------------------------------------------------- diff --git a/src/OpenVario/System/SystemSettingsWidget.hpp b/src/OpenVario/System/SystemSettingsWidget.hpp new file mode 100644 index 00000000000..f89f0507cbc --- /dev/null +++ b/src/OpenVario/System/SystemSettingsWidget.hpp @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project + +#pragma once + +#include "Widget/RowFormWidget.hpp" +#include "ui/event/Queue.hpp" +#include "ui/window/SingleWindow.hpp" + +class SystemSettingsWidget final + : public RowFormWidget +{ + UI::Display &display; + UI::EventQueue &event_queue; + + WndForm &dialog; + +public: + SystemSettingsWidget(UI::Display &_display, UI::EventQueue &_event_queue, + WndForm &_dialog) noexcept + :RowFormWidget(_dialog.GetLook()), + display(_display), event_queue(_event_queue), + dialog(_dialog) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, + const PixelRect &rc) noexcept override; +}; + From 0ab9bb9676a8d3a4925289d43f2c5cc8b9607e0d Mon Sep 17 00:00:00 2001 From: August2111 Date: Sat, 6 Jan 2024 11:22:04 +0100 Subject: [PATCH 074/403] [CMake] - OpenVarioMenu - start reorganize --- CMakeLists.txt | 2 +- src/OV/CMakeSource.cmake | 11 ----------- src/{OV => OpenVario}/CMakeLists.txt | 2 +- src/OpenVario/CMakeSource.cmake | 12 ++++++++++++ 4 files changed, 14 insertions(+), 13 deletions(-) delete mode 100644 src/OV/CMakeSource.cmake rename src/{OV => OpenVario}/CMakeLists.txt (95%) create mode 100644 src/OpenVario/CMakeSource.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 985b7dfa9d6..c19b326d2dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -358,7 +358,7 @@ endif() add_subdirectory(src/lib) add_subdirectory(src) # libOpenSoar! -add_subdirectory(src/OV) # libOpenSoar! +add_subdirectory(src/OpenVario) # libOpenSoar! list(APPEND SOURCE_FILES "src/OpenSoar.cpp") # list(APPEND SOURCE_FILES "src/Version.cpp") diff --git a/src/OV/CMakeSource.cmake b/src/OV/CMakeSource.cmake deleted file mode 100644 index 5c7ac403679..00000000000 --- a/src/OV/CMakeSource.cmake +++ /dev/null @@ -1,11 +0,0 @@ -set(_SOURCES - OV/OpenVarioMenu.cpp - OV/System.cpp - OV/Settings.cpp - OV/FileMenuWidget.cpp -) - -set(SCRIPT_FILES - CMakeSource.cmake - ../../build/ov.mk -) diff --git a/src/OV/CMakeLists.txt b/src/OpenVario/CMakeLists.txt similarity index 95% rename from src/OV/CMakeLists.txt rename to src/OpenVario/CMakeLists.txt index ea6f2d5a7ea..54e17353144 100644 --- a/src/OV/CMakeLists.txt +++ b/src/OpenVario/CMakeLists.txt @@ -49,5 +49,5 @@ target_link_libraries(${TARGET_NAME} PUBLIC Logger) # message(FATAL_ERROR "Stop!") set_target_properties(${TARGET_NAME} PROPERTIES FOLDER OpenVario) -target_link_libraries(${TARGET_NAME} PUBLIC Dialogs Math ${XCSOAR_LINK_LIBRARIES}) +target_link_libraries(${TARGET_NAME} PUBLIC Dialogs Math Language ${XCSOAR_LINK_LIBRARIES}) add_dependencies(${TARGET_NAME} util Data) diff --git a/src/OpenVario/CMakeSource.cmake b/src/OpenVario/CMakeSource.cmake new file mode 100644 index 00000000000..80e119ab483 --- /dev/null +++ b/src/OpenVario/CMakeSource.cmake @@ -0,0 +1,12 @@ +set(_SOURCES + OpenVario/OpenVarioMenu.cpp + OpenVario/System/System.cpp + OpenVario/System/SystemMenuWidget.cpp + OpenVario/System/SystemSettingsWidget.cpp + OpenVario/FileMenuWidget.cpp +) + +set(SCRIPT_FILES + CMakeSource.cmake + ../../build/ov.mk +) From de85b316652d680f9b06d51ac649f2fd1dddcab2 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sat, 6 Jan 2024 11:22:30 +0100 Subject: [PATCH 075/403] [build] ov.mk - OpenVarioMenu - start reorganize --- build/ov.mk | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/build/ov.mk b/build/ov.mk index 877ff97b407..eb0bbd5023d 100644 --- a/build/ov.mk +++ b/build/ov.mk @@ -31,10 +31,11 @@ OV_MENU_SOURCES = \ $(TEST_SRC_DIR)/FakeLanguage.cpp \ $(TEST_SRC_DIR)/FakeLogFile.cpp \ $(SRC)/Kobo/FakeSymbols.cpp \ - $(SRC)/OV/FileMenuWidget.cpp\ - $(SRC)/OV/Settings.cpp\ - $(SRC)/OV/System.cpp\ - $(SRC)/OV/OpenVarioMenu.cpp + $(SRC)/OpenVario/FileMenuWidget.cpp\ + $(SRC)/OpenVario/System/System.cpp\ + $(SRC)/OpenVario/System/SystemMenuWidget.cpp\ + $(SRC)/OpenVario/System/SystemSettingsWidget.cpp\ + $(SRC)/OpenVario/OpenVarioMenu.cpp OV_MENU_DEPENDS = WIDGET FORM DATA_FIELD SCREEN EVENT RESOURCE ASYNC LIBNET OS IO THREAD TIME MATH UTIL OV_MENU_STRIP = y From cc02a400253c0c6538799e97ffa6e0784bae6a48 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 4 Jan 2024 22:52:11 +0100 Subject: [PATCH 076/403] OpenVario/System/System - move DBUS_FUNCTIONS to System.hpp and use it ... w/0 WIN32 --- src/OpenVario/System/System.cpp | 4 ---- src/OpenVario/System/System.hpp | 6 ++++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/OpenVario/System/System.cpp b/src/OpenVario/System/System.cpp index 188ddf82c4f..a3baecf8c7a 100644 --- a/src/OpenVario/System/System.cpp +++ b/src/OpenVario/System/System.cpp @@ -1,10 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright The XCSoar Project -#if !defined(_WIN32) && 0 -# define DBUS_FUNCTIONS 1 -#endif - #include "OpenVario/System/System.hpp" #ifdef DBUS_FUNCTIONS #include "lib/dbus/Connection.hxx" diff --git a/src/OpenVario/System/System.hpp b/src/OpenVario/System/System.hpp index 29c581e0797..85126a5bf79 100644 --- a/src/OpenVario/System/System.hpp +++ b/src/OpenVario/System/System.hpp @@ -12,6 +12,10 @@ #include +#if !defined(_WIN32) && 1 +# define DBUS_FUNCTIONS 1 +#endif + class Path; enum class SSHStatus { @@ -48,6 +52,7 @@ OpenvarioGetRotation(); void OpenvarioSetRotation(DisplayOrientation orientation); +#ifdef DBUS_FUNCTIONS SSHStatus OpenvarioGetSSHStatus(); @@ -56,6 +61,7 @@ OpenvarioEnableSSH(bool temporary); void OpenvarioDisableSSH(); +#endif void GetConfigInt(const std::string &keyvalue, unsigned &value, From 231b653765670c0519bd58c2c354cddd50a6930a Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 5 Jan 2024 08:12:25 +0100 Subject: [PATCH 077/403] [build] targets.mk - try to add dbus include --- build/targets.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/build/targets.mk b/build/targets.mk index c8f671b19b8..18514f86664 100644 --- a/build/targets.mk +++ b/build/targets.mk @@ -434,6 +434,7 @@ endif ifeq ($(TARGET_IS_OPENVARIO),y) TARGET_CPPFLAGS += -DIS_OPENVARIO + TARGET_CPPFLAGS += -isystem /usr/include/dbus-1.0 -isystem /usr/lib/x86_64-linux-gnu/dbus-1.0/include endif ifeq ($(HAVE_MSVCRT),y) From 1d59571a0edacf94aa0032b5f6e281090420a0a0 Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 5 Jan 2024 09:35:14 +0100 Subject: [PATCH 078/403] OpenVario - use Path instead of TCHAR* --- src/OpenVario/OpenVarioMenu.cpp | 2 +- src/OpenVario/System/System.cpp | 41 +++++++++++-------- src/OpenVario/System/System.hpp | 9 +++- src/OpenVario/System/SystemSettingsWidget.cpp | 4 +- 4 files changed, 33 insertions(+), 23 deletions(-) diff --git a/src/OpenVario/OpenVarioMenu.cpp b/src/OpenVario/OpenVarioMenu.cpp index e12b0dbfd0b..2d2b7e497f3 100644 --- a/src/OpenVario/OpenVarioMenu.cpp +++ b/src/OpenVario/OpenVarioMenu.cpp @@ -124,7 +124,7 @@ class MainMenuWidget final :RowFormWidget(_dialog.GetLook()), display(_display), event_queue(_event_queue), dialog(_dialog) { - GetConfigInt("timeout", remaining_seconds, _T("/boot/config.uEnv")); + GetConfigInt("timeout", remaining_seconds, ConfigFile); } private: diff --git a/src/OpenVario/System/System.cpp b/src/OpenVario/System/System.cpp index a3baecf8c7a..661723e865f 100644 --- a/src/OpenVario/System/System.cpp +++ b/src/OpenVario/System/System.cpp @@ -10,7 +10,6 @@ #include "system/Process.hpp" #include "system/FileUtil.hpp" -#include "system/Path.hpp" #include "io/KeyValueFileReader.hpp" #include "io/FileOutputStream.hxx" #include "io/BufferedOutputStream.hxx" @@ -41,6 +40,7 @@ #include +// constexpr const Path ConfigFile(_T("/boot/config.uEnv")); //---------------------------------------------------------- void LoadConfigFile(std::map> &map, Path path) @@ -69,28 +69,33 @@ WriteConfigFile(std::map> &map, Path path) //---------------------------------------------------------- void GetConfigInt(const std::string &keyvalue, unsigned &value, - const TCHAR* path) + const Path &ConfigPath) { - const Path ConfigPath(path); - - ProfileMap configuration; - Profile::LoadFile(configuration, ConfigPath); - configuration.Get(keyvalue.c_str(), value); + if (File::Exists(ConfigFile)) { + ProfileMap configuration; + Profile::LoadFile(configuration, ConfigPath); + configuration.Get(keyvalue.c_str(), value); + } else { + printf("ConfigFile '%s' does not exist!", "/boot/config.uEnv"); + } } -void ChangeConfigInt(const std::string &keyvalue, int value, - const TCHAR *path) { - const Path ConfigPath(path); - - ProfileMap configuration; - - try { - Profile::LoadFile(configuration, ConfigPath); - } catch (std::exception &e) { +void +ChangeConfigInt(const std::string &keyvalue, int value, + const Path &ConfigPath) +{ + if (File::Exists(ConfigFile)) { + ProfileMap configuration; + try { + Profile::LoadFile(configuration, ConfigPath); + } catch (std::exception &e) { + Profile::SaveFile(configuration, ConfigPath); + } + configuration.Set(keyvalue.c_str(), value); Profile::SaveFile(configuration, ConfigPath); + } else { + printf("ConfigFile '%s' does not exist!", "/boot/config.uEnv"); } - configuration.Set(keyvalue.c_str(), value); - Profile::SaveFile(configuration, ConfigPath); } diff --git a/src/OpenVario/System/System.hpp b/src/OpenVario/System/System.hpp index 85126a5bf79..c1e639de25e 100644 --- a/src/OpenVario/System/System.hpp +++ b/src/OpenVario/System/System.hpp @@ -5,6 +5,7 @@ #include "DisplayOrientation.hpp" #include "Language/Language.hpp" +#include "system/Path.hpp" #include @@ -12,6 +13,10 @@ #include +// extern constexpr const Path ConfigFile; +constexpr const Path ConfigFile(_T("/boot/config.uEnv")); + + #if !defined(_WIN32) && 1 # define DBUS_FUNCTIONS 1 #endif @@ -65,9 +70,9 @@ OpenvarioDisableSSH(); void GetConfigInt(const std::string &keyvalue, unsigned &value, - const TCHAR *path); + const Path &ConfigPath); void ChangeConfigInt(const std::string &keyvalue, int value, - const TCHAR *path); + const Path &ConfigPath); diff --git a/src/OpenVario/System/SystemSettingsWidget.cpp b/src/OpenVario/System/SystemSettingsWidget.cpp index dfa123dc248..e6d27e41cbe 100644 --- a/src/OpenVario/System/SystemSettingsWidget.cpp +++ b/src/OpenVario/System/SystemSettingsWidget.cpp @@ -81,7 +81,7 @@ ScreenRotationWidget::SaveRotation(const std::string &rotationString) { File::WriteExisting(Path(_T("/sys/class/graphics/fbcon/rotate")), (rotationString).c_str()); int rotationInt = stoi(rotationString); - ChangeConfigInt("rotation", rotationInt, _T("/boot/config.uEnv")); + ChangeConfigInt("rotation", rotationInt, ConfigFile); } void @@ -200,7 +200,7 @@ class ScreenTimeoutWidget final void ScreenTimeoutWidget::SaveTimeout(int timeoutInt) { - ChangeConfigInt("timeout", timeoutInt, _T("/boot/config.uEnv")); + ChangeConfigInt("timeout", timeoutInt, ConfigFile); } void From 56e09793266699239b770df1f05f3e764e1fa0b1 Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 5 Jan 2024 12:02:46 +0100 Subject: [PATCH 079/403] OpenVarioMenu - change config path if it cannot accessed --- src/OpenVario/OpenVarioMenu.cpp | 105 +++++++++++++++++++++++--------- src/OpenVario/System/System.cpp | 2 +- src/OpenVario/System/System.hpp | 3 +- 3 files changed, 80 insertions(+), 30 deletions(-) diff --git a/src/OpenVario/OpenVarioMenu.cpp b/src/OpenVario/OpenVarioMenu.cpp index 2d2b7e497f3..9229f5bb10c 100644 --- a/src/OpenVario/OpenVarioMenu.cpp +++ b/src/OpenVario/OpenVarioMenu.cpp @@ -36,6 +36,10 @@ #include #include +#include "util/StaticString.hxx" + +bool IsOpenVarioDevice = true; + template static void ChangeConfigString(const std::string &keyvalue, T value, const std::string &path) { @@ -131,7 +135,10 @@ class MainMenuWidget final void StartOpenSoar() noexcept { const UI::ScopeDropMaster drop_master{display}; const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; - Run("/usr/bin/OpenSoar", "-fly", "-datapath=/home/root/data/OpenSoarData"); + if (File::Exists(Path(_T("/usr/bin/OpenSoar")))) + Run("/usr/bin/OpenSoar", "-fly", "-datapath=/home/root/data/OpenSoarData"); + else + Run("./output/UNIX/bin/OpenSoar", "-fly"); } void StartXCSoar() noexcept { @@ -192,10 +199,8 @@ class MainMenuWidget final } }; -void -MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, - [[maybe_unused]] const PixelRect &rc) noexcept -{ +void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, + [[maybe_unused]] const PixelRect &rc) noexcept { AddButton(_("Start OpenSoar (Club)"), [this]() { CancelTimer(); StartOpenSoar(); @@ -206,49 +211,49 @@ MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, StartOpenSoar(); }); - AddButton(_("Start XCSoar"), [this]() { + auto Btn_XCSoar = AddButton(_("Start XCSoar"), [this]() { CancelTimer(); StartXCSoar(); }); - AddButton(_("Files"), [this](){ + AddButton(_("Files"), [this]() { CancelTimer(); - TWidgetDialog - sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), _T("OpenVario Files")); + TWidgetDialog sub_dialog(WidgetDialog::Full{}, + dialog.GetMainWindow(), GetLook(), + _T("OpenVario Files")); sub_dialog.SetWidget(display, event_queue, GetLook()); sub_dialog.AddButton(_("Close"), mrOK); return sub_dialog.ShowModal(); }); - AddButton(_("System"), [this](){ + AddButton(_("System"), [this]() { CancelTimer(); - TWidgetDialog - sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), _T("OpenVario System Settings")); - sub_dialog.SetWidget(display, event_queue, sub_dialog); + TWidgetDialog sub_dialog( + WidgetDialog::Full{}, dialog.GetMainWindow(), GetLook(), + _T("OpenVario System Settings")); + sub_dialog.SetWidget(display, event_queue, sub_dialog); sub_dialog.AddButton(_("Close"), mrOK); return sub_dialog.ShowModal(); }); AddReadOnly(_T("")); - AddButton(_T("Shell"), [this]() { - dialog.SetModalResult(LAUNCH_SHELL); - }); + AddButton(_T("Shell"), [this]() { dialog.SetModalResult(LAUNCH_SHELL); }); - AddButton(_T("Reboot"), [](){ - Run("/sbin/reboot"); - }); + auto Btn_Reboot = AddButton(_T("Reboot"), []() { Run("/sbin/reboot"); }); - AddButton(_T("Power off") , [](){ - Run("/sbin/poweroff"); - }); + auto Btn_Shutdown = + AddButton(_T("Power off"), []() { Run("/sbin/poweroff"); }); - AddReadOnly(_T("")); // Timer-Progress + AddReadOnly(_T("")); // Timer-Progress + if (!IsOpenVarioDevice) { + Btn_XCSoar->SetEnabled(false); + Btn_Reboot->SetEnabled(false); + Btn_Shutdown->SetEnabled(false); + } HideRow(Controls::OPENSOAR_CLUB); } @@ -264,9 +269,24 @@ Main(UI::EventQueue &event_queue, UI::SingleWindow &main_window, return dialog.ShowModal(); } +#include +#define MAX_PATH 0x100 +void debugln(const char *fmt, ...) noexcept { + char buf[MAX_PATH]; + va_list ap; + + va_start(ap, fmt); + vsnprintf(buf, sizeof(buf) - 1, fmt, ap); + va_end(ap); + + strcat(buf, "\n"); + printf(buf); +} + static int Main() { + IsOpenVarioDevice = File::Exists(ConfigFile); dialog_settings.SetDefaults(); ScreenGlobalInit screen_init; @@ -278,17 +298,37 @@ Main() UI::TopWindowStyle main_style; main_style.Resizable(); - #ifndef _WIN32 +#ifndef _WIN32 main_style.InitialOrientation(Display::DetectInitialOrientation()); - #endif +#endif UI::SingleWindow main_window{screen_init.GetDisplay()}; - main_window.Create(_T("XCSoar/KoboMenu"), {600, 800}, main_style); + main_window.Create(_T("XCSoar/OpenVarioMenu"), {600, 800}, main_style); main_window.Show(); global_dialog_look = &dialog_look; global_main_window = &main_window; + if (!IsOpenVarioDevice) { + // StaticString<0x100> Home; + //Home.SetUTF8(getenv("HOME")); + // Home = _T("/home/august2111"); + debugln("HOME = %s", getenv("HOME")); + + ConfigFile = Path(_T("./config.uEnv")); + // AllocatedPath::Build(Path(Home), Path(_T("/config.uEnv"))); + // AllocatedPath::Build(Path(_T("/home/august2111")), Path(_T("/config.uEnv"))); + // AllocatedPath::Build(Path(), Path(_T("/config.uEnv"))); + debugln("ConfigFile: %s", ConfigFile.c_str()); + // #endif + if (!File::Exists(ConfigFile)) { + debugln("ConfigFile does not exist", ConfigFile.c_str()); + File::CreateExclusive(ConfigFile); + if (!File::Exists(ConfigFile)) + debugln("still ConfigFile does not exist", ConfigFile.c_str()); + } + } + int action = Main(screen_init.GetEventQueue(), main_window, dialog_look); main_window.Destroy(); @@ -307,3 +347,12 @@ int main() // save in LogFormat? return action; } + +#ifdef _WIN32 +int RunProcessDialog(UI::SingleWindow &parent, const DialogLook &dialog_look, + const TCHAR *caption, const char *const *argv, + std::function on_exit = {}) noexcept +{ + return 0; +} +#endif // _WIN32 diff --git a/src/OpenVario/System/System.cpp b/src/OpenVario/System/System.cpp index 661723e865f..730d60d9a38 100644 --- a/src/OpenVario/System/System.cpp +++ b/src/OpenVario/System/System.cpp @@ -41,6 +41,7 @@ #include // constexpr const Path ConfigFile(_T("/boot/config.uEnv")); +Path ConfigFile(_T("/boot/config.uEnv")); //---------------------------------------------------------- void LoadConfigFile(std::map> &map, Path path) @@ -210,4 +211,3 @@ OpenvarioDisableSSH() } #endif // _WIN32 //---------------------------------------------------------- - diff --git a/src/OpenVario/System/System.hpp b/src/OpenVario/System/System.hpp index c1e639de25e..c7db819cdff 100644 --- a/src/OpenVario/System/System.hpp +++ b/src/OpenVario/System/System.hpp @@ -14,7 +14,8 @@ // extern constexpr const Path ConfigFile; -constexpr const Path ConfigFile(_T("/boot/config.uEnv")); +// constexpr const Path ConfigFile(_T("/boot/config.uEnv")); +extern Path ConfigFile; #if !defined(_WIN32) && 1 From 61dc8daf1db24aae787fa4ef7d4c569199e41b61 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 15 Apr 2024 10:13:36 +0200 Subject: [PATCH 080/403] [CMake] - OpenVario-Menu update --- src/OpenVario/CMakeLists.txt | 8 +++++++- src/OpenVario/CMakeSource.cmake | 29 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/OpenVario/CMakeLists.txt b/src/OpenVario/CMakeLists.txt index 54e17353144..ccf47cc25a0 100644 --- a/src/OpenVario/CMakeLists.txt +++ b/src/OpenVario/CMakeLists.txt @@ -49,5 +49,11 @@ target_link_libraries(${TARGET_NAME} PUBLIC Logger) # message(FATAL_ERROR "Stop!") set_target_properties(${TARGET_NAME} PROPERTIES FOLDER OpenVario) -target_link_libraries(${TARGET_NAME} PUBLIC Dialogs Math Language ${XCSOAR_LINK_LIBRARIES}) +target_link_libraries(${TARGET_NAME} PUBLIC Dialogs Math Language Profile net co Blackboard util system io Look Widget Renderer + gdiplus + ${FMT_LIB} ${CURL_TARGET} ${CARES_TARGET} ${ZLIB_TARGET} + ${SODIUM_TARGET} # new at 06/2020 + ${SSL_LIB} # new at 03/2021 + ${CRYPTO_LIB} # new at 03/2021 +) add_dependencies(${TARGET_NAME} util Data) diff --git a/src/OpenVario/CMakeSource.cmake b/src/OpenVario/CMakeSource.cmake index 80e119ab483..d21d223e7f6 100644 --- a/src/OpenVario/CMakeSource.cmake +++ b/src/OpenVario/CMakeSource.cmake @@ -4,6 +4,35 @@ set(_SOURCES OpenVario/System/SystemMenuWidget.cpp OpenVario/System/SystemSettingsWidget.cpp OpenVario/FileMenuWidget.cpp + + ${SRC}/Version.cpp + ${SRC}/Asset.cpp + ${SRC}/Formatter/HexColor.cpp + ${SRC}/Formatter/TimeFormatter.cpp + ${SRC}/Hardware/CPU.cpp + ${SRC}/Hardware/DisplayDPI.cpp + ${SRC}/Hardware/RotateDisplay.cpp + ${SRC}/Hardware/DisplayGlue.cpp + ${SRC}/Screen/Layout.cpp + ${SRC}/ui/control/TerminalWindow.cpp + ${SRC}/Look/TerminalLook.cpp + ${SRC}/Look/DialogLook.cpp + ${SRC}/Look/ButtonLook.cpp + ${SRC}/Look/CheckBoxLook.cpp + ${SRC}/Renderer/TwoTextRowsRenderer.cpp + ${SRC}/Gauge/LogoView.cpp + ${SRC}/Dialogs/DialogSettings.cpp + ${SRC}/Dialogs/WidgetDialog.cpp + ${SRC}/Dialogs/HelpDialog.cpp + ${SRC}/Dialogs/Message.cpp + ${SRC}/Dialogs/LockScreen.cpp + ${SRC}/Dialogs/TextEntry.cpp + ${SRC}/Dialogs/KnobTextEntry.cpp + ${SRC}/Dialogs/TouchTextEntry.cpp + ${SRC}/Profile/Map.cpp + ${SRC}/Profile/File.cpp + ${SRC}/Profile/NumericValue.cpp + ) set(SCRIPT_FILES From 6201711d0614f1425bfa228414b13ea50cf454aa Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 5 Jan 2024 23:14:26 +0100 Subject: [PATCH 081/403] OpenVarioMenu - split the (Widget) classes in different source files --- src/OpenVario/FileMenuWidget.cpp | 20 +- src/OpenVario/OpenVarioMenu.cpp | 103 ++++++--- .../System/Setting/BrightnessWidget.cpp | 99 +++++++++ .../System/Setting/BrightnessWidget.hpp | 28 +++ .../System/Setting/RotationWidget.cpp | 89 ++++++++ .../System/Setting/RotationWidget.hpp | 28 +++ src/OpenVario/System/Setting/SSHWidget.cpp | 79 +++++++ src/OpenVario/System/Setting/SSHWidget.hpp | 27 +++ .../System/Setting/SensordWidget.cpp | 75 +++++++ .../System/Setting/SensordWidget.hpp | 27 +++ .../System/Setting/TimeoutWidget.cpp | 208 ++++++++++++++++++ .../System/Setting/TimeoutWidget.hpp | 27 +++ src/OpenVario/System/Setting/VariodWidget.cpp | 76 +++++++ src/OpenVario/System/Setting/VariodWidget.hpp | 27 +++ src/OpenVario/System/Setting/WifiWidget.cpp | 47 ++++ src/OpenVario/System/Setting/WifiWidget.hpp | 9 + src/OpenVario/System/System.cpp | 1 - src/OpenVario/System/SystemMenuWidget.cpp | 9 +- src/OpenVario/System/SystemSettingsWidget.cpp | 34 ++- 19 files changed, 958 insertions(+), 55 deletions(-) create mode 100644 src/OpenVario/System/Setting/BrightnessWidget.cpp create mode 100644 src/OpenVario/System/Setting/BrightnessWidget.hpp create mode 100644 src/OpenVario/System/Setting/RotationWidget.cpp create mode 100644 src/OpenVario/System/Setting/RotationWidget.hpp create mode 100644 src/OpenVario/System/Setting/SSHWidget.cpp create mode 100644 src/OpenVario/System/Setting/SSHWidget.hpp create mode 100644 src/OpenVario/System/Setting/SensordWidget.cpp create mode 100644 src/OpenVario/System/Setting/SensordWidget.hpp create mode 100644 src/OpenVario/System/Setting/TimeoutWidget.cpp create mode 100644 src/OpenVario/System/Setting/TimeoutWidget.hpp create mode 100644 src/OpenVario/System/Setting/VariodWidget.cpp create mode 100644 src/OpenVario/System/Setting/VariodWidget.hpp create mode 100644 src/OpenVario/System/Setting/WifiWidget.cpp create mode 100644 src/OpenVario/System/Setting/WifiWidget.hpp diff --git a/src/OpenVario/FileMenuWidget.cpp b/src/OpenVario/FileMenuWidget.cpp index 3d67a41ce51..865d5fd2b17 100644 --- a/src/OpenVario/FileMenuWidget.cpp +++ b/src/OpenVario/FileMenuWidget.cpp @@ -5,11 +5,13 @@ #include "Hardware/DisplayGlue.hpp" #include "Language/Language.hpp" +#include #include -constexpr const char *opensoar = "OpenSoar"; -constexpr const char *xcsoar = "XCSoar"; -constexpr const char *main_app = opensoar; +constexpr const TCHAR *opensoar = _T("OpenSoar"); +constexpr const TCHAR *xcsoar = _T("XCSoar"); +constexpr const TCHAR *main_app = opensoar; +constexpr const char *_main_app = "OpenSoar"; // only temporarily void FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, @@ -30,7 +32,7 @@ FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, title.Format(_("Download %s data files from OV to USB"), main_app); AddButton(title, []() { static constexpr const char *argv[] = { - "/usr/bin/transfers.sh", "download-data", "main_app.c_str()", nullptr + "/usr/bin/transfers.sh", "download-data", _main_app, nullptr }; RunProcessDialog(UIGlobals::GetMainWindow(), @@ -41,7 +43,7 @@ FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, title.Format(_("Restore %s data files from USB"), main_app); AddButton(title, []() { static constexpr const char *argv[] = {"/usr/bin/transfers.sh", - "upload-data", main_app, nullptr}; + "upload-data", _main_app, nullptr}; StaticString<32> dialog_title; dialog_title.Format(_("Restore %s"), main_app); @@ -53,8 +55,8 @@ FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, title.Format(_("System Backup: OpenVario and %s settings to USB"), main_app); AddButton(title, []() { - static constexpr const char *argv[] = { - "/usr/bin/transfer-system.sh", "backup", main_app, nullptr + static constexpr const char *argv[] = {"/usr/bin/transfer-system.sh", + "backup", _main_app, nullptr }; RunProcessDialog(UIGlobals::GetMainWindow(), @@ -65,8 +67,8 @@ FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, title.Format(_("System Restore: OpenVario and %s settings from USB"), main_app); AddButton(title, []() { - static constexpr const char *argv[] = { - "/usr/bin/transfer-system.sh", "restore", main_app, nullptr + static constexpr const char *argv[] = {"/usr/bin/transfer-system.sh", + "restore", _main_app, nullptr }; RunProcessDialog(UIGlobals::GetMainWindow(), diff --git a/src/OpenVario/OpenVarioMenu.cpp b/src/OpenVario/OpenVarioMenu.cpp index 9229f5bb10c..f0ce78ac84f 100644 --- a/src/OpenVario/OpenVarioMenu.cpp +++ b/src/OpenVario/OpenVarioMenu.cpp @@ -11,11 +11,13 @@ #include "Screen/Layout.hpp" // #include "../test/src/Fonts.hpp" // #include "Fonts.hpp" + #include "ui/window/Init.hpp" #include "ui/window/SingleWindow.hpp" // #include "ui/event/Queue.hpp" #include "ui/event/Timer.hpp" #include "ui/event/KeyCode.hpp" + #include "Language/Language.hpp" #include "system/Process.hpp" // #include "util/ScopeExit.hxx" @@ -26,6 +28,7 @@ #include "Hardware/DisplayGlue.hpp" #include "Hardware/DisplayDPI.hpp" #include "Hardware/RotateDisplay.hpp" +#include "util/StaticString.hxx" #include "OpenVario/System/System.hpp" #include "OpenVario/FileMenuWidget.h" @@ -35,36 +38,45 @@ #include #include #include +#include -#include "util/StaticString.hxx" -bool IsOpenVarioDevice = true; +#include "boost/filesystem/operations.hpp" +#include "boost/filesystem/path.hpp" -template -static void ChangeConfigString(const std::string &keyvalue, T value, - const std::string &path) { - const Path ConfigPath(path.c_str()); +// #include "System/System.cpp" - ProfileMap configuration; - try { - Profile::LoadFile(configuration, ConfigPath); - } catch (std::exception &e) { - Profile::SaveFile(configuration, ConfigPath); - } - configuration.Set(keyvalue.c_str(), value); - Profile::SaveFile(configuration, ConfigPath); -} - -// enum Buttons { -// LAUNCH_SHELL = 100, -// START_UPGRADE = 111, -// }; +bool IsOpenVarioDevice = true; static DialogSettings dialog_settings; static UI::SingleWindow *global_main_window; static DialogLook *global_dialog_look; + +// #ifdef OPENVARIO_DEVICE // remove this after OpenVarioMenu is ready +// Path ConfigFile(_T("/boot/config.uEnv")); +// #endif + +// #ifndef OPENVARIO_DEVICE // remove this after OpenVarioMenu is ready +// +// template +// static void ChangeConfigString(const std::string &keyvalue, T value, +// const std::string &path) { +// const Path ConfigPath(path.c_str()); +// +// ProfileMap configuration; +// +// try { +// Profile::LoadFile(configuration, ConfigPath); +// } catch (std::exception &e) { +// Profile::SaveFile(configuration, ConfigPath); +// } +// configuration.Set(keyvalue.c_str(), value); +// Profile::SaveFile(configuration, ConfigPath); +// } +// #else + const DialogSettings & UIGlobals::GetDialogSettings() { @@ -135,10 +147,35 @@ class MainMenuWidget final void StartOpenSoar() noexcept { const UI::ScopeDropMaster drop_master{display}; const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; +#ifdef _WIN32 + // namespace fs = ; + + boost::filesystem::path ExePathBoost(boost::filesystem::initial_path()); + // std::cout << ExePath.native_file_string() << endl; + std::filesystem::path ExePath(std::filesystem::current_path()); + ExePath.append("OpenSoar.exe"); + ExePath = "D:/Projects/Binaries/OpenSoar/dev-branch/msvc2022/Release/" + "OpenSoar.exe"; +// for (unsigned int i = 0; i < 2; i++) { +// auto arg = args[i]; +// printf(arg); +// } + char buf[0x200]; + + snprintf(buf, sizeof(buf) - 1, "%s -fly -datapath=%s -profile=%s", + ExePath.generic_string().c_str(), + "D:/Data/XCSoarData", + "D:/Data/XCSoarData/August.prf" + ); + + Run(buf); + // , "-datapath=/home/root/data/OpenSoarData"); +#else if (File::Exists(Path(_T("/usr/bin/OpenSoar")))) Run("/usr/bin/OpenSoar", "-fly", "-datapath=/home/root/data/OpenSoarData"); else Run("./output/UNIX/bin/OpenSoar", "-fly"); +#endif } void StartXCSoar() noexcept { @@ -201,6 +238,7 @@ class MainMenuWidget final void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { + AddButton(_("Start OpenSoar (Club)"), [this]() { CancelTimer(); StartOpenSoar(); @@ -240,7 +278,7 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, AddReadOnly(_T("")); - AddButton(_T("Shell"), [this]() { dialog.SetModalResult(LAUNCH_SHELL); }); + auto Btn_Shell = AddButton(_T("Shell"), [this]() { dialog.SetModalResult(LAUNCH_SHELL); }); auto Btn_Reboot = AddButton(_T("Reboot"), []() { Run("/sbin/reboot"); }); @@ -250,12 +288,14 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, AddReadOnly(_T("")); // Timer-Progress if (!IsOpenVarioDevice) { + Btn_Shell->SetCaption(_T("Exit")); Btn_XCSoar->SetEnabled(false); Btn_Reboot->SetEnabled(false); Btn_Shutdown->SetEnabled(false); } HideRow(Controls::OPENSOAR_CLUB); } +// #endif // OPENVARIO_DEVICE // remove this after OpenVarioMenu is ready static int Main(UI::EventQueue &event_queue, UI::SingleWindow &main_window, @@ -270,8 +310,15 @@ Main(UI::EventQueue &event_queue, UI::SingleWindow &main_window, } #include -#define MAX_PATH 0x100 -void debugln(const char *fmt, ...) noexcept { + +void debugln(const char *fmt, ...) noexcept; + +#ifndef MAX_PATH +# define MAX_PATH 0x100 +#endif +void +debugln(const char *fmt, ...) noexcept +{ char buf[MAX_PATH]; va_list ap; @@ -292,6 +339,9 @@ Main() ScreenGlobalInit screen_init; Layout::Initialise(screen_init.GetDisplay(), {600, 800}); // InitialiseFonts(); + + // AllowLanguage is not in FalkLanguage + // AllowLanguage(); DialogLook dialog_look; dialog_look.Initialise(); @@ -310,10 +360,11 @@ Main() global_main_window = &main_window; if (!IsOpenVarioDevice) { - // StaticString<0x100> Home; - //Home.SetUTF8(getenv("HOME")); + StaticString<0x100> Home; + Home.SetUTF8(getenv("HOME")); // Home = _T("/home/august2111"); - debugln("HOME = %s", getenv("HOME")); + debugln("HOME(1) = %s", getenv("HOME")); + debugln("HOME(2) = %s", Home.c_str()); ConfigFile = Path(_T("./config.uEnv")); // AllocatedPath::Build(Path(Home), Path(_T("/config.uEnv"))); diff --git a/src/OpenVario/System/Setting/BrightnessWidget.cpp b/src/OpenVario/System/Setting/BrightnessWidget.cpp new file mode 100644 index 00000000000..806a17be124 --- /dev/null +++ b/src/OpenVario/System/Setting/BrightnessWidget.cpp @@ -0,0 +1,99 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project + +#if 0 // ndef __MSVC__ +#include "lib/dbus/Connection.hxx" +#include "lib/dbus/ScopeMatch.hxx" +#include "lib/dbus/Systemd.hxx" +#endif + +#include "Dialogs/DialogSettings.hpp" +#include "Dialogs/Message.hpp" +#include "Dialogs/ProcessDialog.hpp" +#include "Dialogs/WidgetDialog.hpp" +#include "DisplayOrientation.hpp" +#include "Hardware/DisplayDPI.hpp" +#include "Hardware/DisplayGlue.hpp" +#include "Hardware/RotateDisplay.hpp" +#include "Look/DialogLook.hpp" +#include "Profile/File.hpp" +#include "Profile/Map.hpp" +#include "Screen/Layout.hpp" +#include "UIGlobals.hpp" +// #include "Widget/RowFormWidget.hpp" +#include "system/FileUtil.hpp" +#include "system/Process.hpp" +#include "ui/event/KeyCode.hpp" +// #include "ui/event/Queue.hpp" +#include "ui/event/Timer.hpp" +#include "ui/window/Init.hpp" +// #include "ui/window/SingleWindow.hpp" + +#include "Language/Language.hpp" + +#include "io/KeyValueFileReader.hpp" +#include "io/FileOutputStream.hxx" +#include "io/BufferedOutputStream.hxx" +#include "io/FileLineReader.hpp" + +#include "OpenVario/System/System.hpp" +#include "OpenVario/System/Setting/BrightnessWidget.hpp" + +#ifndef __MSVC__ +#include +#include +#endif +#include + +#include +#include + +//---------------------------------------------------------- +//---------------------------------------------------------- +//---------------------------------------------------------- +void SettingBrightnessWidget::SaveBrightness(const std::string &brightness) { + File::WriteExisting(Path(_T("/sys/class/backlight/lcd/brightness")), + (brightness).c_str()); +} + +void +SettingBrightnessWidget::Prepare([[maybe_unused]] ContainerWindow &parent, + [[maybe_unused]] const PixelRect &rc) noexcept +{ + AddButton(_T("20"), [this](){ + SaveBrightness("2"); + }); + + AddButton(_T("30"), [this](){ + SaveBrightness("3"); + }); + + AddButton(_T("40"), [this](){ + SaveBrightness("4"); + }); + + AddButton(_T("50"), [this](){ + SaveBrightness("5"); + }); + + AddButton(_T("60"), [this](){ + SaveBrightness("6"); + }); + + AddButton(_T("70"), [this](){ + SaveBrightness("7"); + }); + + AddButton(_T("80"), [this](){ + SaveBrightness("8"); + }); + + AddButton(_T("90"), [this](){ + SaveBrightness("9"); + }); + + AddButton(_T("100"), [this](){ + SaveBrightness("10"); + }); +} + diff --git a/src/OpenVario/System/Setting/BrightnessWidget.hpp b/src/OpenVario/System/Setting/BrightnessWidget.hpp new file mode 100644 index 00000000000..58e0a5c8b9b --- /dev/null +++ b/src/OpenVario/System/Setting/BrightnessWidget.hpp @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project + +#pragma once + +#include "Widget/RowFormWidget.hpp" +#include "ui/event/Queue.hpp" +#include "ui/window/SingleWindow.hpp" + +class SettingBrightnessWidget final + : public RowFormWidget +{ + UI::Display &display; + UI::EventQueue &event_queue; + +public: + SettingBrightnessWidget(UI::Display &_display, UI::EventQueue &_event_queue, + const DialogLook &look) noexcept + :RowFormWidget(look), + display(_display), event_queue(_event_queue) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, + const PixelRect &rc) noexcept override; + + void SaveBrightness(const std::string &brightness); +}; diff --git a/src/OpenVario/System/Setting/RotationWidget.cpp b/src/OpenVario/System/Setting/RotationWidget.cpp new file mode 100644 index 00000000000..0a1a276208c --- /dev/null +++ b/src/OpenVario/System/Setting/RotationWidget.cpp @@ -0,0 +1,89 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project + +#if 0 // ndef __MSVC__ +#include "lib/dbus/Connection.hxx" +#include "lib/dbus/ScopeMatch.hxx" +#include "lib/dbus/Systemd.hxx" +#endif + +#include "Dialogs/DialogSettings.hpp" +#include "Dialogs/Message.hpp" +#include "Dialogs/ProcessDialog.hpp" +#include "Dialogs/WidgetDialog.hpp" +#include "DisplayOrientation.hpp" +#include "Hardware/DisplayDPI.hpp" +#include "Hardware/DisplayGlue.hpp" +#include "Hardware/RotateDisplay.hpp" +#include "Look/DialogLook.hpp" +#include "Profile/File.hpp" +#include "Profile/Map.hpp" +#include "Screen/Layout.hpp" +#include "UIGlobals.hpp" +// #include "Widget/RowFormWidget.hpp" +#include "system/FileUtil.hpp" +#include "system/Process.hpp" +#include "ui/event/KeyCode.hpp" +// #include "ui/event/Queue.hpp" +#include "ui/event/Timer.hpp" +#include "ui/window/Init.hpp" +// #include "ui/window/SingleWindow.hpp" + +#include "Language/Language.hpp" + +#include "io/KeyValueFileReader.hpp" +#include "io/FileOutputStream.hxx" +#include "io/BufferedOutputStream.hxx" +#include "io/FileLineReader.hpp" + +#include "OpenVario/System/System.hpp" +#include "OpenVario/System/Setting/RotationWidget.hpp" + +#ifndef __MSVC__ +#include +#include +#endif +#include + +#include +#include + +//---------------------------------------------------------- +//---------------------------------------------------------- +//---------------------------------------------------------- + +/* x-menu writes the value for the display rotation to /sys because the value is also required for the console in the OpenVario. +In addition, the display rotation is saved in /boot/config.uEnv so that the Openvario sets the correct rotation again when it is restarted.*/ +void +SettingRotationWidget::SaveRotation(const std::string &rotationString) +{ + File::WriteExisting(Path(_T("/sys/class/graphics/fbcon/rotate")), (rotationString).c_str()); + int rotationInt = stoi(rotationString); + ChangeConfigInt("rotation", rotationInt, ConfigFile); +} + +void +SettingRotationWidget::Prepare([[maybe_unused]] ContainerWindow &parent, + [[maybe_unused]] const PixelRect &rc) noexcept +{ + AddButton(_T("Landscape"), [this](){ + SaveRotation("0"); + Display::Rotate(DisplayOrientation::LANDSCAPE); + }); + + AddButton(_T("Portrait (90°)"), [this](){ + SaveRotation("1"); + Display::Rotate(DisplayOrientation::REVERSE_PORTRAIT); + }); + + AddButton(_T("Landscape (180°)"), [this](){ + SaveRotation("2"); + Display::Rotate(DisplayOrientation::REVERSE_LANDSCAPE); + }); + + AddButton(_T("Portrait (270°)"), [this](){ + SaveRotation("3"); + Display::Rotate(DisplayOrientation::PORTRAIT); + }); +} + diff --git a/src/OpenVario/System/Setting/RotationWidget.hpp b/src/OpenVario/System/Setting/RotationWidget.hpp new file mode 100644 index 00000000000..4655ade52d7 --- /dev/null +++ b/src/OpenVario/System/Setting/RotationWidget.hpp @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project + +#pragma once + +#include "Widget/RowFormWidget.hpp" +#include "ui/event/Queue.hpp" +#include "ui/window/SingleWindow.hpp" + +class SettingRotationWidget final + : public RowFormWidget +{ + UI::Display &display; + UI::EventQueue &event_queue; + +public: + SettingRotationWidget(UI::Display &_display, UI::EventQueue &_event_queue, + const DialogLook &look) noexcept + :RowFormWidget(look), + display(_display), event_queue(_event_queue) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, + const PixelRect &rc) noexcept override; + void SaveRotation(const std::string &rotationvalue); +}; + diff --git a/src/OpenVario/System/Setting/SSHWidget.cpp b/src/OpenVario/System/Setting/SSHWidget.cpp new file mode 100644 index 00000000000..e6fbe2a21ad --- /dev/null +++ b/src/OpenVario/System/Setting/SSHWidget.cpp @@ -0,0 +1,79 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project + +#if 0 // ndef __MSVC__ +#include "lib/dbus/Connection.hxx" +#include "lib/dbus/ScopeMatch.hxx" +#include "lib/dbus/Systemd.hxx" +#endif + +#include "Dialogs/DialogSettings.hpp" +#include "Dialogs/Message.hpp" +#include "Dialogs/ProcessDialog.hpp" +#include "Dialogs/WidgetDialog.hpp" +#include "DisplayOrientation.hpp" +#include "Hardware/DisplayDPI.hpp" +#include "Hardware/DisplayGlue.hpp" +#include "Hardware/RotateDisplay.hpp" +#include "Look/DialogLook.hpp" +#include "Profile/File.hpp" +#include "Profile/Map.hpp" +#include "Screen/Layout.hpp" +#include "UIGlobals.hpp" +// #include "Widget/RowFormWidget.hpp" +#include "system/FileUtil.hpp" +#include "system/Process.hpp" +#include "ui/event/KeyCode.hpp" +// #include "ui/event/Queue.hpp" +#include "ui/event/Timer.hpp" +#include "ui/window/Init.hpp" +// #include "ui/window/SingleWindow.hpp" + +#include "Language/Language.hpp" + +#include "io/KeyValueFileReader.hpp" +#include "io/FileOutputStream.hxx" +#include "io/BufferedOutputStream.hxx" +#include "io/FileLineReader.hpp" + +#include "OpenVario/System/System.hpp" +#include "OpenVario/System/Setting/SSHWidget.hpp" + +#ifndef __MSVC__ +#include +#include +#endif +#include + +#include +#include + +void +SettingSSHWidget::Prepare([[maybe_unused]] ContainerWindow &parent, + [[maybe_unused]] const PixelRect &rc) noexcept +{ + AddButton(_T("Enable") , [](){ + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "systemctl enable dropbear.socket && printf '\nSSH has been enabled'", + + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _T("Enable"), argv); + }); + + AddButton(_T("Disable") , [](){ + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "systemctl disable dropbear.socket && printf '\nSSH has been disabled'", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _T("Disable"), argv); + }); +} diff --git a/src/OpenVario/System/Setting/SSHWidget.hpp b/src/OpenVario/System/Setting/SSHWidget.hpp new file mode 100644 index 00000000000..345cc7c7a35 --- /dev/null +++ b/src/OpenVario/System/Setting/SSHWidget.hpp @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project + +#pragma once + +#include "Widget/RowFormWidget.hpp" +#include "ui/event/Queue.hpp" +#include "ui/window/SingleWindow.hpp" + +class SettingSSHWidget final + : public RowFormWidget +{ + UI::Display &display; + UI::EventQueue &event_queue; + +public: + SettingSSHWidget(UI::Display &_display, UI::EventQueue &_event_queue, + const DialogLook &look) noexcept + :RowFormWidget(look), + display(_display), event_queue(_event_queue) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, + const PixelRect &rc) noexcept override; +}; + diff --git a/src/OpenVario/System/Setting/SensordWidget.cpp b/src/OpenVario/System/Setting/SensordWidget.cpp new file mode 100644 index 00000000000..043a8abbb6e --- /dev/null +++ b/src/OpenVario/System/Setting/SensordWidget.cpp @@ -0,0 +1,75 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project + +#include "Dialogs/DialogSettings.hpp" +#include "Dialogs/Message.hpp" +#include "Dialogs/ProcessDialog.hpp" +#include "Dialogs/WidgetDialog.hpp" +#include "DisplayOrientation.hpp" +#include "Hardware/DisplayDPI.hpp" +#include "Hardware/DisplayGlue.hpp" +#include "Hardware/RotateDisplay.hpp" +#include "Look/DialogLook.hpp" +#include "Profile/File.hpp" +#include "Profile/Map.hpp" +#include "Screen/Layout.hpp" +#include "UIGlobals.hpp" +// #include "Widget/RowFormWidget.hpp" +#include "system/FileUtil.hpp" +#include "system/Process.hpp" +#include "ui/event/KeyCode.hpp" +// #include "ui/event/Queue.hpp" +#include "ui/event/Timer.hpp" +#include "ui/window/Init.hpp" +// #include "ui/window/SingleWindow.hpp" + +#include "Language/Language.hpp" + +#include "io/KeyValueFileReader.hpp" +#include "io/FileOutputStream.hxx" +#include "io/BufferedOutputStream.hxx" +#include "io/FileLineReader.hpp" + +#include "OpenVario/System/System.hpp" +#include "OpenVario/System/Setting/SensordWidget.hpp" + +#ifndef __MSVC__ +#include +#include +#endif +#include + +#include +#include + +//---------------------------------------------------------- +//---------------------------------------------------------- +//---------------------------------------------------------- +void +SettingSensordWidget::Prepare([[maybe_unused]] ContainerWindow &parent, + [[maybe_unused]] const PixelRect &rc) noexcept +{ + AddButton(_T("Enable"), [](){ + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "systemctl enable sensord && printf '\nsensord has been enabled'", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _T("Enable"), argv); + }); + + AddButton(_T("Disable"), [](){ + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "systemctl disable sensord && printf '\nsensord has been disabled'", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _T("Disable"), argv); + }); +} diff --git a/src/OpenVario/System/Setting/SensordWidget.hpp b/src/OpenVario/System/Setting/SensordWidget.hpp new file mode 100644 index 00000000000..03e15441f6c --- /dev/null +++ b/src/OpenVario/System/Setting/SensordWidget.hpp @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project + +#pragma once + +#include "Widget/RowFormWidget.hpp" +#include "ui/event/Queue.hpp" +#include "ui/window/SingleWindow.hpp" + +class SettingSensordWidget final + : public RowFormWidget +{ + UI::Display &display; + UI::EventQueue &event_queue; + +public: + SettingSensordWidget(UI::Display &_display, UI::EventQueue &_event_queue, + const DialogLook &look) noexcept + :RowFormWidget(look), + display(_display), event_queue(_event_queue) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, + const PixelRect &rc) noexcept override; +}; + diff --git a/src/OpenVario/System/Setting/TimeoutWidget.cpp b/src/OpenVario/System/Setting/TimeoutWidget.cpp new file mode 100644 index 00000000000..ab432f53889 --- /dev/null +++ b/src/OpenVario/System/Setting/TimeoutWidget.cpp @@ -0,0 +1,208 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project + +#if 0 // ndef __MSVC__ +#include "lib/dbus/Connection.hxx" +#include "lib/dbus/ScopeMatch.hxx" +#include "lib/dbus/Systemd.hxx" +#endif + +#include "Dialogs/DialogSettings.hpp" +#include "Dialogs/Message.hpp" +#include "Dialogs/ProcessDialog.hpp" +#include "Dialogs/WidgetDialog.hpp" +#include "DisplayOrientation.hpp" +#include "Hardware/DisplayDPI.hpp" +#include "Hardware/DisplayGlue.hpp" +#include "Hardware/RotateDisplay.hpp" +#include "Look/DialogLook.hpp" +#include "Profile/File.hpp" +#include "Profile/Map.hpp" +#include "Screen/Layout.hpp" +#include "UIGlobals.hpp" +// #include "Widget/RowFormWidget.hpp" +#include "system/FileUtil.hpp" +#include "system/Process.hpp" +#include "ui/event/KeyCode.hpp" +// #include "ui/event/Queue.hpp" +#include "ui/event/Timer.hpp" +#include "ui/window/Init.hpp" +// #include "ui/window/SingleWindow.hpp" + +#include "Language/Language.hpp" + +#include "io/KeyValueFileReader.hpp" +#include "io/FileOutputStream.hxx" +#include "io/BufferedOutputStream.hxx" +#include "io/FileLineReader.hpp" + +#include "OpenVario/System/System.hpp" +#include "OpenVario/System/Setting/TimeoutWidget.hpp" + +#ifndef __MSVC__ +#include +#include +#endif +#include + +#include +#include + +//---------------------------------------------------------- +//---------------------------------------------------------- +//---------------------------------------------------------- + +void +SettingTimeoutWidget::SaveTimeout(int timeoutInt) +{ + ChangeConfigInt("timeout", timeoutInt, ConfigFile); +} + +void +SettingTimeoutWidget::Prepare([[maybe_unused]] ContainerWindow &parent, + [[maybe_unused]] const PixelRect &rc) noexcept + +{ + AddButton(_T("immediately"), [this](){ + SaveTimeout(0); + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "echo Automatic timeout was set to 0s", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _T("immediately"), argv); + }); + + AddButton(_T("1s"), [this](){ + SaveTimeout(1); + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "echo Automatic timeout was set to 1s", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _T("1s"), argv); + }); + + AddButton(_T("3s"), [this](){ + SaveTimeout(3); + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "echo Automatic timeout was set to 3s", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _T("3s"), argv); + }); + + AddButton(_T("5s"), [this](){ + SaveTimeout(5); + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "echo Automatic timeout was set to 5s", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _T("5s"), argv); + }); + + AddButton(_T("10s"), [this](){ + SaveTimeout(10); + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "echo Automatic timeout was set to 10s", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _T("10s"), argv); + }); + + AddButton(_T("30s"), [this](){ + SaveTimeout(30); + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "echo Automatic timeout was set to 30s", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _T("30s"), argv); + }); +} + +//---------------------------------------------------------- +//---------------------------------------------------------- +//---------------------------------------------------------- +#if 0 +void +SystemSettingsWidget::Prepare([[maybe_unused]] ContainerWindow &parent, + [[maybe_unused]] const PixelRect &rc) noexcept +{ + AddButton(_("Setting Rotation"), [this](){ + TWidgetDialog + sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), + GetLook(), _T("Display Rotation Settings")); + sub_dialog.SetWidget(display, event_queue, GetLook()); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); + }); + + AddButton(_("Setting Brightness"), [this](){ + TWidgetDialog + sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), + GetLook(), _T("Display Brightness Settings")); + sub_dialog.SetWidget(display, event_queue, GetLook()); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); + }); + + AddButton(_("Autostart Timeout"), [this](){ + TWidgetDialog + sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), + GetLook(), _T("Autostart Timeout")); + sub_dialog.SetWidget(display, event_queue, GetLook()); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); + }); + + AddButton(_("SSH"), [this](){ + TWidgetDialog + sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), + GetLook(), _T("Enable or Disable SSH")); + sub_dialog.SetWidget(display, event_queue, GetLook()); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); + }); + + AddButton(_("Variod"), [this](){ + TWidgetDialog + sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), + GetLook(), _T("Enable or Disable Variod")); + sub_dialog.SetWidget(display, event_queue, GetLook()); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); + }); + + AddButton(_("Sensord"), [this](){ + TWidgetDialog + sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), + GetLook(), _T("Enable or Disable Sensord")); + sub_dialog.SetWidget(display, event_queue, GetLook()); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); + }); +} + +#endif \ No newline at end of file diff --git a/src/OpenVario/System/Setting/TimeoutWidget.hpp b/src/OpenVario/System/Setting/TimeoutWidget.hpp new file mode 100644 index 00000000000..c3480e4fb29 --- /dev/null +++ b/src/OpenVario/System/Setting/TimeoutWidget.hpp @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project + +#pragma once + +#include "Widget/RowFormWidget.hpp" +#include "ui/event/Queue.hpp" +#include "ui/window/SingleWindow.hpp" + +class SettingTimeoutWidget final + : public RowFormWidget +{ + UI::Display &display; + UI::EventQueue &event_queue; + +public: + SettingTimeoutWidget(UI::Display &_display, UI::EventQueue &_event_queue, + const DialogLook &look) noexcept + :RowFormWidget(look), + display(_display), event_queue(_event_queue) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, + const PixelRect &rc) noexcept override; + void SaveTimeout(int timeoutvalue); +}; diff --git a/src/OpenVario/System/Setting/VariodWidget.cpp b/src/OpenVario/System/Setting/VariodWidget.cpp new file mode 100644 index 00000000000..1d02caa3530 --- /dev/null +++ b/src/OpenVario/System/Setting/VariodWidget.cpp @@ -0,0 +1,76 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project + +#include "Dialogs/DialogSettings.hpp" +#include "Dialogs/Message.hpp" +#include "Dialogs/ProcessDialog.hpp" +#include "Dialogs/WidgetDialog.hpp" +#include "DisplayOrientation.hpp" +#include "Hardware/DisplayDPI.hpp" +#include "Hardware/DisplayGlue.hpp" +#include "Hardware/RotateDisplay.hpp" +#include "Look/DialogLook.hpp" +#include "Profile/File.hpp" +#include "Profile/Map.hpp" +#include "Screen/Layout.hpp" +#include "UIGlobals.hpp" +// #include "Widget/RowFormWidget.hpp" +#include "system/FileUtil.hpp" +#include "system/Process.hpp" +#include "ui/event/KeyCode.hpp" +// #include "ui/event/Queue.hpp" +#include "ui/event/Timer.hpp" +#include "ui/window/Init.hpp" +// #include "ui/window/SingleWindow.hpp" + +#include "Language/Language.hpp" + +#include "io/KeyValueFileReader.hpp" +#include "io/FileOutputStream.hxx" +#include "io/BufferedOutputStream.hxx" +#include "io/FileLineReader.hpp" + +#include "OpenVario/System/System.hpp" +#include "OpenVario/System/Setting/VariodWidget.hpp" + +#ifndef __MSVC__ +#include +#include +#endif +#include + +#include +#include + +//---------------------------------------------------------- +//---------------------------------------------------------- +//---------------------------------------------------------- +void +SettingVariodWidget::Prepare([[maybe_unused]] ContainerWindow &parent, + [[maybe_unused]] const PixelRect &rc) noexcept +{ + AddButton(_T("Enable") , [](){ + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "systemctl enable variod && printf '\nvariod has been enabled'", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _T("Enable"), argv); + }); + + AddButton(_T("Disable"), [](){ + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "systemctl disable variod && printf '\nvariod has been disabled'", + nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _T("Disable"), argv); + }); +} + diff --git a/src/OpenVario/System/Setting/VariodWidget.hpp b/src/OpenVario/System/Setting/VariodWidget.hpp new file mode 100644 index 00000000000..21e42d4af8f --- /dev/null +++ b/src/OpenVario/System/Setting/VariodWidget.hpp @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project + +#pragma once + +#include "Widget/RowFormWidget.hpp" +#include "ui/event/Queue.hpp" +#include "ui/window/SingleWindow.hpp" + +class SettingVariodWidget final + : public RowFormWidget +{ + UI::Display &display; + UI::EventQueue &event_queue; + +public: + SettingVariodWidget(UI::Display &_display, UI::EventQueue &_event_queue, + const DialogLook &look) noexcept + :RowFormWidget(look), + display(_display), event_queue(_event_queue) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, + const PixelRect &rc) noexcept override; +}; + diff --git a/src/OpenVario/System/Setting/WifiWidget.cpp b/src/OpenVario/System/Setting/WifiWidget.cpp new file mode 100644 index 00000000000..cbfca6241ed --- /dev/null +++ b/src/OpenVario/System/Setting/WifiWidget.cpp @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project + +#include "Dialogs/DialogSettings.hpp" +#include "Dialogs/Message.hpp" +#include "Dialogs/ProcessDialog.hpp" +#include "Dialogs/WidgetDialog.hpp" +#include "DisplayOrientation.hpp" +#include "Hardware/DisplayDPI.hpp" +#include "Hardware/DisplayGlue.hpp" +#include "Hardware/RotateDisplay.hpp" +#include "Look/DialogLook.hpp" +#include "Profile/File.hpp" +#include "Profile/Map.hpp" +#include "Screen/Layout.hpp" +#include "UIGlobals.hpp" +// #include "Widget/RowFormWidget.hpp" +#include "system/FileUtil.hpp" +#include "system/Process.hpp" +#include "ui/event/KeyCode.hpp" +// #include "ui/event/Queue.hpp" +#include "ui/event/Timer.hpp" +#include "ui/window/Init.hpp" +// #include "ui/window/SingleWindow.hpp" + +#include "Language/Language.hpp" + +#include "io/KeyValueFileReader.hpp" +#include "io/FileOutputStream.hxx" +#include "io/BufferedOutputStream.hxx" +#include "io/FileLineReader.hpp" + +#include "OpenVario/System/System.hpp" +#include "OpenVario/System/Setting/WifiWidget.hpp" + +#ifndef __MSVC__ +#include +#include +#endif +#include + +#include +#include + +//---------------------------------------------------------- +//---------------------------------------------------------- +//---------------------------------------------------------- diff --git a/src/OpenVario/System/Setting/WifiWidget.hpp b/src/OpenVario/System/Setting/WifiWidget.hpp new file mode 100644 index 00000000000..d4dbe691280 --- /dev/null +++ b/src/OpenVario/System/Setting/WifiWidget.hpp @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project + +#pragma once + +#include "Widget/RowFormWidget.hpp" +#include "ui/event/Queue.hpp" +#include "ui/window/SingleWindow.hpp" + diff --git a/src/OpenVario/System/System.cpp b/src/OpenVario/System/System.cpp index 730d60d9a38..945ddc8ee54 100644 --- a/src/OpenVario/System/System.cpp +++ b/src/OpenVario/System/System.cpp @@ -40,7 +40,6 @@ #include -// constexpr const Path ConfigFile(_T("/boot/config.uEnv")); Path ConfigFile(_T("/boot/config.uEnv")); //---------------------------------------------------------- void diff --git a/src/OpenVario/System/SystemMenuWidget.cpp b/src/OpenVario/System/SystemMenuWidget.cpp index 03e187e9092..35a7e2f57ac 100644 --- a/src/OpenVario/System/SystemMenuWidget.cpp +++ b/src/OpenVario/System/SystemMenuWidget.cpp @@ -14,7 +14,10 @@ #include "UIGlobals.hpp" // #include "Widget/RowFormWidget.hpp" #include "system/FileUtil.hpp" -#include "system/Process.hpp" + +#if !defined(_WIN32) +# include "system/Process.hpp" +#endif #include "ui/event/KeyCode.hpp" // #include "ui/event/Queue.hpp" #include "ui/event/Timer.hpp" @@ -132,7 +135,11 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, AddButton(_("Calibrate Touch"), [this](){ const UI::ScopeDropMaster drop_master{display}; const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; +#if !defined(_WIN32) + // RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), + // _T("System Info"), "/usr/bin/ov-calibrate-ts.sh"); Run("/usr/bin/ov-calibrate-ts.sh"); +#endif }); AddButton(_("System Settings"), [this](){ diff --git a/src/OpenVario/System/SystemSettingsWidget.cpp b/src/OpenVario/System/SystemSettingsWidget.cpp index e6d27e41cbe..907bcf0db93 100644 --- a/src/OpenVario/System/SystemSettingsWidget.cpp +++ b/src/OpenVario/System/SystemSettingsWidget.cpp @@ -1,13 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright The XCSoar Project -#include "System.hpp" -#ifndef _WIN32 -# include "lib/dbus/Connection.hxx" -# include "lib/dbus/ScopeMatch.hxx" -# include "lib/dbus/Systemd.hxx" -#endif - #include "Dialogs/DialogSettings.hpp" #include "Dialogs/Message.hpp" #include "Dialogs/ProcessDialog.hpp" @@ -28,7 +21,6 @@ // #include "ui/event/Queue.hpp" #include "ui/event/Timer.hpp" #include "ui/window/Init.hpp" -// #include "ui/window/SingleWindow.hpp" #include "Language/Language.hpp" @@ -37,10 +29,15 @@ #include "io/BufferedOutputStream.hxx" #include "io/FileLineReader.hpp" -#include "OpenVario/FileMenuWidget.h" #include "OpenVario/System/System.hpp" #include "OpenVario/System/SystemSettingsWidget.hpp" -#include "OpenVario/System/SystemMenuWidget.hpp" +#include "OpenVario/System/Setting/RotationWidget.hpp" +#include "OpenVario/System/Setting/BrightnessWidget.hpp" +#include "OpenVario/System/Setting/TimeoutWidget.hpp" +#include "OpenVario/System/Setting/SSHWidget.hpp" +#include "OpenVario/System/Setting/SensordWidget.hpp" +#include "OpenVario/System/Setting/VariodWidget.hpp" +#include "OpenVario/System/Setting/WifiWidget.hpp" #ifndef _WIN32 #include @@ -54,7 +51,7 @@ //---------------------------------------------------------- //---------------------------------------------------------- //---------------------------------------------------------- - +#if 0 class ScreenRotationWidget final : public RowFormWidget { @@ -428,6 +425,7 @@ ScreenSensordWidget::Prepare([[maybe_unused]] ContainerWindow &parent, _T("Disable"), argv); }); } +#endif //---------------------------------------------------------- //---------------------------------------------------------- //---------------------------------------------------------- @@ -437,7 +435,7 @@ SystemSettingsWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { AddButton(_("Screen Rotation"), [this](){ - TWidgetDialog + TWidgetDialog sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), GetLook(), _T("Display Rotation Settings")); sub_dialog.SetWidget(display, event_queue, GetLook()); @@ -445,8 +443,8 @@ SystemSettingsWidget::Prepare([[maybe_unused]] ContainerWindow &parent, return sub_dialog.ShowModal(); }); - AddButton(_("Screen Brightness"), [this](){ - TWidgetDialog + AddButton(_("Setting Brightness"), [this](){ + TWidgetDialog sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), GetLook(), _T("Display Brightness Settings")); sub_dialog.SetWidget(display, event_queue, GetLook()); @@ -455,7 +453,7 @@ SystemSettingsWidget::Prepare([[maybe_unused]] ContainerWindow &parent, }); AddButton(_("Autostart Timeout"), [this](){ - TWidgetDialog + TWidgetDialog sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), GetLook(), _T("Autostart Timeout")); sub_dialog.SetWidget(display, event_queue, GetLook()); @@ -464,7 +462,7 @@ SystemSettingsWidget::Prepare([[maybe_unused]] ContainerWindow &parent, }); AddButton(_("SSH"), [this](){ - TWidgetDialog + TWidgetDialog sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), GetLook(), _T("Enable or Disable SSH")); sub_dialog.SetWidget(display, event_queue, GetLook()); @@ -473,7 +471,7 @@ SystemSettingsWidget::Prepare([[maybe_unused]] ContainerWindow &parent, }); AddButton(_("Variod"), [this](){ - TWidgetDialog + TWidgetDialog sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), GetLook(), _T("Enable or Disable Variod")); sub_dialog.SetWidget(display, event_queue, GetLook()); @@ -482,7 +480,7 @@ SystemSettingsWidget::Prepare([[maybe_unused]] ContainerWindow &parent, }); AddButton(_("Sensord"), [this](){ - TWidgetDialog + TWidgetDialog sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), GetLook(), _T("Enable or Disable Sensord")); sub_dialog.SetWidget(display, event_queue, GetLook()); From a0d0191b4866aa150f02a6d698c726718db29271 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sat, 6 Jan 2024 11:23:43 +0100 Subject: [PATCH 082/403] [CMake] OpenVarioMenu - split the (Widget) classes in different source files --- src/OpenVario/CMakeLists.txt | 12 ++++++++-- src/OpenVario/CMakeSource.cmake | 39 ++++++++++++++++++++++++++++++--- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/src/OpenVario/CMakeLists.txt b/src/OpenVario/CMakeLists.txt index ccf47cc25a0..ebbded2415d 100644 --- a/src/OpenVario/CMakeLists.txt +++ b/src/OpenVario/CMakeLists.txt @@ -38,6 +38,9 @@ endif() include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +add_compile_definitions("OPENVARIO_DEVICE") +# remeve this definition after + # add_library(${TARGET_NAME} ${XCSOAR_LIB_TYPE} add_executable(${TARGET_NAME} ${SOURCE_FILES} @@ -49,11 +52,16 @@ target_link_libraries(${TARGET_NAME} PUBLIC Logger) # message(FATAL_ERROR "Stop!") set_target_properties(${TARGET_NAME} PROPERTIES FOLDER OpenVario) -target_link_libraries(${TARGET_NAME} PUBLIC Dialogs Math Language Profile net co Blackboard util system io Look Widget Renderer - gdiplus +target_link_libraries(${TARGET_NAME} PUBLIC Math Language Profile net co Blackboard util system io + ui Dialogs Look Widget Renderer MapWindow ${FMT_LIB} ${CURL_TARGET} ${CARES_TARGET} ${ZLIB_TARGET} ${SODIUM_TARGET} # new at 06/2020 ${SSL_LIB} # new at 03/2021 ${CRYPTO_LIB} # new at 03/2021 + + msimg32 + winmm + ws2_32 + gdiplus ) add_dependencies(${TARGET_NAME} util Data) diff --git a/src/OpenVario/CMakeSource.cmake b/src/OpenVario/CMakeSource.cmake index d21d223e7f6..9ef8945f804 100644 --- a/src/OpenVario/CMakeSource.cmake +++ b/src/OpenVario/CMakeSource.cmake @@ -1,20 +1,32 @@ set(_SOURCES OpenVario/OpenVarioMenu.cpp + + OpenVario/FileMenuWidget.cpp + OpenVario/System/System.cpp OpenVario/System/SystemMenuWidget.cpp OpenVario/System/SystemSettingsWidget.cpp - OpenVario/FileMenuWidget.cpp ${SRC}/Version.cpp ${SRC}/Asset.cpp + ${SRC}/Dialogs/DialogSettings.cpp + ${SRC}/Dialogs/WidgetDialog.cpp + ${SRC}/Dialogs/HelpDialog.cpp + ${SRC}/Dialogs/Message.cpp + ${SRC}/Dialogs/LockScreen.cpp + ${SRC}/Dialogs/TextEntry.cpp + ${SRC}/Dialogs/KnobTextEntry.cpp + ${SRC}/Dialogs/TouchTextEntry.cpp + ${SRC}/Form/DigitEntry.cpp ${SRC}/Formatter/HexColor.cpp ${SRC}/Formatter/TimeFormatter.cpp + ${SRC}/Gauge/LogoView.cpp ${SRC}/Hardware/CPU.cpp ${SRC}/Hardware/DisplayDPI.cpp ${SRC}/Hardware/RotateDisplay.cpp ${SRC}/Hardware/DisplayGlue.cpp - ${SRC}/Screen/Layout.cpp - ${SRC}/ui/control/TerminalWindow.cpp + ${SRC}/LogFile.cpp + ${SRC}/LocalPath.cpp ${SRC}/Look/TerminalLook.cpp ${SRC}/Look/DialogLook.cpp ${SRC}/Look/ButtonLook.cpp @@ -33,6 +45,27 @@ set(_SOURCES ${SRC}/Profile/File.cpp ${SRC}/Profile/NumericValue.cpp + ${SRC}/ProgressGlue.cpp + ${SRC}/ProgressWindow.cpp + + ${SRC}/Renderer/TwoTextRowsRenderer.cpp + ${SRC}/Screen/Layout.cpp + + ${SRC}/io/FileOutputStream.cxx + + ${SRC}/lib/fmt/SystemError.cxx + ${SRC}/Units/Descriptor.cpp + + ${SRC}/ResourceLoader.cpp + ${SRC}/ui/control/TerminalWindow.cpp + ${SRC}/ui/canvas/gdi/Canvas.cpp + ${SRC}/ui/canvas/gdi/Bitmap.cpp + ${SRC}/ui/canvas/gdi/GdiPlusBitmap.cpp + ${SRC}/ui/canvas/gdi/ResourceBitmap.cpp + + ${SRC}/Interface.cpp + ${SRC}/Blackboard/InterfaceBlackboard.cpp + ${SRC}/MainWindow.cpp ) set(SCRIPT_FILES From 7c246b80bd29fd4cd23293c99e1ba2f224b324f0 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sat, 6 Jan 2024 10:26:36 +0100 Subject: [PATCH 083/403] [build] ov.mk - add OpenVario/System/Setting/(XXX)Widget(s).cpp --- build/ov.mk | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build/ov.mk b/build/ov.mk index eb0bbd5023d..29498161059 100644 --- a/build/ov.mk +++ b/build/ov.mk @@ -35,6 +35,13 @@ OV_MENU_SOURCES = \ $(SRC)/OpenVario/System/System.cpp\ $(SRC)/OpenVario/System/SystemMenuWidget.cpp\ $(SRC)/OpenVario/System/SystemSettingsWidget.cpp\ + $(SRC)/OpenVario/System/Setting/RotationWidget.cpp\ + $(SRC)/OpenVario/System/Setting/BrightnessWidget.cpp\ + $(SRC)/OpenVario/System/Setting/TimeoutWidget.cpp\ + $(SRC)/OpenVario/System/Setting/SSHWidget.cpp\ + $(SRC)/OpenVario/System/Setting/VariodWidget.cpp\ + $(SRC)/OpenVario/System/Setting/SensordWidget.cpp\ + $(SRC)/OpenVario/System/Setting/WifiWidget.cpp\ $(SRC)/OpenVario/OpenVarioMenu.cpp OV_MENU_DEPENDS = WIDGET FORM DATA_FIELD SCREEN EVENT RESOURCE ASYNC LIBNET OS IO THREAD TIME MATH UTIL OV_MENU_STRIP = y From d99f9178b8304837f3039cc3ff0f1d8984dcd41f Mon Sep 17 00:00:00 2001 From: August2111 Date: Sat, 6 Jan 2024 11:28:20 +0100 Subject: [PATCH 084/403] [build] ov.mk - reorder file layout --- build/ov.mk | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/build/ov.mk b/build/ov.mk index 29498161059..cceb47cf365 100644 --- a/build/ov.mk +++ b/build/ov.mk @@ -1,4 +1,17 @@ OV_MENU_SOURCES = \ + $(SRC)/OpenVario/OpenVarioMenu.cpp \ + $(SRC)/OpenVario/System/System.cpp \ + $(SRC)/OpenVario/FileMenuWidget.cpp \ + $(SRC)/OpenVario/System/SystemMenuWidget.cpp \ + $(SRC)/OpenVario/System/SystemSettingsWidget.cpp \ + $(SRC)/OpenVario/System/Setting/RotationWidget.cpp \ + $(SRC)/OpenVario/System/Setting/BrightnessWidget.cpp \ + $(SRC)/OpenVario/System/Setting/TimeoutWidget.cpp \ + $(SRC)/OpenVario/System/Setting/SSHWidget.cpp \ + $(SRC)/OpenVario/System/Setting/VariodWidget.cpp \ + $(SRC)/OpenVario/System/Setting/SensordWidget.cpp \ + $(SRC)/OpenVario/System/Setting/WifiWidget.cpp \ + \ $(SRC)/Version.cpp \ $(SRC)/Asset.cpp \ $(SRC)/Formatter/HexColor.cpp \ @@ -30,19 +43,7 @@ OV_MENU_SOURCES = \ $(TEST_SRC_DIR)/Fonts.cpp \ $(TEST_SRC_DIR)/FakeLanguage.cpp \ $(TEST_SRC_DIR)/FakeLogFile.cpp \ - $(SRC)/Kobo/FakeSymbols.cpp \ - $(SRC)/OpenVario/FileMenuWidget.cpp\ - $(SRC)/OpenVario/System/System.cpp\ - $(SRC)/OpenVario/System/SystemMenuWidget.cpp\ - $(SRC)/OpenVario/System/SystemSettingsWidget.cpp\ - $(SRC)/OpenVario/System/Setting/RotationWidget.cpp\ - $(SRC)/OpenVario/System/Setting/BrightnessWidget.cpp\ - $(SRC)/OpenVario/System/Setting/TimeoutWidget.cpp\ - $(SRC)/OpenVario/System/Setting/SSHWidget.cpp\ - $(SRC)/OpenVario/System/Setting/VariodWidget.cpp\ - $(SRC)/OpenVario/System/Setting/SensordWidget.cpp\ - $(SRC)/OpenVario/System/Setting/WifiWidget.cpp\ - $(SRC)/OpenVario/OpenVarioMenu.cpp + $(SRC)/Kobo/FakeSymbols.cpp OV_MENU_DEPENDS = WIDGET FORM DATA_FIELD SCREEN EVENT RESOURCE ASYNC LIBNET OS IO THREAD TIME MATH UTIL OV_MENU_STRIP = y From 5988f7347e352f9fd08bb4952c54eaed4da03833 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sat, 6 Jan 2024 11:31:57 +0100 Subject: [PATCH 085/403] [CMake] update for WIN32 (f.e. FakeLanguage.cpp instead of Language.lib) --- src/OpenVario/CMakeLists.txt | 2 +- src/OpenVario/CMakeSource.cmake | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/OpenVario/CMakeLists.txt b/src/OpenVario/CMakeLists.txt index ebbded2415d..4d1097400c8 100644 --- a/src/OpenVario/CMakeLists.txt +++ b/src/OpenVario/CMakeLists.txt @@ -52,7 +52,7 @@ target_link_libraries(${TARGET_NAME} PUBLIC Logger) # message(FATAL_ERROR "Stop!") set_target_properties(${TARGET_NAME} PROPERTIES FOLDER OpenVario) -target_link_libraries(${TARGET_NAME} PUBLIC Math Language Profile net co Blackboard util system io +target_link_libraries(${TARGET_NAME} PUBLIC Math Profile net co Blackboard util system io # Language ui Dialogs Look Widget Renderer MapWindow ${FMT_LIB} ${CURL_TARGET} ${CARES_TARGET} ${ZLIB_TARGET} ${SODIUM_TARGET} # new at 06/2020 diff --git a/src/OpenVario/CMakeSource.cmake b/src/OpenVario/CMakeSource.cmake index 9ef8945f804..68d42f950ad 100644 --- a/src/OpenVario/CMakeSource.cmake +++ b/src/OpenVario/CMakeSource.cmake @@ -1,3 +1,5 @@ +set(TEST_SRC_DIR "${PROJECTGROUP_SOURCE_DIR}/test/src") + set(_SOURCES OpenVario/OpenVarioMenu.cpp @@ -25,7 +27,8 @@ set(_SOURCES ${SRC}/Hardware/DisplayDPI.cpp ${SRC}/Hardware/RotateDisplay.cpp ${SRC}/Hardware/DisplayGlue.cpp - ${SRC}/LogFile.cpp +# FakeLogFile ${SRC}/LogFile.cpp + ${TEST_SRC_DIR}/FakeLogFile.cpp ${SRC}/LocalPath.cpp ${SRC}/Look/TerminalLook.cpp ${SRC}/Look/DialogLook.cpp @@ -65,7 +68,11 @@ set(_SOURCES ${SRC}/Interface.cpp ${SRC}/Blackboard/InterfaceBlackboard.cpp - ${SRC}/MainWindow.cpp + ${TEST_SRC_DIR}/Fonts.cpp + ${TEST_SRC_DIR}/FakeLanguage.cpp + ${SRC}/Kobo/FakeSymbols.cpp + +## ${SRC}/MainWindow.cpp ) set(SCRIPT_FILES From b52ee41573659278c07b061a445adf72dd7d5ac3 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sun, 7 Jan 2024 17:41:16 +0100 Subject: [PATCH 086/403] OpenVarioBaseMenu - renamed from OpenVarioMenu, make it possible to compile... and debug for WIN64, MSVC, CMake... --- OpenSoar-News.md | 2 +- src/Dialogs/ProcessDialog.cpp | 40 ++++++- .../Settings/Panels/OpenVarioConfigPanel.cpp | 52 ++++++++- src/Hardware/DisplayGlue.cpp | 3 +- ...penVarioMenu.cpp => OpenVarioBaseMenu.cpp} | 108 ++++++++++-------- src/OpenVario/System/System.cpp | 34 +++++- src/OpenVario/System/System.hpp | 18 +++ src/OpenVario/System/SystemSettingsWidget.cpp | 5 + src/Profile/Profile.cpp | 2 + src/event/PipeEvent.hxx | 23 +++- src/ui/event/poll/InputQueue.hpp | 12 ++ src/ui/event/shared/Event.hpp | 4 +- 12 files changed, 238 insertions(+), 65 deletions(-) rename src/OpenVario/{OpenVarioMenu.cpp => OpenVarioBaseMenu.cpp} (80%) diff --git a/OpenSoar-News.md b/OpenSoar-News.md index d01777c5581..14a4ea67b90 100644 --- a/OpenSoar-News.md +++ b/OpenSoar-News.md @@ -1,6 +1,6 @@ OpenSoar Version 7.41.21.1 - not yet released --------------- -* start with OpenVarioMenu +* start with OpenVarioBaseMenu OpenSoar Version 7.41.21 - 2023/12/28 --------------- diff --git a/src/Dialogs/ProcessDialog.cpp b/src/Dialogs/ProcessDialog.cpp index 6484c1e4f28..5229744a20c 100644 --- a/src/Dialogs/ProcessDialog.cpp +++ b/src/Dialogs/ProcessDialog.cpp @@ -6,8 +6,8 @@ #include "Widget/LargeTextWidget.hpp" #include "ui/event/poll/Queue.hpp" #include "ui/event/Globals.hpp" -#include "Language/Language.hpp" #include "event/PipeEvent.hxx" +#include "Language/Language.hpp" #include "io/Open.hxx" #include "io/UniqueFileDescriptor.hxx" #include "system/Error.hxx" @@ -17,7 +17,13 @@ #include #include #include +#ifdef _WIN32 + // TODO(August2111): needs work! +#include "util/ConvertString.hpp" +typedef size_t pid_t; +#else #include +#endif class ProcessWidget final : public LargeTextWidget { const char *const*const argv; @@ -63,9 +69,14 @@ class ProcessWidget final : public LargeTextWidget { static bool UnblockAllSignals() noexcept { +#ifdef _WIN32 + // TODO(August2111): needs work! + return false; +#else sigset_t ss; sigemptyset(&ss); return sigprocmask(SIG_SETMASK, &ss, nullptr) == 0; +#endif } void @@ -77,6 +88,10 @@ ProcessWidget::Start() if (!UniqueFileDescriptor::CreatePipe(r, w)) throw MakeErrno("Failed to create pipe"); +#ifdef _WIN32 + // TODO(August2111): needs work! +#else + pid = fork(); if (pid < 0) throw MakeErrno("Failed to fork"); @@ -92,6 +107,7 @@ ProcessWidget::Start() fprintf(stderr, "Failed to execute %s: %s\n", argv[0], strerror(errno)); _exit(EXIT_FAILURE); } +#endif fd.Open(r.Release()); fd.ScheduleRead(); @@ -102,12 +118,16 @@ ProcessWidget::Cancel() noexcept { fd.Close(); +#ifdef _WIN32 + // TODO(August2111): needs work! +#else if (pid > 0) { kill(pid, SIGTERM); int status; waitpid(pid, &status, 0); } +#endif } bool @@ -138,7 +158,11 @@ ProcessWidget::OnPipeReady(unsigned) noexcept return; text.append("\nFailed to read from pipe"); +#ifdef _WIN32 + SetText(ConvertACPToWide(text.c_str()).c_str()); +#else SetText(text.c_str()); +#endif cancel_button->SetCaption(_("Close")); @@ -151,6 +175,10 @@ ProcessWidget::OnPipeReady(unsigned) noexcept fd.Close(); int status; +#ifdef _WIN32 + // TODO(August2111): needs work! + status = 0; +#else if (waitpid(pid, &status, 0) == pid) { pid = 0; @@ -160,7 +188,7 @@ ProcessWidget::OnPipeReady(unsigned) noexcept status = EXIT_FAILURE; } else status = EXIT_FAILURE; - +#endif if (OnExit(status)) return; @@ -175,7 +203,11 @@ ProcessWidget::OnPipeReady(unsigned) noexcept if (text.length() > 16384) text.erase(0, 4096); +#ifdef _WIN32 + SetText(ConvertACPToWide(text.c_str()).c_str()); +#else SetText(text.c_str()); +#endif // make sure the EventLoop gets interrupted so the UI gets redrawn UI::event_queue->Interrupt(); } @@ -189,7 +221,11 @@ ProcessWidget::Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept Start(); } catch (...) { text = GetFullMessage(std::current_exception()); +#ifdef _WIN32 + SetText(ConvertACPToWide(text.c_str()).c_str()); +#else SetText(text.c_str()); +#endif } } diff --git a/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp b/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp index 8abe91a4ee0..e189efad4be 100644 --- a/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp @@ -12,9 +12,25 @@ #include "Interface.hpp" #include "UIGlobals.hpp" +#include "Dialogs/Message.hpp" + + #include + +bool bTest = true; +unsigned iTest = 0; +unsigned iBrightness = 80; + // #define HAVE_WEGLIDE_PILOTNAME +enum ControlIndex { + OVFirmware, + OVBooleanTest, + OVIntegerTest, + OVBrightness, + OVButtonShell, +}; + class OpenVarioConfigPanel final : public RowFormWidget, DataFieldListener { @@ -42,6 +58,9 @@ OpenVarioConfigPanel::SetEnabled([[maybe_unused]] bool enabled) noexcept SetRowEnabled(WeGlidePilotBirthDate, enabled); SetRowEnabled(WeGlidePilotID, enabled); #endif + // this disabled itself: SetRowEnabled(OVBooleanTest, enabled); + SetRowEnabled(OVIntegerTest, enabled); + SetRowEnabled(OVBrightness, enabled); } void @@ -54,6 +73,10 @@ OpenVarioConfigPanel::OnModified([[maybe_unused]] DataField &df) noexcept SetEnabled(dfb.GetValue()); } #endif + if (IsDataField(OVBooleanTest, df)) { + const DataFieldBoolean &dfb = (const DataFieldBoolean &)df; + SetEnabled(dfb.GetValue()); + } } void @@ -64,11 +87,8 @@ OpenVarioConfigPanel::Prepare(ContainerWindow &parent, RowFormWidget::Prepare(parent, rc); - bool bTest = false; - unsigned iTest = 0; - // void AddReadOnly(label, help,text; - auto version = _("3.2.20"); + auto version = _T("3.2.20"); AddReadOnly(_("OV-Firmware-Version"), _("Current firmware version of OpenVario"), version); AddBoolean( _("Boolean Test"), @@ -79,15 +99,27 @@ OpenVarioConfigPanel::Prepare(ContainerWindow &parent, _("Integer Test."), _T("%d"), _T("%d"), 1, 99999, 1, iTest); + AddInteger(_("Brightness Test"), + _("Brightness ???."), _T("%d"), _T("%d%%"), 10, + 100, 10, iBrightness); + + auto Btn_Shell = AddButton( + _T("Shell"), [this]() { + // dialog.SetModalResult(mrOK); + ShowMessageBox(_("Button pressed"), _("OV-Button"), + MB_OK | MB_ICONERROR); + }); + + SetEnabled(bTest); } bool OpenVarioConfigPanel::Save([[maybe_unused]] bool &_changed) noexcept { + bool changed = false; #ifdef OPENVARIO_CONFIG // out commented currently: - bool changed = false; auto &weglide = CommonInterface::SetComputerSettings().weglide; @@ -105,9 +137,17 @@ OpenVarioConfigPanel::Save([[maybe_unused]] bool &_changed) noexcept changed |= SaveValue(WeGlideEnabled, ProfileKeys::WeGlideEnabled, weglide.enabled); - _changed |= changed; #endif + changed |= SaveValue(OVBooleanTest, "OVBooleanTest", + bTest); + + changed |= SaveValueInteger(OVIntegerTest, "OVIntegerTest", + iTest); + + changed |= SaveValueInteger(OVBrightness, "OVBrightness", iBrightness); + + _changed |= changed; return true; } diff --git a/src/Hardware/DisplayGlue.cpp b/src/Hardware/DisplayGlue.cpp index 375e6ecf4e2..0858c835c8c 100644 --- a/src/Hardware/DisplayGlue.cpp +++ b/src/Hardware/DisplayGlue.cpp @@ -45,8 +45,9 @@ Display::LoadOrientation(VerboseOperationEnvironment &env) LogString("Display rotated"); +#ifndef OPENVARIO_DEVICE // remove this after OpenVarioBaseMenu is ready CommonInterface::main_window->Initialise(); - +#endif /* force the progress dialog to update its layout */ env.UpdateLayout(); } diff --git a/src/OpenVario/OpenVarioMenu.cpp b/src/OpenVario/OpenVarioBaseMenu.cpp similarity index 80% rename from src/OpenVario/OpenVarioMenu.cpp rename to src/OpenVario/OpenVarioBaseMenu.cpp index f0ce78ac84f..692d99685f3 100644 --- a/src/OpenVario/OpenVarioMenu.cpp +++ b/src/OpenVario/OpenVarioBaseMenu.cpp @@ -22,6 +22,7 @@ #include "system/Process.hpp" // #include "util/ScopeExit.hxx" #include "system/FileUtil.hpp" +#include "Profile/Profile.hpp" #include "Profile/File.hpp" #include "Profile/Map.hpp" #include "DisplayOrientation.hpp" @@ -34,18 +35,18 @@ #include "OpenVario/FileMenuWidget.h" #include "OpenVario/System/SystemMenuWidget.hpp" + +#include "Form/DataField/Listener.hpp" +#include "Dialogs/Settings/Panels/OpenVarioConfigPanel.hpp" +#include "LocalPath.hpp" + #include #include #include #include #include - -#include "boost/filesystem/operations.hpp" -#include "boost/filesystem/path.hpp" - -// #include "System/System.cpp" - +#include "util/ConvertString.hpp" bool IsOpenVarioDevice = true; @@ -53,30 +54,6 @@ static DialogSettings dialog_settings; static UI::SingleWindow *global_main_window; static DialogLook *global_dialog_look; - -// #ifdef OPENVARIO_DEVICE // remove this after OpenVarioMenu is ready -// Path ConfigFile(_T("/boot/config.uEnv")); -// #endif - -// #ifndef OPENVARIO_DEVICE // remove this after OpenVarioMenu is ready -// -// template -// static void ChangeConfigString(const std::string &keyvalue, T value, -// const std::string &path) { -// const Path ConfigPath(path.c_str()); -// -// ProfileMap configuration; -// -// try { -// Profile::LoadFile(configuration, ConfigPath); -// } catch (std::exception &e) { -// Profile::SaveFile(configuration, ConfigPath); -// } -// configuration.Set(keyvalue.c_str(), value); -// Profile::SaveFile(configuration, ConfigPath); -// } -// #else - const DialogSettings & UIGlobals::GetDialogSettings() { @@ -110,6 +87,7 @@ class MainMenuWidget final OPENSOAR, XCSOAR, FILE, + TEST, SYSTEM, READONLY_1, SHELL, @@ -127,8 +105,7 @@ class MainMenuWidget final UI::Timer timer{[this](){ if (--remaining_seconds == 0) { HideRow(Controls::TIMER); - StartOpenSoar(); - // StartXCSoar(); + StartOpenSoar(); // StartXCSoar(); } else { ScheduleTimer(); } @@ -148,18 +125,10 @@ class MainMenuWidget final const UI::ScopeDropMaster drop_master{display}; const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; #ifdef _WIN32 - // namespace fs = ; - - boost::filesystem::path ExePathBoost(boost::filesystem::initial_path()); - // std::cout << ExePath.native_file_string() << endl; std::filesystem::path ExePath(std::filesystem::current_path()); ExePath.append("OpenSoar.exe"); ExePath = "D:/Projects/Binaries/OpenSoar/dev-branch/msvc2022/Release/" "OpenSoar.exe"; -// for (unsigned int i = 0; i < 2; i++) { -// auto arg = args[i]; -// printf(arg); -// } char buf[0x200]; snprintf(buf, sizeof(buf) - 1, "%s -fly -datapath=%s -profile=%s", @@ -169,7 +138,6 @@ class MainMenuWidget final ); Run(buf); - // , "-datapath=/home/root/data/OpenSoarData"); #else if (File::Exists(Path(_T("/usr/bin/OpenSoar")))) Run("/usr/bin/OpenSoar", "-fly", "-datapath=/home/root/data/OpenSoarData"); @@ -213,8 +181,7 @@ class MainMenuWidget final } else { HideRow(Controls::TIMER); - StartOpenSoar(); - // StartXCSoar(); + StartOpenSoar(); // StartXCSoar(); } } @@ -236,6 +203,21 @@ class MainMenuWidget final } }; +class OpenVarioConfigPanel final : public RowFormWidget, DataFieldListener { +public: + OpenVarioConfigPanel() noexcept : RowFormWidget(UIGlobals::GetDialogLook()) {} + + void SetEnabled(bool enabled) noexcept; + + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept override; + bool Save(bool &changed) noexcept override; + +private: + /* methods from DataFieldListener */ + void OnModified(DataField &df) noexcept override; +}; + void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { @@ -264,6 +246,23 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, sub_dialog.AddButton(_("Close"), mrOK); return sub_dialog.ShowModal(); }); + + AddButton(_("Test"), [this]() { + CancelTimer(); + std::unique_ptr widget = CreateOpenVarioConfigPanel(); + Profile::LoadFile(ovdevice.GetConfigFile()); + TWidgetDialog sub_dialog( + WidgetDialog::Full{}, dialog.GetMainWindow(), GetLook(), + _T("OpenVario Test")); + sub_dialog.SetWidget(); + sub_dialog.AddButton(_("Close"), mrOK); + auto ret_value = sub_dialog.ShowModal(); + + if (sub_dialog.GetChanged()) { + Profile::SaveFile(ovdevice.GetConfigFile()); + } + return ret_value; + }); AddButton(_("System"), [this]() { CancelTimer(); @@ -295,7 +294,6 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, } HideRow(Controls::OPENSOAR_CLUB); } -// #endif // OPENVARIO_DEVICE // remove this after OpenVarioMenu is ready static int Main(UI::EventQueue &event_queue, UI::SingleWindow &main_window, @@ -303,7 +301,7 @@ Main(UI::EventQueue &event_queue, UI::SingleWindow &main_window, { TWidgetDialog dialog(WidgetDialog::Full{}, main_window, - dialog_look, _T("OpenVario")); + dialog_look, _T("OpenVario Base Menu")); dialog.SetWidget(main_window.GetDisplay(), event_queue, dialog); return dialog.ShowModal(); @@ -333,6 +331,8 @@ debugln(const char *fmt, ...) noexcept static int Main() { + InitialiseDataPath(); + IsOpenVarioDevice = File::Exists(ConfigFile); dialog_settings.SetDefaults(); @@ -353,7 +353,7 @@ Main() #endif UI::SingleWindow main_window{screen_init.GetDisplay()}; - main_window.Create(_T("XCSoar/OpenVarioMenu"), {600, 800}, main_style); + main_window.Create(_T("OpenSoar/OpenVarioBaseMenu"), {600, 800}, main_style); main_window.Show(); global_dialog_look = &dialog_look; @@ -362,15 +362,22 @@ Main() if (!IsOpenVarioDevice) { StaticString<0x100> Home; Home.SetUTF8(getenv("HOME")); + auto HomePath = Path(Home); // Home = _T("/home/august2111"); debugln("HOME(1) = %s", getenv("HOME")); - debugln("HOME(2) = %s", Home.c_str()); + debugln("HOME(2) = %s", ConvertWideToACP(Home.c_str()).c_str()); + debugln("HOME(3) = %s", ConvertWideToACP(HomePath.c_str()).c_str()); ConfigFile = Path(_T("./config.uEnv")); - // AllocatedPath::Build(Path(Home), Path(_T("/config.uEnv"))); - // AllocatedPath::Build(Path(_T("/home/august2111")), Path(_T("/config.uEnv"))); + debugln("ConfigFile: %s", ConvertWideToACP(ConfigFile.c_str()).c_str()); + // AllocatedPath::Build(Path(Home), Path(_T("/config.uEnv"))); + auto ConfigFile2 = + AllocatedPath::Build(Path(Home), Path(_T("config.uEnv"))); // AllocatedPath::Build(Path(), Path(_T("/config.uEnv"))); - debugln("ConfigFile: %s", ConfigFile.c_str()); + debugln("ConfigFile: %s", ConvertWideToACP(ConfigFile2.c_str()).c_str()); + debugln("ConfigFile: %s", + ConvertWideToACP(ovdevice.GetConfigFile().c_str()).c_str()); + // debugln("ConfigFile: %s", ConvertWideToACP(path.c_str()).c_str()); // #endif if (!File::Exists(ConfigFile)) { debugln("ConfigFile does not exist", ConfigFile.c_str()); @@ -385,6 +392,7 @@ Main() main_window.Destroy(); // DeinitialiseFonts(); + DeinitialiseDataPath(); return action; } diff --git a/src/OpenVario/System/System.cpp b/src/OpenVario/System/System.cpp index 945ddc8ee54..4b2605c46a6 100644 --- a/src/OpenVario/System/System.cpp +++ b/src/OpenVario/System/System.cpp @@ -20,6 +20,9 @@ #include "Profile/File.hpp" #include "Profile/Map.hpp" +#include "util/StaticString.hxx" +#include "util/ConvertString.hpp" + #include "OpenVario/System/System.hpp" #ifndef _WIN32 @@ -41,7 +44,36 @@ #include Path ConfigFile(_T("/boot/config.uEnv")); -//---------------------------------------------------------- + + +// Path OpenVarioDevice::ConfigFile; +OpenVarioDevice ovdevice; + +OpenVarioDevice::OpenVarioDevice() { + StaticString<0x100> home; + home.SetUTF8(getenv("HOME")); + HomePath = Path(home); +#ifdef _WIN32 +// DataPath = Path(_T("D:/Data/OpenSoarData")); +// DataPath = Path(_T("D:/Data/XCSoarData")); + DataPath = Path(_T("D:\\Data\\XCSoarData")); + + if (Directory::Exists(DataPath)) { + auto config = AllocatedPath::Build(DataPath, Path(_T("openvario.cfg"))); + ConfigFile = AllocatedPath::Build(DataPath, Path(_T("openvario.cfg"))); + } else { + ConfigFile = AllocatedPath::Build(HomePath, Path(_T("openvario.cfg"))); + } +#else + if (Directory::Exists(Path(_T("/boot/config.uEnv")))) { + ConfigFile = AllocatedPath::Build(Path(_T("/boot/config.uEnv")), + Path(_T("openvario.cfg"))); + } else { + ConfigFile = AllocatedPath::Build(HomePath, Path(_T("openvario.cfg"))); + } +#endif +} + //---------------------------------------------------------- void LoadConfigFile(std::map> &map, Path path) { diff --git a/src/OpenVario/System/System.hpp b/src/OpenVario/System/System.hpp index c7db819cdff..61fb66c5a4e 100644 --- a/src/OpenVario/System/System.hpp +++ b/src/OpenVario/System/System.hpp @@ -17,6 +17,24 @@ // constexpr const Path ConfigFile(_T("/boot/config.uEnv")); extern Path ConfigFile; +class OpenVarioDevice { +public: + OpenVarioDevice(); + Path GetConfigFile() noexcept + { + return ConfigFile; + } + Path SetConfigFile(Path _ConfigFile) noexcept + { + ConfigFile = _ConfigFile; + } + +private: + AllocatedPath ConfigFile; + AllocatedPath HomePath; + AllocatedPath DataPath; +}; +extern OpenVarioDevice ovdevice; #if !defined(_WIN32) && 1 # define DBUS_FUNCTIONS 1 diff --git a/src/OpenVario/System/SystemSettingsWidget.cpp b/src/OpenVario/System/SystemSettingsWidget.cpp index 907bcf0db93..ba01cbe193f 100644 --- a/src/OpenVario/System/SystemSettingsWidget.cpp +++ b/src/OpenVario/System/SystemSettingsWidget.cpp @@ -452,6 +452,11 @@ SystemSettingsWidget::Prepare([[maybe_unused]] ContainerWindow &parent, return sub_dialog.ShowModal(); }); + uint32_t iTest = 0; + AddInteger(_("Brightness Test"), _("Setting Brightness."), _T("%d"), _T("%d"), 1, + 10, 1, iTest); + + AddButton(_("Autostart Timeout"), [this](){ TWidgetDialog sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), diff --git a/src/Profile/Profile.cpp b/src/Profile/Profile.cpp index 2d9dbdf6ad2..faf041a1ef2 100644 --- a/src/Profile/Profile.cpp +++ b/src/Profile/Profile.cpp @@ -32,6 +32,8 @@ Profile::GetPath() noexcept void Profile::Load() noexcept { + if (startProfileFile == nullptr) + SetFiles(nullptr); assert(startProfileFile != nullptr); LogString("Loading profiles"); diff --git a/src/event/PipeEvent.hxx b/src/event/PipeEvent.hxx index 1df423f5517..a33e6adefa6 100644 --- a/src/event/PipeEvent.hxx +++ b/src/event/PipeEvent.hxx @@ -20,9 +20,13 @@ public: template PipeEvent(EventLoop &event_loop, C callback, FileDescriptor fd=FileDescriptor::Undefined()) noexcept - :event(event_loop, callback, +#ifdef _WIN32 + // TODO(August2111): needs work! + : event(event_loop, callback, SocketDescriptor()){} +#else + : event(event_loop, callback, SocketDescriptor::FromFileDescriptor(fd)) {} - +#endif EventLoop &GetEventLoop() const noexcept { return event.GetEventLoop(); } @@ -31,7 +35,21 @@ public: return event.IsDefined(); } +#ifdef _WIN32 + // TODO(August2111): needs work! FileDescriptor GetFileDescriptor() const noexcept { + return FileDescriptor(); + } + + FileDescriptor ReleaseFileDescriptor() noexcept { + return FileDescriptor(); + } + + void Open([[maybe_unused]] FileDescriptor fd) noexcept { + // event.Open(SocketDescriptor::FromFileDescriptor(fd)); + } +#else + FileDescriptor GetFileDescriptor() const noexcept { return event.GetSocket().ToFileDescriptor(); } @@ -42,6 +60,7 @@ public: void Open(FileDescriptor fd) noexcept { event.Open(SocketDescriptor::FromFileDescriptor(fd)); } + #endif void Close() noexcept { event.Close(); diff --git a/src/ui/event/poll/InputQueue.hpp b/src/ui/event/poll/InputQueue.hpp index 9946f387984..4c215579e61 100644 --- a/src/ui/event/poll/InputQueue.hpp +++ b/src/ui/event/poll/InputQueue.hpp @@ -37,6 +37,8 @@ class InputEventQueue final { void SetScreenSize(PixelSize screen_size) noexcept { #ifdef USE_LIBINPUT libinput_handler.SetScreenSize(screen_size); + #elif defined(_WIN32) + // TODO(August2111): needs work? #else merge_mouse.SetScreenSize(screen_size); #endif @@ -44,13 +46,20 @@ class InputEventQueue final { #ifndef USE_LIBINPUT void SetDisplayOrientation(DisplayOrientation orientation) { +#if defined(_WIN32) + // TODO(August2111): needs work? +#else merge_mouse.SetDisplayOrientation(orientation); +#endif } #endif bool HasPointer() const noexcept { #ifdef USE_LIBINPUT return libinput_handler.HasPointer(); +#elif defined(_WIN32) + // TODO(August2111): needs work? + return false; #else return merge_mouse.HasPointer(); #endif @@ -69,6 +78,9 @@ class InputEventQueue final { PixelPoint GetMousePosition() const noexcept { #ifdef USE_LIBINPUT return PixelPoint(libinput_handler.GetX(), libinput_handler.GetY()); +#elif defined(_WIN32) + // TODO(August2111): needs work? + return PixelPoint(0, 0); #else return merge_mouse.GetPosition(); #endif diff --git a/src/ui/event/shared/Event.hpp b/src/ui/event/shared/Event.hpp index b3ec87cae33..8a9d4b387f2 100644 --- a/src/ui/event/shared/Event.hpp +++ b/src/ui/event/shared/Event.hpp @@ -19,7 +19,7 @@ struct Event { TIMER, #endif - CALLBACK, + CALLBACK_, KEY_DOWN, KEY_UP, @@ -111,7 +111,7 @@ struct Event { :type(_type), param(_param), ptr(_ptr) {} Event(Type _type, void *_ptr):type(_type), ptr(_ptr) {} Event(Callback _callback, void *_ptr) - :type(CALLBACK), ptr(_ptr), callback(_callback) {} + :type(CALLBACK_), ptr(_ptr), callback(_callback) {} Event(Type _type, PixelPoint _point) :type(_type), point(_point) {} From b30a5f1ebdbced83b87e1329b50d440616462559 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sun, 7 Jan 2024 17:57:58 +0100 Subject: [PATCH 087/403] [build] ov.mk - build OpenVarioBaseMenu for OpenVarioMenu --- build/ov.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/ov.mk b/build/ov.mk index cceb47cf365..8bae141514c 100644 --- a/build/ov.mk +++ b/build/ov.mk @@ -1,5 +1,5 @@ OV_MENU_SOURCES = \ - $(SRC)/OpenVario/OpenVarioMenu.cpp \ + $(SRC)/OpenVario/OpenVarioBaseMenu.cpp \ $(SRC)/OpenVario/System/System.cpp \ $(SRC)/OpenVario/FileMenuWidget.cpp \ $(SRC)/OpenVario/System/SystemMenuWidget.cpp \ @@ -47,7 +47,7 @@ OV_MENU_SOURCES = \ OV_MENU_DEPENDS = WIDGET FORM DATA_FIELD SCREEN EVENT RESOURCE ASYNC LIBNET OS IO THREAD TIME MATH UTIL OV_MENU_STRIP = y -$(eval $(call link-program,OpenVarioMenu,OV_MENU)) +$(eval $(call link-program,OpenVarioBaseMenu,OV_MENU)) ifeq ($(TARGET),UNIX) OPTIONAL_OUTPUTS += $(OV_MENU_BIN) From d176d93fa73bc6dac8613df4f3048fdace2fc476 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sun, 7 Jan 2024 17:58:49 +0100 Subject: [PATCH 088/403] [CMake] build OpenVarioBaseMenu for OpenVarioMenu --- build/cmake/WinMSVC.cmake | 1 + src/OpenVario/CMakeLists.txt | 27 +++++-------- src/OpenVario/CMakeSource.cmake | 71 +++++++++++++++++++++------------ 3 files changed, 56 insertions(+), 43 deletions(-) diff --git a/build/cmake/WinMSVC.cmake b/build/cmake/WinMSVC.cmake index 1deb3d468bc..04e6cfbd373 100644 --- a/build/cmake/WinMSVC.cmake +++ b/build/cmake/WinMSVC.cmake @@ -6,6 +6,7 @@ set(LIB_SUFFIX ".lib") # "a") # only in DEBUG-Version--- #add_definitions(-DIS_OPENVARIO) # add special OpenVario functions +add_compile_definitions(IS_OPENVARIO) # add special OpenVario functions #------------------------------- add_compile_definitions(__MSVC__) #******************************************************************************** diff --git a/src/OpenVario/CMakeLists.txt b/src/OpenVario/CMakeLists.txt index 4d1097400c8..ad5cfd6f959 100644 --- a/src/OpenVario/CMakeLists.txt +++ b/src/OpenVario/CMakeLists.txt @@ -3,13 +3,15 @@ if (SHOW_SUBPROJECTS) message(STATUS "+++ Start CMake ${CMAKE_CURRENT_SOURCE_DIR}!") endif() - get_filename_component(TARGET_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME_WE) + get_filename_component(TARGET_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} NAME_WE) + set(TARGET_NAME OpenVarioBaseMenu) include(CMakeSource.cmake) # organize the files in subdirectories set(SOURCE_FILES ) foreach(source_file ${_SOURCES}) - string(REPLACE "${TARGET_NAME}/" "" source_file ${source_file}) + string(REPLACE "${TARGET_FOLDER}/" "" source_file ${source_file}) + string(REPLACE "${PROJECTGROUP_SOURCE_DIR}/" "../../" source_file ${source_file}) list(APPEND SOURCE_FILES ${source_file}) get_filename_component(src_path ${source_file} DIRECTORY) if (src_path) @@ -39,29 +41,20 @@ endif() include_directories(${CMAKE_CURRENT_SOURCE_DIR}) add_compile_definitions("OPENVARIO_DEVICE") +add_compile_definitions("IS_OPENVARIO") + +# add_compile_definitions("USE_LIBINPUT") # remeve this definition after -# add_library(${TARGET_NAME} ${XCSOAR_LIB_TYPE} add_executable(${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES} ${SCRIPT_FILES} ) -target_link_libraries(${TARGET_NAME} PUBLIC Logger) +## target_link_libraries(${TARGET_NAME} PUBLIC Logger) # message(FATAL_ERROR "Stop!") -set_target_properties(${TARGET_NAME} PROPERTIES FOLDER OpenVario) - -target_link_libraries(${TARGET_NAME} PUBLIC Math Profile net co Blackboard util system io # Language - ui Dialogs Look Widget Renderer MapWindow - ${FMT_LIB} ${CURL_TARGET} ${CARES_TARGET} ${ZLIB_TARGET} - ${SODIUM_TARGET} # new at 06/2020 - ${SSL_LIB} # new at 03/2021 - ${CRYPTO_LIB} # new at 03/2021 +set_target_properties(${TARGET_NAME} PROPERTIES FOLDER OpenVarioBaseMenu) - msimg32 - winmm - ws2_32 - gdiplus -) +target_link_libraries(${TARGET_NAME} PUBLIC ${OPENVARIOBASEMENU_LIBS}) add_dependencies(${TARGET_NAME} util Data) diff --git a/src/OpenVario/CMakeSource.cmake b/src/OpenVario/CMakeSource.cmake index 68d42f950ad..97e14d228bd 100644 --- a/src/OpenVario/CMakeSource.cmake +++ b/src/OpenVario/CMakeSource.cmake @@ -1,35 +1,26 @@ set(TEST_SRC_DIR "${PROJECTGROUP_SOURCE_DIR}/test/src") set(_SOURCES - OpenVario/OpenVarioMenu.cpp + OpenVario/OpenVarioBaseMenu.cpp + OpenVario/System/System.cpp OpenVario/FileMenuWidget.cpp - OpenVario/System/System.cpp OpenVario/System/SystemMenuWidget.cpp OpenVario/System/SystemSettingsWidget.cpp + ${SRC}/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp + ${SRC}/Version.cpp ${SRC}/Asset.cpp - ${SRC}/Dialogs/DialogSettings.cpp - ${SRC}/Dialogs/WidgetDialog.cpp - ${SRC}/Dialogs/HelpDialog.cpp - ${SRC}/Dialogs/Message.cpp - ${SRC}/Dialogs/LockScreen.cpp - ${SRC}/Dialogs/TextEntry.cpp - ${SRC}/Dialogs/KnobTextEntry.cpp - ${SRC}/Dialogs/TouchTextEntry.cpp - ${SRC}/Form/DigitEntry.cpp ${SRC}/Formatter/HexColor.cpp ${SRC}/Formatter/TimeFormatter.cpp - ${SRC}/Gauge/LogoView.cpp ${SRC}/Hardware/CPU.cpp ${SRC}/Hardware/DisplayDPI.cpp ${SRC}/Hardware/RotateDisplay.cpp ${SRC}/Hardware/DisplayGlue.cpp -# FakeLogFile ${SRC}/LogFile.cpp - ${TEST_SRC_DIR}/FakeLogFile.cpp - ${SRC}/LocalPath.cpp + ${SRC}/Screen/Layout.cpp + ${SRC}/ui/control/TerminalWindow.cpp ${SRC}/Look/TerminalLook.cpp ${SRC}/Look/DialogLook.cpp ${SRC}/Look/ButtonLook.cpp @@ -47,12 +38,49 @@ set(_SOURCES ${SRC}/Profile/Map.cpp ${SRC}/Profile/File.cpp ${SRC}/Profile/NumericValue.cpp + ${TEST_SRC_DIR}/Fonts.cpp + ${TEST_SRC_DIR}/FakeLanguage.cpp + ${TEST_SRC_DIR}/FakeLogFile.cpp + # ${SRC}/Kobo/FakeSymbols.cpp + ${SRC}/Dialogs/DataField.cpp +) + +set(OPENVARIOBASEMENU_LIBS +# ov.mk: OV_MENU_DEPENDS = WIDGET FORM DATA_FIELD SCREEN EVENT RESOURCE ASYNC LIBNET OS IO THREAD TIME MATH UTIL +# ov.mk: OV_MENU_STRIP = y + Profile Widget Form Renderer ui event net system io thread time Math util + co Blackboard # Language + Dialogs Look MapWindow + + ${FMT_LIB} ${CURL_TARGET} ${CARES_TARGET} ${ZLIB_TARGET} + ${SODIUM_TARGET} # new at 06/2020 + ${SSL_LIB} # new at 03/2021 + ${CRYPTO_LIB} # new at 03/2021 +) + +# Win32! +if(WIN32) + list(APPEND _SOURCES + ${SRC}/ui/canvas/gdi/Canvas.cpp + ${SRC}/ui/canvas/gdi/Bitmap.cpp + ${SRC}/ui/canvas/gdi/GdiPlusBitmap.cpp + ${SRC}/ui/canvas/gdi/ResourceBitmap.cpp + ) + list(APPEND OPENVARIOBASEMENU_LIBS + msimg32 + winmm + ws2_32 + gdiplus + ) +endif() +list(APPEND _SOURCES +# FakeLogFile ${SRC}/LogFile.cpp + ${SRC}/LocalPath.cpp ${SRC}/ProgressGlue.cpp ${SRC}/ProgressWindow.cpp - ${SRC}/Renderer/TwoTextRowsRenderer.cpp - ${SRC}/Screen/Layout.cpp + ${SRC}/Form/DigitEntry.cpp ${SRC}/io/FileOutputStream.cxx @@ -60,21 +88,12 @@ set(_SOURCES ${SRC}/Units/Descriptor.cpp ${SRC}/ResourceLoader.cpp - ${SRC}/ui/control/TerminalWindow.cpp - ${SRC}/ui/canvas/gdi/Canvas.cpp - ${SRC}/ui/canvas/gdi/Bitmap.cpp - ${SRC}/ui/canvas/gdi/GdiPlusBitmap.cpp - ${SRC}/ui/canvas/gdi/ResourceBitmap.cpp ${SRC}/Interface.cpp ${SRC}/Blackboard/InterfaceBlackboard.cpp - ${TEST_SRC_DIR}/Fonts.cpp - ${TEST_SRC_DIR}/FakeLanguage.cpp - ${SRC}/Kobo/FakeSymbols.cpp ## ${SRC}/MainWindow.cpp ) - set(SCRIPT_FILES CMakeSource.cmake ../../build/ov.mk From c3db1331fd4cf35da6d7d84ba3dfe628b9ce3159 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sun, 7 Jan 2024 18:22:33 +0100 Subject: [PATCH 089/403] ui/event - use CALLBACK instead of CALLBACK (in MSVC this is a protected word) so you don't need a preprocessor switch --- src/ui/event/poll/Loop.cpp | 2 +- src/ui/event/poll/Queue.cpp | 2 +- src/ui/window/poll/TopWindow.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ui/event/poll/Loop.cpp b/src/ui/event/poll/Loop.cpp index 06ea9ca0492..53d0db7099a 100644 --- a/src/ui/event/poll/Loop.cpp +++ b/src/ui/event/poll/Loop.cpp @@ -36,7 +36,7 @@ EventLoop::Get(Event &event) void EventLoop::Dispatch(const Event &event) { - if (event.type == Event::CALLBACK) { + if (event.type == Event::CALLBACK_) { event.callback(event.ptr); } else if (top_window != nullptr && event.type != Event::NOP) { #ifndef NON_INTERACTIVE diff --git a/src/ui/event/poll/Queue.cpp b/src/ui/event/poll/Queue.cpp index c2d6bfbd7fe..3e63786b1a2 100644 --- a/src/ui/event/poll/Queue.cpp +++ b/src/ui/event/poll/Queue.cpp @@ -164,7 +164,7 @@ static bool MatchCallback(const Event &event, void *ctx) noexcept { const Event *match = (const Event *)ctx; - return event.type == Event::CALLBACK && event.callback == match->callback && + return event.type == Event::CALLBACK_ && event.callback == match->callback && event.ptr == match->ptr; } diff --git a/src/ui/window/poll/TopWindow.cpp b/src/ui/window/poll/TopWindow.cpp index 376aa27dbff..b96ca20430a 100644 --- a/src/ui/window/poll/TopWindow.cpp +++ b/src/ui/window/poll/TopWindow.cpp @@ -28,7 +28,7 @@ TopWindow::OnEvent(const Event &event) Window *w; case Event::NOP: - case Event::CALLBACK: + case Event::CALLBACK_: break; case Event::CLOSE: From e02afb04a66477a2129ef457c7572d7cf84d5eb8 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sun, 7 Jan 2024 18:25:14 +0100 Subject: [PATCH 090/403] OpenVarioConfigPanel.cpp - don't use a unused variable and call SaveValue with complete parameter list --- src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp | 9 ++++----- src/OpenVario/OpenVarioBaseMenu.cpp | 7 +++++-- src/OpenVario/System/System.hpp | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp b/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp index e189efad4be..fd7a7e35423 100644 --- a/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp @@ -103,9 +103,9 @@ OpenVarioConfigPanel::Prepare(ContainerWindow &parent, _("Brightness ???."), _T("%d"), _T("%d%%"), 10, 100, 10, iBrightness); - auto Btn_Shell = AddButton( + // auto Btn_Shell = + AddButton( _T("Shell"), [this]() { - // dialog.SetModalResult(mrOK); ShowMessageBox(_("Button pressed"), _("OV-Button"), MB_OK | MB_ICONERROR); }); @@ -140,10 +140,9 @@ OpenVarioConfigPanel::Save([[maybe_unused]] bool &_changed) noexcept #endif changed |= SaveValue(OVBooleanTest, "OVBooleanTest", - bTest); + bTest, this); - changed |= SaveValueInteger(OVIntegerTest, "OVIntegerTest", - iTest); + changed |= SaveValueInteger(OVIntegerTest, "OVIntegerTest", iTest); changed |= SaveValueInteger(OVBrightness, "OVBrightness", iBrightness); diff --git a/src/OpenVario/OpenVarioBaseMenu.cpp b/src/OpenVario/OpenVarioBaseMenu.cpp index 692d99685f3..47eadde3ee5 100644 --- a/src/OpenVario/OpenVarioBaseMenu.cpp +++ b/src/OpenVario/OpenVarioBaseMenu.cpp @@ -360,10 +360,11 @@ Main() global_main_window = &main_window; if (!IsOpenVarioDevice) { + /* StaticString<0x100> Home; Home.SetUTF8(getenv("HOME")); auto HomePath = Path(Home); - // Home = _T("/home/august2111"); + debugln("HOME(1) = %s", getenv("HOME")); debugln("HOME(2) = %s", ConvertWideToACP(Home.c_str()).c_str()); debugln("HOME(3) = %s", ConvertWideToACP(HomePath.c_str()).c_str()); @@ -379,8 +380,10 @@ Main() ConvertWideToACP(ovdevice.GetConfigFile().c_str()).c_str()); // debugln("ConfigFile: %s", ConvertWideToACP(path.c_str()).c_str()); // #endif + */ + auto ConfigFile = ovdevice.GetConfigFile(); if (!File::Exists(ConfigFile)) { - debugln("ConfigFile does not exist", ConfigFile.c_str()); + debugln("ConfigFile does not exist", ConfigFile.c_str()); File::CreateExclusive(ConfigFile); if (!File::Exists(ConfigFile)) debugln("still ConfigFile does not exist", ConfigFile.c_str()); diff --git a/src/OpenVario/System/System.hpp b/src/OpenVario/System/System.hpp index 61fb66c5a4e..102f5b81b1e 100644 --- a/src/OpenVario/System/System.hpp +++ b/src/OpenVario/System/System.hpp @@ -24,7 +24,7 @@ class OpenVarioDevice { { return ConfigFile; } - Path SetConfigFile(Path _ConfigFile) noexcept + void SetConfigFile(Path _ConfigFile) noexcept { ConfigFile = _ConfigFile; } From 7452e671ab3c9a1af3592b8f2dc35e49a2ec77d5 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sun, 7 Jan 2024 21:28:16 +0100 Subject: [PATCH 091/403] OpenVarioBaseMenu - remove outcommented dbus includes --- src/OpenVario/OpenVarioBaseMenu.cpp | 5 +++-- src/OpenVario/System/Setting/BrightnessWidget.cpp | 6 ------ src/OpenVario/System/Setting/RotationWidget.cpp | 6 ------ src/OpenVario/System/Setting/SSHWidget.cpp | 6 ------ src/OpenVario/System/Setting/TimeoutWidget.cpp | 6 ------ 5 files changed, 3 insertions(+), 26 deletions(-) diff --git a/src/OpenVario/OpenVarioBaseMenu.cpp b/src/OpenVario/OpenVarioBaseMenu.cpp index 47eadde3ee5..50c7c515194 100644 --- a/src/OpenVario/OpenVarioBaseMenu.cpp +++ b/src/OpenVario/OpenVarioBaseMenu.cpp @@ -324,8 +324,9 @@ debugln(const char *fmt, ...) noexcept vsnprintf(buf, sizeof(buf) - 1, fmt, ap); va_end(ap); - strcat(buf, "\n"); - printf(buf); +// strcat(buf, "\n"); + std::cout << buf << std::endl; +// printf(buf); } static int diff --git a/src/OpenVario/System/Setting/BrightnessWidget.cpp b/src/OpenVario/System/Setting/BrightnessWidget.cpp index 806a17be124..7198f000a2d 100644 --- a/src/OpenVario/System/Setting/BrightnessWidget.cpp +++ b/src/OpenVario/System/Setting/BrightnessWidget.cpp @@ -1,12 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright The XCSoar Project -#if 0 // ndef __MSVC__ -#include "lib/dbus/Connection.hxx" -#include "lib/dbus/ScopeMatch.hxx" -#include "lib/dbus/Systemd.hxx" -#endif - #include "Dialogs/DialogSettings.hpp" #include "Dialogs/Message.hpp" #include "Dialogs/ProcessDialog.hpp" diff --git a/src/OpenVario/System/Setting/RotationWidget.cpp b/src/OpenVario/System/Setting/RotationWidget.cpp index 0a1a276208c..a8671819032 100644 --- a/src/OpenVario/System/Setting/RotationWidget.cpp +++ b/src/OpenVario/System/Setting/RotationWidget.cpp @@ -1,12 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright The XCSoar Project -#if 0 // ndef __MSVC__ -#include "lib/dbus/Connection.hxx" -#include "lib/dbus/ScopeMatch.hxx" -#include "lib/dbus/Systemd.hxx" -#endif - #include "Dialogs/DialogSettings.hpp" #include "Dialogs/Message.hpp" #include "Dialogs/ProcessDialog.hpp" diff --git a/src/OpenVario/System/Setting/SSHWidget.cpp b/src/OpenVario/System/Setting/SSHWidget.cpp index e6fbe2a21ad..ed0da52642b 100644 --- a/src/OpenVario/System/Setting/SSHWidget.cpp +++ b/src/OpenVario/System/Setting/SSHWidget.cpp @@ -1,12 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright The XCSoar Project -#if 0 // ndef __MSVC__ -#include "lib/dbus/Connection.hxx" -#include "lib/dbus/ScopeMatch.hxx" -#include "lib/dbus/Systemd.hxx" -#endif - #include "Dialogs/DialogSettings.hpp" #include "Dialogs/Message.hpp" #include "Dialogs/ProcessDialog.hpp" diff --git a/src/OpenVario/System/Setting/TimeoutWidget.cpp b/src/OpenVario/System/Setting/TimeoutWidget.cpp index ab432f53889..1cb8b1ac26d 100644 --- a/src/OpenVario/System/Setting/TimeoutWidget.cpp +++ b/src/OpenVario/System/Setting/TimeoutWidget.cpp @@ -1,12 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright The XCSoar Project -#if 0 // ndef __MSVC__ -#include "lib/dbus/Connection.hxx" -#include "lib/dbus/ScopeMatch.hxx" -#include "lib/dbus/Systemd.hxx" -#endif - #include "Dialogs/DialogSettings.hpp" #include "Dialogs/Message.hpp" #include "Dialogs/ProcessDialog.hpp" From ae4b7170995fb4487027f507c91a1829b12ff919 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sun, 7 Jan 2024 21:30:36 +0100 Subject: [PATCH 092/403] [build] targets.mk - for cross-compiling not allowed system includes to root '/' --- build/targets.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/targets.mk b/build/targets.mk index 18514f86664..e157b0547ab 100644 --- a/build/targets.mk +++ b/build/targets.mk @@ -434,7 +434,7 @@ endif ifeq ($(TARGET_IS_OPENVARIO),y) TARGET_CPPFLAGS += -DIS_OPENVARIO - TARGET_CPPFLAGS += -isystem /usr/include/dbus-1.0 -isystem /usr/lib/x86_64-linux-gnu/dbus-1.0/include + # TARGET_CPPFLAGS += -isystem /usr/include/dbus-1.0 -isystem /usr/lib/x86_64-linux-gnu/dbus-1.0/include endif ifeq ($(HAVE_MSVCRT),y) From 341550104e66dcfb2c88a5282bdd22f36e5d1585 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sun, 7 Jan 2024 21:36:32 +0100 Subject: [PATCH 093/403] System.hpp - compile w/o dbus functions --- src/OpenVario/System/System.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenVario/System/System.hpp b/src/OpenVario/System/System.hpp index 102f5b81b1e..f1a55b64750 100644 --- a/src/OpenVario/System/System.hpp +++ b/src/OpenVario/System/System.hpp @@ -36,7 +36,7 @@ class OpenVarioDevice { }; extern OpenVarioDevice ovdevice; -#if !defined(_WIN32) && 1 +#if !defined(_WIN32) && 0 # define DBUS_FUNCTIONS 1 #endif From 5453ee4d1361b0e177eeeb047c46c8359307a6fb Mon Sep 17 00:00:00 2001 From: August2111 Date: Sun, 7 Jan 2024 21:44:33 +0100 Subject: [PATCH 094/403] [build] ov.mk - missing references --- build/ov.mk | 229 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 227 insertions(+), 2 deletions(-) diff --git a/build/ov.mk b/build/ov.mk index 8bae141514c..01e303b3017 100644 --- a/build/ov.mk +++ b/build/ov.mk @@ -1,4 +1,177 @@ +EXTRA_CPPFLAGS+=-DIS_OPENVARIO + +DIALOG_SOURCES = \ + $(SRC)/Dialogs/Inflate.cpp \ + $(SRC)/Dialogs/Message.cpp \ + $(SRC)/Dialogs/LockScreen.cpp \ + $(SRC)/Dialogs/Error.cpp \ + $(SRC)/Dialogs/ListPicker.cpp \ + $(SRC)/Dialogs/ProgressDialog.cpp \ + $(SRC)/Dialogs/CoDialog.cpp \ + $(SRC)/Dialogs/JobDialog.cpp \ + $(SRC)/Dialogs/WidgetDialog.cpp \ + $(SRC)/Dialogs/FileManager.cpp \ + $(SRC)/Dialogs/Device/PortDataField.cpp \ + $(SRC)/Dialogs/Device/PortPicker.cpp \ + $(SRC)/Dialogs/Device/DeviceEditWidget.cpp \ + $(SRC)/Dialogs/Device/DeviceListDialog.cpp \ + $(SRC)/Dialogs/Device/PortMonitor.cpp \ + $(SRC)/Dialogs/Device/ManageCAI302Dialog.cpp \ + $(SRC)/Dialogs/Device/CAI302/UnitsEditor.cpp \ + $(SRC)/Dialogs/Device/CAI302/WaypointUploader.cpp \ + $(SRC)/Dialogs/Device/ManageFlarmDialog.cpp \ + $(SRC)/Dialogs/Device/BlueFly/BlueFlyConfigurationDialog.cpp \ + $(SRC)/Dialogs/Device/ManageI2CPitotDialog.cpp \ + $(SRC)/Dialogs/Device/LX/ManageLXNAVVarioDialog.cpp \ + $(SRC)/Dialogs/Device/LX/LXNAVVarioConfigWidget.cpp \ + $(SRC)/Dialogs/Device/LX/ManageNanoDialog.cpp \ + $(SRC)/Dialogs/Device/LX/NanoConfigWidget.cpp \ + $(SRC)/Dialogs/Device/LX/ManageLX16xxDialog.cpp \ + $(SRC)/Dialogs/Device/Vega/VegaParametersWidget.cpp \ + $(SRC)/Dialogs/Device/Vega/VegaConfigurationDialog.cpp \ + $(SRC)/Dialogs/Device/Vega/VegaDemoDialog.cpp \ + $(SRC)/Dialogs/Device/Vega/SwitchesDialog.cpp \ + $(SRC)/Dialogs/Device/FLARM/ConfigWidget.cpp \ + $(SRC)/Dialogs/MapItemListDialog.cpp \ + $(SRC)/Dialogs/MapItemListSettingsDialog.cpp \ + $(SRC)/Dialogs/MapItemListSettingsPanel.cpp \ + $(SRC)/Dialogs/ColorListDialog.cpp \ + $(SRC)/Dialogs/Airspace/dlgAirspace.cpp \ + $(SRC)/Dialogs/Airspace/dlgAirspacePatterns.cpp \ + $(SRC)/Dialogs/Airspace/dlgAirspaceDetails.cpp \ + $(SRC)/Dialogs/Airspace/AirspaceList.cpp \ + $(SRC)/Dialogs/Airspace/AirspaceCRendererSettingsDialog.cpp \ + $(SRC)/Dialogs/Airspace/AirspaceCRendererSettingsPanel.cpp \ + $(SRC)/Dialogs/Airspace/dlgAirspaceWarnings.cpp \ + $(SRC)/Dialogs/Settings/WindSettingsPanel.cpp \ + $(SRC)/Dialogs/Settings/WindSettingsDialog.cpp \ + $(SRC)/Dialogs/Settings/dlgBasicSettings.cpp \ + $(SRC)/Dialogs/Settings/dlgConfiguration.cpp \ + $(SRC)/Dialogs/Settings/dlgConfigInfoboxes.cpp \ + $(SRC)/Dialogs/Traffic/TrafficList.cpp \ + $(SRC)/Dialogs/Traffic/FlarmTrafficDetails.cpp \ + $(SRC)/Dialogs/Traffic/TeamCodeDialog.cpp \ + $(SRC)/Dialogs/dlgAnalysis.cpp \ + $(SRC)/Dialogs/dlgChecklist.cpp \ + $(SRC)/Dialogs/ProfileListDialog.cpp \ + $(SRC)/Dialogs/Plane/PlaneListDialog.cpp \ + $(SRC)/Dialogs/Plane/PlaneDetailsDialog.cpp \ + $(SRC)/Dialogs/Plane/PlanePolarDialog.cpp \ + $(SRC)/Dialogs/Plane/PolarShapeEditWidget.cpp \ + $(SRC)/Dialogs/DataField.cpp \ + $(SRC)/Dialogs/ComboPicker.cpp \ + $(SRC)/Dialogs/FilePicker.cpp \ + $(SRC)/Dialogs/HelpDialog.cpp \ + $(SRC)/Dialogs/dlgInfoBoxAccess.cpp \ + $(SRC)/Dialogs/ReplayDialog.cpp \ + $(SRC)/Dialogs/dlgSimulatorPrompt.cpp \ + $(SRC)/Dialogs/SimulatorPromptWindow.cpp \ + $(SRC)/Dialogs/StartupDialog.cpp \ + $(SRC)/Dialogs/ProfilePasswordDialog.cpp \ + \ + $(SRC)/Dialogs/dlgStatus.cpp \ + $(SRC)/Dialogs/StatusPanels/StatusPanel.cpp \ + $(SRC)/Dialogs/StatusPanels/FlightStatusPanel.cpp \ + $(SRC)/Dialogs/StatusPanels/SystemStatusPanel.cpp \ + $(SRC)/Dialogs/StatusPanels/TaskStatusPanel.cpp \ + $(SRC)/Dialogs/StatusPanels/RulesStatusPanel.cpp \ + $(SRC)/Dialogs/StatusPanels/TimesStatusPanel.cpp \ + \ + $(SRC)/Dialogs/Waypoint/WaypointInfoWidget.cpp \ + $(SRC)/Dialogs/Waypoint/WaypointCommandsWidget.cpp \ + $(SRC)/Dialogs/Waypoint/dlgWaypointDetails.cpp \ + $(SRC)/Dialogs/Waypoint/Manager.cpp \ + $(SRC)/Dialogs/Waypoint/dlgWaypointEdit.cpp \ + $(SRC)/Dialogs/Waypoint/WaypointList.cpp \ + $(SRC)/Dialogs/Waypoint/NearestWaypoint.cpp \ + \ + $(SRC)/Dialogs/Settings/Panels/AirspaceConfigPanel.cpp \ + $(SRC)/Dialogs/Settings/Panels/GaugesConfigPanel.cpp \ + $(SRC)/Dialogs/Settings/Panels/VarioConfigPanel.cpp \ + $(SRC)/Dialogs/Settings/Panels/GlideComputerConfigPanel.cpp \ + $(SRC)/Dialogs/Settings/Panels/WindConfigPanel.cpp \ + $(SRC)/Dialogs/Settings/Panels/InfoBoxesConfigPanel.cpp \ + $(SRC)/Dialogs/Settings/Panels/InterfaceConfigPanel.cpp \ + $(SRC)/Dialogs/Settings/Panels/LayoutConfigPanel.cpp \ + $(SRC)/Dialogs/Settings/Panels/LoggerConfigPanel.cpp \ + $(SRC)/Dialogs/Settings/Panels/MapDisplayConfigPanel.cpp \ + $(SRC)/Dialogs/Settings/Panels/PagesConfigPanel.cpp \ + $(SRC)/Dialogs/Settings/Panels/RouteConfigPanel.cpp \ + $(SRC)/Dialogs/Settings/Panels/SafetyFactorsConfigPanel.cpp \ + $(SRC)/Dialogs/Settings/Panels/SiteConfigPanel.cpp \ + $(SRC)/Dialogs/Settings/Panels/SymbolsConfigPanel.cpp \ + $(SRC)/Dialogs/Settings/Panels/TaskRulesConfigPanel.cpp \ + $(SRC)/Dialogs/Settings/Panels/TaskDefaultsConfigPanel.cpp \ + $(SRC)/Dialogs/Settings/Panels/ScoringConfigPanel.cpp \ + $(SRC)/Dialogs/Settings/Panels/TerrainDisplayConfigPanel.cpp \ + $(SRC)/Dialogs/Settings/Panels/UnitsConfigPanel.cpp \ + $(SRC)/Dialogs/Settings/Panels/TimeConfigPanel.cpp \ + $(SRC)/Dialogs/Settings/Panels/WaypointDisplayConfigPanel.cpp \ + $(SRC)/Dialogs/Settings/Panels/TrackingConfigPanel.cpp \ + $(SRC)/Dialogs/Settings/Panels/CloudConfigPanel.cpp \ + $(SRC)/Dialogs/Settings/Panels/WeatherConfigPanel.cpp \ + $(SRC)/Dialogs/Settings/Panels/WeGlideConfigPanel.cpp \ + \ + $(SRC)/Dialogs/Task/Widgets/ObservationZoneEditWidget.cpp \ + $(SRC)/Dialogs/Task/Widgets/CylinderZoneEditWidget.cpp \ + $(SRC)/Dialogs/Task/Widgets/LineSectorZoneEditWidget.cpp \ + $(SRC)/Dialogs/Task/Widgets/SectorZoneEditWidget.cpp \ + $(SRC)/Dialogs/Task/Widgets/KeyholeZoneEditWidget.cpp \ + $(SRC)/Dialogs/Task/Manager/TaskMapButtonRenderer.cpp \ + $(SRC)/Dialogs/Task/Manager/TaskManagerDialog.cpp \ + $(SRC)/Dialogs/Task/Manager/TaskClosePanel.cpp \ + $(SRC)/Dialogs/Task/Manager/TaskEditPanel.cpp \ + $(SRC)/Dialogs/Task/Manager/TaskPropertiesPanel.cpp \ + $(SRC)/Dialogs/Task/Manager/TaskMiscPanel.cpp \ + $(SRC)/Dialogs/Task/Manager/TaskActionsPanel.cpp \ + $(SRC)/Dialogs/Task/Manager/TaskListPanel.cpp \ + $(SRC)/Dialogs/Task/Manager/WeGlideTasksPanel.cpp \ + $(SRC)/Dialogs/Task/OptionalStartsDialog.cpp \ + $(SRC)/Dialogs/Task/TaskPointDialog.cpp \ + $(SRC)/Dialogs/Task/MutateTaskPointDialog.cpp \ + $(SRC)/Dialogs/Task/dlgTaskHelpers.cpp \ + $(SRC)/Dialogs/Task/TargetDialog.cpp \ + $(SRC)/Dialogs/Task/AlternatesListDialog.cpp \ + \ + $(SRC)/Dialogs/Tracking/CloudEnableDialog.cpp \ + \ + $(SRC)/Dialogs/NumberEntry.cpp \ + $(SRC)/Dialogs/TextEntry.cpp \ + $(SRC)/Dialogs/KnobTextEntry.cpp \ + $(SRC)/Dialogs/TouchTextEntry.cpp \ + $(SRC)/Dialogs/TimeEntry.cpp \ + $(SRC)/Dialogs/DateEntry.cpp \ + $(SRC)/Dialogs/GeoPointEntry.cpp \ + $(SRC)/Dialogs/Weather/WeatherDialog.cpp \ + $(SRC)/Dialogs/Weather/RASPDialog.cpp \ + $(SRC)/Dialogs/dlgCredits.cpp \ + $(SRC)/Dialogs/dlgQuickMenu.cpp \ + \ + $(SRC)/Dialogs/DownloadFilePicker.cpp \ + +## ifeq ($(HAVE_HTTP),y) +DIALOG_SOURCES += \ + $(SRC)/Dialogs/DownloadFilePicker.cpp \ + $(SRC)/Repository/Glue.cpp \ + +## $(SRC)/Renderer/NOAAListRenderer.cpp \ +## $(SRC)/Weather/PCMet/Images.cpp \ +## $(SRC)/Weather/PCMet/Overlays.cpp \ +## $(SRC)/Weather/NOAAGlue.cpp \ +## $(SRC)/Weather/METARParser.cpp \ +## $(SRC)/Weather/NOAAFormatter.cpp \ +## $(SRC)/Weather/NOAADownloader.cpp \ +## $(SRC)/Weather/NOAAStore.cpp \ +## $(SRC)/Weather/NOAAUpdater.cpp +## endif + +## ifeq ($(TARGET_IS_OPENVARIO),y) +## DIALOG_SOURCES += \ +## $(SRC)/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp +## endif + OV_MENU_SOURCES = \ + $(DIALOG_SOURCES) \ $(SRC)/OpenVario/OpenVarioBaseMenu.cpp \ $(SRC)/OpenVario/System/System.cpp \ $(SRC)/OpenVario/FileMenuWidget.cpp \ @@ -12,6 +185,8 @@ OV_MENU_SOURCES = \ $(SRC)/OpenVario/System/Setting/SensordWidget.cpp \ $(SRC)/OpenVario/System/Setting/WifiWidget.cpp \ \ + $(SRC)/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp \ + \ $(SRC)/Version.cpp \ $(SRC)/Asset.cpp \ $(SRC)/Formatter/HexColor.cpp \ @@ -43,8 +218,58 @@ OV_MENU_SOURCES = \ $(TEST_SRC_DIR)/Fonts.cpp \ $(TEST_SRC_DIR)/FakeLanguage.cpp \ $(TEST_SRC_DIR)/FakeLogFile.cpp \ - $(SRC)/Kobo/FakeSymbols.cpp -OV_MENU_DEPENDS = WIDGET FORM DATA_FIELD SCREEN EVENT RESOURCE ASYNC LIBNET OS IO THREAD TIME MATH UTIL + \ + $(SRC)/LocalPath.cpp \ + $(SRC)/Form/DigitEntry.cpp \ + $(SRC)/Renderer/TextRowRenderer.cpp \ + $(SRC)/net/http/DownloadManager.cpp \ + $(SRC)/Profile/Map.cpp \ + $(SRC)/Profile/File.cpp \ + $(SRC)/Profile/NumericValue.cpp \ + $(SRC)/Profile/Profile.cpp \ + $(SRC)/Profile/ProfileMap.cpp \ + \ + $(SRC)/ProgressWindow.cpp \ + \ + $(SRC)/ResourceLoader.cpp \ + $(SRC)/Repository/Parser.cpp \ + $(SRC)/ResourceLoader.cpp \ + $(SRC)/event/Call.cxx \ + $(SRC)/Math/FastTrig.cpp \ + $(SRC)/ui/window/ContainerWindow.cpp \ + + + +OV_MENU_DEPENDS = WIDGET FORM DATA_FIELD SCREEN EVENT RESOURCE ASYNC LIBNET OS IO THREAD TIME MATH UTIL \ + LIBMAPWINDOW \ + GETTEXT \ + PROFILE \ + LOOK \ + LIBHTTP \ + CO OPERATION UNITS + + +### $(SRC)/Profile/Profile.cpp \ +### $(SRC)/Profile/Map.cpp \ +### $(SRC)/Profile/ProfileMap.cpp \ +### $(SRC)/Profile/File.cpp \ +### $(SRC)/Profile/NumericValue.cpp \ +### $(SRC)/Profile/Current.cpp \ + +### $(SRC)/Dialogs/ComboPicker.cpp \ +### $(SRC)/Dialogs/ListPicker.cpp \ +### $(SRC)/Dialogs/FilePicker.cpp \ +### $(SRC)/Dialogs/NumberEntry.cpp \ +### $(SRC)/Dialogs/TextEntry.cpp \ +### $(SRC)/Dialogs/KnobTextEntry.cpp \ +### $(SRC)/Dialogs/TouchTextEntry.cpp \ +### $(SRC)/Dialogs/TimeEntry.cpp \ +### $(SRC)/Dialogs/DateEntry.cpp \ +### $(SRC)/Dialogs/GeoPointEntry.cpp \ +### \ +### $(SRC)/Dialogs/DataField.cpp + + OV_MENU_STRIP = y $(eval $(call link-program,OpenVarioBaseMenu,OV_MENU)) From 2870e0877162342502b750a94280d07e0e30acca Mon Sep 17 00:00:00 2001 From: August2111 Date: Sun, 7 Jan 2024 23:25:34 +0100 Subject: [PATCH 095/403] OpenVario/System - resolve mismatch with ConfigFile --- src/OpenVario/OpenVarioBaseMenu.cpp | 61 +------------------ .../System/Setting/RotationWidget.cpp | 5 +- .../System/Setting/TimeoutWidget.cpp | 2 +- src/OpenVario/System/System.cpp | 57 +++++++++++------ src/OpenVario/System/System.hpp | 4 +- src/OpenVario/System/SystemSettingsWidget.cpp | 4 +- 6 files changed, 46 insertions(+), 87 deletions(-) diff --git a/src/OpenVario/OpenVarioBaseMenu.cpp b/src/OpenVario/OpenVarioBaseMenu.cpp index 50c7c515194..e0dac05e7a4 100644 --- a/src/OpenVario/OpenVarioBaseMenu.cpp +++ b/src/OpenVario/OpenVarioBaseMenu.cpp @@ -2,25 +2,19 @@ // Copyright The XCSoar Project #include "Dialogs/DialogSettings.hpp" -// #include "Dialogs/Message.hpp" #include "Dialogs/WidgetDialog.hpp" -// #include "Dialogs/ProcessDialog.hpp" #include "Widget/RowFormWidget.hpp" #include "UIGlobals.hpp" #include "Look/DialogLook.hpp" #include "Screen/Layout.hpp" -// #include "../test/src/Fonts.hpp" -// #include "Fonts.hpp" #include "ui/window/Init.hpp" #include "ui/window/SingleWindow.hpp" -// #include "ui/event/Queue.hpp" #include "ui/event/Timer.hpp" #include "ui/event/KeyCode.hpp" #include "Language/Language.hpp" #include "system/Process.hpp" -// #include "util/ScopeExit.hxx" #include "system/FileUtil.hpp" #include "Profile/Profile.hpp" #include "Profile/File.hpp" @@ -117,7 +111,7 @@ class MainMenuWidget final :RowFormWidget(_dialog.GetLook()), display(_display), event_queue(_event_queue), dialog(_dialog) { - GetConfigInt("timeout", remaining_seconds, ConfigFile); + GetConfigInt("timeout", remaining_seconds, ovdevice.GetConfigFile()); } private: @@ -307,34 +301,12 @@ Main(UI::EventQueue &event_queue, UI::SingleWindow &main_window, return dialog.ShowModal(); } -#include - -void debugln(const char *fmt, ...) noexcept; - -#ifndef MAX_PATH -# define MAX_PATH 0x100 -#endif -void -debugln(const char *fmt, ...) noexcept -{ - char buf[MAX_PATH]; - va_list ap; - - va_start(ap, fmt); - vsnprintf(buf, sizeof(buf) - 1, fmt, ap); - va_end(ap); - -// strcat(buf, "\n"); - std::cout << buf << std::endl; -// printf(buf); -} - static int Main() { InitialiseDataPath(); - IsOpenVarioDevice = File::Exists(ConfigFile); + IsOpenVarioDevice = File::Exists(ovdevice.GetConfigFile()); dialog_settings.SetDefaults(); ScreenGlobalInit screen_init; @@ -361,34 +333,7 @@ Main() global_main_window = &main_window; if (!IsOpenVarioDevice) { - /* - StaticString<0x100> Home; - Home.SetUTF8(getenv("HOME")); - auto HomePath = Path(Home); - - debugln("HOME(1) = %s", getenv("HOME")); - debugln("HOME(2) = %s", ConvertWideToACP(Home.c_str()).c_str()); - debugln("HOME(3) = %s", ConvertWideToACP(HomePath.c_str()).c_str()); - - ConfigFile = Path(_T("./config.uEnv")); - debugln("ConfigFile: %s", ConvertWideToACP(ConfigFile.c_str()).c_str()); - // AllocatedPath::Build(Path(Home), Path(_T("/config.uEnv"))); - auto ConfigFile2 = - AllocatedPath::Build(Path(Home), Path(_T("config.uEnv"))); - // AllocatedPath::Build(Path(), Path(_T("/config.uEnv"))); - debugln("ConfigFile: %s", ConvertWideToACP(ConfigFile2.c_str()).c_str()); - debugln("ConfigFile: %s", - ConvertWideToACP(ovdevice.GetConfigFile().c_str()).c_str()); - // debugln("ConfigFile: %s", ConvertWideToACP(path.c_str()).c_str()); - // #endif - */ - auto ConfigFile = ovdevice.GetConfigFile(); - if (!File::Exists(ConfigFile)) { - debugln("ConfigFile does not exist", ConfigFile.c_str()); - File::CreateExclusive(ConfigFile); - if (!File::Exists(ConfigFile)) - debugln("still ConfigFile does not exist", ConfigFile.c_str()); - } + assert(File::Exists(ovdevice.GetConfigFile())); } int action = Main(screen_init.GetEventQueue(), main_window, dialog_look); diff --git a/src/OpenVario/System/Setting/RotationWidget.cpp b/src/OpenVario/System/Setting/RotationWidget.cpp index a8671819032..7ffa2d82f92 100644 --- a/src/OpenVario/System/Setting/RotationWidget.cpp +++ b/src/OpenVario/System/Setting/RotationWidget.cpp @@ -14,14 +14,11 @@ #include "Profile/Map.hpp" #include "Screen/Layout.hpp" #include "UIGlobals.hpp" -// #include "Widget/RowFormWidget.hpp" #include "system/FileUtil.hpp" #include "system/Process.hpp" #include "ui/event/KeyCode.hpp" -// #include "ui/event/Queue.hpp" #include "ui/event/Timer.hpp" #include "ui/window/Init.hpp" -// #include "ui/window/SingleWindow.hpp" #include "Language/Language.hpp" @@ -53,7 +50,7 @@ SettingRotationWidget::SaveRotation(const std::string &rotationString) { File::WriteExisting(Path(_T("/sys/class/graphics/fbcon/rotate")), (rotationString).c_str()); int rotationInt = stoi(rotationString); - ChangeConfigInt("rotation", rotationInt, ConfigFile); + ChangeConfigInt("rotation", rotationInt, ovdevice.GetConfigFile()); } void diff --git a/src/OpenVario/System/Setting/TimeoutWidget.cpp b/src/OpenVario/System/Setting/TimeoutWidget.cpp index 1cb8b1ac26d..e9af9414775 100644 --- a/src/OpenVario/System/Setting/TimeoutWidget.cpp +++ b/src/OpenVario/System/Setting/TimeoutWidget.cpp @@ -49,7 +49,7 @@ void SettingTimeoutWidget::SaveTimeout(int timeoutInt) { - ChangeConfigInt("timeout", timeoutInt, ConfigFile); + ChangeConfigInt("timeout", timeoutInt, ovdevice.GetConfigFile()); } void diff --git a/src/OpenVario/System/System.cpp b/src/OpenVario/System/System.cpp index 4b2605c46a6..74aeb8c5ca7 100644 --- a/src/OpenVario/System/System.cpp +++ b/src/OpenVario/System/System.cpp @@ -31,9 +31,11 @@ #endif #include +#include + #include #include - +#include #ifndef __MSVC__ #include @@ -43,10 +45,6 @@ #include -Path ConfigFile(_T("/boot/config.uEnv")); - - -// Path OpenVarioDevice::ConfigFile; OpenVarioDevice ovdevice; OpenVarioDevice::OpenVarioDevice() { @@ -65,13 +63,16 @@ OpenVarioDevice::OpenVarioDevice() { ConfigFile = AllocatedPath::Build(HomePath, Path(_T("openvario.cfg"))); } #else - if (Directory::Exists(Path(_T("/boot/config.uEnv")))) { - ConfigFile = AllocatedPath::Build(Path(_T("/boot/config.uEnv")), - Path(_T("openvario.cfg"))); - } else { + ConfigFile = + AllocatedPath::Build(Path(_T("/boot")), Path(_T("openvario.cfg"))); + if (!File::Exists(ConfigFile)) { ConfigFile = AllocatedPath::Build(HomePath, Path(_T("openvario.cfg"))); } #endif + if (!File::Exists(ConfigFile)) + File::CreateExclusive(ConfigFile); + + assert(File::Exists(ConfigFile)); } //---------------------------------------------------------- void @@ -101,32 +102,32 @@ WriteConfigFile(std::map> &map, Path path) //---------------------------------------------------------- void GetConfigInt(const std::string &keyvalue, unsigned &value, - const Path &ConfigPath) + const Path &config) { - if (File::Exists(ConfigFile)) { + if (File::Exists(config)) { ProfileMap configuration; - Profile::LoadFile(configuration, ConfigPath); + Profile::LoadFile(configuration, config); configuration.Get(keyvalue.c_str(), value); } else { - printf("ConfigFile '%s' does not exist!", "/boot/config.uEnv"); + debugln("ConfigFile '%s' does not exist!", config.c_str()); } } void ChangeConfigInt(const std::string &keyvalue, int value, - const Path &ConfigPath) + const Path &config) { - if (File::Exists(ConfigFile)) { + if (File::Exists(config)) { ProfileMap configuration; try { - Profile::LoadFile(configuration, ConfigPath); + Profile::LoadFile(configuration, config); } catch (std::exception &e) { - Profile::SaveFile(configuration, ConfigPath); + Profile::SaveFile(configuration, config); } configuration.Set(keyvalue.c_str(), value); - Profile::SaveFile(configuration, ConfigPath); + Profile::SaveFile(configuration, config); } else { - printf("ConfigFile '%s' does not exist!", "/boot/config.uEnv"); + debugln("ConfigFile '%s' does not exist!", config.c_str()); } } @@ -241,4 +242,22 @@ OpenvarioDisableSSH() Systemd::StopUnit(connection, "dropbear.socket"); } #endif // _WIN32 + + +#ifndef MAX_PATH +#define MAX_PATH 0x100 +#endif +void debugln(const char *fmt, ...) noexcept { + char buf[MAX_PATH]; + va_list ap; + + va_start(ap, fmt); + vsnprintf(buf, sizeof(buf) - 1, fmt, ap); + va_end(ap); + + // strcat(buf, "\n"); + std::cout << buf << std::endl; + // printf(buf); +} + //---------------------------------------------------------- diff --git a/src/OpenVario/System/System.hpp b/src/OpenVario/System/System.hpp index f1a55b64750..53ca5f2e3c1 100644 --- a/src/OpenVario/System/System.hpp +++ b/src/OpenVario/System/System.hpp @@ -13,9 +13,7 @@ #include -// extern constexpr const Path ConfigFile; -// constexpr const Path ConfigFile(_T("/boot/config.uEnv")); -extern Path ConfigFile; +void debugln(const char *fmt, ...) noexcept; class OpenVarioDevice { public: diff --git a/src/OpenVario/System/SystemSettingsWidget.cpp b/src/OpenVario/System/SystemSettingsWidget.cpp index ba01cbe193f..7f37a2693cb 100644 --- a/src/OpenVario/System/SystemSettingsWidget.cpp +++ b/src/OpenVario/System/SystemSettingsWidget.cpp @@ -78,7 +78,7 @@ ScreenRotationWidget::SaveRotation(const std::string &rotationString) { File::WriteExisting(Path(_T("/sys/class/graphics/fbcon/rotate")), (rotationString).c_str()); int rotationInt = stoi(rotationString); - ChangeConfigInt("rotation", rotationInt, ConfigFile); + ChangeConfigInt("rotation", rotationInt, ovdevice.GetConfigFile()); } void @@ -197,7 +197,7 @@ class ScreenTimeoutWidget final void ScreenTimeoutWidget::SaveTimeout(int timeoutInt) { - ChangeConfigInt("timeout", timeoutInt, ConfigFile); + ChangeConfigInt("timeout", timeoutInt, ovdevice.GetConfigFile()); } void From b3dde45e3689053b6e055e2c8f14d9c52b0e6d43 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 8 Jan 2024 11:47:47 +0100 Subject: [PATCH 096/403] OpenVarioBaseMenu.cpp - check if really OpenVario device was wrong --- src/OpenVario/OpenVarioBaseMenu.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/OpenVario/OpenVarioBaseMenu.cpp b/src/OpenVario/OpenVarioBaseMenu.cpp index e0dac05e7a4..58b130d6e67 100644 --- a/src/OpenVario/OpenVarioBaseMenu.cpp +++ b/src/OpenVario/OpenVarioBaseMenu.cpp @@ -306,7 +306,8 @@ Main() { InitialiseDataPath(); - IsOpenVarioDevice = File::Exists(ovdevice.GetConfigFile()); + // check if this config file exists as indicator of a real OpenVario-Device: + IsOpenVarioDevice = File::Exists(Path(_T("/boot/config.uEnv"))); dialog_settings.SetDefaults(); ScreenGlobalInit screen_init; From 5cb3a5da572e13eef8982b983023ab2e47ee43f4 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 10 Jan 2024 14:27:33 +0100 Subject: [PATCH 097/403] OpenVarioBaseMenu - change setup of configuration filesystem system_config (GetSystemConfig()): the config.uEnf in the /boot folder, only available an real OpenVario settings_config (GetSettingsConfig()): config for the complete setting inside the OpenVarioBaseMenu upgrade_config (GetUpgradeConfig()): used for preparing upgrade (and later restore) of device --- src/OpenVario/OpenVarioBaseMenu.cpp | 8 ++-- .../System/Setting/RotationWidget.cpp | 2 +- .../System/Setting/TimeoutWidget.cpp | 2 +- src/OpenVario/System/System.cpp | 39 +++++++++++-------- src/OpenVario/System/System.hpp | 38 ++++++++++++++---- 5 files changed, 59 insertions(+), 30 deletions(-) diff --git a/src/OpenVario/OpenVarioBaseMenu.cpp b/src/OpenVario/OpenVarioBaseMenu.cpp index 58b130d6e67..d00ebeda227 100644 --- a/src/OpenVario/OpenVarioBaseMenu.cpp +++ b/src/OpenVario/OpenVarioBaseMenu.cpp @@ -111,7 +111,7 @@ class MainMenuWidget final :RowFormWidget(_dialog.GetLook()), display(_display), event_queue(_event_queue), dialog(_dialog) { - GetConfigInt("timeout", remaining_seconds, ovdevice.GetConfigFile()); + GetConfigInt("timeout", remaining_seconds, ovdevice.GetSettingsConfig()); } private: @@ -244,7 +244,7 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, AddButton(_("Test"), [this]() { CancelTimer(); std::unique_ptr widget = CreateOpenVarioConfigPanel(); - Profile::LoadFile(ovdevice.GetConfigFile()); + Profile::LoadFile(ovdevice.GetSettingsConfig()); TWidgetDialog sub_dialog( WidgetDialog::Full{}, dialog.GetMainWindow(), GetLook(), _T("OpenVario Test")); @@ -253,7 +253,7 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, auto ret_value = sub_dialog.ShowModal(); if (sub_dialog.GetChanged()) { - Profile::SaveFile(ovdevice.GetConfigFile()); + Profile::SaveFile(ovdevice.GetSettingsConfig()); } return ret_value; }); @@ -334,7 +334,7 @@ Main() global_main_window = &main_window; if (!IsOpenVarioDevice) { - assert(File::Exists(ovdevice.GetConfigFile())); + assert(File::Exists(ovdevice.GetSettingsConfig())); } int action = Main(screen_init.GetEventQueue(), main_window, dialog_look); diff --git a/src/OpenVario/System/Setting/RotationWidget.cpp b/src/OpenVario/System/Setting/RotationWidget.cpp index 7ffa2d82f92..1dc99587b7f 100644 --- a/src/OpenVario/System/Setting/RotationWidget.cpp +++ b/src/OpenVario/System/Setting/RotationWidget.cpp @@ -50,7 +50,7 @@ SettingRotationWidget::SaveRotation(const std::string &rotationString) { File::WriteExisting(Path(_T("/sys/class/graphics/fbcon/rotate")), (rotationString).c_str()); int rotationInt = stoi(rotationString); - ChangeConfigInt("rotation", rotationInt, ovdevice.GetConfigFile()); + ChangeConfigInt("rotation", rotationInt, ovdevice.GetSettingsConfig()); } void diff --git a/src/OpenVario/System/Setting/TimeoutWidget.cpp b/src/OpenVario/System/Setting/TimeoutWidget.cpp index e9af9414775..89e625c2a43 100644 --- a/src/OpenVario/System/Setting/TimeoutWidget.cpp +++ b/src/OpenVario/System/Setting/TimeoutWidget.cpp @@ -49,7 +49,7 @@ void SettingTimeoutWidget::SaveTimeout(int timeoutInt) { - ChangeConfigInt("timeout", timeoutInt, ovdevice.GetConfigFile()); + ChangeConfigInt("timeout", timeoutInt, ovdevice.GetSettingsConfig()); } void diff --git a/src/OpenVario/System/System.cpp b/src/OpenVario/System/System.cpp index 74aeb8c5ca7..e36659b8e62 100644 --- a/src/OpenVario/System/System.cpp +++ b/src/OpenVario/System/System.cpp @@ -50,29 +50,34 @@ OpenVarioDevice ovdevice; OpenVarioDevice::OpenVarioDevice() { StaticString<0x100> home; home.SetUTF8(getenv("HOME")); - HomePath = Path(home); + home_path = Path(home); #ifdef _WIN32 // DataPath = Path(_T("D:/Data/OpenSoarData")); -// DataPath = Path(_T("D:/Data/XCSoarData")); - DataPath = Path(_T("D:\\Data\\XCSoarData")); + data_path = Path(_T("D:\\Data\\XCSoarData")); - if (Directory::Exists(DataPath)) { - auto config = AllocatedPath::Build(DataPath, Path(_T("openvario.cfg"))); - ConfigFile = AllocatedPath::Build(DataPath, Path(_T("openvario.cfg"))); - } else { - ConfigFile = AllocatedPath::Build(HomePath, Path(_T("openvario.cfg"))); - } #else - ConfigFile = - AllocatedPath::Build(Path(_T("/boot")), Path(_T("openvario.cfg"))); - if (!File::Exists(ConfigFile)) { - ConfigFile = AllocatedPath::Build(HomePath, Path(_T("openvario.cfg"))); - } + data_path = Path(_T("data")); + + system_config = + AllocatedPath::Build(Path(_T("/boot")), Path(_T("config.uEnf"))); #endif - if (!File::Exists(ConfigFile)) - File::CreateExclusive(ConfigFile); + if (Directory::Exists(data_path)) { + // auto config = AllocatedPath::Build(data_path, Path(_T("openvario.cfg"))); + settings_config = + AllocatedPath::Build(data_path, Path(_T("openvario.cfg"))); + upgrade_config = + AllocatedPath::Build(data_path, Path(_T("upgrade.cfg"))); + } else { + settings_config = + AllocatedPath::Build(home_path, Path(_T("openvario.cfg"))); + upgrade_config = + AllocatedPath::Build(home_path, Path(_T("upgrade.cfg"))); + } + + if (!File::Exists(settings_config)) + File::CreateExclusive(settings_config); - assert(File::Exists(ConfigFile)); + assert(File::Exists(settings_config)); } //---------------------------------------------------------- void diff --git a/src/OpenVario/System/System.hpp b/src/OpenVario/System/System.hpp index 53ca5f2e3c1..129da9ef5d6 100644 --- a/src/OpenVario/System/System.hpp +++ b/src/OpenVario/System/System.hpp @@ -18,19 +18,43 @@ void debugln(const char *fmt, ...) noexcept; class OpenVarioDevice { public: OpenVarioDevice(); - Path GetConfigFile() noexcept + + Path GetSystemConfig() noexcept + { + return system_config; + } + + Path SetSystemConfig(Path configfile) noexcept + { + system_config = configfile; + } + + Path GetSettingsConfig() noexcept + { + return settings_config; + } + void SetSettingsConfig(Path configfile) noexcept + { + settings_config = configfile; + } + + Path GetUpgradeConfig() noexcept { - return ConfigFile; + return upgrade_config; } - void SetConfigFile(Path _ConfigFile) noexcept + void SetUpgradeConfig(Path configfile) noexcept { - ConfigFile = _ConfigFile; + upgrade_config = configfile; } private: - AllocatedPath ConfigFile; - AllocatedPath HomePath; - AllocatedPath DataPath; + AllocatedPath system_config; // system config file, in the OV the + // /boot/config.uEnf + AllocatedPath upgrade_config; // the config file for upgrading OV + AllocatedPath settings_config; // the config file for settings inside + // the OpenVarioBaseMenu + AllocatedPath home_path; + AllocatedPath data_path; }; extern OpenVarioDevice ovdevice; From d93082ee49980a4a5ce759cf2d61fc0e9594b2a6 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 10 Jan 2024 14:31:18 +0100 Subject: [PATCH 098/403] OpenVarioBaseMenu - remove outcommended code created on splitting the code in several files --- .../System/Setting/TimeoutWidget.cpp | 64 --- src/OpenVario/System/SystemSettingsWidget.cpp | 382 ------------------ 2 files changed, 446 deletions(-) diff --git a/src/OpenVario/System/Setting/TimeoutWidget.cpp b/src/OpenVario/System/Setting/TimeoutWidget.cpp index 89e625c2a43..c205e1a302f 100644 --- a/src/OpenVario/System/Setting/TimeoutWidget.cpp +++ b/src/OpenVario/System/Setting/TimeoutWidget.cpp @@ -136,67 +136,3 @@ SettingTimeoutWidget::Prepare([[maybe_unused]] ContainerWindow &parent, }); } -//---------------------------------------------------------- -//---------------------------------------------------------- -//---------------------------------------------------------- -#if 0 -void -SystemSettingsWidget::Prepare([[maybe_unused]] ContainerWindow &parent, - [[maybe_unused]] const PixelRect &rc) noexcept -{ - AddButton(_("Setting Rotation"), [this](){ - TWidgetDialog - sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), _T("Display Rotation Settings")); - sub_dialog.SetWidget(display, event_queue, GetLook()); - sub_dialog.AddButton(_("Close"), mrOK); - return sub_dialog.ShowModal(); - }); - - AddButton(_("Setting Brightness"), [this](){ - TWidgetDialog - sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), _T("Display Brightness Settings")); - sub_dialog.SetWidget(display, event_queue, GetLook()); - sub_dialog.AddButton(_("Close"), mrOK); - return sub_dialog.ShowModal(); - }); - - AddButton(_("Autostart Timeout"), [this](){ - TWidgetDialog - sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), _T("Autostart Timeout")); - sub_dialog.SetWidget(display, event_queue, GetLook()); - sub_dialog.AddButton(_("Close"), mrOK); - return sub_dialog.ShowModal(); - }); - - AddButton(_("SSH"), [this](){ - TWidgetDialog - sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), _T("Enable or Disable SSH")); - sub_dialog.SetWidget(display, event_queue, GetLook()); - sub_dialog.AddButton(_("Close"), mrOK); - return sub_dialog.ShowModal(); - }); - - AddButton(_("Variod"), [this](){ - TWidgetDialog - sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), _T("Enable or Disable Variod")); - sub_dialog.SetWidget(display, event_queue, GetLook()); - sub_dialog.AddButton(_("Close"), mrOK); - return sub_dialog.ShowModal(); - }); - - AddButton(_("Sensord"), [this](){ - TWidgetDialog - sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), _T("Enable or Disable Sensord")); - sub_dialog.SetWidget(display, event_queue, GetLook()); - sub_dialog.AddButton(_("Close"), mrOK); - return sub_dialog.ShowModal(); - }); -} - -#endif \ No newline at end of file diff --git a/src/OpenVario/System/SystemSettingsWidget.cpp b/src/OpenVario/System/SystemSettingsWidget.cpp index 7f37a2693cb..7c21dee42c5 100644 --- a/src/OpenVario/System/SystemSettingsWidget.cpp +++ b/src/OpenVario/System/SystemSettingsWidget.cpp @@ -48,388 +48,6 @@ #include #include -//---------------------------------------------------------- -//---------------------------------------------------------- -//---------------------------------------------------------- -#if 0 -class ScreenRotationWidget final - : public RowFormWidget -{ - UI::Display &display; - UI::EventQueue &event_queue; - -public: - ScreenRotationWidget(UI::Display &_display, UI::EventQueue &_event_queue, - const DialogLook &look) noexcept - :RowFormWidget(look), - display(_display), event_queue(_event_queue) {} - -private: - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, - const PixelRect &rc) noexcept override; - void SaveRotation(const std::string &rotationvalue); -}; - -/* x-menu writes the value for the display rotation to /sys because the value is also required for the console in the OpenVario. -In addition, the display rotation is saved in /boot/config.uEnv so that the Openvario sets the correct rotation again when it is restarted.*/ -void -ScreenRotationWidget::SaveRotation(const std::string &rotationString) -{ - File::WriteExisting(Path(_T("/sys/class/graphics/fbcon/rotate")), (rotationString).c_str()); - int rotationInt = stoi(rotationString); - ChangeConfigInt("rotation", rotationInt, ovdevice.GetConfigFile()); -} - -void -ScreenRotationWidget::Prepare([[maybe_unused]] ContainerWindow &parent, - [[maybe_unused]] const PixelRect &rc) noexcept -{ - AddButton(_T("Landscape"), [this](){ - SaveRotation("0"); - Display::Rotate(DisplayOrientation::LANDSCAPE); - }); - - AddButton(_T("Portrait (90°)"), [this](){ - SaveRotation("1"); - Display::Rotate(DisplayOrientation::REVERSE_PORTRAIT); - }); - - AddButton(_T("Landscape (180°)"), [this](){ - SaveRotation("2"); - Display::Rotate(DisplayOrientation::REVERSE_LANDSCAPE); - }); - - AddButton(_T("Portrait (270°)"), [this](){ - SaveRotation("3"); - Display::Rotate(DisplayOrientation::PORTRAIT); - }); -} - -class ScreenBrightnessWidget final - : public RowFormWidget -{ - UI::Display &display; - UI::EventQueue &event_queue; - -public: - ScreenBrightnessWidget(UI::Display &_display, UI::EventQueue &_event_queue, - const DialogLook &look) noexcept - :RowFormWidget(look), - display(_display), event_queue(_event_queue) {} - -private: - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, - const PixelRect &rc) noexcept override; - -void SaveBrightness(const std::string &brightness); -}; - -void -ScreenBrightnessWidget::SaveBrightness(const std::string &brightness) -{ -File::WriteExisting(Path(_T("/sys/class/backlight/lcd/brightness")), - (brightness).c_str()); -} - -void -ScreenBrightnessWidget::Prepare([[maybe_unused]] ContainerWindow &parent, - [[maybe_unused]] const PixelRect &rc) noexcept -{ - AddButton(_T("20"), [this](){ - SaveBrightness("2"); - }); - - AddButton(_T("30"), [this](){ - SaveBrightness("3"); - }); - - AddButton(_T("40"), [this](){ - SaveBrightness("4"); - }); - - AddButton(_T("50"), [this](){ - SaveBrightness("5"); - }); - - AddButton(_T("60"), [this](){ - SaveBrightness("6"); - }); - - AddButton(_T("70"), [this](){ - SaveBrightness("7"); - }); - - AddButton(_T("80"), [this](){ - SaveBrightness("8"); - }); - - AddButton(_T("90"), [this](){ - SaveBrightness("9"); - }); - - AddButton(_T("100"), [this](){ - SaveBrightness("10"); - }); -} - - -class ScreenTimeoutWidget final - : public RowFormWidget -{ - UI::Display &display; - UI::EventQueue &event_queue; - -public: - ScreenTimeoutWidget(UI::Display &_display, UI::EventQueue &_event_queue, - const DialogLook &look) noexcept - :RowFormWidget(look), - display(_display), event_queue(_event_queue) {} - -private: - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, - const PixelRect &rc) noexcept override; - void SaveTimeout(int timeoutvalue); -}; - -void -ScreenTimeoutWidget::SaveTimeout(int timeoutInt) -{ - ChangeConfigInt("timeout", timeoutInt, ovdevice.GetConfigFile()); -} - -void -ScreenTimeoutWidget::Prepare([[maybe_unused]] ContainerWindow &parent, - [[maybe_unused]] const PixelRect &rc) noexcept - -{ - AddButton(_T("immediately"), [this](){ - SaveTimeout(0); - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "echo Automatic timeout was set to 0s", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("immediately"), argv); - }); - - AddButton(_T("1s"), [this](){ - SaveTimeout(1); - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "echo Automatic timeout was set to 1s", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("1s"), argv); - }); - - AddButton(_T("3s"), [this](){ - SaveTimeout(3); - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "echo Automatic timeout was set to 3s", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("3s"), argv); - }); - - AddButton(_T("5s"), [this](){ - SaveTimeout(5); - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "echo Automatic timeout was set to 5s", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("5s"), argv); - }); - - AddButton(_T("10s"), [this](){ - SaveTimeout(10); - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "echo Automatic timeout was set to 10s", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("10s"), argv); - }); - - AddButton(_T("30s"), [this](){ - SaveTimeout(30); - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "echo Automatic timeout was set to 30s", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("30s"), argv); - }); -} - -class ScreenSSHWidget final - : public RowFormWidget -{ - UI::Display &display; - UI::EventQueue &event_queue; - -public: - ScreenSSHWidget(UI::Display &_display, UI::EventQueue &_event_queue, - const DialogLook &look) noexcept - :RowFormWidget(look), - display(_display), event_queue(_event_queue) {} - -private: - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, - const PixelRect &rc) noexcept override; -}; - -void -ScreenSSHWidget::Prepare([[maybe_unused]] ContainerWindow &parent, - [[maybe_unused]] const PixelRect &rc) noexcept -{ - AddButton(_T("Enable") , [](){ - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "systemctl enable dropbear.socket && printf '\nSSH has been enabled'", - - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("Enable"), argv); - }); - - AddButton(_T("Disable") , [](){ - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "systemctl disable dropbear.socket && printf '\nSSH has been disabled'", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("Disable"), argv); - }); -} - -class ScreenVariodWidget final - : public RowFormWidget -{ - UI::Display &display; - UI::EventQueue &event_queue; - -public: - ScreenVariodWidget(UI::Display &_display, UI::EventQueue &_event_queue, - const DialogLook &look) noexcept - :RowFormWidget(look), - display(_display), event_queue(_event_queue) {} - -private: - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, - const PixelRect &rc) noexcept override; -}; - -void -ScreenVariodWidget::Prepare([[maybe_unused]] ContainerWindow &parent, - [[maybe_unused]] const PixelRect &rc) noexcept -{ - AddButton(_T("Enable") , [](){ - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "systemctl enable variod && printf '\nvariod has been enabled'", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("Enable"), argv); - }); - - AddButton(_T("Disable"), [](){ - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "systemctl disable variod && printf '\nvariod has been disabled'", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("Disable"), argv); - }); -} - -class ScreenSensordWidget final - : public RowFormWidget -{ - UI::Display &display; - UI::EventQueue &event_queue; - -public: - ScreenSensordWidget(UI::Display &_display, UI::EventQueue &_event_queue, - const DialogLook &look) noexcept - :RowFormWidget(look), - display(_display), event_queue(_event_queue) {} - -private: - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, - const PixelRect &rc) noexcept override; -}; - -void -ScreenSensordWidget::Prepare([[maybe_unused]] ContainerWindow &parent, - [[maybe_unused]] const PixelRect &rc) noexcept -{ - AddButton(_T("Enable"), [](){ - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "systemctl enable sensord && printf '\nsensord has been enabled'", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("Enable"), argv); - }); - - AddButton(_T("Disable"), [](){ - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "systemctl disable sensord && printf '\nsensord has been disabled'", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("Disable"), argv); - }); -} -#endif -//---------------------------------------------------------- -//---------------------------------------------------------- -//---------------------------------------------------------- - void SystemSettingsWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept From bb6f8f18a0bbaf6a20e87555bf341fbffbbbd844 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 11 Jan 2024 15:06:53 +0100 Subject: [PATCH 099/403] [CMake] output directory for MSVC Binary dir/$ --- src/OpenVario/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/OpenVario/CMakeLists.txt b/src/OpenVario/CMakeLists.txt index ad5cfd6f959..31b24be1af4 100644 --- a/src/OpenVario/CMakeLists.txt +++ b/src/OpenVario/CMakeLists.txt @@ -46,6 +46,7 @@ add_compile_definitions("IS_OPENVARIO") # add_compile_definitions("USE_LIBINPUT") # remeve this definition after +set(RUNTIME_OUTPUT_DIRECTORY ${PROJECTGROUP_SOURCE_DIR}/$) add_executable(${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES} From afa7ac11f19778ab9d3cc3c9ccd17b7751e6e433 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 10 Jan 2024 14:53:59 +0100 Subject: [PATCH 100/403] OpenVarioBaseMenu - 'IsOpenVarioDevice' is depend on GetSettingsConfig() exist --- src/OpenVario/OpenVarioBaseMenu.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/OpenVario/OpenVarioBaseMenu.cpp b/src/OpenVario/OpenVarioBaseMenu.cpp index d00ebeda227..d57aaec688a 100644 --- a/src/OpenVario/OpenVarioBaseMenu.cpp +++ b/src/OpenVario/OpenVarioBaseMenu.cpp @@ -307,7 +307,8 @@ Main() InitialiseDataPath(); // check if this config file exists as indicator of a real OpenVario-Device: - IsOpenVarioDevice = File::Exists(Path(_T("/boot/config.uEnv"))); + // SystemConfig is only available on real OpenVario Device + IsOpenVarioDevice = File::Exists(ovdevice.GetSystemConfig()); dialog_settings.SetDefaults(); ScreenGlobalInit screen_init; From 1a6b90456d0abe976fa3db36cc80f13cc37a696e Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 10 Jan 2024 14:59:44 +0100 Subject: [PATCH 101/403] System.hpp - update return statement --- src/OpenVario/System/System.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenVario/System/System.hpp b/src/OpenVario/System/System.hpp index 129da9ef5d6..6fe2563bb1b 100644 --- a/src/OpenVario/System/System.hpp +++ b/src/OpenVario/System/System.hpp @@ -24,7 +24,7 @@ class OpenVarioDevice { return system_config; } - Path SetSystemConfig(Path configfile) noexcept + void SetSystemConfig(Path configfile) noexcept { system_config = configfile; } From e7a4bdbae251a27c006e3bb64c07f0ce686824ad Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 10 Jan 2024 20:12:10 +0100 Subject: [PATCH 102/403] Device/Driver/LX/NanoLogger.cpp - don't check a boolean value with '>0' - this was a warning warning --- src/Device/Driver/LX/NanoLogger.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Device/Driver/LX/NanoLogger.cpp b/src/Device/Driver/LX/NanoLogger.cpp index c48019cda5d..f935a00e506 100644 --- a/src/Device/Driver/LX/NanoLogger.cpp +++ b/src/Device/Driver/LX/NanoLogger.cpp @@ -147,7 +147,7 @@ ParseLogbookContent(const char *_line, RecordedFlightInfo &info) unsigned n; return line.ReadChecked(n) && - ReadFilename(line, info) > 0 && + ReadFilename(line, info) && ReadDate(line, info.date) && ReadTime(line, info.start_time) && ReadTime(line, info.end_time); From 9149af448fa4cff1f5cab2335353847bcb74c97f Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 10 Jan 2024 20:22:07 +0100 Subject: [PATCH 103/403] OpenVarioBaseMenu - use a OpenVarioDevice object vor all accesses to folders. states, settings and so on --- src/OpenVario/OpenVarioBaseMenu.cpp | 9 ++------- src/OpenVario/System/System.cpp | 1 + src/OpenVario/System/System.hpp | 20 ++++++++++++++++---- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/OpenVario/OpenVarioBaseMenu.cpp b/src/OpenVario/OpenVarioBaseMenu.cpp index d57aaec688a..e6f58006957 100644 --- a/src/OpenVario/OpenVarioBaseMenu.cpp +++ b/src/OpenVario/OpenVarioBaseMenu.cpp @@ -42,8 +42,6 @@ #include "util/ConvertString.hpp" -bool IsOpenVarioDevice = true; - static DialogSettings dialog_settings; static UI::SingleWindow *global_main_window; static DialogLook *global_dialog_look; @@ -280,7 +278,7 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, AddReadOnly(_T("")); // Timer-Progress - if (!IsOpenVarioDevice) { + if (!ovdevice.IsReal()) { Btn_Shell->SetCaption(_T("Exit")); Btn_XCSoar->SetEnabled(false); Btn_Reboot->SetEnabled(false); @@ -306,9 +304,6 @@ Main() { InitialiseDataPath(); - // check if this config file exists as indicator of a real OpenVario-Device: - // SystemConfig is only available on real OpenVario Device - IsOpenVarioDevice = File::Exists(ovdevice.GetSystemConfig()); dialog_settings.SetDefaults(); ScreenGlobalInit screen_init; @@ -334,7 +329,7 @@ Main() global_dialog_look = &dialog_look; global_main_window = &main_window; - if (!IsOpenVarioDevice) { + if (!ovdevice.IsReal()) { assert(File::Exists(ovdevice.GetSettingsConfig())); } diff --git a/src/OpenVario/System/System.cpp b/src/OpenVario/System/System.cpp index e36659b8e62..1f5d40ec374 100644 --- a/src/OpenVario/System/System.cpp +++ b/src/OpenVario/System/System.cpp @@ -60,6 +60,7 @@ OpenVarioDevice::OpenVarioDevice() { system_config = AllocatedPath::Build(Path(_T("/boot")), Path(_T("config.uEnf"))); + is_real = File::Exists(system_config); #endif if (Directory::Exists(data_path)) { // auto config = AllocatedPath::Build(data_path, Path(_T("openvario.cfg"))); diff --git a/src/OpenVario/System/System.hpp b/src/OpenVario/System/System.hpp index 6fe2563bb1b..da7495c1767 100644 --- a/src/OpenVario/System/System.hpp +++ b/src/OpenVario/System/System.hpp @@ -29,24 +29,34 @@ class OpenVarioDevice { system_config = configfile; } - Path GetSettingsConfig() noexcept + Path + GetSettingsConfig() noexcept { return settings_config; } - void SetSettingsConfig(Path configfile) noexcept + void + SetSettingsConfig(Path configfile) noexcept { settings_config = configfile; } - Path GetUpgradeConfig() noexcept + Path + GetUpgradeConfig() noexcept { return upgrade_config; } - void SetUpgradeConfig(Path configfile) noexcept + void + SetUpgradeConfig(Path configfile) noexcept { upgrade_config = configfile; } + bool + IsReal() noexcept + { + return is_real; + } + private: AllocatedPath system_config; // system config file, in the OV the // /boot/config.uEnf @@ -55,6 +65,8 @@ class OpenVarioDevice { // the OpenVarioBaseMenu AllocatedPath home_path; AllocatedPath data_path; + + bool is_real = false; }; extern OpenVarioDevice ovdevice; From 6c0b8722686112bf15b5d1c30ce6f8ba2183b644 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 10 Jan 2024 20:24:49 +0100 Subject: [PATCH 104/403] Gauge/LogoView - remove the define flags for USE_GDI. I cannot the a problem with the fonts in this configuration up to now --- src/Gauge/LogoView.cpp | 7 +++++++ src/Gauge/LogoView.hpp | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Gauge/LogoView.cpp b/src/Gauge/LogoView.cpp index ee83ca5852a..da33249586b 100644 --- a/src/Gauge/LogoView.cpp +++ b/src/Gauge/LogoView.cpp @@ -17,6 +17,8 @@ LogoView::LogoView() noexcept try { #ifndef USE_GDI font.Load(FontDescription(Layout::FontScale(10))); +#else + font.Load(FontDescription(Layout::FontScale(10))); #endif } catch (...) { /* ignore Bitmap/Font loader exceptions */ @@ -147,6 +149,11 @@ LogoView::draw(Canvas &canvas, const PixelRect &rc) noexcept if (!font.IsDefined()) return; + canvas.Select(font); +#else + if (!font.IsDefined()) + return; + canvas.Select(font); #endif diff --git a/src/Gauge/LogoView.hpp b/src/Gauge/LogoView.hpp index d8179376854..6647a0148f0 100644 --- a/src/Gauge/LogoView.hpp +++ b/src/Gauge/LogoView.hpp @@ -12,9 +12,9 @@ class Canvas; class LogoView { Bitmap logo, big_logo, title, big_title; -#ifndef USE_GDI +// #ifndef USE_GDI Font font; -#endif +// #endif public: LogoView() noexcept; From cf01f9e5f125346319288641e19f46f15d0135b0 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 10 Jan 2024 22:14:45 +0100 Subject: [PATCH 105/403] Gauge/LogoView.cpp - remove flag USE_GDI finally --- src/Gauge/LogoView.cpp | 11 ----------- src/Gauge/LogoView.hpp | 2 -- 2 files changed, 13 deletions(-) diff --git a/src/Gauge/LogoView.cpp b/src/Gauge/LogoView.cpp index da33249586b..1af74ed92aa 100644 --- a/src/Gauge/LogoView.cpp +++ b/src/Gauge/LogoView.cpp @@ -15,11 +15,7 @@ LogoView::LogoView() noexcept try :logo(IDB_LOGO), big_logo(IDB_LOGO_HD), title(IDB_TITLE), big_title(IDB_TITLE_HD) { -#ifndef USE_GDI font.Load(FontDescription(Layout::FontScale(10))); -#else - font.Load(FontDescription(Layout::FontScale(10))); -#endif } catch (...) { /* ignore Bitmap/Font loader exceptions */ } @@ -145,17 +141,10 @@ LogoView::draw(Canvas &canvas, const PixelRect &rc) noexcept // Draw full XCSoar version number -#ifndef USE_GDI - if (!font.IsDefined()) - return; - - canvas.Select(font); -#else if (!font.IsDefined()) return; canvas.Select(font); -#endif canvas.SetTextColor(COLOR_BLACK); canvas.SetBackgroundTransparent(); diff --git a/src/Gauge/LogoView.hpp b/src/Gauge/LogoView.hpp index 6647a0148f0..042f3422779 100644 --- a/src/Gauge/LogoView.hpp +++ b/src/Gauge/LogoView.hpp @@ -12,9 +12,7 @@ class Canvas; class LogoView { Bitmap logo, big_logo, title, big_title; -// #ifndef USE_GDI Font font; -// #endif public: LogoView() noexcept; From 17137bdc592daac63bd414af302af3b815f37273 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 10 Jan 2024 20:46:21 +0100 Subject: [PATCH 106/403] OpenVarioBaseMenu.cpp - change some captions --- src/OpenVario/OpenVarioBaseMenu.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/OpenVario/OpenVarioBaseMenu.cpp b/src/OpenVario/OpenVarioBaseMenu.cpp index e6f58006957..70701777d8b 100644 --- a/src/OpenVario/OpenVarioBaseMenu.cpp +++ b/src/OpenVario/OpenVarioBaseMenu.cpp @@ -228,24 +228,24 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, StartXCSoar(); }); - AddButton(_("Files"), [this]() { + AddButton(_("File Transfers"), [this]() { CancelTimer(); TWidgetDialog sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), GetLook(), - _T("OpenVario Files")); + _T("OpenVario File Transfers")); sub_dialog.SetWidget(display, event_queue, GetLook()); sub_dialog.AddButton(_("Close"), mrOK); return sub_dialog.ShowModal(); }); - AddButton(_("Test"), [this]() { + AddButton(_("System Settings"), [this]() { CancelTimer(); std::unique_ptr widget = CreateOpenVarioConfigPanel(); Profile::LoadFile(ovdevice.GetSettingsConfig()); TWidgetDialog sub_dialog( WidgetDialog::Full{}, dialog.GetMainWindow(), GetLook(), - _T("OpenVario Test")); + _T("OpenVario System Settings")); sub_dialog.SetWidget(); sub_dialog.AddButton(_("Close"), mrOK); auto ret_value = sub_dialog.ShowModal(); @@ -256,12 +256,12 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, return ret_value; }); - AddButton(_("System"), [this]() { + AddButton(_("System (Blaubart)"), [this]() { CancelTimer(); TWidgetDialog sub_dialog( WidgetDialog::Full{}, dialog.GetMainWindow(), GetLook(), - _T("OpenVario System Settings")); + _T("OpenVario System Settings (Blaubart)")); sub_dialog.SetWidget(display, event_queue, sub_dialog); sub_dialog.AddButton(_("Close"), mrOK); return sub_dialog.ShowModal(); From ef038ae9a092aaec5d2f15b278e50045b79c497d Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 10 Jan 2024 14:49:31 +0100 Subject: [PATCH 107/403] [Wifi] add WifiDialogOV (modified copy from Kobo) --- src/OpenVario/WifiDialogOV.cpp | 505 +++++++++++++++++++++++++++++++++ src/OpenVario/WifiDialogOV.hpp | 10 + 2 files changed, 515 insertions(+) create mode 100644 src/OpenVario/WifiDialogOV.cpp create mode 100644 src/OpenVario/WifiDialogOV.hpp diff --git a/src/OpenVario/WifiDialogOV.cpp b/src/OpenVario/WifiDialogOV.cpp new file mode 100644 index 00000000000..e8134c44d3e --- /dev/null +++ b/src/OpenVario/WifiDialogOV.cpp @@ -0,0 +1,505 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project + +#include "WifiDialogOV.hpp" +#include "Dialogs/WidgetDialog.hpp" +#include "Dialogs/Message.hpp" +#include "Dialogs/Error.hpp" +#include "Dialogs/TextEntry.hpp" +#include "UIGlobals.hpp" +#include "Look/DialogLook.hpp" +#include "ui/canvas/Canvas.hpp" +#include "Screen/Layout.hpp" +#include "Renderer/TwoTextRowsRenderer.hpp" +#include "Language/Language.hpp" +#include "Widget/ListWidget.hpp" +#ifdef Kobo +#include "WPASupplicant.hpp" +#endif // Kobo +#include "net/IPv4Address.hxx" +#include "ui/event/PeriodicTimer.hpp" +#include "util/HexFormat.hxx" +#include "util/StaticString.hxx" + +#ifdef KOBO +#include "Model.hpp" +#else +static const char * +GetKoboWifiInterface() noexcept +{ + /* dummy implementation for builds on (regular) Linux so KoboMenu + can be debugged there */ + return "dummy"; +} +#endif + +#ifdef Kobo +/* workaround because OpenSSL has a typedef called "UI", which clashes + with our "UI" namespace */ +#define UI OPENSSL_UI +#include // for PKCS5_PBKDF2_HMAC_SHA1() +#undef UI +#endif // Kobo + +class WifiListWidget final + : public ListWidget { + + struct NetworkInfo { + NarrowString<32> bssid; + NarrowString<256> ssid; + int signal_level; + int id; + + enum WifiSecurity security; + + bool old_visible, old_configured; + }; + + Button *connect_button; + + WifiStatus status; + TrivialArray networks; + + TwoTextRowsRenderer row_renderer; + +#ifdef Kobo + WPASupplicant wpa_supplicant; +#endif // Kobo + + UI::PeriodicTimer update_timer{[this]{ UpdateList(); }}; + +public: + void CreateButtons(WidgetDialog &dialog) { + dialog.AddButton(_("Scan"), [this](){ + try { + EnsureConnected(); +#ifdef Kobo + wpa_supplicant.Scan(); +#endif // Kobo + UpdateList(); + } catch (...) { + ShowError(std::current_exception(), _("Error")); + } + }); + + connect_button = dialog.AddButton(_("Connect"), [this](){ + try { + Connect(); + } catch (...) { + ShowError(std::current_exception(), _("Error")); + } + }); + } + + void UpdateButtons(); + + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, + const PixelRect &rc) noexcept override { + const DialogLook &look = UIGlobals::GetDialogLook(); + + CreateList(parent, look, rc, + row_renderer.CalculateLayout(look.text_font, + look.small_font)); + UpdateList(); + update_timer.Schedule(std::chrono::seconds(1)); + } + + /* virtual methods from class ListItemRenderer */ + void OnPaintItem(Canvas &canvas, const PixelRect rc, + unsigned idx) noexcept override; + + /* virtual methods from class ListCursorHandler */ + void OnCursorMoved([[maybe_unused]] unsigned index) noexcept override { + UpdateButtons(); + } + +private: + /** + * Ensure that we're connected to wpa_supplicant. + * + * Throws on error. + */ + void EnsureConnected(); + + [[gnu::pure]] + NetworkInfo *FindByID(int id) noexcept; + + [[gnu::pure]] + NetworkInfo *FindByBSSID(const char *bssid) noexcept; + + [[gnu::pure]] + NetworkInfo *FindVisibleBySSID(const char *ssid) noexcept; + +#ifdef Kobo + [[gnu::pure]] + NetworkInfo *Find(const WifiConfiguredNetworkInfo &c) noexcept; + + void MergeList(const WifiVisibleNetwork *p, unsigned n); + void Append(const WifiConfiguredNetworkInfo &src); + void Merge(const WifiConfiguredNetworkInfo &c); + void MergeList(const WifiConfiguredNetworkInfo *p, unsigned n); +#endif // Kobo + void UpdateScanResults(); + void UpdateConfigured(); + void SweepList(); + void UpdateList(); + + void Connect(); +}; + +void +WifiListWidget::UpdateButtons() +{ + const unsigned cursor = GetList().GetCursorIndex(); + + if (cursor < networks.size()) { + const auto &info = networks[cursor]; + + if (info.id >= 0) { + connect_button->SetCaption(_("Remove")); + connect_button->SetEnabled(true); + } else if (info.signal_level >= 0) { + connect_button->SetCaption(_("Connect")); + connect_button->SetEnabled(true); + } + } else { + connect_button->SetEnabled(false); + } +} + +void +WifiListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, + unsigned idx) noexcept +{ + const auto &info = networks[idx]; + + static char wifi_security[][20] = { + "WPA", + "WEP", + "Open", + }; + + row_renderer.DrawFirstRow(canvas, rc, info.ssid); + row_renderer.DrawSecondRow(canvas, rc, info.bssid); + + const TCHAR *state = nullptr; + StaticString<40> state_buffer; + + /* found the currently connected wifi network? */ + if (StringIsEqual(info.bssid, status.bssid)) { + state = _("Connected"); + + /* look up ip address for wlan0 or eth0 */ +#ifdef Kobo + const auto addr = IPv4Address::GetDeviceAddress(GetKoboWifiInterface()); + if (addr.IsDefined()) { /* valid address? */ + StaticString<40> addr_str; + if (addr.ToString(addr_str.buffer(), addr_str.capacity()) != nullptr) { + state_buffer.Format(_T("%s (%s)"), state, addr_str.c_str()); + state = state_buffer; + } + } +#endif // Kobo + } + else if (info.id >= 0) + state = info.signal_level >= 0 + ? _("Saved and visible") + : _("Saved, but not visible"); + else if (info.signal_level >= 0) + state = _("Visible"); + + if (state != nullptr) + row_renderer.DrawRightFirstRow(canvas, rc, state); + + if (info.signal_level >= 0) { + StaticString<32> text; + text.UnsafeFormat(_T("%s %u"), wifi_security[info.security], info.signal_level); + row_renderer.DrawRightSecondRow(canvas, rc, text); + } +} + +#ifdef Kobo +static void +WifiConnect(enum WifiSecurity security, WPASupplicant &wpa_supplicant, const char *ssid, const char *psk) +{ + const unsigned id = wpa_supplicant.AddNetwork(); + char *endPsk_ptr; + + wpa_supplicant.SetNetworkSSID(id, ssid); + + if (security == WPA_SECURITY) { + std::array pmk; + PKCS5_PBKDF2_HMAC_SHA1(psk, strlen(psk), + (const unsigned char *)ssid, strlen(ssid), + 4096, + pmk.size(), (unsigned char *)pmk.data()); + + std::array hex; + *HexFormat(hex.data(), pmk) = 0; + + wpa_supplicant.SetNetworkPSK(id, hex.data()); + } else if (security == WEP_SECURITY) { + wpa_supplicant.SetNetworkID(id, "key_mgmt", "NONE"); + + /* + * If psk is all hexidecimal should SetNetworkID, assuming user provided key in hex. + * Use strtoll to confirm the psk is entirely in hex. + * Also to need to check that it does not begin with 0x which WPA supplicant does not like. + */ + + (void) strtoll(psk, &endPsk_ptr, 16); + + if ((*endPsk_ptr == '\0') && // confirm strtoll processed all of psk + (strlen(psk) >= 2) && (psk[0] != '0') && (psk[1] != 'x')) // and the first two characters were no "0x" + wpa_supplicant.SetNetworkID(id, "wep_key0", psk); + else + wpa_supplicant.SetNetworkString(id, "wep_key0", psk); + + wpa_supplicant.SetNetworkID(id, "auth_alg", "OPEN\tSHARED"); + } else if (security == OPEN_SECURITY){ + wpa_supplicant.SetNetworkID(id, "key_mgmt", "NONE"); + } else + throw std::runtime_error{"Unsupported Wifi security type"}; + + wpa_supplicant.EnableNetwork(id); + wpa_supplicant.SaveConfig(); +} +#endif // Kobo + +inline void +WifiListWidget::Connect() +{ + EnsureConnected(); + +#ifdef Kobo + const unsigned i = GetList().GetCursorIndex(); + if (i >= networks.size()) + return; + + const auto &info = networks[i]; + if (info.id < 0) { + const auto ssid = info.ssid; + + StaticString<256> caption; + caption.Format(_("Passphrase of network '%s'"), ssid.c_str()); + + StaticString<32> passphrase; + passphrase.clear(); + if (info.security == OPEN_SECURITY) + passphrase.clear(); + else if (!TextEntryDialog(passphrase, caption, false)) + return; + + WifiConnect(info.security, wpa_supplicant, info.ssid, passphrase); + } else { + wpa_supplicant.RemoveNetwork(info.id); + wpa_supplicant.SaveConfig(); +#endif // Kobo + } + + UpdateList(); +} + +void +WifiListWidget::EnsureConnected() +{ +#ifdef Kobo + char path[64]; + sprintf(path, "/var/run/wpa_supplicant/%s", GetKoboWifiInterface()); + wpa_supplicant.EnsureConnected(path); +#endif // Kobo +} + +inline WifiListWidget::NetworkInfo * +WifiListWidget::FindByID(int id) noexcept +{ + auto f = std::find_if(networks.begin(), networks.end(), + [id](const NetworkInfo &info) { + return info.id == id; + }); + if (f == networks.end()) + return nullptr; + + return f; +} + +WifiListWidget::NetworkInfo * +WifiListWidget::FindByBSSID(const char *bssid) noexcept +{ + auto f = std::find_if(networks.begin(), networks.end(), + [bssid](const NetworkInfo &info) { + return info.bssid == bssid; + }); + if (f == networks.end()) + return nullptr; + + return f; +} + +WifiListWidget::NetworkInfo * +WifiListWidget::FindVisibleBySSID(const char *ssid) noexcept +{ + auto f = std::find_if(networks.begin(), networks.end(), + [ssid](const NetworkInfo &info) { + return info.signal_level >= 0 && info.ssid == ssid; + }); + if (f == networks.end()) + return nullptr; + + return f; +} + +inline void +WifiListWidget::MergeList(const WifiVisibleNetwork *p, unsigned n) +{ + for (unsigned i = 0; i < unsigned(n); ++i) { + const auto &found = p[i]; + + auto info = FindByBSSID(found.bssid); + if (info == nullptr) { + info = &networks.append(); + info->bssid = found.bssid; + info->id = -1; + } + + info->ssid = found.ssid; + info->signal_level = found.signal_level; + info->security = found.security; + info->old_visible = false; + } +} + +inline void +WifiListWidget::UpdateScanResults() +{ + WifiVisibleNetwork *buffer = new WifiVisibleNetwork[networks.capacity()]; + +#ifdef Kobo + int n = wpa_supplicant.ScanResults(buffer, networks.capacity()); + if (n >= 0) + MergeList(buffer, n); +#endif // Kobo + + delete[] buffer; +} + +inline WifiListWidget::NetworkInfo * +WifiListWidget::Find(const WifiConfiguredNetworkInfo &c) noexcept +{ + auto found = FindByID(c.id); + if (found != nullptr) + return found; + + return c.bssid == "any" + ? FindVisibleBySSID(c.ssid) + : FindByBSSID(c.bssid); +} + +inline void +WifiListWidget::Append(const WifiConfiguredNetworkInfo &src) +{ + auto &dest = networks.append(); + dest.bssid = src.bssid; + dest.ssid = src.ssid; + dest.id = src.id; + dest.signal_level = -1; + dest.old_configured = false; +} + +inline void +WifiListWidget::Merge(const WifiConfiguredNetworkInfo &c) +{ + auto found = Find(c); + if (found != nullptr) { + found->id = c.id; + found->old_configured = false; + } else + Append(c); +} + +inline void +WifiListWidget::MergeList(const WifiConfiguredNetworkInfo *p, unsigned n) +{ + for (unsigned i = 0; i < unsigned(n); ++i) + Merge(p[i]); +} + +inline void +WifiListWidget::UpdateConfigured() +{ + WifiConfiguredNetworkInfo *buffer = + new WifiConfiguredNetworkInfo[networks.capacity()]; +#ifdef Kobo + int n = wpa_supplicant.ListNetworks(buffer, networks.capacity()); + if (n >= 0) + MergeList(buffer, n); +#endif // Kobo + + delete[] buffer; +} + +inline void +WifiListWidget::SweepList() +{ + unsigned cursor = GetList().GetCursorIndex(); + + for (int i = networks.size() - 1; i >= 0; --i) { + NetworkInfo &info = networks[i]; + + if (info.old_visible && info.old_configured) { + networks.remove(i); + if (cursor > unsigned(i)) + --cursor; + } else { + if (info.old_visible) + info.signal_level = -1; + + if (info.old_configured) + info.id = -1; + } + } + + GetList().SetCursorIndex(cursor); +} + +void +WifiListWidget::UpdateList() +{ + status.Clear(); + + try { + EnsureConnected(); +#ifdef Kobo + wpa_supplicant.Status(status); +#endif // Kobo + + for (auto &i : networks) + i.old_visible = i.old_configured = true; + + UpdateScanResults(); + UpdateConfigured(); + + /* remove items that are still marked as "old" */ + SweepList(); + } catch (...) { + networks.clear(); + } + + GetList().SetLength(networks.size()); + + UpdateButtons(); +} + +void +ShowWifiDialog() +{ + const DialogLook &look = UIGlobals::GetDialogLook(); + TWidgetDialog + dialog(WidgetDialog::Full{}, UIGlobals::GetMainWindow(), + look, _("Wifi")); + dialog.AddButton(_("Close"), mrOK); + dialog.SetWidget(); + dialog.GetWidget().CreateButtons(dialog); + dialog.ShowModal(); +} diff --git a/src/OpenVario/WifiDialogOV.hpp b/src/OpenVario/WifiDialogOV.hpp new file mode 100644 index 00000000000..bb4ba8ae355 --- /dev/null +++ b/src/OpenVario/WifiDialogOV.hpp @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project + +#pragma once + +class SingleWindow; +struct DialogLook; + +void +ShowWifiDialog(); From 94629734a0bf57b47c2dd718276e4ccfb8b7721d Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 15 Apr 2024 10:21:47 +0200 Subject: [PATCH 108/403] [build] ok.mk - insert macro PROGRAM_VERSION, add missing Wifi files --- build/ov.mk | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/build/ov.mk b/build/ov.mk index 01e303b3017..00cb653cdb6 100644 --- a/build/ov.mk +++ b/build/ov.mk @@ -1,3 +1,13 @@ +CONFIG = $(topdir)/OpenSoar.config +include $(CONFIG) + +# w/o VERSION.txt: +ifeq ($(PROGRAM_VERSION),"") + # take the version from XCSoar VERSION.txt + PROGRAM_VERSION = $(strip $(shell cat $(topdir)/VERSION.txt)) +endif +EXTRA_CPPFLAGS+= -DPROGRAM_VERSION=\"$(PROGRAM_VERSION)\" + EXTRA_CPPFLAGS+=-DIS_OPENVARIO DIALOG_SOURCES = \ @@ -185,8 +195,10 @@ OV_MENU_SOURCES = \ $(SRC)/OpenVario/System/Setting/SensordWidget.cpp \ $(SRC)/OpenVario/System/Setting/WifiWidget.cpp \ \ - $(SRC)/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp \ - \ + $(SRC)/OpenVario/WifiDialogOV.cpp \ + \ + $(SRC)/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp \ + \ $(SRC)/Version.cpp \ $(SRC)/Asset.cpp \ $(SRC)/Formatter/HexColor.cpp \ From 25e1158fe4acc4c48e896e0ad7a6d2b44ee83a2f Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 15 Apr 2024 10:22:20 +0200 Subject: [PATCH 109/403] [CMake] add missing Wifi files --- src/OpenVario/CMakeSource.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/OpenVario/CMakeSource.cmake b/src/OpenVario/CMakeSource.cmake index 97e14d228bd..2ec62ccc2e4 100644 --- a/src/OpenVario/CMakeSource.cmake +++ b/src/OpenVario/CMakeSource.cmake @@ -9,6 +9,8 @@ set(_SOURCES OpenVario/System/SystemMenuWidget.cpp OpenVario/System/SystemSettingsWidget.cpp + OpenVario/WifiDialogOV.cpp + ${SRC}/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp ${SRC}/Version.cpp From 315a4ac9912ad08ef477ee7dde8d2fc202e30b02 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 10 Jan 2024 20:17:48 +0100 Subject: [PATCH 110/403] add WifiDialog in folder OpenVario/System to the OpenVarioBaseMenu * remove the files in the root * this is a copy from Kobo, with disabling the WPA authenticator, but very similar to this * the challange is the swapping the code from WPASupplicant to ConnMan --- src/OpenVario/{ => System}/WifiDialogOV.cpp | 64 ++-- src/OpenVario/{ => System}/WifiDialogOV.hpp | 0 src/OpenVario/System/WifiSupplicantOV.cpp | 381 ++++++++++++++++++++ src/OpenVario/System/WifiSupplicantOV.hpp | 135 +++++++ 4 files changed, 553 insertions(+), 27 deletions(-) rename src/OpenVario/{ => System}/WifiDialogOV.cpp (92%) rename src/OpenVario/{ => System}/WifiDialogOV.hpp (100%) create mode 100644 src/OpenVario/System/WifiSupplicantOV.cpp create mode 100644 src/OpenVario/System/WifiSupplicantOV.hpp diff --git a/src/OpenVario/WifiDialogOV.cpp b/src/OpenVario/System/WifiDialogOV.cpp similarity index 92% rename from src/OpenVario/WifiDialogOV.cpp rename to src/OpenVario/System/WifiDialogOV.cpp index e8134c44d3e..d9d4c2f4487 100644 --- a/src/OpenVario/WifiDialogOV.cpp +++ b/src/OpenVario/System/WifiDialogOV.cpp @@ -1,7 +1,8 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright The XCSoar Project -#include "WifiDialogOV.hpp" +#include "OpenVario/System/WifiDialogOV.hpp" +#include "OpenVario/System/WifiSupplicantOV.hpp" #include "Dialogs/WidgetDialog.hpp" #include "Dialogs/Message.hpp" #include "Dialogs/Error.hpp" @@ -13,14 +14,12 @@ #include "Renderer/TwoTextRowsRenderer.hpp" #include "Language/Language.hpp" #include "Widget/ListWidget.hpp" -#ifdef Kobo -#include "WPASupplicant.hpp" -#endif // Kobo #include "net/IPv4Address.hxx" #include "ui/event/PeriodicTimer.hpp" #include "util/HexFormat.hxx" #include "util/StaticString.hxx" + #ifdef KOBO #include "Model.hpp" #else @@ -33,13 +32,13 @@ GetKoboWifiInterface() noexcept } #endif -#ifdef Kobo +#ifdef WithWPA /* workaround because OpenSSL has a typedef called "UI", which clashes with our "UI" namespace */ #define UI OPENSSL_UI #include // for PKCS5_PBKDF2_HMAC_SHA1() #undef UI -#endif // Kobo +#endif // WithWPA class WifiListWidget final : public ListWidget { @@ -58,13 +57,12 @@ class WifiListWidget final Button *connect_button; WifiStatus status; + TrivialArray networks; TwoTextRowsRenderer row_renderer; -#ifdef Kobo WPASupplicant wpa_supplicant; -#endif // Kobo UI::PeriodicTimer update_timer{[this]{ UpdateList(); }}; @@ -73,9 +71,7 @@ class WifiListWidget final dialog.AddButton(_("Scan"), [this](){ try { EnsureConnected(); -#ifdef Kobo wpa_supplicant.Scan(); -#endif // Kobo UpdateList(); } catch (...) { ShowError(std::current_exception(), _("Error")); @@ -131,7 +127,6 @@ class WifiListWidget final [[gnu::pure]] NetworkInfo *FindVisibleBySSID(const char *ssid) noexcept; -#ifdef Kobo [[gnu::pure]] NetworkInfo *Find(const WifiConfiguredNetworkInfo &c) noexcept; @@ -139,7 +134,6 @@ class WifiListWidget final void Append(const WifiConfiguredNetworkInfo &src); void Merge(const WifiConfiguredNetworkInfo &c); void MergeList(const WifiConfiguredNetworkInfo *p, unsigned n); -#endif // Kobo void UpdateScanResults(); void UpdateConfigured(); void SweepList(); @@ -180,8 +174,13 @@ WifiListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, "Open", }; +#ifdef WithWPA row_renderer.DrawFirstRow(canvas, rc, info.ssid); row_renderer.DrawSecondRow(canvas, rc, info.bssid); +#else + row_renderer.DrawFirstRow(canvas, rc, L"info.ssid"); // TODO(August2111) + row_renderer.DrawSecondRow(canvas, rc, L"info.bssid"); // TODO(August2111) +#endif // WithWPA const TCHAR *state = nullptr; StaticString<40> state_buffer; @@ -191,7 +190,7 @@ WifiListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, state = _("Connected"); /* look up ip address for wlan0 or eth0 */ -#ifdef Kobo +#ifdef WithWPA const auto addr = IPv4Address::GetDeviceAddress(GetKoboWifiInterface()); if (addr.IsDefined()) { /* valid address? */ StaticString<40> addr_str; @@ -200,7 +199,7 @@ WifiListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, state = state_buffer; } } -#endif // Kobo +#endif // WithWPA } else if (info.id >= 0) state = info.signal_level >= 0 @@ -218,8 +217,8 @@ WifiListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, row_renderer.DrawRightSecondRow(canvas, rc, text); } } +// #endif -#ifdef Kobo static void WifiConnect(enum WifiSecurity security, WPASupplicant &wpa_supplicant, const char *ssid, const char *psk) { @@ -229,6 +228,7 @@ WifiConnect(enum WifiSecurity security, WPASupplicant &wpa_supplicant, const cha wpa_supplicant.SetNetworkSSID(id, ssid); if (security == WPA_SECURITY) { +#ifdef WithWPA std::array pmk; PKCS5_PBKDF2_HMAC_SHA1(psk, strlen(psk), (const unsigned char *)ssid, strlen(ssid), @@ -239,6 +239,7 @@ WifiConnect(enum WifiSecurity security, WPASupplicant &wpa_supplicant, const cha *HexFormat(hex.data(), pmk) = 0; wpa_supplicant.SetNetworkPSK(id, hex.data()); +#endif // WithWPA } else if (security == WEP_SECURITY) { wpa_supplicant.SetNetworkID(id, "key_mgmt", "NONE"); @@ -265,14 +266,12 @@ WifiConnect(enum WifiSecurity security, WPASupplicant &wpa_supplicant, const cha wpa_supplicant.EnableNetwork(id); wpa_supplicant.SaveConfig(); } -#endif // Kobo inline void WifiListWidget::Connect() { EnsureConnected(); -#ifdef Kobo const unsigned i = GetList().GetCursorIndex(); if (i >= networks.size()) return; @@ -291,11 +290,15 @@ WifiListWidget::Connect() else if (!TextEntryDialog(passphrase, caption, false)) return; +#ifdef WithWPA WifiConnect(info.security, wpa_supplicant, info.ssid, passphrase); +#else // WithWPA + WifiConnect(info.security, wpa_supplicant, info.ssid, + "ConvertWideToUTF8(passphrase.c_str()).c_str()"); // TODO(August2111) +#endif // WithWPA } else { wpa_supplicant.RemoveNetwork(info.id); wpa_supplicant.SaveConfig(); -#endif // Kobo } UpdateList(); @@ -304,17 +307,16 @@ WifiListWidget::Connect() void WifiListWidget::EnsureConnected() { -#ifdef Kobo char path[64]; sprintf(path, "/var/run/wpa_supplicant/%s", GetKoboWifiInterface()); wpa_supplicant.EnsureConnected(path); -#endif // Kobo } inline WifiListWidget::NetworkInfo * WifiListWidget::FindByID(int id) noexcept { - auto f = std::find_if(networks.begin(), networks.end(), +#ifdef WithWPA // TODO(August2111) + auto f = std::find_if(networks.begin(), networks.end() [id](const NetworkInfo &info) { return info.id == id; }); @@ -322,11 +324,16 @@ WifiListWidget::FindByID(int id) noexcept return nullptr; return f; +#else // WithWPA + WifiListWidget::NetworkInfo f; + return &f; +#endif // WithWPA } WifiListWidget::NetworkInfo * WifiListWidget::FindByBSSID(const char *bssid) noexcept { +#ifdef WithWPA // TODO(August2111) auto f = std::find_if(networks.begin(), networks.end(), [bssid](const NetworkInfo &info) { return info.bssid == bssid; @@ -335,11 +342,16 @@ WifiListWidget::FindByBSSID(const char *bssid) noexcept return nullptr; return f; +#else // WithWPA + WifiListWidget::NetworkInfo f; + return &f; +#endif // WithWPA } WifiListWidget::NetworkInfo * WifiListWidget::FindVisibleBySSID(const char *ssid) noexcept { +#ifdef WithWPA // TODO(August2111) auto f = std::find_if(networks.begin(), networks.end(), [ssid](const NetworkInfo &info) { return info.signal_level >= 0 && info.ssid == ssid; @@ -348,6 +360,10 @@ WifiListWidget::FindVisibleBySSID(const char *ssid) noexcept return nullptr; return f; +#else // WithWPA + WifiListWidget::NetworkInfo f; + return &f; +#endif // WithWPA } inline void @@ -375,11 +391,9 @@ WifiListWidget::UpdateScanResults() { WifiVisibleNetwork *buffer = new WifiVisibleNetwork[networks.capacity()]; -#ifdef Kobo int n = wpa_supplicant.ScanResults(buffer, networks.capacity()); if (n >= 0) MergeList(buffer, n); -#endif // Kobo delete[] buffer; } @@ -430,11 +444,9 @@ WifiListWidget::UpdateConfigured() { WifiConfiguredNetworkInfo *buffer = new WifiConfiguredNetworkInfo[networks.capacity()]; -#ifdef Kobo int n = wpa_supplicant.ListNetworks(buffer, networks.capacity()); if (n >= 0) MergeList(buffer, n); -#endif // Kobo delete[] buffer; } @@ -470,9 +482,7 @@ WifiListWidget::UpdateList() try { EnsureConnected(); -#ifdef Kobo wpa_supplicant.Status(status); -#endif // Kobo for (auto &i : networks) i.old_visible = i.old_configured = true; diff --git a/src/OpenVario/WifiDialogOV.hpp b/src/OpenVario/System/WifiDialogOV.hpp similarity index 100% rename from src/OpenVario/WifiDialogOV.hpp rename to src/OpenVario/System/WifiDialogOV.hpp diff --git a/src/OpenVario/System/WifiSupplicantOV.cpp b/src/OpenVario/System/WifiSupplicantOV.cpp new file mode 100644 index 00000000000..2cee67e2f61 --- /dev/null +++ b/src/OpenVario/System/WifiSupplicantOV.cpp @@ -0,0 +1,381 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project + +#include "OpenVario/System/WifiSupplicantOV.hpp" +#include "lib/fmt/ToBuffer.hxx" +#include "lib/fmt/SystemError.hxx" +#include "net/AllocatedSocketAddress.hxx" +#include "util/IterableSplitString.hxx" +#include "util/NumberParser.hxx" +#include "util/SpanCast.hxx" +#include "util/StringSplit.hxx" + +#include +#include +#include + +using std::string_view_literals::operator""sv; + +void +WPASupplicant::Connect(const char *path) +{ + Close(); + + AllocatedSocketAddress peer_address; +#ifdef WithWPA + peer_address.SetLocal(path); + + if (!fd.Create(AF_LOCAL, SOCK_DGRAM, 0)) + throw MakeErrno("Failed to create socket"); + + if (!fd.AutoBind()) + throw MakeErrno("Failed to bind socket"); + + if (!fd.Connect(peer_address)) + throw FmtErrno("Failed to connect to {}", path); +#endif +} + +void +WPASupplicant::Close() noexcept +{ + if (fd.IsDefined()) + fd.Close(); +} + +void +WPASupplicant::SendCommand(std::string_view cmd) +{ + /* discard any previous responses that may be left in the socket's + receive queue, maybe because the last command failed */ + ReadDiscard(); + + const ssize_t nbytes = fd.Write(AsBytes(cmd)); + if (nbytes < 0) + throw MakeErrno("Failed to send command to wpa_supplicant"); + + if (std::size_t(nbytes) != cmd.size()) + throw std::runtime_error("Short send to wpa_supplicant"); +} + +void +WPASupplicant::ExpectResponse(std::string_view expected) +{ + char buffer[4096]; + assert(expected.size() <= sizeof(buffer)); + + if (ReadStringTimeout(buffer) != expected) + throw std::runtime_error{"Unexpected wpa_supplicant response"}; +} + +static bool +ParseStatusLine(WifiStatus &status, std::string_view src) noexcept +{ + const auto [name, value] = Split(src, '='); + if (value.data() == nullptr) + return false; + + if (name == "bssid"sv) + status.bssid = value; + else if (name == "ssid"sv) + status.ssid = value; + return true; +} + +static bool +ParseStatus(WifiStatus &status, std::string_view src) noexcept +{ + status.Clear(); + + for (const auto line : IterableSplitString(src, '\n')) + ParseStatusLine(status, line); + + return true; +} + +bool +WPASupplicant::Status(WifiStatus &status) +{ + SendCommand("STATUS"); + + char buffer[4096]; + const auto src = ReadStringTimeout(buffer); + if (src.empty()) + throw std::runtime_error{"wpa_supplicant closed the socket"}; + + return ParseStatus(status, src); +} + +/* + * Scan Results look like: + * bssid frequency signal_level flags ssid + * bc:14:01:e1:d6:78 2412 178 [WPA-PSK-TKIP+CCMP][WPA2-PSK-TKIP+CCMP][WPS][ESS] FunnyMaple + * 00:22:a4:b8:f3:31 2437 185 [WEP][ESS] BELL778 + * 98:fc:11:3e:58:ea 2462 169 [WPA-PSK-TKIP+CCMP][WPA2-PSK-TKIP+CCMP][WPS][ESS] Cisco54414 + * bc:14:01:e1:d6:79 2412 176 [WPA2-PSK-CCMP][ESS] + * 44:94:fc:36:22:48 2412 173 [WPA2-PSK-CCMP][WPS][ESS] NETGEAR14 + * + * Fields are delimited by single tabs. + * + * Items of interest which are: + * - bssid binary ssid + * - signal_level a number, bigger is better. + * - network type. A wireless router may support one or all of WEP, WPA, and WPA2. + * WPA and WPA2 are handled the same. WPA/WPA2 are preferred over WEP. + * - ssid ascii ssid. ssid could be empty if ssid broadcast is disabled. + */ +static bool +ParseScanResultsLine(WifiVisibleNetwork &dest, std::string_view line) noexcept +{ + const auto [bssid, rest1] = Split(line, '\t'); + const auto [frequency, rest2] = Split(rest1, '\t'); + const auto [signal_level, rest3] = Split(rest2, '\t'); + const auto [flags, rest4] = Split(rest3, '\t'); + const auto [ssid, _] = Split(rest4, '\t'); + + if (bssid.empty() || frequency.empty() || signal_level.empty() || ssid.empty()) + return false; + + dest.bssid = bssid; + + if (const auto value = ParseInteger(signal_level)) + dest.signal_level = *value; + else + return false; + + if (flags.find("WPA"sv) != flags.npos) + dest.security = WPA_SECURITY; + else if (flags.find("WEP"sv) != flags.npos) + dest.security = WEP_SECURITY; + else + dest.security = OPEN_SECURITY; + + dest.ssid = ssid; + return true; +} + +static std::size_t +ParseScanResults(WifiVisibleNetwork *dest, std::size_t max, std::string_view src) +{ + if (!src.starts_with("bssid"sv)) + throw std::runtime_error{"Malformed wpa_supplicant response"}; + + src = Split(src, '\n').second; + if (src.data() == nullptr) + throw std::runtime_error{"Malformed wpa_supplicant response"}; + + std::size_t n = 0; + for (const auto line : IterableSplitString(src, '\n')) { + if (line.empty()) + break; + + if (!ParseScanResultsLine(dest[n], line)) + break; + + // skip hidden ssid + if (!dest[n].ssid.empty()) { + ++n; + + if (n >= max) + break; + } + } + + return n; +} + +std::size_t +WPASupplicant::ScanResults(WifiVisibleNetwork *dest, unsigned max) +{ + assert(dest != nullptr); + assert(max > 0); + + SendCommand("SCAN_RESULTS"); + + char buffer[4096]; + const auto src = ReadStringTimeout(buffer); + if (src.empty()) + throw std::runtime_error{"wpa_supplicant closed the socket"}; + + return ParseScanResults(dest, max, src); +} + +unsigned +WPASupplicant::AddNetwork() +{ + SendCommand("ADD_NETWORK"); + + char buffer[4096]; + const auto line = ExpectLineTimeout(buffer); + + if (auto id = ParseInteger(line)) + return *id; + + throw std::runtime_error{"Malformed wpa_supplicant response"}; +} + +void +WPASupplicant::SetNetworkString(unsigned id, + const char *name, const char *value) +{ + SendCommand(FmtBuffer<512>("SET_NETWORK {} {} \"{}\"", id, name, value).c_str()); + ExpectOK(); +} + +void +WPASupplicant::SetNetworkID(unsigned id, + const char *name, const char *value) +{ + SendCommand(FmtBuffer<512>("SET_NETWORK {} {} {}", id, name, value).c_str()); + ExpectOK(); +} + +void +WPASupplicant::SelectNetwork(unsigned id) +{ + SendCommand(FmtBuffer<64>("SELECT_NETWORK {}", id).c_str()); + ExpectOK(); +} + +void +WPASupplicant::EnableNetwork(unsigned id) +{ + SendCommand(FmtBuffer<64>("ENABLE_NETWORK {}", id).c_str()); + ExpectOK(); +} + +void +WPASupplicant::DisableNetwork(unsigned id) +{ + SendCommand(FmtBuffer<64>("DISABLE_NETWORK {}", id).c_str()); + ExpectOK(); +} + +void +WPASupplicant::RemoveNetwork(unsigned id) +{ + SendCommand(FmtBuffer<64>("REMOVE_NETWORK {}", id).c_str()); + ExpectOK(); +} + +static bool +ParseListResultsLine(WifiConfiguredNetworkInfo &dest, std::string_view line) +{ + const auto [id, rest1] = Split(line, '\t'); + const auto [ssid, rest2] = Split(rest1, '\t'); + const auto [bssid, _] = Split(rest2, '\t'); + + if (ssid.data() == nullptr || bssid.data() == nullptr) + return false; + + if (const auto value = ParseInteger(id)) + dest.id = *value; + else + return false; + + dest.ssid = ssid; + dest.bssid = bssid; + return true; +} + +static std::size_t +ParseListResults(WifiConfiguredNetworkInfo *dest, std::size_t max, std::string_view src) +{ + if (!src.starts_with("network id"sv)) + throw std::runtime_error{"Malformed wpa_supplicant response"}; + + src = Split(src, '\n').second; + if (src.data() == nullptr) + throw std::runtime_error{"Malformed wpa_supplicant response"}; + + std::size_t n = 0; + for (const auto line : IterableSplitString(src, '\n')) { + if (line.empty()) + break; + + if (!ParseListResultsLine(dest[n], line)) + break; + + ++n; + if (n >= max) + break; + } + + return n; +} + +std::size_t +WPASupplicant::ListNetworks(WifiConfiguredNetworkInfo *dest, std::size_t max) +{ + assert(dest != nullptr); + assert(max > 0); + + SendCommand("LIST_NETWORKS"); + + char buffer[4096]; + const auto src = ReadStringTimeout(buffer); + if (src.empty()) + throw std::runtime_error{"Malformed wpa_supplicant response"}; + + return ParseListResults(dest, max, src); +} + +void +WPASupplicant::ReadDiscard() noexcept +{ + std::byte buffer[4096]; + + while (fd.ReadNoWait(buffer) > 0) {} +} + +std::size_t +WPASupplicant::ReadTimeout(std::span dest, int timeout_ms) +{ + /* TODO: this is a kludge, because SocketDescriptor::Read() + hard-codes MSG_DONTWAIT; we would be better off moving all of + this into an IOLoop/IOThread */ + + ssize_t nbytes = fd.ReadNoWait(dest); + if (nbytes < 0) { + const int e = errno; + if (e != EAGAIN) + throw MakeErrno(e, "Failed to receive response from wpa_supplicant"); + + const int r = fd.WaitReadable(timeout_ms); + if (r < 0) + throw MakeErrno("Failed to receive response from wpa_supplicant"); + + if (r == 0) + throw std::runtime_error{"Timeout waiting for wpa_supplicant response"}; + + nbytes = fd.Read(dest); + } + + if (nbytes < 0) + throw MakeErrno("Failed to receive response from wpa_supplicant"); + + if (nbytes == 0) { + fd.Close(); + throw std::runtime_error{"Connection to wpa_supplicant closed"}; + } + + return nbytes; +} + +std::string_view +WPASupplicant::ReadStringTimeout(std::span buffer, int timeout_ms) +{ + std::size_t nbytes = ReadTimeout(std::as_writable_bytes(buffer), timeout_ms); + return ToStringView(buffer.first(nbytes)); +} + +std::string_view +WPASupplicant::ExpectLineTimeout(std::span buffer, int timeout_ms) +{ + std::string_view result = ReadStringTimeout(buffer, timeout_ms); + if (!result.ends_with('\n')) + throw std::runtime_error{"Unexpected wpa_supplicant response"}; + + result.remove_suffix(1); + return result; +} diff --git a/src/OpenVario/System/WifiSupplicantOV.hpp b/src/OpenVario/System/WifiSupplicantOV.hpp new file mode 100644 index 00000000000..15bb6c61b32 --- /dev/null +++ b/src/OpenVario/System/WifiSupplicantOV.hpp @@ -0,0 +1,135 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project + +#pragma once + +#include "util/StaticString.hxx" +#include "net/SocketDescriptor.hxx" + +#include +#include +#include + +enum WifiSecurity { + WPA_SECURITY, + WEP_SECURITY, + OPEN_SECURITY, +}; + +struct WifiStatus { + NarrowString<32> bssid; + NarrowString<256> ssid; + + void Clear() { + bssid.clear(); + ssid.clear(); + } +}; + +struct WifiVisibleNetwork { + NarrowString<32> bssid; + NarrowString<256> ssid; + unsigned signal_level; + enum WifiSecurity security; +}; + +struct WifiConfiguredNetworkInfo { + int id; + NarrowString<32> bssid; + NarrowString<256> ssid; +}; + +/** + * All methods that are not `noexcept` throw on error. + */ +class WPASupplicant { + SocketDescriptor fd; + +public: + WPASupplicant() noexcept:fd(SocketDescriptor::Undefined()) {} + + ~WPASupplicant() noexcept { + Close(); + } + + [[gnu::pure]] + bool IsConnected() const noexcept { + // TODO: what if the socket is broken? + return fd.IsDefined(); + } + + /** + * Throws on error. + */ + void Connect(const char *path); + + void EnsureConnected(const char *path) { + if (!IsConnected()) + Connect(path); + } + + void Close() noexcept; + + void SendCommand(std::string_view cmd); + + void ExpectResponse(std::string_view expected); + + void ExpectOK() { + ExpectResponse("OK\n"); + } + + void SaveConfig() { + SendCommand("SAVE_CONFIG"); + ExpectOK(); + } + + bool Status(WifiStatus &status); + + void Scan() { + SendCommand("SCAN"); + ExpectOK(); + } + + /** + * @return the number of networks + */ + std::size_t ScanResults(WifiVisibleNetwork *dest, unsigned max); + + /** + * @return the network id + */ + unsigned AddNetwork(); + + void SetNetworkString(unsigned id, const char *name, const char *value); + + void SetNetworkID(unsigned id, const char *name, const char *value); + + void SetNetworkSSID(unsigned id, const char *ssid) { + SetNetworkString(id, "ssid", ssid); + } + + void SetNetworkPSK(unsigned id, const char *psk) { + SetNetworkID(id, "psk", psk); + } + + void SelectNetwork(unsigned id); + void EnableNetwork(unsigned id); + void DisableNetwork(unsigned id); + void RemoveNetwork(unsigned id); + + /** + * Throws on error. + * + * @return the number of networks + */ + std::size_t ListNetworks(WifiConfiguredNetworkInfo *dest, std::size_t max); + +private: + void ReadDiscard() noexcept; + + std::size_t ReadTimeout(std::span dest, int timeout_ms=2000); + + std::string_view ReadStringTimeout(std::span buffer, int timeout_ms=2000); + + std::string_view ExpectLineTimeout(std::span buffer, int timeout_ms=2000); +}; From 59a43159192ce21c8c8482e74987b83b0fee7be6 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 15 Apr 2024 11:47:31 +0200 Subject: [PATCH 111/403] [build] add WifiDialog to OpenVario --- build/ov.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/ov.mk b/build/ov.mk index 00cb653cdb6..77f8d87bb15 100644 --- a/build/ov.mk +++ b/build/ov.mk @@ -195,7 +195,8 @@ OV_MENU_SOURCES = \ $(SRC)/OpenVario/System/Setting/SensordWidget.cpp \ $(SRC)/OpenVario/System/Setting/WifiWidget.cpp \ \ - $(SRC)/OpenVario/WifiDialogOV.cpp \ + $(SRC)/OpenVario/System/WifiDialogOV.cpp \ + $(SRC)/OpenVario/System/WifiSupplicantOV.cpp \ \ $(SRC)/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp \ \ From 8a0bec8a2babc1dbcc42072af6df1c89fe8be505 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 15 Apr 2024 11:47:55 +0200 Subject: [PATCH 112/403] [CMake] add WifiDialog To OpenVario --- src/Device/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Device/CMakeLists.txt b/src/Device/CMakeLists.txt index 0ac980fbd75..4fb8a09d376 100644 --- a/src/Device/CMakeLists.txt +++ b/src/Device/CMakeLists.txt @@ -8,6 +8,11 @@ endif() include(CMakeSource.cmake) # organize the files in subdirectories +if(MSVC) + # in device driver could be found characters f.e. fro german codepage + # (f.e. VOLKSLOGGER) - surpress this warnings: + add_compile_options(/wd4828) # "|": unsichere Kombination von Typ "bool" mit Typ "int" in einer Operation +endif() set(SOURCE_FILES ) foreach(source_file ${_SOURCES}) From 063bc453251070264584833f4c84a66f36546339 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 10 Jan 2024 20:18:44 +0100 Subject: [PATCH 113/403] [CMake] update OpenVarioBaseMenu --- src/OpenVario/CMakeSource.cmake | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/OpenVario/CMakeSource.cmake b/src/OpenVario/CMakeSource.cmake index 2ec62ccc2e4..f05ef3238b0 100644 --- a/src/OpenVario/CMakeSource.cmake +++ b/src/OpenVario/CMakeSource.cmake @@ -8,8 +8,16 @@ set(_SOURCES OpenVario/System/SystemMenuWidget.cpp OpenVario/System/SystemSettingsWidget.cpp + OpenVario/System/Setting/RotationWidget.cpp + OpenVario/System/Setting/BrightnessWidget.cpp + OpenVario/System/Setting/TimeoutWidget.cpp + OpenVario/System/Setting/SSHWidget.cpp + OpenVario/System/Setting/VariodWidget.cpp + OpenVario/System/Setting/SensordWidget.cpp + OpenVario/System/Setting/WifiWidget.cpp - OpenVario/WifiDialogOV.cpp + OpenVario/System/WifiDialogOV.cpp + OpenVario/System/WifiSupplicantOV.cpp ${SRC}/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp @@ -37,6 +45,7 @@ set(_SOURCES ${SRC}/Dialogs/TextEntry.cpp ${SRC}/Dialogs/KnobTextEntry.cpp ${SRC}/Dialogs/TouchTextEntry.cpp + # ov.mk: ${SRC}/Dialogs/ProcessDialog.cpp ${SRC}/Profile/Map.cpp ${SRC}/Profile/File.cpp ${SRC}/Profile/NumericValue.cpp @@ -91,6 +100,10 @@ list(APPEND _SOURCES ${SRC}/ResourceLoader.cpp +### ${SRC}/Dialogs/ProcessDialog.cpp +### ${SRC}/Kobo/FakeSymbols.cpp +### ${SRC}/ui/control/TerminalWindow.cpp + ${SRC}/Interface.cpp ${SRC}/Blackboard/InterfaceBlackboard.cpp From fc088a1c67c29a9049f345e5753549430cfc9e0e Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 10 Jan 2024 22:00:29 +0100 Subject: [PATCH 114/403] [CMake] add the Wifi files to the OpenSoar project too Maybe there should be created an OpenVarioLib for this --- src/Dialogs/CMakeSource.cmake | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Dialogs/CMakeSource.cmake b/src/Dialogs/CMakeSource.cmake index d4ece1e6b84..a95a423f886 100644 --- a/src/Dialogs/CMakeSource.cmake +++ b/src/Dialogs/CMakeSource.cmake @@ -156,6 +156,15 @@ set(_SOURCES Dialogs/CoDialog.cpp ) + + +if(ON) # IS_OPENVARIO + list(APPEND _SOURCES + ../OpenVario/System/WifiDialogOV.cpp + ../OpenVario/System/WifiSupplicantOV.cpp + ) +endif() + if(UNIX) list(APPEND _SOURCES Dialogs/Settings/Panels/AudioVarioConfigPanel.cpp From c1eaeb31f952f2a220d28dcb4631e5927d3096fe Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 12 Jan 2024 14:00:42 +0100 Subject: [PATCH 115/403] [CMake] OpenVarioBaseMenu - set RunTime directory (Windows) --- src/OpenVario/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/OpenVario/CMakeLists.txt b/src/OpenVario/CMakeLists.txt index 31b24be1af4..88b487a03ea 100644 --- a/src/OpenVario/CMakeLists.txt +++ b/src/OpenVario/CMakeLists.txt @@ -46,7 +46,10 @@ add_compile_definitions("IS_OPENVARIO") # add_compile_definitions("USE_LIBINPUT") # remeve this definition after -set(RUNTIME_OUTPUT_DIRECTORY ${PROJECTGROUP_SOURCE_DIR}/$) +if(MSVC) + SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECTGROUP_BINARY_DIR}") +endif() + add_executable(${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES} From 8303092fe62cf17af30916992e03d88a1fad22cc Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 10 Jan 2024 20:35:22 +0100 Subject: [PATCH 116/403] WifiDialogOV.cpp - use UTF8ToWideConverter vor parse Ascii to TCHAR* --- src/OpenVario/System/WifiDialogOV.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/OpenVario/System/WifiDialogOV.cpp b/src/OpenVario/System/WifiDialogOV.cpp index d9d4c2f4487..20c488066f2 100644 --- a/src/OpenVario/System/WifiDialogOV.cpp +++ b/src/OpenVario/System/WifiDialogOV.cpp @@ -18,6 +18,7 @@ #include "ui/event/PeriodicTimer.hpp" #include "util/HexFormat.hxx" #include "util/StaticString.hxx" +#include "util/ConvertString.hpp" #ifdef KOBO @@ -178,8 +179,10 @@ WifiListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, row_renderer.DrawFirstRow(canvas, rc, info.ssid); row_renderer.DrawSecondRow(canvas, rc, info.bssid); #else - row_renderer.DrawFirstRow(canvas, rc, L"info.ssid"); // TODO(August2111) - row_renderer.DrawSecondRow(canvas, rc, L"info.bssid"); // TODO(August2111) + row_renderer.DrawFirstRow( + canvas, rc, UTF8ToWideConverter(info.ssid).c_str()); // TODO(August2111) + row_renderer.DrawSecondRow( + canvas, rc, UTF8ToWideConverter(info.bssid).c_str()); // TODO(August2111) #endif // WithWPA const TCHAR *state = nullptr; From 16e648c67f599344e414bc4d0cf08074f0881d15 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 10 Jan 2024 22:05:28 +0100 Subject: [PATCH 117/403] OpenVarioConfigPanel.cpp - add a button for the WifiDialogOV --- src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp b/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp index fd7a7e35423..5d55a93ab69 100644 --- a/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp @@ -14,6 +14,8 @@ #include "Dialogs/Message.hpp" +#include "OpenVario/System/WifiDialogOV.hpp" + #include @@ -110,6 +112,11 @@ OpenVarioConfigPanel::Prepare(ContainerWindow &parent, MB_OK | MB_ICONERROR); }); + AddButton( + _T("Settings Wifi"), [this]() { + ShowWifiDialog(); + }); + SetEnabled(bTest); } From 32c94952732a8c28917c63e78b1cb4844053f6d9 Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 12 Jan 2024 14:15:36 +0100 Subject: [PATCH 118/403] OpenVario/System/Setting/*.cpp - remove function ChangeConfigInt --- src/OpenVario/System/Setting/RotationWidget.cpp | 7 ++++++- src/OpenVario/System/Setting/TimeoutWidget.cpp | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/OpenVario/System/Setting/RotationWidget.cpp b/src/OpenVario/System/Setting/RotationWidget.cpp index 1dc99587b7f..7262241a50d 100644 --- a/src/OpenVario/System/Setting/RotationWidget.cpp +++ b/src/OpenVario/System/Setting/RotationWidget.cpp @@ -50,7 +50,12 @@ SettingRotationWidget::SaveRotation(const std::string &rotationString) { File::WriteExisting(Path(_T("/sys/class/graphics/fbcon/rotate")), (rotationString).c_str()); int rotationInt = stoi(rotationString); - ChangeConfigInt("rotation", rotationInt, ovdevice.GetSettingsConfig()); + // ChangeConfigInt("rotation", rotationInt, ovdevice.GetSettingsConfig()); + // TODO(August2111): move the from ovdevice.settings to ovdevice.sysetm + LoadConfigFile(ovdevice.system_map, ovdevice.GetSystemConfig()); // -> OpenVarioBaseMenu->StartUp! + ovdevice.rotation = stoi(rotationString); + ovdevice.system_map.insert_or_assign("Rotation", std::to_string(ovdevice.rotation)); + WriteConfigFile(ovdevice.system_map, ovdevice.GetSystemConfig()); } void diff --git a/src/OpenVario/System/Setting/TimeoutWidget.cpp b/src/OpenVario/System/Setting/TimeoutWidget.cpp index c205e1a302f..e1969dc45c6 100644 --- a/src/OpenVario/System/Setting/TimeoutWidget.cpp +++ b/src/OpenVario/System/Setting/TimeoutWidget.cpp @@ -49,7 +49,10 @@ void SettingTimeoutWidget::SaveTimeout(int timeoutInt) { - ChangeConfigInt("timeout", timeoutInt, ovdevice.GetSettingsConfig()); + ovdevice.timeout = timeoutInt; + ovdevice.settings.insert_or_assign("Timeout", + std::to_string(ovdevice.timeout)); + WriteConfigFile(ovdevice.settings, ovdevice.GetSettingsConfig()); } void From 5cae448c34175d99a556f106d2b5013e0ec9b234 Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 12 Jan 2024 19:12:51 +0100 Subject: [PATCH 119/403] OpenVarioBaseMenu - complete rebuild regarding OpenVarioConfigPanel --- .../Settings/Panels/OpenVarioConfigPanel.cpp | 149 ++++++++++-------- src/OpenVario/OpenVarioBaseMenu.cpp | 100 +++++++----- src/OpenVario/System/System.cpp | 54 +++++-- src/OpenVario/System/System.hpp | 45 +++--- 4 files changed, 207 insertions(+), 141 deletions(-) diff --git a/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp b/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp index 5d55a93ab69..e8d4d4a556a 100644 --- a/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp @@ -4,33 +4,37 @@ #ifdef IS_OPENVARIO // don't use (and compile) this code outside an OpenVario project! -#include "Profile/Keys.hpp" +#include "Dialogs/WidgetDialog.hpp" +#include "Widget/RowFormWidget.hpp" +#include "Look/DialogLook.hpp" + #include "Language/Language.hpp" #include "Widget/RowFormWidget.hpp" #include "Form/DataField/Boolean.hpp" #include "Form/DataField/Listener.hpp" +#include "Form/DataField/Enum.hpp" #include "Interface.hpp" #include "UIGlobals.hpp" +#include "ui/window/SingleWindow.hpp" #include "Dialogs/Message.hpp" +#include "OpenVario/System/System.hpp" #include "OpenVario/System/WifiDialogOV.hpp" #include -bool bTest = true; -unsigned iTest = 0; -unsigned iBrightness = 80; - -// #define HAVE_WEGLIDE_PILOTNAME enum ControlIndex { - OVFirmware, - OVBooleanTest, - OVIntegerTest, - OVBrightness, - OVButtonShell, + FIRMWARE, + ENABLED, + BRIGHTNESS, + TIMEOUT, + SHELL_BUTTON, + WIFI_BUTTON, + + INTEGERTEST, }; @@ -49,33 +53,32 @@ class OpenVarioConfigPanel final private: /* methods from DataFieldListener */ void OnModified(DataField &df) noexcept override; + + static constexpr StaticEnumChoice timeout_list[] = { + { 0, _T("imm."), }, + { 1, _T("1s"), }, + { 3, _T("3s"), }, + { 5, _T("5s"), }, + { 10, _T("10s"), }, + { 30, _T("30s"), }, + { 60, _T("1min"), }, + { -1, _T("never"), }, + nullptr + }; }; void OpenVarioConfigPanel::SetEnabled([[maybe_unused]] bool enabled) noexcept { -#ifdef OPENVARIO_CONFIG - // out commented currently: - SetRowEnabled(WeGlideAutomaticUpload, enabled); - SetRowEnabled(WeGlidePilotBirthDate, enabled); - SetRowEnabled(WeGlidePilotID, enabled); -#endif - // this disabled itself: SetRowEnabled(OVBooleanTest, enabled); - SetRowEnabled(OVIntegerTest, enabled); - SetRowEnabled(OVBrightness, enabled); + // this disabled itself: SetRowEnabled(ENABLED, enabled); + SetRowEnabled(BRIGHTNESS, enabled); + SetRowEnabled(TIMEOUT, enabled); } void OpenVarioConfigPanel::OnModified([[maybe_unused]] DataField &df) noexcept { -#ifdef OPENVARIO_CONFIG -// out commented currently: - if (IsDataField(WeGlideEnabled, df)) { - const DataFieldBoolean &dfb = (const DataFieldBoolean &)df; - SetEnabled(dfb.GetValue()); - } -#endif - if (IsDataField(OVBooleanTest, df)) { + if (IsDataField(ENABLED, df)) { const DataFieldBoolean &dfb = (const DataFieldBoolean &)df; SetEnabled(dfb.GetValue()); } @@ -85,25 +88,25 @@ void OpenVarioConfigPanel::Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept { - // const WeGlideSettings &weglide = CommonInterface::GetComputerSettings().weglide; - RowFormWidget::Prepare(parent, rc); - // void AddReadOnly(label, help,text; - auto version = _T("3.2.20"); + const TCHAR version[] = _T(PROGRAM_VERSION); + +// auto version = _T("3.2.20 (hard coded)"); AddReadOnly(_("OV-Firmware-Version"), _("Current firmware version of OpenVario"), version); AddBoolean( - _("Boolean Test"), - _("Boolean Test."), - bTest, this); + _("Settings Enabled"), + _("Enable the Settings Page"), ovdevice.enabled, this); + + AddInteger(_("Brightness"), + _("Brightness Display OpenVario"), _T("%d"), _T("%d%%"), 10, + 100, 10, ovdevice.brightness); - AddInteger(_("Integer Test"), - _("Integer Test."), - _T("%d"), _T("%d"), 1, 99999, 1, iTest); +// AddInteger(_("Program Timeout"), +// _("Timeout for Program Start."), _T("%d"), _T("%d"), 0, +// 30, 1, ovdevice.timeout); - AddInteger(_("Brightness Test"), - _("Brightness ???."), _T("%d"), _T("%d%%"), 10, - 100, 10, iBrightness); + AddEnum(_("Program Timeout"), _("Timeout for Program Start."), timeout_list, ovdevice.timeout); // auto Btn_Shell = AddButton( @@ -117,43 +120,56 @@ OpenVarioConfigPanel::Prepare(ContainerWindow &parent, ShowWifiDialog(); }); + AddInteger(_("IntegerTest"), + _("IntegerTest."), _T("%d"), _T("%d"), 0, + 99999, 1, ovdevice.iTest); - SetEnabled(bTest); + SetEnabled(ovdevice.enabled); } bool OpenVarioConfigPanel::Save([[maybe_unused]] bool &_changed) noexcept { bool changed = false; -#ifdef OPENVARIO_CONFIG - // out commented currently: + changed |= SaveValue(ENABLED, "Enabled", ovdevice.enabled, false); - auto &weglide = CommonInterface::SetComputerSettings().weglide; - - changed |= SaveValue(WeGlideAutomaticUpload, - ProfileKeys::WeGlideAutomaticUpload, - weglide.automatic_upload); - - changed |= SaveValueInteger(WeGlidePilotID, ProfileKeys::WeGlidePilotID, - weglide.pilot_id); + if (SaveValue(ENABLED, "Enabled", ovdevice.enabled, false)) { + ovdevice.settings.insert_or_assign("Enabled", + ovdevice.brightness ? "True" : "False"); + changed = true; + } - changed |= SaveValue(WeGlidePilotBirthDate, - ProfileKeys::WeGlidePilotBirthDate, - weglide.pilot_birthdate); + if (SaveValueEnum(TIMEOUT, "Timeout", ovdevice.timeout)) { + ovdevice.settings.insert_or_assign("Timeout", + std::to_string(ovdevice.timeout)); + changed = true; + } - changed |= SaveValue(WeGlideEnabled, ProfileKeys::WeGlideEnabled, - weglide.enabled); + if (SaveValueInteger(BRIGHTNESS, "Brightness", ovdevice.brightness)) { + ovdevice.settings.insert_or_assign( + "Brightness", std::to_string(ovdevice.brightness)); + changed = true; + } - - #endif - changed |= SaveValue(OVBooleanTest, "OVBooleanTest", - bTest, this); + if (SaveValueInteger(INTEGERTEST, "iTest",ovdevice.iTest)) { + ovdevice.settings.insert_or_assign( + "iTest", std::to_string(ovdevice.iTest)); + changed = true; + } +#if 0 // TOD(August2111) Only Test + ovdevice.settings.insert_or_assign("OpenSoarData", + "D:/Data/OpenSoarData"); +#endif - changed |= SaveValueInteger(OVIntegerTest, "OVIntegerTest", iTest); + if (changed) { + WriteConfigFile(ovdevice.settings, ovdevice.GetSettingsConfig()); - changed |= SaveValueInteger(OVBrightness, "OVBrightness", iBrightness); + // Profile::SaveFile(ovdevice.GetSettingsConfig()); + // the parent dialog don't need to save this values because we have an own + // config file ('openvario.cfg'): + // _changed |= changed; + } - _changed |= changed; return true; } @@ -162,4 +178,7 @@ CreateOpenVarioConfigPanel() noexcept { return std::make_unique(); } -#endif \ No newline at end of file + +#endif + + diff --git a/src/OpenVario/OpenVarioBaseMenu.cpp b/src/OpenVario/OpenVarioBaseMenu.cpp index 70701777d8b..a9971fc22bf 100644 --- a/src/OpenVario/OpenVarioBaseMenu.cpp +++ b/src/OpenVario/OpenVarioBaseMenu.cpp @@ -95,7 +95,9 @@ class MainMenuWidget final WndForm &dialog; UI::Timer timer{[this](){ - if (--remaining_seconds == 0) { + if (remaining_seconds == (unsigned)-1) + CancelTimer(); + else if (--remaining_seconds == 0) { HideRow(Controls::TIMER); StartOpenSoar(); // StartXCSoar(); } else { @@ -109,42 +111,61 @@ class MainMenuWidget final :RowFormWidget(_dialog.GetLook()), display(_display), event_queue(_event_queue), dialog(_dialog) { - GetConfigInt("timeout", remaining_seconds, ovdevice.GetSettingsConfig()); + ovdevice.LoadSettings(); + remaining_seconds = ovdevice.timeout; } private: - void StartOpenSoar() noexcept { + void StartSoarExe(std::string_view exe, + std::filesystem::path _datapath = "") noexcept { const UI::ScopeDropMaster drop_master{display}; const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; -#ifdef _WIN32 std::filesystem::path ExePath(std::filesystem::current_path()); - ExePath.append("OpenSoar.exe"); - ExePath = "D:/Projects/Binaries/OpenSoar/dev-branch/msvc2022/Release/" - "OpenSoar.exe"; - char buf[0x200]; - - snprintf(buf, sizeof(buf) - 1, "%s -fly -datapath=%s -profile=%s", - ExePath.generic_string().c_str(), - "D:/Data/XCSoarData", - "D:/Data/XCSoarData/August.prf" - ); - - Run(buf); -#else - if (File::Exists(Path(_T("/usr/bin/OpenSoar")))) - Run("/usr/bin/OpenSoar", "-fly", "-datapath=/home/root/data/OpenSoarData"); - else - Run("./output/UNIX/bin/OpenSoar", "-fly"); + ExePath.append(exe); + + if (_datapath.empty()) { + _datapath = GetPrimaryDataPath().c_str(); + } + NarrowString<0x200> datapath("-datapath="); + datapath.append(_datapath.generic_string()); + + NarrowString<0x80> profile(""); + if (ovdevice.settings.find("MainProfile") != ovdevice.settings.end()) + profile = "-profile="; + std::string str = ovdevice.settings.find("MainProfile")->second; + profile += ovdevice.settings.find("MainProfile")->second; + + NarrowString<0x10> format(""); +#ifdef _WIN32 + if (ovdevice.settings.find("Format") != ovdevice.settings.end()) { + format = "-"; + format += ovdevice.settings.find("Format")->second; + } + else + format = "-1400x700"; #endif + Run(ExePath.generic_string().c_str(), "-fly", datapath, profile, + format); + } + + void StartOpenSoar() noexcept { + std::filesystem::path datapath = ""; + if (ovdevice.settings.find("OpenSoarData") != ovdevice.settings.end()) + datapath = ovdevice.settings.find("OpenSoarData")->second; + StartSoarExe("OpenSoar.exe", datapath); + + // after OpenSoar the settings can be changed + ovdevice.LoadSettings(); } void StartXCSoar() noexcept { - const UI::ScopeDropMaster drop_master{display}; - const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; - Run("/usr/bin/xcsoar", "-fly", "-datapath=/home/root/data/XCSoarData"); + std::filesystem::path datapath = ""; + if (ovdevice.settings.find("XCSoarData") != ovdevice.settings.end()) + datapath = ovdevice.settings.find("XCSoarData")->second; + StartSoarExe("XCSoar.exe", datapath); } - void ScheduleTimer() noexcept { + void ScheduleTimer() noexcept { assert(remaining_seconds > 0); timer.Schedule(std::chrono::seconds{1}); @@ -168,12 +189,17 @@ class MainMenuWidget final void Show(const PixelRect &rc) noexcept override { RowFormWidget::Show(rc); - if (remaining_seconds > 0) { - ScheduleTimer(); - } - else { + switch (remaining_seconds) { + case (unsigned)-1: HideRow(Controls::TIMER); - StartOpenSoar(); // StartXCSoar(); + break; // Do Nothing ! + case 0: + HideRow(Controls::TIMER); + StartOpenSoar(); // StartXCSoar(); + break; + default: + ScheduleTimer(); + break; } } @@ -242,18 +268,13 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, AddButton(_("System Settings"), [this]() { CancelTimer(); std::unique_ptr widget = CreateOpenVarioConfigPanel(); - Profile::LoadFile(ovdevice.GetSettingsConfig()); + TWidgetDialog sub_dialog( WidgetDialog::Full{}, dialog.GetMainWindow(), GetLook(), _T("OpenVario System Settings")); sub_dialog.SetWidget(); sub_dialog.AddButton(_("Close"), mrOK); - auto ret_value = sub_dialog.ShowModal(); - - if (sub_dialog.GetChanged()) { - Profile::SaveFile(ovdevice.GetSettingsConfig()); - } - return ret_value; + return sub_dialog.ShowModal(); }); AddButton(_("System (Blaubart)"), [this]() { @@ -272,7 +293,7 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, auto Btn_Shell = AddButton(_T("Shell"), [this]() { dialog.SetModalResult(LAUNCH_SHELL); }); auto Btn_Reboot = AddButton(_T("Reboot"), []() { Run("/sbin/reboot"); }); - + auto Btn_Shutdown = AddButton(_T("Power off"), []() { Run("/sbin/poweroff"); }); @@ -280,10 +301,11 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, if (!ovdevice.IsReal()) { Btn_Shell->SetCaption(_T("Exit")); - Btn_XCSoar->SetEnabled(false); Btn_Reboot->SetEnabled(false); Btn_Shutdown->SetEnabled(false); } + // Btn_XCSoar->SetEnabled(File::Exists); + HideRow(Controls::OPENSOAR_CLUB); } diff --git a/src/OpenVario/System/System.cpp b/src/OpenVario/System/System.cpp index 1f5d40ec374..819b2bfbd01 100644 --- a/src/OpenVario/System/System.cpp +++ b/src/OpenVario/System/System.cpp @@ -53,7 +53,7 @@ OpenVarioDevice::OpenVarioDevice() { home_path = Path(home); #ifdef _WIN32 // DataPath = Path(_T("D:/Data/OpenSoarData")); - data_path = Path(_T("D:\\Data\\XCSoarData")); + data_path = Path(_T("D:/Data/XCSoarData")); #else data_path = Path(_T("data")); @@ -66,29 +66,58 @@ OpenVarioDevice::OpenVarioDevice() { // auto config = AllocatedPath::Build(data_path, Path(_T("openvario.cfg"))); settings_config = AllocatedPath::Build(data_path, Path(_T("openvario.cfg"))); - upgrade_config = - AllocatedPath::Build(data_path, Path(_T("upgrade.cfg"))); + upgrade_config = AllocatedPath::Build(data_path, Path(_T("upgrade.cfg"))); } else { settings_config = AllocatedPath::Build(home_path, Path(_T("openvario.cfg"))); - upgrade_config = - AllocatedPath::Build(home_path, Path(_T("upgrade.cfg"))); + upgrade_config = AllocatedPath::Build(home_path, Path(_T("upgrade.cfg"))); } + system_config = AllocatedPath::Build(home_path, Path(_T("config.uEnv"))); if (!File::Exists(settings_config)) File::CreateExclusive(settings_config); assert(File::Exists(settings_config)); } - //---------------------------------------------------------- +//---------------------------------------------------------- +void ReadBool(std::map> &map, + std::string_view name, bool &value) noexcept { + if (map.find(name) != map.end()) + value = map.find(name)->second != "False"; +} +//---------------------------------------------------------- +void ReadInteger(std::map> &map, + std::string_view name, unsigned &value) noexcept { + if (map.find(name) != map.end()) + value = std::stoul(map.find(name)->second); +} +//---------------------------------------------------------- +void +OpenVarioDevice::LoadSettings() noexcept +{ + LoadConfigFile(system_map, GetSystemConfig()); + LoadConfigFile(settings, GetSettingsConfig()); + LoadConfigFile(upgrade_map, GetUpgradeConfig()); + + ReadInteger(system_map, "rotation", rotation); + + ReadBool(settings, "Enabled", enabled); + ReadInteger(settings, "iTest", iTest); + ReadInteger(settings, "Timeout", timeout); + ReadInteger(settings, "Brightness", brightness); + +} +//---------------------------------------------------------- void LoadConfigFile(std::map> &map, Path path) { - FileLineReaderA reader(path); - KeyValueFileReader kvreader(reader); - KeyValuePair pair; - while (kvreader.Read(pair)) - map.emplace(pair.key, pair.value); + if (File::Exists(path)) { + FileLineReaderA reader(path); + KeyValueFileReader kvreader(reader); + KeyValuePair pair; + while (kvreader.Read(pair)) + map.emplace(pair.key, pair.value); + } } //---------------------------------------------------------- @@ -106,6 +135,7 @@ WriteConfigFile(std::map> &map, Path path) } //---------------------------------------------------------- +/*/ void GetConfigInt(const std::string &keyvalue, unsigned &value, const Path &config) @@ -136,7 +166,7 @@ ChangeConfigInt(const std::string &keyvalue, int value, debugln("ConfigFile '%s' does not exist!", config.c_str()); } } - +*/ //---------------------------------------------------------- uint_least8_t diff --git a/src/OpenVario/System/System.hpp b/src/OpenVario/System/System.hpp index da7495c1767..a1f5e20f301 100644 --- a/src/OpenVario/System/System.hpp +++ b/src/OpenVario/System/System.hpp @@ -19,37 +19,22 @@ class OpenVarioDevice { public: OpenVarioDevice(); - Path GetSystemConfig() noexcept - { - return system_config; - } + void LoadSettings() noexcept; + Path GetSystemConfig() noexcept { return system_config; } + void SetSystemConfig(Path configfile) noexcept { system_config = configfile; } + std::map> system_map; - void SetSystemConfig(Path configfile) noexcept - { - system_config = configfile; - } - - Path - GetSettingsConfig() noexcept - { - return settings_config; - } - void - SetSettingsConfig(Path configfile) noexcept - { + Path GetSettingsConfig() noexcept { return settings_config; } + void SetSettingsConfig(Path configfile) noexcept { settings_config = configfile; } + std::map> settings; - Path - GetUpgradeConfig() noexcept - { - return upgrade_config; - } - void - SetUpgradeConfig(Path configfile) noexcept - { + Path GetUpgradeConfig() noexcept { return upgrade_config; } + void SetUpgradeConfig(Path configfile) noexcept { upgrade_config = configfile; } + std::map> upgrade_map; bool IsReal() noexcept @@ -57,6 +42,14 @@ class OpenVarioDevice { return is_real; } + struct { + bool enabled = true; + unsigned brightness = 100; + unsigned timeout = 5; + unsigned rotation = 0; + unsigned iTest = 0; + }; + private: AllocatedPath system_config; // system config file, in the OV the // /boot/config.uEnf @@ -121,6 +114,7 @@ void OpenvarioDisableSSH(); #endif +/*/ void GetConfigInt(const std::string &keyvalue, unsigned &value, const Path &ConfigPath); @@ -129,3 +123,4 @@ void ChangeConfigInt(const std::string &keyvalue, int value, const Path &ConfigPath); +*/ \ No newline at end of file From 8ce1c07d69d4a0fd0d1ee8fe579cf88e86c88bc1 Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 12 Jan 2024 21:05:31 +0100 Subject: [PATCH 120/403] OpenVario/System/Setting - add ReadString (from map), from config.uEnv read a string in Debug (fdtfile) --- src/OpenVario/System/System.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/OpenVario/System/System.cpp b/src/OpenVario/System/System.cpp index 819b2bfbd01..5ef2612adcc 100644 --- a/src/OpenVario/System/System.cpp +++ b/src/OpenVario/System/System.cpp @@ -92,6 +92,12 @@ void ReadInteger(std::map> &map, value = std::stoul(map.find(name)->second); } //---------------------------------------------------------- +void ReadString(std::map> &map, + std::string_view name, std::string_view &value) noexcept { + if (map.find(name) != map.end()) + value = map.find(name)->second; +} +//---------------------------------------------------------- void OpenVarioDevice::LoadSettings() noexcept { @@ -100,6 +106,10 @@ OpenVarioDevice::LoadSettings() noexcept LoadConfigFile(upgrade_map, GetUpgradeConfig()); ReadInteger(system_map, "rotation", rotation); +#ifdef _DEBUG + std::string_view fdtfile; + ReadString(system_map, "fdtfile", fdtfile); +#endif ReadBool(settings, "Enabled", enabled); ReadInteger(settings, "iTest", iTest); From ac369c5ce44f040a9ec62f3ec65b5206d1def551 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sat, 13 Jan 2024 23:24:10 +0100 Subject: [PATCH 121/403] [build] main.mk - add OpenVarioBase files --- build/main.mk | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/build/main.mk b/build/main.mk index 3803474e6be..fb7ba9b0b3e 100644 --- a/build/main.mk +++ b/build/main.mk @@ -155,8 +155,23 @@ DIALOG_SOURCES = \ $(SRC)/Dialogs/dlgQuickMenu.cpp \ ifeq ($(TARGET_IS_OPENVARIO),y) + # $(SRC)/OpenVario/OpenVarioBaseMenu.cpp DIALOG_SOURCES += \ - $(SRC)/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp + $(SRC)/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp \ + $(SRC)/OpenVario/System/System.cpp \ + $(SRC)/OpenVario/FileMenuWidget.cpp \ + $(SRC)/OpenVario/System/SystemMenuWidget.cpp \ + $(SRC)/OpenVario/System/SystemSettingsWidget.cpp \ + $(SRC)/OpenVario/System/Setting/RotationWidget.cpp \ + $(SRC)/OpenVario/System/Setting/BrightnessWidget.cpp \ + $(SRC)/OpenVario/System/Setting/TimeoutWidget.cpp \ + $(SRC)/OpenVario/System/Setting/SSHWidget.cpp \ + $(SRC)/OpenVario/System/Setting/VariodWidget.cpp \ + $(SRC)/OpenVario/System/Setting/SensordWidget.cpp \ + $(SRC)/OpenVario/System/Setting/WifiWidget.cpp \ + \ + $(SRC)/OpenVario/System/WifiDialogOV.cpp \ + $(SRC)/OpenVario/System/WifiSupplicantOV.cpp endif ifeq ($(HAVE_PCM_PLAYER),y) From 12af20877df36873f32dce91274b307bef23208f Mon Sep 17 00:00:00 2001 From: August2111 Date: Sat, 13 Jan 2024 23:33:19 +0100 Subject: [PATCH 122/403] OpenVario/System - rename OpenVarioDevice in OpenVario_Device, complete rebuild of system access functions OpenVarioDevice has conflicts with OpenVario in Device/Driver... --- src/OpenVario/System/System.cpp | 11 ++--- src/OpenVario/System/System.hpp | 88 +++++++++++++++++---------------- 2 files changed, 49 insertions(+), 50 deletions(-) diff --git a/src/OpenVario/System/System.cpp b/src/OpenVario/System/System.cpp index 5ef2612adcc..3cda67eed81 100644 --- a/src/OpenVario/System/System.cpp +++ b/src/OpenVario/System/System.cpp @@ -45,16 +45,15 @@ #include -OpenVarioDevice ovdevice; +OpenVario_Device ovdevice; -OpenVarioDevice::OpenVarioDevice() { +OpenVario_Device::OpenVario_Device() { StaticString<0x100> home; home.SetUTF8(getenv("HOME")); home_path = Path(home); #ifdef _WIN32 // DataPath = Path(_T("D:/Data/OpenSoarData")); data_path = Path(_T("D:/Data/XCSoarData")); - #else data_path = Path(_T("data")); @@ -99,7 +98,7 @@ void ReadString(std::map> &map, } //---------------------------------------------------------- void -OpenVarioDevice::LoadSettings() noexcept +OpenVario_Device::LoadSettings() noexcept { LoadConfigFile(system_map, GetSystemConfig()); LoadConfigFile(settings, GetSettingsConfig()); @@ -287,7 +286,7 @@ OpenvarioDisableSSH() Systemd::DisableUnitFile(connection, "dropbear.socket"); Systemd::StopUnit(connection, "dropbear.socket"); } -#endif // _WIN32 +#endif // DBUS_FUNCTIONS #ifndef MAX_PATH @@ -301,9 +300,7 @@ void debugln(const char *fmt, ...) noexcept { vsnprintf(buf, sizeof(buf) - 1, fmt, ap); va_end(ap); - // strcat(buf, "\n"); std::cout << buf << std::endl; - // printf(buf); } //---------------------------------------------------------- diff --git a/src/OpenVario/System/System.hpp b/src/OpenVario/System/System.hpp index a1f5e20f301..a791a756a21 100644 --- a/src/OpenVario/System/System.hpp +++ b/src/OpenVario/System/System.hpp @@ -15,27 +15,42 @@ void debugln(const char *fmt, ...) noexcept; -class OpenVarioDevice { +enum class SSHStatus { + ENABLED, + DISABLED, + TEMPORARY, +}; + +enum Buttons { + LAUNCH_SHELL = 100, + START_UPGRADE = 111, +}; + +class OpenVario_Device { public: - OpenVarioDevice(); + OpenVario_Device(); void LoadSettings() noexcept; Path GetSystemConfig() noexcept { return system_config; } - void SetSystemConfig(Path configfile) noexcept { system_config = configfile; } + // void SetSystemConfig(Path configfile) noexcept { system_config = configfile; } std::map> system_map; Path GetSettingsConfig() noexcept { return settings_config; } - void SetSettingsConfig(Path configfile) noexcept { - settings_config = configfile; - } + // void SetSettingsConfig(Path configfile) noexcept { + // settings_config = configfile; + // } std::map> settings; Path GetUpgradeConfig() noexcept { return upgrade_config; } - void SetUpgradeConfig(Path configfile) noexcept { - upgrade_config = configfile; - } + // void SetUpgradeConfig(Path configfile) noexcept { + // upgrade_config = configfile; + // } std::map> upgrade_map; - +#ifdef _WIN32 + // This map is only for Debug purposes on Non-OpenVario systems + std::map> internal_map; + Path GetInternalConfig() noexcept { return internal_config; } +#endif bool IsReal() noexcept { @@ -47,21 +62,34 @@ class OpenVarioDevice { unsigned brightness = 100; unsigned timeout = 5; unsigned rotation = 0; + unsigned iTest = 0; }; + struct { // internal data + bool sensord = false; + bool variod = false; + unsigned ssh = (unsigned) SSHStatus::DISABLED; + }; + + private: AllocatedPath system_config; // system config file, in the OV the // /boot/config.uEnf AllocatedPath upgrade_config; // the config file for upgrading OV AllocatedPath settings_config; // the config file for settings inside // the OpenVarioBaseMenu +#ifdef _WIN32 + // This path is only for Debug purposes on Non-OpenVario systems + AllocatedPath internal_config; +#endif + AllocatedPath home_path; AllocatedPath data_path; bool is_real = false; }; -extern OpenVarioDevice ovdevice; +extern OpenVario_Device ovdevice; #if !defined(_WIN32) && 0 # define DBUS_FUNCTIONS 1 @@ -69,17 +97,6 @@ extern OpenVarioDevice ovdevice; class Path; -enum class SSHStatus { - ENABLED, - DISABLED, - TEMPORARY, -}; - -enum Buttons { - LAUNCH_SHELL = 100, - START_UPGRADE = 111, -}; - /** * Load a system config file and put its variables into a map */ @@ -103,24 +120,9 @@ OpenvarioGetRotation(); void OpenvarioSetRotation(DisplayOrientation orientation); -#ifdef DBUS_FUNCTIONS -SSHStatus -OpenvarioGetSSHStatus(); - -void -OpenvarioEnableSSH(bool temporary); - -void -OpenvarioDisableSSH(); -#endif - -/*/ -void -GetConfigInt(const std::string &keyvalue, unsigned &value, - const Path &ConfigPath); - -void -ChangeConfigInt(const std::string &keyvalue, int value, - const Path &ConfigPath); - -*/ \ No newline at end of file +SSHStatus OpenvarioGetSSHStatus(); +void OpenvarioSetSSHStatus(SSHStatus state); +bool OpenvarioGetSensordStatus() noexcept; +bool OpenvarioGetVariodStatus() noexcept; +void OpenvarioSetSensordStatus(bool value) noexcept; +void OpenvarioSetVariodStatus(bool value) noexcept; From f73f74e73685022083d9df5e7427f3862546d402 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sat, 13 Jan 2024 23:58:53 +0100 Subject: [PATCH 123/403] [CMake] OpenVarioBaseMenu - add missing source files remove files which are not necessary --- src/Dialogs/CMakeSource.cmake | 16 +++++++++++++++- src/OpenVario/CMakeSource.cmake | 10 +++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/Dialogs/CMakeSource.cmake b/src/Dialogs/CMakeSource.cmake index a95a423f886..554885bf267 100644 --- a/src/Dialogs/CMakeSource.cmake +++ b/src/Dialogs/CMakeSource.cmake @@ -94,7 +94,6 @@ set(_SOURCES Dialogs/Settings/Panels/WaypointDisplayConfigPanel.cpp Dialogs/Settings/Panels/WeatherConfigPanel.cpp Dialogs/Settings/Panels/WindConfigPanel.cpp - Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp Dialogs/Settings/WindSettingsDialog.cpp Dialogs/Settings/WindSettingsPanel.cpp @@ -158,10 +157,25 @@ set(_SOURCES ) + if(ON) # IS_OPENVARIO list(APPEND _SOURCES + ../OpenVario/System/System.cpp + ../OpenVario/FileMenuWidget.cpp + + ../OpenVario/System/SystemMenuWidget.cpp + ../OpenVario/System/SystemSettingsWidget.cpp + ../OpenVario/System/Setting/RotationWidget.cpp + # OpenVario/System/Setting/BrightnessWidget.cpp + # OpenVario/System/Setting/TimeoutWidget.cpp + # OpenVario/System/Setting/SSHWidget.cpp + # OpenVario/System/Setting/VariodWidget.cpp + # OpenVario/System/Setting/SensordWidget.cpp + ../OpenVario/System/WifiDialogOV.cpp ../OpenVario/System/WifiSupplicantOV.cpp + + Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp ) endif() diff --git a/src/OpenVario/CMakeSource.cmake b/src/OpenVario/CMakeSource.cmake index f05ef3238b0..d3bd1da75b7 100644 --- a/src/OpenVario/CMakeSource.cmake +++ b/src/OpenVario/CMakeSource.cmake @@ -9,11 +9,11 @@ set(_SOURCES OpenVario/System/SystemMenuWidget.cpp OpenVario/System/SystemSettingsWidget.cpp OpenVario/System/Setting/RotationWidget.cpp - OpenVario/System/Setting/BrightnessWidget.cpp - OpenVario/System/Setting/TimeoutWidget.cpp - OpenVario/System/Setting/SSHWidget.cpp - OpenVario/System/Setting/VariodWidget.cpp - OpenVario/System/Setting/SensordWidget.cpp + # OpenVario/System/Setting/BrightnessWidget.cpp + # OpenVario/System/Setting/TimeoutWidget.cpp + # OpenVario/System/Setting/SSHWidget.cpp + # OpenVario/System/Setting/VariodWidget.cpp + # OpenVario/System/Setting/SensordWidget.cpp OpenVario/System/Setting/WifiWidget.cpp OpenVario/System/WifiDialogOV.cpp From 4d3bdc6c79081a85190b4e3f41447b7cf6ba5aec Mon Sep 17 00:00:00 2001 From: August2111 Date: Sun, 14 Jan 2024 12:22:43 +0100 Subject: [PATCH 124/403] [CMake] OpenVarioBaseMenu - use Language and LogFile instead of Fake... --- src/OpenVario/CMakeSource.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/OpenVario/CMakeSource.cmake b/src/OpenVario/CMakeSource.cmake index d3bd1da75b7..0c36643231c 100644 --- a/src/OpenVario/CMakeSource.cmake +++ b/src/OpenVario/CMakeSource.cmake @@ -49,9 +49,9 @@ set(_SOURCES ${SRC}/Profile/Map.cpp ${SRC}/Profile/File.cpp ${SRC}/Profile/NumericValue.cpp - ${TEST_SRC_DIR}/Fonts.cpp - ${TEST_SRC_DIR}/FakeLanguage.cpp - ${TEST_SRC_DIR}/FakeLogFile.cpp + # ${TEST_SRC_DIR}/Fonts.cpp + # ${SRC}/Language/Language.cpp # ${TEST_SRC_DIR}/FakeLanguage.cpp + ${SRC}/LogFile.cpp # ${TEST_SRC_DIR}/FakeLogFile.cpp # ${SRC}/Kobo/FakeSymbols.cpp ${SRC}/Dialogs/DataField.cpp ) @@ -60,7 +60,7 @@ set(OPENVARIOBASEMENU_LIBS # ov.mk: OV_MENU_DEPENDS = WIDGET FORM DATA_FIELD SCREEN EVENT RESOURCE ASYNC LIBNET OS IO THREAD TIME MATH UTIL # ov.mk: OV_MENU_STRIP = y Profile Widget Form Renderer ui event net system io thread time Math util - co Blackboard # Language + co Blackboard Language Dialogs Look MapWindow ${FMT_LIB} ${CURL_TARGET} ${CARES_TARGET} ${ZLIB_TARGET} From a10bd526c87e6e10e9770ccf28eedfe7cfc3a3cd Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 15 Apr 2024 10:50:04 +0200 Subject: [PATCH 125/403] [build] OpenVarioBaseMenu - use Language and LogFile instead of Fake... --- build/ov.mk | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/build/ov.mk b/build/ov.mk index 77f8d87bb15..933c4193dfb 100644 --- a/build/ov.mk +++ b/build/ov.mk @@ -228,9 +228,9 @@ OV_MENU_SOURCES = \ $(SRC)/Profile/Map.cpp \ $(SRC)/Profile/File.cpp \ $(SRC)/Profile/NumericValue.cpp \ - $(TEST_SRC_DIR)/Fonts.cpp \ - $(TEST_SRC_DIR)/FakeLanguage.cpp \ - $(TEST_SRC_DIR)/FakeLogFile.cpp \ + # $(TEST_SRC_DIR)/Fonts.cpp \ + # $(SRC)/Language/Language.cpp # $(TEST_SRC_DIR)/FakeLanguage.cpp\ + $(SRC)/LogFile.cpp # $(TEST_SRC_DIR)/FakeLogFile.cpp\ \ $(SRC)/LocalPath.cpp \ $(SRC)/Form/DigitEntry.cpp \ @@ -254,6 +254,7 @@ OV_MENU_SOURCES = \ OV_MENU_DEPENDS = WIDGET FORM DATA_FIELD SCREEN EVENT RESOURCE ASYNC LIBNET OS IO THREAD TIME MATH UTIL \ + LANGUAGE \ LIBMAPWINDOW \ GETTEXT \ PROFILE \ From 9bb1d5f8f173be46ee6330df1a5014a5b98d356f Mon Sep 17 00:00:00 2001 From: August2111 Date: Sun, 14 Jan 2024 17:25:43 +0100 Subject: [PATCH 126/403] [build] ok.mk -with LogFile.cpp --- build/ov.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/ov.mk b/build/ov.mk index 933c4193dfb..b6fb1176011 100644 --- a/build/ov.mk +++ b/build/ov.mk @@ -229,8 +229,8 @@ OV_MENU_SOURCES = \ $(SRC)/Profile/File.cpp \ $(SRC)/Profile/NumericValue.cpp \ # $(TEST_SRC_DIR)/Fonts.cpp \ - # $(SRC)/Language/Language.cpp # $(TEST_SRC_DIR)/FakeLanguage.cpp\ - $(SRC)/LogFile.cpp # $(TEST_SRC_DIR)/FakeLogFile.cpp\ + # $(SRC)/Language/Language.cpp # $(TEST_SRC_DIR)/FakeLanguage.cpp \ + $(SRC)/LogFile.cpp # $(TEST_SRC_DIR)/FakeLogFile.cpp \ \ $(SRC)/LocalPath.cpp \ $(SRC)/Form/DigitEntry.cpp \ From cf0e7c28a8ba7bc15b0aa30f8e4770cc64f0d6ff Mon Sep 17 00:00:00 2001 From: August2111 Date: Sun, 14 Jan 2024 21:56:00 +0100 Subject: [PATCH 127/403] OpenVarioBaseMenu - complete reorganization of structure (part2) * move dialogues to another place * remove some (blaubart) dialogues (AddEnum and so on instead of adding a own diolog with a lot of (add-)Buttons * organize the folder structur in OpenVario_Device (content of system.*pp) * remove FakeLanguage and FakeLogFile with real objects (with some new dependencies) --- src/Device/Config.cpp | 1 + .../Settings/Panels/OpenVarioConfigPanel.cpp | 48 +++- .../Settings/Panels/OpenVarioConfigPanel.hpp | 21 ++ src/Dialogs/Settings/dlgConfiguration.cpp | 9 + src/LogFile.cpp | 7 + src/OpenVario/OpenVarioBaseMenu.cpp | 39 +--- .../System/Setting/BrightnessWidget.cpp | 93 -------- .../System/Setting/BrightnessWidget.hpp | 28 --- src/OpenVario/System/Setting/SSHWidget.cpp | 73 ------ src/OpenVario/System/Setting/SSHWidget.hpp | 27 --- .../System/Setting/SensordWidget.cpp | 75 ------ .../System/Setting/SensordWidget.hpp | 27 --- .../System/Setting/TimeoutWidget.cpp | 141 ----------- .../System/Setting/TimeoutWidget.hpp | 27 --- src/OpenVario/System/Setting/VariodWidget.cpp | 76 ------ src/OpenVario/System/Setting/VariodWidget.hpp | 27 --- src/OpenVario/System/System.cpp | 219 ++++++++++-------- src/OpenVario/System/System.hpp | 7 +- src/OpenVario/System/SystemMenuWidget.cpp | 14 +- src/OpenVario/System/SystemSettingsWidget.cpp | 102 ++++---- 20 files changed, 275 insertions(+), 786 deletions(-) delete mode 100644 src/OpenVario/System/Setting/BrightnessWidget.cpp delete mode 100644 src/OpenVario/System/Setting/BrightnessWidget.hpp delete mode 100644 src/OpenVario/System/Setting/SSHWidget.cpp delete mode 100644 src/OpenVario/System/Setting/SSHWidget.hpp delete mode 100644 src/OpenVario/System/Setting/SensordWidget.cpp delete mode 100644 src/OpenVario/System/Setting/SensordWidget.hpp delete mode 100644 src/OpenVario/System/Setting/TimeoutWidget.cpp delete mode 100644 src/OpenVario/System/Setting/TimeoutWidget.hpp delete mode 100644 src/OpenVario/System/Setting/VariodWidget.cpp delete mode 100644 src/OpenVario/System/Setting/VariodWidget.hpp diff --git a/src/Device/Config.cpp b/src/Device/Config.cpp index 2ab618df021..4a17a0bb6aa 100644 --- a/src/Device/Config.cpp +++ b/src/Device/Config.cpp @@ -187,6 +187,7 @@ DeviceConfig::Clear() noexcept #ifndef NDEBUG dump_port = false; #endif + dump_port = true; } const TCHAR * diff --git a/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp b/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp index e8d4d4a556a..370f8ba9fc4 100644 --- a/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp @@ -29,7 +29,11 @@ enum ControlIndex { FIRMWARE, ENABLED, + ROTATION, BRIGHTNESS, + SENSORD, + VARIOD, + SSH, TIMEOUT, SHELL_BUTTON, WIFI_BUTTON, @@ -55,7 +59,7 @@ class OpenVarioConfigPanel final void OnModified(DataField &df) noexcept override; static constexpr StaticEnumChoice timeout_list[] = { - { 0, _T("imm."), }, + { 0, _T("immediately"), }, { 1, _T("1s"), }, { 3, _T("3s"), }, { 5, _T("5s"), }, @@ -65,6 +69,13 @@ class OpenVarioConfigPanel final { -1, _T("never"), }, nullptr }; + + static constexpr StaticEnumChoice enable_list[] = { + { SSHStatus::ENABLED, _T("enabled"), }, + { SSHStatus::DISABLED, _T("disabled"), }, + { SSHStatus::TEMPORARY, _T("temporary"), }, + nullptr + }; }; void @@ -90,6 +101,11 @@ OpenVarioConfigPanel::Prepare(ContainerWindow &parent, { RowFormWidget::Prepare(parent, rc); + ovdevice.sensord = OpenvarioGetSensordStatus(); + ovdevice.variod = OpenvarioGetVariodStatus(); + ovdevice.ssh = (unsigned) OpenvarioGetSSHStatus(); + + const TCHAR version[] = _T(PROGRAM_VERSION); // auto version = _T("3.2.20 (hard coded)"); @@ -98,13 +114,17 @@ OpenVarioConfigPanel::Prepare(ContainerWindow &parent, _("Settings Enabled"), _("Enable the Settings Page"), ovdevice.enabled, this); + AddInteger(_("Rotation"), + _("Rotation Display OpenVario"), _T("%d"), _T("%d%%"), 0, + 3, 1, ovdevice.rotation); + AddInteger(_("Brightness"), _("Brightness Display OpenVario"), _T("%d"), _T("%d%%"), 10, 100, 10, ovdevice.brightness); - -// AddInteger(_("Program Timeout"), -// _("Timeout for Program Start."), _T("%d"), _T("%d"), 0, -// 30, 1, ovdevice.timeout); + AddBoolean(_("SensorD"), _("Enable the SensorD"), ovdevice.sensord, this); + AddBoolean(_("VarioD"), _("Enable the VarioD"), ovdevice.variod, this); + AddEnum(_("SSH"), _("Enable the SSH Connection"), enable_list, + ovdevice.ssh); AddEnum(_("Program Timeout"), _("Timeout for Program Start."), timeout_list, ovdevice.timeout); @@ -124,6 +144,9 @@ OpenVarioConfigPanel::Prepare(ContainerWindow &parent, _("IntegerTest."), _T("%d"), _T("%d"), 0, 99999, 1, ovdevice.iTest); + AddReadOnly(_("OV-Firmware-Version"), + _("Current firmware version of OpenVario"), version); + SetEnabled(ovdevice.enabled); } @@ -163,13 +186,18 @@ OpenVarioConfigPanel::Save([[maybe_unused]] bool &_changed) noexcept if (changed) { WriteConfigFile(ovdevice.settings, ovdevice.GetSettingsConfig()); - - // Profile::SaveFile(ovdevice.GetSettingsConfig()); - // the parent dialog don't need to save this values because we have an own - // config file ('openvario.cfg'): - // _changed |= changed; } + if (SaveValueEnum(SSH, ovdevice.ssh)) + OpenvarioSetSSHStatus((SSHStatus) ovdevice.ssh); + + if (SaveValue(SENSORD, ovdevice.sensord)) + OpenvarioSetSensordStatus(ovdevice.sensord); + + if (SaveValue(VARIOD, ovdevice.variod)) + OpenvarioSetSensordStatus(ovdevice.variod); + + return true; } diff --git a/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.hpp b/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.hpp index bcf533b976b..a52acf03849 100644 --- a/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.hpp +++ b/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.hpp @@ -5,10 +5,31 @@ #ifdef IS_OPENVARIO +#include "Form/DataField/Listener.hpp" +#include "Widget/RowFormWidget.hpp" + + #include class Widget; +// ------------------------------------------- +class OpenVarioConfigPanel final : public RowFormWidget, DataFieldListener { +public: + OpenVarioConfigPanel() noexcept : RowFormWidget(UIGlobals::GetDialogLook()) {} + + void SetEnabled(bool enabled) noexcept; + + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept override; + bool Save(bool &changed) noexcept override; + +private: + /* methods from DataFieldListener */ + void OnModified(DataField &df) noexcept override; +}; +// --------------------------------------------- + std::unique_ptr CreateOpenVarioConfigPanel(); diff --git a/src/Dialogs/Settings/dlgConfiguration.cpp b/src/Dialogs/Settings/dlgConfiguration.cpp index 5a9990b9f7b..6e6db60fbec 100644 --- a/src/Dialogs/Settings/dlgConfiguration.cpp +++ b/src/Dialogs/Settings/dlgConfiguration.cpp @@ -65,6 +65,10 @@ #include "Panels/WeGlideConfigPanel.hpp" +#if defined(IS_OPENVARIO) +#include "OpenVario/System/System.hpp" +#endif + #include static unsigned current_page; @@ -343,6 +347,11 @@ void dlgConfigurationShowModal() return std::move(_menu); })); + +#ifdef IS_OPENVARIO + ovdevice.Initialise(); +#endif + menu.InitMenu(main_menu_captions, ARRAY_SIZE(main_menu_captions)); /* restore last selected menu item */ diff --git a/src/LogFile.cpp b/src/LogFile.cpp index f3efa5c3eff..9b3b9ad5ed7 100644 --- a/src/LogFile.cpp +++ b/src/LogFile.cpp @@ -35,12 +35,19 @@ OpenLog() if (!initialised) { initialised = true; +#ifdef IS_OPENVARIO + /* delete the obsolete log file */ + File::Delete(LocalPath(_T("opensoar-startup.log"))); + path = LocalPath(_T("opensoar.log")); + File::Replace(path, LocalPath(_T("opensoar-old.log"))); +#else /* delete the obsolete log file */ File::Delete(LocalPath(_T("xcsoar-startup.log"))); path = LocalPath(_T("xcsoar.log")); File::Replace(path, LocalPath(_T("xcsoar-old.log"))); +#endif #ifdef ANDROID /* redirect stdout/stderr to xcsoar-startup.log on Android so we diff --git a/src/OpenVario/OpenVarioBaseMenu.cpp b/src/OpenVario/OpenVarioBaseMenu.cpp index a9971fc22bf..2b62c87bf52 100644 --- a/src/OpenVario/OpenVarioBaseMenu.cpp +++ b/src/OpenVario/OpenVarioBaseMenu.cpp @@ -29,9 +29,6 @@ #include "OpenVario/FileMenuWidget.h" #include "OpenVario/System/SystemMenuWidget.hpp" - -#include "Form/DataField/Listener.hpp" -#include "Dialogs/Settings/Panels/OpenVarioConfigPanel.hpp" #include "LocalPath.hpp" #include @@ -79,7 +76,7 @@ class MainMenuWidget final OPENSOAR, XCSOAR, FILE, - TEST, + // TEST, SYSTEM, READONLY_1, SHELL, @@ -221,21 +218,6 @@ class MainMenuWidget final } }; -class OpenVarioConfigPanel final : public RowFormWidget, DataFieldListener { -public: - OpenVarioConfigPanel() noexcept : RowFormWidget(UIGlobals::GetDialogLook()) {} - - void SetEnabled(bool enabled) noexcept; - - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept override; - bool Save(bool &changed) noexcept override; - -private: - /* methods from DataFieldListener */ - void OnModified(DataField &df) noexcept override; -}; - void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { @@ -265,24 +247,12 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, return sub_dialog.ShowModal(); }); - AddButton(_("System Settings"), [this]() { - CancelTimer(); - std::unique_ptr widget = CreateOpenVarioConfigPanel(); - - TWidgetDialog sub_dialog( - WidgetDialog::Full{}, dialog.GetMainWindow(), GetLook(), - _T("OpenVario System Settings")); - sub_dialog.SetWidget(); - sub_dialog.AddButton(_("Close"), mrOK); - return sub_dialog.ShowModal(); - }); - - AddButton(_("System (Blaubart)"), [this]() { + AddButton(_("OpenVario settings"), [this]() { CancelTimer(); TWidgetDialog sub_dialog( WidgetDialog::Full{}, dialog.GetMainWindow(), GetLook(), - _T("OpenVario System Settings (Blaubart)")); + _T("OpenVario System Settings")); sub_dialog.SetWidget(display, event_queue, sub_dialog); sub_dialog.AddButton(_("Close"), mrOK); return sub_dialog.ShowModal(); @@ -325,6 +295,7 @@ static int Main() { InitialiseDataPath(); + ovdevice.Initialise(); dialog_settings.SetDefaults(); @@ -333,7 +304,7 @@ Main() // InitialiseFonts(); // AllowLanguage is not in FalkLanguage - // AllowLanguage(); + AllowLanguage(); DialogLook dialog_look; dialog_look.Initialise(); diff --git a/src/OpenVario/System/Setting/BrightnessWidget.cpp b/src/OpenVario/System/Setting/BrightnessWidget.cpp deleted file mode 100644 index 7198f000a2d..00000000000 --- a/src/OpenVario/System/Setting/BrightnessWidget.cpp +++ /dev/null @@ -1,93 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -// Copyright The XCSoar Project - -#include "Dialogs/DialogSettings.hpp" -#include "Dialogs/Message.hpp" -#include "Dialogs/ProcessDialog.hpp" -#include "Dialogs/WidgetDialog.hpp" -#include "DisplayOrientation.hpp" -#include "Hardware/DisplayDPI.hpp" -#include "Hardware/DisplayGlue.hpp" -#include "Hardware/RotateDisplay.hpp" -#include "Look/DialogLook.hpp" -#include "Profile/File.hpp" -#include "Profile/Map.hpp" -#include "Screen/Layout.hpp" -#include "UIGlobals.hpp" -// #include "Widget/RowFormWidget.hpp" -#include "system/FileUtil.hpp" -#include "system/Process.hpp" -#include "ui/event/KeyCode.hpp" -// #include "ui/event/Queue.hpp" -#include "ui/event/Timer.hpp" -#include "ui/window/Init.hpp" -// #include "ui/window/SingleWindow.hpp" - -#include "Language/Language.hpp" - -#include "io/KeyValueFileReader.hpp" -#include "io/FileOutputStream.hxx" -#include "io/BufferedOutputStream.hxx" -#include "io/FileLineReader.hpp" - -#include "OpenVario/System/System.hpp" -#include "OpenVario/System/Setting/BrightnessWidget.hpp" - -#ifndef __MSVC__ -#include -#include -#endif -#include - -#include -#include - -//---------------------------------------------------------- -//---------------------------------------------------------- -//---------------------------------------------------------- -void SettingBrightnessWidget::SaveBrightness(const std::string &brightness) { - File::WriteExisting(Path(_T("/sys/class/backlight/lcd/brightness")), - (brightness).c_str()); -} - -void -SettingBrightnessWidget::Prepare([[maybe_unused]] ContainerWindow &parent, - [[maybe_unused]] const PixelRect &rc) noexcept -{ - AddButton(_T("20"), [this](){ - SaveBrightness("2"); - }); - - AddButton(_T("30"), [this](){ - SaveBrightness("3"); - }); - - AddButton(_T("40"), [this](){ - SaveBrightness("4"); - }); - - AddButton(_T("50"), [this](){ - SaveBrightness("5"); - }); - - AddButton(_T("60"), [this](){ - SaveBrightness("6"); - }); - - AddButton(_T("70"), [this](){ - SaveBrightness("7"); - }); - - AddButton(_T("80"), [this](){ - SaveBrightness("8"); - }); - - AddButton(_T("90"), [this](){ - SaveBrightness("9"); - }); - - AddButton(_T("100"), [this](){ - SaveBrightness("10"); - }); -} - diff --git a/src/OpenVario/System/Setting/BrightnessWidget.hpp b/src/OpenVario/System/Setting/BrightnessWidget.hpp deleted file mode 100644 index 58e0a5c8b9b..00000000000 --- a/src/OpenVario/System/Setting/BrightnessWidget.hpp +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -// Copyright The XCSoar Project - -#pragma once - -#include "Widget/RowFormWidget.hpp" -#include "ui/event/Queue.hpp" -#include "ui/window/SingleWindow.hpp" - -class SettingBrightnessWidget final - : public RowFormWidget -{ - UI::Display &display; - UI::EventQueue &event_queue; - -public: - SettingBrightnessWidget(UI::Display &_display, UI::EventQueue &_event_queue, - const DialogLook &look) noexcept - :RowFormWidget(look), - display(_display), event_queue(_event_queue) {} - -private: - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, - const PixelRect &rc) noexcept override; - - void SaveBrightness(const std::string &brightness); -}; diff --git a/src/OpenVario/System/Setting/SSHWidget.cpp b/src/OpenVario/System/Setting/SSHWidget.cpp deleted file mode 100644 index ed0da52642b..00000000000 --- a/src/OpenVario/System/Setting/SSHWidget.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -// Copyright The XCSoar Project - -#include "Dialogs/DialogSettings.hpp" -#include "Dialogs/Message.hpp" -#include "Dialogs/ProcessDialog.hpp" -#include "Dialogs/WidgetDialog.hpp" -#include "DisplayOrientation.hpp" -#include "Hardware/DisplayDPI.hpp" -#include "Hardware/DisplayGlue.hpp" -#include "Hardware/RotateDisplay.hpp" -#include "Look/DialogLook.hpp" -#include "Profile/File.hpp" -#include "Profile/Map.hpp" -#include "Screen/Layout.hpp" -#include "UIGlobals.hpp" -// #include "Widget/RowFormWidget.hpp" -#include "system/FileUtil.hpp" -#include "system/Process.hpp" -#include "ui/event/KeyCode.hpp" -// #include "ui/event/Queue.hpp" -#include "ui/event/Timer.hpp" -#include "ui/window/Init.hpp" -// #include "ui/window/SingleWindow.hpp" - -#include "Language/Language.hpp" - -#include "io/KeyValueFileReader.hpp" -#include "io/FileOutputStream.hxx" -#include "io/BufferedOutputStream.hxx" -#include "io/FileLineReader.hpp" - -#include "OpenVario/System/System.hpp" -#include "OpenVario/System/Setting/SSHWidget.hpp" - -#ifndef __MSVC__ -#include -#include -#endif -#include - -#include -#include - -void -SettingSSHWidget::Prepare([[maybe_unused]] ContainerWindow &parent, - [[maybe_unused]] const PixelRect &rc) noexcept -{ - AddButton(_T("Enable") , [](){ - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "systemctl enable dropbear.socket && printf '\nSSH has been enabled'", - - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("Enable"), argv); - }); - - AddButton(_T("Disable") , [](){ - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "systemctl disable dropbear.socket && printf '\nSSH has been disabled'", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("Disable"), argv); - }); -} diff --git a/src/OpenVario/System/Setting/SSHWidget.hpp b/src/OpenVario/System/Setting/SSHWidget.hpp deleted file mode 100644 index 345cc7c7a35..00000000000 --- a/src/OpenVario/System/Setting/SSHWidget.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -// Copyright The XCSoar Project - -#pragma once - -#include "Widget/RowFormWidget.hpp" -#include "ui/event/Queue.hpp" -#include "ui/window/SingleWindow.hpp" - -class SettingSSHWidget final - : public RowFormWidget -{ - UI::Display &display; - UI::EventQueue &event_queue; - -public: - SettingSSHWidget(UI::Display &_display, UI::EventQueue &_event_queue, - const DialogLook &look) noexcept - :RowFormWidget(look), - display(_display), event_queue(_event_queue) {} - -private: - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, - const PixelRect &rc) noexcept override; -}; - diff --git a/src/OpenVario/System/Setting/SensordWidget.cpp b/src/OpenVario/System/Setting/SensordWidget.cpp deleted file mode 100644 index 043a8abbb6e..00000000000 --- a/src/OpenVario/System/Setting/SensordWidget.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -// Copyright The XCSoar Project - -#include "Dialogs/DialogSettings.hpp" -#include "Dialogs/Message.hpp" -#include "Dialogs/ProcessDialog.hpp" -#include "Dialogs/WidgetDialog.hpp" -#include "DisplayOrientation.hpp" -#include "Hardware/DisplayDPI.hpp" -#include "Hardware/DisplayGlue.hpp" -#include "Hardware/RotateDisplay.hpp" -#include "Look/DialogLook.hpp" -#include "Profile/File.hpp" -#include "Profile/Map.hpp" -#include "Screen/Layout.hpp" -#include "UIGlobals.hpp" -// #include "Widget/RowFormWidget.hpp" -#include "system/FileUtil.hpp" -#include "system/Process.hpp" -#include "ui/event/KeyCode.hpp" -// #include "ui/event/Queue.hpp" -#include "ui/event/Timer.hpp" -#include "ui/window/Init.hpp" -// #include "ui/window/SingleWindow.hpp" - -#include "Language/Language.hpp" - -#include "io/KeyValueFileReader.hpp" -#include "io/FileOutputStream.hxx" -#include "io/BufferedOutputStream.hxx" -#include "io/FileLineReader.hpp" - -#include "OpenVario/System/System.hpp" -#include "OpenVario/System/Setting/SensordWidget.hpp" - -#ifndef __MSVC__ -#include -#include -#endif -#include - -#include -#include - -//---------------------------------------------------------- -//---------------------------------------------------------- -//---------------------------------------------------------- -void -SettingSensordWidget::Prepare([[maybe_unused]] ContainerWindow &parent, - [[maybe_unused]] const PixelRect &rc) noexcept -{ - AddButton(_T("Enable"), [](){ - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "systemctl enable sensord && printf '\nsensord has been enabled'", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("Enable"), argv); - }); - - AddButton(_T("Disable"), [](){ - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "systemctl disable sensord && printf '\nsensord has been disabled'", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("Disable"), argv); - }); -} diff --git a/src/OpenVario/System/Setting/SensordWidget.hpp b/src/OpenVario/System/Setting/SensordWidget.hpp deleted file mode 100644 index 03e15441f6c..00000000000 --- a/src/OpenVario/System/Setting/SensordWidget.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -// Copyright The XCSoar Project - -#pragma once - -#include "Widget/RowFormWidget.hpp" -#include "ui/event/Queue.hpp" -#include "ui/window/SingleWindow.hpp" - -class SettingSensordWidget final - : public RowFormWidget -{ - UI::Display &display; - UI::EventQueue &event_queue; - -public: - SettingSensordWidget(UI::Display &_display, UI::EventQueue &_event_queue, - const DialogLook &look) noexcept - :RowFormWidget(look), - display(_display), event_queue(_event_queue) {} - -private: - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, - const PixelRect &rc) noexcept override; -}; - diff --git a/src/OpenVario/System/Setting/TimeoutWidget.cpp b/src/OpenVario/System/Setting/TimeoutWidget.cpp deleted file mode 100644 index e1969dc45c6..00000000000 --- a/src/OpenVario/System/Setting/TimeoutWidget.cpp +++ /dev/null @@ -1,141 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -// Copyright The XCSoar Project - -#include "Dialogs/DialogSettings.hpp" -#include "Dialogs/Message.hpp" -#include "Dialogs/ProcessDialog.hpp" -#include "Dialogs/WidgetDialog.hpp" -#include "DisplayOrientation.hpp" -#include "Hardware/DisplayDPI.hpp" -#include "Hardware/DisplayGlue.hpp" -#include "Hardware/RotateDisplay.hpp" -#include "Look/DialogLook.hpp" -#include "Profile/File.hpp" -#include "Profile/Map.hpp" -#include "Screen/Layout.hpp" -#include "UIGlobals.hpp" -// #include "Widget/RowFormWidget.hpp" -#include "system/FileUtil.hpp" -#include "system/Process.hpp" -#include "ui/event/KeyCode.hpp" -// #include "ui/event/Queue.hpp" -#include "ui/event/Timer.hpp" -#include "ui/window/Init.hpp" -// #include "ui/window/SingleWindow.hpp" - -#include "Language/Language.hpp" - -#include "io/KeyValueFileReader.hpp" -#include "io/FileOutputStream.hxx" -#include "io/BufferedOutputStream.hxx" -#include "io/FileLineReader.hpp" - -#include "OpenVario/System/System.hpp" -#include "OpenVario/System/Setting/TimeoutWidget.hpp" - -#ifndef __MSVC__ -#include -#include -#endif -#include - -#include -#include - -//---------------------------------------------------------- -//---------------------------------------------------------- -//---------------------------------------------------------- - -void -SettingTimeoutWidget::SaveTimeout(int timeoutInt) -{ - ovdevice.timeout = timeoutInt; - ovdevice.settings.insert_or_assign("Timeout", - std::to_string(ovdevice.timeout)); - WriteConfigFile(ovdevice.settings, ovdevice.GetSettingsConfig()); -} - -void -SettingTimeoutWidget::Prepare([[maybe_unused]] ContainerWindow &parent, - [[maybe_unused]] const PixelRect &rc) noexcept - -{ - AddButton(_T("immediately"), [this](){ - SaveTimeout(0); - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "echo Automatic timeout was set to 0s", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("immediately"), argv); - }); - - AddButton(_T("1s"), [this](){ - SaveTimeout(1); - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "echo Automatic timeout was set to 1s", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("1s"), argv); - }); - - AddButton(_T("3s"), [this](){ - SaveTimeout(3); - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "echo Automatic timeout was set to 3s", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("3s"), argv); - }); - - AddButton(_T("5s"), [this](){ - SaveTimeout(5); - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "echo Automatic timeout was set to 5s", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("5s"), argv); - }); - - AddButton(_T("10s"), [this](){ - SaveTimeout(10); - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "echo Automatic timeout was set to 10s", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("10s"), argv); - }); - - AddButton(_T("30s"), [this](){ - SaveTimeout(30); - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "echo Automatic timeout was set to 30s", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("30s"), argv); - }); -} - diff --git a/src/OpenVario/System/Setting/TimeoutWidget.hpp b/src/OpenVario/System/Setting/TimeoutWidget.hpp deleted file mode 100644 index c3480e4fb29..00000000000 --- a/src/OpenVario/System/Setting/TimeoutWidget.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -// Copyright The XCSoar Project - -#pragma once - -#include "Widget/RowFormWidget.hpp" -#include "ui/event/Queue.hpp" -#include "ui/window/SingleWindow.hpp" - -class SettingTimeoutWidget final - : public RowFormWidget -{ - UI::Display &display; - UI::EventQueue &event_queue; - -public: - SettingTimeoutWidget(UI::Display &_display, UI::EventQueue &_event_queue, - const DialogLook &look) noexcept - :RowFormWidget(look), - display(_display), event_queue(_event_queue) {} - -private: - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, - const PixelRect &rc) noexcept override; - void SaveTimeout(int timeoutvalue); -}; diff --git a/src/OpenVario/System/Setting/VariodWidget.cpp b/src/OpenVario/System/Setting/VariodWidget.cpp deleted file mode 100644 index 1d02caa3530..00000000000 --- a/src/OpenVario/System/Setting/VariodWidget.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -// Copyright The XCSoar Project - -#include "Dialogs/DialogSettings.hpp" -#include "Dialogs/Message.hpp" -#include "Dialogs/ProcessDialog.hpp" -#include "Dialogs/WidgetDialog.hpp" -#include "DisplayOrientation.hpp" -#include "Hardware/DisplayDPI.hpp" -#include "Hardware/DisplayGlue.hpp" -#include "Hardware/RotateDisplay.hpp" -#include "Look/DialogLook.hpp" -#include "Profile/File.hpp" -#include "Profile/Map.hpp" -#include "Screen/Layout.hpp" -#include "UIGlobals.hpp" -// #include "Widget/RowFormWidget.hpp" -#include "system/FileUtil.hpp" -#include "system/Process.hpp" -#include "ui/event/KeyCode.hpp" -// #include "ui/event/Queue.hpp" -#include "ui/event/Timer.hpp" -#include "ui/window/Init.hpp" -// #include "ui/window/SingleWindow.hpp" - -#include "Language/Language.hpp" - -#include "io/KeyValueFileReader.hpp" -#include "io/FileOutputStream.hxx" -#include "io/BufferedOutputStream.hxx" -#include "io/FileLineReader.hpp" - -#include "OpenVario/System/System.hpp" -#include "OpenVario/System/Setting/VariodWidget.hpp" - -#ifndef __MSVC__ -#include -#include -#endif -#include - -#include -#include - -//---------------------------------------------------------- -//---------------------------------------------------------- -//---------------------------------------------------------- -void -SettingVariodWidget::Prepare([[maybe_unused]] ContainerWindow &parent, - [[maybe_unused]] const PixelRect &rc) noexcept -{ - AddButton(_T("Enable") , [](){ - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "systemctl enable variod && printf '\nvariod has been enabled'", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("Enable"), argv); - }); - - AddButton(_T("Disable"), [](){ - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "systemctl disable variod && printf '\nvariod has been disabled'", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("Disable"), argv); - }); -} - diff --git a/src/OpenVario/System/Setting/VariodWidget.hpp b/src/OpenVario/System/Setting/VariodWidget.hpp deleted file mode 100644 index 21e42d4af8f..00000000000 --- a/src/OpenVario/System/Setting/VariodWidget.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -// Copyright The XCSoar Project - -#pragma once - -#include "Widget/RowFormWidget.hpp" -#include "ui/event/Queue.hpp" -#include "ui/window/SingleWindow.hpp" - -class SettingVariodWidget final - : public RowFormWidget -{ - UI::Display &display; - UI::EventQueue &event_queue; - -public: - SettingVariodWidget(UI::Display &_display, UI::EventQueue &_event_queue, - const DialogLook &look) noexcept - :RowFormWidget(look), - display(_display), event_queue(_event_queue) {} - -private: - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, - const PixelRect &rc) noexcept override; -}; - diff --git a/src/OpenVario/System/System.cpp b/src/OpenVario/System/System.cpp index 3cda67eed81..8a1cb3e2f1b 100644 --- a/src/OpenVario/System/System.cpp +++ b/src/OpenVario/System/System.cpp @@ -23,6 +23,9 @@ #include "util/StaticString.hxx" #include "util/ConvertString.hpp" +#include "LogFile.hpp" +#include "LocalPath.hpp" + #include "OpenVario/System/System.hpp" #ifndef _WIN32 @@ -47,39 +50,61 @@ OpenVario_Device ovdevice; -OpenVario_Device::OpenVario_Device() { - StaticString<0x100> home; - home.SetUTF8(getenv("HOME")); - home_path = Path(home); +void +OpenVario_Device::Initialise() noexcept { + if (!initialised) { + InitialiseDataPath(); + StaticString<0x100> home; + home.SetUTF8(getenv("HOME")); + home_path = Path(home); #ifdef _WIN32 -// DataPath = Path(_T("D:/Data/OpenSoarData")); - data_path = Path(_T("D:/Data/XCSoarData")); + data_path = Path(_T("D:/Data/OpenSoarData")); #else - data_path = Path(_T("data")); + data_path = Path(_T("data")); - system_config = - AllocatedPath::Build(Path(_T("/boot")), Path(_T("config.uEnf"))); - is_real = File::Exists(system_config); + system_config = + AllocatedPath::Build(Path(_T("/boot")), Path(_T("config.uEnf"))); + is_real = File::Exists(system_config); #endif - if (Directory::Exists(data_path)) { - // auto config = AllocatedPath::Build(data_path, Path(_T("openvario.cfg"))); - settings_config = - AllocatedPath::Build(data_path, Path(_T("openvario.cfg"))); - upgrade_config = AllocatedPath::Build(data_path, Path(_T("upgrade.cfg"))); - } else { - settings_config = - AllocatedPath::Build(home_path, Path(_T("openvario.cfg"))); - upgrade_config = AllocatedPath::Build(home_path, Path(_T("upgrade.cfg"))); - } - system_config = AllocatedPath::Build(home_path, Path(_T("config.uEnv"))); - - if (!File::Exists(settings_config)) - File::CreateExclusive(settings_config); - - assert(File::Exists(settings_config)); + if (Directory::Exists(data_path)) { + // auto config = AllocatedPath::Build(data_path, + // Path(_T("openvario.cfg"))); + settings_config = + AllocatedPath::Build(data_path, Path(_T("openvario.cfg"))); + upgrade_config = AllocatedPath::Build(data_path, Path(_T("upgrade.cfg"))); + } else { + settings_config = + AllocatedPath::Build(home_path, Path(_T("openvario.cfg"))); + upgrade_config = AllocatedPath::Build(home_path, Path(_T("upgrade.cfg"))); + } + system_config = AllocatedPath::Build(home_path, Path(_T("config.uEnv"))); + + if (!File::Exists(settings_config)) + File::CreateExclusive(settings_config); + + assert(File::Exists(settings_config)); + + internal_config = + AllocatedPath::Build(data_path, Path(_T("ov-internal.cfg"))); + + SetPrimaryDataPath(data_path); + //---------------------------- + LogFormat("data_path = %s", data_path.ToUTF8().c_str()); +#ifdef DEBUG_OPENVARIO + LogFormat("home_path = %s", home_path.ToUTF8().c_str()); + LogFormat("settings_config = %s", settings_config.ToUTF8().c_str()); + LogFormat("system_config = %s", system_config.ToUTF8().c_str()); + LogFormat("upgrade_config = %s", upgrade_config.ToUTF8().c_str()); + // the same...: LogFormat(_T("upgrade_config = %s"), upgrade_config.c_str()); + LogFormat("is_real = %s", is_real ? "True" : "False"); +#endif + //---------------------------- + initialised = true; + } } +void OpenVario_Device::Deinitialise() noexcept {} //---------------------------------------------------------- -void ReadBool(std::map> &map, + void ReadBool(std::map> &map, std::string_view name, bool &value) noexcept { if (map.find(name) != map.end()) value = map.find(name)->second != "False"; @@ -103,7 +128,9 @@ OpenVario_Device::LoadSettings() noexcept LoadConfigFile(system_map, GetSystemConfig()); LoadConfigFile(settings, GetSettingsConfig()); LoadConfigFile(upgrade_map, GetUpgradeConfig()); - +#ifdef _WIN32 + LoadConfigFile(internal_map, GetInternalConfig()); +#endif ReadInteger(system_map, "rotation", rotation); #ifdef _DEBUG std::string_view fdtfile; @@ -143,40 +170,6 @@ WriteConfigFile(std::map> &map, Path path) file.Commit(); } -//---------------------------------------------------------- -/*/ -void -GetConfigInt(const std::string &keyvalue, unsigned &value, - const Path &config) -{ - if (File::Exists(config)) { - ProfileMap configuration; - Profile::LoadFile(configuration, config); - configuration.Get(keyvalue.c_str(), value); - } else { - debugln("ConfigFile '%s' does not exist!", config.c_str()); - } -} - -void -ChangeConfigInt(const std::string &keyvalue, int value, - const Path &config) -{ - if (File::Exists(config)) { - ProfileMap configuration; - try { - Profile::LoadFile(configuration, config); - } catch (std::exception &e) { - Profile::SaveFile(configuration, config); - } - configuration.Set(keyvalue.c_str(), value); - Profile::SaveFile(configuration, config); - } else { - debugln("ConfigFile '%s' does not exist!", config.c_str()); - } -} -*/ - //---------------------------------------------------------- uint_least8_t OpenvarioGetBrightness() noexcept @@ -263,44 +256,86 @@ OpenvarioGetSSHStatus() } } -void -OpenvarioEnableSSH(bool temporary) -{ +void OpenvarioSetSSHStatus(SSHStatus state) { auto connection = ODBus::Connection::GetSystem(); - const ODBus::ScopeMatch job_removed_match{connection, Systemd::job_removed_match}; - - if (temporary) - Systemd::DisableUnitFile(connection, "dropbear.socket"); - else + const ODBus::ScopeMatch job_removed_match{connection, + Systemd::job_removed_match}; + switch (state) { + case SSHStatus::ENABLED: Systemd::EnableUnitFile(connection, "dropbear.socket"); - - Systemd::StartUnit(connection, "dropbear.socket"); + Systemd::StartUnit(connection, "dropbear.socket"); + break; + case SSHStatus::TEMPORARY: + Systemd::DisableUnitFile(connection, "dropbear.socket"); + Systemd::StartUnit(connection, "dropbear.socket"); + break; + case SSHStatus::DISABLED: + Systemd::DisableUnitFile(connection, "dropbear.socket"); + Systemd::StopUnit(connection, "dropbear.socket"); + break; + } +} +#else // DBUS_FUNCTIONS +bool OpenvarioGetSensordStatus() noexcept { + bool value; + ReadBool(ovdevice.internal_map, "SensorD", value); + return value; +} +bool OpenvarioGetVariodStatus() noexcept { + bool value; + ReadBool(ovdevice.internal_map, "VarioD", value); + return value; +} +void OpenvarioSetSensordStatus(bool value) noexcept { + ovdevice.internal_map.insert_or_assign("SensorD", value ? "True" : "False"); + WriteConfigFile(ovdevice.internal_map, ovdevice.GetInternalConfig()); +} +void OpenvarioSetVariodStatus(bool value) noexcept { + ovdevice.internal_map.insert_or_assign("VarioD", value ? "True" : "False"); + WriteConfigFile(ovdevice.internal_map, ovdevice.GetInternalConfig()); } -void -OpenvarioDisableSSH() -{ - auto connection = ODBus::Connection::GetSystem(); - const ODBus::ScopeMatch job_removed_match{connection, Systemd::job_removed_match}; +SSHStatus +OpenvarioGetSSHStatus() +{ + unsigned ssh; + ReadInteger(ovdevice.internal_map, "SSH", ssh); - Systemd::DisableUnitFile(connection, "dropbear.socket"); - Systemd::StopUnit(connection, "dropbear.socket"); + if (ssh == 0) { + return SSHStatus::ENABLED; + } else if (ssh == 1) { + return SSHStatus::DISABLED; + } else { + return SSHStatus::TEMPORARY; + } } -#endif // DBUS_FUNCTIONS +void OpenvarioSetSSHStatus(SSHStatus state) { + switch (state) { + case SSHStatus::DISABLED: + case SSHStatus::ENABLED: + case SSHStatus::TEMPORARY: + ovdevice.internal_map.insert_or_assign("SSH", + std::to_string((unsigned)state)); + WriteConfigFile(ovdevice.internal_map, ovdevice.GetInternalConfig()); + break; + } +} +#endif // DBUS_FUNCTIONS -#ifndef MAX_PATH -#define MAX_PATH 0x100 -#endif -void debugln(const char *fmt, ...) noexcept { - char buf[MAX_PATH]; - va_list ap; - - va_start(ap, fmt); - vsnprintf(buf, sizeof(buf) - 1, fmt, ap); - va_end(ap); - std::cout << buf << std::endl; -} +// #ifndef MAX_PATH +// #define MAX_PATH 0x100 +// #endif +// void debugln(const char *fmt, ...) noexcept { +// char buf[MAX_PATH]; +// va_list ap; +// +// va_start(ap, fmt); +// vsnprintf(buf, sizeof(buf) - 1, fmt, ap); +// va_end(ap); +// +// std::cout << buf << std::endl; +// } //---------------------------------------------------------- diff --git a/src/OpenVario/System/System.hpp b/src/OpenVario/System/System.hpp index a791a756a21..1fa69bcd18b 100644 --- a/src/OpenVario/System/System.hpp +++ b/src/OpenVario/System/System.hpp @@ -13,7 +13,7 @@ #include -void debugln(const char *fmt, ...) noexcept; +#define DEBUG_OPENVARIO 1 enum class SSHStatus { ENABLED, @@ -28,8 +28,10 @@ enum Buttons { class OpenVario_Device { public: - OpenVario_Device(); + OpenVario_Device() {} + void Initialise() noexcept; + void Deinitialise() noexcept; void LoadSettings() noexcept; Path GetSystemConfig() noexcept { return system_config; } // void SetSystemConfig(Path configfile) noexcept { system_config = configfile; } @@ -88,6 +90,7 @@ class OpenVario_Device { AllocatedPath data_path; bool is_real = false; + bool initialised = false; }; extern OpenVario_Device ovdevice; diff --git a/src/OpenVario/System/SystemMenuWidget.cpp b/src/OpenVario/System/SystemMenuWidget.cpp index 35a7e2f57ac..917804a0cf4 100644 --- a/src/OpenVario/System/SystemMenuWidget.cpp +++ b/src/OpenVario/System/SystemMenuWidget.cpp @@ -29,6 +29,7 @@ #include "OpenVario/System/System.hpp" #include "OpenVario/System/SystemSettingsWidget.hpp" #include "OpenVario/System/SystemMenuWidget.hpp" +#include "Dialogs/Settings/Panels/OpenVarioConfigPanel.hpp" #include #include @@ -152,7 +153,18 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, return sub_dialog.ShowModal(); }); - AddButton(_("System Info"), [](){ + AddButton(_("Device Settings"), [this]() { + std::unique_ptr widget = CreateOpenVarioConfigPanel(); + + TWidgetDialog sub_dialog( + WidgetDialog::Full{}, dialog.GetMainWindow(), GetLook(), + _T("OpenVario System Settings")); + sub_dialog.SetWidget(); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); + }); + + AddButton(_("System Info"), []() { static constexpr const char *argv[] = { "/usr/bin/system-info.sh", nullptr }; diff --git a/src/OpenVario/System/SystemSettingsWidget.cpp b/src/OpenVario/System/SystemSettingsWidget.cpp index 7c21dee42c5..c3dea2ff02f 100644 --- a/src/OpenVario/System/SystemSettingsWidget.cpp +++ b/src/OpenVario/System/SystemSettingsWidget.cpp @@ -14,11 +14,9 @@ #include "Profile/Map.hpp" #include "Screen/Layout.hpp" #include "UIGlobals.hpp" -// #include "Widget/RowFormWidget.hpp" #include "system/FileUtil.hpp" #include "system/Process.hpp" #include "ui/event/KeyCode.hpp" -// #include "ui/event/Queue.hpp" #include "ui/event/Timer.hpp" #include "ui/window/Init.hpp" @@ -32,11 +30,9 @@ #include "OpenVario/System/System.hpp" #include "OpenVario/System/SystemSettingsWidget.hpp" #include "OpenVario/System/Setting/RotationWidget.hpp" -#include "OpenVario/System/Setting/BrightnessWidget.hpp" -#include "OpenVario/System/Setting/TimeoutWidget.hpp" -#include "OpenVario/System/Setting/SSHWidget.hpp" -#include "OpenVario/System/Setting/SensordWidget.hpp" -#include "OpenVario/System/Setting/VariodWidget.hpp" +// #include "OpenVario/System/Setting/SSHWidget.hpp" +// #include "OpenVario/System/Setting/SensordWidget.hpp" +// #include "OpenVario/System/Setting/VariodWidget.hpp" #include "OpenVario/System/Setting/WifiWidget.hpp" #ifndef _WIN32 @@ -61,54 +57,54 @@ SystemSettingsWidget::Prepare([[maybe_unused]] ContainerWindow &parent, return sub_dialog.ShowModal(); }); - AddButton(_("Setting Brightness"), [this](){ - TWidgetDialog - sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), _T("Display Brightness Settings")); - sub_dialog.SetWidget(display, event_queue, GetLook()); - sub_dialog.AddButton(_("Close"), mrOK); - return sub_dialog.ShowModal(); - }); - - uint32_t iTest = 0; - AddInteger(_("Brightness Test"), _("Setting Brightness."), _T("%d"), _T("%d"), 1, - 10, 1, iTest); - +// AddButton(_("Setting Brightness"), [this](){ +// TWidgetDialog +// sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), +// GetLook(), _T("Display Brightness Settings")); +// sub_dialog.SetWidget(display, event_queue, GetLook()); +// sub_dialog.AddButton(_("Close"), mrOK); +// return sub_dialog.ShowModal(); +// }); +// +// uint32_t iTest = 0; +// AddInteger(_("Brightness Test"), _("Setting Brightness."), _T("%d"), _T("%d"), 1, +// 10, 1, iTest); - AddButton(_("Autostart Timeout"), [this](){ - TWidgetDialog - sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), _T("Autostart Timeout")); - sub_dialog.SetWidget(display, event_queue, GetLook()); - sub_dialog.AddButton(_("Close"), mrOK); - return sub_dialog.ShowModal(); - }); - - AddButton(_("SSH"), [this](){ - TWidgetDialog - sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), _T("Enable or Disable SSH")); - sub_dialog.SetWidget(display, event_queue, GetLook()); - sub_dialog.AddButton(_("Close"), mrOK); - return sub_dialog.ShowModal(); - }); - AddButton(_("Variod"), [this](){ - TWidgetDialog - sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), _T("Enable or Disable Variod")); - sub_dialog.SetWidget(display, event_queue, GetLook()); - sub_dialog.AddButton(_("Close"), mrOK); - return sub_dialog.ShowModal(); - }); +// AddButton(_("Autostart Timeout"), [this](){ +// TWidgetDialog +// sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), +// GetLook(), _T("Autostart Timeout")); +// sub_dialog.SetWidget(display, event_queue, GetLook()); +// sub_dialog.AddButton(_("Close"), mrOK); +// return sub_dialog.ShowModal(); +// }); - AddButton(_("Sensord"), [this](){ - TWidgetDialog - sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), _T("Enable or Disable Sensord")); - sub_dialog.SetWidget(display, event_queue, GetLook()); - sub_dialog.AddButton(_("Close"), mrOK); - return sub_dialog.ShowModal(); - }); +// AddButton(_("SSH"), [this](){ +// TWidgetDialog +// sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), +// GetLook(), _T("Enable or Disable SSH")); +// sub_dialog.SetWidget(display, event_queue, GetLook()); +// sub_dialog.AddButton(_("Close"), mrOK); +// return sub_dialog.ShowModal(); +// }); +// +// AddButton(_("Variod"), [this](){ +// TWidgetDialog +// sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), +// GetLook(), _T("Enable or Disable Variod")); +// sub_dialog.SetWidget(display, event_queue, GetLook()); +// sub_dialog.AddButton(_("Close"), mrOK); +// return sub_dialog.ShowModal(); +// }); +// +// AddButton(_("Sensord"), [this](){ +// TWidgetDialog +// sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), +// GetLook(), _T("Enable or Disable Sensord")); +// sub_dialog.SetWidget(display, event_queue, GetLook()); +// sub_dialog.AddButton(_("Close"), mrOK); +// return sub_dialog.ShowModal(); +// }); } From 46960a9292e3d8a91bd0b65483f7d357f98b2f7b Mon Sep 17 00:00:00 2001 From: August2111 Date: Sun, 14 Jan 2024 21:58:00 +0100 Subject: [PATCH 128/403] [CMake] OpenVarioBaseMenu - complete reorganization of structure (part2) --- src/OpenVario/CMakeSource.cmake | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/OpenVario/CMakeSource.cmake b/src/OpenVario/CMakeSource.cmake index 0c36643231c..15b50ef0cac 100644 --- a/src/OpenVario/CMakeSource.cmake +++ b/src/OpenVario/CMakeSource.cmake @@ -9,11 +9,6 @@ set(_SOURCES OpenVario/System/SystemMenuWidget.cpp OpenVario/System/SystemSettingsWidget.cpp OpenVario/System/Setting/RotationWidget.cpp - # OpenVario/System/Setting/BrightnessWidget.cpp - # OpenVario/System/Setting/TimeoutWidget.cpp - # OpenVario/System/Setting/SSHWidget.cpp - # OpenVario/System/Setting/VariodWidget.cpp - # OpenVario/System/Setting/SensordWidget.cpp OpenVario/System/Setting/WifiWidget.cpp OpenVario/System/WifiDialogOV.cpp @@ -49,6 +44,7 @@ set(_SOURCES ${SRC}/Profile/Map.cpp ${SRC}/Profile/File.cpp ${SRC}/Profile/NumericValue.cpp + ${SRC}/LocalPath.cpp # ${TEST_SRC_DIR}/Fonts.cpp # ${SRC}/Language/Language.cpp # ${TEST_SRC_DIR}/FakeLanguage.cpp ${SRC}/LogFile.cpp # ${TEST_SRC_DIR}/FakeLogFile.cpp @@ -86,7 +82,6 @@ if(WIN32) endif() list(APPEND _SOURCES # FakeLogFile ${SRC}/LogFile.cpp - ${SRC}/LocalPath.cpp ${SRC}/ProgressGlue.cpp ${SRC}/ProgressWindow.cpp From 0c019ed42a867ad22b413e1e1ebbdac301a30d5e Mon Sep 17 00:00:00 2001 From: August2111 Date: Sun, 14 Jan 2024 21:58:56 +0100 Subject: [PATCH 129/403] [build] ov.mk, main.mk: OpenVarioBaseMenu - re-org of structure (part2) * missing DBUS library in OpenVarioBaseMenu --- build/main.mk | 5 ----- build/ov.mk | 20 +++++++++++--------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/build/main.mk b/build/main.mk index fb7ba9b0b3e..80b304fbf5f 100644 --- a/build/main.mk +++ b/build/main.mk @@ -163,11 +163,6 @@ DIALOG_SOURCES += \ $(SRC)/OpenVario/System/SystemMenuWidget.cpp \ $(SRC)/OpenVario/System/SystemSettingsWidget.cpp \ $(SRC)/OpenVario/System/Setting/RotationWidget.cpp \ - $(SRC)/OpenVario/System/Setting/BrightnessWidget.cpp \ - $(SRC)/OpenVario/System/Setting/TimeoutWidget.cpp \ - $(SRC)/OpenVario/System/Setting/SSHWidget.cpp \ - $(SRC)/OpenVario/System/Setting/VariodWidget.cpp \ - $(SRC)/OpenVario/System/Setting/SensordWidget.cpp \ $(SRC)/OpenVario/System/Setting/WifiWidget.cpp \ \ $(SRC)/OpenVario/System/WifiDialogOV.cpp \ diff --git a/build/ov.mk b/build/ov.mk index b6fb1176011..80d4c7cdd51 100644 --- a/build/ov.mk +++ b/build/ov.mk @@ -188,11 +188,6 @@ OV_MENU_SOURCES = \ $(SRC)/OpenVario/System/SystemMenuWidget.cpp \ $(SRC)/OpenVario/System/SystemSettingsWidget.cpp \ $(SRC)/OpenVario/System/Setting/RotationWidget.cpp \ - $(SRC)/OpenVario/System/Setting/BrightnessWidget.cpp \ - $(SRC)/OpenVario/System/Setting/TimeoutWidget.cpp \ - $(SRC)/OpenVario/System/Setting/SSHWidget.cpp \ - $(SRC)/OpenVario/System/Setting/VariodWidget.cpp \ - $(SRC)/OpenVario/System/Setting/SensordWidget.cpp \ $(SRC)/OpenVario/System/Setting/WifiWidget.cpp \ \ $(SRC)/OpenVario/System/WifiDialogOV.cpp \ @@ -228,11 +223,11 @@ OV_MENU_SOURCES = \ $(SRC)/Profile/Map.cpp \ $(SRC)/Profile/File.cpp \ $(SRC)/Profile/NumericValue.cpp \ - # $(TEST_SRC_DIR)/Fonts.cpp \ - # $(SRC)/Language/Language.cpp # $(TEST_SRC_DIR)/FakeLanguage.cpp \ - $(SRC)/LogFile.cpp # $(TEST_SRC_DIR)/FakeLogFile.cpp \ + $(TEST_SRC_DIR)/Fonts.cpp \ + $(SRC)/Language/Language.cpp \ \ $(SRC)/LocalPath.cpp \ + $(SRC)/LogFile.cpp \ $(SRC)/Form/DigitEntry.cpp \ $(SRC)/Renderer/TextRowRenderer.cpp \ $(SRC)/net/http/DownloadManager.cpp \ @@ -250,6 +245,7 @@ OV_MENU_SOURCES = \ $(SRC)/event/Call.cxx \ $(SRC)/Math/FastTrig.cpp \ $(SRC)/ui/window/ContainerWindow.cpp \ + \ @@ -260,7 +256,13 @@ OV_MENU_DEPENDS = WIDGET FORM DATA_FIELD SCREEN EVENT RESOURCE ASYNC LIBNET OS I PROFILE \ LOOK \ LIBHTTP \ - CO OPERATION UNITS + CO OPERATION UNITS \ + DBUS + +# $(TEST_SRC_DIR)/Fonts.cpp +# $(SRC)/Language/Language.cpp # $(TEST_SRC_DIR)/FakeLanguage.cpp +# $(SRC)/LocalPath.cpp +# $(SRC)/LogFile.cpp # $(TEST_SRC_DIR)/FakeLogFile.cpp ### $(SRC)/Profile/Profile.cpp \ From d50e242cb0546e6adc1f1a692f8abfd337e00479 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sun, 14 Jan 2024 22:11:14 +0100 Subject: [PATCH 130/403] update reorganization OpenVarioBaseMenu --- src/Device/Config.cpp | 2 +- src/OpenVario/System/System.cpp | 5 ++++- src/OpenVario/System/System.hpp | 11 +++++------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Device/Config.cpp b/src/Device/Config.cpp index 4a17a0bb6aa..8e581849b51 100644 --- a/src/Device/Config.cpp +++ b/src/Device/Config.cpp @@ -187,7 +187,7 @@ DeviceConfig::Clear() noexcept #ifndef NDEBUG dump_port = false; #endif - dump_port = true; +// dump_port = true; } const TCHAR * diff --git a/src/OpenVario/System/System.cpp b/src/OpenVario/System/System.cpp index 8a1cb3e2f1b..972b501e6d8 100644 --- a/src/OpenVario/System/System.cpp +++ b/src/OpenVario/System/System.cpp @@ -84,8 +84,11 @@ OpenVario_Device::Initialise() noexcept { assert(File::Exists(settings_config)); +#ifndef DBUS_FUNCTIONS + // This path is only for Debug purposes on Non-OpenVario systems internal_config = AllocatedPath::Build(data_path, Path(_T("ov-internal.cfg"))); +#endif SetPrimaryDataPath(data_path); //---------------------------- @@ -128,7 +131,7 @@ OpenVario_Device::LoadSettings() noexcept LoadConfigFile(system_map, GetSystemConfig()); LoadConfigFile(settings, GetSettingsConfig()); LoadConfigFile(upgrade_map, GetUpgradeConfig()); -#ifdef _WIN32 +#ifndef DBUS_FUNCTIONS LoadConfigFile(internal_map, GetInternalConfig()); #endif ReadInteger(system_map, "rotation", rotation); diff --git a/src/OpenVario/System/System.hpp b/src/OpenVario/System/System.hpp index 1fa69bcd18b..06f29babfff 100644 --- a/src/OpenVario/System/System.hpp +++ b/src/OpenVario/System/System.hpp @@ -14,6 +14,9 @@ #define DEBUG_OPENVARIO 1 +#if !defined(_WIN32) && 0 +# define DBUS_FUNCTIONS 1 +#endif enum class SSHStatus { ENABLED, @@ -48,7 +51,7 @@ class OpenVario_Device { // upgrade_config = configfile; // } std::map> upgrade_map; -#ifdef _WIN32 +#ifndef DBUS_FUNCTIONS // This map is only for Debug purposes on Non-OpenVario systems std::map> internal_map; Path GetInternalConfig() noexcept { return internal_config; } @@ -81,7 +84,7 @@ class OpenVario_Device { AllocatedPath upgrade_config; // the config file for upgrading OV AllocatedPath settings_config; // the config file for settings inside // the OpenVarioBaseMenu -#ifdef _WIN32 +#ifndef DBUS_FUNCTIONS // This path is only for Debug purposes on Non-OpenVario systems AllocatedPath internal_config; #endif @@ -94,10 +97,6 @@ class OpenVario_Device { }; extern OpenVario_Device ovdevice; -#if !defined(_WIN32) && 0 -# define DBUS_FUNCTIONS 1 -#endif - class Path; /** From cc4a54e46f0fe3da94558597aaa834f51d5506e2 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sun, 14 Jan 2024 23:15:31 +0100 Subject: [PATCH 131/403] OpenVario/System/System.cpp - add enable and disable functions for sensord and variod OpenVario/System/System.cpp - update: missing connection definition --- src/OpenVario/System/System.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/OpenVario/System/System.cpp b/src/OpenVario/System/System.cpp index 972b501e6d8..ba21fbf4a1e 100644 --- a/src/OpenVario/System/System.cpp +++ b/src/OpenVario/System/System.cpp @@ -278,7 +278,32 @@ void OpenvarioSetSSHStatus(SSHStatus state) { break; } } -#else // DBUS_FUNCTIONS + +// TODO(August2111): This has be filled!!!! +bool OpenvarioGetSensordStatus() noexcept { + auto connection = ODBus::Connection::GetSystem(); + return Systemd::IsUnitEnabled(connection, "sensord"); +} +bool OpenvarioGetVariodStatus() noexcept { + auto connection = ODBus::Connection::GetSystem(); + return Systemd::IsUnitEnabled(connection, "variod"); +} +void OpenvarioSetSensordStatus(bool value) noexcept { + auto connection = ODBus::Connection::GetSystem(); + if (value) + Systemd::EnableUnitFile(connection, "sensord"); + else + Systemd::DisableUnitFile(connection, "sensord"); +} +void OpenvarioSetVariodStatus(bool value) noexcept { + auto connection = ODBus::Connection::GetSystem(); + if (value) + Systemd::EnableUnitFile(connection, "variodd"); + else + Systemd::DisableUnitFile(connection, "variod"); +} + +#else // DBUS_FUNCTIONS bool OpenvarioGetSensordStatus() noexcept { bool value; ReadBool(ovdevice.internal_map, "SensorD", value); From 26a1098e77a9314ee3d986c042b10e0da7f48e56 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 15 Jan 2024 14:42:54 +0100 Subject: [PATCH 132/403] OpenVarioDevice.cpp - renamed from System.cpp --- .../Settings/Panels/OpenVarioConfigPanel.cpp | 2 +- src/Dialogs/Settings/dlgConfiguration.cpp | 2 +- .../{System.cpp => OpenVarioDevice.cpp} | 23 ++++--------------- .../{System.hpp => OpenVarioDevice.hpp} | 0 .../System/Setting/RotationWidget.cpp | 2 +- src/OpenVario/System/Setting/WifiWidget.cpp | 5 +--- src/OpenVario/System/SystemMenuWidget.cpp | 2 +- src/OpenVario/System/SystemSettingsWidget.cpp | 2 +- 8 files changed, 11 insertions(+), 27 deletions(-) rename src/OpenVario/System/{System.cpp => OpenVarioDevice.cpp} (96%) rename src/OpenVario/System/{System.hpp => OpenVarioDevice.hpp} (100%) diff --git a/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp b/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp index 370f8ba9fc4..04dbccae128 100644 --- a/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp @@ -19,7 +19,7 @@ #include "Dialogs/Message.hpp" -#include "OpenVario/System/System.hpp" +#include "OpenVario/System/OpenVarioDevice.hpp" #include "OpenVario/System/WifiDialogOV.hpp" diff --git a/src/Dialogs/Settings/dlgConfiguration.cpp b/src/Dialogs/Settings/dlgConfiguration.cpp index 6e6db60fbec..49a7fdcc35c 100644 --- a/src/Dialogs/Settings/dlgConfiguration.cpp +++ b/src/Dialogs/Settings/dlgConfiguration.cpp @@ -66,7 +66,7 @@ #include "Panels/WeGlideConfigPanel.hpp" #if defined(IS_OPENVARIO) -#include "OpenVario/System/System.hpp" +#include "OpenVario/System/OpenVarioDevice.hpp" #endif #include diff --git a/src/OpenVario/System/System.cpp b/src/OpenVario/System/OpenVarioDevice.cpp similarity index 96% rename from src/OpenVario/System/System.cpp rename to src/OpenVario/System/OpenVarioDevice.cpp index ba21fbf4a1e..8af73396361 100644 --- a/src/OpenVario/System/System.cpp +++ b/src/OpenVario/System/OpenVarioDevice.cpp @@ -63,7 +63,7 @@ OpenVario_Device::Initialise() noexcept { data_path = Path(_T("data")); system_config = - AllocatedPath::Build(Path(_T("/boot")), Path(_T("config.uEnf"))); + AllocatedPath::Build(Path(_T("/boot")), Path(_T("config.uEnv"))); is_real = File::Exists(system_config); #endif if (Directory::Exists(data_path)) { @@ -77,8 +77,6 @@ OpenVario_Device::Initialise() noexcept { AllocatedPath::Build(home_path, Path(_T("openvario.cfg"))); upgrade_config = AllocatedPath::Build(home_path, Path(_T("upgrade.cfg"))); } - system_config = AllocatedPath::Build(home_path, Path(_T("config.uEnv"))); - if (!File::Exists(settings_config)) File::CreateExclusive(settings_config); @@ -96,6 +94,10 @@ OpenVario_Device::Initialise() noexcept { #ifdef DEBUG_OPENVARIO LogFormat("home_path = %s", home_path.ToUTF8().c_str()); LogFormat("settings_config = %s", settings_config.ToUTF8().c_str()); + LogFormat("system_config = %s", system_config.ToUTF8().c_str()); + if (!is_real) + system_config = AllocatedPath::Build(home_path, Path(_T("config.uEnv"))); + LogFormat("system_config = %s", system_config.ToUTF8().c_str()); LogFormat("upgrade_config = %s", upgrade_config.ToUTF8().c_str()); // the same...: LogFormat(_T("upgrade_config = %s"), upgrade_config.c_str()); @@ -351,19 +353,4 @@ void OpenvarioSetSSHStatus(SSHStatus state) { } #endif // DBUS_FUNCTIONS - -// #ifndef MAX_PATH -// #define MAX_PATH 0x100 -// #endif -// void debugln(const char *fmt, ...) noexcept { -// char buf[MAX_PATH]; -// va_list ap; -// -// va_start(ap, fmt); -// vsnprintf(buf, sizeof(buf) - 1, fmt, ap); -// va_end(ap); -// -// std::cout << buf << std::endl; -// } - //---------------------------------------------------------- diff --git a/src/OpenVario/System/System.hpp b/src/OpenVario/System/OpenVarioDevice.hpp similarity index 100% rename from src/OpenVario/System/System.hpp rename to src/OpenVario/System/OpenVarioDevice.hpp diff --git a/src/OpenVario/System/Setting/RotationWidget.cpp b/src/OpenVario/System/Setting/RotationWidget.cpp index 7262241a50d..e712fb8d226 100644 --- a/src/OpenVario/System/Setting/RotationWidget.cpp +++ b/src/OpenVario/System/Setting/RotationWidget.cpp @@ -27,7 +27,7 @@ #include "io/BufferedOutputStream.hxx" #include "io/FileLineReader.hpp" -#include "OpenVario/System/System.hpp" +#include "OpenVario/System/OpenVarioDevice.hpp" #include "OpenVario/System/Setting/RotationWidget.hpp" #ifndef __MSVC__ diff --git a/src/OpenVario/System/Setting/WifiWidget.cpp b/src/OpenVario/System/Setting/WifiWidget.cpp index cbfca6241ed..ee18ad01a92 100644 --- a/src/OpenVario/System/Setting/WifiWidget.cpp +++ b/src/OpenVario/System/Setting/WifiWidget.cpp @@ -14,14 +14,11 @@ #include "Profile/Map.hpp" #include "Screen/Layout.hpp" #include "UIGlobals.hpp" -// #include "Widget/RowFormWidget.hpp" #include "system/FileUtil.hpp" #include "system/Process.hpp" #include "ui/event/KeyCode.hpp" -// #include "ui/event/Queue.hpp" #include "ui/event/Timer.hpp" #include "ui/window/Init.hpp" -// #include "ui/window/SingleWindow.hpp" #include "Language/Language.hpp" @@ -30,7 +27,7 @@ #include "io/BufferedOutputStream.hxx" #include "io/FileLineReader.hpp" -#include "OpenVario/System/System.hpp" +#include "OpenVario/System/OpenVarioDevice.hpp" #include "OpenVario/System/Setting/WifiWidget.hpp" #ifndef __MSVC__ diff --git a/src/OpenVario/System/SystemMenuWidget.cpp b/src/OpenVario/System/SystemMenuWidget.cpp index 917804a0cf4..8818cbe02b4 100644 --- a/src/OpenVario/System/SystemMenuWidget.cpp +++ b/src/OpenVario/System/SystemMenuWidget.cpp @@ -26,7 +26,7 @@ #include "util/ScopeExit.hxx" #include "OpenVario/FileMenuWidget.h" -#include "OpenVario/System/System.hpp" +#include "OpenVario/System/OpenVarioDevice.hpp" #include "OpenVario/System/SystemSettingsWidget.hpp" #include "OpenVario/System/SystemMenuWidget.hpp" #include "Dialogs/Settings/Panels/OpenVarioConfigPanel.hpp" diff --git a/src/OpenVario/System/SystemSettingsWidget.cpp b/src/OpenVario/System/SystemSettingsWidget.cpp index c3dea2ff02f..b5aa4a1ada9 100644 --- a/src/OpenVario/System/SystemSettingsWidget.cpp +++ b/src/OpenVario/System/SystemSettingsWidget.cpp @@ -27,7 +27,7 @@ #include "io/BufferedOutputStream.hxx" #include "io/FileLineReader.hpp" -#include "OpenVario/System/System.hpp" +#include "OpenVario/System/OpenVarioDevice.hpp" #include "OpenVario/System/SystemSettingsWidget.hpp" #include "OpenVario/System/Setting/RotationWidget.hpp" // #include "OpenVario/System/Setting/SSHWidget.hpp" From e923e123e919a8aabf21c500c75ba3dde8a1089b Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 15 Jan 2024 15:43:48 +0100 Subject: [PATCH 133/403] OpenVarioConfigPanel.cpp - add missing include --- src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp b/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp index 04dbccae128..4a7b77428df 100644 --- a/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp @@ -20,6 +20,7 @@ #include "Dialogs/Message.hpp" #include "OpenVario/System/OpenVarioDevice.hpp" +#include "OpenVario/System/OpenVarioConfigPanel.hpp" #include "OpenVario/System/WifiDialogOV.hpp" From a48d1cdddf49cd72aff3b3522e10851734b5c9be Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 15 Jan 2024 15:10:04 +0100 Subject: [PATCH 134/403] [CMake] OpenVario - rename OpenVarioDevice.cpp from System.cpp --- src/Dialogs/CMakeSource.cmake | 2 +- src/OpenVario/CMakeSource.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Dialogs/CMakeSource.cmake b/src/Dialogs/CMakeSource.cmake index 554885bf267..2b60c15b198 100644 --- a/src/Dialogs/CMakeSource.cmake +++ b/src/Dialogs/CMakeSource.cmake @@ -160,7 +160,7 @@ set(_SOURCES if(ON) # IS_OPENVARIO list(APPEND _SOURCES - ../OpenVario/System/System.cpp + ../OpenVario/System/OpenVarioDevice.cpp ../OpenVario/FileMenuWidget.cpp ../OpenVario/System/SystemMenuWidget.cpp diff --git a/src/OpenVario/CMakeSource.cmake b/src/OpenVario/CMakeSource.cmake index 15b50ef0cac..1546a3dac04 100644 --- a/src/OpenVario/CMakeSource.cmake +++ b/src/OpenVario/CMakeSource.cmake @@ -3,7 +3,7 @@ set(TEST_SRC_DIR "${PROJECTGROUP_SOURCE_DIR}/test/src") set(_SOURCES OpenVario/OpenVarioBaseMenu.cpp - OpenVario/System/System.cpp + OpenVario/System/OpenVarioDevice.cpp OpenVario/FileMenuWidget.cpp OpenVario/System/SystemMenuWidget.cpp From a6a06f70a257524c0d845af3368e293205eb2003 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 1 Jan 1970 01:00:00 +0100 Subject: [PATCH 135/403] OpenVarioDevice - test with DEBUG_FUNCTIONS --- src/OpenVario/System/OpenVarioDevice.cpp | 4 +--- src/OpenVario/System/OpenVarioDevice.hpp | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/OpenVario/System/OpenVarioDevice.cpp b/src/OpenVario/System/OpenVarioDevice.cpp index 8af73396361..232eae9f5cd 100644 --- a/src/OpenVario/System/OpenVarioDevice.cpp +++ b/src/OpenVario/System/OpenVarioDevice.cpp @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright The XCSoar Project -#include "OpenVario/System/System.hpp" +#include "OpenVario/System/OpenVarioDevice.hpp" #ifdef DBUS_FUNCTIONS #include "lib/dbus/Connection.hxx" #include "lib/dbus/ScopeMatch.hxx" @@ -26,8 +26,6 @@ #include "LogFile.hpp" #include "LocalPath.hpp" -#include "OpenVario/System/System.hpp" - #ifndef _WIN32 #include #include diff --git a/src/OpenVario/System/OpenVarioDevice.hpp b/src/OpenVario/System/OpenVarioDevice.hpp index 06f29babfff..1b25ec16123 100644 --- a/src/OpenVario/System/OpenVarioDevice.hpp +++ b/src/OpenVario/System/OpenVarioDevice.hpp @@ -14,7 +14,7 @@ #define DEBUG_OPENVARIO 1 -#if !defined(_WIN32) && 0 +#if __linux__ && __has_include("dbus/dbus.h>") # define DBUS_FUNCTIONS 1 #endif From e605ccfc5c246c98c6686732acd5317caa52f471 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 29 Jan 2024 12:41:20 +0100 Subject: [PATCH 136/403] OpenVarioConfigPanel - some cleaning up additional changes renaming System.hpp to OpenVarioDevice.hpp --- .../Settings/Panels/OpenVarioConfigPanel.cpp | 24 ++++++++++++++++--- .../Settings/Panels/OpenVarioConfigPanel.hpp | 8 +++++-- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp b/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp index 4a7b77428df..dabf42c107a 100644 --- a/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp @@ -4,6 +4,7 @@ #ifdef IS_OPENVARIO // don't use (and compile) this code outside an OpenVario project! +#include "Dialogs/Settings/Panels/OpenVarioConfigPanel.hpp" #include "Dialogs/WidgetDialog.hpp" #include "Widget/RowFormWidget.hpp" #include "Look/DialogLook.hpp" @@ -20,7 +21,6 @@ #include "Dialogs/Message.hpp" #include "OpenVario/System/OpenVarioDevice.hpp" -#include "OpenVario/System/OpenVarioConfigPanel.hpp" #include "OpenVario/System/WifiDialogOV.hpp" @@ -43,6 +43,7 @@ enum ControlIndex { }; +#if 0 class OpenVarioConfigPanel final : public RowFormWidget, DataFieldListener { public: @@ -55,10 +56,13 @@ class OpenVarioConfigPanel final void Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept override; bool Save(bool &changed) noexcept override; + int OnShow(const UI::SingleWindow &parent) noexcept; + private: /* methods from DataFieldListener */ void OnModified(DataField &df) noexcept override; - +}; +#endif static constexpr StaticEnumChoice timeout_list[] = { { 0, _T("immediately"), }, { 1, _T("1s"), }, @@ -77,7 +81,6 @@ class OpenVarioConfigPanel final { SSHStatus::TEMPORARY, _T("temporary"), }, nullptr }; -}; void OpenVarioConfigPanel::SetEnabled([[maybe_unused]] bool enabled) noexcept @@ -202,6 +205,21 @@ OpenVarioConfigPanel::Save([[maybe_unused]] bool &_changed) noexcept return true; } +int +OpenVarioConfigPanel::OnShow([[maybe_unused]] const UI::SingleWindow &parent) + noexcept { +#if 0 + TWidgetDialog sub_dialog( + WidgetDialog::Full{}, parent, GetLook(), + _T("OpenVario System Settings")); + sub_dialog.SetWidget(); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); +#else + return 0; +#endif +} + std::unique_ptr CreateOpenVarioConfigPanel() noexcept { diff --git a/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.hpp b/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.hpp index a52acf03849..b4bd1d67ed7 100644 --- a/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.hpp +++ b/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.hpp @@ -13,6 +13,8 @@ class Widget; +#if 1 +#include "UIGlobals.hpp" // ------------------------------------------- class OpenVarioConfigPanel final : public RowFormWidget, DataFieldListener { public: @@ -24,13 +26,15 @@ class OpenVarioConfigPanel final : public RowFormWidget, DataFieldListener { void Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept override; bool Save(bool &changed) noexcept override; + int OnShow(const UI::SingleWindow &parent) noexcept; + private: /* methods from DataFieldListener */ void OnModified(DataField &df) noexcept override; }; // --------------------------------------------- - +#endif std::unique_ptr -CreateOpenVarioConfigPanel(); +CreateOpenVarioConfigPanel() noexcept; #endif \ No newline at end of file From 19a55168ee18bd7cebc448957d43321c9166cbff Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 29 Jan 2024 12:42:36 +0100 Subject: [PATCH 137/403] OpenVarioBaseMenu - rename System.hpp in OpenVarioDevice.hpp --- src/OpenVario/OpenVarioBaseMenu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenVario/OpenVarioBaseMenu.cpp b/src/OpenVario/OpenVarioBaseMenu.cpp index 2b62c87bf52..38d9ad0794c 100644 --- a/src/OpenVario/OpenVarioBaseMenu.cpp +++ b/src/OpenVario/OpenVarioBaseMenu.cpp @@ -25,7 +25,7 @@ #include "Hardware/RotateDisplay.hpp" #include "util/StaticString.hxx" -#include "OpenVario/System/System.hpp" +#include "OpenVario/System/OpenVarioDevice.hpp" #include "OpenVario/FileMenuWidget.h" #include "OpenVario/System/SystemMenuWidget.hpp" From ae55380401118e66782ecb8995dc2e58045fe8ea Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 15 Jan 2024 15:10:50 +0100 Subject: [PATCH 138/403] [build] main.mk, ov.mk - OpenVario - rename OpenVarioDevice.cpp from System.cpp remove obsolet BrightnessWidget, TimeoutWidget and SSHWidget --- build/main.mk | 2 +- build/ov.mk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/main.mk b/build/main.mk index 80b304fbf5f..a3e0814f5a6 100644 --- a/build/main.mk +++ b/build/main.mk @@ -158,7 +158,7 @@ ifeq ($(TARGET_IS_OPENVARIO),y) # $(SRC)/OpenVario/OpenVarioBaseMenu.cpp DIALOG_SOURCES += \ $(SRC)/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp \ - $(SRC)/OpenVario/System/System.cpp \ + $(SRC)/OpenVario/System/OpenVarioDevice.cpp \ $(SRC)/OpenVario/FileMenuWidget.cpp \ $(SRC)/OpenVario/System/SystemMenuWidget.cpp \ $(SRC)/OpenVario/System/SystemSettingsWidget.cpp \ diff --git a/build/ov.mk b/build/ov.mk index 80d4c7cdd51..6cb2702df79 100644 --- a/build/ov.mk +++ b/build/ov.mk @@ -183,7 +183,7 @@ DIALOG_SOURCES += \ OV_MENU_SOURCES = \ $(DIALOG_SOURCES) \ $(SRC)/OpenVario/OpenVarioBaseMenu.cpp \ - $(SRC)/OpenVario/System/System.cpp \ + $(SRC)/OpenVario/System/OpenVarioDevice.cpp \ $(SRC)/OpenVario/FileMenuWidget.cpp \ $(SRC)/OpenVario/System/SystemMenuWidget.cpp \ $(SRC)/OpenVario/System/SystemSettingsWidget.cpp \ From b7e26551b77d8501f90103f5f6fc78f660712c35 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 17 Jan 2024 14:41:16 +0100 Subject: [PATCH 139/403] LogFile.cpp - change LogFileNames according to ProgramName --- src/LogFile.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/LogFile.cpp b/src/LogFile.cpp index 9b3b9ad5ed7..f1c928152b1 100644 --- a/src/LogFile.cpp +++ b/src/LogFile.cpp @@ -12,6 +12,7 @@ #include "system/FileUtil.hpp" #include "io/UniqueFileDescriptor.hxx" #include "util/Exception.hxx" +#include "util/StaticString.hxx" #include @@ -26,6 +27,10 @@ #include #endif +#ifdef IS_OPENVARIO +# include "OpenVario/System/OpenVarioDevice.hpp" +#endif + static FileOutputStream OpenLog() { @@ -36,18 +41,15 @@ OpenLog() initialised = true; #ifdef IS_OPENVARIO - /* delete the obsolete log file */ - File::Delete(LocalPath(_T("opensoar-startup.log"))); - path = LocalPath(_T("opensoar.log")); - File::Replace(path, LocalPath(_T("opensoar-old.log"))); + path = LocalPath(ovdevice.GetExeName().c_str()); #else - /* delete the obsolete log file */ - File::Delete(LocalPath(_T("xcsoar-startup.log"))); - path = LocalPath(_T("xcsoar.log")); - - File::Replace(path, LocalPath(_T("xcsoar-old.log"))); #endif + /* delete the obsolete log file */ + File::Delete(path + _T("-startup.log")); + auto back_path = path + _T("-old.log"); + path = path + _T(".log"); + File::Replace(path, back_path); #ifdef ANDROID /* redirect stdout/stderr to xcsoar-startup.log on Android so we From 8678da3e9dec9f2d826cdbf560c88ef8759e68be Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 15 Jan 2024 19:49:50 +0100 Subject: [PATCH 140/403] OpenVarioConfigPanel.cpp - Shell button call exit() - w/o cleaning up --- src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp b/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp index dabf42c107a..91194e39ed1 100644 --- a/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp @@ -19,6 +19,7 @@ #include "ui/window/SingleWindow.hpp" #include "Dialogs/Message.hpp" +#include "./LogFile.hpp" #include "OpenVario/System/OpenVarioDevice.hpp" #include "OpenVario/System/WifiDialogOV.hpp" @@ -134,9 +135,9 @@ OpenVarioConfigPanel::Prepare(ContainerWindow &parent, // auto Btn_Shell = AddButton( - _T("Shell"), [this]() { - ShowMessageBox(_("Button pressed"), _("OV-Button"), - MB_OK | MB_ICONERROR); + _T("Exit to Shell"), [this]() { + LogFormat("Exit to Shell"); + exit(111); // without cleaning up???? }); AddButton( From 8bc3302005f75598f657bd3ec250fee458b90896 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 15 Jan 2024 23:06:36 +0100 Subject: [PATCH 141/403] OpenVarioMenu - Reorganization part 3 move OpenVarioConfigPanel from Dialogs to OpenVario (like all other panels) start with better structure in OpenVario main menu create a DisplaySettingsWidget for all display relevant settings move Button "Display Setting" and "System Setting" from SystemMenu- Widget to the main panel OpenVarioBaseMenu OpenVario/OpenVarioBaseMenu.cpp - debug test with Exe String OpenVario/OpenVarioBaseMenu - next test with LogFormat on real system --- src/Dialogs/Settings/dlgConfiguration.cpp | 4 +- ...gsWidget.cpp => DisplaySettingsWidget.cpp} | 7 +- ...gsWidget.hpp => DisplaySettingsWidget.hpp} | 4 +- src/OpenVario/OpenVarioBaseMenu.cpp | 202 +++++++++++++----- src/OpenVario/System/SystemMenuWidget.cpp | 26 --- .../SystemSettingsWidget.cpp} | 22 +- .../SystemSettingsWidget.hpp} | 6 +- 7 files changed, 173 insertions(+), 98 deletions(-) rename src/OpenVario/{System/SystemSettingsWidget.cpp => DisplaySettingsWidget.cpp} (92%) rename src/OpenVario/{System/SystemSettingsWidget.hpp => DisplaySettingsWidget.hpp} (84%) rename src/{Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp => OpenVario/SystemSettingsWidget.cpp} (90%) rename src/{Dialogs/Settings/Panels/OpenVarioConfigPanel.hpp => OpenVario/SystemSettingsWidget.hpp} (82%) diff --git a/src/Dialogs/Settings/dlgConfiguration.cpp b/src/Dialogs/Settings/dlgConfiguration.cpp index 49a7fdcc35c..55be938804f 100644 --- a/src/Dialogs/Settings/dlgConfiguration.cpp +++ b/src/Dialogs/Settings/dlgConfiguration.cpp @@ -38,7 +38,6 @@ #include "Panels/TaskDefaultsConfigPanel.hpp" #include "Panels/ScoringConfigPanel.hpp" #include "Panels/InfoBoxesConfigPanel.hpp" -#include "Panels/OpenVarioConfigPanel.hpp" #include "Interface.hpp" #include "Language/Language.hpp" #include "Audio/Features.hpp" @@ -66,6 +65,7 @@ #include "Panels/WeGlideConfigPanel.hpp" #if defined(IS_OPENVARIO) +#include "OpenVario/SystemSettingsWidget.hpp" #include "OpenVario/System/OpenVarioDevice.hpp" #endif @@ -146,7 +146,7 @@ static constexpr TabMenuPage setup_pages[] = { #ifdef IS_OPENVARIO static constexpr TabMenuPage openvario_pages[] = { - { N_("OpenVario Device"), CreateOpenVarioConfigPanel }, + {N_("OpenVario System Settings"), CreateSystemSettingsWidget}, { nullptr, nullptr } }; #endif diff --git a/src/OpenVario/System/SystemSettingsWidget.cpp b/src/OpenVario/DisplaySettingsWidget.cpp similarity index 92% rename from src/OpenVario/System/SystemSettingsWidget.cpp rename to src/OpenVario/DisplaySettingsWidget.cpp index b5aa4a1ada9..0d76564bb62 100644 --- a/src/OpenVario/System/SystemSettingsWidget.cpp +++ b/src/OpenVario/DisplaySettingsWidget.cpp @@ -28,11 +28,8 @@ #include "io/FileLineReader.hpp" #include "OpenVario/System/OpenVarioDevice.hpp" -#include "OpenVario/System/SystemSettingsWidget.hpp" +#include "OpenVario/DisplaySettingsWidget.hpp" #include "OpenVario/System/Setting/RotationWidget.hpp" -// #include "OpenVario/System/Setting/SSHWidget.hpp" -// #include "OpenVario/System/Setting/SensordWidget.hpp" -// #include "OpenVario/System/Setting/VariodWidget.hpp" #include "OpenVario/System/Setting/WifiWidget.hpp" #ifndef _WIN32 @@ -45,7 +42,7 @@ #include void -SystemSettingsWidget::Prepare([[maybe_unused]] ContainerWindow &parent, +DisplaySettingsWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { AddButton(_("Screen Rotation"), [this](){ diff --git a/src/OpenVario/System/SystemSettingsWidget.hpp b/src/OpenVario/DisplaySettingsWidget.hpp similarity index 84% rename from src/OpenVario/System/SystemSettingsWidget.hpp rename to src/OpenVario/DisplaySettingsWidget.hpp index f89f0507cbc..2ffbf2adb6e 100644 --- a/src/OpenVario/System/SystemSettingsWidget.hpp +++ b/src/OpenVario/DisplaySettingsWidget.hpp @@ -7,7 +7,7 @@ #include "ui/event/Queue.hpp" #include "ui/window/SingleWindow.hpp" -class SystemSettingsWidget final +class DisplaySettingsWidget final : public RowFormWidget { UI::Display &display; @@ -16,7 +16,7 @@ class SystemSettingsWidget final WndForm &dialog; public: - SystemSettingsWidget(UI::Display &_display, UI::EventQueue &_event_queue, + DisplaySettingsWidget(UI::Display &_display, UI::EventQueue &_event_queue, WndForm &_dialog) noexcept :RowFormWidget(_dialog.GetLook()), display(_display), event_queue(_event_queue), diff --git a/src/OpenVario/OpenVarioBaseMenu.cpp b/src/OpenVario/OpenVarioBaseMenu.cpp index 38d9ad0794c..d85c561853e 100644 --- a/src/OpenVario/OpenVarioBaseMenu.cpp +++ b/src/OpenVario/OpenVarioBaseMenu.cpp @@ -25,11 +25,17 @@ #include "Hardware/RotateDisplay.hpp" #include "util/StaticString.hxx" -#include "OpenVario/System/OpenVarioDevice.hpp" #include "OpenVario/FileMenuWidget.h" +#include "OpenVario/DisplaySettingsWidget.hpp" +#include "OpenVario/SystemSettingsWidget.hpp" + +#include "OpenVario/System/OpenVarioDevice.hpp" #include "OpenVario/System/SystemMenuWidget.hpp" +#include "util/ConvertString.hpp" #include "LocalPath.hpp" +#include "LogFile.hpp" +#include "Dialogs/Message.hpp" #include #include @@ -37,8 +43,6 @@ #include #include -#include "util/ConvertString.hpp" - static DialogSettings dialog_settings; static UI::SingleWindow *global_main_window; static DialogLook *global_dialog_look; @@ -65,6 +69,21 @@ UIGlobals::GetMainWindow() return *global_main_window; } +// #if __linux__ +// std::filesystem::path getExecutableDir() { +// std::string executablePath = getExecutablePath(); +// char *executablePathStr = new char[executablePath.length() + 1]; +// strcpy(executablePathStr, executablePath.c_str()); +// char *executableDir = dirname(executablePathStr); +// delete[] executablePathStr; +// return std::string(executableDir); +// } +// #else +// std::filesystem::path getExecutableDir() { +// // TODO(August2111): This is only correct in case of CurrentDir == ExeDir +// return std::filesystem::current_path(); +// } +// #endif class MainMenuWidget final : public RowFormWidget @@ -75,15 +94,18 @@ class MainMenuWidget final OPENSOAR_CLUB, OPENSOAR, XCSOAR, + READONLY_1, FILE, // TEST, + DISPLAY, SYSTEM, - READONLY_1, + PLACEHOLDER, + READONLY_2, SHELL, REBOOT, SHUTDOWN, TIMER, - READONLY_2, + READONLY_3, }; UI::Display &display; @@ -113,43 +135,16 @@ class MainMenuWidget final } private: - void StartSoarExe(std::string_view exe, - std::filesystem::path _datapath = "") noexcept { - const UI::ScopeDropMaster drop_master{display}; - const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; - std::filesystem::path ExePath(std::filesystem::current_path()); - ExePath.append(exe); - - if (_datapath.empty()) { - _datapath = GetPrimaryDataPath().c_str(); - } - NarrowString<0x200> datapath("-datapath="); - datapath.append(_datapath.generic_string()); - - NarrowString<0x80> profile(""); - if (ovdevice.settings.find("MainProfile") != ovdevice.settings.end()) - profile = "-profile="; - std::string str = ovdevice.settings.find("MainProfile")->second; - profile += ovdevice.settings.find("MainProfile")->second; - - NarrowString<0x10> format(""); -#ifdef _WIN32 - if (ovdevice.settings.find("Format") != ovdevice.settings.end()) { - format = "-"; - format += ovdevice.settings.find("Format")->second; - } - else - format = "-1400x700"; -#endif - Run(ExePath.generic_string().c_str(), "-fly", datapath, profile, - format); - } + void StartSoarExe(std::string_view exe, + std::filesystem::path _datapath = "") noexcept; void StartOpenSoar() noexcept { std::filesystem::path datapath = ""; if (ovdevice.settings.find("OpenSoarData") != ovdevice.settings.end()) datapath = ovdevice.settings.find("OpenSoarData")->second; - StartSoarExe("OpenSoar.exe", datapath); + else + datapath = ovdevice.GetDataPath().ToUTF8() + "/OpenSoarData"; + StartSoarExe("OpenSoar", datapath); // after OpenSoar the settings can be changed ovdevice.LoadSettings(); @@ -159,7 +154,9 @@ class MainMenuWidget final std::filesystem::path datapath = ""; if (ovdevice.settings.find("XCSoarData") != ovdevice.settings.end()) datapath = ovdevice.settings.find("XCSoarData")->second; - StartSoarExe("XCSoar.exe", datapath); + else + datapath = ovdevice.GetDataPath().ToUTF8() + "/XCSoarData"; + StartSoarExe("XCSoar", datapath); } void ScheduleTimer() noexcept { @@ -216,12 +213,80 @@ class MainMenuWidget final return true; } } + + WndProperty *progress_timer = nullptr; }; +void MainMenuWidget::StartSoarExe(std::string_view _exe, + std::filesystem::path _datapath) noexcept { + const UI::ScopeDropMaster drop_master{display}; + const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; + +#if _WIN32 + std::filesystem::path ExePath = + ovdevice.GetBinPath().append(std::string(_exe) + ".exe"); +#else + std::filesystem::path ExePath = ovdevice.GetBinPath().append(_exe); +#endif + LogFormat("ExePath = %s", ExePath.c_str()); + if (File::Exists(Path(ExePath.c_str()))) { + + NarrowString<0x200> datapath("-datapath="); + if (_datapath.empty()) { + _datapath = GetPrimaryDataPath().c_str(); + } else { + datapath.append(_datapath.generic_string()); + } + LogFormat("datapath = %s / %", datapath.c_str(), _datapath.c_str()); + + NarrowString<0x80> profile(""); + if (ovdevice.settings.find("MainProfile") != ovdevice.settings.end()) { + profile = "-profile="; + std::string str = ovdevice.settings.find("MainProfile")->second; + profile += ovdevice.settings.find("MainProfile")->second; + } + LogFormat("profile = %s", profile.c_str()); + NarrowString<0x10> format(""); +#ifdef _WIN32 + if (ovdevice.settings.find("Format") != ovdevice.settings.end()) { + format = "-"; + format += ovdevice.settings.find("Format")->second; + } else { + format = "-1400x700"; + } + LogFormat("format = %s", format.c_str()); +#endif +#if 1 // TODO(August2111): only Debug Purpose + NarrowString<0x200> test(ExePath.string().c_str()); + test.AppendFormat(" %s", "-fly"); + test.AppendFormat(" %s", datapath.c_str()); + test.AppendFormat(" %s", profile.c_str()); + test.AppendFormat(" %s", format.c_str()); + LogFormat("TEST = %s", test.c_str()); +#if _UNICODE + ShowMessageBox(ConvertACPToWide(test.c_str()).c_str(), _T("Run"), + MB_OK | MB_ICONEXCLAMATION); +#else // _UNICODE + ShowMessageBox((TCHAR *)test.c_str(), _T("Run"), + MB_OK | MB_ICONEXCLAMATION); + // Run(test.c_str()); +#endif + // Run(ExePath.generic_string().c_str(), "-fly", datapath, profile, format); +#else +#endif + Run(ExePath.generic_string().c_str(), "-fly", datapath, profile, format, nullptr); + } else { // ExePath doesnt exist! + ShowMessageBox(_("Program file doesnt exist!"), _T("Run"), + MB_OK | MB_ICONEXCLAMATION); + + } +} + void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { - AddButton(_("Start OpenSoar (Club)"), [this]() { + [[maybe_unused]] auto Btn_Club = // unused + AddButton(_("Start OpenSoar (Club)"), [this]() { CancelTimer(); StartOpenSoar(); }); @@ -231,11 +296,15 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, StartOpenSoar(); }); - auto Btn_XCSoar = AddButton(_("Start XCSoar"), [this]() { + [[maybe_unused]] auto Btn_XCSoar = AddButton(_("Start XCSoar"), [this]() { CancelTimer(); StartXCSoar(); }); + //---------------------------------------------------------- + AddReadOnly(_T("")); // split between start cmds and setting + //---------------------------------------------------------- + AddButton(_("File Transfers"), [this]() { CancelTimer(); @@ -247,27 +316,54 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, return sub_dialog.ShowModal(); }); - AddButton(_("OpenVario settings"), [this]() { + AddButton(_("Display Settings"), [this]() { + TWidgetDialog sub_dialog( + WidgetDialog::Full{}, dialog.GetMainWindow(), GetLook(), + _T("OpenVario Display Settings")); + sub_dialog.SetWidget(display, event_queue, sub_dialog); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); + }); + + AddButton(_("System Settings"), [this]() { + std::unique_ptr widget = CreateSystemSettingsWidget(); +#if 1 + TWidgetDialog sub_dialog( + WidgetDialog::Full{}, dialog.GetMainWindow(), GetLook(), + _T("OpenVario System Settings")); + sub_dialog.SetWidget(); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); +#endif + }); + + AddButton(_("OpenVario Placeholder"), [this]() { CancelTimer(); TWidgetDialog sub_dialog( WidgetDialog::Full{}, dialog.GetMainWindow(), GetLook(), - _T("OpenVario System Settings")); + _T("OpenVario Placeholder Settings")); sub_dialog.SetWidget(display, event_queue, sub_dialog); sub_dialog.AddButton(_("Close"), mrOK); return sub_dialog.ShowModal(); }); - AddReadOnly(_T("")); + //---------------------------------------------------------- + AddReadOnly(_T("")); // split setting and switch off cmds + //---------------------------------------------------------- - auto Btn_Shell = AddButton(_T("Shell"), [this]() { dialog.SetModalResult(LAUNCH_SHELL); }); + auto Btn_Shell = AddButton(_T("Exit to Shell"), + [this]() { dialog.SetModalResult(LAUNCH_SHELL); }); auto Btn_Reboot = AddButton(_T("Reboot"), []() { Run("/sbin/reboot"); }); auto Btn_Shutdown = AddButton(_T("Power off"), []() { Run("/sbin/poweroff"); }); - AddReadOnly(_T("")); // Timer-Progress + //---------------------------------------------------------- + progress_timer = RowFormWidget::Add(_T(""), _T(""), true); + // AddReadOnly(_T("")); // Timer-Progress + //---------------------------------------------------------- if (!ovdevice.IsReal()) { Btn_Shell->SetCaption(_T("Exit")); @@ -275,8 +371,9 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, Btn_Shutdown->SetEnabled(false); } // Btn_XCSoar->SetEnabled(File::Exists); - - HideRow(Controls::OPENSOAR_CLUB); + + progress_timer->Hide(); + // HideRow(Controls::OPENSOAR_CLUB); } static int @@ -336,9 +433,16 @@ Main() return action; } -int main() +int +main(int argc, char *argv[]) { - /*the x-menu is waiting a second to solve timing problem with display rotation */ +// StaticString<0x200> exepath; +// exepath.SetASCII(argv[0]); +// ovdevice.SetBinPath(exepath.c_str()); + if (argc > 0) + ovdevice.SetBinPath(argv[0]); + /*the x-menu is waiting a second to solve timing problem with display rotation + */ std::this_thread::sleep_for(std::chrono::seconds(1)); int action = Main(); diff --git a/src/OpenVario/System/SystemMenuWidget.cpp b/src/OpenVario/System/SystemMenuWidget.cpp index 8818cbe02b4..08ff06b54c6 100644 --- a/src/OpenVario/System/SystemMenuWidget.cpp +++ b/src/OpenVario/System/SystemMenuWidget.cpp @@ -12,24 +12,19 @@ #include "Profile/Map.hpp" #include "Screen/Layout.hpp" #include "UIGlobals.hpp" -// #include "Widget/RowFormWidget.hpp" #include "system/FileUtil.hpp" #if !defined(_WIN32) # include "system/Process.hpp" #endif #include "ui/event/KeyCode.hpp" -// #include "ui/event/Queue.hpp" #include "ui/event/Timer.hpp" #include "ui/window/Init.hpp" -// #include "ui/window/SingleWindow.hpp" #include "util/ScopeExit.hxx" -#include "OpenVario/FileMenuWidget.h" #include "OpenVario/System/OpenVarioDevice.hpp" #include "OpenVario/System/SystemSettingsWidget.hpp" #include "OpenVario/System/SystemMenuWidget.hpp" -#include "Dialogs/Settings/Panels/OpenVarioConfigPanel.hpp" #include #include @@ -143,27 +138,6 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, #endif }); - AddButton(_("System Settings"), [this](){ - - TWidgetDialog - sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), _T("OpenVario System Settings")); - sub_dialog.SetWidget(display, event_queue, sub_dialog); - sub_dialog.AddButton(_("Close"), mrOK); - return sub_dialog.ShowModal(); - }); - - AddButton(_("Device Settings"), [this]() { - std::unique_ptr widget = CreateOpenVarioConfigPanel(); - - TWidgetDialog sub_dialog( - WidgetDialog::Full{}, dialog.GetMainWindow(), GetLook(), - _T("OpenVario System Settings")); - sub_dialog.SetWidget(); - sub_dialog.AddButton(_("Close"), mrOK); - return sub_dialog.ShowModal(); - }); - AddButton(_("System Info"), []() { static constexpr const char *argv[] = { "/usr/bin/system-info.sh", nullptr diff --git a/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp b/src/OpenVario/SystemSettingsWidget.cpp similarity index 90% rename from src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp rename to src/OpenVario/SystemSettingsWidget.cpp index 91194e39ed1..a9c901f800a 100644 --- a/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp +++ b/src/OpenVario/SystemSettingsWidget.cpp @@ -4,7 +4,7 @@ #ifdef IS_OPENVARIO // don't use (and compile) this code outside an OpenVario project! -#include "Dialogs/Settings/Panels/OpenVarioConfigPanel.hpp" +#include "OpenVario/SystemSettingsWidget.hpp" #include "Dialogs/WidgetDialog.hpp" #include "Widget/RowFormWidget.hpp" #include "Look/DialogLook.hpp" @@ -45,10 +45,10 @@ enum ControlIndex { #if 0 -class OpenVarioConfigPanel final +class SystemSettingsWidget final : public RowFormWidget, DataFieldListener { public: - OpenVarioConfigPanel() noexcept + SystemSettingsWidget() noexcept :RowFormWidget(UIGlobals::GetDialogLook()) {} void SetEnabled(bool enabled) noexcept; @@ -84,7 +84,7 @@ class OpenVarioConfigPanel final }; void -OpenVarioConfigPanel::SetEnabled([[maybe_unused]] bool enabled) noexcept +SystemSettingsWidget::SetEnabled([[maybe_unused]] bool enabled) noexcept { // this disabled itself: SetRowEnabled(ENABLED, enabled); SetRowEnabled(BRIGHTNESS, enabled); @@ -92,7 +92,7 @@ OpenVarioConfigPanel::SetEnabled([[maybe_unused]] bool enabled) noexcept } void -OpenVarioConfigPanel::OnModified([[maybe_unused]] DataField &df) noexcept +SystemSettingsWidget::OnModified([[maybe_unused]] DataField &df) noexcept { if (IsDataField(ENABLED, df)) { const DataFieldBoolean &dfb = (const DataFieldBoolean &)df; @@ -101,7 +101,7 @@ OpenVarioConfigPanel::OnModified([[maybe_unused]] DataField &df) noexcept } void -OpenVarioConfigPanel::Prepare(ContainerWindow &parent, +SystemSettingsWidget::Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept { RowFormWidget::Prepare(parent, rc); @@ -156,7 +156,7 @@ OpenVarioConfigPanel::Prepare(ContainerWindow &parent, } bool -OpenVarioConfigPanel::Save([[maybe_unused]] bool &_changed) noexcept +SystemSettingsWidget::Save([[maybe_unused]] bool &_changed) noexcept { bool changed = false; changed |= SaveValue(ENABLED, "Enabled", ovdevice.enabled, false); @@ -207,10 +207,10 @@ OpenVarioConfigPanel::Save([[maybe_unused]] bool &_changed) noexcept } int -OpenVarioConfigPanel::OnShow([[maybe_unused]] const UI::SingleWindow &parent) +SystemSettingsWidget::OnShow([[maybe_unused]] const UI::SingleWindow &parent) noexcept { #if 0 - TWidgetDialog sub_dialog( + TWidgetDialog sub_dialog( WidgetDialog::Full{}, parent, GetLook(), _T("OpenVario System Settings")); sub_dialog.SetWidget(); @@ -222,9 +222,9 @@ OpenVarioConfigPanel::OnShow([[maybe_unused]] const UI::SingleWindow &parent) } std::unique_ptr -CreateOpenVarioConfigPanel() noexcept +CreateSystemSettingsWidget() noexcept { - return std::make_unique(); + return std::make_unique(); } #endif diff --git a/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.hpp b/src/OpenVario/SystemSettingsWidget.hpp similarity index 82% rename from src/Dialogs/Settings/Panels/OpenVarioConfigPanel.hpp rename to src/OpenVario/SystemSettingsWidget.hpp index b4bd1d67ed7..00a407abf10 100644 --- a/src/Dialogs/Settings/Panels/OpenVarioConfigPanel.hpp +++ b/src/OpenVario/SystemSettingsWidget.hpp @@ -16,9 +16,9 @@ class Widget; #if 1 #include "UIGlobals.hpp" // ------------------------------------------- -class OpenVarioConfigPanel final : public RowFormWidget, DataFieldListener { +class SystemSettingsWidget final : public RowFormWidget, DataFieldListener { public: - OpenVarioConfigPanel() noexcept : RowFormWidget(UIGlobals::GetDialogLook()) {} + SystemSettingsWidget() noexcept : RowFormWidget(UIGlobals::GetDialogLook()) {} void SetEnabled(bool enabled) noexcept; @@ -35,6 +35,6 @@ class OpenVarioConfigPanel final : public RowFormWidget, DataFieldListener { // --------------------------------------------- #endif std::unique_ptr -CreateOpenVarioConfigPanel() noexcept; +CreateSystemSettingsWidget() noexcept; #endif \ No newline at end of file From 983a49ba6ece8a06f57d287dd8ba3222e0250cef Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 15 Apr 2024 10:55:11 +0200 Subject: [PATCH 142/403] [CMake] OpenVarioMenu - Reorganization part 3 --- src/Dialogs/CMakeSource.cmake | 13 ++++--------- src/OpenVario/CMakeSource.cmake | 6 +++--- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/Dialogs/CMakeSource.cmake b/src/Dialogs/CMakeSource.cmake index 2b60c15b198..d3d4c6450f9 100644 --- a/src/Dialogs/CMakeSource.cmake +++ b/src/Dialogs/CMakeSource.cmake @@ -160,22 +160,17 @@ set(_SOURCES if(ON) # IS_OPENVARIO list(APPEND _SOURCES - ../OpenVario/System/OpenVarioDevice.cpp ../OpenVario/FileMenuWidget.cpp + ../OpenVario/DisplaySettingsWidget.cpp + ../OpenVario/SystemSettingsWidget.cpp + ../OpenVario/System/OpenVarioDevice.cpp ../OpenVario/System/SystemMenuWidget.cpp - ../OpenVario/System/SystemSettingsWidget.cpp - ../OpenVario/System/Setting/RotationWidget.cpp - # OpenVario/System/Setting/BrightnessWidget.cpp - # OpenVario/System/Setting/TimeoutWidget.cpp - # OpenVario/System/Setting/SSHWidget.cpp - # OpenVario/System/Setting/VariodWidget.cpp - # OpenVario/System/Setting/SensordWidget.cpp + ../OpenVario/System/Setting/RotationWidget.cpp ../OpenVario/System/WifiDialogOV.cpp ../OpenVario/System/WifiSupplicantOV.cpp - Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp ) endif() diff --git a/src/OpenVario/CMakeSource.cmake b/src/OpenVario/CMakeSource.cmake index 1546a3dac04..0b09ae1af30 100644 --- a/src/OpenVario/CMakeSource.cmake +++ b/src/OpenVario/CMakeSource.cmake @@ -2,19 +2,19 @@ set(TEST_SRC_DIR "${PROJECTGROUP_SOURCE_DIR}/test/src") set(_SOURCES OpenVario/OpenVarioBaseMenu.cpp + OpenVario/FileMenuWidget.cpp + OpenVario/DisplaySettingsWidget.cpp + OpenVario/SystemSettingsWidget.cpp OpenVario/System/OpenVarioDevice.cpp - OpenVario/FileMenuWidget.cpp OpenVario/System/SystemMenuWidget.cpp - OpenVario/System/SystemSettingsWidget.cpp OpenVario/System/Setting/RotationWidget.cpp OpenVario/System/Setting/WifiWidget.cpp OpenVario/System/WifiDialogOV.cpp OpenVario/System/WifiSupplicantOV.cpp - ${SRC}/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp ${SRC}/Version.cpp ${SRC}/Asset.cpp From b26d66d7fe478328a32be584d7673c90f90e0ac5 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 15 Apr 2024 10:55:33 +0200 Subject: [PATCH 143/403] [build] OpenVarioMenu - Reorganization part 3 --- build/main.mk | 4 ++-- build/ov.mk | 9 ++------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/build/main.mk b/build/main.mk index a3e0814f5a6..2fdb89009fb 100644 --- a/build/main.mk +++ b/build/main.mk @@ -157,11 +157,11 @@ DIALOG_SOURCES = \ ifeq ($(TARGET_IS_OPENVARIO),y) # $(SRC)/OpenVario/OpenVarioBaseMenu.cpp DIALOG_SOURCES += \ - $(SRC)/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp \ + $(SRC)/OpenVario/SystemSettingsWidget.cpp \ $(SRC)/OpenVario/System/OpenVarioDevice.cpp \ $(SRC)/OpenVario/FileMenuWidget.cpp \ $(SRC)/OpenVario/System/SystemMenuWidget.cpp \ - $(SRC)/OpenVario/System/SystemSettingsWidget.cpp \ + $(SRC)/OpenVario/DisplaySettingsWidget.cpp \ $(SRC)/OpenVario/System/Setting/RotationWidget.cpp \ $(SRC)/OpenVario/System/Setting/WifiWidget.cpp \ \ diff --git a/build/ov.mk b/build/ov.mk index 6cb2702df79..0943aa67144 100644 --- a/build/ov.mk +++ b/build/ov.mk @@ -175,25 +175,20 @@ DIALOG_SOURCES += \ ## $(SRC)/Weather/NOAAUpdater.cpp ## endif -## ifeq ($(TARGET_IS_OPENVARIO),y) -## DIALOG_SOURCES += \ -## $(SRC)/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp -## endif - OV_MENU_SOURCES = \ $(DIALOG_SOURCES) \ $(SRC)/OpenVario/OpenVarioBaseMenu.cpp \ $(SRC)/OpenVario/System/OpenVarioDevice.cpp \ $(SRC)/OpenVario/FileMenuWidget.cpp \ $(SRC)/OpenVario/System/SystemMenuWidget.cpp \ - $(SRC)/OpenVario/System/SystemSettingsWidget.cpp \ + $(SRC)/OpenVario/DisplaySettingsWidget.cpp \ $(SRC)/OpenVario/System/Setting/RotationWidget.cpp \ $(SRC)/OpenVario/System/Setting/WifiWidget.cpp \ \ $(SRC)/OpenVario/System/WifiDialogOV.cpp \ $(SRC)/OpenVario/System/WifiSupplicantOV.cpp \ \ - $(SRC)/Dialogs/Settings/Panels/OpenVarioConfigPanel.cpp \ + $(SRC)/OpenVario/SystemSettingsWidget.cpp \ \ $(SRC)/Version.cpp \ $(SRC)/Asset.cpp \ From 64be87c1f4da298ea5a804ec1e0ded49b9e510c9 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 29 Jan 2024 13:02:51 +0100 Subject: [PATCH 144/403] OpenVarioDevice - remove all global OpenvarioGet... and OpenvarioSet... functions, use internal Ddevice funktions for that create GetSystemStatus() to avoid double code... OpenVarioDevice.hpp - add GetExeName(), GetHomePath() --- src/OpenVario/System/OpenVarioDevice.cpp | 160 ++++++++++++++++------- src/OpenVario/System/OpenVarioDevice.hpp | 55 +++++--- 2 files changed, 149 insertions(+), 66 deletions(-) diff --git a/src/OpenVario/System/OpenVarioDevice.cpp b/src/OpenVario/System/OpenVarioDevice.cpp index 232eae9f5cd..9fba65eb5c3 100644 --- a/src/OpenVario/System/OpenVarioDevice.cpp +++ b/src/OpenVario/System/OpenVarioDevice.cpp @@ -42,13 +42,20 @@ #include #include #endif -#include #include OpenVario_Device ovdevice; -void + +void ReadBool(std::map> &map, + std::string_view name, bool &value) noexcept; +void ReadInteger(std::map> &map, + std::string_view name, unsigned &value) noexcept; +void ReadString(std::map> &map, + std::string_view name, std::string_view &value) noexcept; + + void OpenVario_Device::Initialise() noexcept { if (!initialised) { InitialiseDataPath(); @@ -83,7 +90,7 @@ OpenVario_Device::Initialise() noexcept { #ifndef DBUS_FUNCTIONS // This path is only for Debug purposes on Non-OpenVario systems internal_config = - AllocatedPath::Build(data_path, Path(_T("ov-internal.cfg"))); + AllocatedPath::Build(home_path, Path(_T("ov-internal.cfg"))); #endif SetPrimaryDataPath(data_path); @@ -100,14 +107,20 @@ OpenVario_Device::Initialise() noexcept { LogFormat("upgrade_config = %s", upgrade_config.ToUTF8().c_str()); // the same...: LogFormat(_T("upgrade_config = %s"), upgrade_config.c_str()); LogFormat("is_real = %s", is_real ? "True" : "False"); + + LogFormat("exe_path = %s", exe_path.c_str()); + LogFormat("bin_path = %s", bin_path.c_str()); #endif //---------------------------- + // StaticString<0x200> str; + // str.Format(_T("%s/%s"), home_path, _T("process.txt")); + run_output_file = AllocatedPath::Build(home_path, Path(_T("tmp.txt"))); initialised = true; } } void OpenVario_Device::Deinitialise() noexcept {} //---------------------------------------------------------- - void ReadBool(std::map> &map, +void ReadBool(std::map> &map, std::string_view name, bool &value) noexcept { if (map.find(name) != map.end()) value = map.find(name)->second != "False"; @@ -174,8 +187,8 @@ WriteConfigFile(std::map> &map, Path path) } //---------------------------------------------------------- -uint_least8_t -OpenvarioGetBrightness() noexcept +uint_least8_t +OpenVario_Device::GetBrightness() noexcept { char line[4]; int result = 10; @@ -187,8 +200,8 @@ OpenvarioGetBrightness() noexcept return result; } -void -OpenvarioSetBrightness(uint_least8_t value) noexcept +void +OpenVario_Device::SetBrightness(uint_least8_t value) noexcept { if (value < 1) { value = 1; } if (value > 10) { value = 10; } @@ -197,7 +210,7 @@ OpenvarioSetBrightness(uint_least8_t value) noexcept } DisplayOrientation -OpenvarioGetRotation() +OpenVario_Device::GetRotation() { std::map> map; LoadConfigFile(map, Path(_T("/boot/config.uEnv"))); @@ -215,7 +228,7 @@ OpenvarioGetRotation() } void -OpenvarioSetRotation(DisplayOrientation orientation) +OpenVario_Device::SetRotation(DisplayOrientation orientation) { std::map> map; @@ -246,8 +259,9 @@ OpenvarioSetRotation(DisplayOrientation orientation) #ifdef DBUS_FUNCTIONS SSHStatus -OpenvarioGetSSHStatus() +OpenVario_Device::GetSSHStatus() noexcept { +#if 0 auto connection = ODBus::Connection::GetSystem(); if (Systemd::IsUnitEnabled(connection, "dropbear.socket")) { @@ -257,9 +271,17 @@ OpenvarioGetSSHStatus() } else { return SSHStatus::DISABLED; } +#else + if (GetSystemStatus("dropbear.socket") == 0) + return SSHStatus::ENABLED; + else + return SSHStatus::DISABLED; +#endif } -void OpenvarioSetSSHStatus(SSHStatus state) { +void +OpenVario_Device::SetSSHStatus(SSHStatus state) noexcept +{ auto connection = ODBus::Connection::GetSystem(); const ODBus::ScopeMatch job_removed_match{connection, Systemd::job_removed_match}; @@ -279,52 +301,97 @@ void OpenvarioSetSSHStatus(SSHStatus state) { } } -// TODO(August2111): This has be filled!!!! -bool OpenvarioGetSensordStatus() noexcept { - auto connection = ODBus::Connection::GetSystem(); - return Systemd::IsUnitEnabled(connection, "sensord"); -} -bool OpenvarioGetVariodStatus() noexcept { - auto connection = ODBus::Connection::GetSystem(); - return Systemd::IsUnitEnabled(connection, "variod"); -} -void OpenvarioSetSensordStatus(bool value) noexcept { +bool +OpenVario_Device::GetSystemStatus(std::string_view system) noexcept +{ +#ifdef WITH_NEW_DBUS auto connection = ODBus::Connection::GetSystem(); - if (value) - Systemd::EnableUnitFile(connection, "sensord"); - else - Systemd::DisableUnitFile(connection, "sensord"); + return Systemd::IsUnitEnabled(connection, system.data()); +#else + // StaticString + + std::cout << " 0: " << system << std::endl; + StaticString<0x20> file; +///// std::string home = std::string("/home/root/"); +///// home += system; +///// +///// // AllocatedPath run_tmp_file = AllocatedPath::Build(home, system); +///// AllocatedPath run_tmp_file(home); //, system); +///// // AllocatedPath::Build(home_path, system); +///// +///// +///// std::string filename = system; +///// filename += ".txt"; +///// AllocatedPath run_tmp_file = +///// AllocatedPath::Build(home_path, Path(_T(filename.c_str()))); + + std::string_view _dirname("/home/august2111"); + //Path run_tmp_file("/home/august2111/test.txt"); + Path run_tmp_file(_dirname.data()); + + if (system == "sensord") + file = _T("SensorD.txt"); + else if (system == "variod") + file = _T("VarioD.txt"); + else if (system == "dropbear.socket") + file = _T("SSH.txt"); + AllocatedPath _tmp_file = AllocatedPath::Build(home_path, Path(file)); + + Path tmp_file = _tmp_file; + + std::cout << " 1: " << tmp_file.ToUTF8() + << ", " << system << std::endl; + auto run_value = Run(tmp_file, "/bin/systemctl", "is-enabled", system.data()); + std::cout << " 2: " << tmp_file.ToUTF8() << ", " << std::endl; + char buffer[0x20]; + File::ReadString(tmp_file, buffer, sizeof(buffer)); + std::cout << " 3: " << buffer << ", " << std::endl; + switch (run_value) { + case 0: + return std::string_view("enabled") == buffer; + break; + case 1: + if (std::string_view("disabled") == buffer) + std::strncat(buffer, " -> ok", sizeof(buffer)); + File::WriteExisting(tmp_file, buffer); + return false; + default: + std::strncat(buffer, " Wrong!", sizeof(buffer)); + File::WriteExisting(tmp_file, buffer); + return false; + } +#endif } -void OpenvarioSetVariodStatus(bool value) noexcept { +void +OpenVario_Device::SetSystemStatus(std::string_view system, bool value) noexcept +{ +#ifdef WITH_NEW_DBUS auto connection = ODBus::Connection::GetSystem(); if (value) - Systemd::EnableUnitFile(connection, "variodd"); + Systemd::EnableUnitFile(connection, system.data()); else - Systemd::DisableUnitFile(connection, "variod"); + Systemd::DisableUnitFile(connection, system.data()); +#else + Run("/bin/systemctl", value ? "enable" : "disable", system.data()); +#endif } #else // DBUS_FUNCTIONS -bool OpenvarioGetSensordStatus() noexcept { +bool +OpenVario_Device::GetSystemStatus(std::string_view system) noexcept { bool value; - ReadBool(ovdevice.internal_map, "SensorD", value); + ReadBool(internal_map, system.data(), value); return value; } -bool OpenvarioGetVariodStatus() noexcept { - bool value; - ReadBool(ovdevice.internal_map, "VarioD", value); - return value; -} -void OpenvarioSetSensordStatus(bool value) noexcept { - ovdevice.internal_map.insert_or_assign("SensorD", value ? "True" : "False"); - WriteConfigFile(ovdevice.internal_map, ovdevice.GetInternalConfig()); -} -void OpenvarioSetVariodStatus(bool value) noexcept { - ovdevice.internal_map.insert_or_assign("VarioD", value ? "True" : "False"); - WriteConfigFile(ovdevice.internal_map, ovdevice.GetInternalConfig()); +void +OpenVario_Device::SetSystemStatus(std::string_view system, bool value) noexcept { + internal_map.insert_or_assign(system.data(), + value ? "True" : "False"); + WriteConfigFile(internal_map, GetInternalConfig()); } SSHStatus -OpenvarioGetSSHStatus() +OpenVario_Device::GetSSHStatus() noexcept { unsigned ssh; ReadInteger(ovdevice.internal_map, "SSH", ssh); @@ -338,7 +405,9 @@ OpenvarioGetSSHStatus() } } -void OpenvarioSetSSHStatus(SSHStatus state) { +void +OpenVario_Device::SetSSHStatus(SSHStatus state) noexcept +{ switch (state) { case SSHStatus::DISABLED: case SSHStatus::ENABLED: @@ -350,5 +419,4 @@ void OpenvarioSetSSHStatus(SSHStatus state) { } } #endif // DBUS_FUNCTIONS - //---------------------------------------------------------- diff --git a/src/OpenVario/System/OpenVarioDevice.hpp b/src/OpenVario/System/OpenVarioDevice.hpp index 1b25ec16123..642a4b650ec 100644 --- a/src/OpenVario/System/OpenVarioDevice.hpp +++ b/src/OpenVario/System/OpenVarioDevice.hpp @@ -6,11 +6,13 @@ #include "DisplayOrientation.hpp" #include "Language/Language.hpp" #include "system/Path.hpp" +// #include "LogFile.hpp" #include #include #include +#include #define DEBUG_OPENVARIO 1 @@ -61,6 +63,19 @@ class OpenVario_Device { { return is_real; } + Path GetDataPath() noexcept { return data_path; } + Path GetHomePath() noexcept { return home_path; } + std::filesystem::path GetBinPath() noexcept { return bin_path; } + std::filesystem::path GetExePath() noexcept { return exe_path; } + std::filesystem::path GetExeName() noexcept { + return exe_path.filename().replace_extension(); + } + void SetBinPath(const char *path) noexcept { + exe_path = path; + // std::filesystem::path::path + bin_path = exe_path.parent_path(); + } + Path GetRunTempFile() noexcept { return run_output_file; } struct { bool enabled = true; @@ -78,12 +93,24 @@ class OpenVario_Device { }; -private: + uint_least8_t GetBrightness() noexcept; + void SetBrightness(uint_least8_t value) noexcept; + DisplayOrientation GetRotation(); + void SetRotation(DisplayOrientation orientation); + + bool GetSystemStatus(std::string_view system) noexcept; + void SetSystemStatus(std::string_view system, bool value) noexcept; + SSHStatus GetSSHStatus() noexcept; + void SetSSHStatus(SSHStatus state) noexcept; + + private: AllocatedPath system_config; // system config file, in the OV the // /boot/config.uEnf AllocatedPath upgrade_config; // the config file for upgrading OV AllocatedPath settings_config; // the config file for settings inside // the OpenVarioBaseMenu + AllocatedPath run_output_file; // the temp file in Run() processes +// AllocatedPath run_output_file; // the temp file in Run() processes #ifndef DBUS_FUNCTIONS // This path is only for Debug purposes on Non-OpenVario systems AllocatedPath internal_config; @@ -94,6 +121,13 @@ class OpenVario_Device { bool is_real = false; bool initialised = false; +#if 1 // test with filesystem + std::filesystem::path exe_path; + std::filesystem::path bin_path; +#else + AllocatedPath exe_path; + AllocatedPath bin_path; +#endif }; extern OpenVario_Device ovdevice; @@ -109,22 +143,3 @@ LoadConfigFile(std::map> &map, Path path); */ void WriteConfigFile(std::map> &map, Path path); - -uint_least8_t -OpenvarioGetBrightness() noexcept; - -void -OpenvarioSetBrightness(uint_least8_t value) noexcept; - -DisplayOrientation -OpenvarioGetRotation(); - -void -OpenvarioSetRotation(DisplayOrientation orientation); - -SSHStatus OpenvarioGetSSHStatus(); -void OpenvarioSetSSHStatus(SSHStatus state); -bool OpenvarioGetSensordStatus() noexcept; -bool OpenvarioGetVariodStatus() noexcept; -void OpenvarioSetSensordStatus(bool value) noexcept; -void OpenvarioSetVariodStatus(bool value) noexcept; From 8b3d41b97bfa40db8559e17e4de2d3573de63db1 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 29 Jan 2024 13:30:07 +0100 Subject: [PATCH 145/403] [OV] Test DBUS_FUNCTIONS for Wifi --- src/OpenVario/System/OpenVarioDevice.cpp | 6 +++--- src/OpenVario/System/OpenVarioDevice.hpp | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/OpenVario/System/OpenVarioDevice.cpp b/src/OpenVario/System/OpenVarioDevice.cpp index 9fba65eb5c3..f2eccc009ce 100644 --- a/src/OpenVario/System/OpenVarioDevice.cpp +++ b/src/OpenVario/System/OpenVarioDevice.cpp @@ -3,9 +3,9 @@ #include "OpenVario/System/OpenVarioDevice.hpp" #ifdef DBUS_FUNCTIONS -#include "lib/dbus/Connection.hxx" -#include "lib/dbus/ScopeMatch.hxx" -#include "lib/dbus/Systemd.hxx" +# include "lib/dbus/Connection.hxx" +# include "lib/dbus/ScopeMatch.hxx" +# include "lib/dbus/Systemd.hxx" #endif #include "system/Process.hpp" diff --git a/src/OpenVario/System/OpenVarioDevice.hpp b/src/OpenVario/System/OpenVarioDevice.hpp index 642a4b650ec..a5a56312558 100644 --- a/src/OpenVario/System/OpenVarioDevice.hpp +++ b/src/OpenVario/System/OpenVarioDevice.hpp @@ -16,8 +16,13 @@ #define DEBUG_OPENVARIO 1 -#if __linux__ && __has_include("dbus/dbus.h>") +#if __GNUC__ && __has_include("dbus/dbus.h") # define DBUS_FUNCTIONS 1 +# warning (Attention: DBUS is enabled) +#elif __GNUC__ +# warning (Attention: No DBUS!) +#else +#pragma message("Attention: No DBUS!") #endif enum class SSHStatus { From 94373bc491708072b10381ddcf6e0b5fc1271586 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 16 Jan 2024 22:41:37 +0100 Subject: [PATCH 146/403] remove all enum Controls, access to buttons directly preparing for publishing --- src/OpenVario/OpenVarioBaseMenu.cpp | 135 +++++++++------------------- 1 file changed, 43 insertions(+), 92 deletions(-) diff --git a/src/OpenVario/OpenVarioBaseMenu.cpp b/src/OpenVario/OpenVarioBaseMenu.cpp index d85c561853e..ed44f8526ca 100644 --- a/src/OpenVario/OpenVarioBaseMenu.cpp +++ b/src/OpenVario/OpenVarioBaseMenu.cpp @@ -69,45 +69,11 @@ UIGlobals::GetMainWindow() return *global_main_window; } -// #if __linux__ -// std::filesystem::path getExecutableDir() { -// std::string executablePath = getExecutablePath(); -// char *executablePathStr = new char[executablePath.length() + 1]; -// strcpy(executablePathStr, executablePath.c_str()); -// char *executableDir = dirname(executablePathStr); -// delete[] executablePathStr; -// return std::string(executableDir); -// } -// #else -// std::filesystem::path getExecutableDir() { -// // TODO(August2111): This is only correct in case of CurrentDir == ExeDir -// return std::filesystem::current_path(); -// } -// #endif - class MainMenuWidget final : public RowFormWidget { unsigned remaining_seconds = 3; - enum Controls { - OPENSOAR_CLUB, - OPENSOAR, - XCSOAR, - READONLY_1, - FILE, - // TEST, - DISPLAY, - SYSTEM, - PLACEHOLDER, - READONLY_2, - SHELL, - REBOOT, - SHUTDOWN, - TIMER, - READONLY_3, - }; - UI::Display &display; UI::EventQueue &event_queue; @@ -117,7 +83,7 @@ class MainMenuWidget final if (remaining_seconds == (unsigned)-1) CancelTimer(); else if (--remaining_seconds == 0) { - HideRow(Controls::TIMER); + progress_timer->Hide(); StartOpenSoar(); // StartXCSoar(); } else { ScheduleTimer(); @@ -156,7 +122,7 @@ class MainMenuWidget final datapath = ovdevice.settings.find("XCSoarData")->second; else datapath = ovdevice.GetDataPath().ToUTF8() + "/XCSoarData"; - StartSoarExe("XCSoar", datapath); + StartSoarExe("xcsoar", datapath); } void ScheduleTimer() noexcept { @@ -167,13 +133,13 @@ class MainMenuWidget final StaticString<256> buffer; buffer.Format(_T("Starting XCSoar in %u seconds (press any key to cancel)"), remaining_seconds); - SetText(Controls::TIMER, buffer); + progress_timer->SetText(buffer); } void CancelTimer() noexcept { timer.Cancel(); remaining_seconds = 0; - HideRow(Controls::TIMER); + progress_timer->Hide(); } /* virtual methods from class Widget */ @@ -185,10 +151,10 @@ class MainMenuWidget final switch (remaining_seconds) { case (unsigned)-1: - HideRow(Controls::TIMER); + progress_timer->Hide(); break; // Do Nothing ! case 0: - HideRow(Controls::TIMER); + progress_timer->Hide(); StartOpenSoar(); // StartXCSoar(); break; default: @@ -222,63 +188,61 @@ void MainMenuWidget::StartSoarExe(std::string_view _exe, const UI::ScopeDropMaster drop_master{display}; const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; -#if _WIN32 - std::filesystem::path ExePath = - ovdevice.GetBinPath().append(std::string(_exe) + ".exe"); -#else std::filesystem::path ExePath = ovdevice.GetBinPath().append(_exe); +#ifdef _WIN32 + ExePath += ".exe"; #endif - LogFormat("ExePath = %s", ExePath.c_str()); + // std::string for memory storage reasons + std::string exe = ExePath.string().c_str(); + LogFormat("ExePath = %s", exe.c_str()); + printf("ExePath = %s\n", exe.c_str()); if (File::Exists(Path(ExePath.c_str()))) { + std::vector ArgList; + ArgList.reserve(10); + ArgList = {exe.c_str(), "-fly"}; + //=============== Datapath ======================= NarrowString<0x200> datapath("-datapath="); if (_datapath.empty()) { _datapath = GetPrimaryDataPath().c_str(); } else { datapath.append(_datapath.generic_string()); } - LogFormat("datapath = %s / %", datapath.c_str(), _datapath.c_str()); + if (!datapath.empty()) + ArgList.push_back(datapath.c_str()); - NarrowString<0x80> profile(""); + //=============== Profile ======================= if (ovdevice.settings.find("MainProfile") != ovdevice.settings.end()) { - profile = "-profile="; - std::string str = ovdevice.settings.find("MainProfile")->second; - profile += ovdevice.settings.find("MainProfile")->second; + NarrowString<0x80> profile(""); + profile = "-profile="; + std::string str = ovdevice.settings.find("MainProfile")->second; + profile += ovdevice.settings.find("MainProfile")->second; + ArgList.push_back(profile.c_str()); } - LogFormat("profile = %s", profile.c_str()); - NarrowString<0x10> format(""); -#ifdef _WIN32 + + //=============== Profile ======================= +#ifdef _WIN32 // OpenVario needs no format field! if (ovdevice.settings.find("Format") != ovdevice.settings.end()) { - format = "-"; - format += ovdevice.settings.find("Format")->second; + NarrowString<0x10> format(""); + format = "-"; + format += ovdevice.settings.find("Format")->second; + ArgList.push_back(format.c_str()); + // LogFormat("format = %s", format.c_str()); } else { - format = "-1400x700"; + ArgList.push_back("-1400x700"); } - LogFormat("format = %s", format.c_str()); -#endif -#if 1 // TODO(August2111): only Debug Purpose - NarrowString<0x200> test(ExePath.string().c_str()); - test.AppendFormat(" %s", "-fly"); - test.AppendFormat(" %s", datapath.c_str()); - test.AppendFormat(" %s", profile.c_str()); - test.AppendFormat(" %s", format.c_str()); - LogFormat("TEST = %s", test.c_str()); -#if _UNICODE - ShowMessageBox(ConvertACPToWide(test.c_str()).c_str(), _T("Run"), - MB_OK | MB_ICONEXCLAMATION); -#else // _UNICODE - ShowMessageBox((TCHAR *)test.c_str(), _T("Run"), - MB_OK | MB_ICONEXCLAMATION); - // Run(test.c_str()); #endif - // Run(ExePath.generic_string().c_str(), "-fly", datapath, profile, format); -#else -#endif - Run(ExePath.generic_string().c_str(), "-fly", datapath, profile, format, nullptr); + //=============== End of Parameter ======================= + ArgList.push_back(nullptr); + //======================================================== + Run(&ArgList[0]); } else { // ExePath doesnt exist! + LogFormat("Program file '%s' doesnt exist!", ExePath.c_str()); +#ifdef _WIN32 + // with Linux ShowMessageBox -> crash! ShowMessageBox(_("Program file doesnt exist!"), _T("Run"), MB_OK | MB_ICONEXCLAMATION); - +#endif } } @@ -373,7 +337,6 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, // Btn_XCSoar->SetEnabled(File::Exists); progress_timer->Hide(); - // HideRow(Controls::OPENSOAR_CLUB); } static int @@ -436,25 +399,13 @@ Main() int main(int argc, char *argv[]) { -// StaticString<0x200> exepath; -// exepath.SetASCII(argv[0]); -// ovdevice.SetBinPath(exepath.c_str()); if (argc > 0) ovdevice.SetBinPath(argv[0]); - /*the x-menu is waiting a second to solve timing problem with display rotation - */ + /* the OpenVarioBaseMenu is waiting a second to solve timing problem with + display rotation */ std::this_thread::sleep_for(std::chrono::seconds(1)); int action = Main(); // save in LogFormat? return action; } - -#ifdef _WIN32 -int RunProcessDialog(UI::SingleWindow &parent, const DialogLook &dialog_look, - const TCHAR *caption, const char *const *argv, - std::function on_exit = {}) noexcept -{ - return 0; -} -#endif // _WIN32 From 4863978380947eb7022921bc28286c6b4f9f7c32 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 18 Jan 2024 11:54:42 +0100 Subject: [PATCH 147/403] Widget/LargeTextWidget - make it possible to write in SetText with char* and std::string_view strings on _UNICODE systems --- src/Widget/LargeTextWidget.cpp | 18 ++++++++++++++++++ src/Widget/LargeTextWidget.hpp | 8 +++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/Widget/LargeTextWidget.cpp b/src/Widget/LargeTextWidget.cpp index b3f85878806..8b94498c77a 100644 --- a/src/Widget/LargeTextWidget.cpp +++ b/src/Widget/LargeTextWidget.cpp @@ -5,6 +5,9 @@ #include "ui/control/LargeTextWindow.hpp" #include "Look/DialogLook.hpp" +#if _UNICODE +# include "util/ConvertString.hpp" +#endif void LargeTextWidget::SetText(const TCHAR *text) noexcept { @@ -12,6 +15,21 @@ LargeTextWidget::SetText(const TCHAR *text) noexcept w.SetText(text); } +#if _UNICODE +// Maybe this is against MaxK XCSoar rules, but this makes the life much easier +void +LargeTextWidget::SetText(const char *text) noexcept +{ + SetText(ConvertACPToWide(text).c_str()); +} + +void +LargeTextWidget::SetText(std::string_view text) noexcept +{ + SetText(text.data()); +} +#endif + void LargeTextWidget::Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept { diff --git a/src/Widget/LargeTextWidget.hpp b/src/Widget/LargeTextWidget.hpp index 78507389d8e..358bbcc9ba8 100644 --- a/src/Widget/LargeTextWidget.hpp +++ b/src/Widget/LargeTextWidget.hpp @@ -6,6 +6,9 @@ #include "WindowWidget.hpp" #include +#if _UNICODE +#include +#endif struct DialogLook; @@ -22,7 +25,10 @@ class LargeTextWidget : public WindowWidget { :look(_look), text(_text) {} void SetText(const TCHAR *text) noexcept; - +#if _UNICODE + void SetText(const char *text) noexcept; + void SetText(const std::string_view text) noexcept; +#endif /* virtual methods from class Widget */ void Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept override; bool SetFocus() noexcept override; From 96064228fdb59d038c6a1c2b8ca5932e747c092b Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 18 Jan 2024 11:56:45 +0100 Subject: [PATCH 148/403] [CMake] OpenVarioBaseMenu - update with adding ProcessDialog --- src/OpenVario/CMakeSource.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenVario/CMakeSource.cmake b/src/OpenVario/CMakeSource.cmake index 0b09ae1af30..64a3f230b26 100644 --- a/src/OpenVario/CMakeSource.cmake +++ b/src/OpenVario/CMakeSource.cmake @@ -40,7 +40,7 @@ set(_SOURCES ${SRC}/Dialogs/TextEntry.cpp ${SRC}/Dialogs/KnobTextEntry.cpp ${SRC}/Dialogs/TouchTextEntry.cpp - # ov.mk: ${SRC}/Dialogs/ProcessDialog.cpp + ${SRC}/Dialogs/ProcessDialog.cpp ${SRC}/Profile/Map.cpp ${SRC}/Profile/File.cpp ${SRC}/Profile/NumericValue.cpp From cd7346d2d3dc1ca793dd55b722b967f456b96667 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 18 Jan 2024 11:58:17 +0100 Subject: [PATCH 149/403] Dialogs/ProcessDialog - preparing for usage in Wibndows systems don't call the command, only write the command in the Text-Window --- src/Dialogs/ProcessDialog.cpp | 41 ++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/src/Dialogs/ProcessDialog.cpp b/src/Dialogs/ProcessDialog.cpp index 5229744a20c..bb5e47c43a2 100644 --- a/src/Dialogs/ProcessDialog.cpp +++ b/src/Dialogs/ProcessDialog.cpp @@ -21,6 +21,7 @@ // TODO(August2111): needs work! #include "util/ConvertString.hpp" typedef size_t pid_t; +#include #else #include #endif @@ -82,16 +83,26 @@ UnblockAllSignals() noexcept void ProcessWidget::Start() { +#ifdef _WIN32 + // TODO(August2111): needs work! + std::stringstream ss; + ss << "Call Linux Command:" << std::endl; + ss << "=================" << std::endl << std::endl; + + unsigned int i = 0; + for (auto arg = argv[0]; arg != nullptr; arg = argv[++i]) { + printf("%s\n", arg); + ss << arg << ' '; + } + SetText(ss.str()); + // system(ss.str().c_str()); +#else auto dev_null = OpenReadOnly("/dev/null"); UniqueFileDescriptor r, w; if (!UniqueFileDescriptor::CreatePipe(r, w)) throw MakeErrno("Failed to create pipe"); -#ifdef _WIN32 - // TODO(August2111): needs work! -#else - pid = fork(); if (pid < 0) throw MakeErrno("Failed to fork"); @@ -107,10 +118,10 @@ ProcessWidget::Start() fprintf(stderr, "Failed to execute %s: %s\n", argv[0], strerror(errno)); _exit(EXIT_FAILURE); } -#endif fd.Open(r.Release()); fd.ScheduleRead(); +#endif } void @@ -141,7 +152,9 @@ ProcessWidget::OnExit(int code) noexcept return false; dialog->SetModalResult(result); +#ifndef _WIN32 UI::event_queue->Interrupt(); +#endif return true; } @@ -158,16 +171,14 @@ ProcessWidget::OnPipeReady(unsigned) noexcept return; text.append("\nFailed to read from pipe"); -#ifdef _WIN32 - SetText(ConvertACPToWide(text.c_str()).c_str()); -#else SetText(text.c_str()); -#endif cancel_button->SetCaption(_("Close")); // make sure the EventLoop gets interrupted so the UI gets redrawn +#ifndef _WIN32 UI::event_queue->Interrupt(); +#endif return; } @@ -195,7 +206,9 @@ ProcessWidget::OnPipeReady(unsigned) noexcept cancel_button->SetCaption(_("Close")); // make sure the EventLoop gets interrupted so the UI gets redrawn +#ifndef _WIN32 UI::event_queue->Interrupt(); +#endif return; } @@ -203,13 +216,11 @@ ProcessWidget::OnPipeReady(unsigned) noexcept if (text.length() > 16384) text.erase(0, 4096); -#ifdef _WIN32 - SetText(ConvertACPToWide(text.c_str()).c_str()); -#else SetText(text.c_str()); -#endif // make sure the EventLoop gets interrupted so the UI gets redrawn +#ifndef _WIN32 UI::event_queue->Interrupt(); +#endif } void @@ -221,11 +232,7 @@ ProcessWidget::Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept Start(); } catch (...) { text = GetFullMessage(std::current_exception()); -#ifdef _WIN32 - SetText(ConvertACPToWide(text.c_str()).c_str()); -#else SetText(text.c_str()); -#endif } } From 48e929368c127225093b9c465845f1284e25daf9 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sat, 20 Jan 2024 20:18:28 +0100 Subject: [PATCH 150/403] SystemMenuWidget.cpp - use GetHomePath use Run with output file use define switch to select DBUS or cmd line for ... setting VarioD and SensorD --- src/OpenVario/System/SystemMenuWidget.cpp | 119 +++++++++++++++++++++- 1 file changed, 118 insertions(+), 1 deletion(-) diff --git a/src/OpenVario/System/SystemMenuWidget.cpp b/src/OpenVario/System/SystemMenuWidget.cpp index 08ff06b54c6..f71dae8efc8 100644 --- a/src/OpenVario/System/SystemMenuWidget.cpp +++ b/src/OpenVario/System/SystemMenuWidget.cpp @@ -22,10 +22,13 @@ #include "ui/window/Init.hpp" #include "util/ScopeExit.hxx" +#include "OpenVario/SystemSettingsWidget.hpp" #include "OpenVario/System/OpenVarioDevice.hpp" -#include "OpenVario/System/SystemSettingsWidget.hpp" #include "OpenVario/System/SystemMenuWidget.hpp" +#include "system/Process.hpp" + +#include #include #include @@ -93,6 +96,84 @@ CalibrateSensors() noexcept }); } +//----------------------------------------------------------------------------- +class ScreenSSHWidget final : public RowFormWidget { + UI::Display &display; + UI::EventQueue &event_queue; + +public: + ScreenSSHWidget(UI::Display &_display, UI::EventQueue &_event_queue, + const DialogLook &look) noexcept + : RowFormWidget(look), display(_display), event_queue(_event_queue) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept override; +}; + +void ScreenSSHWidget::Prepare([[maybe_unused]] ContainerWindow &parent, + [[maybe_unused]] const PixelRect &rc) noexcept { + AddButton(_T("Enable"), []() { + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "systemctl enable --now dropbear.socket && printf '\nSSH has been enabled'", + + nullptr}; + + RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), + _T("Enable"), argv); + }); + + AddButton(_T("Disable"), []() { + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "systemctl disable --now dropbear.socket && printf '\nSSH has been disabled'", + nullptr}; + + RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), + _T("Disable"), argv); + }); + + AddButton(_T("IsEnabled"), []() { + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "systemctl is-enabled dropbear.socket", + nullptr}; + + RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), + _T("IsEnabled"), argv); + }); + AddButton(_T("IsActive"), []() { + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "systemctl is-active dropbear.socket", + nullptr}; + + RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), + _T("IsActive"), argv); + }); + + AddButton(_T("GetStatus"), []() { + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "systemctl is-enabled dropbear.socket", + "systemctl is-active dropbear.socket", nullptr}; + + RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), + _T("GetStatus"), argv); + }); + AddButton(_T("GetStatus2"), []() { + static constexpr const char *argv[] = { + "/bin/sh", "-c", + "/bin/systemctl is-enabled dropbear.socket", + "echo '\n ===== \n'", + "/bin/systemctl is-active dropbear.socket", nullptr}; + + RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), + _T("GetStatus2"), argv); + }); +} + //----------------------------------------------------------------------------- void SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, @@ -103,6 +184,15 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, exit(START_UPGRADE); }); + AddButton(_T("SSH"), [this]() { + TWidgetDialog sub_dialog(WidgetDialog::Full{}, + dialog.GetMainWindow(), GetLook(), + _T("Enable or Disable SSH")); + sub_dialog.SetWidget(display, event_queue, GetLook()); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); + }); + AddButton(_("WiFi Settings"), []() { static constexpr const char *argv[] = { "/bin/sh", "-c", @@ -147,5 +237,32 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, UIGlobals::GetDialogLook(), _T("System Info"), argv); }); + AddButton(_("Test-Process"), []() { + static constexpr const char *argv[] = { + "/bin/ls", nullptr + }; + + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _T("Test-Process"), argv); + }); + + AddButton(_("Test-Process 2"), [this]() { + StaticString<0x200> str; + str.Format(_T("%s/%s"), ovdevice.GetHomePath().c_str(), _T("process.txt")); + Path output = Path(str); + std::cout << "FileName: " << output.ToUTF8() << std::endl; + + auto ret_value = Run( + output, + "/home/august2111/TestProcess.sh"); + + char buffer[0x100]; + File::ReadString(output, buffer, sizeof(buffer)); + std::string xx = buffer; + xx += "\nreturn value: " + std::to_string(ret_value); + File::WriteExisting(output, xx.c_str()); + return ret_value; + }); } From 1aac60c6fe56c45adf90d0f1ef8b9ad71eb0d122 Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 26 Jan 2024 18:18:12 +0100 Subject: [PATCH 151/403] SystemSettingsWidget.cpp - OpenVario_Device::GetSystemStatus() instead of OpenVarioGetSensorDStatus() and OpenVarioGetVarioDStatus() --- src/OpenVario/SystemSettingsWidget.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/OpenVario/SystemSettingsWidget.cpp b/src/OpenVario/SystemSettingsWidget.cpp index a9c901f800a..976af3938f0 100644 --- a/src/OpenVario/SystemSettingsWidget.cpp +++ b/src/OpenVario/SystemSettingsWidget.cpp @@ -106,10 +106,10 @@ SystemSettingsWidget::Prepare(ContainerWindow &parent, { RowFormWidget::Prepare(parent, rc); - ovdevice.sensord = OpenvarioGetSensordStatus(); - ovdevice.variod = OpenvarioGetVariodStatus(); - ovdevice.ssh = (unsigned) OpenvarioGetSSHStatus(); - + ovdevice.ssh = (unsigned)ovdevice.GetSSHStatus(); + ovdevice.sensord = ovdevice.GetSystemStatus("sensord"); + ovdevice.variod = ovdevice.GetSystemStatus("variod"); + const TCHAR version[] = _T(PROGRAM_VERSION); @@ -194,14 +194,13 @@ SystemSettingsWidget::Save([[maybe_unused]] bool &_changed) noexcept } if (SaveValueEnum(SSH, ovdevice.ssh)) - OpenvarioSetSSHStatus((SSHStatus) ovdevice.ssh); + ovdevice.SetSSHStatus((SSHStatus)ovdevice.ssh); if (SaveValue(SENSORD, ovdevice.sensord)) - OpenvarioSetSensordStatus(ovdevice.sensord); + ovdevice.SetSystemStatus("sensord", ovdevice.sensord); if (SaveValue(VARIOD, ovdevice.variod)) - OpenvarioSetSensordStatus(ovdevice.variod); - + ovdevice.SetSystemStatus("variod", ovdevice.variod); return true; } From d4190a298cfc10ebab4cee838d1c5e7f41f27bd9 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 29 Jan 2024 20:27:50 +0100 Subject: [PATCH 152/403] OpenVario - add WiFiDBus.cpp --- src/OpenVario/System/WifiDBus.cpp | 84 +++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 src/OpenVario/System/WifiDBus.cpp diff --git a/src/OpenVario/System/WifiDBus.cpp b/src/OpenVario/System/WifiDBus.cpp new file mode 100644 index 00000000000..63fc41e357b --- /dev/null +++ b/src/OpenVario/System/WifiDBus.cpp @@ -0,0 +1,84 @@ +WiFiAgent::WiFiAgent(GDBusConnection *inputConnection, Poco::JSON::Object::Ptr credentials) +: connection(inputConnection), parameters(std::move(credentials)) { + static const GDBusInterfaceVTable vtable = { + .method_call = handleMethodCall, + .get_property = nullptr, + .set_property = nullptr, + }; + static GError* error = nullptr; + + objectId = g_dbus_connection_register_object( + connection, + WiFiAgent::ourAgentPath, + WiFiAgent::introspectionWrapper->interfaces[0], + &vtable, + parameters.get(), + nullptr, + &error + ); + if(objectId == 0 || error != nullptr) + throw GlibException("Register WiFi agent", error); + + GVariant* agentPathVariant = g_variant_new("(o)", WiFiAgent::ourAgentPath); + if(agentPathVariant == nullptr) + throw std::runtime_error("Register WiFi agent: g_variant_new failed."); + + GVariant* result = g_dbus_connection_call_sync(connection, "net.connman", "/", "net.connman.Manager", +"RegisterAgent", agentPathVariant, nullptr, G_DBUS_CALL_FLAGS_NONE, -1, nullptr, &error); + if(result == nullptr || error != nullptr) + throw GlibException("Register WiFi agent", error); +} + + +//----------------------------------------------------------------------------- +void WiFiAgent::handleMethodCall(GDBusConnection *, const gchar *, + const gchar *, const gchar *, const gchar *method, + GVariant *methodParameters, GDBusMethodInvocation *invocation, gpointer userdata) { + std::cout << "Method got called." << std::endl; +} +//----------------------------------------------------------------------------- +static inline class IntrospectionWrapper final { + GDBusNodeInfo* introspection = nullptr; + static constexpr auto introspectionXML = + "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + ""; + +public: + IntrospectionWrapper() { + GError* error = nullptr; + introspection = g_dbus_node_info_new_for_xml(introspectionXML, &error); + if(introspection == nullptr || error != nullptr) + std::cerr << GlibException("Agent introspection construction", error) << std::endl; + } + GDBusNodeInfo* operator->() { return introspection; }; + GDBusNodeInfo* get() { return introspection; } +} introspectionWrapper; +//----------------------------------------------------------------------------- +void DBusManipulator::connectToTheNetwork(GDBusProxy *network) { + GError* error = nullptr; + g_dbus_proxy_call_sync(network, "Connect", nullptr, G_DBUS_CALL_FLAGS_NONE, -1, nullptr, &error); + if(error != nullptr) + throw GlibException("Connect to the network", error); + + const auto state = variantGetValue(getNetworkProperty(network, "State")); + if(state != "online" && state != "ready") + throw std::runtime_error("Connect to the WiFi network: connection failed"); + + std::cout << "Connected to the network successfully." << std::endl; +} +//----------------------------------------------------------------------------- +GDBusProxy* network = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, nullptr, "net.connman", servicePath, "net.connman.Service", nullptr, &error); +if(network == nullptr || error != nullptr) + throw GlibException("Get network by name", error); +//----------------------------------------------------------------------------- From 73a36bb799ce6d2774dab29f223e35aed7dd6438 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 15 Apr 2024 11:54:25 +0200 Subject: [PATCH 153/403] [build] OpenVario - add WiFiDBus.cpp --- build/ov.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/build/ov.mk b/build/ov.mk index 0943aa67144..33e3603a8f0 100644 --- a/build/ov.mk +++ b/build/ov.mk @@ -187,6 +187,7 @@ OV_MENU_SOURCES = \ \ $(SRC)/OpenVario/System/WifiDialogOV.cpp \ $(SRC)/OpenVario/System/WifiSupplicantOV.cpp \ + $(SRC)/OpenVario/System/WifiDBus.cpp \ \ $(SRC)/OpenVario/SystemSettingsWidget.cpp \ \ From 02ce2a382939f3e343d4155bc7e325da9fc1616e Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 15 Apr 2024 11:54:42 +0200 Subject: [PATCH 154/403] [CMake] OpenVario - add WiFiDBus.cpp --- src/OpenVario/CMakeSource.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OpenVario/CMakeSource.cmake b/src/OpenVario/CMakeSource.cmake index 64a3f230b26..615688a7ad1 100644 --- a/src/OpenVario/CMakeSource.cmake +++ b/src/OpenVario/CMakeSource.cmake @@ -12,9 +12,9 @@ set(_SOURCES OpenVario/System/Setting/RotationWidget.cpp OpenVario/System/Setting/WifiWidget.cpp - OpenVario/System/WifiDialogOV.cpp - OpenVario/System/WifiSupplicantOV.cpp - + OpenVario/System/WifiDialogOV.cpp + OpenVario/System/WifiSupplicantOV.cpp + OpenVario/System/WifiDBus.cpp ${SRC}/Version.cpp ${SRC}/Asset.cpp From ebb1b93ea6e1dd5073c71ca5b79ead5a12e113e9 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 29 Jan 2024 22:12:41 +0100 Subject: [PATCH 155/403] WifiDBus.cpp - disable code for all systems --- src/OpenVario/System/WifiDBus.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/OpenVario/System/WifiDBus.cpp b/src/OpenVario/System/WifiDBus.cpp index 63fc41e357b..e185bf49614 100644 --- a/src/OpenVario/System/WifiDBus.cpp +++ b/src/OpenVario/System/WifiDBus.cpp @@ -1,3 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project + + +// #ifdef __GNUC__ +#if 1 +#ifdef DBUS_FUNCTIONS +#include "lib/dbus/Conn ection.hxx" +#include "lib/dbus/ScopeMatch.hxx" +#include "lib/dbus/Systemd.hxx" +#endif + +#if 0 + WiFiAgent::WiFiAgent(GDBusConnection *inputConnection, Poco::JSON::Object::Ptr credentials) : connection(inputConnection), parameters(std::move(credentials)) { static const GDBusInterfaceVTable vtable = { @@ -78,7 +92,15 @@ void DBusManipulator::connectToTheNetwork(GDBusProxy *network) { std::cout << "Connected to the network successfully." << std::endl; } //----------------------------------------------------------------------------- -GDBusProxy* network = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, nullptr, "net.connman", servicePath, "net.connman.Service", nullptr, &error); -if(network == nullptr || error != nullptr) +void TestDBus() { + // GDBusProxy *network = g_dbus_proxy_new_for_bus_sync( + ODBus::Proxy *network = g_dbus_proxy_new_for_bus_sync( + G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, nullptr, + "net.connman", servicePath, "net.connman.Service", nullptr, &error); + if (network == nullptr || error != nullptr) throw GlibException("Get network by name", error); +} + +#endif 0 //----------------------------------------------------------------------------- +#endif // __GNUC__ From 9f2d6c2f0c46ee5e17cdc92355e0d4383ed5e417 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 29 Jan 2024 22:13:50 +0100 Subject: [PATCH 156/403] OpenVario - add NMConnector.cpp --- src/OpenVario/System/NMConnector.cpp | 110 +++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 src/OpenVario/System/NMConnector.cpp diff --git a/src/OpenVario/System/NMConnector.cpp b/src/OpenVario/System/NMConnector.cpp new file mode 100644 index 00000000000..a4258873cfa --- /dev/null +++ b/src/OpenVario/System/NMConnector.cpp @@ -0,0 +1,110 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2011 Red Hat, Inc. + */ + +#if 0 // __MSVC__ + +// #ifndef __MSVC__ +/* + * The example shows how to add a new connection using libnm. Contrast this + * example with add-connection-gdbus.c, which is a bit lower level and talks + * directly to NM using GDBus. This example is simpler because libnm handles + * much of the low-level stuff for you. + * + * Compile with: + * gcc -Wall add-connection-libnm.c -o add-connection-libnm `pkg-config --libs + * --cflags libnm` + */ + +#include +#include + +static void added_cb(GObject *client, GAsyncResult *result, + gpointer user_data) { + GMainLoop *loop = user_data; + NMRemoteConnection *remote; + GError *error = NULL; + + /* NM responded to our request; either handle the resulting error or + * print out the object path of the connection we just added. + */ + remote = nm_client_add_connection_finish(NM_CLIENT(client), result, &error); + + if (error) { + g_print("Error adding connection: %s", error->message); + g_error_free(error); + } else { + g_print("Added: %s\n", nm_connection_get_path(NM_CONNECTION(remote))); + g_object_unref(remote); + } + + /* Tell the mainloop we're done and we can quit now */ + g_main_loop_quit(loop); +} + +static void add_connection(NMClient *client, GMainLoop *loop, + const char *con_name) { + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIP4Config *s_ip4; + char *uuid; + + /* Create a new connection object */ + connection = nm_simple_connection_new(); + + /* Build up the 'connection' Setting */ + s_con = (NMSettingConnection *)nm_setting_connection_new(); + uuid = nm_utils_uuid_generate(); + g_object_set(G_OBJECT(s_con), NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_ID, con_name, NM_SETTING_CONNECTION_TYPE, + "802-3-ethernet", NULL); + g_free(uuid); + nm_connection_add_setting(connection, NM_SETTING(s_con)); + + /* Build up the 'wired' Setting */ + s_wired = (NMSettingWired *)nm_setting_wired_new(); + nm_connection_add_setting(connection, NM_SETTING(s_wired)); + + /* Build up the 'ipv4' Setting */ + s_ip4 = (NMSettingIP4Config *)nm_setting_ip4_config_new(); + g_object_set(G_OBJECT(s_ip4), NM_SETTING_IP_CONFIG_METHOD, + NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); + nm_connection_add_setting(connection, NM_SETTING(s_ip4)); + + /* Ask the settings service to add the new connection; we'll quit the + * mainloop and exit when the callback is called. + */ + nm_client_add_connection_async(client, connection, TRUE, NULL, added_cb, + loop); + g_object_unref(connection); +} + +int main(int argc, char *argv[]) { + NMClient *client; + GMainLoop *loop; + GError *error = NULL; + + loop = g_main_loop_new(NULL, FALSE); + + /* Connect to NetworkManager */ + client = nm_client_new(NULL, &error); + if (!client) { + g_message("Error: Could not connect to NetworkManager: %s.", + error->message); + g_error_free(error); + return 1; + } + + /* Ask NM to add the new connection */ + add_connection(client, loop, "__Test connection__"); + /* Wait for the connection to be added */ + g_main_loop_run(loop); + + /* Clean up */ + g_object_unref(client); + + return 0; +} +#endif // __MSVC__ From 02a344fac37a9b9d2af26abef8de2695e847daa2 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 15 Apr 2024 10:58:06 +0200 Subject: [PATCH 157/403] [CMake/OV] - add NMConnector.cpp --- src/OpenVario/CMakeSource.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/src/OpenVario/CMakeSource.cmake b/src/OpenVario/CMakeSource.cmake index 615688a7ad1..a64b3bed0b0 100644 --- a/src/OpenVario/CMakeSource.cmake +++ b/src/OpenVario/CMakeSource.cmake @@ -15,6 +15,7 @@ set(_SOURCES OpenVario/System/WifiDialogOV.cpp OpenVario/System/WifiSupplicantOV.cpp OpenVario/System/WifiDBus.cpp + OpenVario/System/NMConnector.cpp ${SRC}/Version.cpp ${SRC}/Asset.cpp From 872de482150401acef891666c60bfd7c0500f060 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 15 Apr 2024 10:58:58 +0200 Subject: [PATCH 158/403] [build/OV] - add NMConnector.cpp --- build/ov.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/build/ov.mk b/build/ov.mk index 33e3603a8f0..965120093b2 100644 --- a/build/ov.mk +++ b/build/ov.mk @@ -188,6 +188,7 @@ OV_MENU_SOURCES = \ $(SRC)/OpenVario/System/WifiDialogOV.cpp \ $(SRC)/OpenVario/System/WifiSupplicantOV.cpp \ $(SRC)/OpenVario/System/WifiDBus.cpp \ + $(SRC)/OpenVario/System/NMConnector.cpp \ \ $(SRC)/OpenVario/SystemSettingsWidget.cpp \ \ From 0edb760232d0bbff39b7e2f3a15b25cf537bfcb8 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 31 Jan 2024 08:49:59 +0100 Subject: [PATCH 159/403] OpenVarioDevice.cpp - better check enabled/disabled in GetSystemStatus --- src/OpenVario/System/OpenVarioDevice.cpp | 45 +++++++++--------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/src/OpenVario/System/OpenVarioDevice.cpp b/src/OpenVario/System/OpenVarioDevice.cpp index f2eccc009ce..370ee36e325 100644 --- a/src/OpenVario/System/OpenVarioDevice.cpp +++ b/src/OpenVario/System/OpenVarioDevice.cpp @@ -45,6 +45,8 @@ #include +using std::string_view_literals::operator""sv; + OpenVario_Device ovdevice; @@ -261,7 +263,6 @@ OpenVario_Device::SetRotation(DisplayOrientation orientation) SSHStatus OpenVario_Device::GetSSHStatus() noexcept { -#if 0 auto connection = ODBus::Connection::GetSystem(); if (Systemd::IsUnitEnabled(connection, "dropbear.socket")) { @@ -271,12 +272,6 @@ OpenVario_Device::GetSSHStatus() noexcept } else { return SSHStatus::DISABLED; } -#else - if (GetSystemStatus("dropbear.socket") == 0) - return SSHStatus::ENABLED; - else - return SSHStatus::DISABLED; -#endif } void @@ -312,18 +307,6 @@ OpenVario_Device::GetSystemStatus(std::string_view system) noexcept std::cout << " 0: " << system << std::endl; StaticString<0x20> file; -///// std::string home = std::string("/home/root/"); -///// home += system; -///// -///// // AllocatedPath run_tmp_file = AllocatedPath::Build(home, system); -///// AllocatedPath run_tmp_file(home); //, system); -///// // AllocatedPath::Build(home_path, system); -///// -///// -///// std::string filename = system; -///// filename += ".txt"; -///// AllocatedPath run_tmp_file = -///// AllocatedPath::Build(home_path, Path(_T(filename.c_str()))); std::string_view _dirname("/home/august2111"); //Path run_tmp_file("/home/august2111/test.txt"); @@ -339,8 +322,9 @@ OpenVario_Device::GetSystemStatus(std::string_view system) noexcept Path tmp_file = _tmp_file; - std::cout << " 1: " << tmp_file.ToUTF8() - << ", " << system << std::endl; + std::cout << " 1: " << tmp_file.ToUTF8() << ", " << system << std::endl; + if (File::Exists(tmp_file)) + File::Delete(tmp_file); // remove, if exists auto run_value = Run(tmp_file, "/bin/systemctl", "is-enabled", system.data()); std::cout << " 2: " << tmp_file.ToUTF8() << ", " << std::endl; char buffer[0x20]; @@ -348,16 +332,21 @@ OpenVario_Device::GetSystemStatus(std::string_view system) noexcept std::cout << " 3: " << buffer << ", " << std::endl; switch (run_value) { case 0: - return std::string_view("enabled") == buffer; - break; + if (std::string_view(buffer).starts_with("enabled")) + std::strncpy(buffer, "enabled -> ok!", sizeof(buffer)); + else + std::strncpy(buffer, "enabled -> not ok???", sizeof(buffer)); + std::cout << " 4: " << system << ": " << buffer << std::endl; + return true; case 1: - if (std::string_view("disabled") == buffer) - std::strncat(buffer, " -> ok", sizeof(buffer)); - File::WriteExisting(tmp_file, buffer); + if (std::string_view(buffer).starts_with("enabled")) + std::strncpy(buffer, "disabled -> ok!", sizeof(buffer)); + else + std::strncpy(buffer, "disabled -> not ok???", sizeof(buffer)); + std::cout << " 4: " << system << ": " << buffer << std::endl; return false; default: - std::strncat(buffer, " Wrong!", sizeof(buffer)); - File::WriteExisting(tmp_file, buffer); + std::cout << " 4: " << system << " = Wrong" << std::endl; return false; } #endif From 1b85bc58e856bde31ba61584e8ff94137654d240 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 31 Jan 2024 12:08:22 +0100 Subject: [PATCH 160/403] OpenVarioBaseMenu.cpp - start with StartTimeout --- src/OpenVario/OpenVarioBaseMenu.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/OpenVario/OpenVarioBaseMenu.cpp b/src/OpenVario/OpenVarioBaseMenu.cpp index ed44f8526ca..0737c4fa280 100644 --- a/src/OpenVario/OpenVarioBaseMenu.cpp +++ b/src/OpenVario/OpenVarioBaseMenu.cpp @@ -46,6 +46,7 @@ static DialogSettings dialog_settings; static UI::SingleWindow *global_main_window; static DialogLook *global_dialog_look; +static unsigned StartTimeout = 1; const DialogSettings & UIGlobals::GetDialogSettings() @@ -97,7 +98,7 @@ class MainMenuWidget final display(_display), event_queue(_event_queue), dialog(_dialog) { ovdevice.LoadSettings(); - remaining_seconds = ovdevice.timeout; + remaining_seconds = StartTimeout == 0 ? 0 : ovdevice.timeout; } private: @@ -319,6 +320,11 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, auto Btn_Shell = AddButton(_T("Exit to Shell"), [this]() { dialog.SetModalResult(LAUNCH_SHELL); }); +#ifndef RELEASE_VERSION + AddButton(_T("Exit to Shell (with Wait)"), + [this]() { dialog.SetModalResult(LAUNCH_SHELL+1); }); +#endif + auto Btn_Reboot = AddButton(_T("Reboot"), []() { Run("/sbin/reboot"); }); auto Btn_Shutdown = @@ -401,6 +407,8 @@ main(int argc, char *argv[]) { if (argc > 0) ovdevice.SetBinPath(argv[0]); + if (argc > 1) + StartTimeout = std::strtoul(argv[1], nullptr, 10); /* the OpenVarioBaseMenu is waiting a second to solve timing problem with display rotation */ std::this_thread::sleep_for(std::chrono::seconds(1)); From ce32684349f493f22ae375d9a1c783e5b0323324 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 31 Jan 2024 14:40:34 +0100 Subject: [PATCH 161/403] OpenVarioBaseMenu.cpp try with output path --- src/OpenVario/OpenVarioBaseMenu.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/OpenVario/OpenVarioBaseMenu.cpp b/src/OpenVario/OpenVarioBaseMenu.cpp index 0737c4fa280..23b01629242 100644 --- a/src/OpenVario/OpenVarioBaseMenu.cpp +++ b/src/OpenVario/OpenVarioBaseMenu.cpp @@ -325,10 +325,16 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [this]() { dialog.SetModalResult(LAUNCH_SHELL+1); }); #endif - auto Btn_Reboot = AddButton(_T("Reboot"), []() { Run("/sbin/reboot"); }); + // const Path TestPath = Path(); + // const std::filesystem::path TestPath = "test.txt"; + // const std::filesystem::path TestPath = "test.txt"; + auto Btn_Reboot = + AddButton(_T("Reboot"), []() { Run("/sbin/reboot"); }); + // auto Btn_Reboot = AddButton(_T("Reboot"), []() { Run("/sbin/reboot"); }); auto Btn_Shutdown = AddButton(_T("Power off"), []() { Run("/sbin/poweroff"); }); + // AddButton(_T("Power off"), []() { "/sbin/poweroff"); }); //---------------------------------------------------------- progress_timer = RowFormWidget::Add(_T(""), _T(""), true); From f315b9064b82f10c721882682d27cfb5583c8e3d Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 31 Jan 2024 15:41:57 +0100 Subject: [PATCH 162/403] system/Path.hpp - the Path is empty too if value is 0 (from default ctor) --- src/system/Path.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/system/Path.hpp b/src/system/Path.hpp index cbf0f7db1df..bb25a60bd10 100644 --- a/src/system/Path.hpp +++ b/src/system/Path.hpp @@ -49,7 +49,7 @@ class Path { AllocatedPath operator+(const_pointer other) const noexcept; bool empty() const noexcept { - return value.empty(); + return (value == 0) || value.empty(); } constexpr const_pointer c_str() const noexcept { From f0474f7d9ba7b83eaef503540109e08ce21a81d7 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 31 Jan 2024 19:18:22 +0100 Subject: [PATCH 163/403] OpenVarioBaseMenu.cpp - cleanup --- src/OpenVario/OpenVarioBaseMenu.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/OpenVario/OpenVarioBaseMenu.cpp b/src/OpenVario/OpenVarioBaseMenu.cpp index 23b01629242..c0aff45ac2a 100644 --- a/src/OpenVario/OpenVarioBaseMenu.cpp +++ b/src/OpenVario/OpenVarioBaseMenu.cpp @@ -325,9 +325,6 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [this]() { dialog.SetModalResult(LAUNCH_SHELL+1); }); #endif - // const Path TestPath = Path(); - // const std::filesystem::path TestPath = "test.txt"; - // const std::filesystem::path TestPath = "test.txt"; auto Btn_Reboot = AddButton(_T("Reboot"), []() { Run("/sbin/reboot"); }); // auto Btn_Reboot = AddButton(_T("Reboot"), []() { Run("/sbin/reboot"); }); From 03a5750e22d351f3196598ceeb8818311c36af2d Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 31 Jan 2024 19:20:15 +0100 Subject: [PATCH 164/403] OpenVarioDevice.cpp - use a better test for bool --- src/OpenVario/System/OpenVarioDevice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenVario/System/OpenVarioDevice.cpp b/src/OpenVario/System/OpenVarioDevice.cpp index 370ee36e325..b28b5b52876 100644 --- a/src/OpenVario/System/OpenVarioDevice.cpp +++ b/src/OpenVario/System/OpenVarioDevice.cpp @@ -370,7 +370,7 @@ bool OpenVario_Device::GetSystemStatus(std::string_view system) noexcept { bool value; ReadBool(internal_map, system.data(), value); - return value; + return value != 0; } void OpenVario_Device::SetSystemStatus(std::string_view system, bool value) noexcept { From 96c69ba4c54ba1d7c738b417ce29716b35cb9e78 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 31 Jan 2024 19:22:09 +0100 Subject: [PATCH 165/403] OpenVarioDevice.hpp - use DEBUG_TEST_VERSION for test some things in the development --- src/OpenVario/System/OpenVarioDevice.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/OpenVario/System/OpenVarioDevice.hpp b/src/OpenVario/System/OpenVarioDevice.hpp index a5a56312558..7c373fafa9a 100644 --- a/src/OpenVario/System/OpenVarioDevice.hpp +++ b/src/OpenVario/System/OpenVarioDevice.hpp @@ -15,6 +15,12 @@ #include +#define DEBUG_TEST_VERSION 1 +#if !DEBUG_TEST_VERSION +#define RELEASE_VERSION +#endif + + #define DEBUG_OPENVARIO 1 #if __GNUC__ && __has_include("dbus/dbus.h") # define DBUS_FUNCTIONS 1 From dd3354b35e353a65aa0ceff8481d22b24327c171 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 31 Jan 2024 20:11:22 +0100 Subject: [PATCH 166/403] OpenVarioDevice.cpp - bugfix use string 'disabled' at disabled result --- src/OpenVario/System/OpenVarioDevice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenVario/System/OpenVarioDevice.cpp b/src/OpenVario/System/OpenVarioDevice.cpp index b28b5b52876..899224fadfb 100644 --- a/src/OpenVario/System/OpenVarioDevice.cpp +++ b/src/OpenVario/System/OpenVarioDevice.cpp @@ -339,7 +339,7 @@ OpenVario_Device::GetSystemStatus(std::string_view system) noexcept std::cout << " 4: " << system << ": " << buffer << std::endl; return true; case 1: - if (std::string_view(buffer).starts_with("enabled")) + if (std::string_view(buffer).starts_with("disabled")) std::strncpy(buffer, "disabled -> ok!", sizeof(buffer)); else std::strncpy(buffer, "disabled -> not ok???", sizeof(buffer)); From c9f31175de8d1d041b48604d42bf10eb47103257 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 1 Feb 2024 10:59:00 +0100 Subject: [PATCH 167/403] OpenVarioBaseMenu.cpp - add missing CancelTimer --- src/OpenVario/OpenVarioBaseMenu.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/OpenVario/OpenVarioBaseMenu.cpp b/src/OpenVario/OpenVarioBaseMenu.cpp index c0aff45ac2a..025ede3eb0b 100644 --- a/src/OpenVario/OpenVarioBaseMenu.cpp +++ b/src/OpenVario/OpenVarioBaseMenu.cpp @@ -282,6 +282,8 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, }); AddButton(_("Display Settings"), [this]() { + CancelTimer(); + TWidgetDialog sub_dialog( WidgetDialog::Full{}, dialog.GetMainWindow(), GetLook(), _T("OpenVario Display Settings")); @@ -291,15 +293,15 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, }); AddButton(_("System Settings"), [this]() { + CancelTimer(); + std::unique_ptr widget = CreateSystemSettingsWidget(); -#if 1 TWidgetDialog sub_dialog( WidgetDialog::Full{}, dialog.GetMainWindow(), GetLook(), _T("OpenVario System Settings")); sub_dialog.SetWidget(); sub_dialog.AddButton(_("Close"), mrOK); return sub_dialog.ShowModal(); -#endif }); AddButton(_("OpenVario Placeholder"), [this]() { From caead4d4edb7c80ca40bc729215d3fb3d0562f90 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 8 Feb 2024 23:54:13 +0100 Subject: [PATCH 168/403] util/ConvertString.hpp - add _A() and _W() macro --- src/util/ConvertString.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/util/ConvertString.hpp b/src/util/ConvertString.hpp index 7e4f30ec3f5..078442c6a3c 100644 --- a/src/util/ConvertString.hpp +++ b/src/util/ConvertString.hpp @@ -5,6 +5,16 @@ #include "UTF8.hpp" +#ifdef _UNICODE +# define _W(text) (UTF8ToWideConverter(text).c_str()) +# define _A(text) (WideToUTF8Converter(text).c_str()) +#else +# define _W(text) (text) +# define _A(text) (text) +#endif + + + #ifdef _UNICODE #include "AllocatedString.hxx" #else From 2f764c829a79f9353aa2460527711799f01b4efb Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 30 Jan 2024 14:17:26 +0100 Subject: [PATCH 169/403] OpenVario/System/WifiSupplicantOV.hpp - Connect and Disconnect --- src/OpenVario/System/WifiDialogOV.cpp | 462 ++++++++++++++++++++++---- 1 file changed, 401 insertions(+), 61 deletions(-) diff --git a/src/OpenVario/System/WifiDialogOV.cpp b/src/OpenVario/System/WifiDialogOV.cpp index 20c488066f2..408903d008b 100644 --- a/src/OpenVario/System/WifiDialogOV.cpp +++ b/src/OpenVario/System/WifiDialogOV.cpp @@ -20,6 +20,33 @@ #include "util/StaticString.hxx" #include "util/ConvertString.hpp" +#include "LocalPath.hpp" +#include "LogFile.hpp" +#include "system/Process.hpp" +#include "OpenVario/System/OpenVarioDevice.hpp" +#include "system/FileUtil.hpp" +#include "io/FileReader.hxx" +#include "io/ProgressReader.hpp" +#include "io/BufferedReader.hxx" +#include "io/StringConverter.hpp" +#include "io/ProgressReader.hpp" +#include "util/StringStrip.hxx" +#include "util/StringCompare.hxx" +#include "util/StringAPI.hxx" +// #include "Operation/ConsoleOperationEnvironment.hpp" +#include "Operation/Operation.hpp" +#include "Operation/ProgressListener.hpp" +// #include "lib/fmt/RuntimeError.hxx" + +#include +#include +#if DEBUG_TEST_VERSION +# include +#endif + +using std::string_view_literals::operator""sv; + +const char *const connmanctl = "/usr/bin/connmanctl"; #ifdef KOBO #include "Model.hpp" @@ -45,14 +72,19 @@ class WifiListWidget final : public ListWidget { struct NetworkInfo { - NarrowString<32> bssid; + NarrowString<64> mac_id; + NarrowString<64> bssid; NarrowString<256> ssid; + NarrowString<256> base_id; int signal_level; int id; enum WifiSecurity security; bool old_visible, old_configured; + bool enabled = false; // '*' - 1st char + bool coupled = false; // 'A' - 2nd char + bool connected = false; // 'R' - 3rd char; }; Button *connect_button; @@ -63,7 +95,7 @@ class WifiListWidget final TwoTextRowsRenderer row_renderer; - WPASupplicant wpa_supplicant; +// WPASupplicant wpa_supplicant; UI::PeriodicTimer update_timer{[this]{ UpdateList(); }}; @@ -72,7 +104,8 @@ class WifiListWidget final dialog.AddButton(_("Scan"), [this](){ try { EnsureConnected(); - wpa_supplicant.Scan(); + // wpa_supplicant.Scan(); + ScanWifi(); UpdateList(); } catch (...) { ShowError(std::current_exception(), _("Error")); @@ -89,6 +122,7 @@ class WifiListWidget final } void UpdateButtons(); + void ScanWifi(); /* virtual methods from class Widget */ void Prepare(ContainerWindow &parent, @@ -98,6 +132,9 @@ class WifiListWidget final CreateList(parent, look, rc, row_renderer.CalculateLayout(look.text_font, look.small_font)); + // insert from August2111 + ScanWifi(); + UpdateList(); update_timer.Schedule(std::chrono::seconds(1)); } @@ -111,7 +148,13 @@ class WifiListWidget final UpdateButtons(); } -private: + // add August2111: + void WifiConnect(enum WifiSecurity security, + // WPASupplicant &wpa_supplicant, + const char *ssid, const char *psk); + void WifiDisconnect(const char *ssid); + + private: /** * Ensure that we're connected to wpa_supplicant. * @@ -143,6 +186,49 @@ class WifiListWidget final void Connect(); }; + +#if 0 //DEBUG_TEST_VERSION +const char *TestArray[5][2] = { + { + "SSID-1", + "bssid-1", + }, + { + "SSID-2", + "bssid-2", + }, + { + "SSID-3", + "bssid-3", + }, + { + "SSID-4", + "bssid-4", + }, + { + "SSID-5", + "bssid-5", + } +}; +#endif + +void +WifiListWidget::ScanWifi() +{ +#ifdef __MSVC__ + char buffer[0x1000]; + auto file = Path(_T("connman-scan-results.txt")); + File::ReadString(Path(_T("/Data/connman-services.txt")), buffer, sizeof(buffer)); + File::CreateExclusive(file); + File::WriteExisting(file, buffer); +#else + Run(Path(_T("connman-technologies.txt")), connmanctl, "technologies"); + Run(Path(_T("connman-enable.txt")), connmanctl, "enable", "wifi"); + Run(Path(_T("connman-scan.txt")), connmanctl, "scan", "wifi"); + Run(Path(_T("connman-scan-results.txt")), connmanctl, "services"); +#endif +} + void WifiListWidget::UpdateButtons() { @@ -151,8 +237,10 @@ WifiListWidget::UpdateButtons() if (cursor < networks.size()) { const auto &info = networks[cursor]; - if (info.id >= 0) { - connect_button->SetCaption(_("Remove")); +// if (info.id >= 0) { + if (info.connected) { + // connect_button->SetCaption(_("Remove")); + connect_button->SetCaption(_("Disconnect")); connect_button->SetEnabled(true); } else if (info.signal_level >= 0) { connect_button->SetCaption(_("Connect")); @@ -175,63 +263,184 @@ WifiListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, "Open", }; -#ifdef WithWPA - row_renderer.DrawFirstRow(canvas, rc, info.ssid); - row_renderer.DrawSecondRow(canvas, rc, info.bssid); -#else - row_renderer.DrawFirstRow( - canvas, rc, UTF8ToWideConverter(info.ssid).c_str()); // TODO(August2111) - row_renderer.DrawSecondRow( - canvas, rc, UTF8ToWideConverter(info.bssid).c_str()); // TODO(August2111) -#endif // WithWPA + row_renderer.DrawFirstRow(canvas, rc, _W(info.ssid)); + row_renderer.DrawSecondRow(canvas, rc,_W(info.bssid)); const TCHAR *state = nullptr; StaticString<40> state_buffer; /* found the currently connected wifi network? */ - if (StringIsEqual(info.bssid, status.bssid)) { + if (StringIsEqual(info.bssid.c_str(), status.bssid.c_str())) { state = _("Connected"); /* look up ip address for wlan0 or eth0 */ -#ifdef WithWPA - const auto addr = IPv4Address::GetDeviceAddress(GetKoboWifiInterface()); +#ifdef _WIN32 + const auto addr = IPv4Address(192, 168, 0, 1, 0); + if (addr.IsDefined()) { /* valid address? */ + // StaticString<40> addr_str; + StaticString<40> addr_str; + addr_str = _T("192.186.0.1"); + state_buffer.Format(_T("%s (%s)"), state, addr_str.c_str()); + state = state_buffer; + } +#else + // const auto addr = IPv4Address::GetDeviceAddress(GetKoboWifiInterface()); + const auto addr = IPv4Address::GetDeviceAddress("wlan0"); if (addr.IsDefined()) { /* valid address? */ + // StaticString<40> addr_str; StaticString<40> addr_str; if (addr.ToString(addr_str.buffer(), addr_str.capacity()) != nullptr) { state_buffer.Format(_T("%s (%s)"), state, addr_str.c_str()); state = state_buffer; } } -#endif // WithWPA +#endif } +#if 0 else if (info.id >= 0) state = info.signal_level >= 0 ? _("Saved and visible") : _("Saved, but not visible"); else if (info.signal_level >= 0) state = _("Visible"); +#else + else if (info.connected) + state = _("Connected"); + else if (info.coupled) + state = _("Saved and visible"); + else if (info.enabled) + state = _("Saved, but not visible"); // ? + else + state = _("Visible"); +#endif if (state != nullptr) row_renderer.DrawRightFirstRow(canvas, rc, state); if (info.signal_level >= 0) { StaticString<32> text; - text.UnsafeFormat(_T("%s %u"), wifi_security[info.security], info.signal_level); + text.UnsafeFormat(_T("%s %u"), _W(wifi_security[info.security]), + info.signal_level); row_renderer.DrawRightSecondRow(canvas, rc, text); } } -// #endif -static void -WifiConnect(enum WifiSecurity security, WPASupplicant &wpa_supplicant, const char *ssid, const char *psk) +// TODO August2111: coming fro WPA-Sup..?? +// static +void WifiListWidget::WifiDisconnect( const char *ssid) { + auto network = FindVisibleBySSID(ssid); +// StaticString<0x100> base_id; +// base_id.Format(_T("wifi_%s_%s_managed_"), _W(network->mac_id.c_str()), +// _W(network->bssid.c_str())); +#if defined(IS_OPENVARIO_CB2) + // disconnect port + Run(Path(_T("wifi-disconnect.txt")), connmanctl, "disconnect", network->base_id.c_str()); +#endif + ShowMessageBox(_W(network->base_id.c_str()), _T("Disconnected"), MB_OK); +} + +void WifiListWidget::WifiConnect(enum WifiSecurity security, + // WPASupplicant &wpa_supplicant, + const char *ssid, const char *psk) { + { +// ShowMessageBox(_W(psk), _T("Wifi-Passphrase"), MB_OK); + + auto network = FindVisibleBySSID(ssid); + std::cout << "Test: " << 1 << std::endl; +// StaticString<0x100> base_id; +// base_id.Format(_T("wifi_%s_%s_managed_"), _W(network->mac_id.c_str()), +// _W(network->bssid.c_str())); + +// std::cout << "Test: " << 2 << std::endl; +// switch (network->security) { +// case WPA_SECURITY: +// base_id.append(_T("psk")); +// break; +// case WEP_SECURITY: +// base_id.append(_T("wep")); +// break; +// case OPEN_SECURITY: +// default: +// base_id.append(_T("none")); +// break; +// } + +#if 0 // content of 'settings' file: + [wifi_8c883b0078ce_537573616e6e65204361626c652047617374_managed_psk] + Name=Susanne Cable Gast + SSID=537573616e6e65204361626c652047617374 + Frequency=2412 + Favorite=true + AutoConnect=true + Modified=2024-01-31T13:55:30Z + Passphrase=LibeLLe7B + IPv4.method=dhcp + IPv4.DHCP.LastAddress=192.168.179.2 + IPv6.method=off + IPv6.privacy=disabled +#endif // WithWPA + StaticString<0x1000> buffer; + buffer.Format(_T("[%s]\n"), _W(network->base_id.c_str())); + buffer.AppendFormat(_T("Type=%s\n"), _W("wifi")); + buffer.AppendFormat(_T("Name=%s\n"), _W(ssid)); + buffer.AppendFormat(_T("SSID=%s\n"), + _W(network->bssid.c_str())); // _W(network->bssid); + buffer.AppendFormat(_T("Frequency=%d\n"), 2412); + // buffer.AppendFormat(_T("Favorite=true\n")); + buffer.append(_T("Favorite=true\n")); + buffer.append(_T("AutoConnect=true\n")); + buffer.AppendFormat(_T("Passphrase=%s\n"), _W(psk)); + // buffer.AppendFormat(_T("Modified=2024-02-01T12:38:31Z\n")); + buffer.AppendFormat(_T("IPv4.method=%s\n"), _T("dhcp")); + // buffer.AppendFormat(_T("IPv4.DHCP.LastAddress=192.168.178.32\n")); + buffer.append(_T("IPv6.method=off\n")); + buffer.append(_T("IPv6.privacy=disabled\n")); + std::cout << "Test: " << 6 << std::endl; + std::cout << _A(buffer.c_str()) << std::endl; + ShowMessageBox(buffer.c_str(), _T("WifiConnect"), MB_OK); + std::cout << "Test: " << 7 << std::endl; + + Path base_id(_W(network->base_id.c_str())); + +#if defined(IS_OPENVARIO_CB2) + // save on the connman setting location: + auto ssid_path = + AllocatedPath::Build(Path(_T("/var/lib/connman")), base_id); +#else + auto ssid_path = AllocatedPath::Build(ovdevice.GetDataPath(), + base_id); + ssid_path = AllocatedPath::Build(ssid_path, base_id); +#endif + auto setting_file = AllocatedPath::Build(ssid_path, Path(_T("settings"))); + if (File::Exists(setting_file)) + File::Delete(setting_file); + else + Directory::Create(ssid_path); + File::CreateExclusive(setting_file); + File::WriteExisting(setting_file, _A(buffer.c_str())); + +#if defined(IS_OPENVARIO_CB2) + // disable wifi + Run(Path(_T("wifi-disable.txt")), connmanctl, "disable", "wifi"); + // wait a second + std::this_thread::sleep_for(std::chrono::seconds(1)); + // enable wifi again for AutoConnect + Run(Path(_T("wifi-enable.txt")), connmanctl, "enable", "wifi"); + // wait a second after wifi enabling (?) + std::this_thread::sleep_for(std::chrono::seconds(1)); + // ask state of the wifi connection + Run(Path(_T("wifi-connect.txt")), connmanctl, "services", + network->base_id.c_str()); +#endif + } +#ifdef WithWPA const unsigned id = wpa_supplicant.AddNetwork(); char *endPsk_ptr; wpa_supplicant.SetNetworkSSID(id, ssid); if (security == WPA_SECURITY) { -#ifdef WithWPA std::array pmk; PKCS5_PBKDF2_HMAC_SHA1(psk, strlen(psk), (const unsigned char *)ssid, strlen(ssid), @@ -242,7 +451,6 @@ WifiConnect(enum WifiSecurity security, WPASupplicant &wpa_supplicant, const cha *HexFormat(hex.data(), pmk) = 0; wpa_supplicant.SetNetworkPSK(id, hex.data()); -#endif // WithWPA } else if (security == WEP_SECURITY) { wpa_supplicant.SetNetworkID(id, "key_mgmt", "NONE"); @@ -268,6 +476,7 @@ WifiConnect(enum WifiSecurity security, WPASupplicant &wpa_supplicant, const cha wpa_supplicant.EnableNetwork(id); wpa_supplicant.SaveConfig(); +#endif // WithWPA } inline void @@ -280,11 +489,14 @@ WifiListWidget::Connect() return; const auto &info = networks[i]; - if (info.id < 0) { +// if (info.id < 0) { + if (info.connected) { + WifiDisconnect(info.ssid); + } else { const auto ssid = info.ssid; StaticString<256> caption; - caption.Format(_("Passphrase of network '%s'"), ssid.c_str()); + caption.Format(_("Passphrase of network '%s'"), _W(ssid.c_str())); StaticString<32> passphrase; passphrase.clear(); @@ -293,15 +505,11 @@ WifiListWidget::Connect() else if (!TextEntryDialog(passphrase, caption, false)) return; -#ifdef WithWPA - WifiConnect(info.security, wpa_supplicant, info.ssid, passphrase); -#else // WithWPA - WifiConnect(info.security, wpa_supplicant, info.ssid, - "ConvertWideToUTF8(passphrase.c_str()).c_str()"); // TODO(August2111) -#endif // WithWPA - } else { - wpa_supplicant.RemoveNetwork(info.id); - wpa_supplicant.SaveConfig(); + WifiConnect(info.security, /* wpa_supplicant, */ info.ssid, + _A(passphrase.c_str())); +// } else { +// wpa_supplicant.RemoveNetwork(info.id); +// wpa_supplicant.SaveConfig(); } UpdateList(); @@ -312,49 +520,45 @@ WifiListWidget::EnsureConnected() { char path[64]; sprintf(path, "/var/run/wpa_supplicant/%s", GetKoboWifiInterface()); - wpa_supplicant.EnsureConnected(path); +// wpa_supplicant.EnsureConnected(path); } inline WifiListWidget::NetworkInfo * WifiListWidget::FindByID(int id) noexcept { -#ifdef WithWPA // TODO(August2111) - auto f = std::find_if(networks.begin(), networks.end() + auto f = std::find_if(networks.begin(), networks.end(), [id](const NetworkInfo &info) { return info.id == id; }); if (f == networks.end()) return nullptr; +#ifdef __MSVC__ + return &(*f); +#else return f; -#else // WithWPA - WifiListWidget::NetworkInfo f; - return &f; -#endif // WithWPA +#endif } WifiListWidget::NetworkInfo * WifiListWidget::FindByBSSID(const char *bssid) noexcept { -#ifdef WithWPA // TODO(August2111) auto f = std::find_if(networks.begin(), networks.end(), [bssid](const NetworkInfo &info) { return info.bssid == bssid; }); if (f == networks.end()) return nullptr; - +#ifdef __MSVC__ + return &(*f); +#else return f; -#else // WithWPA - WifiListWidget::NetworkInfo f; - return &f; -#endif // WithWPA +#endif } WifiListWidget::NetworkInfo * WifiListWidget::FindVisibleBySSID(const char *ssid) noexcept { -#ifdef WithWPA // TODO(August2111) auto f = std::find_if(networks.begin(), networks.end(), [ssid](const NetworkInfo &info) { return info.signal_level >= 0 && info.ssid == ssid; @@ -362,11 +566,11 @@ WifiListWidget::FindVisibleBySSID(const char *ssid) noexcept if (f == networks.end()) return nullptr; +#ifdef __MSVC__ + return &(*f); +#else return f; -#else // WithWPA - WifiListWidget::NetworkInfo f; - return &f; -#endif // WithWPA +#endif } inline void @@ -382,19 +586,150 @@ WifiListWidget::MergeList(const WifiVisibleNetwork *p, unsigned n) info->id = -1; } + info->mac_id = found.mac_id; info->ssid = found.ssid; info->signal_level = found.signal_level; + info->base_id = found.base_id; info->security = found.security; + info->enabled = found.enabled; + info->coupled = found.coupled; + info->connected = found.connected; info->old_visible = false; } + +#ifndef WithWPA + +#endif + + +} + +size_t +ParseConnmanScan(WifiVisibleNetwork *dest, BufferedReader &reader, + [[maybe_unused]] OperationEnvironment &env, size_t max) { + StringConverter string_converter; + + bool ignore = false; + const char *line; + size_t n = 0; + + // Iterate through the lines + while ((line = reader.ReadLine()) != nullptr) { + StripRight(line); + + // Skip empty line + if (StringIsEmpty(line)) + continue; + if (StringLength(line) < 4) + continue; + + auto info = &dest[n]; + std::string_view state{line, 4}; + line += 4; + auto pos = StringFind(line, " wifi_"); + if (pos == nullptr) + continue; + //------------------------------------- + std::string_view base_id{pos + 1}; + info->base_id = StripRight(base_id); + + info->enabled = state[0] == '*'; // '*' - 1st char + info->coupled = state[1] == 'A'; // 'A' - 2nd char + info->connected = state[2] == 'R'; // 'R' - 3rd char; + // SSID + if (pos - line > 2) { + std::string_view ssid{line, (size_t)(pos - line)}; + info->ssid = StripRight(ssid); + } + line = pos + StringLength(" wifi_"); + + pos = StringFind(line, "_"); + if (pos - line > 2) { + std::string_view bssid{line, (size_t)(pos - line)}; + info->bssid = StripRight(bssid); + std::string_view mac_id{line, (size_t)(pos - line)}; + info->mac_id = StripRight(mac_id); + } + line = pos +1; + + pos = StringFind(line, "_managed"); + if (pos - line > 2) { + std::string_view bssid{line, (size_t)(pos - line)}; + info->bssid = StripRight(bssid); + } + line = pos + StringLength("_managed") +1; + + info->signal_level = 1; // signal level not supported up to now ?-1; + + + if (line == "psk"sv) + info->security = WPA_SECURITY; + // info->security = OPEN_SECURITY; + else if (line == "wep"sv) + info->security = WEP_SECURITY; + else if (line == "open"sv) + info->security = OPEN_SECURITY; + + if (++n >= max) + break; + } + return n; +} + +static size_t +ParseConnmanScan(WifiVisibleNetwork *dest, Path path, + OperationEnvironment &env, size_t max) noexcept +try { + FileReader file_reader{path}; + ProgressReader progress_reader{file_reader, file_reader.GetSize(), env }; + BufferedReader buffered_reader{progress_reader}; + size_t n = 0; + try { + n = ParseConnmanScan(dest, buffered_reader, env, max); + } catch (...) { +// std::throw_with_nested(FmtRuntimeError("Error in file {}", path)); + } + + return n; +} catch (...) { + LogError(std::current_exception()); + // operation.SetError(std::current_exception()); + return 0; } +#ifndef WithWPA +unsigned +ScanResults(WifiVisibleNetwork *dest, unsigned max) +{ + const Path file = Path(_T("connman-scan-results.txt")); + if (File::Exists(file)) { + // ConsoleOperationEnvironment env; + NullOperationEnvironment env; + auto n = ParseConnmanScan(dest, file, env, max); + + auto file2 = Path(_T("connman-services.txt")); + if (File::Exists(file2)) + File::Delete(file2); + File::Rename(file, file2); + // File::Delete(file); + return n; + } else { + return 0; + } +} +#endif + inline void WifiListWidget::UpdateScanResults() { WifiVisibleNetwork *buffer = new WifiVisibleNetwork[networks.capacity()]; +#ifdef WithWPA int n = wpa_supplicant.ScanResults(buffer, networks.capacity()); +#else + auto n = ScanResults(buffer, networks.capacity()); +#endif + // int n = networks.capacity(); if (n >= 0) MergeList(buffer, n); @@ -447,7 +782,8 @@ WifiListWidget::UpdateConfigured() { WifiConfiguredNetworkInfo *buffer = new WifiConfiguredNetworkInfo[networks.capacity()]; - int n = wpa_supplicant.ListNetworks(buffer, networks.capacity()); + int n = 0; + //wpa_supplicant.ListNetworks(buffer, networks.capacity()); if (n >= 0) MergeList(buffer, n); @@ -481,27 +817,31 @@ WifiListWidget::SweepList() void WifiListWidget::UpdateList() { + // std::cout << "UpdateList!" << std::endl; status.Clear(); try { - EnsureConnected(); - wpa_supplicant.Status(status); +// WPA? EnsureConnected(); +// WPA? wpa_supplicant.Status(status); for (auto &i : networks) i.old_visible = i.old_configured = true; - UpdateScanResults(); - UpdateConfigured(); - +// WPA? + UpdateScanResults(); +// WPA? UpdateConfigured(); /* remove items that are still marked as "old" */ - SweepList(); + // but not without WPA SweepList(); + // std::cout << "After SweepList!" << std::endl; } catch (...) { networks.clear(); } GetList().SetLength(networks.size()); + // std::cout << "After GetList.SetLength!" << std::endl; UpdateButtons(); + // std::cout << "After UpdateButton!" << std::endl; } void From cdf2d43347d6b6612cdc06ea52ae49abb615f725 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 1 Feb 2024 14:38:45 +0100 Subject: [PATCH 170/403] [build] OpenVarioBaseMenu - add Operation (ConsoleEnvironment, NullOperationEnvironment) --- build/ov.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/ov.mk b/build/ov.mk index 965120093b2..2f759481557 100644 --- a/build/ov.mk +++ b/build/ov.mk @@ -242,9 +242,10 @@ OV_MENU_SOURCES = \ $(SRC)/event/Call.cxx \ $(SRC)/Math/FastTrig.cpp \ $(SRC)/ui/window/ContainerWindow.cpp \ + $(SRC)/Operation/Operation.cpp \ \ - +# $(SRC)/Operation/ConsoleOperationEnvironment.cpp OV_MENU_DEPENDS = WIDGET FORM DATA_FIELD SCREEN EVENT RESOURCE ASYNC LIBNET OS IO THREAD TIME MATH UTIL \ LANGUAGE \ From 5ecd98fcc0df374fed6ce1d9465389f51dced7ee Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 15 Apr 2024 11:17:02 +0200 Subject: [PATCH 171/403] [CMake] OpenVarioBaseMenu - add Operation (ConsoleEnvironment, NullOperationEnvironment) --- src/OpenVario/CMakeSource.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/OpenVario/CMakeSource.cmake b/src/OpenVario/CMakeSource.cmake index a64b3bed0b0..712719cc673 100644 --- a/src/OpenVario/CMakeSource.cmake +++ b/src/OpenVario/CMakeSource.cmake @@ -103,6 +103,9 @@ list(APPEND _SOURCES ${SRC}/Interface.cpp ${SRC}/Blackboard/InterfaceBlackboard.cpp + # ${SRC}/Operation/ConsoleOperationEnvironment.cpp + ${SRC}/Operation/Operation.cpp + ## ${SRC}/MainWindow.cpp ) set(SCRIPT_FILES From e9a897639dddebac7d103f392e70a647e72f137f Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 2 Feb 2024 07:59:05 +0100 Subject: [PATCH 172/403] [build] targets.mk - add target OPENVARIO to separate between a real HW device and the software simulation (OPENVARIO_CB2 vs. OPENVARIO) --- build/ov.mk | 5 ++++- build/targets.mk | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/build/ov.mk b/build/ov.mk index 2f759481557..4fecd7f1be4 100644 --- a/build/ov.mk +++ b/build/ov.mk @@ -8,7 +8,10 @@ ifeq ($(PROGRAM_VERSION),"") endif EXTRA_CPPFLAGS+= -DPROGRAM_VERSION=\"$(PROGRAM_VERSION)\" -EXTRA_CPPFLAGS+=-DIS_OPENVARIO +EXTRA_CPPFLAGS += -DIS_OPENVARIO +ifeq ($(TARGET_IS_OVDEVICE),y) + EXTRA_CPPFLAGS+= -DIS_OPENVARIO_CB2 +endif DIALOG_SOURCES = \ $(SRC)/Dialogs/Inflate.cpp \ diff --git a/build/targets.mk b/build/targets.mk index e157b0547ab..b96d11b7a5c 100644 --- a/build/targets.mk +++ b/build/targets.mk @@ -3,13 +3,13 @@ TARGETS = PC WIN64 \ WAYLAND \ FUZZER \ PI PI2 CUBIE KOBO NEON \ - OPENVARIO_CB2 \ + OPENVARIO OPENVARIO_CB2 \ ANDROID ANDROID7 ANDROID86 \ ANDROIDAARCH64 ANDROIDX64 \ ANDROIDFAT \ OSX64 IOS32 IOS64 -ifeq ($(TARGET),OPENVARIO_CB2) +ifeq ($(TARGET),OPENVARIO) # the OpenVario is a linux target # but has special functions, menus,... override TARGET = UNIX @@ -18,6 +18,17 @@ else TARGET_IS_OPENVARIO = n endif +ifeq ($(TARGET),OPENVARIO_CB2) + # the OpenVario is a linux target + # but has special functions, menus,... + # in difference to OPENVARIO it is really compiled for OpenVario device + override TARGET = UNIX + TARGET_IS_OPENVARIO = y + TARGET_IS_OVDEVICE = y +else + TARGET_IS_OVDEVICE = n +endif + ifeq ($(TARGET),) ifeq ($(HOST_IS_UNIX),y) @@ -437,6 +448,10 @@ ifeq ($(TARGET_IS_OPENVARIO),y) # TARGET_CPPFLAGS += -isystem /usr/include/dbus-1.0 -isystem /usr/lib/x86_64-linux-gnu/dbus-1.0/include endif +ifeq ($(TARGET_IS_OVDEVICE),y) + TARGET_CPPFLAGS += -DIS_OPENVARIO_CB2 +endif + ifeq ($(HAVE_MSVCRT),y) TARGET_CPPFLAGS += -DHAVE_MSVCRT TARGET_CPPFLAGS += -DUNICODE -D_UNICODE From 41b005779976951ddee6683f80ac55ddeabaadd0 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 1 Feb 2024 22:40:21 +0100 Subject: [PATCH 173/403] WifiSupplicantOV.hpp - extend strings von 32 chars to 64, add Mac_id to NetworkInfo --- src/OpenVario/System/WifiSupplicantOV.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/OpenVario/System/WifiSupplicantOV.hpp b/src/OpenVario/System/WifiSupplicantOV.hpp index 15bb6c61b32..87d0321d5d2 100644 --- a/src/OpenVario/System/WifiSupplicantOV.hpp +++ b/src/OpenVario/System/WifiSupplicantOV.hpp @@ -17,7 +17,7 @@ enum WifiSecurity { }; struct WifiStatus { - NarrowString<32> bssid; + NarrowString<64> bssid; NarrowString<256> ssid; void Clear() { @@ -27,7 +27,8 @@ struct WifiStatus { }; struct WifiVisibleNetwork { - NarrowString<32> bssid; + NarrowString<64> mac_id; + NarrowString<64> bssid; NarrowString<256> ssid; unsigned signal_level; enum WifiSecurity security; @@ -35,7 +36,7 @@ struct WifiVisibleNetwork { struct WifiConfiguredNetworkInfo { int id; - NarrowString<32> bssid; + NarrowString<64> bssid; NarrowString<256> ssid; }; From 3f77f1fe54fd2b64724004c568ea5d3bcbc49298 Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 2 Feb 2024 19:21:39 +0100 Subject: [PATCH 174/403] WifiSupplicantOV.hpp - add base_id to network --- src/OpenVario/System/WifiSupplicantOV.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/OpenVario/System/WifiSupplicantOV.hpp b/src/OpenVario/System/WifiSupplicantOV.hpp index 87d0321d5d2..4178479e73e 100644 --- a/src/OpenVario/System/WifiSupplicantOV.hpp +++ b/src/OpenVario/System/WifiSupplicantOV.hpp @@ -30,8 +30,13 @@ struct WifiVisibleNetwork { NarrowString<64> mac_id; NarrowString<64> bssid; NarrowString<256> ssid; + NarrowString<256> base_id; unsigned signal_level; enum WifiSecurity security; + + bool enabled = false; // '*' - 1st char + bool coupled = false; // 'A' - 2nd char + bool connected = false; // 'R' - 3rd char; }; struct WifiConfiguredNetworkInfo { From f3f681153f05f57ddf47af77f3f890366ca6a434 Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 2 Feb 2024 19:41:31 +0100 Subject: [PATCH 175/403] WifiSupplicantOV - remove supplicant code --- src/OpenVario/System/WifiSupplicantOV.cpp | 3 +++ src/OpenVario/System/WifiSupplicantOV.hpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/OpenVario/System/WifiSupplicantOV.cpp b/src/OpenVario/System/WifiSupplicantOV.cpp index 2cee67e2f61..73862dd8fd4 100644 --- a/src/OpenVario/System/WifiSupplicantOV.cpp +++ b/src/OpenVario/System/WifiSupplicantOV.cpp @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright The XCSoar Project +#if 0 #include "OpenVario/System/WifiSupplicantOV.hpp" #include "lib/fmt/ToBuffer.hxx" #include "lib/fmt/SystemError.hxx" @@ -379,3 +380,5 @@ WPASupplicant::ExpectLineTimeout(std::span buffer, int timeout_ms) result.remove_suffix(1); return result; } + +#endif \ No newline at end of file diff --git a/src/OpenVario/System/WifiSupplicantOV.hpp b/src/OpenVario/System/WifiSupplicantOV.hpp index 4178479e73e..91a4e22d143 100644 --- a/src/OpenVario/System/WifiSupplicantOV.hpp +++ b/src/OpenVario/System/WifiSupplicantOV.hpp @@ -45,6 +45,7 @@ struct WifiConfiguredNetworkInfo { NarrowString<256> ssid; }; +#if 0 /** * All methods that are not `noexcept` throw on error. */ @@ -139,3 +140,5 @@ class WPASupplicant { std::string_view ExpectLineTimeout(std::span buffer, int timeout_ms=2000); }; + +#endif \ No newline at end of file From ab16d8586b0c2846a6957bcc180c9cfc2ec8f756 Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 2 Feb 2024 08:11:17 +0100 Subject: [PATCH 176/403] OpenVarioDevice.hpp - disable DBUS access for sensord, variod in normal Linux --- src/OpenVario/System/OpenVarioDevice.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/OpenVario/System/OpenVarioDevice.hpp b/src/OpenVario/System/OpenVarioDevice.hpp index 7c373fafa9a..018cedf3cf4 100644 --- a/src/OpenVario/System/OpenVarioDevice.hpp +++ b/src/OpenVario/System/OpenVarioDevice.hpp @@ -22,13 +22,14 @@ #define DEBUG_OPENVARIO 1 -#if __GNUC__ && __has_include("dbus/dbus.h") +#if defined(IS_OPENVARIO_CB2) + // && __has_include("dbus/dbus.h") # define DBUS_FUNCTIONS 1 # warning (Attention: DBUS is enabled) #elif __GNUC__ -# warning (Attention: No DBUS!) +// # warning (Attention: No DBUS!) #else -#pragma message("Attention: No DBUS!") +// #pragma message("Attention: No DBUS!") #endif enum class SSHStatus { From 18f9bc8eecb067a5dfc79d08b4349fbd4734e07f Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 2 Feb 2024 14:16:13 +0100 Subject: [PATCH 177/403] OpenVario/OpenVarioBaseMenu.cpp - add a separator at end of datapath --- src/OpenVario/OpenVarioBaseMenu.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/OpenVario/OpenVarioBaseMenu.cpp b/src/OpenVario/OpenVarioBaseMenu.cpp index 025ede3eb0b..605a2e91bf7 100644 --- a/src/OpenVario/OpenVarioBaseMenu.cpp +++ b/src/OpenVario/OpenVarioBaseMenu.cpp @@ -208,6 +208,7 @@ void MainMenuWidget::StartSoarExe(std::string_view _exe, _datapath = GetPrimaryDataPath().c_str(); } else { datapath.append(_datapath.generic_string()); + datapath.append("/"); // last delimiter } if (!datapath.empty()) ArgList.push_back(datapath.c_str()); From f8b82b172b4c4bb5cd4dd0a1301f6729e6bf27e1 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sun, 4 Feb 2024 20:07:33 +0100 Subject: [PATCH 178/403] [CMake] add Process.cpp for alignment OpenVarioMenu w/ OpenVarioBaseMenu --- src/Dialogs/CMakeSource.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Dialogs/CMakeSource.cmake b/src/Dialogs/CMakeSource.cmake index d3d4c6450f9..35fae07a483 100644 --- a/src/Dialogs/CMakeSource.cmake +++ b/src/Dialogs/CMakeSource.cmake @@ -171,6 +171,7 @@ if(ON) # IS_OPENVARIO ../OpenVario/System/WifiDialogOV.cpp ../OpenVario/System/WifiSupplicantOV.cpp + Dialogs/ProcessDialog.cpp ) endif() From 22435a6d31d66ec158f6315385ef7893163f5868 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 5 Feb 2024 23:22:39 +0100 Subject: [PATCH 179/403] .gitignore - add /src/OpenVario/_DustBin --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d8a9b6e41f7..c21af01bd46 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,4 @@ build/local-config.mk .idea /VERSION.txt +/src/OpenVario/_DustBin From 1cede876b1039c02ed84bf7e72017caa2c616d52 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 8 Feb 2024 11:28:56 +0100 Subject: [PATCH 180/403] Dialogs/Settings/dlgConfiguration.cpp - add the same pages like OpenVarioBaseMenu --- src/Dialogs/Settings/dlgConfiguration.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Dialogs/Settings/dlgConfiguration.cpp b/src/Dialogs/Settings/dlgConfiguration.cpp index 55be938804f..2b25ff35493 100644 --- a/src/Dialogs/Settings/dlgConfiguration.cpp +++ b/src/Dialogs/Settings/dlgConfiguration.cpp @@ -65,7 +65,11 @@ #include "Panels/WeGlideConfigPanel.hpp" #if defined(IS_OPENVARIO) +#include "OpenVario/FileMenuWidget.hpp" #include "OpenVario/SystemSettingsWidget.hpp" +#include "OpenVario/System/SystemMenuWidget.hpp" +#include "OpenVario/DisplaySettingsWidget.hpp" +#include "OpenVario/ExtraWidget.hpp" #include "OpenVario/System/OpenVarioDevice.hpp" #endif @@ -146,7 +150,11 @@ static constexpr TabMenuPage setup_pages[] = { #ifdef IS_OPENVARIO static constexpr TabMenuPage openvario_pages[] = { - {N_("OpenVario System Settings"), CreateSystemSettingsWidget}, + {N_("System Settings"), CreateSystemSettingsWidget}, + {N_("Display Settings"), CreateDisplaySettingsWidget}, + {N_("File Transfer"), CreateFileMenuWidget}, + {N_("Advanced Menu (temp)"), CreateExtraWidget}, + {N_("Advanced Settings (temp)"), CreateSystemMenuWidget}, { nullptr, nullptr } }; #endif From 610f45226edd1d4ab51035d9edd9eab7142bb1e7 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 8 Feb 2024 11:33:05 +0100 Subject: [PATCH 181/403] Dialogs/Settings/dlgConfiguration.cpp - close executable in case of push an exit command --- src/Dialogs/Settings/dlgConfiguration.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Dialogs/Settings/dlgConfiguration.cpp b/src/Dialogs/Settings/dlgConfiguration.cpp index 2b25ff35493..5ac2402a87e 100644 --- a/src/Dialogs/Settings/dlgConfiguration.cpp +++ b/src/Dialogs/Settings/dlgConfiguration.cpp @@ -71,6 +71,7 @@ #include "OpenVario/DisplaySettingsWidget.hpp" #include "OpenVario/ExtraWidget.hpp" #include "OpenVario/System/OpenVarioDevice.hpp" +#include "UIActions.hpp" #endif #include @@ -269,6 +270,20 @@ class ConfigurationExtraButtons final expert.FastHide(); button2.FastHide(); button1.FastHide(); + #ifdef IS_OPENVARIO + // this is a workaround: the 1st SignalShutdown closed the Setup window + // the 2nd one here close the executable + // a directly exit isn't possible + switch (ContainerWindow::GetExitValue()) { + case LAUNCH_SHELL: // 100, + case START_UPGRADE: // 111 + case LAUNCH_TOUCH_CALIBRATE: // 112, + UIActions::SignalShutdown(true); + break; + default: + break; + } + #endif } void Move(const PixelRect &rc) noexcept override { From f469b124999fbe95568678771fdadcbf6669d4b4 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 8 Feb 2024 11:40:15 +0100 Subject: [PATCH 182/403] OpenVario - reorganizing menu pages for doubled use in OpenSoar and OVBaseMenu --- src/OpenVario/DisplaySettingsWidget.cpp | 80 ++++++---------- src/OpenVario/DisplaySettingsWidget.hpp | 31 ++---- src/OpenVario/FileMenuWidget.cpp | 47 ++++++++- src/OpenVario/FileMenuWidget.h | 27 ------ src/OpenVario/FileMenuWidget.hpp | 20 ++++ src/OpenVario/OpenVarioBaseMenu.cpp | 43 +++------ .../System/Setting/RotationWidget.cpp | 32 +++++++ .../System/Setting/RotationWidget.hpp | 27 ++---- src/OpenVario/System/SystemMenuWidget.cpp | 95 ++++++++++++------- src/OpenVario/System/SystemMenuWidget.hpp | 32 +++---- src/OpenVario/SystemSettingsWidget.cpp | 26 +++-- src/OpenVario/SystemSettingsWidget.hpp | 29 +----- 12 files changed, 244 insertions(+), 245 deletions(-) delete mode 100644 src/OpenVario/FileMenuWidget.h create mode 100644 src/OpenVario/FileMenuWidget.hpp diff --git a/src/OpenVario/DisplaySettingsWidget.cpp b/src/OpenVario/DisplaySettingsWidget.cpp index 0d76564bb62..34a281b95cf 100644 --- a/src/OpenVario/DisplaySettingsWidget.cpp +++ b/src/OpenVario/DisplaySettingsWidget.cpp @@ -41,67 +41,45 @@ #include #include +class DisplaySettingsWidget final : public RowFormWidget { +public: + DisplaySettingsWidget() noexcept + : RowFormWidget(UIGlobals::GetDialogLook()) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept override; +}; + void DisplaySettingsWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { AddButton(_("Screen Rotation"), [this](){ - TWidgetDialog - sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), - GetLook(), _T("Display Rotation Settings")); - sub_dialog.SetWidget(display, event_queue, GetLook()); - sub_dialog.AddButton(_("Close"), mrOK); - return sub_dialog.ShowModal(); + return ShowRotationSettingsWidget(UIGlobals::GetMainWindow(), GetLook()); }); -// AddButton(_("Setting Brightness"), [this](){ -// TWidgetDialog -// sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), -// GetLook(), _T("Display Brightness Settings")); -// sub_dialog.SetWidget(display, event_queue, GetLook()); -// sub_dialog.AddButton(_("Close"), mrOK); -// return sub_dialog.ShowModal(); -// }); -// +// AddButton(_("Setting Brightness"), [this](){ +// return ShowSettingBrightnessWidget(UIGlobals::GetMainWindow(), GetLook()); +// }); + // uint32_t iTest = 0; // AddInteger(_("Brightness Test"), _("Setting Brightness."), _T("%d"), _T("%d"), 1, // 10, 1, iTest); +} - -// AddButton(_("Autostart Timeout"), [this](){ -// TWidgetDialog -// sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), -// GetLook(), _T("Autostart Timeout")); -// sub_dialog.SetWidget(display, event_queue, GetLook()); -// sub_dialog.AddButton(_("Close"), mrOK); -// return sub_dialog.ShowModal(); -// }); - -// AddButton(_("SSH"), [this](){ -// TWidgetDialog -// sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), -// GetLook(), _T("Enable or Disable SSH")); -// sub_dialog.SetWidget(display, event_queue, GetLook()); -// sub_dialog.AddButton(_("Close"), mrOK); -// return sub_dialog.ShowModal(); -// }); -// -// AddButton(_("Variod"), [this](){ -// TWidgetDialog -// sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), -// GetLook(), _T("Enable or Disable Variod")); -// sub_dialog.SetWidget(display, event_queue, GetLook()); -// sub_dialog.AddButton(_("Close"), mrOK); -// return sub_dialog.ShowModal(); -// }); -// -// AddButton(_("Sensord"), [this](){ -// TWidgetDialog -// sub_dialog(WidgetDialog::Full{}, dialog.GetMainWindow(), -// GetLook(), _T("Enable or Disable Sensord")); -// sub_dialog.SetWidget(display, event_queue, GetLook()); -// sub_dialog.AddButton(_("Close"), mrOK); -// return sub_dialog.ShowModal(); -// }); +bool +ShowDisplaySettingsWidget(ContainerWindow &parent, + const DialogLook &look) noexcept { + TWidgetDialog sub_dialog( + WidgetDialog::Full{}, (UI::SingleWindow &)parent, look, + _T("OpenVario Display Settings")); + sub_dialog.SetWidget(); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); } +std::unique_ptr +CreateDisplaySettingsWidget() noexcept { + return std::make_unique(); +} diff --git a/src/OpenVario/DisplaySettingsWidget.hpp b/src/OpenVario/DisplaySettingsWidget.hpp index 2ffbf2adb6e..cf763ee1366 100644 --- a/src/OpenVario/DisplaySettingsWidget.hpp +++ b/src/OpenVario/DisplaySettingsWidget.hpp @@ -3,28 +3,17 @@ #pragma once -#include "Widget/RowFormWidget.hpp" -#include "ui/event/Queue.hpp" -#include "ui/window/SingleWindow.hpp" +#ifdef IS_OPENVARIO -class DisplaySettingsWidget final - : public RowFormWidget -{ - UI::Display &display; - UI::EventQueue &event_queue; +#include - WndForm &dialog; +class Widget; +class ContainerWindow; +class DialogLook; -public: - DisplaySettingsWidget(UI::Display &_display, UI::EventQueue &_event_queue, - WndForm &_dialog) noexcept - :RowFormWidget(_dialog.GetLook()), - display(_display), event_queue(_event_queue), - dialog(_dialog) {} - -private: - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, - const PixelRect &rc) noexcept override; -}; +bool ShowDisplaySettingsWidget(ContainerWindow &parent, + const DialogLook &look) noexcept; +std::unique_ptr +CreateDisplaySettingsWidget() noexcept; +#endif \ No newline at end of file diff --git a/src/OpenVario/FileMenuWidget.cpp b/src/OpenVario/FileMenuWidget.cpp index 865d5fd2b17..19f3ec0e10d 100644 --- a/src/OpenVario/FileMenuWidget.cpp +++ b/src/OpenVario/FileMenuWidget.cpp @@ -1,9 +1,21 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright The XCSoar Project -#include "FileMenuWidget.h" + +#ifdef IS_OPENVARIO + +#include "FileMenuWidget.hpp" #include "Dialogs/ProcessDialog.hpp" +#include "Dialogs/WidgetDialog.hpp" +#include "Form/Form.hpp" #include "Hardware/DisplayGlue.hpp" +#include "Hardware/RotateDisplay.hpp" #include "Language/Language.hpp" +#include "Widget/RowFormWidget.hpp" + +#include "UIGlobals.hpp" + +// #include "ui/event/Globals.hpp" +// #include "ui/display/Display.hpp" #include #include @@ -13,8 +25,16 @@ constexpr const TCHAR *xcsoar = _T("XCSoar"); constexpr const TCHAR *main_app = opensoar; constexpr const char *_main_app = "OpenSoar"; // only temporarily - void -FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, +class FileMenuWidget final : public RowFormWidget { +public: + FileMenuWidget() noexcept : RowFormWidget(UIGlobals::GetDialogLook()) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept override; +}; + +void FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { StaticString<60> title; @@ -70,10 +90,27 @@ FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, static constexpr const char *argv[] = {"/usr/bin/transfer-system.sh", "restore", _main_app, nullptr }; - RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), _("Restore System"), argv); Display::Rotate(Display::DetectInitialOrientation()); }); -} \ No newline at end of file +} + +bool +ShowFileMenuWidget(ContainerWindow &parent, + const DialogLook &look) noexcept +{ + TWidgetDialog sub_dialog( + WidgetDialog::Full{}, (UI::SingleWindow &)parent, look, + _("OpenVario File Transfers")); + sub_dialog.SetWidget(); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); +} + +std::unique_ptr +CreateFileMenuWidget() noexcept { + return std::make_unique(); +} +#endif diff --git a/src/OpenVario/FileMenuWidget.h b/src/OpenVario/FileMenuWidget.h deleted file mode 100644 index b463275c6b8..00000000000 --- a/src/OpenVario/FileMenuWidget.h +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -// Copyright The XCSoar Project -#pragma once -#include "UIGlobals.hpp" -#include "ui/event/Globals.hpp" -#include "ui/display/Display.hpp" -#include "Widget/RowFormWidget.hpp" -#include "Hardware/RotateDisplay.hpp" - -class FileMenuWidget final - : public RowFormWidget -{ - UI::Display &display; - UI::EventQueue &event_queue; - -public: - FileMenuWidget(UI::Display &_display, UI::EventQueue &_event_queue, - const DialogLook &look) noexcept - :RowFormWidget(look), - display(_display), event_queue(_event_queue) {} - -private: - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, - const PixelRect &rc) noexcept override; - -}; diff --git a/src/OpenVario/FileMenuWidget.hpp b/src/OpenVario/FileMenuWidget.hpp new file mode 100644 index 00000000000..cc68a5243bd --- /dev/null +++ b/src/OpenVario/FileMenuWidget.hpp @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project +#pragma once + +#ifdef IS_OPENVARIO + +#include + +class Widget; +class ContainerWindow; +struct DialogLook; + +bool +ShowFileMenuWidget(ContainerWindow &parent, + const DialogLook &look) noexcept; + +std::unique_ptr +CreateFileMenuWidget() noexcept; + +#endif \ No newline at end of file diff --git a/src/OpenVario/OpenVarioBaseMenu.cpp b/src/OpenVario/OpenVarioBaseMenu.cpp index 605a2e91bf7..4196b1e015a 100644 --- a/src/OpenVario/OpenVarioBaseMenu.cpp +++ b/src/OpenVario/OpenVarioBaseMenu.cpp @@ -25,7 +25,7 @@ #include "Hardware/RotateDisplay.hpp" #include "util/StaticString.hxx" -#include "OpenVario/FileMenuWidget.h" +#include "OpenVario/FileMenuWidget.hpp" #include "OpenVario/DisplaySettingsWidget.hpp" #include "OpenVario/SystemSettingsWidget.hpp" @@ -273,47 +273,30 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, AddButton(_("File Transfers"), [this]() { CancelTimer(); - - TWidgetDialog sub_dialog(WidgetDialog::Full{}, - dialog.GetMainWindow(), GetLook(), - _T("OpenVario File Transfers")); - sub_dialog.SetWidget(display, event_queue, GetLook()); - sub_dialog.AddButton(_("Close"), mrOK); - return sub_dialog.ShowModal(); + return ShowFileMenuWidget(UIGlobals::GetMainWindow(), GetLook()); }); AddButton(_("Display Settings"), [this]() { CancelTimer(); - - TWidgetDialog sub_dialog( - WidgetDialog::Full{}, dialog.GetMainWindow(), GetLook(), - _T("OpenVario Display Settings")); - sub_dialog.SetWidget(display, event_queue, sub_dialog); - sub_dialog.AddButton(_("Close"), mrOK); - return sub_dialog.ShowModal(); + return ShowDisplaySettingsWidget(UIGlobals::GetMainWindow(), GetLook()); }); AddButton(_("System Settings"), [this]() { CancelTimer(); - - std::unique_ptr widget = CreateSystemSettingsWidget(); - TWidgetDialog sub_dialog( - WidgetDialog::Full{}, dialog.GetMainWindow(), GetLook(), - _T("OpenVario System Settings")); - sub_dialog.SetWidget(); - sub_dialog.AddButton(_("Close"), mrOK); - return sub_dialog.ShowModal(); + return ShowSystemSettingsWidget(UIGlobals::GetMainWindow(), GetLook()); }); AddButton(_("OpenVario Placeholder"), [this]() { CancelTimer(); - - TWidgetDialog sub_dialog( - WidgetDialog::Full{}, dialog.GetMainWindow(), GetLook(), - _T("OpenVario Placeholder Settings")); - sub_dialog.SetWidget(display, event_queue, sub_dialog); - sub_dialog.AddButton(_("Close"), mrOK); - return sub_dialog.ShowModal(); + return ShowSystemMenuWidget(UIGlobals::GetMainWindow(), GetLook()); + +// TWidgetDialog sub_dialog( +// WidgetDialog::Full{}, UIGlobals::GetMainWindow(), GetLook(), +// _T("OpenVario Placeholder Settings")); +// sub_dialog.SetWidget(display, event_queue, sub_dialog); +// // sub_dialog.SetWidget(); +// sub_dialog.AddButton(_("Close"), mrOK); +// return sub_dialog.ShowModal(); }); //---------------------------------------------------------- diff --git a/src/OpenVario/System/Setting/RotationWidget.cpp b/src/OpenVario/System/Setting/RotationWidget.cpp index e712fb8d226..8c22373408a 100644 --- a/src/OpenVario/System/Setting/RotationWidget.cpp +++ b/src/OpenVario/System/Setting/RotationWidget.cpp @@ -27,6 +27,9 @@ #include "io/BufferedOutputStream.hxx" #include "io/FileLineReader.hpp" +#include "Widget/RowFormWidget.hpp" + + #include "OpenVario/System/OpenVarioDevice.hpp" #include "OpenVario/System/Setting/RotationWidget.hpp" @@ -45,6 +48,19 @@ /* x-menu writes the value for the display rotation to /sys because the value is also required for the console in the OpenVario. In addition, the display rotation is saved in /boot/config.uEnv so that the Openvario sets the correct rotation again when it is restarted.*/ + +class SettingRotationWidget final : public RowFormWidget { + +public: + SettingRotationWidget() noexcept + : RowFormWidget(UIGlobals::GetDialogLook()) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept override; + void SaveRotation(const std::string &rotationvalue); +}; + void SettingRotationWidget::SaveRotation(const std::string &rotationString) { @@ -83,3 +99,19 @@ SettingRotationWidget::Prepare([[maybe_unused]] ContainerWindow &parent, }); } +bool +ShowRotationSettingsWidget(ContainerWindow &parent, + const DialogLook &look) noexcept { + TWidgetDialog sub_dialog( + WidgetDialog::Full{}, (UI::SingleWindow &)parent, look, + _T("OpenVario Rotation Settings")); + sub_dialog.SetWidget(); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); +} + +// std::unique_ptr +// CreateSettingRotationWidget() noexcept +// { +// return std::make_unique(); +// } diff --git a/src/OpenVario/System/Setting/RotationWidget.hpp b/src/OpenVario/System/Setting/RotationWidget.hpp index 4655ade52d7..11631f9c982 100644 --- a/src/OpenVario/System/Setting/RotationWidget.hpp +++ b/src/OpenVario/System/Setting/RotationWidget.hpp @@ -3,26 +3,15 @@ #pragma once -#include "Widget/RowFormWidget.hpp" -#include "ui/event/Queue.hpp" -#include "ui/window/SingleWindow.hpp" +#include -class SettingRotationWidget final - : public RowFormWidget -{ - UI::Display &display; - UI::EventQueue &event_queue; +// class Widget; +class ContainerWindow; +class DialogLook; -public: - SettingRotationWidget(UI::Display &_display, UI::EventQueue &_event_queue, - const DialogLook &look) noexcept - :RowFormWidget(look), - display(_display), event_queue(_event_queue) {} +bool +ShowRotationSettingsWidget(ContainerWindow &parent, + const DialogLook &look) noexcept; -private: - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, - const PixelRect &rc) noexcept override; - void SaveRotation(const std::string &rotationvalue); -}; +// std::unique_ptr CreateSettingRotationWidget() noexcept; diff --git a/src/OpenVario/System/SystemMenuWidget.cpp b/src/OpenVario/System/SystemMenuWidget.cpp index f71dae8efc8..6b6704e6bfc 100644 --- a/src/OpenVario/System/SystemMenuWidget.cpp +++ b/src/OpenVario/System/SystemMenuWidget.cpp @@ -1,3 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project + +#ifdef IS_OPENVARIO +// don't use (and compile) this code outside an OpenVario project! #include "Dialogs/DialogSettings.hpp" #include "Dialogs/Message.hpp" @@ -14,6 +19,8 @@ #include "UIGlobals.hpp" #include "system/FileUtil.hpp" +#include "Widget/RowFormWidget.hpp" + #if !defined(_WIN32) # include "system/Process.hpp" #endif @@ -32,7 +39,17 @@ #include #include -// void +class SystemMenuWidget final : public RowFormWidget { +public: + SystemMenuWidget() noexcept : RowFormWidget(UIGlobals::GetDialogLook()) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept override; + // void CalibrateSensors() noexcept; +}; + +// void // SystemMenuWidget::CalibrateSensors() noexcept static void CalibrateSensors() noexcept @@ -98,13 +115,9 @@ CalibrateSensors() noexcept //----------------------------------------------------------------------------- class ScreenSSHWidget final : public RowFormWidget { - UI::Display &display; - UI::EventQueue &event_queue; public: - ScreenSSHWidget(UI::Display &_display, UI::EventQueue &_event_queue, - const DialogLook &look) noexcept - : RowFormWidget(look), display(_display), event_queue(_event_queue) {} + ScreenSSHWidget() noexcept : RowFormWidget(UIGlobals::GetDialogLook()) {} private: /* virtual methods from class Widget */ @@ -184,28 +197,19 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, exit(START_UPGRADE); }); +#if 1 + // the variant with command line... + // UI::SingleWindow main_window = AddButton(_T("SSH"), [this]() { TWidgetDialog sub_dialog(WidgetDialog::Full{}, - dialog.GetMainWindow(), GetLook(), + // dialog.GetMainWindow(), GetLook(), + UIGlobals::GetMainWindow(), GetLook(), _T("Enable or Disable SSH")); - sub_dialog.SetWidget(display, event_queue, GetLook()); + sub_dialog.SetWidget(); sub_dialog.AddButton(_("Close"), mrOK); return sub_dialog.ShowModal(); }); - - AddButton(_("WiFi Settings"), []() { - static constexpr const char *argv[] = { - "/bin/sh", "-c", - "printf '\\nWiFi-Settings are not implemented, yet!! \\n\\nIf you are " - "interessted to help with this, write me an email: dirk@freevario.de'", - nullptr - }; - - RunProcessDialog(UIGlobals::GetMainWindow(), - UIGlobals::GetDialogLook(), - _T("WiFi Settings"), argv); - }); - +#endif AddButton(_("Update System"), [](){ static constexpr const char *argv[] = { @@ -218,11 +222,20 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, }); AddButton(_("Calibrate Sensors"), CalibrateSensors); - AddButton(_("Calibrate Touch"), [this](){ - const UI::ScopeDropMaster drop_master{display}; - const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; -#if !defined(_WIN32) - // RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), + + AddButton(_("Calibrate Touch"), [this]() { +#if defined(_WIN32) + static constexpr const char *argv[] = { "/usr/bin/ov-calibrate-ts.sh", + nullptr}; + + RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), + _T("Calibrate Touch"), argv); +#else +// const UI::ScopeDropMaster drop_master{display}; +// const UI::ScopeSuspendEventQueue + // suspend_event_queue{event_queue}; + // RunProcessDialog(UIGlobals::GetMainWindow(), + // UIGlobals::GetDialogLook(), // _T("System Info"), "/usr/bin/ov-calibrate-ts.sh"); Run("/usr/bin/ov-calibrate-ts.sh"); #endif @@ -237,14 +250,13 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, UIGlobals::GetDialogLook(), _T("System Info"), argv); }); - AddButton(_("Test-Process"), []() { - static constexpr const char *argv[] = { - "/bin/ls", nullptr - }; + + AddButton(_("List Dir"), []() { + static constexpr const char *argv[] = {"/bin/ls", "-l", nullptr}; RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T("Test-Process"), argv); + _T("List Dir"), argv); }); AddButton(_("Test-Process 2"), [this]() { @@ -266,3 +278,22 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, }); } +bool +ShowSystemMenuWidget(ContainerWindow &parent, + const DialogLook &look) noexcept +{ + TWidgetDialog sub_dialog( + WidgetDialog::Full{}, (UI::SingleWindow &) parent, look, + _T("OpenVario System Menu")); + sub_dialog.SetWidget(); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); +} + +std::unique_ptr +CreateSystemMenuWidget() noexcept +{ + return std::make_unique(); +} + +#endif diff --git a/src/OpenVario/System/SystemMenuWidget.hpp b/src/OpenVario/System/SystemMenuWidget.hpp index d86c733123e..ac7ac378692 100644 --- a/src/OpenVario/System/SystemMenuWidget.hpp +++ b/src/OpenVario/System/SystemMenuWidget.hpp @@ -5,28 +5,18 @@ #define OV_SETTINGS 0 -#include "Widget/RowFormWidget.hpp" -#include "ui/event/Queue.hpp" -#include "ui/window/SingleWindow.hpp" +#ifdef IS_OPENVARIO -class SystemMenuWidget final - : public RowFormWidget -{ - UI::Display &display; - UI::EventQueue &event_queue; +#include - WndForm &dialog; +class Widget; +class ContainerWindow; +struct DialogLook; -public: - SystemMenuWidget(UI::Display &_display, UI::EventQueue &_event_queue, - WndForm &_dialog) noexcept - :RowFormWidget(_dialog.GetLook()), - display(_display), event_queue(_event_queue), - dialog(_dialog) {} +bool +ShowSystemMenuWidget(ContainerWindow &parent, + const DialogLook &look) noexcept; -private: - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, - const PixelRect &rc) noexcept override; - // void CalibrateSensors() noexcept; -}; +std::unique_ptr +CreateSystemMenuWidget() noexcept; +#endif \ No newline at end of file diff --git a/src/OpenVario/SystemSettingsWidget.cpp b/src/OpenVario/SystemSettingsWidget.cpp index 976af3938f0..54343844938 100644 --- a/src/OpenVario/SystemSettingsWidget.cpp +++ b/src/OpenVario/SystemSettingsWidget.cpp @@ -10,7 +10,6 @@ #include "Look/DialogLook.hpp" #include "Language/Language.hpp" -#include "Widget/RowFormWidget.hpp" #include "Form/DataField/Boolean.hpp" #include "Form/DataField/Listener.hpp" #include "Form/DataField/Enum.hpp" @@ -44,12 +43,12 @@ enum ControlIndex { }; -#if 0 -class SystemSettingsWidget final - : public RowFormWidget, DataFieldListener { +#if 1 +#include "UIGlobals.hpp" +// ------------------------------------------- +class SystemSettingsWidget final : public RowFormWidget, DataFieldListener { public: - SystemSettingsWidget() noexcept - :RowFormWidget(UIGlobals::GetDialogLook()) {} + SystemSettingsWidget() noexcept : RowFormWidget(UIGlobals::GetDialogLook()) {} void SetEnabled(bool enabled) noexcept; @@ -57,7 +56,7 @@ class SystemSettingsWidget final void Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept override; bool Save(bool &changed) noexcept override; - int OnShow(const UI::SingleWindow &parent) noexcept; + // int OnShow(const UI::SingleWindow &parent) noexcept; private: /* methods from DataFieldListener */ @@ -205,19 +204,16 @@ SystemSettingsWidget::Save([[maybe_unused]] bool &_changed) noexcept return true; } -int -SystemSettingsWidget::OnShow([[maybe_unused]] const UI::SingleWindow &parent) - noexcept { -#if 0 +bool +ShowSystemSettingsWidget(ContainerWindow &parent, + const DialogLook &look) noexcept +{ TWidgetDialog sub_dialog( - WidgetDialog::Full{}, parent, GetLook(), + WidgetDialog::Full{}, (UI::SingleWindow &) parent, look, _T("OpenVario System Settings")); sub_dialog.SetWidget(); sub_dialog.AddButton(_("Close"), mrOK); return sub_dialog.ShowModal(); -#else - return 0; -#endif } std::unique_ptr diff --git a/src/OpenVario/SystemSettingsWidget.hpp b/src/OpenVario/SystemSettingsWidget.hpp index 00a407abf10..07e7dae42fc 100644 --- a/src/OpenVario/SystemSettingsWidget.hpp +++ b/src/OpenVario/SystemSettingsWidget.hpp @@ -5,35 +5,16 @@ #ifdef IS_OPENVARIO -#include "Form/DataField/Listener.hpp" -#include "Widget/RowFormWidget.hpp" - - #include class Widget; +class ContainerWindow; +struct DialogLook; -#if 1 -#include "UIGlobals.hpp" -// ------------------------------------------- -class SystemSettingsWidget final : public RowFormWidget, DataFieldListener { -public: - SystemSettingsWidget() noexcept : RowFormWidget(UIGlobals::GetDialogLook()) {} - - void SetEnabled(bool enabled) noexcept; - - /* virtual methods from class Widget */ - void Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept override; - bool Save(bool &changed) noexcept override; - - int OnShow(const UI::SingleWindow &parent) noexcept; +bool +ShowSystemSettingsWidget(ContainerWindow &parent, + const DialogLook &look) noexcept; -private: - /* methods from DataFieldListener */ - void OnModified(DataField &df) noexcept override; -}; -// --------------------------------------------- -#endif std::unique_ptr CreateSystemSettingsWidget() noexcept; From 2202b3314a6620158acddfe7ae19856fac2c20c7 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 5 Feb 2024 17:14:01 +0100 Subject: [PATCH 183/403] Driver/Larus.cpp - extend with bidirectional settings parameters $PLARS --- src/Device/Driver/Larus.cpp | 148 ++++++++++++++++++++++++++++++++++-- 1 file changed, 143 insertions(+), 5 deletions(-) diff --git a/src/Device/Driver/Larus.cpp b/src/Device/Driver/Larus.cpp index 8d997b2fb78..9678f2dde89 100644 --- a/src/Device/Driver/Larus.cpp +++ b/src/Device/Driver/Larus.cpp @@ -30,6 +30,7 @@ Copyright_License { #include "Device/Driver/Larus.hpp" #include "Device/Driver.hpp" +#include "Device/Port/Port.hpp" #include "Device/Util/NMEAWriter.hpp" #include "NMEA/Checksum.hpp" #include "NMEA/Info.hpp" @@ -38,28 +39,42 @@ Copyright_License { #include "Units/System.hpp" #include "Operation/Operation.hpp" #include "LogFile.hpp" +#include "util/StaticString.hxx" + +#include using std::string_view_literals::operator""sv; class LarusDevice : public AbstractDevice { - // unused up to now: Port &port; + Port &port; public: - LarusDevice([[maybe_unused]] Port &_port) {} + LarusDevice(Port &_port) : port(_port) {} /* virtual methods from class Device */ bool ParseNMEA(const char *line, NMEAInfo &info) override; -// void OnCalculatedUpdate(const MoreData &basic, -// const DerivedInfo &calculated) override; + // void OnCalculatedUpdate(const MoreData &basic, + // const DerivedInfo &calculated) override; + bool PutMacCready(double mc, OperationEnvironment &env) override; + bool PutBugs(double bugs, OperationEnvironment &env) override; + bool PutBallast(double fraction, double overload, + OperationEnvironment &env) override; + bool PutQNH(const AtmosphericPressure &pres, + OperationEnvironment &env) override; + private: static bool PLARA(NMEAInputLine &line, NMEAInfo &info); static bool PLARB(NMEAInputLine &line, NMEAInfo &info); static bool PLARD(NMEAInputLine &line, NMEAInfo &info); static bool PLARV(NMEAInputLine &line, NMEAInfo &info); + static bool PLARS(NMEAInputLine &line, NMEAInfo &info); static bool PLARW(NMEAInputLine &line, NMEAInfo &info); static bool HCHDT(NMEAInputLine &line, NMEAInfo &info); + + bool SendCmd(const char *cmd, double value, OperationEnvironment &env); }; +//----------------------------------------------------------------------------- /** * Parses non-negative floating-point angle value in degrees. */ @@ -77,7 +92,10 @@ ReadBearing(NMEAInputLine &line, Angle &value_r) return true; } -bool LarusDevice::ParseNMEA(const char *_line, NMEAInfo &info) { +//----------------------------------------------------------------------------- +bool +LarusDevice::ParseNMEA(const char *_line, NMEAInfo &info) +{ if (!VerifyNMEAChecksum(_line)) return false; @@ -95,6 +113,8 @@ bool LarusDevice::ParseNMEA(const char *_line, NMEAInfo &info) { return PLARV(line, info); case 'W': return PLARW(line, info); + case 'S': + return PLARS(line, info); default: break; } @@ -105,6 +125,7 @@ bool LarusDevice::ParseNMEA(const char *_line, NMEAInfo &info) { return false; } +//----------------------------------------------------------------------------- bool LarusDevice::HCHDT(NMEAInputLine &line, NMEAInfo &info) { @@ -139,6 +160,7 @@ LarusDevice::HCHDT(NMEAInputLine &line, NMEAInfo &info) return false; } +//----------------------------------------------------------------------------- bool LarusDevice::PLARA(NMEAInputLine &line, NMEAInfo &info) { @@ -180,6 +202,7 @@ LarusDevice::PLARA(NMEAInputLine &line, NMEAInfo &info) return true; } +//----------------------------------------------------------------------------- bool LarusDevice::PLARB(NMEAInputLine &line, NMEAInfo &info) { @@ -206,6 +229,7 @@ LarusDevice::PLARB(NMEAInputLine &line, NMEAInfo &info) return true; } +//----------------------------------------------------------------------------- bool LarusDevice::PLARD(NMEAInputLine &line, [[maybe_unused]] NMEAInfo &info) { @@ -243,6 +267,7 @@ LarusDevice::PLARD(NMEAInputLine &line, [[maybe_unused]] NMEAInfo &info) return true; } +//----------------------------------------------------------------------------- bool LarusDevice::PLARV(NMEAInputLine &line, NMEAInfo &info) { @@ -288,6 +313,7 @@ LarusDevice::PLARV(NMEAInputLine &line, NMEAInfo &info) return true; } +//----------------------------------------------------------------------------- bool LarusDevice::PLARW(NMEAInputLine &line, NMEAInfo &info) { @@ -325,15 +351,127 @@ LarusDevice::PLARW(NMEAInputLine &line, NMEAInfo &info) return true; } +//----------------------------------------------------------------------------- +/* +$PLARS Settings parameters bidirectional + + 1 2 3 4 + | | | | +$PLARS,a,a,xxx*hh + +Examples: +$PLARS,L,MC,1.3*1E +$PLARS,L,BAL,1.25*6B +$PLARS,L,BUGS,15*3B +$PLARS,L,QNH,1013.2*74 + +$PLARS,H,MC,2.1*1B +$PLARS,H,BAL,1.00*68 +$PLARS,H,BUGS,0*0B +$PLARS,H,QNH,1031.4*76 + +The $PLARS record is intended for exchanging setting values between Larus and a host system such as XCSoar. The record can be used in both directions: from host to Larus or from Larus to host. + +These records should not be sent cyclically, but only when needed during initialization and when changes are made. + + Data source (L: Larus, H: Host) + Settings parameter + MC MacCready (0.0 - 9.9) + BAL Ballast (1.00 - 1.60) + BUGS Bugs in % (0 - 30) + QNH QNH in hPa + Value (format depends on settings parameter, see examples) + Checksum +*/ +bool +LarusDevice::PLARS(NMEAInputLine &line, NMEAInfo &info) +{ // the line starts with the host indicator + if (line.ReadOneChar() == 'L') { + double value; + auto field = line.ReadView(); + if (line.ReadChecked(value)) { + if (field == "MC"sv) { + // - value is MacCReady in m/s [0.0 .. 9.9] + return info.settings.ProvideMacCready(value, info.clock); + } else if (field == "BUGS"sv) { + // - value is bugs in % [0-30], OpenSoar wants [0.5 .. 1.00] + return info.settings.ProvideBugs((1.0 - value)/100.0, info.clock); + } else if (field == "BAL"sv) { + // - value is ballast overload [1.00..1.60] + return info.settings.ProvideBallastOverload(value, info.clock); + } else if (field == "QNH"sv) { + // - value is pressure in hPa + return info.settings.ProvideQNH(AtmosphericPressure::HectoPascal(value), + info.clock); + } + } + } + return false; +} + +//----------------------------------------------------------------------------- +bool +LarusDevice::PutBugs(double bugs, OperationEnvironment &env) +{ + // $PLARS,H,BUGS,0*0B + // OpenSoar/XCSoar has values between [0.5 ..1.0] + if ((bugs < 0.7) || (bugs > 1.0)) + return false; + return SendCmd("BUGS,%u", uround((1.0-bugs) * 100), env); +} + +//----------------------------------------------------------------------------- +bool +LarusDevice::PutMacCready(double mc, OperationEnvironment &env) +{ + // $PLARS,H,MC,2.1*1B + return SendCmd("MC,%0.1f", mc, env); +} + +//----------------------------------------------------------------------------- +bool +LarusDevice::PutBallast([[maybe_unused]] double fraction, double overload, + OperationEnvironment &env) +{ + // $PLARS,H,BAL,1.00*68 + if ((overload < 1.0) || (overload > 1.60)) + return false; + return SendCmd("BAL,%0.2f", overload, env); +} + +//----------------------------------------------------------------------------- +bool +LarusDevice::PutQNH(const AtmosphericPressure &pres, + OperationEnvironment &env) +{ + // $PLARS,H,QNH,1031.4*76 + return SendCmd("QNH,%0.1f", pres.GetHectoPascal(), env); +} + +//----------------------------------------------------------------------------- +bool +LarusDevice::SendCmd(const char *cmd, double value, + OperationEnvironment &env) { + NarrowString<80> buffer("PLARS,H,"); + buffer.AppendFormat(cmd, value); + + PortWriteNMEA(port, buffer.c_str(), env); + return true; +} + + +//----------------------------------------------------------------------------- static Device * LarusCreateOnPort([[maybe_unused]] const DeviceConfig &config, Port &com_port) { return new LarusDevice(com_port); } +//----------------------------------------------------------------------------- const struct DeviceRegister larus_driver = { _T("Larus"), _T("Larus"), DeviceRegister::SEND_SETTINGS, LarusCreateOnPort, }; +//----------------------------------------------------------------------------- From d1c35c9c635f592a186260f1688228945bab07de Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 5 Feb 2024 17:58:57 +0100 Subject: [PATCH 184/403] [CMake] add Clang and MSVC toolchain --- build/cmake/toolchains/WinClang.toolchain | 32 +++++++++++++++++++++++ build/cmake/toolchains/mscv2022.toolchain | 17 ++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 build/cmake/toolchains/WinClang.toolchain create mode 100644 build/cmake/toolchains/mscv2022.toolchain diff --git a/build/cmake/toolchains/WinClang.toolchain b/build/cmake/toolchains/WinClang.toolchain new file mode 100644 index 00000000000..81baf1636d0 --- /dev/null +++ b/build/cmake/toolchains/WinClang.toolchain @@ -0,0 +1,32 @@ +# the name of the target operating system +set(CMAKE_SYSTEM_NAME Windows) + +### # which compilers to use for C and C++ +### set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) +### set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) +### # set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) + +if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL Windows) + set(WIN_HOST ON) +else() +### # here is the target environment located +### set(CMAKE_FIND_ROOT_PATH /usr/bin ) +### # set(CMAKE_FIND_ROOT_PATH /usr/lib/gcc/x86_64-w64-mingw32/10-win32 ) +### # set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32 ) # /home/august/mingw-install +### +### # because cross compiling no compiler check +### set(CMAKE_C_COMPILER_WORKS 1) +### set(CMAKE_CXX_COMPILER_WORKS 1) +endif() + +### set(MINGW ON) + +# adjust the default behaviour of the FIND_XXX() commands: +# search headers and libraries in the target environment, search +# programs in the host environment + +#set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +#set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +#set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +set(CMAKE_INCLUDE_SYSTEM build/cmake/WinClang.cmake) diff --git a/build/cmake/toolchains/mscv2022.toolchain b/build/cmake/toolchains/mscv2022.toolchain new file mode 100644 index 00000000000..b70252a4102 --- /dev/null +++ b/build/cmake/toolchains/mscv2022.toolchain @@ -0,0 +1,17 @@ +# the name of the target operating system +SET(CMAKE_SYSTEM_NAME Windows) + +# which compilers to use for C and C++ +SET(CMAKE_C_COMPILER vc) +SET(CMAKE_CXX_COMPILER vc) +# SET(CMAKE_RC_COMPILER i586-mingw32msvc-windres) + +# here is the target environment located +SET(CMAKE_FIND_ROOT_PATH /usr/i586-mingw32msvc /home/alex/mingw-install ) + +# adjust the default behaviour of the FIND_XXX() commands: +# search headers and libraries in the target environment, search +# programs in the host environment +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) From 3f48e0377e4a7b6108d9d2cd5111af6a07a5bf14 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 5 Feb 2024 18:02:48 +0100 Subject: [PATCH 185/403] [CMake] add Kobo to build tree With this access is possible to this files in VisualStudio --- src/Kobo/CMakeLists.txt | 55 ++++++++++++++++++++++++++++++++++++++ src/Kobo/CMakeSource.cmake | 52 +++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 src/Kobo/CMakeLists.txt create mode 100644 src/Kobo/CMakeSource.cmake diff --git a/src/Kobo/CMakeLists.txt b/src/Kobo/CMakeLists.txt new file mode 100644 index 00000000000..12c12f37ec8 --- /dev/null +++ b/src/Kobo/CMakeLists.txt @@ -0,0 +1,55 @@ +cmake_minimum_required(VERSION 3.15) +if (SHOW_SUBPROJECTS) + message(STATUS "+++ Start CMake ${CMAKE_CURRENT_SOURCE_DIR}!") +endif() + + get_filename_component(TARGET_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} NAME_WE) + set(TARGET_NAME ${TARGET_FOLDER}) + +include(CMakeSource.cmake) +# organize the files in subdirectories +set(SOURCE_FILES ) +foreach(source_file ${_SOURCES}) + string(REPLACE "${TARGET_FOLDER}/" "" source_file ${source_file}) + string(REPLACE "${PROJECTGROUP_SOURCE_DIR}/" "../../" source_file ${source_file}) + list(APPEND SOURCE_FILES ${source_file}) + get_filename_component(src_path ${source_file} DIRECTORY) + if (src_path) + string(REPLACE "/" "\\" src_path ${src_path}) + endif() + source_group("Source\\${src_path}" FILES ${source_file}) + # message(STATUS "### ${src_path} --- ${source_file}") +endforeach() + +if(NOT HEADER_FILES) # STREQUAL "" +file(GLOB_RECURSE HEADER_FILES_TEMP "${CMAKE_CURRENT_SOURCE_DIR}/*.h*") # ;../*.hxx;../*.h +# message(FATAL_ERROR "### ### Header-Liste --- ${HEADER_FILES_TEMP}" ) +set(HEADER_FILES) +foreach(header_file ${HEADER_FILES_TEMP}) + string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" header_file ${header_file}) + list(APPEND HEADER_FILES ${header_file}) + get_filename_component(src_path ${header_file} DIRECTORY) + if (src_path) + string(REPLACE "/" "\\" src_path ${src_path}) + endif() + source_group("Header\\${src_path}" FILES ${header_file}) + ## message(STATUS "### ### ${src_path} --- ${header_file}" ) +endforeach() +# message(FATAL_ERROR "### ### Header-Liste --- ${HEADER_FILES}" ) +endif() + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + +add_compile_definitions("OPENVARIO_DEVICE") +add_compile_definitions("IS_OPENVARIO") + +add_executable(${TARGET_NAME} + ${SOURCE_FILES} + ${HEADER_FILES} + ${SCRIPT_FILES} +) + # message(FATAL_ERROR "Stop!") +set_target_properties(${TARGET_NAME} PROPERTIES FOLDER Libs) + +target_link_libraries(${TARGET_NAME} PUBLIC ${OPENVARIOBASEMENU_LIBS}) +# add_dependencies(${TARGET_NAME} util Data) diff --git a/src/Kobo/CMakeSource.cmake b/src/Kobo/CMakeSource.cmake new file mode 100644 index 00000000000..efbd84e5443 --- /dev/null +++ b/src/Kobo/CMakeSource.cmake @@ -0,0 +1,52 @@ +set(TEST_SRC_DIR "${PROJECTGROUP_SOURCE_DIR}/test/src") + +set(_SOURCES + Kobo/WifiDialog.cpp + Kobo/WPASupplicant.cpp +) +set (KOBO_MENU_SOURCES + ${SRC}/Kobo/WPASupplicant.cpp + ${SRC}/Kobo/System.cpp + ${SRC}/Kobo/Kernel.cpp + ${SRC}/Kobo/NetworkDialog.cpp + ${SRC}/Kobo/SystemDialog.cpp + ${SRC}/Kobo/ToolsDialog.cpp + ${SRC}/Kobo/WPASupplicant.cpp + ${SRC}/Kobo/WifiDialog.cpp + ${SRC}/Kobo/FakeSymbols.cpp + ${SRC}/Kobo/KoboMenu.cpp +) +list (APPEND KOBO_MENU_SOURCES + ${SRC}/Version.cpp + ${SRC}/Asset.cpp + ${SRC}/Formatter/HexColor.cpp + ${SRC}/Hardware/CPU.cpp + ${SRC}/Hardware/DisplayDPI.cpp + ${SRC}/Hardware/RotateDisplay.cpp + ${SRC}/Screen/Layout.cpp + ${SRC}/ui/control/TerminalWindow.cpp + ${SRC}/Look/TerminalLook.cpp + ${SRC}/Look/DialogLook.cpp + ${SRC}/Look/ButtonLook.cpp + ${SRC}/Look/CheckBoxLook.cpp + ${SRC}/Renderer/TwoTextRowsRenderer.cpp + ${SRC}/Gauge/LogoView.cpp + ${SRC}/Dialogs/DialogSettings.cpp + ${SRC}/Dialogs/WidgetDialog.cpp + ${SRC}/Dialogs/HelpDialog.cpp + ${SRC}/Dialogs/Message.cpp + ${SRC}/Dialogs/Error.cpp + ${SRC}/Dialogs/LockScreen.cpp + ${SRC}/Dialogs/TextEntry.cpp + ${SRC}/Dialogs/KnobTextEntry.cpp + ${SRC}/Dialogs/TouchTextEntry.cpp + ${SRC}/Dialogs/SimulatorPromptWindow.cpp + ${TEST_SRC_DIR}/Fonts.cpp + ${TEST_SRC_DIR}/FakeLanguage.cpp + ${TEST_SRC_DIR}/FakeLogFile.cpp +) + +set(SCRIPT_FILES + CMakeSource.cmake + ../../build/kobo.mk +) From d076312abd78edc12c1318c4f249f3c6c3636874 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 6 Feb 2024 08:57:42 +0100 Subject: [PATCH 186/403] [build] main.mk - add Dialoges/ProcessDialog.cpp to OpenSoar --- build/main.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/main.mk b/build/main.mk index 2fdb89009fb..cc97657aded 100644 --- a/build/main.mk +++ b/build/main.mk @@ -157,6 +157,8 @@ DIALOG_SOURCES = \ ifeq ($(TARGET_IS_OPENVARIO),y) # $(SRC)/OpenVario/OpenVarioBaseMenu.cpp DIALOG_SOURCES += \ + $(SRC)/Dialogs/ProcessDialog.cpp \ + \ $(SRC)/OpenVario/SystemSettingsWidget.cpp \ $(SRC)/OpenVario/System/OpenVarioDevice.cpp \ $(SRC)/OpenVario/FileMenuWidget.cpp \ From 1bcb95028a8fc4a90e2db4600e29077de8020597 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 6 Feb 2024 18:15:31 +0100 Subject: [PATCH 187/403] change font size in serial port monitor --- src/Look/TerminalLook.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Look/TerminalLook.cpp b/src/Look/TerminalLook.cpp index 012ba59a9e7..eaafb1e8bcc 100644 --- a/src/Look/TerminalLook.cpp +++ b/src/Look/TerminalLook.cpp @@ -8,5 +8,6 @@ void TerminalLook::Initialise() { - font.Load(FontDescription(Layout::FontScale(11), false, false, true)); +// font.Load(FontDescription(Layout::FontScale(11), false, false, true)); + font.Load(FontDescription(Layout::FastScale(6), false, false, true)); } From 31fb0de28cc09e57d20a6fb32eeec72437b3f885 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 6 Feb 2024 22:22:03 +0100 Subject: [PATCH 188/403] OpenVario - with Touch calibration exit program, calibrate (and start again) --- src/OpenVario/System/OpenVarioDevice.hpp | 1 + src/OpenVario/System/SystemMenuWidget.cpp | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/OpenVario/System/OpenVarioDevice.hpp b/src/OpenVario/System/OpenVarioDevice.hpp index 018cedf3cf4..740836b2096 100644 --- a/src/OpenVario/System/OpenVarioDevice.hpp +++ b/src/OpenVario/System/OpenVarioDevice.hpp @@ -41,6 +41,7 @@ enum class SSHStatus { enum Buttons { LAUNCH_SHELL = 100, START_UPGRADE = 111, + LAUNCH_TOUCH_CALIBRATE = 112, }; class OpenVario_Device { diff --git a/src/OpenVario/System/SystemMenuWidget.cpp b/src/OpenVario/System/SystemMenuWidget.cpp index 6b6704e6bfc..5d5ff15b5f2 100644 --- a/src/OpenVario/System/SystemMenuWidget.cpp +++ b/src/OpenVario/System/SystemMenuWidget.cpp @@ -17,6 +17,7 @@ #include "Profile/Map.hpp" #include "Screen/Layout.hpp" #include "UIGlobals.hpp" +// #include "UIActions.hpp" #include "system/FileUtil.hpp" #include "Widget/RowFormWidget.hpp" @@ -27,6 +28,7 @@ #include "ui/event/KeyCode.hpp" #include "ui/event/Timer.hpp" #include "ui/window/Init.hpp" +#include "ui/window/ContainerWindow.hpp" #include "util/ScopeExit.hxx" #include "OpenVario/SystemSettingsWidget.hpp" @@ -224,6 +226,14 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, AddButton(_("Calibrate Sensors"), CalibrateSensors); AddButton(_("Calibrate Touch"), [this]() { + // dialog.SetModalResult(LAUNCH_TOUCH_CALIBRATE); + // dialog.SetModalResult(LAUNCH_TOUCH_CALIBRATE); + ContainerWindow::SetExitValue(LAUNCH_TOUCH_CALIBRATE); +// UIActions::SignalShutdown(false); + + + exit(LAUNCH_TOUCH_CALIBRATE); +#if 0 #if defined(_WIN32) static constexpr const char *argv[] = { "/usr/bin/ov-calibrate-ts.sh", nullptr}; @@ -237,7 +247,8 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, // RunProcessDialog(UIGlobals::GetMainWindow(), // UIGlobals::GetDialogLook(), // _T("System Info"), "/usr/bin/ov-calibrate-ts.sh"); - Run("/usr/bin/ov-calibrate-ts.sh"); +// Run("/usr/bin/ov-calibrate-ts.sh"); +#endif #endif }); From 617e4aaa0507b246f9cb8d0d470791ce7e8b7c01 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 7 Feb 2024 21:12:50 +0100 Subject: [PATCH 189/403] Device/Descriptor.cpp - use _A() macro --- src/Device/Descriptor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Device/Descriptor.cpp b/src/Device/Descriptor.cpp index fc6fa0986b7..e26cd730fab 100644 --- a/src/Device/Descriptor.cpp +++ b/src/Device/Descriptor.cpp @@ -390,7 +390,7 @@ try { TCHAR name_buffer[64]; const TCHAR *name = config.GetPortName(name_buffer, 64); - LogError(e, WideToUTF8Converter(name)); + LogError(e, _A(name)); const auto _msg = GetFullMessage(e); if (const UTF8ToWideConverter what{_msg.c_str()}; what.IsValid()) { From 541f588920c8c1534095e1a5c1f64e824dc318b5 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 7 Feb 2024 09:02:14 +0100 Subject: [PATCH 190/403] Look/TerminalLook.cpp - smaller font with a difference in OpenVario / normal --- src/Look/TerminalLook.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Look/TerminalLook.cpp b/src/Look/TerminalLook.cpp index eaafb1e8bcc..1cf9153fb4a 100644 --- a/src/Look/TerminalLook.cpp +++ b/src/Look/TerminalLook.cpp @@ -8,6 +8,9 @@ void TerminalLook::Initialise() { -// font.Load(FontDescription(Layout::FontScale(11), false, false, true)); +#ifdef IS_OPENVARIO_CB2 font.Load(FontDescription(Layout::FastScale(6), false, false, true)); +#else + font.Load(FontDescription(Layout::FontScale(8), false, false, true)); +#endif } From b6194dec59964b7a13bd95706f6ada513bed921f Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 7 Feb 2024 20:59:23 +0100 Subject: [PATCH 191/403] [OV] add ExtraWidget and OpenVarioTools to the project --- src/OpenVario/ExtraWidget.cpp | 86 +++++++++++++++++++++++++ src/OpenVario/ExtraWidget.hpp | 20 ++++++ src/OpenVario/System/OpenVarioTools.cpp | 85 ++++++++++++++++++++++++ src/OpenVario/System/OpenVarioTools.hpp | 6 ++ 4 files changed, 197 insertions(+) create mode 100644 src/OpenVario/ExtraWidget.cpp create mode 100644 src/OpenVario/ExtraWidget.hpp create mode 100644 src/OpenVario/System/OpenVarioTools.cpp create mode 100644 src/OpenVario/System/OpenVarioTools.hpp diff --git a/src/OpenVario/ExtraWidget.cpp b/src/OpenVario/ExtraWidget.cpp new file mode 100644 index 00000000000..3c3f272db59 --- /dev/null +++ b/src/OpenVario/ExtraWidget.cpp @@ -0,0 +1,86 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project + +#ifdef IS_OPENVARIO + +#include "OpenVario/ExtraWidget.hpp" + +#include "Dialogs/ProcessDialog.hpp" +#include "Dialogs/WidgetDialog.hpp" +#include "Form/Form.hpp" +#include "Hardware/DisplayGlue.hpp" +#include "Hardware/RotateDisplay.hpp" +#include "Language/Language.hpp" +#include "Widget/RowFormWidget.hpp" + +#include "UIGlobals.hpp" + +#include "OpenVario/System/OpenVarioDevice.hpp" +#include "OpenVario/System/OpenVarioTools.hpp" + +#ifndef OPENVARIO_BASEMENU +# include "UIActions.hpp" +# include "ui/window/ContainerWindow.hpp" +#endif + +#include +#include + +constexpr const TCHAR *opensoar = _T("OpenSoar"); +constexpr const TCHAR *xcsoar = _T("XCSoar"); +constexpr const TCHAR *main_app = opensoar; +constexpr const char *_main_app = "OpenSoar"; // only temporarily + +class ExtraWidget final : public RowFormWidget { +public: + ExtraWidget() noexcept : RowFormWidget(UIGlobals::GetDialogLook()) {} + +private: + /* virtual methods from class Widget */ + void Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept override; +}; + +void ExtraWidget::Prepare([[maybe_unused]] ContainerWindow &parent, + [[maybe_unused]] const PixelRect &rc) noexcept +{ + AddButton(_("Upgrade Firmware"), [this]() { +#ifdef OPENVARIO_BASEMENU + exit(START_UPGRADE); +#else // OPENVARIO_BASEMENU + ContainerWindow::SetExitValue(START_UPGRADE); + UIActions::SignalShutdown(false); + return mrOK; // START_UPGRADE; +#endif + }); + + AddButton(_("Calibrate Sensors"), CalibrateSensors); + + AddButton(_("Calibrate Touch"), [this]() { +// the programm exit in OpenSoar looks complete different fro OpenVarioBaseMenu +#ifdef OPENVARIO_BASEMENU + exit(LAUNCH_TOUCH_CALIBRATE); +#else // OPENVARIO_BASEMENU + ContainerWindow::SetExitValue(LAUNCH_TOUCH_CALIBRATE); + UIActions::SignalShutdown(true); + return mrOK; +#endif // OPENVARIO_BASEMENU + }); +} + +bool +ShowExtraWidget(ContainerWindow &parent, + const DialogLook &look) noexcept +{ + TWidgetDialog sub_dialog( + WidgetDialog::Full{}, (UI::SingleWindow &)parent, look, + _("OpenVario File Transfers")); + sub_dialog.SetWidget(); + sub_dialog.AddButton(_("Close"), mrOK); + return sub_dialog.ShowModal(); +} + +std::unique_ptr +CreateExtraWidget() noexcept { + return std::make_unique(); +} +#endif diff --git a/src/OpenVario/ExtraWidget.hpp b/src/OpenVario/ExtraWidget.hpp new file mode 100644 index 00000000000..813418a8802 --- /dev/null +++ b/src/OpenVario/ExtraWidget.hpp @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project +#pragma once + +#ifdef IS_OPENVARIO + +#include + +class Widget; +class ContainerWindow; +struct DialogLook; + +bool +ShowExtraWidget(ContainerWindow &parent, + const DialogLook &look) noexcept; + +std::unique_ptr +CreateExtraWidget() noexcept; + +#endif \ No newline at end of file diff --git a/src/OpenVario/System/OpenVarioTools.cpp b/src/OpenVario/System/OpenVarioTools.cpp new file mode 100644 index 00000000000..79399ff9530 --- /dev/null +++ b/src/OpenVario/System/OpenVarioTools.cpp @@ -0,0 +1,85 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project + +#include "OpenVario/System/OpenVarioTools.hpp" + +#include "Dialogs/ProcessDialog.hpp" +#include "Dialogs/Message.hpp" +#include "Form/Form.hpp" + +#include "UIGlobals.hpp" +#include "system/FileUtil.hpp" + +#include "Widget/RowFormWidget.hpp" + +#include "system/Process.hpp" +#include "ui/event/KeyCode.hpp" +#include "ui/event/Timer.hpp" +#include "ui/window/Init.hpp" +#include "util/ScopeExit.hxx" +#include "util/ConvertString.hpp" + + +//---------------------------------------------------------- + +void +CalibrateSensors() noexcept +{ + /* make sure sensord is stopped while calibrating sensors */ + static constexpr const char *start_sensord[] = {"/bin/systemctl", "start", + "sensord.service", nullptr}; + static constexpr const char *stop_sensord[] = {"/bin/systemctl", "stop", + "sensord.service", nullptr}; + + RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), + _T("Calibrate Sensors"), stop_sensord, [](int status) { + return status == EXIT_SUCCESS ? mrOK : 0; + }); + + AtScopeExit() { + RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), + _T("Calibrate Sensors"), start_sensord, [](int status) { + return status == EXIT_SUCCESS ? mrOK : 0; + }); + }; + + /* calibrate the sensors */ + static constexpr const char *calibrate_sensors[] = {"/opt/bin/sensorcal", + "-c", nullptr}; + + static constexpr int STATUS_BOARD_NOT_INITIALISED = 2; + static constexpr int RESULT_BOARD_NOT_INITIALISED = 100; + int result = RunProcessDialog( + UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), + _T("Calibrate Sensors"), calibrate_sensors, [](int status) { + return status == STATUS_BOARD_NOT_INITIALISED + ? RESULT_BOARD_NOT_INITIALISED + : 0; + }); + if (result != RESULT_BOARD_NOT_INITIALISED) + return; + + /* initialise the sensors? */ + if (ShowMessageBox(_T("Sensorboard is virgin. Do you want to initialise it?"), + _T("Calibrate Sensors"), MB_YESNO) != IDYES) + return; + + static constexpr const char *init_sensors[] = {"/opt/bin/sensorcal", "-i", + nullptr}; + + result = + RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), + _T("Calibrate Sensors"), init_sensors, [](int status) { + return status == EXIT_SUCCESS ? mrOK : 0; + }); + if (result != mrOK) + return; + + /* calibrate again */ + RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), + _T("Calibrate Sensors"), calibrate_sensors, [](int status) { + return status == STATUS_BOARD_NOT_INITIALISED + ? RESULT_BOARD_NOT_INITIALISED + : 0; + }); +} diff --git a/src/OpenVario/System/OpenVarioTools.hpp b/src/OpenVario/System/OpenVarioTools.hpp new file mode 100644 index 00000000000..ac67bd37e26 --- /dev/null +++ b/src/OpenVario/System/OpenVarioTools.hpp @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project + +#pragma once + +void CalibrateSensors() noexcept; From 397cd11a4b5dd2a086da5ef984fae8c27433da8d Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 15 Apr 2024 11:20:46 +0200 Subject: [PATCH 192/403] [build] add ExtraWidget and OpenVarioTools to the project --- build/main.mk | 11 ++++++++--- build/ov.mk | 15 +++++++++------ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/build/main.mk b/build/main.mk index cc97657aded..8fc1d8e6f62 100644 --- a/build/main.mk +++ b/build/main.mk @@ -155,15 +155,20 @@ DIALOG_SOURCES = \ $(SRC)/Dialogs/dlgQuickMenu.cpp \ ifeq ($(TARGET_IS_OPENVARIO),y) - # $(SRC)/OpenVario/OpenVarioBaseMenu.cpp + # $(SRC)/OpenVario/OpenVarioBaseMenu.cpp # for exe only... DIALOG_SOURCES += \ $(SRC)/Dialogs/ProcessDialog.cpp \ \ $(SRC)/OpenVario/SystemSettingsWidget.cpp \ - $(SRC)/OpenVario/System/OpenVarioDevice.cpp \ + $(SRC)/OpenVario/DisplaySettingsWidget.cpp \ $(SRC)/OpenVario/FileMenuWidget.cpp \ + $(SRC)/OpenVario/ExtraWidget.cpp \ + \ $(SRC)/OpenVario/System/SystemMenuWidget.cpp \ - $(SRC)/OpenVario/DisplaySettingsWidget.cpp \ + \ + $(SRC)/OpenVario/System/OpenVarioDevice.cpp \ + $(SRC)/OpenVario/System/OpenVarioTools.cpp \ + \ $(SRC)/OpenVario/System/Setting/RotationWidget.cpp \ $(SRC)/OpenVario/System/Setting/WifiWidget.cpp \ \ diff --git a/build/ov.mk b/build/ov.mk index 4fecd7f1be4..59e64b24131 100644 --- a/build/ov.mk +++ b/build/ov.mk @@ -181,19 +181,22 @@ DIALOG_SOURCES += \ OV_MENU_SOURCES = \ $(DIALOG_SOURCES) \ $(SRC)/OpenVario/OpenVarioBaseMenu.cpp \ - $(SRC)/OpenVario/System/OpenVarioDevice.cpp \ + \ + $(SRC)/OpenVario/SystemSettingsWidget.cpp \ + $(SRC)/OpenVario/DisplaySettingsWidget.cpp \ $(SRC)/OpenVario/FileMenuWidget.cpp \ + $(SRC)/OpenVario/ExtraWidget.cpp \ + \ $(SRC)/OpenVario/System/SystemMenuWidget.cpp \ - $(SRC)/OpenVario/DisplaySettingsWidget.cpp \ + \ + $(SRC)/OpenVario/System/OpenVarioDevice.cpp \ + $(SRC)/OpenVario/System/OpenVarioTools.cpp \ + \ $(SRC)/OpenVario/System/Setting/RotationWidget.cpp \ $(SRC)/OpenVario/System/Setting/WifiWidget.cpp \ \ $(SRC)/OpenVario/System/WifiDialogOV.cpp \ $(SRC)/OpenVario/System/WifiSupplicantOV.cpp \ - $(SRC)/OpenVario/System/WifiDBus.cpp \ - $(SRC)/OpenVario/System/NMConnector.cpp \ - \ - $(SRC)/OpenVario/SystemSettingsWidget.cpp \ \ $(SRC)/Version.cpp \ $(SRC)/Asset.cpp \ From 242469fabdb3853a1a2814eeb0e8c8984333873b Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 15 Apr 2024 11:21:08 +0200 Subject: [PATCH 193/403] [CMake] add ExtraWidget and OpenVarioTools to the project --- src/Dialogs/CMakeSource.cmake | 3 +++ src/OpenVario/CMakeSource.cmake | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/Dialogs/CMakeSource.cmake b/src/Dialogs/CMakeSource.cmake index 35fae07a483..deb6e0255d1 100644 --- a/src/Dialogs/CMakeSource.cmake +++ b/src/Dialogs/CMakeSource.cmake @@ -163,8 +163,11 @@ if(ON) # IS_OPENVARIO ../OpenVario/FileMenuWidget.cpp ../OpenVario/DisplaySettingsWidget.cpp ../OpenVario/SystemSettingsWidget.cpp + ../OpenVario/ExtraWidget.cpp ../OpenVario/System/OpenVarioDevice.cpp + ../OpenVario/System/OpenVarioTools.cpp + ../OpenVario/System/SystemMenuWidget.cpp ../OpenVario/System/Setting/RotationWidget.cpp diff --git a/src/OpenVario/CMakeSource.cmake b/src/OpenVario/CMakeSource.cmake index 712719cc673..32a196fd55d 100644 --- a/src/OpenVario/CMakeSource.cmake +++ b/src/OpenVario/CMakeSource.cmake @@ -5,8 +5,10 @@ set(_SOURCES OpenVario/FileMenuWidget.cpp OpenVario/DisplaySettingsWidget.cpp OpenVario/SystemSettingsWidget.cpp + OpenVario/ExtraWidget.cpp OpenVario/System/OpenVarioDevice.cpp + OpenVario/System/OpenVarioTools.cpp OpenVario/System/SystemMenuWidget.cpp OpenVario/System/Setting/RotationWidget.cpp From 9fdba9f80914ad3ef71b4da5aa60cf492999c561 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 7 Feb 2024 14:54:04 +0100 Subject: [PATCH 194/403] [build] - add definition OPENVARIO_BASEMENU for OpenVarioBaseMenu --- build/ov.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/ov.mk b/build/ov.mk index 59e64b24131..83564160f46 100644 --- a/build/ov.mk +++ b/build/ov.mk @@ -9,6 +9,7 @@ endif EXTRA_CPPFLAGS+= -DPROGRAM_VERSION=\"$(PROGRAM_VERSION)\" EXTRA_CPPFLAGS += -DIS_OPENVARIO +EXTRA_CPPFLAGS += -DOPENVARIO_BASEMENU ifeq ($(TARGET_IS_OVDEVICE),y) EXTRA_CPPFLAGS+= -DIS_OPENVARIO_CB2 endif @@ -159,7 +160,7 @@ DIALOG_SOURCES = \ $(SRC)/Dialogs/Weather/RASPDialog.cpp \ $(SRC)/Dialogs/dlgCredits.cpp \ $(SRC)/Dialogs/dlgQuickMenu.cpp \ - \ + \ $(SRC)/Dialogs/DownloadFilePicker.cpp \ ## ifeq ($(HAVE_HTTP),y) From 48ed9c6f4b33e762dbb0b3cb81b0aa6490867d8b Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 15 Apr 2024 11:22:28 +0200 Subject: [PATCH 195/403] [CMake] - add definition OPENVARIO_BASEMENU for OpenVarioBaseMenu --- src/OpenVario/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/OpenVario/CMakeLists.txt b/src/OpenVario/CMakeLists.txt index 88b487a03ea..42b1f6b2de1 100644 --- a/src/OpenVario/CMakeLists.txt +++ b/src/OpenVario/CMakeLists.txt @@ -44,7 +44,9 @@ add_compile_definitions("OPENVARIO_DEVICE") add_compile_definitions("IS_OPENVARIO") # add_compile_definitions("USE_LIBINPUT") -# remeve this definition after +# remove this definition after ??? + +add_compile_definitions("OPENVARIO_BASEMENU") if(MSVC) SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECTGROUP_BINARY_DIR}") From d3137415434c6363a057986af0a5fac4e02d7797 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 8 Feb 2024 09:07:23 +0100 Subject: [PATCH 196/403] System/SystemMenuWidget.cpp - add some functions, make Prepare public move CalibrateSensors to ExtraWidget --- src/OpenVario/System/SystemMenuWidget.cpp | 110 +++++++--------------- 1 file changed, 32 insertions(+), 78 deletions(-) diff --git a/src/OpenVario/System/SystemMenuWidget.cpp b/src/OpenVario/System/SystemMenuWidget.cpp index 5d5ff15b5f2..ace4b126293 100644 --- a/src/OpenVario/System/SystemMenuWidget.cpp +++ b/src/OpenVario/System/SystemMenuWidget.cpp @@ -17,103 +17,48 @@ #include "Profile/Map.hpp" #include "Screen/Layout.hpp" #include "UIGlobals.hpp" -// #include "UIActions.hpp" #include "system/FileUtil.hpp" #include "Widget/RowFormWidget.hpp" -#if !defined(_WIN32) # include "system/Process.hpp" -#endif #include "ui/event/KeyCode.hpp" #include "ui/event/Timer.hpp" #include "ui/window/Init.hpp" -#include "ui/window/ContainerWindow.hpp" #include "util/ScopeExit.hxx" +#include "util/ConvertString.hpp" #include "OpenVario/SystemSettingsWidget.hpp" + #include "OpenVario/System/OpenVarioDevice.hpp" +#include "OpenVario/System/OpenVarioTools.hpp" + #include "OpenVario/System/SystemMenuWidget.hpp" #include "system/Process.hpp" -#include +#include // for std::cout << ... #include #include +#ifndef OPENVARIO_BASEMENU +# include "ui/window/ContainerWindow.hpp" +# include "UIActions.hpp" +#endif + class SystemMenuWidget final : public RowFormWidget { public: SystemMenuWidget() noexcept : RowFormWidget(UIGlobals::GetDialogLook()) {} -private: + void SetEnabled([[maybe_unused]]bool enabled) noexcept {} + /* virtual methods from class Widget */ void Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept override; - // void CalibrateSensors() noexcept; -}; + bool Save(bool &changed) noexcept override { return true; } -// void -// SystemMenuWidget::CalibrateSensors() noexcept -static void -CalibrateSensors() noexcept -{ - /* make sure sensord is stopped while calibrating sensors */ - static constexpr const char *start_sensord[] = {"/bin/systemctl", "start", - "sensord.service", nullptr}; - static constexpr const char *stop_sensord[] = {"/bin/systemctl", "stop", - "sensord.service", nullptr}; - - RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T("Calibrate Sensors"), stop_sensord, [](int status) { - return status == EXIT_SUCCESS ? mrOK : 0; - }); - - AtScopeExit() { - RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T("Calibrate Sensors"), start_sensord, [](int status) { - return status == EXIT_SUCCESS ? mrOK : 0; - }); - }; - - /* calibrate the sensors */ - static constexpr const char *calibrate_sensors[] = {"/opt/bin/sensorcal", - "-c", nullptr}; - - static constexpr int STATUS_BOARD_NOT_INITIALISED = 2; - static constexpr int RESULT_BOARD_NOT_INITIALISED = 100; - int result = RunProcessDialog( - UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T("Calibrate Sensors"), calibrate_sensors, [](int status) { - return status == STATUS_BOARD_NOT_INITIALISED - ? RESULT_BOARD_NOT_INITIALISED - : 0; - }); - if (result != RESULT_BOARD_NOT_INITIALISED) - return; - - /* initialise the sensors? */ - if (ShowMessageBox(_T("Sensorboard is virgin. Do you want to initialise it?"), - _T("Calibrate Sensors"), MB_YESNO) != IDYES) - return; - - static constexpr const char *init_sensors[] = {"/opt/bin/sensorcal", "-i", - nullptr}; - - result = - RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T("Calibrate Sensors"), init_sensors, [](int status) { - return status == EXIT_SUCCESS ? mrOK : 0; - }); - if (result != mrOK) - return; - - /* calibrate again */ - RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T("Calibrate Sensors"), calibrate_sensors, [](int status) { - return status == STATUS_BOARD_NOT_INITIALISED - ? RESULT_BOARD_NOT_INITIALISED - : 0; - }); -} +private: + +}; //----------------------------------------------------------------------------- class ScreenSSHWidget final : public RowFormWidget { @@ -195,8 +140,13 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { AddButton(_("Upgrade Firmware"), [this]() { - // dialog.SetModalResult(START_UPGRADE); +#ifdef OPENVARIO_BASEMENU exit(START_UPGRADE); +#else // OPENVARIO_BASEMENU + ContainerWindow::SetExitValue(START_UPGRADE); + UIActions::SignalShutdown(true); + return START_UPGRADE; +#endif }); #if 1 @@ -226,13 +176,17 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, AddButton(_("Calibrate Sensors"), CalibrateSensors); AddButton(_("Calibrate Touch"), [this]() { +// the programm exit in OpenSoar looks complete different fro OpenVarioBaseMenu +#ifdef OPENVARIO_BASEMENU + exit(LAUNCH_TOUCH_CALIBRATE); +#else // OPENVARIO_BASEMENU + ContainerWindow::SetExitValue(LAUNCH_TOUCH_CALIBRATE); + UIActions::SignalShutdown(true); + return mrOK; + // InputEvents::eventExit(_T("reboot")); // dialog.SetModalResult(LAUNCH_TOUCH_CALIBRATE); // dialog.SetModalResult(LAUNCH_TOUCH_CALIBRATE); - ContainerWindow::SetExitValue(LAUNCH_TOUCH_CALIBRATE); -// UIActions::SignalShutdown(false); - - exit(LAUNCH_TOUCH_CALIBRATE); #if 0 #if defined(_WIN32) static constexpr const char *argv[] = { "/usr/bin/ov-calibrate-ts.sh", @@ -250,7 +204,8 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, // Run("/usr/bin/ov-calibrate-ts.sh"); #endif #endif - }); +#endif // OPENVARIO_BASEMENU + }); AddButton(_("System Info"), []() { static constexpr const char *argv[] = { @@ -274,7 +229,6 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, StaticString<0x200> str; str.Format(_T("%s/%s"), ovdevice.GetHomePath().c_str(), _T("process.txt")); Path output = Path(str); - std::cout << "FileName: " << output.ToUTF8() << std::endl; auto ret_value = Run( output, From c0ed61493e11d967257714a3dfce471c8e98f69a Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 7 Feb 2024 21:19:49 +0100 Subject: [PATCH 197/403] OpenVarioBaseMenu.cpp - adding ExtraWidget --- src/OpenVario/OpenVarioBaseMenu.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/OpenVario/OpenVarioBaseMenu.cpp b/src/OpenVario/OpenVarioBaseMenu.cpp index 4196b1e015a..ccdc8cc1673 100644 --- a/src/OpenVario/OpenVarioBaseMenu.cpp +++ b/src/OpenVario/OpenVarioBaseMenu.cpp @@ -26,6 +26,7 @@ #include "util/StaticString.hxx" #include "OpenVario/FileMenuWidget.hpp" +#include "OpenVario/ExtraWidget.hpp" #include "OpenVario/DisplaySettingsWidget.hpp" #include "OpenVario/SystemSettingsWidget.hpp" @@ -286,6 +287,11 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, return ShowSystemSettingsWidget(UIGlobals::GetMainWindow(), GetLook()); }); + AddButton(_("OpenVario Extra menu "), [this]() { + CancelTimer(); + return ShowExtraWidget(UIGlobals::GetMainWindow(), GetLook()); + }); + AddButton(_("OpenVario Placeholder"), [this]() { CancelTimer(); return ShowSystemMenuWidget(UIGlobals::GetMainWindow(), GetLook()); From 7717e5a45a48d7cec4a5a40a7fffdcdce747ffa8 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 7 Feb 2024 21:31:03 +0100 Subject: [PATCH 198/403] OpenVarioBaseMenu.cpp - add handling of exit code OpenSoar --- src/OpenVario/OpenVarioBaseMenu.cpp | 34 +++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/OpenVario/OpenVarioBaseMenu.cpp b/src/OpenVario/OpenVarioBaseMenu.cpp index ccdc8cc1673..2a2aaf88c7c 100644 --- a/src/OpenVario/OpenVarioBaseMenu.cpp +++ b/src/OpenVario/OpenVarioBaseMenu.cpp @@ -103,28 +103,45 @@ class MainMenuWidget final } private: - void StartSoarExe(std::string_view exe, + int StartSoarExe(std::string_view exe, std::filesystem::path _datapath = "") noexcept; - void StartOpenSoar() noexcept { + int StartOpenSoar() noexcept { std::filesystem::path datapath = ""; if (ovdevice.settings.find("OpenSoarData") != ovdevice.settings.end()) datapath = ovdevice.settings.find("OpenSoarData")->second; else datapath = ovdevice.GetDataPath().ToUTF8() + "/OpenSoarData"; - StartSoarExe("OpenSoar", datapath); + int ret_value = StartSoarExe("OpenSoar", datapath); // after OpenSoar the settings can be changed ovdevice.LoadSettings(); + switch (ret_value) { + case 200: + exit(LAUNCH_SHELL); + case 201: + Run("/sbin/reboot"); + break; + case 202: + Run("/sbin/poweroff"); + break; + case START_UPGRADE: + case LAUNCH_SHELL: + case LAUNCH_TOUCH_CALIBRATE: + exit(ret_value); + default: + break; + } + return ret_value; } - void StartXCSoar() noexcept { + int StartXCSoar() noexcept { std::filesystem::path datapath = ""; if (ovdevice.settings.find("XCSoarData") != ovdevice.settings.end()) datapath = ovdevice.settings.find("XCSoarData")->second; else datapath = ovdevice.GetDataPath().ToUTF8() + "/XCSoarData"; - StartSoarExe("xcsoar", datapath); + return StartSoarExe("xcsoar", datapath); } void ScheduleTimer() noexcept { @@ -185,8 +202,10 @@ class MainMenuWidget final WndProperty *progress_timer = nullptr; }; -void MainMenuWidget::StartSoarExe(std::string_view _exe, +int +MainMenuWidget::StartSoarExe(std::string_view _exe, std::filesystem::path _datapath) noexcept { + int ret_value = 0; const UI::ScopeDropMaster drop_master{display}; const UI::ScopeSuspendEventQueue suspend_event_queue{event_queue}; @@ -238,7 +257,7 @@ void MainMenuWidget::StartSoarExe(std::string_view _exe, //=============== End of Parameter ======================= ArgList.push_back(nullptr); //======================================================== - Run(&ArgList[0]); + ret_value = Run(&ArgList[0]); } else { // ExePath doesnt exist! LogFormat("Program file '%s' doesnt exist!", ExePath.c_str()); #ifdef _WIN32 @@ -247,6 +266,7 @@ void MainMenuWidget::StartSoarExe(std::string_view _exe, MB_OK | MB_ICONEXCLAMATION); #endif } + return ret_value; } void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, From 93d20b5ce778ef8edaf45329dc68be6c0023cccb Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 8 Feb 2024 10:23:55 +0100 Subject: [PATCH 199/403] Widget/PagerWidget.hpp - increase capacity of pager to 40 --- src/Widget/PagerWidget.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Widget/PagerWidget.hpp b/src/Widget/PagerWidget.hpp index 4fa6e6bde51..8263d2e0170 100644 --- a/src/Widget/PagerWidget.hpp +++ b/src/Widget/PagerWidget.hpp @@ -37,7 +37,7 @@ class PagerWidget : public Widget { PixelRect position; unsigned current; - boost::container::static_vector children; + boost::container::static_vector children; PageFlippedCallback page_flipped_callback; From 8152645950556b405667e8d73a4f783b914de190 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 8 Feb 2024 10:19:14 +0100 Subject: [PATCH 200/403] PagerWidget.cpp - assertion if capacity limit reached --- src/Widget/PagerWidget.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Widget/PagerWidget.cpp b/src/Widget/PagerWidget.cpp index 40855d410c3..a8bcbb2625a 100644 --- a/src/Widget/PagerWidget.cpp +++ b/src/Widget/PagerWidget.cpp @@ -4,6 +4,8 @@ #include "PagerWidget.hpp" #include +#include + PagerWidget::Child::~Child() noexcept { @@ -26,6 +28,12 @@ PagerWidget::Add(std::unique_ptr w) noexcept } else { assert(current < children.size()); } + // current is always 0 + if (children.size() >= children.capacity()) + std::cout << "PagerWidget::Add - children-limit is reached:" << children.size() + << ", capacity: " << children.capacity() << std::endl; + + assert(children.size() < children.capacity()); auto &child = children.emplace_back(std::move(w)); From f727a78bf1ac0f8b7ff09190a3dc813c62a221cf Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 8 Feb 2024 16:05:37 +0100 Subject: [PATCH 201/403] Form/TabMenuDisplay.hpp - use 40 buttons --- src/Form/TabMenuDisplay.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Form/TabMenuDisplay.hpp b/src/Form/TabMenuDisplay.hpp index 0ccdb8b9d44..5b67a3240b9 100644 --- a/src/Form/TabMenuDisplay.hpp +++ b/src/Form/TabMenuDisplay.hpp @@ -120,7 +120,8 @@ class TabMenuDisplay final : public PaintWindow PagerWidget &pager; const DialogLook &look; - StaticArray buttons; +// StaticArray buttons; + StaticArray buttons; /* holds info and buttons for the main menu. not on child menus */ StaticArray main_menu_buttons; From b960eb2ad8737fbbb4387e34d9906a2faa4411a8 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 8 Feb 2024 18:28:40 +0100 Subject: [PATCH 202/403] Form/TabMenuDisplay.hpp - use a const for the max page definition --- src/Form/TabMenuDisplay.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Form/TabMenuDisplay.hpp b/src/Form/TabMenuDisplay.hpp index 5b67a3240b9..c34b3409b26 100644 --- a/src/Form/TabMenuDisplay.hpp +++ b/src/Form/TabMenuDisplay.hpp @@ -19,6 +19,7 @@ class TabMenuDisplay final : public PaintWindow #else static constexpr unsigned MAX_MAIN_MENU_ITEMS = 7; #endif + static constexpr unsigned SUB_MAIN_MENU_BUTTOMS = 40; /** * The offset from a page number in the #TabMenuDisplay to a page @@ -120,8 +121,7 @@ class TabMenuDisplay final : public PaintWindow PagerWidget &pager; const DialogLook &look; -// StaticArray buttons; - StaticArray buttons; + StaticArray buttons; /* holds info and buttons for the main menu. not on child menus */ StaticArray main_menu_buttons; From 82ea7781a83db2fc5cac961391496643fe5a20a3 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 8 Feb 2024 18:29:59 +0100 Subject: [PATCH 203/403] OpenVario/SystemSettingsWidget.cpp bugfix field alignment with firmware upgrade --- src/OpenVario/SystemSettingsWidget.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/OpenVario/SystemSettingsWidget.cpp b/src/OpenVario/SystemSettingsWidget.cpp index 54343844938..2e6608217ce 100644 --- a/src/OpenVario/SystemSettingsWidget.cpp +++ b/src/OpenVario/SystemSettingsWidget.cpp @@ -30,6 +30,7 @@ enum ControlIndex { FIRMWARE, ENABLED, + FW_IMAGE, ROTATION, BRIGHTNESS, SENSORD, @@ -148,10 +149,7 @@ SystemSettingsWidget::Prepare(ContainerWindow &parent, _("IntegerTest."), _T("%d"), _T("%d"), 0, 99999, 1, ovdevice.iTest); - AddReadOnly(_("OV-Firmware-Version"), - _("Current firmware version of OpenVario"), version); - - SetEnabled(ovdevice.enabled); + SetEnabled(ovdevice.enabled); } bool From 6c90cc07a7d04689e62222bf68908b8932eb8d4c Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 8 Feb 2024 23:43:21 +0100 Subject: [PATCH 204/403] Dialogs/Settings/dlgConfiguration.cpp - rename Files group in 'Basic Settings' and move the deprecated OV Test Menu to this (for a later removing!) --- src/Dialogs/Settings/dlgConfiguration.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Dialogs/Settings/dlgConfiguration.cpp b/src/Dialogs/Settings/dlgConfiguration.cpp index 5ac2402a87e..f8731586212 100644 --- a/src/Dialogs/Settings/dlgConfiguration.cpp +++ b/src/Dialogs/Settings/dlgConfiguration.cpp @@ -81,8 +81,11 @@ static unsigned current_page; // TODO: eliminate global variables static ArrowPagerWidget *pager; -static constexpr TabMenuPage files_pages[] = { +static constexpr TabMenuPage basic_pages[] = { { N_("Site Files"), CreateSiteConfigPanel }, +#ifdef IS_OPENVARIO + { N_("TestOpenVario"), CreateSystemMenuWidget}, +#endif { nullptr, nullptr } }; @@ -155,13 +158,13 @@ static constexpr TabMenuPage openvario_pages[] = { {N_("Display Settings"), CreateDisplaySettingsWidget}, {N_("File Transfer"), CreateFileMenuWidget}, {N_("Advanced Menu (temp)"), CreateExtraWidget}, - {N_("Advanced Settings (temp)"), CreateSystemMenuWidget}, + // {N_("Advanced Settings (temp)"), CreateSystemMenuWidget}, { nullptr, nullptr } }; #endif static constexpr TabMenuGroup main_menu_captions[] = { - { N_("Site Files"), files_pages }, + {N_("Basic Settings"), basic_pages}, { N_("Map Display"), map_pages }, { N_("Glide Computer"), computer_pages }, { N_("Gauges"), gauge_pages }, From 8bea6d9db230067ecb0231dd7e8d04ce083a293d Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 9 Feb 2024 11:11:32 +0100 Subject: [PATCH 205/403] ui/control/TerminalWindow.cpp - smaller font with OpenVario --- src/Look/TerminalLook.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Look/TerminalLook.cpp b/src/Look/TerminalLook.cpp index 1cf9153fb4a..e2d57e5899f 100644 --- a/src/Look/TerminalLook.cpp +++ b/src/Look/TerminalLook.cpp @@ -9,7 +9,7 @@ void TerminalLook::Initialise() { #ifdef IS_OPENVARIO_CB2 - font.Load(FontDescription(Layout::FastScale(6), false, false, true)); + font.Load(FontDescription(Layout::FontScale(6), false, false, true)); #else font.Load(FontDescription(Layout::FontScale(8), false, false, true)); #endif From c99e205e93fac0fd2c00bc1cdce44c2c5c365deb Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 9 Feb 2024 19:26:53 +0100 Subject: [PATCH 206/403] OpenVarioBaseMenu.cpp - normal close of OpenSoar is closing OpenVarioBaseMenu - with OpenSoar return code 200 don't go to shell, only close the executable - use the correct return codes from OpenSoar, f.e. LAUNCH_SHELL_STOP --- src/OpenVario/OpenVarioBaseMenu.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/OpenVario/OpenVarioBaseMenu.cpp b/src/OpenVario/OpenVarioBaseMenu.cpp index 2a2aaf88c7c..968b3026c5d 100644 --- a/src/OpenVario/OpenVarioBaseMenu.cpp +++ b/src/OpenVario/OpenVarioBaseMenu.cpp @@ -112,21 +112,23 @@ class MainMenuWidget final datapath = ovdevice.settings.find("OpenSoarData")->second; else datapath = ovdevice.GetDataPath().ToUTF8() + "/OpenSoarData"; + int ret_value = StartSoarExe("OpenSoar", datapath); // after OpenSoar the settings can be changed ovdevice.LoadSettings(); switch (ret_value) { - case 200: - exit(LAUNCH_SHELL); + case 200: // simple exit from OpenSoar, go in menu + break; case 201: Run("/sbin/reboot"); break; case 202: Run("/sbin/poweroff"); break; + case LAUNCH_SHELL: // "Exit to shell' + exit(100); case START_UPGRADE: - case LAUNCH_SHELL: case LAUNCH_TOUCH_CALIBRATE: exit(ret_value); default: @@ -334,7 +336,7 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, #ifndef RELEASE_VERSION AddButton(_T("Exit to Shell (with Wait)"), - [this]() { dialog.SetModalResult(LAUNCH_SHELL+1); }); + [this]() { dialog.SetModalResult(LAUNCH_SHELL_STOP); }); #endif auto Btn_Reboot = From 1ea571a7352740a7b02d00128fb0c29a80f64f77 Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 9 Feb 2024 21:19:36 +0100 Subject: [PATCH 207/403] OpenVarioDevice.hpp - change return codes according to OpenVario - enum LAUNCH_SHELL_STOP - use enum 204 for Stop --- src/OpenVario/System/OpenVarioDevice.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/OpenVario/System/OpenVarioDevice.hpp b/src/OpenVario/System/OpenVarioDevice.hpp index 740836b2096..55e2d36e2b4 100644 --- a/src/OpenVario/System/OpenVarioDevice.hpp +++ b/src/OpenVario/System/OpenVarioDevice.hpp @@ -39,9 +39,10 @@ enum class SSHStatus { }; enum Buttons { - LAUNCH_SHELL = 100, - START_UPGRADE = 111, - LAUNCH_TOUCH_CALIBRATE = 112, + LAUNCH_SHELL = 203, + LAUNCH_SHELL_STOP = 204, + START_UPGRADE = 205, + LAUNCH_TOUCH_CALIBRATE = 206, }; class OpenVario_Device { From e330d4490ad7a94470e7793672be530dcd227963 Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 9 Feb 2024 20:04:13 +0100 Subject: [PATCH 208/403] Dialogs/FileManager.cpp - add Delete button --- src/Dialogs/FileManager.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/Dialogs/FileManager.cpp b/src/Dialogs/FileManager.cpp index 7679886656f..f78c1e2a866 100644 --- a/src/Dialogs/FileManager.cpp +++ b/src/Dialogs/FileManager.cpp @@ -143,7 +143,7 @@ class ManagedFileListWidget TwoTextRowsRenderer row_renderer; #ifdef HAVE_DOWNLOAD_MANAGER - Button *download_button, *add_button, *cancel_button, *update_button; + Button *download_button, *add_button, *cancel_button, *update_button, *delete_button; /** * Whether at least one file is out of date. @@ -252,6 +252,7 @@ class ManagedFileListWidget void UpdateButtons(); void Download(); + void Delete(); void Add(); void Cancel(); void UpdateFiles(); @@ -396,8 +397,10 @@ ManagedFileListWidget::CreateButtons(WidgetDialog &dialog) noexcept { #ifdef HAVE_DOWNLOAD_MANAGER if (Net::DownloadManager::IsAvailable()) { - download_button = dialog.AddButton(_("Download"), [this](){ Download(); }); + // download_button = dialog.AddButton(_("Download"), [this](){ Download(); }); + download_button = dialog.AddButton(_("Update"), [this](){ Download(); }); add_button = dialog.AddButton(_("Add"), [this](){ Add(); }); + delete_button = dialog.AddButton(_("Delete"), [this](){ Delete(); }); cancel_button = dialog.AddButton(_("Cancel"), [this](){ Cancel(); }); update_button = dialog.AddButton(_("Update all"), [this](){ UpdateFiles(); @@ -464,6 +467,28 @@ ManagedFileListWidget::OnCursorMoved([[maybe_unused]] unsigned index) noexcept UpdateButtons(); } +void +ManagedFileListWidget::Delete() +{ +#ifdef HAVE_DOWNLOAD_MANAGER + assert(Net::DownloadManager::IsAvailable()); + + if (items.empty()) + return; + + const unsigned current = GetList().GetCursorIndex(); + assert(current < items.size()); + + auto path = LocalPath(items[current].name); + // TODO(aug): + // Please delete only w/o asking if the file in no profile inserted + auto r = File::Delete(path); + if (r) + RefreshList(); + // else not deleted??? +#endif +} + void ManagedFileListWidget::Download() { From 20629d61fcc871508d4f56acf34554efd0f70af7 Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 9 Feb 2024 20:07:09 +0100 Subject: [PATCH 209/403] OpenVario WifiDialogOV.cpp - add ReConnect button --- src/OpenVario/System/WifiDialogOV.cpp | 67 ++++++++++++++++----------- 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/src/OpenVario/System/WifiDialogOV.cpp b/src/OpenVario/System/WifiDialogOV.cpp index 408903d008b..6482b2223de 100644 --- a/src/OpenVario/System/WifiDialogOV.cpp +++ b/src/OpenVario/System/WifiDialogOV.cpp @@ -87,6 +87,8 @@ class WifiListWidget final bool connected = false; // 'R' - 3rd char; }; + Button *scan_button; + Button *reconnect_button; Button *connect_button; WifiStatus status; @@ -101,7 +103,7 @@ class WifiListWidget final public: void CreateButtons(WidgetDialog &dialog) { - dialog.AddButton(_("Scan"), [this](){ + scan_button = dialog.AddButton(_("Scan"), [this](){ try { EnsureConnected(); // wpa_supplicant.Scan(); @@ -112,7 +114,15 @@ class WifiListWidget final } }); - connect_button = dialog.AddButton(_("Connect"), [this](){ + reconnect_button = dialog.AddButton(_("Re-Connect"), [this]() { + try { + ReConnect(); + } catch (...) { + ShowError(std::current_exception(), _("Error")); + } + }); + + connect_button = dialog.AddButton(_("Connect"), [this]() { try { Connect(); } catch (...) { @@ -184,34 +194,9 @@ class WifiListWidget final void UpdateList(); void Connect(); + void ReConnect(); }; - -#if 0 //DEBUG_TEST_VERSION -const char *TestArray[5][2] = { - { - "SSID-1", - "bssid-1", - }, - { - "SSID-2", - "bssid-2", - }, - { - "SSID-3", - "bssid-3", - }, - { - "SSID-4", - "bssid-4", - }, - { - "SSID-5", - "bssid-5", - } -}; -#endif - void WifiListWidget::ScanWifi() { @@ -479,6 +464,32 @@ void WifiListWidget::WifiConnect(enum WifiSecurity security, #endif // WithWPA } +inline void +WifiListWidget::ReConnect() +{ + EnsureConnected(); + + const unsigned i = GetList().GetCursorIndex(); + if (i >= networks.size()) + return; + +#if defined(IS_OPENVARIO_CB2) + // disable wifi + Run(Path(_T("wifi-disable.txt")), connmanctl, "disable", "wifi"); + // wait a second + std::this_thread::sleep_for(std::chrono::seconds(1)); + // enable wifi again for AutoConnect + Run(Path(_T("wifi-enable.txt")), connmanctl, "enable", "wifi"); + // wait a second after wifi enabling (?) + std::this_thread::sleep_for(std::chrono::seconds(1)); +// // ask state of the wifi connection +// Run(Path(_T("wifi-connect.txt")), connmanctl, "services", +// network->base_id.c_str()); +#endif + + UpdateList(); +} + inline void WifiListWidget::Connect() { From c74753a5df2bacdcba5193d14f82795242b6ea36 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 2 May 2022 11:47:03 +0200 Subject: [PATCH 210/403] RowFormWidget - AddLabel: add a widget Label for static text Is this Widget 'AddLabel' used in WeGlide only? This is useful also in other dialogs too --- src/Widget/RowFormWidget.cpp | 14 ++++++++++++++ src/Widget/RowFormWidget.hpp | 7 +++++++ 2 files changed, 21 insertions(+) diff --git a/src/Widget/RowFormWidget.cpp b/src/Widget/RowFormWidget.cpp index 083c0e59679..767494a3590 100644 --- a/src/Widget/RowFormWidget.cpp +++ b/src/Widget/RowFormWidget.cpp @@ -4,6 +4,7 @@ #include "RowFormWidget.hpp" #include "Form/Panel.hpp" #include "Form/Button.hpp" +#include "Form/Frame.hpp" #include "Form/HLine.hpp" #include "Look/DialogLook.hpp" #include "Dialogs/DialogSettings.hpp" @@ -265,6 +266,19 @@ RowFormWidget::AddSpacer() noexcept Add(std::move(window)); } +void +RowFormWidget::AddLabel(const TCHAR *text, unsigned lines) noexcept +{ + ContainerWindow &panel = (ContainerWindow &)GetWindow(); + if (lines == 0) lines = 1; + const PixelRect rc = InitialControlRect( + Layout::Scale(lines * look.text_font.GetHeight())); + + auto window = std::make_unique(panel, look, rc); + window->SetText(text); + Add(std::move(window)); +} + void RowFormWidget::AddMultiLine(const TCHAR *text) noexcept { diff --git a/src/Widget/RowFormWidget.hpp b/src/Widget/RowFormWidget.hpp index 70dc976c6e7..0f705e549b3 100644 --- a/src/Widget/RowFormWidget.hpp +++ b/src/Widget/RowFormWidget.hpp @@ -439,6 +439,13 @@ class RowFormWidget : public WindowWidget { nullable); } + /** + * Add a label panel control, not editable, only for some explanations, + * descriptions or messages. You can use SetText() to update its text. + * the parameter lines controls the height if this panel! + */ + void AddLabel(const TCHAR *label, unsigned lines = 1) noexcept; + /** * Add a read-only multi-line control. You can use * SetMultiLineText() to update its text. From 5e1103d7516340ccdc5df91e47fdc26a15e95827 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 19 Sep 2023 21:21:02 +0200 Subject: [PATCH 211/403] [CMake] Form/CMakeLists.txt - move Form from Libs to Frontend --- src/Form/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Form/CMakeLists.txt b/src/Form/CMakeLists.txt index 4d1878695be..9685f28f8c0 100644 --- a/src/Form/CMakeLists.txt +++ b/src/Form/CMakeLists.txt @@ -48,7 +48,7 @@ add_library(${TARGET_NAME} ${XCSOAR_LIB_TYPE} target_link_libraries(${TARGET_NAME} PUBLIC Dialogs Renderer UIUtil) # message(FATAL_ERROR "Stop!") -set_target_properties(${TARGET_NAME} PROPERTIES FOLDER Libs) +set_target_properties(${TARGET_NAME} PROPERTIES FOLDER FrontEnd) add_dependencies(${TARGET_NAME} util) From 77cceaf50b5a870ac59675d58209760ce2cc4aa0 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 28 Feb 2024 14:56:09 +0100 Subject: [PATCH 212/403] [CMake] - change DataPath for Flaps6 This is only a private setting for August2111 --- CMakeLists.txt | 5 +++++ build/cmake/python/CMakeOpenSoar.py | 3 +-- build/cmake/python/CMakeXCSoar.py | 4 ++-- ide/msvc/OpenSoar.vcxproj.user.in | 4 ++-- ide/msvc/XCSoar.vcxproj.user.in | 4 ++-- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c19b326d2dc..ef2549034c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -485,6 +485,11 @@ add_dependencies(${TARGET_NAME} util libOpenSoar) # isn't possible: set_target_properties(ALL_BUILD PROPERTIES FOLDER _CMake) # isn't possible: set_target_properties(ZERO_CHECK PROPERTIES FOLDER _CMake) if (MSVC) + if (EXISTS D:/Data/OpenSoarData/August.prf) + set(OPENSOARDATA D:/Data/OpenSoarData) # this is only valid for August/Flaps6! + else () + set(OPENSOARDATA C:/OpenSoarData) + endif () message(STATUS "Configure: ${PROJECTGROUP_BINARY_DIR}/${TARGET_NAME}.vcxproj.user") configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/ide/msvc/OpenSoar.vcxproj.user.in" diff --git a/build/cmake/python/CMakeOpenSoar.py b/build/cmake/python/CMakeOpenSoar.py index ab4c0e2d9e9..dbb3dac3cfa 100644 --- a/build/cmake/python/CMakeOpenSoar.py +++ b/build/cmake/python/CMakeOpenSoar.py @@ -385,8 +385,7 @@ def create_opensoar(args): elif toolchain.startswith('clang'): opensoar_app = project_name + '-Clang.exe' - arguments = [build_dir + '/' + opensoar_app, '-1400x700', '-fly', '-profile=D:/Data/XCSoarData/August.prf', '-datapath=D:/Data/XCSoarData'] - # arguments = [build_dir + '/' + opensoar_app, '-1400x700', '-fly', '-profile=August5.prf'] + arguments = [build_dir + '/' + opensoar_app, '-1400x700', '-fly', '-profile=D:/Data/OpenSoarData/August.prf', '-datapath=D:/Data/OpenSoarData'] if not os.path.exists(arguments[0]): print("App '", arguments[0], "' doesn't exist!") creation = 0 diff --git a/build/cmake/python/CMakeXCSoar.py b/build/cmake/python/CMakeXCSoar.py index 2920e229ae1..4db4733bffa 100644 --- a/build/cmake/python/CMakeXCSoar.py +++ b/build/cmake/python/CMakeXCSoar.py @@ -367,8 +367,8 @@ def create_xcsoar(args): xcsoar_app = project_name + '-Clang.exe' # XCSoarAug-MinGW.exe -1400x700' -fly -profile=D:\Data\XCSoarData\August.prf -datapath=D:/XCSoarData/Data - arguments = [build_dir + '/' + xcsoar_app, '-1400x700', '-fly', '-profile=D:/Data/XCSoarData/August.prf', '-datapath=D:/Data/XCSoarData'] - # arguments = [build_dir + '/' + xcsoar_app, '-1400x700', '-fly', '-profile=D:/Data/XCSoarData/August2.prf', '-datapath=D:/Data/XCSoarData'] + arguments = [build_dir + '/' + xcsoar_app, '-1400x700', '-fly', '-profile=D:/Data/OpenSoarData/August.prf', '-datapath=D:/Data/OpenSoarData'] + # arguments = [build_dir + '/' + xcsoar_app, '-1400x700', '-fly', '-profile=D:/Data/OpenSoarData/August2.prf', '-datapath=D:/Data/OpenSoarData'] # arguments = [build_dir + '/' + xcsoar_app, '-1400x700', '-fly', '-profile=August5.prf'] if not os.path.exists(arguments[0]): print("App 'arguments[0]' doesn't exist!") diff --git a/ide/msvc/OpenSoar.vcxproj.user.in b/ide/msvc/OpenSoar.vcxproj.user.in index 39abae3d606..21c897d4cc7 100644 --- a/ide/msvc/OpenSoar.vcxproj.user.in +++ b/ide/msvc/OpenSoar.vcxproj.user.in @@ -1,11 +1,11 @@  - -fly -1400x700 -profile=D:/Data/XCSoarData/August.prf -datapath=D:/Data/XCSoarData + -fly -1400x700 -profile=@OPENSOARDATA@/August.prf -datapath=@OPENSOARDATA@ WindowsLocalDebugger - -fly -1400x700 -profile=D:/Data/XCSoarData/August.prf -datapath=D:/Data/XCSoarData + -fly -1400x700 -profile=@OPENSOARDATA@/August.prf -datapath=@OPENSOARDATA@ WindowsLocalDebugger \ No newline at end of file diff --git a/ide/msvc/XCSoar.vcxproj.user.in b/ide/msvc/XCSoar.vcxproj.user.in index 39abae3d606..c7134100cc0 100644 --- a/ide/msvc/XCSoar.vcxproj.user.in +++ b/ide/msvc/XCSoar.vcxproj.user.in @@ -1,11 +1,11 @@  - -fly -1400x700 -profile=D:/Data/XCSoarData/August.prf -datapath=D:/Data/XCSoarData + -fly -1400x700 -profile=@XCSOARDATA@/August.prf -datapath=@XCSOARDATA@ WindowsLocalDebugger - -fly -1400x700 -profile=D:/Data/XCSoarData/August.prf -datapath=D:/Data/XCSoarData + -fly -1400x700 -profile=@XCSOARDATA@/August.prf -datapath=@XCSOARDATA@ WindowsLocalDebugger \ No newline at end of file From 2f830aaf34216152bd55329482382a60ab214cef Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 1 Mar 2024 20:00:05 +0100 Subject: [PATCH 213/403] LocalPath.cpp - change standard path to OpenSoarData instead of .xcsoar, XCSoarData and so on --- src/LocalPath.cpp | 51 ++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/src/LocalPath.cpp b/src/LocalPath.cpp index a97575e943f..8b433a23cda 100644 --- a/src/LocalPath.cpp +++ b/src/LocalPath.cpp @@ -39,7 +39,7 @@ #include #endif -#define XCSDATADIR "XCSoarData" +#define OPENSOAR_DATADIR "OpenSoarData" /** * This is the partition that the Kobo software mounts on PCs @@ -47,7 +47,7 @@ #define KOBO_USER_DATA "/mnt/onboard" /** - * A list of XCSoarData directories. The first one is the primary + * A list of OpenSoarData directories. The first one is the primary * one, where "%LOCAL_PATH%\\" refers to. */ static std::list data_paths; @@ -174,7 +174,7 @@ ContractLocalPath(Path src) noexcept #ifdef _WIN32 /** - * Find a XCSoarData folder in the same location as the executable. + * Find a OpenSoarData folder in the same location as the executable. */ [[gnu::pure]] static AllocatedPath @@ -184,7 +184,7 @@ FindDataPathAtModule(HMODULE hModule) noexcept if (GetModuleFileName(hModule, buffer, MAX_PATH) <= 0) return nullptr; - ReplaceBaseName(buffer, _T(XCSDATADIR)); + ReplaceBaseName(buffer, _T(OPENSOAR_DATADIR)); return Directory::Exists(Path(buffer)) ? AllocatedPath(buffer) : nullptr; @@ -197,9 +197,9 @@ FindDataPaths() noexcept { std::list result; - /* Kobo: hard-coded XCSoarData path */ + /* Kobo: hard-coded OpenSoarData path */ if constexpr (IsKobo()) { - result.emplace_back(_T(KOBO_USER_DATA DIR_SEPARATOR_S XCSDATADIR)); + result.emplace_back(_T(KOBO_USER_DATA DIR_SEPARATOR_S OPENSOAR_DATADIR)); return result; } @@ -209,18 +209,18 @@ FindDataPaths() noexcept const auto env = Java::GetEnv(); for (auto &path : context->GetExternalFilesDirs(env)) { - __android_log_print(ANDROID_LOG_DEBUG, "XCSoar", + __android_log_print(ANDROID_LOG_DEBUG, "OpenSoar", "Context.getExternalFilesDirs()='%s'", path.c_str()); result.emplace_back(std::move(path)); } if (auto path = Environment::GetExternalStoragePublicDirectory(env, - "XCSoarData"); + "OpenSoarData"); path != nullptr) { const bool writable = access(path.c_str(), W_OK) == 0; - __android_log_print(ANDROID_LOG_DEBUG, "XCSoar", + __android_log_print(ANDROID_LOG_DEBUG, "OpenSoar", "Environment.getExternalStoragePublicDirectory()='%s'%s", path.c_str(), writable ? "" : " (not accessible)"); @@ -238,22 +238,22 @@ FindDataPaths() noexcept } #ifdef _WIN32 - /* look for a XCSoarData directory in the same directory as - XCSoar.exe */ + /* look for a OpenSoarData directory in the same directory as + OpenSoar.exe */ if (auto path = FindDataPathAtModule(nullptr); path != nullptr) result.emplace_back(std::move(path)); - /* Windows: use "My Documents\XCSoarData" */ + /* Windows: use "My Documents\OpenSoarData" */ { TCHAR buffer[MAX_PATH]; if (SHGetSpecialFolderPath(nullptr, buffer, CSIDL_PERSONAL, result.empty())) - result.emplace_back(AllocatedPath::Build(buffer, _T(XCSDATADIR))); + result.emplace_back(AllocatedPath::Build(buffer, _T(OPENSOAR_DATADIR))); } #endif // _WIN32 #ifdef HAVE_POSIX - /* on Unix, use ~/.xcsoar */ + /* on Unix, use ~/OpenSoarData too */ if (const char *home = getenv("HOME"); home != nullptr) { #ifdef __APPLE__ /* Mac OS X users are not used to dot-files in their home @@ -263,21 +263,21 @@ FindDataPaths() noexcept folder can also be accessed via iTunes, if UIFileSharingEnabled is set to YES in Info.plist */ #if (TARGET_OS_IPHONE) - constexpr const char *in_home = "Documents" XCSDATADIR; + constexpr const char *in_home = "Documents" OPENSOAR_DATADIR; #else - constexpr const char *in_home = XCSDATADIR; + constexpr const char *in_home = OPENSOAR_DATADIR; #endif #else // !APPLE - constexpr const char *in_home = ".xcsoar"; + constexpr const char *in_home = OPENSOAR_DATADIR; #endif result.emplace_back(AllocatedPath::Build(Path(home), in_home)); } #ifndef __APPLE__ - /* Linux (and others): allow global configuration in /etc/xcsoar */ - if (Directory::Exists(Path{"/etc/xcsoar"})) - result.emplace_back(Path{"/etc/xcsoar"}); + /* Linux (and others): allow global configuration in /etc/opensoar */ + if (Directory::Exists(Path{"/etc/opensoar"})) + result.emplace_back(Path{"/etc/opensoar"}); #endif // !APPLE #endif // HAVE_POSIX @@ -309,16 +309,17 @@ MakeCacheDirectory(const TCHAR *name) noexcept void InitialiseDataPath() { - data_paths = FindDataPaths(); - if (data_paths.empty()) - throw std::runtime_error("No data path found"); - + if (data_paths.empty()) { + data_paths = FindDataPaths(); + if (data_paths.empty()) + throw std::runtime_error("No data path found"); + } #ifdef ANDROID cache_path = context->GetExternalCacheDir(Java::GetEnv()); if (cache_path == nullptr) throw std::runtime_error("No Android cache directory"); - // TODO: delete the old cache directory in XCSoarData? + // TODO: delete the old cache directory in OpenSoarData? #else cache_path = LocalPath(_T("cache")); #endif From 53918b874de7506a591f1a3dddcce2ca66b486cf Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 7 Mar 2024 10:14:48 +0100 Subject: [PATCH 214/403] LogFile.cpp - use "OpenSoar" in debug log instead of "XCSoar" --- src/LogFile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LogFile.cpp b/src/LogFile.cpp index f1c928152b1..ae8b90feaf4 100644 --- a/src/LogFile.cpp +++ b/src/LogFile.cpp @@ -70,7 +70,7 @@ void LogString(std::string_view s) noexcept { #ifdef ANDROID - __android_log_print(ANDROID_LOG_INFO, "XCSoar", "%.*s", + __android_log_print(ANDROID_LOG_INFO, "OpenSoar", "%.*s", int(s.size()), s.data()); #elif defined(HAVE_POSIX) && !defined(NDEBUG) fprintf(stderr, "%.*s\n", From ca2edd03747d124af4e48b412cb3d38bf2f16451 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 27 Feb 2024 11:27:13 +0100 Subject: [PATCH 215/403] DigitEntry - add cursor overflow callbacks --- src/Form/DigitEntry.cpp | 23 +++++++++++++++++------ src/Form/DigitEntry.hpp | 9 +++++++++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/Form/DigitEntry.cpp b/src/Form/DigitEntry.cpp index ab4de246f48..b8947f1d110 100644 --- a/src/Form/DigitEntry.cpp +++ b/src/Form/DigitEntry.cpp @@ -901,16 +901,19 @@ bool DigitEntry::OnKeyCheck(unsigned key_code) const noexcept { switch (key_code) { - case KEY_UP: - case KEY_DOWN: + case KEY_UP: // 38 + case KEY_DOWN: // 40 return true; - case KEY_LEFT: + case KEY_LEFT: // 37 return cursor > 0; - case KEY_RIGHT: + case KEY_RIGHT: // 39 return cursor < length - 1; + // case KEY_RETURN: // 13 + // case KEY_ESCAPE: // 27 + default: return PaintWindow::OnKeyCheck(key_code); } @@ -934,14 +937,22 @@ DigitEntry::OnKeyDown(unsigned key_code) noexcept case KEY_LEFT: i = FindEditableLeft(cursor - 1); - if (i >= 0) + if (i >= 0) { SetCursor(i); + } else if (left_overflow) { + left_overflow(); + cursor = length - 1; + } return true; case KEY_RIGHT: i = FindEditableRight(cursor + 1); - if (i >= 0) + if (i >= 0) { SetCursor(i); + } else if (right_overflow) { + right_overflow(); + cursor = 0; + } return true; case KEY_RETURN: diff --git a/src/Form/DigitEntry.hpp b/src/Form/DigitEntry.hpp index 538911d7a17..32316c7ef6e 100644 --- a/src/Form/DigitEntry.hpp +++ b/src/Form/DigitEntry.hpp @@ -151,6 +151,9 @@ class DigitEntry : public PaintWindow { std::function callback; + std::function left_overflow; + std::function right_overflow; + /** * Total number of columns. */ @@ -214,6 +217,12 @@ class DigitEntry : public PaintWindow { void SetCallback(std::function _callback) noexcept { callback = std::move(_callback); } + void SetLeftOverflow(std::function _callback) noexcept { + left_overflow = std::move(_callback); + } + void SetRightOverflow(std::function _callback) noexcept { + right_overflow = std::move(_callback); + } void SetCursor(unsigned cursor); From 412abec28122d3a0ee60278f839c6b34bbb17cbf Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 27 Feb 2024 16:05:56 +0100 Subject: [PATCH 216/403] Dialogs/NumberEntry.cpp - use callbacks and new DigitEntry with NumberEntry, AngleEntry and DateEntry --- src/Dialogs/DateEntry.cpp | 11 ++++++++--- src/Dialogs/NumberEntry.cpp | 37 +++++++++++++++++++++++++++++++------ src/Dialogs/NumberEntry.hpp | 2 ++ src/Form/Form.hpp | 11 +++++++++++ 4 files changed, 52 insertions(+), 9 deletions(-) diff --git a/src/Dialogs/DateEntry.cpp b/src/Dialogs/DateEntry.cpp index de572334917..de0049cb54f 100644 --- a/src/Dialogs/DateEntry.cpp +++ b/src/Dialogs/DateEntry.cpp @@ -38,15 +38,20 @@ DateEntryDialog(const TCHAR *caption, BrokenDate &value, entry->SetCallback(dialog.MakeModalResultCallback(mrOK)); /* create buttons */ - dialog.AddButton(_("OK"), mrOK); + dialog.first_button = dialog.AddButton(_("OK"), mrOK); dialog.AddButton(_("Cancel"), mrCancel); - dialog.AddButton(_("Reset"), [&entry = *entry, start_value = value](){ + // dialog.AddButton(_("OK"), mrOK); + // dialog.AddButton(_("Cancel"), mrCancel); + + dialog.last_button = + dialog.AddButton(_("Reset"), [&entry = *entry, start_value = value]() { entry.SetValue(start_value); // the start value }); if (nullable) - dialog.AddButton(_("Clear"), [&entry=*entry](){ + dialog.last_button = dialog.AddButton( + _("Clear"), [&entry = *entry]() { entry.SetInvalid(); }); diff --git a/src/Dialogs/NumberEntry.cpp b/src/Dialogs/NumberEntry.cpp index f06f1159bc0..5c6849a2490 100644 --- a/src/Dialogs/NumberEntry.cpp +++ b/src/Dialogs/NumberEntry.cpp @@ -9,6 +9,18 @@ #include "Math/Angle.hpp" #include "UIGlobals.hpp" +// bool LeftOverflowCallback() noexcept { +// last_button->SetFocus(); +// return true; +// } +// +// bool RightOverflowCallback() noexcept { +// first_button->SetFocus(); +// return true; +// } + +// ---------------------------------------------------------------------------- +/** NumberEntryDialog for big signed numbers -> SIGNED with +/-! */ bool NumberEntryDialog(const TCHAR *caption, int &value, unsigned length) @@ -33,11 +45,14 @@ NumberEntryDialog(const TCHAR *caption, length, 0); entry->Resize(entry->GetRecommendedSize()); entry->SetValue(value); + entry->SetCallback(dialog.MakeModalResultCallback(mrOK)); + entry->SetLeftOverflow(dialog.SetFocusButtonCallback(dialog.last_button)); + entry->SetRightOverflow(dialog.SetFocusButtonCallback(dialog.first_button)); /* create buttons */ - dialog.AddButton(_("OK"), mrOK); - dialog.AddButton(_("Cancel"), mrCancel); + dialog.first_button = dialog.AddButton(_("OK"), mrOK); + dialog.last_button = dialog.AddButton(_("Cancel"), mrCancel); /* run it */ @@ -51,6 +66,8 @@ NumberEntryDialog(const TCHAR *caption, return true; } +// ---------------------------------------------------------------------------- +/** NumberEntryDialog for big unsigned numbers -> UNSIGNED! */ bool NumberEntryDialog(const TCHAR *caption, unsigned &value, unsigned length) @@ -75,11 +92,14 @@ NumberEntryDialog(const TCHAR *caption, length, 0); entry->Resize(entry->GetRecommendedSize()); entry->SetValue(value); + entry->SetCallback(dialog.MakeModalResultCallback(mrOK)); + entry->SetLeftOverflow(dialog.SetFocusButtonCallback(dialog.last_button)); + entry->SetRightOverflow(dialog.SetFocusButtonCallback(dialog.first_button)); /* create buttons */ - dialog.AddButton(_("OK"), mrOK); - dialog.AddButton(_("Cancel"), mrCancel); + dialog.first_button = dialog.AddButton(_("OK"), mrOK); + dialog.last_button = dialog.AddButton(_("Cancel"), mrCancel); /* run it */ @@ -93,6 +113,8 @@ NumberEntryDialog(const TCHAR *caption, return true; } +// ---------------------------------------------------------------------------- +/** NumberEntryDialog for big angle values */ bool AngleEntryDialog(const TCHAR *caption, Angle &value) { @@ -115,11 +137,14 @@ AngleEntryDialog(const TCHAR *caption, Angle &value) entry->CreateAngle(client_area, client_area.GetClientRect(), control_style); entry->Resize(entry->GetRecommendedSize()); entry->SetValue(value); + entry->SetCallback(dialog.MakeModalResultCallback(mrOK)); + entry->SetLeftOverflow(dialog.SetFocusButtonCallback(dialog.last_button)); + entry->SetRightOverflow(dialog.SetFocusButtonCallback(dialog.first_button)); /* create buttons */ - dialog.AddButton(_("OK"), mrOK); - dialog.AddButton(_("Cancel"), mrCancel); + dialog.first_button = dialog.AddButton(_("OK"), mrOK); + dialog.last_button = dialog.AddButton(_("Cancel"), mrCancel); /* run it */ diff --git a/src/Dialogs/NumberEntry.hpp b/src/Dialogs/NumberEntry.hpp index 1bf8096827a..3966dd1f55c 100644 --- a/src/Dialogs/NumberEntry.hpp +++ b/src/Dialogs/NumberEntry.hpp @@ -7,10 +7,12 @@ class Angle; +/** NumberEntryDialog for big unsigned numbers -> SIGNED with +/-! */ bool NumberEntryDialog(const TCHAR *caption, int &value, unsigned length); +/** NumberEntryDialog for big unsigned numbers -> UNSIGNED! */ bool NumberEntryDialog(const TCHAR *caption, unsigned &value, unsigned length); diff --git a/src/Form/Form.hpp b/src/Form/Form.hpp index 54f94669c6a..89f98ffda2d 100644 --- a/src/Form/Form.hpp +++ b/src/Form/Form.hpp @@ -6,6 +6,7 @@ #include "ui/window/ContainerWindow.hpp" #include "ui/window/SolidContainerWindow.hpp" #include "util/tstring.hpp" +#include "Form/Button.hpp" #include #include @@ -28,6 +29,9 @@ class WndForm : public ContainerWindow typedef std::function KeyDownFunction; typedef std::function CharacterFunction; + Button *first_button = nullptr; + Button *last_button = nullptr; + protected: const DialogLook &look; @@ -137,6 +141,13 @@ class WndForm : public ContainerWindow }; } + auto SetFocusButtonCallback(Button *button) noexcept { + return [this, button]() { + if (button) + button->SetFocus(); + }; + } + /** * Enables "modeless": dialog will close if mouse is clicked * anywhere on screen outside the dialog From ce5ecb2b8126241ba496e5896664830fb0c539ff Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 28 Feb 2024 16:40:26 +0100 Subject: [PATCH 217/403] Form/DigitEntry.cpp - mark all used keys as to check --- src/Form/DigitEntry.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/Form/DigitEntry.cpp b/src/Form/DigitEntry.cpp index b8947f1d110..a72700bf041 100644 --- a/src/Form/DigitEntry.cpp +++ b/src/Form/DigitEntry.cpp @@ -901,18 +901,13 @@ bool DigitEntry::OnKeyCheck(unsigned key_code) const noexcept { switch (key_code) { - case KEY_UP: // 38 - case KEY_DOWN: // 40 + case KEY_UP: + case KEY_DOWN: + case KEY_LEFT: + case KEY_RIGHT: + case KEY_RETURN: return true; - case KEY_LEFT: // 37 - return cursor > 0; - - case KEY_RIGHT: // 39 - return cursor < length - 1; - - // case KEY_RETURN: // 13 - // case KEY_ESCAPE: // 27 default: return PaintWindow::OnKeyCheck(key_code); From c4e6bb32f081bfd8aefab6ca69f52079ac27e4b8 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 28 Feb 2024 19:44:28 +0100 Subject: [PATCH 218/403] Dialogs/NumberEntry.cpp - create different dialogs for different data types --- src/Dialogs/NumberEntry.cpp | 159 +++++++++++------------------------- 1 file changed, 49 insertions(+), 110 deletions(-) diff --git a/src/Dialogs/NumberEntry.cpp b/src/Dialogs/NumberEntry.cpp index 5c6849a2490..dd5fe095202 100644 --- a/src/Dialogs/NumberEntry.cpp +++ b/src/Dialogs/NumberEntry.cpp @@ -9,59 +9,64 @@ #include "Math/Angle.hpp" #include "UIGlobals.hpp" -// bool LeftOverflowCallback() noexcept { -// last_button->SetFocus(); -// return true; -// } -// -// bool RightOverflowCallback() noexcept { -// first_button->SetFocus(); -// return true; -// } +enum DataType{ + DATA_SIGNED, + DATA_UNSIGNED, + DATA_ANGLE, +}; // ---------------------------------------------------------------------------- -/** NumberEntryDialog for big signed numbers -> SIGNED with +/-! */ +template bool -NumberEntryDialog(const TCHAR *caption, - int &value, unsigned length) +NumberEntryDialog(TWidgetDialog &dialog, + const DataType type, + T &value, unsigned length) { - /* create the dialog */ - - const DialogLook &look = UIGlobals::GetDialogLook(); - - TWidgetDialog - dialog(WidgetDialog::Auto{}, UIGlobals::GetMainWindow(), look, caption); - ContainerWindow &client_area = dialog.GetClientAreaWindow(); - /* create the input control */ - + //create the input control WindowStyle control_style; control_style.Hide(); control_style.TabStop(); - auto entry = std::make_unique(look); - entry->CreateSigned(client_area, client_area.GetClientRect(), control_style, - length, 0); + auto entry = std::make_unique(UIGlobals::GetDialogLook()); + switch (type) { + case DATA_SIGNED: + entry->CreateSigned(client_area, client_area.GetClientRect(), control_style, + length, 0); + break; + case DATA_UNSIGNED: + entry->CreateUnsigned(client_area, client_area.GetClientRect(), + control_style, length, 0); + break; + } entry->Resize(entry->GetRecommendedSize()); entry->SetValue(value); entry->SetCallback(dialog.MakeModalResultCallback(mrOK)); - entry->SetLeftOverflow(dialog.SetFocusButtonCallback(dialog.last_button)); - entry->SetRightOverflow(dialog.SetFocusButtonCallback(dialog.first_button)); - - /* create buttons */ + // create buttons dialog.first_button = dialog.AddButton(_("OK"), mrOK); dialog.last_button = dialog.AddButton(_("Cancel"), mrCancel); - /* run it */ + // set handler for cursor overflow + entry->SetLeftOverflow(dialog.SetFocusButtonCallback(dialog.last_button)); + entry->SetRightOverflow(dialog.SetFocusButtonCallback(dialog.first_button)); + // run it dialog.SetWidget(std::move(entry)); - bool result = dialog.ShowModal() == mrOK; - if (!result) - return false; + return (dialog.ShowModal() == mrOK); +} +// ---------------------------------------------------------------------------- +/** NumberEntryDialog for big signed numbers -> SIGNED with +/-! */ +bool +NumberEntryDialog(const TCHAR *caption, int &value, unsigned length) { + TWidgetDialog dialog(WidgetDialog::Auto{}, + UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), caption); + if (!NumberEntryDialog(dialog, DATA_SIGNED, value, length)) + return false; value = ((DigitEntry &)dialog.GetWidget().GetWindow()).GetIntegerValue(); return true; } @@ -69,46 +74,12 @@ NumberEntryDialog(const TCHAR *caption, // ---------------------------------------------------------------------------- /** NumberEntryDialog for big unsigned numbers -> UNSIGNED! */ bool -NumberEntryDialog(const TCHAR *caption, - unsigned &value, unsigned length) -{ - /* create the dialog */ - - const DialogLook &look = UIGlobals::GetDialogLook(); - - TWidgetDialog - dialog(WidgetDialog::Auto{}, UIGlobals::GetMainWindow(), look, caption); - - ContainerWindow &client_area = dialog.GetClientAreaWindow(); - - /* create the input control */ - - WindowStyle control_style; - control_style.Hide(); - control_style.TabStop(); - - auto entry = std::make_unique(look); - entry->CreateUnsigned(client_area, client_area.GetClientRect(), control_style, - length, 0); - entry->Resize(entry->GetRecommendedSize()); - entry->SetValue(value); - entry->SetCallback(dialog.MakeModalResultCallback(mrOK)); - entry->SetLeftOverflow(dialog.SetFocusButtonCallback(dialog.last_button)); - entry->SetRightOverflow(dialog.SetFocusButtonCallback(dialog.first_button)); - - /* create buttons */ - - dialog.first_button = dialog.AddButton(_("OK"), mrOK); - dialog.last_button = dialog.AddButton(_("Cancel"), mrCancel); - - /* run it */ - - dialog.SetWidget(std::move(entry)); - - bool result = dialog.ShowModal() == mrOK; - if (!result) - return false; - +NumberEntryDialog(const TCHAR *caption, unsigned &value, unsigned length) { + TWidgetDialog dialog(WidgetDialog::Auto{}, + UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), caption); + if (!NumberEntryDialog(dialog, DATA_UNSIGNED, value, length)) + return false; value = ((DigitEntry &)dialog.GetWidget().GetWindow()).GetUnsignedValue(); return true; } @@ -116,44 +87,12 @@ NumberEntryDialog(const TCHAR *caption, // ---------------------------------------------------------------------------- /** NumberEntryDialog for big angle values */ bool -AngleEntryDialog(const TCHAR *caption, Angle &value) -{ - /* create the dialog */ - - const DialogLook &look = UIGlobals::GetDialogLook(); - - TWidgetDialog - dialog(WidgetDialog::Auto{}, UIGlobals::GetMainWindow(), look, caption); - - ContainerWindow &client_area = dialog.GetClientAreaWindow(); - - /* create the input control */ - - WindowStyle control_style; - control_style.Hide(); - control_style.TabStop(); - - auto entry = std::make_unique(look); - entry->CreateAngle(client_area, client_area.GetClientRect(), control_style); - entry->Resize(entry->GetRecommendedSize()); - entry->SetValue(value); - entry->SetCallback(dialog.MakeModalResultCallback(mrOK)); - entry->SetLeftOverflow(dialog.SetFocusButtonCallback(dialog.last_button)); - entry->SetRightOverflow(dialog.SetFocusButtonCallback(dialog.first_button)); - - /* create buttons */ - - dialog.first_button = dialog.AddButton(_("OK"), mrOK); - dialog.last_button = dialog.AddButton(_("Cancel"), mrCancel); - - /* run it */ - - dialog.SetWidget(std::move(entry)); - - bool result = dialog.ShowModal() == mrOK; - if (!result) - return false; - +AngleEntryDialog(const TCHAR *caption, Angle &value) { + TWidgetDialog dialog(WidgetDialog::Auto{}, + UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), caption); + if (!NumberEntryDialog(dialog, DATA_ANGLE, value, 0)) + return false; value = ((DigitEntry &)dialog.GetWidget().GetWindow()).GetAngleValue(); return true; } From 118f1e3762d68d06c6c961ba24e9f0d7f76f17da Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 28 Feb 2024 19:48:11 +0100 Subject: [PATCH 219/403] Dialogs/DateEntry.cpp - move focus through the base buttons too... not only through the date items --- src/Dialogs/DateEntry.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Dialogs/DateEntry.cpp b/src/Dialogs/DateEntry.cpp index de0049cb54f..e84452b50cf 100644 --- a/src/Dialogs/DateEntry.cpp +++ b/src/Dialogs/DateEntry.cpp @@ -13,8 +13,7 @@ bool DateEntryDialog(const TCHAR *caption, BrokenDate &value, bool nullable) { - /* create the dialog */ - + // create the dialog const DialogLook &look = UIGlobals::GetDialogLook(); TWidgetDialog dialog(WidgetDialog::Auto{}, @@ -23,8 +22,7 @@ DateEntryDialog(const TCHAR *caption, BrokenDate &value, ContainerWindow &client_area = dialog.GetClientAreaWindow(); - /* create the input control */ - + // create the input control WindowStyle control_style; control_style.Hide(); control_style.TabStop(); @@ -37,13 +35,10 @@ DateEntryDialog(const TCHAR *caption, BrokenDate &value, entry->SetValue(value); entry->SetCallback(dialog.MakeModalResultCallback(mrOK)); - /* create buttons */ + // create buttons dialog.first_button = dialog.AddButton(_("OK"), mrOK); dialog.AddButton(_("Cancel"), mrCancel); - // dialog.AddButton(_("OK"), mrOK); - // dialog.AddButton(_("Cancel"), mrCancel); - dialog.last_button = dialog.AddButton(_("Reset"), [&entry = *entry, start_value = value]() { entry.SetValue(start_value); // the start value @@ -55,8 +50,11 @@ DateEntryDialog(const TCHAR *caption, BrokenDate &value, entry.SetInvalid(); }); - /* run it */ + // set handler for cursor overflow + entry->SetLeftOverflow(dialog.SetFocusButtonCallback(dialog.last_button)); + entry->SetRightOverflow(dialog.SetFocusButtonCallback(dialog.first_button)); + // ... and run it dialog.SetWidget(std::move(entry)); if (dialog.ShowModal() != mrOK) From 88eb2f0e7d9485436cbe6c27b97837cdd410457f Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 7 Feb 2024 08:59:56 +0100 Subject: [PATCH 220/403] Device/PortMonitor.cpp - increase line length maximum --- src/Dialogs/Device/PortMonitor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Dialogs/Device/PortMonitor.cpp b/src/Dialogs/Device/PortMonitor.cpp index 6f8d89a7739..96c8c58de62 100644 --- a/src/Dialogs/Device/PortMonitor.cpp +++ b/src/Dialogs/Device/PortMonitor.cpp @@ -51,7 +51,7 @@ class PortTerminalBridge final : public DataHandler { private: void OnNotification() noexcept { while (true) { - std::array data; + std::array data; size_t length; { From 280bc5d49fb696fb5406a1ca0552cbd5c89223f9 Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 1 Mar 2024 16:57:58 +0100 Subject: [PATCH 221/403] OpenVarioDevice.cpp - use datapath data/OpenSoarData instead of data only --- src/OpenVario/OpenVarioBaseMenu.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenVario/OpenVarioBaseMenu.cpp b/src/OpenVario/OpenVarioBaseMenu.cpp index 968b3026c5d..455eb4b9727 100644 --- a/src/OpenVario/OpenVarioBaseMenu.cpp +++ b/src/OpenVario/OpenVarioBaseMenu.cpp @@ -111,7 +111,7 @@ class MainMenuWidget final if (ovdevice.settings.find("OpenSoarData") != ovdevice.settings.end()) datapath = ovdevice.settings.find("OpenSoarData")->second; else - datapath = ovdevice.GetDataPath().ToUTF8() + "/OpenSoarData"; + datapath = ovdevice.GetDataPath().ToUTF8() + "/OpenSoarData/"; int ret_value = StartSoarExe("OpenSoar", datapath); @@ -142,7 +142,7 @@ class MainMenuWidget final if (ovdevice.settings.find("XCSoarData") != ovdevice.settings.end()) datapath = ovdevice.settings.find("XCSoarData")->second; else - datapath = ovdevice.GetDataPath().ToUTF8() + "/XCSoarData"; + datapath = ovdevice.GetDataPath().ToUTF8() + "/XCSoarData/"; return StartSoarExe("xcsoar", datapath); } From 554c3e394f12efe753e9da5828a205c873f0831f Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 1 Mar 2024 17:38:38 +0100 Subject: [PATCH 222/403] OpenSoar.cpp - before starting any operation (InitialiseDataPath..) read args of command line to set correct pathes and so on... --- src/OpenSoar.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/OpenSoar.cpp b/src/OpenSoar.cpp index ad2eed401ea..3d1207dc968 100644 --- a/src/OpenSoar.cpp +++ b/src/OpenSoar.cpp @@ -142,15 +142,6 @@ WinMain(HINSTANCE hInstance, [[maybe_unused]] HINSTANCE hPrevInstance, [[maybe_unused]] int nCmdShow) #endif try { -#ifdef USE_WIN32_RESOURCES - ResourceLoader::Init(hInstance); -#endif - - InitialiseDataPath(); - - // Write startup note + version to logfile - LogFormat(_T("Starting OpenSoar %s"), OpenSoar_ProductToken); - // Read options from the command line { #ifdef _WIN32 @@ -161,6 +152,14 @@ try { CommandLine::Parse(args); } + InitialiseDataPath(); + +#ifdef USE_WIN32_RESOURCES + ResourceLoader::Init(hInstance); +#endif + // Write startup note + version to logfile + LogFormat(_T("Starting OpenSoar %s"), OpenSoar_ProductToken); + int ret = Main(); #if defined(__APPLE__) && TARGET_OS_IPHONE From 15f7795fb1f23d1bba746219472946ae8e0491f5 Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 1 Mar 2024 18:47:13 +0100 Subject: [PATCH 223/403] OpenVarioDevice.cpp -remove wrong SetPrimaryDataPath --- src/OpenVario/System/OpenVarioDevice.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/OpenVario/System/OpenVarioDevice.cpp b/src/OpenVario/System/OpenVarioDevice.cpp index 899224fadfb..51f55b7fecc 100644 --- a/src/OpenVario/System/OpenVarioDevice.cpp +++ b/src/OpenVario/System/OpenVarioDevice.cpp @@ -94,10 +94,8 @@ OpenVario_Device::Initialise() noexcept { internal_config = AllocatedPath::Build(home_path, Path(_T("ov-internal.cfg"))); #endif - - SetPrimaryDataPath(data_path); //---------------------------- - LogFormat("data_path = %s", data_path.ToUTF8().c_str()); + LogFormat("data_path (base) = %s", data_path.ToUTF8().c_str()); #ifdef DEBUG_OPENVARIO LogFormat("home_path = %s", home_path.ToUTF8().c_str()); LogFormat("settings_config = %s", settings_config.ToUTF8().c_str()); From 71cb051e54e459a9498da86ff5ce4a6d6dfa3950 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 5 Mar 2024 23:32:37 +0100 Subject: [PATCH 224/403] ContainerWindow, InputEventsActions - use Set- and GetExitValue in all systems --- src/Input/InputEventsActions.cpp | 2 -- src/ui/window/ContainerWindow.cpp | 4 +--- src/ui/window/ContainerWindow.hpp | 6 +----- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/Input/InputEventsActions.cpp b/src/Input/InputEventsActions.cpp index 6c4bb13261e..291fa42108b 100644 --- a/src/Input/InputEventsActions.cpp +++ b/src/Input/InputEventsActions.cpp @@ -625,7 +625,6 @@ InputEvents::eventBrightness([[maybe_unused]] const TCHAR *misc) void InputEvents::eventExit([[maybe_unused]] const TCHAR *misc) { -#ifdef IS_OPENVARIO if (UI::TopWindow::GetExitValue() == 0) { if (StringIsEqual(misc, _T("system"))) { // return value on UNIX(32) is only a Byte? @@ -636,7 +635,6 @@ InputEvents::eventExit([[maybe_unused]] const TCHAR *misc) UI::TopWindow::SetExitValue(202); // 20002); } } -#endif UIActions::SignalShutdown(false); } diff --git a/src/ui/window/ContainerWindow.cpp b/src/ui/window/ContainerWindow.cpp index c8ccd23fdbb..c8526999ca2 100644 --- a/src/ui/window/ContainerWindow.cpp +++ b/src/ui/window/ContainerWindow.cpp @@ -3,9 +3,7 @@ #include "ContainerWindow.hpp" -#ifdef IS_OPENVARIO - unsigned ContainerWindow::exit_value = 0; -#endif +unsigned ContainerWindow::exit_value = 0; void ContainerWindow::ScrollTo(const PixelRect &rc) noexcept diff --git a/src/ui/window/ContainerWindow.hpp b/src/ui/window/ContainerWindow.hpp index 11569f73237..c6e70635427 100644 --- a/src/ui/window/ContainerWindow.hpp +++ b/src/ui/window/ContainerWindow.hpp @@ -62,9 +62,7 @@ class ContainerWindow : public PaintWindow { virtual void OnPaint([[maybe_unused]] Canvas &canvas) noexcept {} #endif -#ifdef IS_OPENVARIO - static unsigned exit_value; -#endif +static unsigned exit_value; public: #ifndef USE_WINUSER @@ -165,12 +163,10 @@ class ContainerWindow : public PaintWindow { */ virtual void ScrollTo(const PixelRect &rc) noexcept; -#ifdef IS_OPENVARIO static void SetExitValue(unsigned value) { exit_value = value; } static unsigned GetExitValue(void) { return exit_value; } -#endif }; From 916e716ae8611454dba0827b93ff96485d137ac0 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 5 Mar 2024 23:27:46 +0100 Subject: [PATCH 225/403] Android - use CALLBACK_ instead of CALLBACK in Android too --- src/ui/event/android/Loop.cpp | 2 +- src/ui/event/android/Queue.cpp | 2 +- src/ui/window/android/TopWindow.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ui/event/android/Loop.cpp b/src/ui/event/android/Loop.cpp index ba5271e8642..bd3619bab8c 100644 --- a/src/ui/event/android/Loop.cpp +++ b/src/ui/event/android/Loop.cpp @@ -38,7 +38,7 @@ EventLoop::Dispatch(const Event &event) if (event.type == Event::TIMER) { Timer *timer = (Timer *)event.ptr; timer->Invoke(); - } else if (event.type == Event::CALLBACK) { + } else if (event.type == Event::CALLBACK_) { event.callback(event.ptr); } else if (event.type != Event::NOP) top_window.OnEvent(event); diff --git a/src/ui/event/android/Queue.cpp b/src/ui/event/android/Queue.cpp index a053c909c05..99c3c8ed60b 100644 --- a/src/ui/event/android/Queue.cpp +++ b/src/ui/event/android/Queue.cpp @@ -99,7 +99,7 @@ static bool MatchCallback(const Event &event, void *ctx) noexcept { const Event *match = (const Event *)ctx; - return event.type == Event::CALLBACK && event.callback == match->callback && + return event.type == Event::CALLBACK_ && event.callback == match->callback && event.ptr == match->ptr; } diff --git a/src/ui/window/android/TopWindow.cpp b/src/ui/window/android/TopWindow.cpp index b17be61a411..4eaa362c456 100644 --- a/src/ui/window/android/TopWindow.cpp +++ b/src/ui/window/android/TopWindow.cpp @@ -200,7 +200,7 @@ TopWindow::OnEvent(const Event &event) case Event::NOP: case Event::TIMER: - case Event::CALLBACK: + case Event::CALLBACK_: break; case Event::KEY_DOWN: From c9eefbe1d2935a4a6583ef3c8e78ee8d45deac53 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 7 Mar 2024 09:43:05 +0100 Subject: [PATCH 226/403] OpenSoar.cpp - create function Finishing for a different exit --- src/OpenSoar.cpp | 69 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 53 insertions(+), 16 deletions(-) diff --git a/src/OpenSoar.cpp b/src/OpenSoar.cpp index 3d1207dc968..1eb8ec67f29 100644 --- a/src/OpenSoar.cpp +++ b/src/OpenSoar.cpp @@ -48,6 +48,9 @@ Copyright_License { #include "io/async/AsioThread.hpp" #include "util/PrintException.hxx" +#include "UIGlobals.hpp" +#include "system/Process.hpp" + #ifdef ENABLE_SDL /* this is necessary on Mac OS X, to let libSDL bootstrap Quartz before entering our main() */ @@ -130,6 +133,29 @@ Main() return ret; } +int +Finishing(int ret) { + LogString("Finishing"); + switch (ret) { + case EXIT_REBOOT: +#ifdef IS_OPENVARIO + Run("/sbin/reboot"); + break; +#endif + return ret; + case EXIT_SHUTDOWN: +#ifdef IS_OPENVARIO + Run("/sbin/poweroff"); + break; +#endif + return ret; + case EXIT_SYSTEM: + default: + break; + } + return ret; +} + /** * Main entry point for the whole OpenSoar application */ @@ -143,37 +169,48 @@ WinMain(HINSTANCE hInstance, [[maybe_unused]] HINSTANCE hPrevInstance, #endif try { // Read options from the command line - { + int ret = -1; + bool rerun = false; + do { + { + rerun = false; #ifdef _WIN32 - Args args(GetCommandLine(), Usage); + if (UIGlobals::CommandLine == nullptr) + UIGlobals::CommandLine = GetCommandLine(); + Args args(UIGlobals::CommandLine, Usage); #else - Args args(argc, argv, Usage); + Args args(argc, argv, Usage); #endif - CommandLine::Parse(args); - } + CommandLine::Parse(args); + } - InitialiseDataPath(); + InitialiseDataPath(); #ifdef USE_WIN32_RESOURCES - ResourceLoader::Init(hInstance); + if (!ResourceLoader::Initialized()) + ResourceLoader::Init(hInstance); #endif - // Write startup note + version to logfile - LogFormat(_T("Starting OpenSoar %s"), OpenSoar_ProductToken); + // Write startup note + version to logfile + LogFormat(_T("Starting OpenSoar %s"), OpenSoar_ProductToken); - int ret = Main(); + ret = Main(); #if defined(__APPLE__) && TARGET_OS_IPHONE - /* For some reason, the app process does not exit on iOS, but a black - * screen remains, if the process is not explicitly terminated */ - exit(ret); + /* For some reason, the app process does not exit on iOS, but a black + * screen remains, if the process is not explicitly terminated */ + exit(ret); #endif #ifdef IS_OPENVARIO - if (ret == 0) - ret = UI::TopWindow::GetExitValue(); + if (ret == 0) + ret = UI::TopWindow::GetExitValue(); #endif + rerun = (ret == EXIT_RESTART); + if (rerun) + UI::TopWindow::SetExitValue(0); + } while (rerun); - return ret; + return Finishing(ret); } catch (...) { PrintException(std::current_exception()); return EXIT_FAILURE; From becfa84e70433f16947151f1bc3f7bbe97ea1159 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 6 Mar 2024 11:35:04 +0100 Subject: [PATCH 227/403] Android OpenSoar.java - Shutdown after exit if Android is rooted --- android/src/OpenSoar.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/android/src/OpenSoar.java b/android/src/OpenSoar.java index c317c85663a..3f859677975 100644 --- a/android/src/OpenSoar.java +++ b/android/src/OpenSoar.java @@ -119,6 +119,18 @@ private void quit() { setContentView(tv); finish(); + { + // This is only possible if Android is rooted! + Log.d(TAG, "ShutDown/Reboot Android?"); + try { + Process proc = + Runtime.getRuntime().exec(new String[]{"su", "-c", "reboot -p"}); + proc.waitFor(); + } catch (Exception ex) { + // Log.d(TAG, "Exception"); + ex.printStackTrace(); + } + } } final Handler quitHandler = new Handler() { From 5c97a3c7a14f8946d671063b26f8746f6436b25f Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 7 Mar 2024 10:01:44 +0100 Subject: [PATCH 228/403] default.xci - add Restart button --- Data/Input/default.xci | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Data/Input/default.xci b/Data/Input/default.xci index 2f1741c1195..84ff01153c4 100644 --- a/Data/Input/default.xci +++ b/Data/Input/default.xci @@ -1272,6 +1272,14 @@ event=AirSpace toggle label=Airspace\n$(AirspaceToggleActionName) location=34 +mode=RemoteStick +type=key +data=0 +event=Exit restart +event=Mode default +label=Restart +location=60 + # OpenVario only: mode=RemoteStick type=key From fb8de743d38ea000396b797728620e223c8bc673 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 7 Mar 2024 10:04:15 +0100 Subject: [PATCH 229/403] OpenSoar-News.md - new extensions inserted --- OpenSoar-News.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/OpenSoar-News.md b/OpenSoar-News.md index 14a4ea67b90..0cdf5400cec 100644 --- a/OpenSoar-News.md +++ b/OpenSoar-News.md @@ -1,6 +1,10 @@ OpenSoar Version 7.41.21.1 - not yet released --------------- -* start with OpenVarioBaseMenu +* End of program with (short) restart, reboot, shutdown and normal program end +* OpenVario menu inserted +* OpenVario: + - WiFi selection +* start with OpenVarioBaseMenu, but hidden for normal user only OpenSoar Version 7.41.21 - 2023/12/28 --------------- From 78fbb6edbb0295008c1db578ee51543456d0ea1b Mon Sep 17 00:00:00 2001 From: August2111 Date: Sun, 3 Mar 2024 21:56:54 +0100 Subject: [PATCH 230/403] ContainerWindow.hpp - use unique enum values for exit on an single place for InputEventsActions.cpp, MainWindow.cpp --- src/Input/InputEventsActions.cpp | 8 +++++--- src/MainWindow.cpp | 2 +- src/OpenVario/System/OpenVarioDevice.hpp | 7 ------- src/ui/window/ContainerWindow.hpp | 17 +++++++++++++++++ 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/Input/InputEventsActions.cpp b/src/Input/InputEventsActions.cpp index 291fa42108b..372dfcdfede 100644 --- a/src/Input/InputEventsActions.cpp +++ b/src/Input/InputEventsActions.cpp @@ -628,11 +628,13 @@ InputEvents::eventExit([[maybe_unused]] const TCHAR *misc) if (UI::TopWindow::GetExitValue() == 0) { if (StringIsEqual(misc, _T("system"))) { // return value on UNIX(32) is only a Byte? - UI::TopWindow::SetExitValue(200); // 20000); + UI::TopWindow::SetExitValue(EXIT_SYSTEM); // 20000); } else if (StringIsEqual(misc, _T("reboot"))) { - UI::TopWindow::SetExitValue(201); // 20001); + UI::TopWindow::SetExitValue(EXIT_REBOOT); // 20001); } else if (StringIsEqual(misc, _T("shutdown"))) { - UI::TopWindow::SetExitValue(202); // 20002); + UI::TopWindow::SetExitValue(EXIT_SHUTDOWN); // 20002); + } else if (StringIsEqual(misc, _T("restart"))) { + UI::TopWindow::SetExitValue(EXIT_RESTART); } } UIActions::SignalShutdown(false); diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 5cd5b89fe8d..19f03eed590 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -777,7 +777,7 @@ MainWindow::OnClose() noexcept #ifdef IS_OPENVARIO if (UI::TopWindow::GetExitValue() == 0) // normal exit code on OpenVario (for Test purpose!) - UI::TopWindow::SetExitValue(100); // unix has only Byte 10000); + UI::TopWindow::SetExitValue(EXIT_NORMAL); // unix has only Byte 10000); #endif return true; } diff --git a/src/OpenVario/System/OpenVarioDevice.hpp b/src/OpenVario/System/OpenVarioDevice.hpp index 55e2d36e2b4..6be4f0ea63d 100644 --- a/src/OpenVario/System/OpenVarioDevice.hpp +++ b/src/OpenVario/System/OpenVarioDevice.hpp @@ -38,13 +38,6 @@ enum class SSHStatus { TEMPORARY, }; -enum Buttons { - LAUNCH_SHELL = 203, - LAUNCH_SHELL_STOP = 204, - START_UPGRADE = 205, - LAUNCH_TOUCH_CALIBRATE = 206, -}; - class OpenVario_Device { public: OpenVario_Device() {} diff --git a/src/ui/window/ContainerWindow.hpp b/src/ui/window/ContainerWindow.hpp index c6e70635427..ef57c88e266 100644 --- a/src/ui/window/ContainerWindow.hpp +++ b/src/ui/window/ContainerWindow.hpp @@ -15,6 +15,23 @@ class Brush; class WindowReference; #endif +enum ExitValues { + EXIT_NORMAL = 100, // 20002); + EXIT_SYSTEM = 200, // 20002); + EXIT_REBOOT = 201, // 20002); + EXIT_SHUTDOWN = 202, // 20002); + + LAUNCH_SHELL = 203, + LAUNCH_SHELL_STOP = 204, + START_UPGRADE = 205, + LAUNCH_TOUCH_CALIBRATE = 206, + +#ifdef IS_OPENVARIO + EXIT_BASE_MENU = 207, +#endif + EXIT_RESTART = 208, +}; + /** * A container for more #Window objects. It is also derived from * #PaintWindow, because you might want to paint a border between the From c089158bee6559a0a2477ff963c92fc224ae4946 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 7 Mar 2024 13:00:15 +0100 Subject: [PATCH 231/403] Simulator.cpp - default mode is 'fly' => don't ask at startup anymore --- src/Simulator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Simulator.cpp b/src/Simulator.cpp index 717cc64628f..a9f4e0f1665 100644 --- a/src/Simulator.cpp +++ b/src/Simulator.cpp @@ -5,6 +5,6 @@ #ifdef SIMULATOR_AVAILABLE -bool global_simulator_flag; -bool sim_set_in_cmd_line_flag; +bool global_simulator_flag = false; +bool sim_set_in_cmd_line_flag = true; #endif From ebb9934d0cbb45635c1fbd1887f5de0f9eb3bdc7 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 7 Mar 2024 13:01:17 +0100 Subject: [PATCH 232/403] net/http/DownloadManager.cpp - set thread to 0 at delete (for Restart option) --- src/net/http/DownloadManager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/net/http/DownloadManager.cpp b/src/net/http/DownloadManager.cpp index 0aed6245cdb..293a477f2b6 100644 --- a/src/net/http/DownloadManager.cpp +++ b/src/net/http/DownloadManager.cpp @@ -296,6 +296,7 @@ Net::DownloadManager::Deinitialise() noexcept assert(thread != nullptr); delete thread; + thread = nullptr; } bool From 0b3f538b2c3da6100c7a0dccf6af1edd9b17c3c3 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 7 Mar 2024 13:03:37 +0100 Subject: [PATCH 233/403] ResourceLoader - detect initialization (for restart option) --- src/ResourceLoader.cpp | 9 +++++++-- src/ResourceLoader.hpp | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/ResourceLoader.cpp b/src/ResourceLoader.cpp index 10a3d86f71f..12fb3eb8c21 100644 --- a/src/ResourceLoader.cpp +++ b/src/ResourceLoader.cpp @@ -13,8 +13,13 @@ static HINSTANCE ResourceLoaderInstance; -void -ResourceLoader::Init(HINSTANCE hInstance) +bool +ResourceLoader::Initialized() +{ + return ResourceLoaderInstance != nullptr; +} + +void ResourceLoader::Init(HINSTANCE hInstance) { assert(ResourceLoaderInstance == nullptr); diff --git a/src/ResourceLoader.hpp b/src/ResourceLoader.hpp index f6c4ca66593..5da3b3542b0 100644 --- a/src/ResourceLoader.hpp +++ b/src/ResourceLoader.hpp @@ -16,6 +16,8 @@ class ResourceId; namespace ResourceLoader { #ifdef _WIN32 +bool Initialized(); + void Init(HINSTANCE hInstance); #endif From 6a1e3af48367f7c9bcfc46cb36f1ccc262b760a0 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 5 Mar 2024 23:22:39 +0100 Subject: [PATCH 234/403] windows/Queue.cpp - on Windows a bugfix is needed for the WM_QUIT message ... on restarted run a 2nd WM_QUIT is in the event loop and has to be removed --- src/ui/event/windows/Queue.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/ui/event/windows/Queue.cpp b/src/ui/event/windows/Queue.cpp index accc930f83d..7cfe7bbdff9 100644 --- a/src/ui/event/windows/Queue.cpp +++ b/src/ui/event/windows/Queue.cpp @@ -41,8 +41,22 @@ EventQueue::Wait(Event &event) /* check for WIN32 event */ - if (::PeekMessage(&event.msg, nullptr, 0, 0, PM_REMOVE)) + if (::PeekMessage(&event.msg, nullptr, 0, 0, PM_REMOVE)) { + #ifdef __AUGUST__ + /* TODO(August2111): + On Windows: if 'Restart' is selected a wrong (?) WM_QUIT is in the + event_loop - and closes the app immediately... ;-( + Bugfix/Workaround: With this handling the restart is OK + */ + static unsigned count = 0; + if (event.msg.message != WM_QUIT) + return true; + else + return (count++ & 1); +#else // __AUGUST__ return event.msg.message != WM_QUIT; +#endif // __AUGUST__ + } const DWORD n = 1; const LPHANDLE handles = &trigger; From b0a3b53c8d840f7a2cdcef97a9c5b243ac5c8eb1 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 7 Mar 2024 13:19:16 +0100 Subject: [PATCH 235/403] UIGlobals - add a global place for the command line to use (or change) it in the restart flow --- src/UIGlobals.cpp | 3 +++ src/UIGlobals.hpp | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/UIGlobals.cpp b/src/UIGlobals.cpp index b0848575ffa..67b6244a689 100644 --- a/src/UIGlobals.cpp +++ b/src/UIGlobals.cpp @@ -75,3 +75,6 @@ UIGlobals::GetMapLook() return CommonInterface::main_window->GetLook().map; } + + +const TCHAR *UIGlobals::CommandLine = nullptr; diff --git a/src/UIGlobals.hpp b/src/UIGlobals.hpp index b5f11d2e73e..2bcea69055a 100644 --- a/src/UIGlobals.hpp +++ b/src/UIGlobals.hpp @@ -3,6 +3,8 @@ #pragma once +#include + namespace UI { class SingleWindow; } class GlueMapWindow; struct DialogSettings; @@ -50,4 +52,7 @@ namespace UIGlobals { [[gnu::const]] const MapLook &GetMapLook(); -}; + + extern const TCHAR *CommandLine; + + }; From deb136f6ab2007193a82c8952c6dc98a0bb6cb5a Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 7 Mar 2024 13:20:47 +0100 Subject: [PATCH 236/403] UIActions.cpp - use different ShowMessage content for different Exit modes --- src/UIActions.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/UIActions.cpp b/src/UIActions.cpp index 08903396f00..83d64840ade 100644 --- a/src/UIActions.cpp +++ b/src/UIActions.cpp @@ -34,9 +34,22 @@ UIActions::CheckShutdown() if (force_shutdown) return true; - return ShowMessageBox(_("Quit program?"), _T("OpenSoar"), - MB_YESNO | MB_ICONQUESTION) == IDYES; + switch (UI::TopWindow::GetExitValue()) { + case EXIT_REBOOT: + return ShowMessageBox(_("Reboot System?"), _T("OpenSoar"), + MB_YESNO | MB_ICONQUESTION) == IDYES; + case EXIT_SHUTDOWN: + return ShowMessageBox(_("Shutdown System?"), _T("OpenSoar"), + MB_YESNO | MB_ICONQUESTION) == IDYES; + case EXIT_RESTART: + return ShowMessageBox(_("Short Restart?"), _T("OpenSoar"), + MB_YESNO | MB_ICONQUESTION) == IDYES; + case EXIT_SYSTEM: + default: + return ShowMessageBox(_("Quit program?"), _T("OpenSoar"), + MB_YESNO | MB_ICONQUESTION) == IDYES; + } } void From 018aebe5a5f0602c945cdf4c28eb07ba0bcab01b Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 7 Mar 2024 13:22:12 +0100 Subject: [PATCH 237/403] FileType.hpp - add file type IMAGE for firmware download --- src/Repository/FileType.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Repository/FileType.hpp b/src/Repository/FileType.hpp index f7f2c7318be..00994ed8a3d 100644 --- a/src/Repository/FileType.hpp +++ b/src/Repository/FileType.hpp @@ -16,4 +16,5 @@ enum class FileType : uint8_t { RASP, XCI, TASK, + IMAGE, }; From a5693d794af2826d2d06c83fb7fe8eb186b57b26 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sat, 2 Mar 2024 19:05:34 +0100 Subject: [PATCH 238/403] OpenVario - rotation settting --- src/OpenVario/System/OpenVarioDevice.cpp | 17 +++++++++-------- src/OpenVario/System/OpenVarioDevice.hpp | 2 +- src/OpenVario/System/Setting/RotationWidget.cpp | 4 ++-- src/OpenVario/SystemSettingsWidget.cpp | 17 ++++++++++++++--- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/OpenVario/System/OpenVarioDevice.cpp b/src/OpenVario/System/OpenVarioDevice.cpp index 51f55b7fecc..ec7c83bf4ae 100644 --- a/src/OpenVario/System/OpenVarioDevice.cpp +++ b/src/OpenVario/System/OpenVarioDevice.cpp @@ -73,6 +73,9 @@ OpenVario_Device::Initialise() noexcept { AllocatedPath::Build(Path(_T("/boot")), Path(_T("config.uEnv"))); is_real = File::Exists(system_config); #endif + if (!is_real) // a pseudo 'config' file in home_path + system_config = AllocatedPath::Build(home_path, Path(_T("config.uEnv"))); + if (Directory::Exists(data_path)) { // auto config = AllocatedPath::Build(data_path, // Path(_T("openvario.cfg"))); @@ -99,10 +102,6 @@ OpenVario_Device::Initialise() noexcept { #ifdef DEBUG_OPENVARIO LogFormat("home_path = %s", home_path.ToUTF8().c_str()); LogFormat("settings_config = %s", settings_config.ToUTF8().c_str()); - LogFormat("system_config = %s", system_config.ToUTF8().c_str()); - if (!is_real) - system_config = AllocatedPath::Build(home_path, Path(_T("config.uEnv"))); - LogFormat("system_config = %s", system_config.ToUTF8().c_str()); LogFormat("upgrade_config = %s", upgrade_config.ToUTF8().c_str()); // the same...: LogFormat(_T("upgrade_config = %s"), upgrade_config.c_str()); @@ -147,7 +146,9 @@ OpenVario_Device::LoadSettings() noexcept #ifndef DBUS_FUNCTIONS LoadConfigFile(internal_map, GetInternalConfig()); #endif - ReadInteger(system_map, "rotation", rotation); + unsigned i_rot = 0; + ReadInteger(system_map, "rotation", i_rot); + rotation = (DisplayOrientation) i_rot; #ifdef _DEBUG std::string_view fdtfile; ReadString(system_map, "fdtfile", fdtfile); @@ -213,7 +214,7 @@ DisplayOrientation OpenVario_Device::GetRotation() { std::map> map; - LoadConfigFile(map, Path(_T("/boot/config.uEnv"))); + LoadConfigFile(map, system_config); // Path(_T("/boot/config.uEnv"))); uint_least8_t result; result = map.contains("rotation") ? std::stoi(map.find("rotation")->second) : 0; @@ -252,9 +253,9 @@ OpenVario_Device::SetRotation(DisplayOrientation orientation) File::WriteExisting(Path(_T("/sys/class/graphics/fbcon/rotate")), fmt::format_int{rotation}.c_str()); - LoadConfigFile(map, Path(_T("/boot/config.uEnv"))); + LoadConfigFile(map, system_config); // Path(_T("/boot/config.uEnv"))); map.insert_or_assign("rotation", fmt::format_int{rotation}.c_str()); - WriteConfigFile(map, Path(_T("/boot/config.uEnv"))); + WriteConfigFile(map, system_config); // Path(_T("/boot/config.uEnv"))); } #ifdef DBUS_FUNCTIONS diff --git a/src/OpenVario/System/OpenVarioDevice.hpp b/src/OpenVario/System/OpenVarioDevice.hpp index 6be4f0ea63d..27b20886bbd 100644 --- a/src/OpenVario/System/OpenVarioDevice.hpp +++ b/src/OpenVario/System/OpenVarioDevice.hpp @@ -88,7 +88,7 @@ class OpenVario_Device { bool enabled = true; unsigned brightness = 100; unsigned timeout = 5; - unsigned rotation = 0; + DisplayOrientation rotation = DisplayOrientation::DEFAULT; unsigned iTest = 0; }; diff --git a/src/OpenVario/System/Setting/RotationWidget.cpp b/src/OpenVario/System/Setting/RotationWidget.cpp index 8c22373408a..bc077df487c 100644 --- a/src/OpenVario/System/Setting/RotationWidget.cpp +++ b/src/OpenVario/System/Setting/RotationWidget.cpp @@ -69,8 +69,8 @@ SettingRotationWidget::SaveRotation(const std::string &rotationString) // ChangeConfigInt("rotation", rotationInt, ovdevice.GetSettingsConfig()); // TODO(August2111): move the from ovdevice.settings to ovdevice.sysetm LoadConfigFile(ovdevice.system_map, ovdevice.GetSystemConfig()); // -> OpenVarioBaseMenu->StartUp! - ovdevice.rotation = stoi(rotationString); - ovdevice.system_map.insert_or_assign("Rotation", std::to_string(ovdevice.rotation)); + ovdevice.rotation = (DisplayOrientation) stoi(rotationString); + ovdevice.system_map.insert_or_assign("Rotation", std::to_string((unsigned) ovdevice.rotation)); WriteConfigFile(ovdevice.system_map, ovdevice.GetSystemConfig()); } diff --git a/src/OpenVario/SystemSettingsWidget.cpp b/src/OpenVario/SystemSettingsWidget.cpp index 2e6608217ce..429194e02fa 100644 --- a/src/OpenVario/SystemSettingsWidget.cpp +++ b/src/OpenVario/SystemSettingsWidget.cpp @@ -83,6 +83,15 @@ class SystemSettingsWidget final : public RowFormWidget, DataFieldListener { nullptr }; + static constexpr StaticEnumChoice rotation_list[] = { + // { DisplayOrientation::DEFAULT, _T("default") }, + { DisplayOrientation::LANDSCAPE, _T("Landscape (0°)") }, + { DisplayOrientation::PORTRAIT, _T("Portrait (90°)") }, + { DisplayOrientation::REVERSE_LANDSCAPE, _T("Rev. Landscape (180°)") }, + { DisplayOrientation::REVERSE_PORTRAIT, _T("rev. Portrait (270°)")}, + nullptr + }; + void SystemSettingsWidget::SetEnabled([[maybe_unused]] bool enabled) noexcept { @@ -119,9 +128,8 @@ SystemSettingsWidget::Prepare(ContainerWindow &parent, _("Settings Enabled"), _("Enable the Settings Page"), ovdevice.enabled, this); - AddInteger(_("Rotation"), - _("Rotation Display OpenVario"), _T("%d"), _T("%d%%"), 0, - 3, 1, ovdevice.rotation); + AddEnum(_("Rotation"), _("Rotation Display OpenVario"), + rotation_list, (unsigned)ovdevice.rotation); AddInteger(_("Brightness"), _("Brightness Display OpenVario"), _T("%d"), _T("%d%%"), 10, @@ -190,6 +198,9 @@ SystemSettingsWidget::Save([[maybe_unused]] bool &_changed) noexcept WriteConfigFile(ovdevice.settings, ovdevice.GetSettingsConfig()); } + if (SaveValueEnum(ROTATION, ovdevice.rotation)) + ovdevice.SetRotation(ovdevice.rotation); + if (SaveValueEnum(SSH, ovdevice.ssh)) ovdevice.SetSSHStatus((SSHStatus)ovdevice.ssh); From 569f47ceb96f9db1badff6c222ca2229746fbffb Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 8 Mar 2024 09:38:44 +0100 Subject: [PATCH 239/403] RowFormWidget.hpp - 'type == Type::BUTTON' is allowed too? --- src/Widget/RowFormWidget.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Widget/RowFormWidget.hpp b/src/Widget/RowFormWidget.hpp index 0f705e549b3..6fe56c70e9d 100644 --- a/src/Widget/RowFormWidget.hpp +++ b/src/Widget/RowFormWidget.hpp @@ -207,7 +207,8 @@ class RowFormWidget : public WindowWidget { [[gnu::pure]] WndProperty &GetControl() noexcept { - assert(type == Type::EDIT); + // aug(2024-03-08): Type::BUTTON is also ok? + assert(type == Type::EDIT || type == Type::BUTTON); assert(window != nullptr); return (WndProperty &)*window; @@ -215,7 +216,8 @@ class RowFormWidget : public WindowWidget { [[gnu::pure]] const WndProperty &GetControl() const noexcept { - assert(type == Type::EDIT); + // aug(2024-03-08): Type::BUTTON is also ok? + assert(type == Type::EDIT || type == Type::BUTTON); assert(window != nullptr); return (WndProperty &)*window; From 1e7a86506714838a06e1dfa0bb6121c0366510d8 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sat, 9 Mar 2024 19:35:04 +0100 Subject: [PATCH 240/403] Renderer/AirspacePreviewRenderer.cpp - switch to black text color in the desc. - solving issue #1371 # Conflicts: # NEWS.txt --- NEWS.txt | 25 ++++++++++++++++++++++++ src/Renderer/AirspacePreviewRenderer.cpp | 1 + 2 files changed, 26 insertions(+) diff --git a/NEWS.txt b/NEWS.txt index 856369361b2..76340a796ea 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -1,3 +1,28 @@ +Version 7.43 - not yet released +* windows + - black text color in airspace list like all other systems +* Kobo + - fix Wifi configuration + +Version 7.42 - 2024/03/01 +* ui + - new terrain ramp High Contrast + - fix unreadable icons in task manager and status dialog + - render icons at 300 dpi +* data files + - fix bogus "Latin-1 to UTF-8 conversion failed" error + - parse elevations in feet correctly in cup files + - ignore unit for radio frequency in airspace files +* devices + - validate wind direction +* Kobo + - Wifi setup, display signal level in dBm for new models + - scale icons on hi-dpi displays (e.g. Clara HD) +* user interface + - new mountain pass and bridge icons +* Android + - update 'white list' of USB devices with more PIDs for SoftRF Academy + Version 7.41 - 2023/12/21 * data files - fix crash with empty user.cup diff --git a/src/Renderer/AirspacePreviewRenderer.cpp b/src/Renderer/AirspacePreviewRenderer.cpp index 114d2890cd8..7870a2e0ddc 100644 --- a/src/Renderer/AirspacePreviewRenderer.cpp +++ b/src/Renderer/AirspacePreviewRenderer.cpp @@ -84,6 +84,7 @@ AirspacePreviewRenderer::UnprepareFill([[maybe_unused]] Canvas &canvas) #ifdef ENABLE_OPENGL ::glDisable(GL_BLEND); #elif defined(USE_GDI) + canvas.SetTextColor(COLOR_BLACK); canvas.SetMixCopy(); #endif } From a463fbe75a3c4aa6b406fbd3676867c9a0d2b283 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 15 Apr 2024 12:36:08 +0200 Subject: [PATCH 241/403] merge xcsoar-7.42 differences --- .github/workflows/build-container.yml | 8 ++-- .github/workflows/build-native.yml | 53 ++++++++++++++------------- android/AndroidManifest.xml | 14 +++---- android/testing/AndroidManifest.xml | 16 ++++---- build/libdata.mk | 3 ++ build/resource.mk | 38 ++++++++++++++----- src/Airspace/AirspaceParser.cpp | 4 +- 7 files changed, 81 insertions(+), 55 deletions(-) diff --git a/.github/workflows/build-container.yml b/.github/workflows/build-container.yml index 52d28ffbdb2..cc619909785 100644 --- a/.github/workflows/build-container.yml +++ b/.github/workflows/build-container.yml @@ -8,11 +8,11 @@ on: - '.github/workflows/build-container.yml' jobs: - xcsoar-docker-env: + opensoar-docker-env: runs-on: ubuntu-latest env: REGISTRY: ghcr.io - IMAGENAME: xcsoar-build + IMAGENAME: opensoar-build steps: - uses: actions/checkout@v4 with: @@ -33,8 +33,8 @@ jobs: push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} context: ./ide file: ./ide/docker/Dockerfile - tags: ghcr.io/${{ steps.lc_repository_name.outputs.lowercase }}/xcsoar-build:latest - cache-from: type=registry,ref=ghcr.io/${{ steps.string.outputs.lowercase }}/xcsoar-build:latest + tags: ghcr.io/${{ steps.lc_repository_name.outputs.lowercase }}/opensoar-build:latest + cache-from: type=registry,ref=ghcr.io/${{ steps.string.outputs.lowercase }}/opensoar-build:latest cache-to: type=inline secrets: | GIT_AUTH_TOKEN=${{ github.token }} diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index a442a0829b5..74d094df930 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -13,6 +13,7 @@ on: - '.github/workflows/build-unix.yml' branches: - master + - dev-branch pull_request: paths-ignore: @@ -26,6 +27,7 @@ on: - '.github/workflows/build-unix.yml' branches: - master + - dev-branch env: DEBUG: y @@ -37,8 +39,8 @@ jobs: env: TARGET: UNIX - TARGET_BIN: xcsoar - TARGET_FINAL: xcsoar-debug + TARGET_BIN: opensoar + TARGET_FINAL: opensoar-debug TARGET_EXT: '' steps: @@ -46,7 +48,7 @@ jobs: if: github.event_name == 'push' run: | echo "DEBUG=n" >> $GITHUB_ENV - echo "TARGET_FINAL=xcsoar" >> $GITHUB_ENV + echo "TARGET_FINAL=OpenSoar" >> $GITHUB_ENV - id: checkout uses: actions/checkout@v4 with: @@ -94,7 +96,7 @@ jobs: libasound2-dev \ libgles2-mesa-dev libegl1-mesa-dev - - name: Compile XCSoar + - name: Compile OpenSoar run: | make -j$(nproc) TARGET=${{env.TARGET }} DEBUG=${{ env.DEBUG }} USE_CCACHE=y V=2 everything check @@ -106,7 +108,7 @@ jobs: - name: Deploy to Staging server if: | - github.repository == 'XCSoar/XCSoar' && + github.repository == 'OpenSoaring/OpenSoar' && github.ref == 'ref/head/master' && github.event == 'push' uses: easingthemes/ssh-deploy@main @@ -173,7 +175,7 @@ jobs: libxml-parser-perl \ libasound2-dev - - name: Compile XCSoar + - name: Compile OpenSoar run: | make -j$(nproc) TARGET=${{env.TARGET }} DEBUG=${{ env.DEBUG }} VFB=y SANITIZE=y DEBUG_GLIBCXX=y USE_CCACHE=y V=2 everything check @@ -239,7 +241,7 @@ jobs: cmake meson ninja-build \ ttf-bitstream-vera - - name: Compile XCSoar + - name: Compile OpenSoar run: | make -j$(nproc) \ TARGET=${{env.TARGET}} \ @@ -256,7 +258,7 @@ jobs: - name: Deploy to Staging server if: | - github.repository == 'XCSoar/XCSoar' && + github.repository == 'OpenSoaring/OpenSoar' && github.ref == 'ref/head/master' && github.event == 'push' uses: easingthemes/ssh-deploy@main @@ -273,8 +275,8 @@ jobs: env: TARGET: ANDROIDFAT - TARGET_BIN: XCSoar-debug - TARGET_FINAL: XCSoar-debug + TARGET_BIN: OpenSoar-debug + TARGET_FINAL: OpenSoar-debug TARGET_EXT: apk NDK: r26c @@ -283,7 +285,7 @@ jobs: if: github.event_name == 'push' run: | echo "DEBUG=n" >> $GITHUB_ENV - echo "TARGET_FINAL=XCSoar" >> $GITHUB_ENV + echo "TARGET_FINAL=OpenSoar" >> $GITHUB_ENV - id: checkout uses: actions/checkout@v4 @@ -338,7 +340,7 @@ jobs: rm android-ndk-${{env.NDK}}-linux.zip echo ANDROID_NDK_LATEST_HOME=$PWD/android-ndk-${{env.NDK}} >> $GITHUB_ENV - - name: Compile XCSoar + - name: Compile OpenSoar run: | make -j$(nproc) \ TARGET=${{env.TARGET}} \ @@ -356,7 +358,7 @@ jobs: - name: Deploy to Staging server if: | - github.repository == 'XCSoar/XCSoar' && + github.repository == 'OpenSoaring/OpenSoar' && github.ref == 'ref/head/master' && github.event == 'push' uses: easingthemes/ssh-deploy@main @@ -375,8 +377,8 @@ jobs: env: TARGET: WIN64 - TARGET_BIN: XCSoar - TARGET_FINAL: XCSoar-debug + TARGET_BIN: OpenSoar + TARGET_FINAL: OpenSoar-debug TARGET_EXT: .exe steps: @@ -384,7 +386,7 @@ jobs: if: github.event_name == 'push' run: | echo "DEBUG=n" >> $GITHUB_ENV - echo "TARGET_FINAL=XCSoar" >> $GITHUB_ENV + echo "TARGET_FINAL=OpenSoar" >> $GITHUB_ENV - name: Install build dependencies run: | @@ -438,7 +440,7 @@ jobs: - name: Patch mingw intrin.h (mingw64 v8 bug workaround) run: sed -i -e '/extern.* __builtin/d' /usr/share/mingw-w64/include/intrin.h - - name: Compile XCSoar + - name: Compile OpenSoar run: | make -j$(nproc) TARGET=${{env.TARGET }} DEBUG=${{ env.DEBUG }} USE_CCACHE=y V=2 everything @@ -451,7 +453,7 @@ jobs: - name: store checks and compile artefacts uses: actions/upload-artifact@v4 with: - name: xcsoar-${{ env.TARGET }}-artifact + name: opensoar-${{ env.TARGET }}-artifact path: | ${{ github.workspace }}/output/${{ env.TARGET }} !${{ github.workspace }}/output/${{ env.TARGET }}/lib/build @@ -460,7 +462,7 @@ jobs: - name: Deploy to Staging server if: | - github.repository == 'XCSoar/XCSoar' && + github.repository == 'OpenSoaring/OpenSoar' && github.ref == 'ref/head/master' && github.event == 'push' uses: easingthemes/ssh-deploy@main @@ -485,9 +487,9 @@ jobs: - name: fetch artifacts uses: actions/download-artifact@v4 with: - name: xcsoar-${{ env.TARGET }}-artifact + name: opensoar-${{ env.TARGET }}-artifact path: ${{ github.workspace }}/output/${{ env.TARGET }} - - name: XCSoar run checks on ${{ env.TARGET }} + - name: OpenSoar run checks on ${{ env.TARGET }} run: make check-no-build working-directory: ${{ github.workspace }} @@ -534,12 +536,13 @@ jobs: curl \ lua - - name: Compile XCSoar + - name: Compile OpenSoar # We use "-O0" instead of the default "-Og" to work around a # LLVM bug in Apple Xcode which crashes clang with "fatal # error: error in backend: Cannot select: intrinsic # %llvm.coro.size" run: | + clang --version && gmake -j$(sysctl -n hw.logicalcpu) TARGET=${{env.TARGET }} USE_CCACHE=y \ OPTIMIZE="-O0" \ USE_HOMEBREW=y \ @@ -548,7 +551,7 @@ jobs: - name: Deploy to Staging server if: | - github.repository == 'XCSoar/XCSoar' && + github.repository == 'OpenSoaring/OpenSoar' && github.ref == 'ref/head/master' && github.event == 'push' uses: easingthemes/ssh-deploy@main @@ -604,7 +607,7 @@ jobs: imagemagick gettext sox \ cmake ninja - - name: Compile XCSoar + - name: Compile OpenSoar # TODO: remove the "||true" as soon as the remaining SDL2 # linker failure ("Undefined symbols: _SDL_IsIPad, _main") is # fixed. @@ -615,7 +618,7 @@ jobs: - name: Deploy to Staging server if: | - github.repository == 'XCSoar/XCSoar' && + github.repository == 'OpenSoaring/OpenSoar' && github.ref == 'ref/head/master' && github.event == 'push' uses: easingthemes/ssh-deploy@main diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 0432f458534..84a6c90a982 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -1,9 +1,9 @@ + android:versionCode="21" + android:versionName="7.42.21"> - - diff --git a/android/testing/AndroidManifest.xml b/android/testing/AndroidManifest.xml index 59741259d00..4a9df503225 100644 --- a/android/testing/AndroidManifest.xml +++ b/android/testing/AndroidManifest.xml @@ -1,9 +1,9 @@ + android:versionCode="21" + android:versionName="7.42.21"> - - diff --git a/build/libdata.mk b/build/libdata.mk index 0150f8a6f46..c617cbcda61 100644 --- a/build/libdata.mk +++ b/build/libdata.mk @@ -3,6 +3,9 @@ DATA_RESOURCES = \ $(MO_FILES) \ + output/data/COPYING.gz \ + output/data/AUTHORS.gz \ + output/data/OpenSoar-News.md.gz \ $(TEXT_COMPRESSED) \ Data/other/egm96s.dem DATA_SOURCES += $(foreach file,$(DATA_RESOURCES),$(DATA)/$(notdir $(file)).c) diff --git a/build/resource.mk b/build/resource.mk index e1b8e1cc138..d4bdbf18bfc 100644 --- a/build/resource.mk +++ b/build/resource.mk @@ -1,6 +1,10 @@ include build/rsvg.mk include build/imagemagick.mk +# TODO(August2111): what is with setting in main.mk? +# PROGRAM_NAME = XCSoar +# PROGRAM_NAME = OpenSoar + USE_WIN32_RESOURCES = $(call bool_and,$(HAVE_WIN32),$(call bool_not,$(ENABLE_SDL))) ifeq ($(USE_WIN32_RESOURCES),y) @@ -82,15 +86,24 @@ $(ICNS_SPLASH_1024): %.icns: %.png ####### version -SVG_TITLE = Data/graphics/title.svg Data/graphics/title_red.svg -PNG_TITLE_110 = $(patsubst Data/graphics/%.svg,$(DATA)/graphics/%_110.png,$(SVG_TITLE)) +SVG_TITLE = Data/graphics/title.svg +# Data/graphics/title_red.svg +SVG_TMP_TITLE = $(DATA)/temp/graphics/title.svg $(DATA)/temp/graphics/title_red.svg +# convert to title +$(DATA)/temp/graphics/%.svg: $(SVG_TITLE) $(topdir)/OpenSoar.config + @$(NQ)echo " TMP_SVG: $< == $@" + $(Q)$(MKDIR) -p $(DATA)/temp/graphics + $(Q)$(MKDIR) -p $(OUT)/include + $(Q)python3 $(topdir)/tools/python/replace.py $(topdir)/OpenSoar.config $< $@ $(OUT)/include/ProgramVersion.h + +PNG_TITLE_110 = $(patsubst $(DATA)/temp/graphics/%.svg,$(DATA)/graphics/%_110.png,$(SVG_TMP_TITLE)) BMP_TITLE_110 = $(PNG_TITLE_110:.png=.bmp) -PNG_TITLE_320 = $(patsubst Data/graphics/%.svg,$(DATA)/graphics/%_320.png,$(SVG_TITLE)) +PNG_TITLE_320 = $(patsubst $(DATA)/temp/graphics/%.svg,$(DATA)/graphics/%_320.png,$(SVG_TMP_TITLE)) BMP_TITLE_320 = $(PNG_TITLE_320:.png=.bmp) # render from SVG to PNG -$(eval $(call rsvg-convert,$(PNG_TITLE_110),$(DATA)/graphics/%_110.png,Data/graphics/%.svg,--width=110)) -$(eval $(call rsvg-convert,$(PNG_TITLE_320),$(DATA)/graphics/%_320.png,Data/graphics/%.svg,--width=320)) +$(eval $(call rsvg-convert,$(PNG_TITLE_110),$(DATA)/graphics/%_110.png,$(DATA)/temp/graphics/%.svg,--width=110)) +$(eval $(call rsvg-convert,$(PNG_TITLE_320),$(DATA)/graphics/%_320.png,$(DATA)/temp/graphics/%.svg,--width=320)) # convert to uncompressed 8-bit BMP $(eval $(call convert-to-bmp-white,$(BMP_TITLE_110) $(BMP_TITLE_320),%.bmp,%.png)) @@ -167,7 +180,8 @@ endif ####### -TEXT_FILES = AUTHORS COPYING NEWS.txt +# TEXT_FILES = AUTHORS COPYING NEWS.txt +TEXT_FILES = AUTHORS COPYING OpenSoar-News.md TEXT_COMPRESSED = $(patsubst %,$(DATA)/%.gz,$(TEXT_FILES)) $(TEXT_COMPRESSED): $(DATA)/%.gz: % | $(DATA)/dirstamp @@ -221,9 +235,12 @@ ifeq ($(TARGET_IS_ANDROID),n) ifeq ($(USE_WIN32_RESOURCES),y) -$(TARGET_OUTPUT_DIR)/XCSoar.rc: $(TARGET_OUTPUT_DIR)/resources.txt Data/XCSoar.rc tools/GenerateWindowsResources.pl +# old (10.03.2024): RESOURCE_TEXT = Data/$(PROGRAM_NAME).rc +# old (10.03.2024): RESOURCE_BINARY = $(TARGET_OUTPUT_DIR)/$(notdir $(RESOURCE_TEXT:.rc=.rsc)) +# old (10.03.2024): RESOURCE_FILES += $(patsubst po/%.po,$(OUT)/po/%.mo,$(wildcard po/*.po)) +$(TARGET_OUTPUT_DIR)/OpenSoar.rc: $(TARGET_OUTPUT_DIR)/resources.txt Data/OpenSoar.rc tools/GenerateWindowsResources.pl @$(NQ)echo " GEN $@" - $(Q)cp Data/XCSoar.rc $@.tmp + $(Q)cp Data/OpenSoar.rc $@.tmp $(Q)$(PERL) tools/GenerateWindowsResources.pl $< >>$@.tmp $(Q)mv $@.tmp $@ @@ -232,14 +249,15 @@ $(TARGET_OUTPUT_DIR)/include/resource.h: $(TARGET_OUTPUT_DIR)/include/MakeResour $(Q)$(PERL) -ne 'print "#define $$1 $$2\n" if /^MAKE_RESOURCE\((\w+), \S+, (\d+)\);/;' $< >$@.tmp $(Q)mv $@.tmp $@ -RESOURCE_BINARY = $(TARGET_OUTPUT_DIR)/XCSoar.rsc +RESOURCE_BINARY = $(TARGET_OUTPUT_DIR)/OpenSoar.rsc -$(TARGET_OUTPUT_DIR)/XCSoar.rsc: %.rsc: %.rc $(TARGET_OUTPUT_DIR)/include/resource.h $(RESOURCE_FILES) | $(TARGET_OUTPUT_DIR)/%/../dirstamp $(BUILD_TOOLCHAIN_TARGET) +$(TARGET_OUTPUT_DIR)/OpenSoar.rsc: %.rsc: %.rc $(TARGET_OUTPUT_DIR)/include/resource.h $(RESOURCE_FILES) | $(TARGET_OUTPUT_DIR)/%/../dirstamp $(BUILD_TOOLCHAIN_TARGET) @$(NQ)echo " WINDRES $@" $(Q)$(WINDRES) $(WINDRESFLAGS) --include-dir output/data --include-dir Data -o $@ $< else # USE_WIN32_RESOURCES +# old (10.03.2024): $(TARGET_OUTPUT_DIR)/resources.c: $(TARGET_OUTPUT_DIR)/$(PROGRAM_NAME).rc $(OUT)/include/resource.h $(RESOURCE_FILES) tools/LinkResources.pl tools/BinToC.pm | $(TARGET_OUTPUT_DIR)/resources/dirstamp $(TARGET_OUTPUT_DIR)/resources.c: export TARGET_IS_ANDROID:=$(TARGET_IS_ANDROID) $(TARGET_OUTPUT_DIR)/resources.c: export ENABLE_OPENGL:=$(OPENGL) $(TARGET_OUTPUT_DIR)/resources.c: $(TARGET_OUTPUT_DIR)/resources.txt $(RESOURCE_FILES) tools/LinkResources.pl tools/BinToC.pm | $(TARGET_OUTPUT_DIR)/resources/dirstamp diff --git a/src/Airspace/AirspaceParser.cpp b/src/Airspace/AirspaceParser.cpp index 4a36a968990..707b630ecd4 100644 --- a/src/Airspace/AirspaceParser.cpp +++ b/src/Airspace/AirspaceParser.cpp @@ -425,6 +425,7 @@ ReadAltitude(StringParser<> &input) return altitude; default: + altitude = {0, 0, 0, AltitudeReference::STD}; // otherwise not initialized break; } @@ -898,7 +899,8 @@ ParseLineTNP(Airspaces &airspace_database, unsigned line_number, } else if (input.SkipMatchIgnoreCase("BASE="sv)) { temp_area.base = ReadAltitude(input); } else if (input.SkipMatchIgnoreCase("RADIO="sv)) { - temp_area.radio_frequency = RadioFrequency::Parse(ReadRadioFrequency(input.c_str())); + temp_area.radio_frequency = RadioFrequency:: + Parse(ReadRadioFrequency(input.c_str())); } else if (input.SkipMatchIgnoreCase("ACTIVE="sv)) { if (input.MatchAllIgnoreCase("WEEKEND")) temp_area.days_of_operation.SetWeekend(); From da89b5ebbe5bdd1f1594ea8765e4ec0dd201c923 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 12 Mar 2024 23:17:01 +0100 Subject: [PATCH 242/403] CMake - Merge changes from v7.42 --- src/io/CMakeSource.cmake | 1 + src/ui/CMakeSource.cmake | 3 --- test/src/CMakeSource.cmake | 1 + 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/io/CMakeSource.cmake b/src/io/CMakeSource.cmake index d2824f641b1..fea0df7b20b 100644 --- a/src/io/CMakeSource.cmake +++ b/src/io/CMakeSource.cmake @@ -23,6 +23,7 @@ set(_SOURCES io/ZipArchive.cpp io/ZipReader.cpp io/Reader.cxx + io/BufferedCsvReader.cpp ) # if(UNIX) # list(APPEND _SOURCES diff --git a/src/ui/CMakeSource.cmake b/src/ui/CMakeSource.cmake index 7e2c1057eea..ff08aa1737a 100644 --- a/src/ui/CMakeSource.cmake +++ b/src/ui/CMakeSource.cmake @@ -12,7 +12,6 @@ set(SCREEN_SOURCES ${CANVAS_SRC_DIR}/Ramp.cpp ${CANVAS_SRC_DIR}/Util.cpp ${CANVAS_SRC_DIR}/Icon.cpp - ${CANVAS_SRC_DIR}/Canvas.cpp ${CANVAS_SRC_DIR}/Color.cpp ${CANVAS_SRC_DIR}/BufferCanvas.cpp ${WINDOW_SRC_DIR}/Window.cpp @@ -339,8 +338,6 @@ set(SCREEN_HEADERS ${CANVAS_SRC_DIR}/Brush.hpp ${CANVAS_SRC_DIR}/BufferCanvas.cpp ${CANVAS_SRC_DIR}/BufferCanvas.hpp - ${CANVAS_SRC_DIR}/Canvas.cpp - ${CANVAS_SRC_DIR}/Canvas.hpp ${CANVAS_SRC_DIR}/Color.cpp ${CANVAS_SRC_DIR}/Color.hpp ${CANVAS_SRC_DIR}/Font.hpp # neu 2021 diff --git a/test/src/CMakeSource.cmake b/test/src/CMakeSource.cmake index c6bdc6433fc..79a25626c29 100644 --- a/test/src/CMakeSource.cmake +++ b/test/src/CMakeSource.cmake @@ -171,6 +171,7 @@ ${SRC_DIR}/TestRoughTime.cpp ${SRC_DIR}/TestStrings.cpp ${SRC_DIR}/TestSunEphemeris.cpp ${SRC_DIR}/TestTaskPoint.cpp +${SRC_DIR}/TestTaskSave.cpp ${SRC_DIR}/TestTaskWaypoint.cpp ${SRC_DIR}/TestTeamCode.cpp ${SRC_DIR}/TestThermalBand.cpp From 525aff0a8318db79ce6621913555d3a6b9e13fc7 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 12 Mar 2024 18:10:25 +0100 Subject: [PATCH 243/403] Device/Config - use a new port_name for displaying info in device list and rename ANDROID_USB_SERIAL to USB_SERIAL --- src/Device/Config.cpp | 16 ++++++++++++---- src/Device/Config.hpp | 23 +++++++++++++++++------ 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/Device/Config.cpp b/src/Device/Config.cpp index 8e581849b51..08076a1837a 100644 --- a/src/Device/Config.cpp +++ b/src/Device/Config.cpp @@ -29,9 +29,10 @@ DeviceConfig::IsAvailable() const noexcept case PortType::RFCOMM: case PortType::BLE_HM10: case PortType::BLE_SENSOR: + case PortType::USB_SERIAL: + return IsAndroid() || true; // IsWindows() case PortType::RFCOMM_SERVER: case PortType::GLIDER_LINK: - case PortType::ANDROID_USB_SERIAL: return IsAndroid(); case PortType::IOIOUART: @@ -82,7 +83,7 @@ DeviceConfig::ShouldReopenOnTimeout() const noexcept case PortType::BLE_SENSOR: case PortType::BLE_HM10: case PortType::RFCOMM_SERVER: - case PortType::ANDROID_USB_SERIAL: + case PortType::USB_SERIAL: case PortType::IOIOUART: case PortType::DROIDSOAR_V2: case PortType::NUNCHUCK: @@ -177,6 +178,7 @@ DeviceConfig::Clear() noexcept i2c_addr = 0; press_use = PressureUse::STATIC_ONLY; path.clear(); + port_name.clear(); bluetooth_mac.clear(); driver_name.clear(); enabled = true; @@ -209,6 +211,8 @@ DeviceConfig::GetPortName(TCHAR *buffer, size_t max_size) const noexcept if (name2 != nullptr) name = name2; } +#elif defined(_WIN32) + name = port_name; #endif StringFormat(buffer, max_size, _T("%s: %s"), @@ -225,6 +229,8 @@ DeviceConfig::GetPortName(TCHAR *buffer, size_t max_size) const noexcept if (name2 != nullptr) name = name2; } +#elif defined(_WIN32) + name = port_name; #endif StringFormat(buffer, max_size, _T("%s: %s"), @@ -241,6 +247,8 @@ DeviceConfig::GetPortName(TCHAR *buffer, size_t max_size) const noexcept if (name2 != nullptr) name = name2; } +#elif defined(_WIN32) + name = port_name; #endif StringFormat(buffer, max_size, _T("Bluetooth %s"), name); @@ -292,9 +300,9 @@ DeviceConfig::GetPortName(TCHAR *buffer, size_t max_size) const noexcept StringFormat(buffer, max_size, _T("Pseudo-terminal %s"), path.c_str()); return buffer; - case PortType::ANDROID_USB_SERIAL: + case PortType::USB_SERIAL: StringFormat(buffer, max_size, _T("%s: %s"), - _("USB serial"), path.c_str()); + _("USB serial"), port_name.c_str()); return buffer; } diff --git a/src/Device/Config.hpp b/src/Device/Config.hpp index 41146e78838..44734ac6ea4 100644 --- a/src/Device/Config.hpp +++ b/src/Device/Config.hpp @@ -101,7 +101,7 @@ struct DeviceConfig { /** * USB serial port on Android. */ - ANDROID_USB_SERIAL, + USB_SERIAL, }; /** @@ -124,10 +124,15 @@ struct DeviceConfig { unsigned bulk_baud_rate; /** - * The path name of the serial port, e.g. "COM4:" or "/dev/ttyUSB0". + * The path name of the serial port, e.g. "COM4" or "/dev/ttyUSB0". */ StaticString<64> path; + /** + * The path name of the bluetooth port, e.g. "COM15 (Larus1234)". + */ + StaticString<128> port_name; + /** * The Bluetooth MAC address of the peer. */ @@ -259,7 +264,7 @@ struct DeviceConfig { */ static constexpr bool UsesSpeed(PortType port_type) noexcept { return port_type == PortType::SERIAL || port_type == PortType::AUTO || - port_type == PortType::ANDROID_USB_SERIAL || + port_type == PortType::USB_SERIAL || port_type == PortType::IOIOUART; } @@ -309,7 +314,7 @@ struct DeviceConfig { case PortType::IOIOUART: case PortType::PTY: case PortType::UDP_LISTENER: - case PortType::ANDROID_USB_SERIAL: + case PortType::USB_SERIAL: break; } @@ -345,7 +350,6 @@ struct DeviceConfig { static constexpr bool UsesDriver(PortType port_type) noexcept { switch (port_type) { case PortType::DISABLED: - case PortType::BLE_SENSOR: case PortType::GLIDER_LINK: case PortType::DROIDSOAR_V2: case PortType::NUNCHUCK: @@ -354,6 +358,13 @@ struct DeviceConfig { case PortType::INTERNAL: return false; + case PortType::BLE_SENSOR: +#ifdef _WIN32 + return true; +#else + return false; +#endif + case PortType::SERIAL: case PortType::BLE_HM10: case PortType::RFCOMM: @@ -364,7 +375,7 @@ struct DeviceConfig { case PortType::IOIOUART: case PortType::PTY: case PortType::UDP_LISTENER: - case PortType::ANDROID_USB_SERIAL: + case PortType::USB_SERIAL: return true; } From 8af8762155558be3f2ff77ec61e5b5a5747a1242 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 12 Mar 2024 18:13:11 +0100 Subject: [PATCH 244/403] ConfiguredPort.cpp - use RFCOMM and USB_SERIAL in Windows too --- src/Device/Port/ConfiguredPort.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Device/Port/ConfiguredPort.cpp b/src/Device/Port/ConfiguredPort.cpp index 990fd4716ea..78e0bed0ad0 100644 --- a/src/Device/Port/ConfiguredPort.cpp +++ b/src/Device/Port/ConfiguredPort.cpp @@ -119,6 +119,15 @@ OpenPortInternal(EventLoop &event_loop, Cares::Channel &cares, return OpenAndroidBluetoothPort(*bluetooth_helper, config.bluetooth_mac, listener, handler); +#elif defined(_WIN32) + if (config.path.empty()) + throw std::runtime_error("No port path configured"); + + // the usual windows style of device names: + _tcscpy(buffer, _T("\\\\.\\")); + _tcscat(buffer, config.path.c_str()); + path = buffer; + break; #else throw std::runtime_error("Bluetooth not available"); #endif @@ -208,7 +217,7 @@ OpenPortInternal(EventLoop &event_loop, Cares::Channel &cares, #endif } - case DeviceConfig::PortType::ANDROID_USB_SERIAL: + case DeviceConfig::PortType::USB_SERIAL: #ifdef ANDROID if (config.path.empty()) throw std::runtime_error("No name configured"); @@ -219,6 +228,14 @@ OpenPortInternal(EventLoop &event_loop, Cares::Channel &cares, return OpenAndroidUsbSerialPort(*usb_serial_helper, config.path.c_str(), config.baud_rate, listener, handler); +#elif defined(_WIN32) + if (config.path.empty()) + throw std::runtime_error("No port path configured"); + + // the usual windows style of device names: + _tcscpy(buffer, _T("\\\\.\\")); + _tcscat(buffer, config.path.c_str()); + path = buffer; #else throw std::runtime_error("Android USB serial not available"); #endif From d6f6becbcda2a1dc90f446078a05be1ca3e136db Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 12 Mar 2024 18:15:51 +0100 Subject: [PATCH 245/403] SerialPort - in Debug mode detect last error in CreateFile --- src/Device/Port/SerialPort.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Device/Port/SerialPort.cpp b/src/Device/Port/SerialPort.cpp index 46f22a11c81..8ec09e9156b 100644 --- a/src/Device/Port/SerialPort.cpp +++ b/src/Device/Port/SerialPort.cpp @@ -50,8 +50,12 @@ SerialPort::Open(const TCHAR *path, unsigned _baud_rate) nullptr); // Handle to port with attribute to copy // If it fails to open the port, return false. - if (hPort == INVALID_HANDLE_VALUE) + if (hPort == INVALID_HANDLE_VALUE) { +#ifdef _DEBUG + auto error = GetLastError(); +#endif throw MakeLastError("Failed to open serial port"); + } baud_rate = _baud_rate; From 07a3a4f8c8f519b10fd5d4ec1d537d14e93b862f Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 12 Mar 2024 18:18:50 +0100 Subject: [PATCH 246/403] Device/device.cpp - in Windows use GetDiplayString for device information --- src/Device/device.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Device/device.cpp b/src/Device/device.cpp index 48b4490bc77..a3533573732 100644 --- a/src/Device/device.cpp +++ b/src/Device/device.cpp @@ -33,13 +33,17 @@ DeviceConfigOverlaps(const DeviceConfig &a, const DeviceConfig &b) switch (a.port_type) { case DeviceConfig::PortType::SERIAL: case DeviceConfig::PortType::PTY: - case DeviceConfig::PortType::ANDROID_USB_SERIAL: return a.path.equals(b.path); + case DeviceConfig::PortType::USB_SERIAL: case DeviceConfig::PortType::RFCOMM: case DeviceConfig::PortType::BLE_HM10: case DeviceConfig::PortType::BLE_SENSOR: +#ifdef _WIN32 + return a.port_name.equals(b.port_name); +#else return a.bluetooth_mac.equals(b.bluetooth_mac); +#endif case DeviceConfig::PortType::IOIOUART: return a.ioio_uart_id == b.ioio_uart_id; From df173654563d8398fbbbef256c1826e1fcfa7692 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 12 Mar 2024 20:27:35 +0100 Subject: [PATCH 247/403] DeviceEditWidget.cpp -in Windows use GetDisplayString for device information change ANDROID_USB_SERIAL --- src/Dialogs/Device/DeviceEditWidget.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Dialogs/Device/DeviceEditWidget.cpp b/src/Dialogs/Device/DeviceEditWidget.cpp index dd6fc1ba885..5e7e75118a8 100644 --- a/src/Dialogs/Device/DeviceEditWidget.cpp +++ b/src/Dialogs/Device/DeviceEditWidget.cpp @@ -375,7 +375,7 @@ FinishPortField(DeviceConfig &config, const DataFieldEnum &df) noexcept case DeviceConfig::PortType::SERIAL: case DeviceConfig::PortType::PTY: - case DeviceConfig::PortType::ANDROID_USB_SERIAL: + case DeviceConfig::PortType::USB_SERIAL: /* Serial Port */ if (new_type == config.port_type && StringIsEqual(config.path, df.GetAsString())) @@ -383,12 +383,25 @@ FinishPortField(DeviceConfig &config, const DataFieldEnum &df) noexcept config.port_type = new_type; config.path = df.GetAsString(); + config.port_name = df.GetAsDisplayString(); return true; case DeviceConfig::PortType::RFCOMM: case DeviceConfig::PortType::BLE_HM10: case DeviceConfig::PortType::BLE_SENSOR: /* Bluetooth */ +#if _WIN32 + // identical with Serial Port + if (new_type == config.port_type && + StringIsEqual(config.path, df.GetAsString())) + return false; + + config.port_type = new_type; + config.path = df.GetAsString(); + config.port_name = df.GetAsDisplayString(); + return true; +#else + /* Bluetooth */ if (new_type == config.port_type && StringIsEqual(config.bluetooth_mac, df.GetAsString())) return false; @@ -396,7 +409,7 @@ FinishPortField(DeviceConfig &config, const DataFieldEnum &df) noexcept config.port_type = new_type; config.bluetooth_mac = df.GetAsString(); return true; - +#endif case DeviceConfig::PortType::IOIOUART: /* IOIO UART */ if (new_type == config.port_type && From 7a97a0f5247925d9cab65b1725794be50ef205ec Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 12 Mar 2024 23:06:11 +0100 Subject: [PATCH 248/403] Device/Descriptor.cpp - use switch instead of multi compare - and for Windows hide the OpenBluetoothSensor() function --- src/Device/Descriptor.cpp | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/Device/Descriptor.cpp b/src/Device/Descriptor.cpp index e26cd730fab..6be6b1359c0 100644 --- a/src/Device/Descriptor.cpp +++ b/src/Device/Descriptor.cpp @@ -341,6 +341,8 @@ DeviceDescriptor::OpenBluetoothSensor() java_sensor = new Java::GlobalCloseable(factory.OpenBluetoothSensor(config, *this)); return true; +#elif defined(_WIN32) + return true; #else return false; #endif @@ -355,27 +357,24 @@ try { const std::lock_guard lock{mutex}; error_message.clear(); } - - if (config.port_type == DeviceConfig::PortType::INTERNAL) + switch (config.port_type) { + case DeviceConfig::PortType::INTERNAL: return OpenInternalSensors(); - - if (config.port_type == DeviceConfig::PortType::DROIDSOAR_V2) + case DeviceConfig::PortType::DROIDSOAR_V2: return OpenDroidSoarV2(); - - if (config.port_type == DeviceConfig::PortType::I2CPRESSURESENSOR) - return OpenI2Cbaro(); - - if (config.port_type == DeviceConfig::PortType::NUNCHUCK) - return OpenNunchuck(); - - if (config.port_type == DeviceConfig::PortType::IOIOVOLTAGE) - return OpenVoltage(); - - if (config.port_type == DeviceConfig::PortType::GLIDER_LINK) - return OpenGliderLink(); - - if (config.port_type == DeviceConfig::PortType::BLE_SENSOR) - return OpenBluetoothSensor(); + case DeviceConfig::PortType::I2CPRESSURESENSOR: + return OpenI2Cbaro(); + case DeviceConfig::PortType::NUNCHUCK: + return OpenNunchuck(); + case DeviceConfig::PortType::IOIOVOLTAGE: + return OpenVoltage(); + case DeviceConfig::PortType::GLIDER_LINK: + return OpenGliderLink(); +#ifndef _WIN32 + case DeviceConfig::PortType::BLE_SENSOR: + return OpenBluetoothSensor(); +#endif + } reopen_clock.Update(); From a29249a67b97aebaf77987e54120dabd4fbaf90e Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 12 Mar 2024 23:07:37 +0100 Subject: [PATCH 249/403] Port/ConfiguredPort.cpp - use a function for creation windows port name --- src/Device/Port/ConfiguredPort.cpp | 33 +++++++++++++++++++----------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/Device/Port/ConfiguredPort.cpp b/src/Device/Port/ConfiguredPort.cpp index 78e0bed0ad0..c58103785f0 100644 --- a/src/Device/Port/ConfiguredPort.cpp +++ b/src/Device/Port/ConfiguredPort.cpp @@ -63,6 +63,20 @@ WrapPort(const DeviceConfig &config, PortListener *listener, return port; } +#if defined(_WIN32) +//void +const TCHAR * +WindowsPort(TCHAR buffer[], const DeviceConfig &config) { + if (config.path.empty()) + throw std::runtime_error("No port path configured"); + + // the usual windows style of device names: + _tcscpy(buffer, _T("\\\\.\\")); + _tcscat(buffer, config.path.c_str()); + return buffer; +} +#endif + static std::unique_ptr OpenPortInternal(EventLoop &event_loop, Cares::Channel &cares, #ifdef ANDROID @@ -85,10 +99,7 @@ OpenPortInternal(EventLoop &event_loop, Cares::Channel &cares, throw std::runtime_error("No port path configured"); #ifdef _WIN32 - // the usual windows style of device names: - _tcscpy(buffer, _T("\\\\.\\")); - _tcscat(buffer, config.path.c_str()); - path = buffer; + path = WindowsPort(buffer, config); #else path = config.path.c_str(); #endif @@ -105,10 +116,14 @@ OpenPortInternal(EventLoop &event_loop, Cares::Channel &cares, return OpenAndroidBleHm10Port(*bluetooth_helper, config.bluetooth_mac, listener, handler); +#elif defined (_WIN32) + path = WindowsPort(buffer, config); + break; #else throw std::runtime_error("Bluetooth not available"); #endif + case DeviceConfig::PortType::BLE_SENSOR: case DeviceConfig::PortType::RFCOMM: #ifdef ANDROID if (config.bluetooth_mac.empty()) @@ -120,13 +135,7 @@ OpenPortInternal(EventLoop &event_loop, Cares::Channel &cares, return OpenAndroidBluetoothPort(*bluetooth_helper, config.bluetooth_mac, listener, handler); #elif defined(_WIN32) - if (config.path.empty()) - throw std::runtime_error("No port path configured"); - - // the usual windows style of device names: - _tcscpy(buffer, _T("\\\\.\\")); - _tcscat(buffer, config.path.c_str()); - path = buffer; + path = WindowsPort(buffer, config); break; #else throw std::runtime_error("Bluetooth not available"); @@ -167,7 +176,7 @@ OpenPortInternal(EventLoop &event_loop, Cares::Channel &cares, break; case DeviceConfig::PortType::INTERNAL: - case DeviceConfig::PortType::BLE_SENSOR: +// case DeviceConfig::PortType::BLE_SENSOR: case DeviceConfig::PortType::DROIDSOAR_V2: case DeviceConfig::PortType::NUNCHUCK: case DeviceConfig::PortType::I2CPRESSURESENSOR: From fd2571466b95c83aa180185ade488cb8a8bf9a0b Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 12 Mar 2024 23:09:04 +0100 Subject: [PATCH 250/403] Device/PortDataField.cpp - complete rework to select the names from Bluetooth- modules --- src/Dialogs/Device/PortDataField.cpp | 149 ++++++++++++++++++++++++--- 1 file changed, 137 insertions(+), 12 deletions(-) diff --git a/src/Dialogs/Device/PortDataField.cpp b/src/Dialogs/Device/PortDataField.cpp index 108e5438d48..fd3928b94ce 100644 --- a/src/Dialogs/Device/PortDataField.cpp +++ b/src/Dialogs/Device/PortDataField.cpp @@ -14,6 +14,8 @@ #ifdef _WIN32 # include "system/WindowsRegistry.hpp" # include "util/StringFormat.hpp" +# include +# include #endif #ifdef ANDROID @@ -103,12 +105,63 @@ DetectSerialPorts(DataFieldEnum &df) noexcept static void DetectSerialPorts(DataFieldEnum &df) noexcept try { +//------------------------------- + RegistryKey bthenums{HKEY_LOCAL_MACHINE, _T("SYSTEM\\CurrentControlSet\\" + "Enum\\BthEnum")}; + std::map bthmap; + for (unsigned k = 0;; ++k) { + TCHAR dev_name[128]; + TCHAR name[128]; + TCHAR friendly_name[128]; + + if (!bthenums.EnumKey(k, std::span{dev_name})) + break; + std::wstring map_name(dev_name); + if (!map_name.starts_with(_T("Dev_"))) + continue; + RegistryKey bthenum_dev{bthenums, dev_name}; + // only one is possible... + if (!bthenum_dev.EnumKey(0, std::span{name})) + break; + RegistryKey bthenum_key{bthenum_dev, name}; + if (!bthenum_key.GetValue(_T("FriendlyName"), friendly_name)) + break; + map_name = map_name.substr(4); + for (std::wstring::iterator it = map_name.begin(); it != map_name.end(); + ++it) + *it = towlower(*it); + bthmap[map_name] = friendly_name; // Left "Dev_" + } + RegistryKey bthle{HKEY_LOCAL_MACHINE, _T("SYSTEM\\CurrentControlSet\\" + "Enum\\BthLE")}; + std::map blemap; + for (unsigned k = 0;; ++k) { + TCHAR dev_name[128]; + TCHAR name[128]; + TCHAR friendly_name[128]; + + if (!bthle.EnumKey(k, std::span{dev_name})) + break; + std::wstring map_name(dev_name); + if (!map_name.starts_with(_T("Dev_"))) + continue; + RegistryKey bthle_dev{bthle, dev_name}; + // only one is possible... + if (!bthle_dev.EnumKey(0, std::span{name})) + break; + RegistryKey bthle_key{bthle_dev, name}; + if (!bthle_key.GetValue(_T("FriendlyName"), friendly_name)) + break; + map_name = map_name.substr(4); + for (std::wstring::iterator it = map_name.begin(); it != map_name.end(); + ++it) + *it = towlower(*it); + blemap[map_name] = friendly_name; // Left "Dev_" + } + /* the registry key HKEY_LOCAL_MACHINE/Hardware/DEVICEMAP/SERIALCOMM is the best way to discover serial ports on Windows */ - - RegistryKey hardware{HKEY_LOCAL_MACHINE, _T("Hardware")}; - RegistryKey devicemap{hardware, _T("DEVICEMAP")}; - RegistryKey serialcomm{devicemap, _T("SERIALCOMM")}; + RegistryKey serialcomm{HKEY_LOCAL_MACHINE, _T("Hardware\\DeviceMap\\SerialComm")}; for (unsigned i = 0;; ++i) { TCHAR name[128]; @@ -123,7 +176,72 @@ try { // weird continue; - AddPort(df, DeviceConfig::PortType::SERIAL, value, name); + RegistryKey devices {HKEY_LOCAL_MACHINE, _T("SYSTEM\\CurrentControlSet\\" + "Control\\COM Name Arbiter\\Devices")}; + TCHAR name1[0x200]; + + DWORD type1; + if (!devices.GetValue(value, name1)) + break; + + // Registry "COM Name Arbiter\Devices" starts with + // BlueTooth: "\\?\bthenum#" + // USB: "\\?\usb#" + // Normal: "\\?\acpi#" - an Kupschis Rechner! +#ifdef UNICODE + std::wstring dev = name1; +#else + std::string dev = name1; +#endif + if (dev.starts_with(_T("\\\\?\\usb#"))) { +#ifdef UNICODE + std::vector strs; + std::wstring port_name; +#else + std::vector strs; + std::string port_name; +#endif + boost::split(strs, name, boost::is_any_of("\\")); + port_name = value; + port_name += _T(" ("); + port_name += strs[2]; + port_name += _T(")"); + + AddPort(df, DeviceConfig::PortType::USB_SERIAL, value, port_name.c_str()); + } else if (dev.starts_with(_T("\\\\?\\bthenum#"))) { +#ifdef UNICODE + std::vector strs; + std::wstring port_name; +#else + std::vector strs; + std::string port_name; +#endif + boost::split(strs, name1, boost::is_any_of("#")); + boost::split(strs, strs[2], boost::is_any_of("_")); + if (strs[1] == _T("c00000000")) { + boost::split(strs, strs[0], boost::is_any_of("&")); + if (strs[3] != _T("000000000000")) { + DeviceConfig::PortType port_type = DeviceConfig::PortType::DISABLED; + port_name = value; + port_name += _T(" ("); + if (blemap.find(strs[3]) != blemap.end()) { + port_type = DeviceConfig::PortType::RFCOMM; + port_type = DeviceConfig::PortType::BLE_HM10; + // port_type = DeviceConfig::PortType::BLE_SENSOR; + port_name += blemap[strs[3]]; + } else if (bthmap.find(strs[3]) != bthmap.end()) { + port_type = DeviceConfig::PortType::RFCOMM; + port_name += bthmap[strs[3]]; + } + + port_name += _T(")"); + if (port_type != DeviceConfig::PortType::DISABLED) + AddPort(df, port_type, value, + port_name.c_str()); + } + } + } else // if (dev.starts_with(_T("\\\\?\\acpi#"))) + AddPort(df, DeviceConfig::PortType::SERIAL, value, name); } } catch (const std::system_error &) { // silently ignore registry errors @@ -155,15 +273,22 @@ SetPort(DataFieldEnum &df, DeviceConfig::PortType type, df.SetValue(AddPort(df, type, value)); } -static void -FillSerialPorts(DataFieldEnum &df, const DeviceConfig &config) noexcept -{ +static void FillSerialPorts(DataFieldEnum &df, + const DeviceConfig &config) noexcept { #if defined(HAVE_POSIX) || defined(_WIN32) DetectSerialPorts(df); #endif - if (config.port_type == DeviceConfig::PortType::SERIAL) + switch (config.port_type) { + case DeviceConfig::PortType::SERIAL: + case DeviceConfig::PortType::RFCOMM: + case DeviceConfig::PortType::BLE_HM10: + case DeviceConfig::PortType::BLE_SENSOR: + case DeviceConfig::PortType::USB_SERIAL: SetPort(df, config.port_type, config.path); + default: + break; + } } void @@ -197,9 +322,9 @@ FillAndroidUsbSerialPorts([[maybe_unused]] DataFieldEnum &df, [[maybe_unused]] const DeviceConfig &config) noexcept { #ifdef ANDROID - if (config.port_type == DeviceConfig::PortType::ANDROID_USB_SERIAL && + if (config.port_type == DeviceConfig::PortType::USB_SERIAL && !config.path.empty()) - SetPort(df, DeviceConfig::PortType::ANDROID_USB_SERIAL, config.path); + SetPort(df, DeviceConfig::PortType::USB_SERIAL, config.path); #endif } @@ -277,7 +402,7 @@ SetDevicePort(DataFieldEnum &df, const DeviceConfig &config) noexcept break; case DeviceConfig::PortType::SERIAL: - case DeviceConfig::PortType::ANDROID_USB_SERIAL: + case DeviceConfig::PortType::USB_SERIAL: SetPort(df, config.port_type, config.path); return; From 35a0abc074a1b73e2077bdb55a902cadebbe16b0 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 12 Mar 2024 23:10:16 +0100 Subject: [PATCH 251/403] Device/PortPicker.cpp - change ANDROID_USB_SERIAL to USB_SERIAL --- src/Dialogs/Device/PortPicker.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Dialogs/Device/PortPicker.cpp b/src/Dialogs/Device/PortPicker.cpp index 82aab11e0ff..223f36bf435 100644 --- a/src/Dialogs/Device/PortPicker.cpp +++ b/src/Dialogs/Device/PortPicker.cpp @@ -55,7 +55,7 @@ class PortListItemRenderer final { case DeviceConfig::PortType::BLE_SENSOR: return _("BLE sensor"); - case DeviceConfig::PortType::ANDROID_USB_SERIAL: + case DeviceConfig::PortType::USB_SERIAL: return _("USB serial"); default: @@ -245,7 +245,7 @@ PortPickerWidget::OnDeviceDetected(Type type, const char *address, break; case Type::USB_SERIAL: - port_type = DeviceConfig::PortType::ANDROID_USB_SERIAL; + port_type = DeviceConfig::PortType::USB_SERIAL; break; } From d9a0821f244fb200925bfe700b9ba493eb3c82f5 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 12 Mar 2024 23:12:15 +0100 Subject: [PATCH 252/403] Profile/DeviceConfig.cpp - change ANDROID_USB_SERIAL... and the names too --- src/Profile/DeviceConfig.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Profile/DeviceConfig.cpp b/src/Profile/DeviceConfig.cpp index 0f07097d41c..eab528e3912 100644 --- a/src/Profile/DeviceConfig.cpp +++ b/src/Profile/DeviceConfig.cpp @@ -14,6 +14,8 @@ #include +using std::string_view_literals::operator""sv; + static const char *const port_type_strings[] = { "disabled", "serial", @@ -33,7 +35,8 @@ static const char *const port_type_strings[] = { "ble_sensor", "ble_hm10", "glider_link", - "android_usb_serial", +// "android_usb_serial", + "usb_serial", NULL }; @@ -54,6 +57,8 @@ MakeDeviceSettingName(char *buffer, const char *prefix, unsigned n, static bool StringToPortType(const char *value, DeviceConfig::PortType &type) { + if (value == "android_usb_serial"sv) + value = "usb_serial"; // avoid the old name for (auto i = port_type_strings; *i != NULL; ++i) { if (StringIsEqual(value, *i)) { type = (DeviceConfig::PortType)std::distance(port_type_strings, i); @@ -117,6 +122,9 @@ Profile::GetDeviceConfig(const ProfileMap &map, unsigned n, MakeDeviceSettingName(buffer, "Port", n, "BluetoothMAC"); map.Get(buffer, config.bluetooth_mac); + MakeDeviceSettingName(buffer, "Port", n, "PortName"); + map.Get(buffer, config.port_name); + MakeDeviceSettingName(buffer, "Port", n, "IOIOUartID"); map.Get(buffer, config.ioio_uart_id); @@ -130,10 +138,16 @@ Profile::GetDeviceConfig(const ProfileMap &map, unsigned n, config.path.clear(); if ((!have_port_type || - config.port_type == DeviceConfig::PortType::ANDROID_USB_SERIAL || + config.port_type == DeviceConfig::PortType::USB_SERIAL || +#ifdef _WIN32 + config.port_type == DeviceConfig::PortType::BLE_HM10 || + config.port_type == DeviceConfig::PortType::BLE_SENSOR || +#endif + config.port_type == DeviceConfig::PortType::RFCOMM || config.port_type == DeviceConfig::PortType::SERIAL) && !LoadPath(map, config, n)) config.port_type = DeviceConfig::PortType::SERIAL; + // config.port_type = DeviceConfig::PortType::BLE_HM10; MakeDeviceSettingName(buffer, "Port", n, "BaudRate"); if (!map.Get(buffer, config.baud_rate)) { @@ -216,6 +230,9 @@ Profile::SetDeviceConfig(ProfileMap &map, WritePortType(map, n, config.port_type); + MakeDeviceSettingName(buffer, "Port", n, "PortName"); + map.Set(buffer, config.port_name); + MakeDeviceSettingName(buffer, "Port", n, "BluetoothMAC"); map.Set(buffer, config.bluetooth_mac); From 1bdd8960038956a71ac2dbb7665169c9c55bfffe Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 19 Mar 2024 15:35:55 +0100 Subject: [PATCH 253/403] [Bugfix] po/de.po - spelling issues --- po/de.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/po/de.po b/po/de.po index 5624675dd55..3c62a6bcb86 100644 --- a/po/de.po +++ b/po/de.po @@ -9702,7 +9702,7 @@ msgstr "Contest Durchschnittsgeschwindigkeit" #: src/InfoBoxes/Content/Factory.cpp:995 #, no-c-format msgid "Cont Speed" -msgstr "Const Geschw" +msgstr "Cont Geschw" #: src/InfoBoxes/Content/Factory.cpp:996 #, no-c-format @@ -9879,7 +9879,7 @@ msgstr "Alternative 2 - Gleitzahl" #: src/InfoBoxes/Content/Factory.cpp:1078 #, no-c-format msgid "Altn2 GR" -msgstr "Altn1 benö GZ" +msgstr "Altn2 benö GZ" #: src/InfoBoxes/Content/Factory.cpp:1079 #, no-c-format From e7f893029c31894301015d6998f7651edabe3e42 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sat, 13 Apr 2024 09:52:10 +0200 Subject: [PATCH 254/403] [Bugfix/Anemoi] - simple avoid access to closed port * needs to be developed to a real mutex --- src/Device/Driver/Anemoi.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Device/Driver/Anemoi.cpp b/src/Device/Driver/Anemoi.cpp index 6871c9c5e67..f089bb87820 100644 --- a/src/Device/Driver/Anemoi.cpp +++ b/src/Device/Driver/Anemoi.cpp @@ -94,9 +94,11 @@ class AnemoiDevice final : public AbstractDevice { static bool ParseWind(const std::byte *data, struct NMEAInfo &info); static bool ParseData(const std::byte *data, struct NMEAInfo &info); + bool active; + ~AnemoiDevice() { active = false; } public: - AnemoiDevice([[maybe_unused]] Port &_port) {} + AnemoiDevice([[maybe_unused]] Port &_port) : active(true) {} // port is unused: AnemoiDevice(Port &_port) : port(_port) {} /* virtual methods from class Device */ @@ -109,8 +111,9 @@ AnemoiDevice::DataReceived(std::span s, struct NMEAInfo &info) noexcept { assert(!s.empty()); - - const auto *data = s.data(); + if (!active) + return false; + const auto *data = s.data(); const auto *const end = data + s.size(); do { // Append new data to the buffer, as much as fits in there @@ -131,6 +134,8 @@ AnemoiDevice::DataReceived(std::span s, for (;;) { // Read data from buffer to handle the messages + if (!active) + return false; range = rx_buf.Read(); if (range.empty()) break; @@ -139,6 +144,8 @@ AnemoiDevice::DataReceived(std::span s, break; expected_msg_length = ExpectedMsgLength(range.data(), range.size()); + if (!active) + return false; if (range.size() >= expected_msg_length) { switch (*(const std::byte *)range.data()) { case StartByte: // Startbyte From 7ab56077c886fa0d78a910ee4264d850566d1f03 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 27 Mar 2024 16:52:12 +0100 Subject: [PATCH 255/403] =?UTF-8?q?[Bugfix]=20device/Descriptor.cpp=20-=20?= =?UTF-8?q?avoid=20error=20message:=20enumeration=20value=20=E2=80=98xxx?= =?UTF-8?q?=E2=80=99=20not=20...=20handled=20in=20switch=20[-Werror=3Dswit?= =?UTF-8?q?ch]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Device/Descriptor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Device/Descriptor.cpp b/src/Device/Descriptor.cpp index 6be6b1359c0..a8e820adce4 100644 --- a/src/Device/Descriptor.cpp +++ b/src/Device/Descriptor.cpp @@ -374,6 +374,8 @@ try { case DeviceConfig::PortType::BLE_SENSOR: return OpenBluetoothSensor(); #endif + default: + break; } reopen_clock.Update(); From 3bec94ae8f0ca70ec34ffed82ef08218c458af15 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sat, 13 Apr 2024 17:24:02 +0200 Subject: [PATCH 256/403] Dialogs/TextEntry.cpp - use TouchTextEntry as default (before KnobTextEntry) --- src/Dialogs/TextEntry.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Dialogs/TextEntry.cpp b/src/Dialogs/TextEntry.cpp index 1928121e909..309a90f4b42 100644 --- a/src/Dialogs/TextEntry.cpp +++ b/src/Dialogs/TextEntry.cpp @@ -13,14 +13,18 @@ TextEntryDialog(TCHAR *text, size_t width, { switch (UIGlobals::GetDialogSettings().text_input_style) { case DialogSettings::TextInputStyle::Default: + return TouchTextEntry(text, width, caption, accb, default_shift_state); case DialogSettings::TextInputStyle::Keyboard: +#if 1 + return TouchTextEntry(text, width, caption, accb, default_shift_state); +#else if (HasPointer()) return TouchTextEntry(text, width, caption, accb, default_shift_state); else { KnobTextEntry(text, width, caption); return true; } - +#endif case DialogSettings::TextInputStyle::HighScore: KnobTextEntry(text, width, caption); return true; From f3819f07a5797b7be84a6801bc07788ddfd95cb4 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 20 Mar 2024 14:16:34 +0100 Subject: [PATCH 257/403] [build] targets.mk - change TARGET_FLAVOR in OPENVARIO for OpenVario --- build/targets.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/build/targets.mk b/build/targets.mk index ed4b396a029..83a5f43cd2b 100644 --- a/build/targets.mk +++ b/build/targets.mk @@ -444,6 +444,7 @@ ifeq ($(HAVE_POSIX),y) endif ifeq ($(TARGET_IS_OPENVARIO),y) + override TARGET_FLAVOR = OPENVARIO TARGET_CPPFLAGS += -DIS_OPENVARIO # TARGET_CPPFLAGS += -isystem /usr/include/dbus-1.0 -isystem /usr/lib/x86_64-linux-gnu/dbus-1.0/include endif From 7a158d384afe440024a835e4a4badf65cb680dfe Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 3 Apr 2024 20:37:03 +0200 Subject: [PATCH 258/403] Makefile - add kobo only if TARGET_IS_KOBO --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index 1c726677884..96aeaa558b5 100644 --- a/Makefile +++ b/Makefile @@ -267,6 +267,10 @@ endif ifeq ($(TARGET_IS_LINUX),y) include $(topdir)/build/cloud.mk +# include $(topdir)/build/kobo.mk +endif + +ifeq ($(TARGET_IS_KOBO),y) include $(topdir)/build/kobo.mk ifeq ($(USE_POLL_EVENT),y) include $(topdir)/build/ov.mk From a894a3f237a7cf1ee562d0996c491f30deb9d0c5 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 12 Mar 2024 23:15:00 +0100 Subject: [PATCH 259/403] [InputEvents] split Exit and Shutdown for a different selection in different system targets --- Data/Input/default.xci | 4 ++-- src/Input/InputEvents.hpp | 3 +++ src/Input/InputEventsActions.cpp | 19 ++++++++++++++++--- src/OpenVario/System/SystemMenuWidget.cpp | 2 +- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Data/Input/default.xci b/Data/Input/default.xci index 84ff01153c4..17ccaa45013 100644 --- a/Data/Input/default.xci +++ b/Data/Input/default.xci @@ -1284,7 +1284,7 @@ location=60 mode=RemoteStick type=key data=0 -event=Exit reboot +event=Shutdown reboot event=Mode default label=Reboot location=61 @@ -1293,7 +1293,7 @@ location=61 mode=RemoteStick type=key data=0 -event=Exit shutdown +event=Shutdown shutdown event=Mode default label=Shutdown location=62 diff --git a/src/Input/InputEvents.hpp b/src/Input/InputEvents.hpp index 35573c0a673..0523966111d 100644 --- a/src/Input/InputEvents.hpp +++ b/src/Input/InputEvents.hpp @@ -192,6 +192,9 @@ void eventRunLuaFile(const TCHAR *misc); void eventResetTask(const TCHAR *misc); void eventLockScreen(const TCHAR *misc); void eventExchangeFrequencies(const TCHAR *misc); +#ifdef IS_OPENVARIO +void eventShutdown(const TCHAR *misc); +#endif void eventUploadIGCFile(const TCHAR *misc); // ------- diff --git a/src/Input/InputEventsActions.cpp b/src/Input/InputEventsActions.cpp index 372dfcdfede..72ad60567ce 100644 --- a/src/Input/InputEventsActions.cpp +++ b/src/Input/InputEventsActions.cpp @@ -622,6 +622,7 @@ InputEvents::eventBrightness([[maybe_unused]] const TCHAR *misc) // not implemented (was only implemented on Altair) } +// Exits for general systems void InputEvents::eventExit([[maybe_unused]] const TCHAR *misc) { @@ -629,16 +630,28 @@ InputEvents::eventExit([[maybe_unused]] const TCHAR *misc) if (StringIsEqual(misc, _T("system"))) { // return value on UNIX(32) is only a Byte? UI::TopWindow::SetExitValue(EXIT_SYSTEM); // 20000); - } else if (StringIsEqual(misc, _T("reboot"))) { + } else if (StringIsEqual(misc, _T("restart"))) { + UI::TopWindow::SetExitValue(EXIT_RESTART); + } + } + UIActions::SignalShutdown(false); +} + +#ifdef IS_OPENVARIO +// Exits with real Shutdown only in systems where this is possible +void +InputEvents::eventShutdown([[maybe_unused]] const TCHAR *misc) +{ + if (UI::TopWindow::GetExitValue() == 0) { + if (StringIsEqual(misc, _T("reboot"))) { UI::TopWindow::SetExitValue(EXIT_REBOOT); // 20001); } else if (StringIsEqual(misc, _T("shutdown"))) { UI::TopWindow::SetExitValue(EXIT_SHUTDOWN); // 20002); - } else if (StringIsEqual(misc, _T("restart"))) { - UI::TopWindow::SetExitValue(EXIT_RESTART); } } UIActions::SignalShutdown(false); } +#endif void InputEvents::eventUserDisplayModeForce(const TCHAR *misc) diff --git a/src/OpenVario/System/SystemMenuWidget.cpp b/src/OpenVario/System/SystemMenuWidget.cpp index ace4b126293..34ba4a62543 100644 --- a/src/OpenVario/System/SystemMenuWidget.cpp +++ b/src/OpenVario/System/SystemMenuWidget.cpp @@ -183,7 +183,7 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, ContainerWindow::SetExitValue(LAUNCH_TOUCH_CALIBRATE); UIActions::SignalShutdown(true); return mrOK; - // InputEvents::eventExit(_T("reboot")); + // InputEvents::eventShutdown(_T("reboot")); // dialog.SetModalResult(LAUNCH_TOUCH_CALIBRATE); // dialog.SetModalResult(LAUNCH_TOUCH_CALIBRATE); From f454180e6ce078232d3abe9d4c2c9d9d631a8dc6 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 10 Apr 2024 15:35:58 +0200 Subject: [PATCH 260/403] [Event] InputEvent.. add eventKeypressed for simulated keys --- src/Input/InputEvents.hpp | 1 + src/Input/InputEventsActions.cpp | 37 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/Input/InputEvents.hpp b/src/Input/InputEvents.hpp index 0523966111d..0d3af9a45c1 100644 --- a/src/Input/InputEvents.hpp +++ b/src/Input/InputEvents.hpp @@ -196,6 +196,7 @@ void eventExchangeFrequencies(const TCHAR *misc); void eventShutdown(const TCHAR *misc); #endif void eventUploadIGCFile(const TCHAR *misc); +void eventKeyPressed(const TCHAR *misc); // ------- } // namespace InputEvents diff --git a/src/Input/InputEventsActions.cpp b/src/Input/InputEventsActions.cpp index 72ad60567ce..785460fe35d 100644 --- a/src/Input/InputEventsActions.cpp +++ b/src/Input/InputEventsActions.cpp @@ -651,6 +651,43 @@ InputEvents::eventShutdown([[maybe_unused]] const TCHAR *misc) } UIActions::SignalShutdown(false); } + +#include "InputKeys.hpp" +#include "ui/event/KeyCode.hpp" + +void +InputEvents::eventKeyPressed(const TCHAR *misc) +{ +// std::map keys; + for (char *p = (char *)misc; *p != 0; p++) { + if (*p != ' ') { + char c[2] = {*p, 0}; + if (!strncmp(p, "LEFT", strlen("LEFT"))) { + c[0] = KEY_LEFT; + p += strlen("LEFT") ; + } else if (!strncmp(p, "RIGHT", strlen("RIGHT"))) { + c[0] = KEY_RIGHT; + p += strlen("RIGHT") ; + } else if (!strncmp(p, "UP", strlen("UP"))) { + c[0] = KEY_UP; + p += strlen("UP") ; + } else if (!strncmp(p, "DOWN", strlen("DOWN"))) { + c[0] = KEY_DOWN; + p += strlen("DOWN") ; + } else if (!strncmp(p, "ESCAPE", strlen("ESCAPE"))) { + c[0] = KEY_ESCAPE; + p += strlen("ESCAPE") ; + } else if (!strncmp(p, "ENTER", strlen("ENTER"))) { + c[0] = KEY_RETURN; + p += strlen("ENTER") ; + } else if (!strncmp(p, "RETURN", strlen("RETURN"))) { + c[0] = KEY_RETURN; + p += strlen("RETURN") ; + } + ParseKeyCode(c); + } + } +} #endif void From 2e7ed02ad7cf867069df693c3ecc8c13b8eeda27 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 10 Apr 2024 15:39:16 +0200 Subject: [PATCH 261/403] Hardware/RotateDisplay.cpp - add GetRotation() --- src/Hardware/RotateDisplay.cpp | 22 ++++++++++++++++++---- src/Hardware/RotateDisplay.hpp | 11 +++++++++-- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/Hardware/RotateDisplay.cpp b/src/Hardware/RotateDisplay.cpp index 4e599119c8b..de6b2297d79 100644 --- a/src/Hardware/RotateDisplay.cpp +++ b/src/Hardware/RotateDisplay.cpp @@ -14,14 +14,19 @@ #include "Kobo/Model.hpp" #endif +#ifdef IS_OPENVARIO +#include "system/FileUtil.hpp" +#endif + #ifdef ENABLE_OPENGL #include "ui/opengl/Features.hpp" -#ifdef SOFTWARE_ROTATE_DISPLAY -#include "UIGlobals.hpp" -#include "ui/window/SingleWindow.hpp" #include "ui/canvas/opengl/Globals.hpp" #endif -#endif + +#include "UIGlobals.hpp" +#include "ui/window/SingleWindow.hpp" + +static DisplayOrientation _rotation = DisplayOrientation::DEFAULT; void Display::RotateInitialize() @@ -46,6 +51,8 @@ Display::RotateSupported() bool Display::Rotate(DisplayOrientation orientation) { + _rotation = orientation; + #if !defined(ANDROID) && !defined(KOBO) if (orientation == DisplayOrientation::DEFAULT) /* leave it as it is */ @@ -157,6 +164,7 @@ Display::Rotate(DisplayOrientation orientation) bool Display::RotateRestore() { + _rotation = DisplayOrientation::DEFAULT; #if defined(ANDROID) return native_view->SetRequestedOrientation(Java::GetEnv(), NativeView::ScreenOrientation::SENSOR); @@ -166,3 +174,9 @@ Display::RotateRestore() return false; #endif } + +DisplayOrientation +Display::GetRotation() +{ + return _rotation; +} diff --git a/src/Hardware/RotateDisplay.hpp b/src/Hardware/RotateDisplay.hpp index 6b28be3a307..3c18cbb97c7 100644 --- a/src/Hardware/RotateDisplay.hpp +++ b/src/Hardware/RotateDisplay.hpp @@ -11,7 +11,8 @@ namespace Display { void RotateInitialize(); [[gnu::const]] - bool RotateSupported(); + bool + RotateSupported(); /** * Change the orientation of the screen. @@ -24,4 +25,10 @@ namespace Display { */ bool RotateRestore(); -} + + /** + * Get the display rotation setting. + */ + DisplayOrientation GetRotation(); + +} // namespace Display From d4468e9bda84fed5fb40fe40dd610486851437a2 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 11 Apr 2024 10:33:02 +0200 Subject: [PATCH 262/403] system/Process.cpp - Hide process debug output --- src/system/Process.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/system/Process.cpp b/src/system/Process.cpp index dc23e352c4a..06b8b033da1 100644 --- a/src/system/Process.cpp +++ b/src/system/Process.cpp @@ -111,21 +111,24 @@ Start(const char *const *argv) noexcept int Run(const char *const *argv) noexcept; +#define PROCESS_DEBUG_OUTPUT 0 int Run(const char *const *argv) noexcept try { -#if 1 // def DEBUG_OPENVARIO +#if PROCESS_DEBUG_OUTPUT // def DEBUG_OPENVARIO std::cout << "Start Run with:" << std::endl; if (!output.empty()) LogFormat(_T("Process.cpp - Run with output: %s"), output.c_str()); else LogFormat("Process.cpp - Run w/o output"); +#endif std::stringstream ss; for (unsigned count = 0; argv[count] != nullptr; count++) { ss << argv[count] << ' '; std::cout << argv[count] << ' '; } +#if PROCESS_DEBUG_OUTPUT // def DEBUG_OPENVARIO std::cout << '!' << std::endl; LogFormat("Process.cpp: %s", ss.str().c_str()); #endif From 1d4a5eea2e8c3a51fe26cc0dd55093dc3e7dd4ef Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 18 Mar 2024 07:54:33 +0100 Subject: [PATCH 263/403] [Settings] DialogSettings - add flag for xcsoar_style (of menu) --- src/Dialogs/DialogSettings.cpp | 1 + src/Dialogs/DialogSettings.hpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Dialogs/DialogSettings.cpp b/src/Dialogs/DialogSettings.cpp index 537d88906b7..1bf4b562efe 100644 --- a/src/Dialogs/DialogSettings.cpp +++ b/src/Dialogs/DialogSettings.cpp @@ -9,4 +9,5 @@ DialogSettings::SetDefaults() noexcept text_input_style = TextInputStyle::Default; tab_style = TabStyle::Text; expert = false; + xcsoar_style = false; } diff --git a/src/Dialogs/DialogSettings.hpp b/src/Dialogs/DialogSettings.hpp index 4f25c345e1d..23fa6ecc8cf 100644 --- a/src/Dialogs/DialogSettings.hpp +++ b/src/Dialogs/DialogSettings.hpp @@ -28,6 +28,7 @@ struct DialogSettings { * Show the "expert" settings? */ bool expert; + bool xcsoar_style; void SetDefaults() noexcept; }; From df471002ad26dd2aca82bc8ce1fc3e05d789a020 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 27 Mar 2024 13:07:59 +0100 Subject: [PATCH 264/403] [Config] OpenSoar.config increase Version to 7.42.21.2 --- OpenSoar.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSoar.config b/OpenSoar.config index e9034cb8372..3c23358c1ef 100644 --- a/OpenSoar.config +++ b/OpenSoar.config @@ -1,4 +1,4 @@ PROGRAM_NAME=OpenSoar -PROGRAM_VERSION=7.41.21.1 +PROGRAM_VERSION=7.42.21.2 ANDROID_VERSIONCODE=21 ANDROID_PACKAGE=de.opensoar From 36d6ca1f9a0373633abfbfcffa2b239e6c48d4dd Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 27 Mar 2024 18:11:42 +0100 Subject: [PATCH 265/403] [XCI] default.xci - add a Volume toggle button (On/Off) to QuickMenu --- Data/Input/default.xci | 47 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/Data/Input/default.xci b/Data/Input/default.xci index 17ccaa45013..f3fecb85d87 100644 --- a/Data/Input/default.xci +++ b/Data/Input/default.xci @@ -1272,6 +1272,14 @@ event=AirSpace toggle label=Airspace\n$(AirspaceToggleActionName) location=34 +mode=RemoteStick +type=key +data=0 +event=Sounds toggle +event=Mode default +label=Audio On/Off +location=59 + mode=RemoteStick type=key data=0 @@ -1306,3 +1314,42 @@ event=Mode default label=Quit location=63 + +# ------------- +# Define AudioMenu buttons for +# Vario app must be connected as device A +# ------------- + +mode=AudioMenu +type=key +data=DOWN +event=Sounds quieter +label=VOLUME- (DOWN) +location=1 + +mode=AudioMenu +type=key +data=RETURN +event=Sounds toggle +label=VOLUME ON/OFF (ENTER) +location=2 + +mode=AudioMenu +type=key +data=UP +event=Sounds louder +label=VOLUME+ (UP) +location=3 + +mode=AudioMenu +type=key +data=ESCAPE +event=Mode default +label=BACK (ESC) +location=5 + +mode=default RemoteStick +type=key +data=M +event=Mode AudioMenu + From e4b566327fabb4f27f96a84fbd3089a343d116b1 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 19 Mar 2024 12:15:05 +0100 Subject: [PATCH 266/403] [XCI] split the default.xci in 2 different files for different usage --- Data/CMakeLists.txt | 12 +- Data/Input/default.xci | 18 - Data/Input/defaultOV.xci | 1316 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 1325 insertions(+), 21 deletions(-) create mode 100644 Data/Input/defaultOV.xci diff --git a/Data/CMakeLists.txt b/Data/CMakeLists.txt index 37f6fde809c..1b05d09ac2f 100644 --- a/Data/CMakeLists.txt +++ b/Data/CMakeLists.txt @@ -266,6 +266,12 @@ endif() ${_INCLUDE_OUTPUT}/InputEvents_Text2NE.cpp ${_INCLUDE_OUTPUT}/InputEvents_default.cpp ) + +if (1) +set(DEFAULT_XCI ${_DATA_INPUT}/Input/defaultOV.xci) +else() +set(DEFAULT_XCI ${_DATA_INPUT}/Input/default.xci) +endif() add_custom_command(OUTPUT ${_INCLUDE_OUTPUT}/InputCppFiles.txt COMMENT Create InputEvents_*.cpp! COMMAND ${CMAKE_COMMAND} -E make_directory ${_INCLUDE_OUTPUT} @@ -274,11 +280,11 @@ endif() COMMAND perl tools/Text2Event.pl src/Input/InputEvents.hpp >${_INCLUDE_OUTPUT}/InputEvents_Text2Event.cpp COMMAND perl tools/Text2GCE.pl src/Input/InputQueue.hpp >${_INCLUDE_OUTPUT}/InputEvents_Text2GCE.cpp COMMAND perl tools/Text2NE.pl src/Input/InputQueue.hpp >${_INCLUDE_OUTPUT}/InputEvents_Text2NE.cpp - COMMAND perl tools/xci2cpp.pl Data/Input/default.xci >${_INCLUDE_OUTPUT}/InputEvents_default.cpp - COMMAND perl tools/xci2cpp.pl Data/Input/default.xci >${_INCLUDE_OUTPUT}/InputCppFiles.txt + COMMAND perl tools/xci2cpp.pl ${DEFAULT_XCI} >${_INCLUDE_OUTPUT}/InputEvents_default.cpp + COMMAND perl tools/xci2cpp.pl ${DEFAULT_XCI} >${_INCLUDE_OUTPUT}/InputCppFiles.txt DEPENDS ${PROJECTGROUP_SOURCE_DIR}/src/Input/InputQueue.hpp ${PROJECTGROUP_SOURCE_DIR}/src/Input/InputEvents.hpp - ${_DATA_INPUT}/Input/default.xci + ${DEFAULT_XCI} WORKING_DIRECTORY ${PROJECTGROUP_SOURCE_DIR} ) diff --git a/Data/Input/default.xci b/Data/Input/default.xci index f3fecb85d87..b73607f734a 100644 --- a/Data/Input/default.xci +++ b/Data/Input/default.xci @@ -1288,24 +1288,6 @@ event=Mode default label=Restart location=60 -# OpenVario only: -mode=RemoteStick -type=key -data=0 -event=Shutdown reboot -event=Mode default -label=Reboot -location=61 - -# OpenVario only: -mode=RemoteStick -type=key -data=0 -event=Shutdown shutdown -event=Mode default -label=Shutdown -location=62 - mode=RemoteStick type=key data=0 diff --git a/Data/Input/defaultOV.xci b/Data/Input/defaultOV.xci new file mode 100644 index 00000000000..7b6c49ece60 --- /dev/null +++ b/Data/Input/defaultOV.xci @@ -0,0 +1,1316 @@ +# ------------------- +# GlideComputerEvents +# ------------------- + +mode=default +type=gce +data=TASK_START +event=Beep 1 +event=TaskTransition start + +mode=default +type=gce +data=TASK_FINISH +event=Beep 1 +event=TaskTransition finish + +mode=default +type=gce +data=TASK_NEXTWAYPOINT +event=Beep 1 +event=TaskTransition next + +mode=default +type=gce +data=GPS_CONNECTION_WAIT + +mode=default +type=gce +data=COMMPORT_RESTART + +mode=default +type=gce +data=GPS_FIX_WAIT + +mode=default +type=gce +data=STARTUP_SIMULATOR + +mode=default +type=gce +data=STARTUP_REAL + +mode=default +type=gce +data=TAKEOFF +event=AutoLogger start +event=AddWaypoint takeoff +event=StatusMessage Takeoff + +mode=default +type=gce +data=LANDING +event=StatusMessage Landing +event=AutoLogger stop + +mode=default +type=gce +data=FLIGHTMODE_FINALGLIDE_ABOVE +event=StatusMessage Above final glide + +mode=default +type=gce +data=FLIGHTMODE_FINALGLIDE_BELOW +event=StatusMessage Below final glide + +mode=default +type=gce +data=FLIGHTMODE_FINALGLIDE_TERRAIN +event=StatusMessage Final glide through terrain + +mode=default +type=gce +data=LANDABLE_UNREACHABLE +event=Beep 1 + +# ------------ +# mode=default +# ------------ + +mode=Nav1 Nav2 Display1 Display2 Config1 Config2 Config3 Info1 Info2 Menu Vario1 Vario2 +type=key +data=ESCAPE +event=Mode default + +mode=default pan +type=key +data=ESCAPE +event=Page restore + +mode=default.Traffic +type=key +data=RETURN +event=Traffic details + +###### pan mode + +mode=pan +type=key +data=DOWN +event=Pan down + +mode=pan +type=key +data=UP +event=Pan up + +mode=pan +type=key +data=LEFT +event=Pan left + +mode=pan +type=key +data=RIGHT +event=Pan right + +mode=pan +type=key +data=APP1 +event=Pan off +label=Cancel +location=1 + +mode=pan +type=key +data=APP2 +event=Zoom in +label=Zoom\n+ +location=2 + +mode=pan +type=key +data=APP3 +event=Zoom out +label=Zoom\n- +location=3 + +mode=pan +type=key +data=APP4 +event=NearestMapItems +label=What's here? +location=4 + +mode=pan +type=key +data=F1 +event=Zoom in +location=5 + +mode=pan +type=key +data=F3 +event=Zoom out +location=6 + +mode=pan +type=key +data=RETURN +event=NearestMapItems +location=7 + +###### main entry buttons + +mode=default +type=key +data=F1 +event=QuickMenu + +mode=default +type=key +data=F2 +event=Analysis +event=Mode default + +mode=default +type=key +data=F3 +event=Checklist +event=Mode default + +mode=default +type=key +data=F4 +event=FlarmTraffic +event=Mode default + +mode=default +type=key +data=F5 +event=GotoLookup +event=Mode default + +mode=default +type=key +data=F6 +event=Setup Alternates +event=Mode default + +mode=default +type=key +data=F7 +event=Setup Task +event=Mode default + +mode=default +type=key +data=F8 +event=Setup Basic +event=Mode default + +mode=default +type=key +data=MENU +event=Mode Menu + +mode=default +type=key +data=APP1 +event=Mode Nav1 + +mode=default +type=key +data=APP2 +event=Mode Display1 + +mode=default +type=key +data=APP3 +event=Mode Config1 + +mode=default +type=key +data=APP4 +event=Mode Info1 + +# Always active buttons. (unless over-written) + +mode=default +type=key +data=DOWN +event=Zoom out + +mode=default +type=key +data=UP +event=Zoom in + +mode=default +type=key +data=RETURN +event=FLARMRadar toggle +event=ClearAirspaceWarnings +event=ClearStatusMessages + +mode=default +type=key +data=LEFT +event=ScreenModes previous + +mode=default +type=key +data=RIGHT +event=ScreenModes next + +# Gestures + +mode=default +type=gesture +data=U +event=Zoom in + +mode=default +type=gesture +data=D +event=Zoom out + +mode=default +type=gesture +data=UD +event=Zoom auto show +event=Zoom auto on + +mode=default +type=gesture +data=R +event=ScreenModes previous + +mode=default +type=gesture +data=L +event=ScreenModes next + +mode=default +type=gesture +data=DR +event=WaypointDetails select + +mode=default +type=gesture +data=DL +event=Setup Alternates + +mode=default +type=gesture +data=DU +event=Mode Menu + +mode=default +type=gesture +data=RD +event=Calculator + +mode=default +type=gesture +data=URD +event=Analysis + +mode=default +type=gesture +data=LDR +event=Checklist + +mode=default +type=gesture +data=URDL +event=Pan on + +mode=default +type=gesture +data=LDRDL +event=Status all + +### + +mode=default +type=key +data=6 +event=Setup Basic +event=Mode default + +mode=default +type=key +data=7 +event=Calculator + +#mode=default +#type=key +#data=8 +#event=Setup Task +#event=Mode default + +mode=default +type=key +data=9 +event=Setup Target + +#mode=default +#type=key +#data=0 +#event=ArmAdvance show +#event=ArmAdvance toggle + + +# ------------- +# mode=Nav1 +# ------------- + +mode=Nav1 +type=key +data=APP1 +event=Mode Nav2 +label=Nav\nPage 2/2 +location=1 + +mode=Nav1 +type=key +data=6 +event=Calculator +event=Mode default +label=Task Manager +location=5 + +mode=Nav1 +type=key +data=7 +event=AdjustWaypoint previousarm +label=$(WaypointPreviousArm) +location=6 + +mode=Nav1 +type=key +data=8 +event=AdjustWaypoint nextarm +label=$(WaypointNextArm) +location=7 + +mode=Nav1 +type=key +data=9 +event=WaypointDetails select +event=Mode default +label=Waypoint List$(CheckWaypointFile) +location=8 + +mode=Nav1 +type=key +data=0 +event=Setup Alternates +event=Mode default +label=Alternates$(CheckWaypointFile) +location=9 + +# ------------- +# mode=Nav2 +# ------------- + +mode=Nav2 +type=key +data=APP1 +event=Mode default +label=Cancel +location=1 + +mode=Nav2 +type=key +data=6 +event=Mode default +event=AbortTask toggle +label=Task\n$(TaskAbortToggleActionName)$(CheckWaypointFile) +location=5 + +mode=Nav2 +type=key +data=7 +event=Mode default +event=StatusMessage Dropped marker +event=Logger note Mark +event=MarkLocation +label=Marker Drop +location=6 + +mode=Nav2 +type=key +data=8 +event=Mode default +event=StatusMessage Pilot event announced +event=Logger note PEV +event=PilotEvent +label=Pilot Event Announce +location=7 + +mode=Nav2 +type=key +data=9 +event=Setup Target +event=Mode default +label=Target Show$(CheckTask)$(CheckTaskResumed) +location=8 + +# ------------- +# mode=Display1 +# ------------- + +mode=Display1 +type=key +data=APP2 +event=Mode Display2 +label=Display\nPage 2/2 +location=2 + + +mode=Display1 +type=key +data=6 +event=Zoom in +label=Zoom\n+ +location=5 + +mode=Display1 +type=key +data=7 +event=Zoom out +label=Zoom\n- +location=6 + +mode=Display1 +type=key +data=8 +event=Zoom auto show +event=Zoom auto toggle +label=Zoom\n$(ZoomAutoToggleActionName) +location=7 + +mode=Display1 +type=key +data=9 +event=ScreenModes cycle +label=Page Show\n$(NextPageName) +location=8 + +mode=Display1 +type=key +data=0 +event=Pan on +label=Pan Mode +location=9 + +# ------------- +# mode=Display2 +# ------------- + +mode=Display2 +type=key +data=APP2 +event=Mode default +label=Cancel +location=2 + +mode=Display2 +type=key +data=6 +event=DeclutterLabels show +event=DeclutterLabels toggle +label=Labels\n$(MapLabelsToggleActionName) +location=5 + +mode=Display2 +type=key +data=7 +event=SnailTrail show +event=SnailTrail toggle +label=Trail\n$(SnailTrailToggleName) +location=6 + +mode=Display2 +type=key +data=8 +event=TerrainTopography terrain toggle +label=Terrain\n$(TerrainToggleActionName) +location=7 + +mode=Display2 +type=key +data=9 +event=TerrainTopography topography toggle +label=Topo.\n$(TopographyToggleActionName) +location=8 + +mode=Display2 +type=key +data=0 +event=AirSpace toggle +label=Airspace\n$(AirspaceToggleActionName) +location=9 + +# ------------- +# mode=Config1 +# ------------- +mode=Config1 +type=key +data=APP3 +event=Mode Config2 +label=Config\nPage 2/3 +location=3 + +mode=Config1 +type=key +data=6 +event=Setup System +event=Mode default +label=System +location=5 + +mode=Config1 +type=key +data=7 +event=Setup Plane +event=Mode default +label=Plane +location=6 + +mode=Config1 +type=key +data=8 +event=Device list +event=Mode default +label=Devices +location=7 + +mode=Config1 +type=key +data=9 +event=Setup Basic +event=Mode default +label=Flight +location=8 + +mode=Config1 +type=key +data=0 +event=Setup Wind +event=Mode default +label=Wind +location=9 + +# ------------- +# mode=Config2 +# ------------- +mode=Config2 +type=key +data=APP3 +event=Mode Config3 +label=Config\nPage 3/3 +location=3 + +mode=Config2 +type=key +data=6 +event=Setup Profile +event=Mode default +label=Profiles +location=5 + +mode=Config2 +type=key +data=8 +event=WaypointEditor +event=Mode default +label=Waypoint Editor +location=7 + +mode=Config2 +type=key +data=9 +event=FileManager +event=Mode default +label=File Manager +location=8 + +mode=Config2 +type=key +data=0 +event=Setup Replay +event=Mode default +label=Replay$(CheckReplay) +location=9 + +# ------------- +# mode=Config3 +# ------------- +mode=Config3 +type=key +data=APP3 +event=Mode default +label=Cancel +location=3 + +mode=Config3 +type=key +data=6 +event=Logger show +event=Logger toggle ask +label=Logger\n$(LoggerActive)$(CheckLogger) +location=5 + +mode=Config3 +type=key +data=8 +event=Logger nmea +label=Raw Logger$(CheckLogger) +location=6 + +mode=Config3 +type=key +data=7 +event=RunLuaFile +event=Mode default +label=Lua +location=7 + +mode=Config3 +type=key +data=9 +event=Mode Vario1 +label=Vega$(CheckVega) +location=8 + +# ------------- +# mode=Vario1 +# ------------- + +mode=Vario1 +type=key +data=APP3 +event=Mode Vario2 +label=Vega\nPage 2/2 +location=3 + +mode=Vario1 +type=key +data=6 +event=Setup Switches +event=Mode default +label=Airframe Switches +location=5 + +mode=Vario1 +type=key +data=8 +event=AdjustVarioFilter xdemo +label=Manual Demo +location=7 + +mode=Vario1 +type=key +data=9 +event=AdjustVarioFilter zero +label=Setup Stall +location=8 + +mode=Vario1 +type=key +data=0 +event=AdjustVarioFilter accel +label=Accel +location=9 + +# ------------- +# mode=Vario2 +# ------------- + +mode=Vario2 +type=key +data=APP3 +event=Mode default +label=Vega\n2/2 +location=3 + +mode=Vario2 +type=key +data=6 +event=AdjustVarioFilter zero +event=StatusMessage Vario ASI zeroed +label=ASI Zero +location=5 + +mode=Vario2 +type=key +data=7 +event=StatusMessage Accelerometer leveled +label=Accel Zero +location=6 + +mode=Vario2 +type=key +data=8 +event=AdjustVarioFilter save +event=StatusMessage Stored to EEPROM +label=Store +location=7 + +mode=Vario2 +type=key +data=9 +event=AdjustVarioFilter demostf +label=Cruise Demo +location=8 + +mode=Vario2 +type=key +data=0 +event=AdjustVarioFilter democlimb +label=Climb Demo +location=9 + +# ------------- +# mode=Info1 +# ------------- +mode=Info1 +type=key +data=APP4 +event=Mode Info2 +label=Info\nPage 2/3 +location=4 + +mode=Info1 +type=key +data=6 +event=FlarmTraffic +event=Mode default +label=FLARM Radar$(CheckFLARM) +location=5 + +mode=Info1 +type=key +data=7 +event=Weather +event=Mode default +label=Weather +location=6 + +mode=Info1 +type=key +data=8 +event=NearestMapItems +event=Mode default +label=What's here? +location=7 + +mode=Info1 +type=key +data=9 +event=Checklist +event=Mode default +label=Checklist +location=8 + +mode=Info1 +type=key +data=0 +event=Analysis +event=Mode default +label=Analysis +location=9 + +# ------------- +# mode=Info2 +# ------------- +mode=Info2 +type=key +data=APP4 +event=Mode Info3 +label=Info\nPage 3/3 +location=4 + +mode=Info2 +type=key +data=6 +event=Status all +event=Mode default +label=Status +location=5 + +mode=Info2 +type=key +data=8 +event=Setup Teamcode +event=Mode default +label=Team Code +location=7 + +mode=Info2 +type=key +data=9 +event=FlarmDetails +event=Mode default +label=Traffic List +location=8 + +mode=Info2 +type=key +data=0 +event=ThermalAssistant +event=Mode default +label=Thermal Assistant +location=9 + +# ------------- +# mode=Info3 +# ------------- +mode=Info3 +type=key +data=APP4 +event=Mode default +label=Cancel +location=4 + + +mode=Info3 +type=key +data=6 +event=Credits +event=Mode default +label=Credits +location=5 + +mode=Info3 +type=key +data=7 +event=AirSpace list +event=Mode default +label=Airspaces +location=6 + +mode=Info3 +type=key +data=8 +event=RepeatStatusMessage +label=Message Repeat +location=7 + +# ------------- +# mode=Menu +# ------------- + +mode=Menu +type=key +data=APP1 +event=Mode Nav1 +label=Nav +location=1 + +mode=Menu +type=key +data=APP2 +event=Mode Display1 +label=Display +location=2 + +mode=Menu +type=key +data=APP3 +event=Mode Config1 +label=Config +location=3 + +mode=Menu +type=key +data=APP4 +event=Mode Info1 +label=Info +location=4 + +mode=Menu +type=key +data=9 +event=LockScreen +event=Mode default +label=Lock Screen +location=7 + +mode=Menu +type=key +data=9 +event=Mode default +label=Cancel +location=8 + +mode=Menu +type=key +data=0 +event=Exit system +event=Mode default +label=Quit +location=9 + +# ---------------------------------- +# mode=default.TA (ThermalAssistant) +# ---------------------------------- + +# --------------------- +# mode=Display1.Traffic +# --------------------- + +mode=Display1.Traffic +type=key +data=6 +event=Traffic zoom in +label=Zoom\n+ +location=5 + +mode=Display1.Traffic +type=key +data=7 +event=Traffic zoom out +label=Zoom\n- +location=6 + +mode=Display1.Traffic +type=key +data=8 +event=Traffic zoom auto toggle +label=Zoom\n$(TrafficZoomAutoToggleActionName) +location=7 + +mode=Display1.Traffic +type=key +data=0 +event=Traffic northup toggle +label=$(TrafficNorthUpToggleActionName) +location=9 + +mode=Display2.Traffic +type=key +data=6 +event=Traffic label toggle +label=AVG/ALT +location=5 + +# ------------- +# mode=RemoteStick +# ------------- + +mode=RemoteStick +type=key +data=0 +event=Calculator +event=Mode default +label=Task +location=0 + +mode=RemoteStick +type=key +data=0 +event=AdjustWaypoint previousarm +label=$(WaypointPreviousArm) +location=1 + +mode=RemoteStick +type=key +data=0 +event=AdjustWaypoint nextarm +label=$(WaypointNextArm) +location=2 + +mode=RemoteStick +type=key +data=0 +event=WaypointDetails select +event=Mode default +label=Waypoint List$(CheckWaypointFile) +location=3 + +mode=RemoteStick +type=key +data=0 +event=Setup Alternates +event=Mode default +label=Alternates$(CheckWaypointFile) +location=4 + +mode=RemoteStick +type=key +data=0 +event=Mode default +event=AbortTask toggle +label=Task\n$(TaskAbortToggleActionName)$(CheckWaypointFile) +location=5 + +mode=RemoteStick +type=key +data=0 +event=GotoLookup +event=Mode default +label=GoTo$(CheckWaypointFile) +location=6 + +mode=RemoteStick +type=key +data=0 +event=Setup Target +event=Mode default +label=Target Show$(CheckTask)$(CheckTaskResumed) +location=7 + + +mode=RemoteStick +type=key +data=0 +event=Zoom auto show +event=Zoom auto toggle +label=Zoom\n$(ZoomAutoToggleActionName) +location=9 + +mode=RemoteStick +type=key +data=0 +event=Mode default +event=StatusMessage Dropped marker +event=Logger note Mark +event=MarkLocation +label=Marker Drop +location=10 + +mode=RemoteStick +type=key +data=0 +event=Pan on +label=Pan Mode +location=11 + +mode=RemoteStick +type=key +data=0 +event=DeclutterLabels show +event=DeclutterLabels toggle +label=Labels\n$(MapLabelsToggleActionName) +location=12 + +mode=RemoteStick +type=key +data=0 +event=SnailTrail show +event=SnailTrail toggle +label=Trail\n$(SnailTrailToggleName) +location=13 + +mode=RemoteStick +type=key +data=0 +event=TerrainTopography terrain toggle +label=Terrain\n$(TerrainToggleActionName) +location=14 + +mode=RemoteStick +type=key +data=0 +event=TerrainTopography topography toggle +label=Topo.\n$(TopographyToggleActionName) +location=15 + + +mode=RemoteStick +type=key +data=0 +event=MacCready auto show +event=MacCready auto toggle +label=$(CheckAutoMc)MC\n$(MacCreadyToggleActionName) +location=16 + +mode=RemoteStick +type=key +data=0 +event=Setup Basic +event=Mode default +label=Flight Setup +location=17 + +mode=RemoteStick +type=key +data=0 +event=Setup Wind +event=Mode default +label=Setup Wind +location=18 + +mode=RemoteStick +type=key +data=0 +event=Setup System +event=Mode default +label=Setup System +location=19 + +mode=RemoteStick +type=key +data=0 +event=Setup Airspace +event=Mode default +label=Settings Airspace$(CheckAirspace) +location=20 + +mode=RemoteStick +type=key +data=0 +event=Logger show +event=Logger toggle ask +label=Logger\n$(LoggerActive)$(CheckLogger) +location=21 + +mode=RemoteStick +type=key +data=0 +event=Logger nmea +label=Raw Logger$(CheckLogger) +location=22 + +mode=RemoteStick +type=key +data=0 +event=Device list +event=Mode default +label=Devices +location=23 + +mode=RemoteStick +type=key +data=0 +event=Setup Plane +event=Mode default +label=Setup Plane +location=24 + +mode=RemoteStick +type=key +data=0 +event=FlarmTraffic +label=FLARM Radar$(CheckFLARM) +location=25 + +mode=RemoteStick +type=key +data=0 +event=Weather +event=Mode default +label=Weather +location=26 + +mode=RemoteStick +type=key +data=0 +event=NearestAirspaceDetails +event=Mode default +label=Nearest Airspace$(CheckAirspace) +location=27 + +mode=RemoteStick +type=key +data=0 +event=Checklist +event=Mode default +label=Checklist +location=28 + +mode=RemoteStick +type=key +data=0 +event=Analysis +event=Mode default +label=Analysis +location=29 + +mode=RemoteStick +type=key +data=0 +event=Status all +event=Mode default +label=Status +location=30 + +mode=RemoteStick +type=key +data=0 +event=ThermalAssistant +event=Mode default +label=Thermal Assistant$(CheckCircling) +location=31 + +mode=RemoteStick +type=key +data=0 +event=FileManager +event=Mode default +label=File Manager +location=32 + +mode=RemoteStick +type=key +data=0 +event=Mode default +event=StatusMessage Pilot event announced +event=Logger note PEV +event=PilotEvent +label=Pilot Event Announce +location=33 + +mode=RemoteStick +type=key +data=0 +event=AirSpace toggle +label=Airspace\n$(AirspaceToggleActionName) +location=34 + +mode=RemoteStick +type=key +data=0 +event=Sounds toggle +event=Mode default +label=Audio On/Off +location=59 + +mode=RemoteStick +type=key +data=0 +event=Exit restart +event=Mode default +label=Restart +location=60 + +# OpenVario only: +mode=RemoteStick +type=key +data=0 +event=Shutdown reboot +event=Mode default +label=Reboot +location=61 + +# OpenVario only: +mode=RemoteStick +type=key +data=0 +event=Shutdown shutdown +event=Mode default +label=Shutdown +location=62 + +mode=RemoteStick +type=key +data=0 +event=Exit system +event=Mode default +label=Quit +location=63 + From 17fd60bb7c0eac621c49d0213d8206c49af390b8 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 27 Mar 2024 18:14:27 +0100 Subject: [PATCH 267/403] [OV] OpenVario - rework menu structure --- .../System/Setting/RotationWidget.cpp | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/OpenVario/System/Setting/RotationWidget.cpp b/src/OpenVario/System/Setting/RotationWidget.cpp index bc077df487c..04395066e8b 100644 --- a/src/OpenVario/System/Setting/RotationWidget.cpp +++ b/src/OpenVario/System/Setting/RotationWidget.cpp @@ -61,41 +61,45 @@ class SettingRotationWidget final : public RowFormWidget { void SaveRotation(const std::string &rotationvalue); }; +/*/ void -SettingRotationWidget::SaveRotation(const std::string &rotationString) +SettingRotationWidget::SaveRotation(const int rotationInt) { + File::WriteExisting(Path(_T("/sys/class/graphics/fbcon/rotate")), (rotationString).c_str()); - int rotationInt = stoi(rotationString); +// int rotationInt = stoi(rotationString); // ChangeConfigInt("rotation", rotationInt, ovdevice.GetSettingsConfig()); // TODO(August2111): move the from ovdevice.settings to ovdevice.sysetm LoadConfigFile(ovdevice.system_map, ovdevice.GetSystemConfig()); // -> OpenVarioBaseMenu->StartUp! ovdevice.rotation = (DisplayOrientation) stoi(rotationString); - ovdevice.system_map.insert_or_assign("Rotation", std::to_string((unsigned) ovdevice.rotation)); + ovdevice.system_map.insert_or_assign("rotation", std::to_string((unsigned) ovdevice.rotation)); WriteConfigFile(ovdevice.system_map, ovdevice.GetSystemConfig()); } +*/ void SettingRotationWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { AddButton(_T("Landscape"), [this](){ - SaveRotation("0"); - Display::Rotate(DisplayOrientation::LANDSCAPE); + // SaveRotation("2"); + // Display::Rotate(DisplayOrientation::LANDSCAPE); + ovdevice.SetRotation(DisplayOrientation::LANDSCAPE); }); AddButton(_T("Portrait (90°)"), [this](){ - SaveRotation("1"); - Display::Rotate(DisplayOrientation::REVERSE_PORTRAIT); + //SaveRotation("1"); + ovdevice.SetRotation(DisplayOrientation::REVERSE_PORTRAIT); }); AddButton(_T("Landscape (180°)"), [this](){ - SaveRotation("2"); - Display::Rotate(DisplayOrientation::REVERSE_LANDSCAPE); + // SaveRotation("4"); + ovdevice.SetRotation(DisplayOrientation::REVERSE_LANDSCAPE); }); AddButton(_T("Portrait (270°)"), [this](){ - SaveRotation("3"); - Display::Rotate(DisplayOrientation::PORTRAIT); + // SaveRotation("3"); + ovdevice.SetRotation(DisplayOrientation::PORTRAIT); }); } @@ -109,9 +113,3 @@ ShowRotationSettingsWidget(ContainerWindow &parent, sub_dialog.AddButton(_("Close"), mrOK); return sub_dialog.ShowModal(); } - -// std::unique_ptr -// CreateSettingRotationWidget() noexcept -// { -// return std::make_unique(); -// } From 115c292eae0c8c72cae12890ef06e431ef74b156 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 4 Apr 2024 14:00:36 +0200 Subject: [PATCH 268/403] [OV] SystemSettingsWidget - rework --- src/OpenVario/SystemSettingsWidget.cpp | 92 +++++++++++++++++--------- src/OpenVario/SystemSettingsWidget.hpp | 2 +- 2 files changed, 61 insertions(+), 33 deletions(-) diff --git a/src/OpenVario/SystemSettingsWidget.cpp b/src/OpenVario/SystemSettingsWidget.cpp index 429194e02fa..1b6357a8771 100644 --- a/src/OpenVario/SystemSettingsWidget.cpp +++ b/src/OpenVario/SystemSettingsWidget.cpp @@ -13,34 +13,38 @@ #include "Form/DataField/Boolean.hpp" #include "Form/DataField/Listener.hpp" #include "Form/DataField/Enum.hpp" +#include "Form/DataField/Integer.hpp" #include "Interface.hpp" #include "UIGlobals.hpp" #include "ui/window/SingleWindow.hpp" #include "Dialogs/Message.hpp" #include "./LogFile.hpp" +#include "UIActions.hpp" +#include "UtilsSettings.hpp" #include "OpenVario/System/OpenVarioDevice.hpp" #include "OpenVario/System/WifiDialogOV.hpp" #include - +#include enum ControlIndex { + FW_VERSION, FIRMWARE, ENABLED, - FW_IMAGE, ROTATION, BRIGHTNESS, SENSORD, VARIOD, SSH, TIMEOUT, - SHELL_BUTTON, WIFI_BUTTON, +#ifdef _DEBUG INTEGERTEST, +#endif }; @@ -56,12 +60,14 @@ class SystemSettingsWidget final : public RowFormWidget, DataFieldListener { /* virtual methods from class Widget */ void Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept override; bool Save(bool &changed) noexcept override; + bool CheckChanged(bool &changed) noexcept; - // int OnShow(const UI::SingleWindow &parent) noexcept; private: /* methods from DataFieldListener */ void OnModified(DataField &df) noexcept override; + + unsigned brightness; }; #endif static constexpr StaticEnumChoice timeout_list[] = { @@ -104,9 +110,20 @@ void SystemSettingsWidget::OnModified([[maybe_unused]] DataField &df) noexcept { if (IsDataField(ENABLED, df)) { - const DataFieldBoolean &dfb = (const DataFieldBoolean &)df; - SetEnabled(dfb.GetValue()); - } + // const DataFieldBoolean &dfb = ; + SetEnabled(((const DataFieldBoolean &)df).GetValue()); + } else if (IsDataField(ROTATION, df)) { + // ShowMessageBox(_T("Set Rotation"), _T("Rotation"), MB_OK); + // ovdevice.SetRotation((DisplayOrientation)((const DataFieldEnum &)df).GetValue()); + } else if (IsDataField(BRIGHTNESS, df)) { + // const DataFieldInteger &dfi = (const DataFieldInteger &)df; + // (DataFieldInteger*)df) + ovdevice.SetBrightness(((const DataFieldInteger &)df).GetValue() / 10); + } else if (IsDataField(FIRMWARE, df)) { + // (DataFieldInteger*)df) + // ConvertString + ShowMessageBox(_T("FirmWare-Selection"), _T("??File??"), MB_OKCANCEL); + } } void @@ -115,25 +132,29 @@ SystemSettingsWidget::Prepare(ContainerWindow &parent, { RowFormWidget::Prepare(parent, rc); - ovdevice.ssh = (unsigned)ovdevice.GetSSHStatus(); - ovdevice.sensord = ovdevice.GetSystemStatus("sensord"); - ovdevice.variod = ovdevice.GetSystemStatus("variod"); - + brightness = ovdevice.brightness * 10; - const TCHAR version[] = _T(PROGRAM_VERSION); -// auto version = _T("3.2.20 (hard coded)"); - AddReadOnly(_("OV-Firmware-Version"), _("Current firmware version of OpenVario"), version); + AddReadOnly(_("Current FW"), _("Current firmware version of OpenVario"), +#if defined(PROGRAM_VERSION) + _T(PROGRAM_VERSION)); +#else + _T("7.42.21.3")); +#endif + // std::string_view version = PROGRAM_VERSION; + AddFile(_("OV-Firmware"), _("Current firmware file version of OpenVario"), + "OVImage", _T("*.img.gz\0"), FileType::IMAGE); // no callback... , this); + AddBoolean( _("Settings Enabled"), _("Enable the Settings Page"), ovdevice.enabled, this); AddEnum(_("Rotation"), _("Rotation Display OpenVario"), - rotation_list, (unsigned)ovdevice.rotation); + rotation_list, (unsigned)ovdevice.rotation, this); AddInteger(_("Brightness"), - _("Brightness Display OpenVario"), _T("%d"), _T("%d%%"), 10, - 100, 10, ovdevice.brightness); + _("Brightness Display OpenVario"), _T("%d%%"), _T("%d%%"), 10, + 100, 10, brightness, this); AddBoolean(_("SensorD"), _("Enable the SensorD"), ovdevice.sensord, this); AddBoolean(_("VarioD"), _("Enable the VarioD"), ovdevice.variod, this); AddEnum(_("SSH"), _("Enable the SSH Connection"), enable_list, @@ -141,25 +162,25 @@ SystemSettingsWidget::Prepare(ContainerWindow &parent, AddEnum(_("Program Timeout"), _("Timeout for Program Start."), timeout_list, ovdevice.timeout); - // auto Btn_Shell = - AddButton( - _T("Exit to Shell"), [this]() { - LogFormat("Exit to Shell"); - exit(111); // without cleaning up???? - }); - AddButton( _T("Settings Wifi"), [this]() { ShowWifiDialog(); }); - +#ifdef _DEBUG AddInteger(_("IntegerTest"), _("IntegerTest."), _T("%d"), _T("%d"), 0, 99999, 1, ovdevice.iTest); +#endif SetEnabled(ovdevice.enabled); } +bool +SystemSettingsWidget::CheckChanged([[maybe_unused]] bool &_changed) noexcept +{ + return false; +} + bool SystemSettingsWidget::Save([[maybe_unused]] bool &_changed) noexcept { @@ -178,17 +199,19 @@ SystemSettingsWidget::Save([[maybe_unused]] bool &_changed) noexcept changed = true; } - if (SaveValueInteger(BRIGHTNESS, "Brightness", ovdevice.brightness)) { - ovdevice.settings.insert_or_assign( - "Brightness", std::to_string(ovdevice.brightness)); + if (SaveValueInteger(BRIGHTNESS, "Brightness", brightness)) { + ovdevice.SetBrightness(brightness/10); changed = true; } - if (SaveValueInteger(INTEGERTEST, "iTest",ovdevice.iTest)) { +#ifdef _DEBUG + if (SaveValueInteger(INTEGERTEST, "iTest", ovdevice.iTest)) { ovdevice.settings.insert_or_assign( "iTest", std::to_string(ovdevice.iTest)); changed = true; } +#endif + #if 0 // TOD(August2111) Only Test ovdevice.settings.insert_or_assign("OpenSoarData", "D:/Data/OpenSoarData"); @@ -198,8 +221,11 @@ SystemSettingsWidget::Save([[maybe_unused]] bool &_changed) noexcept WriteConfigFile(ovdevice.settings, ovdevice.GetSettingsConfig()); } - if (SaveValueEnum(ROTATION, ovdevice.rotation)) - ovdevice.SetRotation(ovdevice.rotation); + if (SaveValueEnum(ROTATION, ovdevice.rotation)) { + // ovdevice.SetRotation(ovdevice.rotation); + // restart = true; + require_restart = changed = true; + } if (SaveValueEnum(SSH, ovdevice.ssh)) ovdevice.SetSSHStatus((SSHStatus)ovdevice.ssh); @@ -210,6 +236,7 @@ SystemSettingsWidget::Save([[maybe_unused]] bool &_changed) noexcept if (SaveValue(VARIOD, ovdevice.variod)) ovdevice.SetSystemStatus("variod", ovdevice.variod); + _changed = changed; return true; } @@ -221,9 +248,11 @@ ShowSystemSettingsWidget(ContainerWindow &parent, WidgetDialog::Full{}, (UI::SingleWindow &) parent, look, _T("OpenVario System Settings")); sub_dialog.SetWidget(); + sub_dialog.AddButton(_("Save"), mrOK); sub_dialog.AddButton(_("Close"), mrOK); return sub_dialog.ShowModal(); } +#endif std::unique_ptr CreateSystemSettingsWidget() noexcept @@ -231,6 +260,5 @@ CreateSystemSettingsWidget() noexcept return std::make_unique(); } -#endif diff --git a/src/OpenVario/SystemSettingsWidget.hpp b/src/OpenVario/SystemSettingsWidget.hpp index 07e7dae42fc..912e3148dd1 100644 --- a/src/OpenVario/SystemSettingsWidget.hpp +++ b/src/OpenVario/SystemSettingsWidget.hpp @@ -13,7 +13,7 @@ struct DialogLook; bool ShowSystemSettingsWidget(ContainerWindow &parent, - const DialogLook &look) noexcept; + const DialogLook &look) noexcept; std::unique_ptr CreateSystemSettingsWidget() noexcept; From f1f288e5a12c9af571fc65d7b50e9c9d80603b1a Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 12 Apr 2024 22:11:59 +0200 Subject: [PATCH 269/403] [build/OV] Makefile - remove ov.mk (for OpenVarioBaseMenu) --- Makefile | 3 --- 1 file changed, 3 deletions(-) diff --git a/Makefile b/Makefile index 96aeaa558b5..9a830c483f0 100644 --- a/Makefile +++ b/Makefile @@ -272,9 +272,6 @@ endif ifeq ($(TARGET_IS_KOBO),y) include $(topdir)/build/kobo.mk -ifeq ($(USE_POLL_EVENT),y) -include $(topdir)/build/ov.mk -endif endif include $(topdir)/build/hot.mk From 2647562991c507af3eb1a231bfe481a4fca7d3d9 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 4 Apr 2024 14:30:08 +0200 Subject: [PATCH 270/403] [OV] dlgConfiguration.cpp - add CheckBoxControl xcsoar_style (only for definition __August__) --- src/Dialogs/Settings/dlgConfiguration.cpp | 94 +++++++++++++++++++++-- 1 file changed, 88 insertions(+), 6 deletions(-) diff --git a/src/Dialogs/Settings/dlgConfiguration.cpp b/src/Dialogs/Settings/dlgConfiguration.cpp index f8731586212..08107ed32a7 100644 --- a/src/Dialogs/Settings/dlgConfiguration.cpp +++ b/src/Dialogs/Settings/dlgConfiguration.cpp @@ -43,6 +43,7 @@ #include "Audio/Features.hpp" #include "UtilsSettings.hpp" #include "net/http/Features.hpp" +#include "ui/window/SingleWindow.hpp" #ifdef HAVE_PCM_PLAYER #include "Panels/AudioVarioConfigPanel.hpp" @@ -179,22 +180,42 @@ static constexpr TabMenuGroup main_menu_captions[] = { static void OnUserLevel(bool expert) noexcept; +#ifdef __AUGUST__ +static void OnXCSoarStyle(bool expert) noexcept; +#endif + class ConfigurationExtraButtons final : public NullWidget { struct Layout { +#ifdef __AUGUST__ + PixelRect expert, xcsoar_style, button2, button1; + + Layout(const PixelRect &rc) + : expert(rc), xcsoar_style(rc), button2(rc), button1(rc) { +#else PixelRect expert, button2, button1; - Layout(const PixelRect &rc):expert(rc), button2(rc), button1(rc) { + Layout(const PixelRect &rc) + : expert(rc), button2(rc), button1(rc) { +#endif const unsigned height = rc.GetHeight(); const unsigned max_control_height = ::Layout::GetMaximumControlHeight(); if (height >= 3 * max_control_height) { expert.bottom = expert.top + max_control_height; +#ifdef __AUGUST__ + xcsoar_style.top = expert.bottom; + xcsoar_style.bottom = xcsoar_style.top + max_control_height; +#endif + button1.top = button2.bottom = rc.bottom - max_control_height; button2.top = button2.bottom - max_control_height; } else { expert.right = button2.left = unsigned(rc.left * 2 + rc.right) / 3; +#ifdef __AUGUST__ + xcsoar_style.right = expert.right; +#endif button2.right = button1.left = unsigned(rc.left + rc.right * 2) / 3; } } @@ -203,6 +224,9 @@ class ConfigurationExtraButtons final const DialogLook &look; CheckBoxControl expert; +#ifdef __AUGUST__ + CheckBoxControl xcsoar_style; +#endif Button button2, button1; bool borrowed2, borrowed1; @@ -247,7 +271,11 @@ class ConfigurationExtraButtons final expert.Create(parent, look, _("Expert"), layout.expert, style, [](bool value){ OnUserLevel(value); }); - +#ifdef __AUGUST__ + xcsoar_style.Create(parent, look, _("XCSoar"), + layout.xcsoar_style, style, + [](bool value){ OnXCSoarStyle(value); }); +#endif button2.Create(parent, look.button, _T(""), layout.button2, style); button1.Create(parent, look.button, _T(""), layout.button1, style); } @@ -257,6 +285,10 @@ class ConfigurationExtraButtons final expert.SetState(CommonInterface::GetUISettings().dialog.expert); expert.MoveAndShow(layout.expert); +#ifdef __AUGUST__ + xcsoar_style.SetState(CommonInterface::GetUISettings().dialog.xcsoar_style); + xcsoar_style.MoveAndShow(layout.xcsoar_style); +#endif if (borrowed2) button2.MoveAndShow(layout.button2); @@ -271,6 +303,9 @@ class ConfigurationExtraButtons final void Hide() noexcept override { expert.FastHide(); +#ifdef __AUGUST__ + xcsoar_style.FastHide(); +#endif button2.FastHide(); button1.FastHide(); #ifdef IS_OPENVARIO @@ -292,6 +327,9 @@ class ConfigurationExtraButtons final void Move(const PixelRect &rc) noexcept override { Layout layout(rc); expert.Move(layout.expert); +#ifdef __AUGUST__ + xcsoar_style.Move(layout.xcsoar_style); +#endif button2.Move(layout.button2); button1.Move(layout.button1); } @@ -328,6 +366,33 @@ OnUserLevel(bool expert) noexcept pager->PagerWidget::Move(pager->GetPosition()); } +#ifdef __AUGUST__ +static void +OnXCSoarStyle(bool xcsoar_style) noexcept +{ + CommonInterface::SetUISettings().dialog.xcsoar_style = xcsoar_style; + Profile::Set(ProfileKeys::ExtendMenu, xcsoar_style); + + /* force layout update */ + pager->PagerWidget::Move(pager->GetPosition()); +} + + /** + * save the settings in the dialog from menu page. + */ +static void +OnSaveClicked(WidgetDialog &dialog) +{ + bool changed = false; + + // PagerWidget +// PagerWidget current = (PagerWidget)dialog.GetWidget(); + if (pager->SaveCurrent(changed)) + // if ((PagerWidget) dialog.GetWidget()).SaveCurrent(changed)) + ; +} +#endif + /** * close dialog from menu page. from content, goes to menu page */ @@ -336,8 +401,19 @@ OnCloseClicked(WidgetDialog &dialog) { if (pager->GetCurrentIndex() == 0) dialog.SetModalResult(mrOK); - else + else { + + CreateWindowWidget *w = &(CreateWindowWidget&)pager->GetCurrentWidget(); + bool changed = false; + if (w->Save(changed)) + // if (w.prepared && !w.widget->Save(changed)) + ; + // return ; + +// return true; + pager->ClickPage(0); + } } static void @@ -360,6 +436,9 @@ void dlgConfigurationShowModal() look, _("Configuration")); pager = new ArrowPagerWidget(look.button, +#ifdef __AUGUST__ + [&dialog](){ OnSaveClicked(dialog); }, +#endif [&dialog](){ OnCloseClicked(dialog); }, std::make_unique(look)); @@ -374,9 +453,9 @@ void dlgConfigurationShowModal() })); -#ifdef IS_OPENVARIO - ovdevice.Initialise(); -#endif +// #ifdef IS_OPENVARIO +// ovdevice.Initialise(); +// #endif menu.InitMenu(main_menu_captions, ARRAY_SIZE(main_menu_captions)); @@ -399,5 +478,8 @@ void dlgConfigurationShowModal() if (require_restart) ShowMessageBox(_("Changes to configuration saved. Restart XCSoar to apply changes."), _T(""), MB_OK); + UI::TopWindow::SetExitValue(EXIT_RESTART); + UIActions::SignalShutdown(true); + } } From a67cbb3724f14110965deb8e6cc5fa699029d6ff Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 4 Apr 2024 17:13:09 +0200 Subject: [PATCH 271/403] [OV] OpenVarioDevice - init with LoadSettings (extended) and splitting with - ReadSettings --- src/OpenVario/System/OpenVarioDevice.cpp | 76 +++++++++++++++++------- src/OpenVario/System/OpenVarioDevice.hpp | 5 +- 2 files changed, 58 insertions(+), 23 deletions(-) diff --git a/src/OpenVario/System/OpenVarioDevice.cpp b/src/OpenVario/System/OpenVarioDevice.cpp index ec7c83bf4ae..47f45c32155 100644 --- a/src/OpenVario/System/OpenVarioDevice.cpp +++ b/src/OpenVario/System/OpenVarioDevice.cpp @@ -22,10 +22,14 @@ #include "util/StaticString.hxx" #include "util/ConvertString.hpp" +#include "util/StringCompare.hxx" #include "LogFile.hpp" #include "LocalPath.hpp" +#include +#include " + #ifndef _WIN32 #include #include @@ -36,7 +40,6 @@ #include #include -#include #ifndef __MSVC__ #include @@ -111,9 +114,8 @@ OpenVario_Device::Initialise() noexcept { LogFormat("bin_path = %s", bin_path.c_str()); #endif //---------------------------- - // StaticString<0x200> str; - // str.Format(_T("%s/%s"), home_path, _T("process.txt")); run_output_file = AllocatedPath::Build(home_path, Path(_T("tmp.txt"))); + LoadSettings(); initialised = true; } } @@ -125,10 +127,15 @@ void ReadBool(std::map> &map, value = map.find(name)->second != "False"; } //---------------------------------------------------------- -void ReadInteger(std::map> &map, - std::string_view name, unsigned &value) noexcept { - if (map.find(name) != map.end()) - value = std::stoul(map.find(name)->second); +void +ReadInteger(std::map> &map, + std::string_view name, unsigned &value) noexcept try { + auto iter = map.find(name); + if (iter != map.end()) { + value = std::stoul(iter->second); + } +} catch (std::exception &e) { + LogFormat("ReadInteger-Exception: %s", e.what()); } //---------------------------------------------------------- void ReadString(std::map> &map, @@ -138,14 +145,18 @@ void ReadString(std::map> &map, } //---------------------------------------------------------- void -OpenVario_Device::LoadSettings() noexcept -{ +OpenVario_Device::LoadSettings() noexcept { LoadConfigFile(system_map, GetSystemConfig()); LoadConfigFile(settings, GetSettingsConfig()); LoadConfigFile(upgrade_map, GetUpgradeConfig()); #ifndef DBUS_FUNCTIONS LoadConfigFile(internal_map, GetInternalConfig()); #endif + ReadSettings(); +} + +//---------------------------------------------------------- +void OpenVario_Device::ReadSettings() noexcept { unsigned i_rot = 0; ReadInteger(system_map, "rotation", i_rot); rotation = (DisplayOrientation) i_rot; @@ -155,9 +166,16 @@ OpenVario_Device::LoadSettings() noexcept #endif ReadBool(settings, "Enabled", enabled); +#ifdef _DEBUG ReadInteger(settings, "iTest", iTest); +#endif ReadInteger(settings, "Timeout", timeout); - ReadInteger(settings, "Brightness", brightness); + + brightness = GetBrightness(); + ssh = (unsigned)GetSSHStatus(); + sensord = GetSystemStatus("sensord"); + variod = GetSystemStatus("variod"); + rotation = GetRotation(); } //---------------------------------------------------------- @@ -168,8 +186,9 @@ LoadConfigFile(std::map> &map, Path path) FileLineReaderA reader(path); KeyValueFileReader kvreader(reader); KeyValuePair pair; - while (kvreader.Read(pair)) + while (kvreader.Read(pair)) { map.emplace(pair.key, pair.value); + } } } @@ -207,6 +226,9 @@ OpenVario_Device::SetBrightness(uint_least8_t value) noexcept if (value < 1) { value = 1; } if (value > 10) { value = 10; } + brightness = value; + settings.insert_or_assign("Brightness", + std::to_string(value)); File::WriteExisting(Path(_T("/sys/class/backlight/lcd/brightness")), fmt::format_int{value}.c_str()); } @@ -215,6 +237,8 @@ OpenVario_Device::GetRotation() { std::map> map; LoadConfigFile(map, system_config); // Path(_T("/boot/config.uEnv"))); + if (map.contains("Rotation")) // this is wrong!!! + map.erase("Rotation"); uint_least8_t result; result = map.contains("rotation") ? std::stoi(map.find("rotation")->second) : 0; @@ -226,6 +250,7 @@ OpenVario_Device::GetRotation() case 3: return DisplayOrientation::PORTRAIT; default: return DisplayOrientation::DEFAULT; } + } void @@ -233,6 +258,10 @@ OpenVario_Device::SetRotation(DisplayOrientation orientation) { std::map> map; + LoadConfigFile(map, system_config); // Path(_T("/boot/config.uEnv"))); + if (map.contains("Rotation")) // this is wrong!!! + map.erase("Rotation"); + Display::Rotate(orientation); int rotation = 0; @@ -250,12 +279,22 @@ OpenVario_Device::SetRotation(DisplayOrientation orientation) rotation = 3; break; }; + std::string rot_string = fmt::format_int{rotation}.c_str(); + if (map["rotation"] != rot_string) { + LogFormat("Set Rotation '%s' vs. '%s' (%d)", map["rotation"].c_str(), + rot_string.c_str(), rotation); + } - File::WriteExisting(Path(_T("/sys/class/graphics/fbcon/rotate")), fmt::format_int{rotation}.c_str()); - LoadConfigFile(map, system_config); // Path(_T("/boot/config.uEnv"))); - map.insert_or_assign("rotation", fmt::format_int{rotation}.c_str()); - WriteConfigFile(map, system_config); // Path(_T("/boot/config.uEnv"))); + if (map["rotation"] != rot_string) { + File::WriteExisting(Path(_T("/sys/class/graphics/fbcon/rotate")), + rot_string.c_str()); + + map.insert_or_assign("rotation", rot_string); + WriteConfigFile(map, system_config); + + // Restart??? + } } #ifdef DBUS_FUNCTIONS @@ -304,7 +343,6 @@ OpenVario_Device::GetSystemStatus(std::string_view system) noexcept #else // StaticString - std::cout << " 0: " << system << std::endl; StaticString<0x20> file; std::string_view _dirname("/home/august2111"); @@ -321,31 +359,25 @@ OpenVario_Device::GetSystemStatus(std::string_view system) noexcept Path tmp_file = _tmp_file; - std::cout << " 1: " << tmp_file.ToUTF8() << ", " << system << std::endl; if (File::Exists(tmp_file)) File::Delete(tmp_file); // remove, if exists auto run_value = Run(tmp_file, "/bin/systemctl", "is-enabled", system.data()); - std::cout << " 2: " << tmp_file.ToUTF8() << ", " << std::endl; char buffer[0x20]; File::ReadString(tmp_file, buffer, sizeof(buffer)); - std::cout << " 3: " << buffer << ", " << std::endl; switch (run_value) { case 0: if (std::string_view(buffer).starts_with("enabled")) std::strncpy(buffer, "enabled -> ok!", sizeof(buffer)); else std::strncpy(buffer, "enabled -> not ok???", sizeof(buffer)); - std::cout << " 4: " << system << ": " << buffer << std::endl; return true; case 1: if (std::string_view(buffer).starts_with("disabled")) std::strncpy(buffer, "disabled -> ok!", sizeof(buffer)); else std::strncpy(buffer, "disabled -> not ok???", sizeof(buffer)); - std::cout << " 4: " << system << ": " << buffer << std::endl; return false; default: - std::cout << " 4: " << system << " = Wrong" << std::endl; return false; } #endif diff --git a/src/OpenVario/System/OpenVarioDevice.hpp b/src/OpenVario/System/OpenVarioDevice.hpp index 27b20886bbd..94cbb3c26c9 100644 --- a/src/OpenVario/System/OpenVarioDevice.hpp +++ b/src/OpenVario/System/OpenVarioDevice.hpp @@ -40,11 +40,14 @@ enum class SSHStatus { class OpenVario_Device { public: - OpenVario_Device() {} + OpenVario_Device() { + Initialise(); + } void Initialise() noexcept; void Deinitialise() noexcept; void LoadSettings() noexcept; + void ReadSettings() noexcept; Path GetSystemConfig() noexcept { return system_config; } // void SetSystemConfig(Path configfile) noexcept { system_config = configfile; } std::map> system_map; From e29bc19239228c6af83fee80a469fd5d8ca71e59 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 14 Mar 2024 12:39:27 +0100 Subject: [PATCH 272/403] [Resource] - Windows use the resource name for Windows resource --- src/ResourceId.hpp | 21 +++++++++++++++++++-- src/ResourceLoader.cpp | 5 +++-- src/ResourceLoader.hpp | 4 ++-- src/Resources.hpp | 3 ++- src/ui/canvas/gdi/ResourceBitmap.cpp | 2 +- 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/ResourceId.hpp b/src/ResourceId.hpp index a4e1c1fecc4..d52616a6dd5 100644 --- a/src/ResourceId.hpp +++ b/src/ResourceId.hpp @@ -5,6 +5,9 @@ #include +#ifdef USE_WIN32_RESOURCES +#include +#endif /** * The identifier for a resource to be passed to * ResourceLoader::Load() or other resource-loading functions. @@ -12,6 +15,7 @@ class ResourceId { #ifdef USE_WIN32_RESOURCES unsigned id; + const char *name; #elif defined(ANDROID) const char *name; #else @@ -23,8 +27,13 @@ class ResourceId { ResourceId() = default; #ifdef USE_WIN32_RESOURCES - constexpr explicit ResourceId(unsigned _id) noexcept - :id(_id) {} +// constexpr explicit ResourceId(unsigned _id, const char* _res_name) noexcept + constexpr explicit ResourceId(unsigned _id) noexcept : id(_id) { + name = nullptr; + } + constexpr explicit ResourceId(unsigned _id, const char *_name) noexcept : id(_id) { + name = _name; + } #elif defined(ANDROID) constexpr explicit ResourceId(const char *_name) noexcept :name(_name) {} @@ -77,6 +86,14 @@ class ResourceId { #endif } +#ifdef USE_WIN32_RESOURCES +std::string_view +GetName() +{ + return name; +} +#endif + constexpr bool operator!=(ResourceId other) const noexcept { #ifdef USE_WIN32_RESOURCES return id != other.id; diff --git a/src/ResourceLoader.cpp b/src/ResourceLoader.cpp index 12fb3eb8c21..4b14545b442 100644 --- a/src/ResourceLoader.cpp +++ b/src/ResourceLoader.cpp @@ -80,10 +80,11 @@ ResourceLoader::Load(ResourceId id) #endif +#include #ifdef USE_WIN32_RESOURCES HBITMAP -ResourceLoader::LoadBitmap2(ResourceId id) +ResourceLoader::LoadResBitmap(ResourceId id) { - return ::LoadBitmap(ResourceLoaderInstance, MAKEINTRESOURCE((unsigned)id)); + return LoadBitmapA(ResourceLoaderInstance, id.GetName().data()); } #endif diff --git a/src/ResourceLoader.hpp b/src/ResourceLoader.hpp index 5da3b3542b0..f1183b99e6a 100644 --- a/src/ResourceLoader.hpp +++ b/src/ResourceLoader.hpp @@ -32,9 +32,9 @@ Data Load(ResourceId id); #endif -#ifdef _WIN32 +#ifdef USE_WIN32_RESOURCES HBITMAP -LoadBitmap2(ResourceId id); +LoadResBitmap(ResourceId id); #endif } // namespace ResourceLoader diff --git a/src/Resources.hpp b/src/Resources.hpp index 5b89fec7494..93a46f75146 100644 --- a/src/Resources.hpp +++ b/src/Resources.hpp @@ -4,9 +4,10 @@ #include "ResourceId.hpp" #ifdef USE_WIN32_RESOURCES +#include #define MAKE_RESOURCE(name, file, id) \ - static constexpr ResourceId name(id); + static constexpr ResourceId name(id, #name) #elif defined(ANDROID) diff --git a/src/ui/canvas/gdi/ResourceBitmap.cpp b/src/ui/canvas/gdi/ResourceBitmap.cpp index d045577c769..bd7ee2de84a 100644 --- a/src/ui/canvas/gdi/ResourceBitmap.cpp +++ b/src/ui/canvas/gdi/ResourceBitmap.cpp @@ -20,7 +20,7 @@ Bitmap::Load(ResourceId id, [[maybe_unused]] Type type) { Reset(); - bitmap = ResourceLoader::LoadBitmap2(id); + bitmap = ResourceLoader::LoadResBitmap(id); return bitmap != nullptr; } From adf2c49f382a65155783172eb82cfb00a937285c Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 27 Mar 2024 18:31:50 +0100 Subject: [PATCH 273/403] [Resource] - extend create_resource.py for Windows with python --- tools/python/create_resource.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/python/create_resource.py b/tools/python/create_resource.py index 7d47838d0d1..739a8da8d24 100644 --- a/tools/python/create_resource.py +++ b/tools/python/create_resource.py @@ -71,6 +71,7 @@ def write_line(outfile, line): else: infile = io.open(sys.argv[1]) outfile = io.open(sys.argv[2], 'w', newline='\n') + outfile2 = io.open(sys.argv[2]+'.h', 'w', newline='\n') for line in infile: write_line(outfile, line) From 60b9cc58566f6dd76d6673582722e2676330c4ea Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 20 Mar 2024 08:58:28 +0100 Subject: [PATCH 274/403] [build] ov.mk - UtilsSettings necessary for require_restart --- build/ov.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/ov.mk b/build/ov.mk index 83564160f46..ce61508defc 100644 --- a/build/ov.mk +++ b/build/ov.mk @@ -250,6 +250,8 @@ OV_MENU_SOURCES = \ $(SRC)/Math/FastTrig.cpp \ $(SRC)/ui/window/ContainerWindow.cpp \ $(SRC)/Operation/Operation.cpp \ + \ + $(SRC)/UtilsSettings.cpp \ \ # $(SRC)/Operation/ConsoleOperationEnvironment.cpp From 49000cd0667139b73431d8d7a9e1e598960fb532 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 20 Mar 2024 09:32:08 +0100 Subject: [PATCH 275/403] [Setting] UtilsSettings.cpp - require_restart initial value --- src/UtilsSettings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/UtilsSettings.cpp b/src/UtilsSettings.cpp index efdad244fde..9884f7dc9b0 100644 --- a/src/UtilsSettings.cpp +++ b/src/UtilsSettings.cpp @@ -53,7 +53,7 @@ bool FlarmFileChanged = false; bool RaspFileChanged = false; bool InputFileChanged = false; bool LanguageChanged = false; -bool require_restart; +bool require_restart = false; static void SettingsEnter() From 6d7da315463fbfd00d0021ebe4587d29f9290ab9 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 19 Mar 2024 17:11:44 +0100 Subject: [PATCH 276/403] [Input] Input/InputEventsActions.cpp - allow eventShutdown for all --- src/Input/InputEvents.hpp | 2 +- src/Input/InputEventsActions.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Input/InputEvents.hpp b/src/Input/InputEvents.hpp index 0d3af9a45c1..557e72ae79e 100644 --- a/src/Input/InputEvents.hpp +++ b/src/Input/InputEvents.hpp @@ -192,7 +192,7 @@ void eventRunLuaFile(const TCHAR *misc); void eventResetTask(const TCHAR *misc); void eventLockScreen(const TCHAR *misc); void eventExchangeFrequencies(const TCHAR *misc); -#ifdef IS_OPENVARIO +#if 1 // def IS_OPENVARIO void eventShutdown(const TCHAR *misc); #endif void eventUploadIGCFile(const TCHAR *misc); diff --git a/src/Input/InputEventsActions.cpp b/src/Input/InputEventsActions.cpp index 785460fe35d..f84292f60ea 100644 --- a/src/Input/InputEventsActions.cpp +++ b/src/Input/InputEventsActions.cpp @@ -637,7 +637,7 @@ InputEvents::eventExit([[maybe_unused]] const TCHAR *misc) UIActions::SignalShutdown(false); } -#ifdef IS_OPENVARIO +#if 1 // def IS_OPENVARIO // Exits with real Shutdown only in systems where this is possible void InputEvents::eventShutdown([[maybe_unused]] const TCHAR *misc) From 1d69becde56af22447365473791d85d73d2cf4b8 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 20 Mar 2024 13:53:23 +0100 Subject: [PATCH 277/403] Widget/LargeTextWidget.cpp - use #ifdef instead of #if --- src/Widget/LargeTextWidget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Widget/LargeTextWidget.cpp b/src/Widget/LargeTextWidget.cpp index 8b94498c77a..7a6c05d644b 100644 --- a/src/Widget/LargeTextWidget.cpp +++ b/src/Widget/LargeTextWidget.cpp @@ -5,7 +5,7 @@ #include "ui/control/LargeTextWindow.hpp" #include "Look/DialogLook.hpp" -#if _UNICODE +#ifdef _UNICODE # include "util/ConvertString.hpp" #endif void @@ -15,7 +15,7 @@ LargeTextWidget::SetText(const TCHAR *text) noexcept w.SetText(text); } -#if _UNICODE +#ifdef _UNICODE // Maybe this is against MaxK XCSoar rules, but this makes the life much easier void LargeTextWidget::SetText(const char *text) noexcept From 6319d4b30b5f563310e960afe611b6b81c74d18f Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 19 Mar 2024 17:42:07 +0100 Subject: [PATCH 278/403] [OV] dlgConfiguration.cpp - YESNO ShowMessageBox for immediately restart (only OV) --- src/Dialogs/Settings/dlgConfiguration.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Dialogs/Settings/dlgConfiguration.cpp b/src/Dialogs/Settings/dlgConfiguration.cpp index 08107ed32a7..516c6d0d484 100644 --- a/src/Dialogs/Settings/dlgConfiguration.cpp +++ b/src/Dialogs/Settings/dlgConfiguration.cpp @@ -476,10 +476,18 @@ void dlgConfigurationShowModal() if (dialog.GetChanged()) { Profile::Save(); if (require_restart) - ShowMessageBox(_("Changes to configuration saved. Restart XCSoar to apply changes."), - _T(""), MB_OK); - UI::TopWindow::SetExitValue(EXIT_RESTART); - UIActions::SignalShutdown(true); - +#if defined(IS_OPENVARIO) + if (ShowMessageBox( + _("Changes to configuration saved. Restart OpenSoar " + "is needed to apply changes. Do you want restart immediately?"), + _T(""), MB_YESNO | MB_ICONQUESTION) == IDYES) { + UI::TopWindow::SetExitValue(EXIT_RESTART); + UIActions::SignalShutdown(true); + } +#else + ShowMessageBox(_("Changes to configuration saved. Restart XCSoar to " + "apply changes."), + _T(""), MB_OK); +#endif } } From 53b5045153a68498af1ed3377107f672ede5f950 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 20 Mar 2024 14:56:41 +0100 Subject: [PATCH 279/403] [Android] Main.cpp - trial to use the ReRun Option at Android too remove Shutdown() from ReRun mode --- src/Android/Main.cpp | 230 +++++++++++++++++++++++++------------------ 1 file changed, 132 insertions(+), 98 deletions(-) diff --git a/src/Android/Main.cpp b/src/Android/Main.cpp index 3e859d6bbcc..127209e3f56 100644 --- a/src/Android/Main.cpp +++ b/src/Android/Main.cpp @@ -60,6 +60,9 @@ #include "NunchuckDevice.hpp" #include "VoltageDevice.hpp" +#include "UIGlobals.hpp" + + #include #include @@ -183,6 +186,20 @@ try { return env->NewStringUTF(GetFullMessage(std::current_exception()).c_str()); } +#define ANDROID_RERUN +/** ReRun hat 2 grosse Probleme zur Zeit: +* - startet man OpenSoar mit einer SD-Card, befindet sich der Data-Ordner (und +* auch der Cache) dort, bei einem ReRun vesucht er aber, z.B. die Maps und +* Wegpunkte(oder Airspaces) von Data-Ordner des Android zu lesen, der ist +* aber leer... +* - Bei Start Von OpenSoar werden die Log-Files auf dem Telefon angelegt, +* nicht wie alles andere auf der SD-Card... (das ist ein ähnliches Verhalten +* wie bei einem 'Umlegen' des datapath bei anderen Systemen +* - Das Quickmenü hat im 1.Fall 12 Zeilen, im 2.Fall nur noch 11 - als ob das +* Fenster ein wenig kleiner geworden ist +* - Ich habe noch keine Moeglichkeit gefunden, auf die 2.Seite des Quickmenus +* zu gelangen -> mit Touch geht es leider (noch) nicht!!! +*/ gcc_visibility_default JNIEXPORT void JNICALL Java_de_opensoar_NativeView_runNative(JNIEnv *env, jobject obj, @@ -192,117 +209,134 @@ Java_de_opensoar_NativeView_runNative(JNIEnv *env, jobject obj, jint xdpi, jint ydpi, jstring product) try { - const std::scoped_lock shutdown_lock{shutdown_mutex}; - - InitThreadDebug(); - - const bool have_bluetooth = BluetoothHelper::Initialise(env); - const bool have_usb_serial = UsbSerialHelper::Initialise(env); - const bool have_ioio = IOIOHelper::Initialise(env); - - context = new Context(env, _context); - AtScopeExit() { - delete context; - context = nullptr; - }; - - permission_manager = env->NewGlobalRef(_permission_manager); - AtScopeExit(env) { env->DeleteGlobalRef(permission_manager); }; +#ifdef ANDROID_RERUN + bool rerun = false; + + do { + rerun = false; + UI::TopWindow::SetExitValue(0); +#endif + const std::scoped_lock shutdown_lock{shutdown_mutex}; + + InitThreadDebug(); + + const bool have_bluetooth = BluetoothHelper::Initialise(env); + const bool have_usb_serial = UsbSerialHelper::Initialise(env); + const bool have_ioio = IOIOHelper::Initialise(env); + + context = new Context(env, _context); + AtScopeExit() { + delete context; + context = nullptr; + }; + + permission_manager = env->NewGlobalRef(_permission_manager); + AtScopeExit(env) { env->DeleteGlobalRef(permission_manager); }; + + const ScopeGlobalAsioThread global_asio_thread; + const Net::ScopeInit net_init(asio_thread->GetEventLoop()); + + InitialiseDataPath(); + AtScopeExit() { DeinitialiseDataPath(); }; + + LogFormat(_T("Starting OpenSoar %s"), OpenSoar_ProductToken); + + TextUtil::Initialise(env); + AtScopeExit(env) { TextUtil::Deinitialise(env); }; + + assert(native_view == nullptr); + native_view = new NativeView(env, obj, width, height, xdpi, ydpi, product); + AtScopeExit() { + delete native_view; + native_view = nullptr; + }; + + SoundUtil::Initialise(env); + AtScopeExit(env) { SoundUtil::Deinitialise(env); }; + + Vibrator::Initialise(env); + vibrator = Vibrator::Create(env, *context); + + AtScopeExit() { + delete vibrator; + vibrator = nullptr; + }; + + if (have_bluetooth) { + try { + bluetooth_helper = + new BluetoothHelper(env, *context, permission_manager); + } catch (...) { + LogError(std::current_exception(), "Failed to initialise Bluetooth"); + } + } - const ScopeGlobalAsioThread global_asio_thread; - const Net::ScopeInit net_init(asio_thread->GetEventLoop()); + AtScopeExit() { + delete bluetooth_helper; + bluetooth_helper = nullptr; + }; + + if (have_usb_serial) { + try { + usb_serial_helper = new UsbSerialHelper(env, *context); + } catch (...) { + LogError(std::current_exception(), + "Failed to initialise USB serial support"); + } + } - InitialiseDataPath(); - AtScopeExit() { DeinitialiseDataPath(); }; + AtScopeExit() { + delete usb_serial_helper; + usb_serial_helper = nullptr; + }; + + if (have_ioio) { + try { + ioio_helper = new IOIOHelper(env); + } catch (...) { + LogError(std::current_exception(), "Failed to initialise IOIO"); + } + } - LogFormat(_T("Starting OpenSoar %s"), OpenSoar_ProductToken); + AtScopeExit() { + delete ioio_helper; + ioio_helper = nullptr; + }; - TextUtil::Initialise(env); - AtScopeExit(env) { TextUtil::Deinitialise(env); }; + ScreenGlobalInit screen_init; + AtScopeExit() { Fonts::Deinitialize(); }; - assert(native_view == nullptr); - native_view = new NativeView(env, obj, width, height, xdpi, ydpi, - product); - AtScopeExit() { - delete native_view; - native_view = nullptr; - }; + AllowLanguage(); + AtScopeExit() { DisallowLanguage(); }; - SoundUtil::Initialise(env); - AtScopeExit(env) { SoundUtil::Deinitialise(env); }; + InitLanguage(); - Vibrator::Initialise(env); - vibrator = Vibrator::Create(env, *context); + AtScopeExit() { + if (CommonInterface::main_window != nullptr) { + CommonInterface::main_window->Destroy(); + delete CommonInterface::main_window; + CommonInterface::main_window = nullptr; + } + }; - AtScopeExit() { - delete vibrator; - vibrator = nullptr; - }; + { + const ScopeUnlock shutdown_unlock{shutdown_mutex}; - if (have_bluetooth) { - try { - bluetooth_helper = new BluetoothHelper(env, *context, - permission_manager); - } catch (...) { - LogError(std::current_exception(), "Failed to initialise Bluetooth"); - } - } - - AtScopeExit() { - delete bluetooth_helper; - bluetooth_helper = nullptr; - }; - - if (have_usb_serial) { - try { - usb_serial_helper = new UsbSerialHelper(env, *context); - } catch (...) { - LogError(std::current_exception(), "Failed to initialise USB serial support"); - } - } - - AtScopeExit() { - delete usb_serial_helper; - usb_serial_helper = nullptr; - }; - - if (have_ioio) { - try { - ioio_helper = new IOIOHelper(env); - } catch (...) { - LogError(std::current_exception(), "Failed to initialise IOIO"); + if (Startup(screen_init.GetDisplay())) + CommonInterface::main_window->RunEventLoop(); } - } - - AtScopeExit() { - delete ioio_helper; - ioio_helper = nullptr; - }; - - ScreenGlobalInit screen_init; - AtScopeExit() { Fonts::Deinitialize(); }; - AllowLanguage(); - AtScopeExit() { DisallowLanguage(); }; - - InitLanguage(); - - AtScopeExit() { - if (CommonInterface::main_window != nullptr) { - CommonInterface::main_window->Destroy(); - delete CommonInterface::main_window; - CommonInterface::main_window = nullptr; +#ifdef ANDROID_RERUN + unsigned ret = UI::TopWindow::GetExitValue(); + rerun = (ret == EXIT_RESTART); + if (rerun) { + env->DeleteGlobalRef(permission_manager); + DeinitialiseDataPath(); } - }; - - { - const ScopeUnlock shutdown_unlock{shutdown_mutex}; - - if (Startup(screen_init.GetDisplay())) - CommonInterface::main_window->RunEventLoop(); - } + } while (rerun); +#endif - Shutdown(); + Shutdown(); } catch (...) { /* if an error occurs, rethrow the C++ exception as Java exception, to be displayed by the Java glue code */ From 9f24c7564f156566de6d7c503815df3f79b90a7f Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 20 Mar 2024 14:57:45 +0100 Subject: [PATCH 280/403] [OV] OpenSoar.cpp - use for UI::TopWindow::SetExitValue a better place --- src/OpenSoar.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/OpenSoar.cpp b/src/OpenSoar.cpp index 1eb8ec67f29..4ede2361370 100644 --- a/src/OpenSoar.cpp +++ b/src/OpenSoar.cpp @@ -174,6 +174,7 @@ try { do { { rerun = false; + UI::TopWindow::SetExitValue(0); #ifdef _WIN32 if (UIGlobals::CommandLine == nullptr) UIGlobals::CommandLine = GetCommandLine(); @@ -206,8 +207,6 @@ try { ret = UI::TopWindow::GetExitValue(); #endif rerun = (ret == EXIT_RESTART); - if (rerun) - UI::TopWindow::SetExitValue(0); } while (rerun); return Finishing(ret); From c154a61cc544e71aca7052609efefabb641c390b Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 19 Mar 2024 11:05:28 +0100 Subject: [PATCH 281/403] [Resource] resource creation for cmake with python --- Data/CMakeLists.txt | 42 ++++++++++++++++------- Data/resources.txt | 3 ++ src/Input/CMakeSource.cmake | 1 + tools/python/create_resource.py | 60 +++++++++++++++++++++++---------- 4 files changed, 76 insertions(+), 30 deletions(-) diff --git a/Data/CMakeLists.txt b/Data/CMakeLists.txt index 1b05d09ac2f..ec09285db79 100644 --- a/Data/CMakeLists.txt +++ b/Data/CMakeLists.txt @@ -108,7 +108,7 @@ add_custom_command(OUTPUT ${_TEMP_OUTPUT}/title.svg WORKING_DIRECTORY ${PROJECTGROUP_SOURCE_DIR} ) # ============================================================================ -if (1) # NOT MINGW) # geht bei MinGW nicht??? +if (0) # NOT MINGW) # geht bei MinGW nicht??? # create the resource file (for all targets ) # add_custom_command(OUTPUT ${_DATA_OUTPUT}/${PROGRAM_NAME}.rc add_custom_command(OUTPUT ${PROJECTGROUP_BINARY_DIR}/${PROGRAM_NAME}.rc @@ -125,6 +125,16 @@ add_custom_command(OUTPUT ${PROJECTGROUP_BINARY_DIR}/${PROGRAM_NAME}.rc ) # add_custom_command endif() +add_custom_command(OUTPUT ${PROJECTGROUP_BINARY_DIR}/${PROGRAM_NAME}.rc + COMMENT "Create Resource File!" + COMMAND ${PYTHON_APP} ${PROJECTGROUP_SOURCE_DIR}/tools/python/create_resource.py + # ${CMAKE_CURRENT_SOURCE_DIR}/OpenSoar.rc # Input + ${CMAKE_CURRENT_SOURCE_DIR}/resources.txt # Input + ${PROJECTGROUP_BINARY_DIR}/${PROGRAM_NAME}.rc # Output + ${_DATA_INPUT} + ${_DATA_OUTPUT} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/resources.txt +) # message(FATAL_ERROR "!!!!!! ${PROJECTGROUP_BINARY_DIR}/${PROGRAM_NAME}.rc") # if (_COMPLETE_INSTALL) set(GRAPHIC_BITMAPS @@ -160,8 +170,9 @@ add_custom_command(OUTPUT ${GRAPHIC_BITMAPS} # endif() set(ICON_BITMAPS ) # set to empty -file(GLOB ICON_FILES ${_DATA_INPUT}/icons/*.svg) -if(OFF) # ==> for test it only with few icons! +if(ON) # ==> for test it only with few icons! + file(GLOB ICON_FILES ${_DATA_INPUT}/icons/*.svg) +else() set (ICON_FILES ${_DATA_INPUT}/icons/map_bridge.svg ${_DATA_INPUT}/icons/map_castle.svg @@ -171,12 +182,14 @@ endif() foreach(icon_file ${ICON_FILES}) get_filename_component(_filename ${icon_file} NAME_WE) set(icon_file_out ${_ICONS_OUTPUT}/${_filename}) - set(icon_file_160 ${_ICONS_OUTPUT}/${_filename}_160) + set(icon_file_std ${_ICONS_OUTPUT}/${_filename}_96) + set(icon_file_hd ${_ICONS_OUTPUT}/${_filename}_160) + set(icon_file_uhd ${_ICONS_OUTPUT}/${_filename}_300) set(tmp_file ${_TEMP_OUTPUT}/icons/${_filename}) set(BMP_CONVERT_PARAM +dither -compress none -type optimize -colors 256 ) set(BMP_BACKGROUND white) # original gray! # if (_COMPLETE_INSTALL) - list(APPEND ICON_BITMAPS ${icon_file_out}.bmp ${icon_file_160}.bmp) + list(APPEND ICON_BITMAPS ${icon_file_std}.bmp ${icon_file_hd}.bmp ${icon_file_uhd}.bmp) if (WITH_REMOVE) set (REMOVE_CMD COMMAND ${CMAKE_COMMAND} -E remove -f ${tmp_file}_alpha.png @@ -193,23 +206,26 @@ foreach(icon_file ${ICON_FILES}) ) else() set (COPY_CMD - COMMAND ${INKSCAPE_APP} ${icon_file_out}.svg --export-dpi=124 --export-type=PNG --export-overwrite --export-filename=${icon_file_out}.png - COMMAND ${INKSCAPE_APP} ${icon_file_out}.svg --export-dpi=200 --export-type=PNG --export-overwrite --export-filename=${icon_file_160}.png + COMMAND ${INKSCAPE_APP} ${icon_file_out}.svg --export-dpi=124 --export-type=PNG --export-overwrite --export-filename=${icon_file_std}.png + COMMAND ${INKSCAPE_APP} ${icon_file_out}.svg --export-dpi=200 --export-type=PNG --export-overwrite --export-filename=${icon_file_hd}.png + COMMAND ${INKSCAPE_APP} ${icon_file_out}.svg --export-dpi=300 --export-type=PNG --export-overwrite --export-filename=${icon_file_uhd}.png ) endif() # ========================================================================= - add_custom_command(OUTPUT ${icon_file_out}.bmp ${icon_file_160}.bmp - COMMENT File aus 'icons': ${icon_file_160}.bmp + add_custom_command(OUTPUT ${icon_file_std}.bmp ${icon_file_hd}.bmp ${icon_file_uhd}.bmp + COMMENT File aus 'icons': ${icon_file_uhd}.bmp COMMAND ${CMAKE_COMMAND} -E make_directory ${_ICONS_OUTPUT} COMMAND ${CMAKE_COMMAND} -E make_directory ${_TEMP_OUTPUT}/icons COMMAND ${CMAKE_COMMAND} -E copy ${icon_file} ${icon_file_out}.svg ${COPY_CMD} - COMMAND ${BMP_CONVERT_APP} ${icon_file_160}.png -alpha Extract -colors 8 ${tmp_file}_alpha.png + COMMAND ${BMP_CONVERT_APP} ${icon_file_uhd}.png -alpha Extract -colors 8 ${tmp_file}_alpha.png # "-alpha Off" == "+matte" - COMMAND ${BMP_CONVERT_APP} ${icon_file_160}.png -background ${BMP_BACKGROUND} -flatten -alpha Off +dither -colors 64 ${tmp_file}_rgb.png + COMMAND ${BMP_CONVERT_APP} ${icon_file_uhd}.png -background ${BMP_BACKGROUND} -flatten -alpha Off +dither -colors 64 ${tmp_file}_rgb.png COMMAND ${BMP_MONTAGE_APP} -tile 2x1 -geometry +0+0 ${tmp_file}_alpha.png ${tmp_file}_rgb.png -depth 8 ${tmp_file}.png - COMMAND ${BMP_CONVERT_APP} ${tmp_file}.png -resize 44x22 -colors 64 BMP3:${icon_file_160}.bmp - COMMAND ${BMP_CONVERT_APP} ${tmp_file}.png -resize 20x10 -colors 64 BMP3:${icon_file_out}.bmp + COMMAND ${BMP_CONVERT_APP} ${tmp_file}.png -resize 132x66 -colors 64 BMP3:${icon_file_uhd}.bmp + COMMAND ${BMP_CONVERT_APP} ${tmp_file}.png -resize 44x22 -colors 64 BMP3:${icon_file_hd}.bmp + COMMAND ${BMP_CONVERT_APP} ${tmp_file}.png -resize 44x22 -colors 64 BMP3:${icon_file_std}.bmp + # COMMAND ${BMP_CONVERT_APP} ${tmp_file}.png -resize 20x10 -colors 64 BMP3:${icon_file_std}.bmp ${REMOVE_CMD} MAIN_DEPENDENCY ${icon_file} DEPENDS ${icon_file} diff --git a/Data/resources.txt b/Data/resources.txt index 27b735692d5..97955b016d4 100644 --- a/Data/resources.txt +++ b/Data/resources.txt @@ -1,3 +1,6 @@ +#ifdef TEST + +#endif /* This file contains definitions of all resources used by XCSoar. Various Perl scripts convert it to a C header and target-specific files (e.g. the Windows RC format). */ diff --git a/src/Input/CMakeSource.cmake b/src/Input/CMakeSource.cmake index 74c7903c1ec..1938f938d1a 100644 --- a/src/Input/CMakeSource.cmake +++ b/src/Input/CMakeSource.cmake @@ -22,5 +22,6 @@ set(_SOURCES set(SCRIPT_FILES ../../Data/Input/default.xci + ../../Data/Input/defaultOV.xci CMakeSource.cmake ) diff --git a/tools/python/create_resource.py b/tools/python/create_resource.py index 739a8da8d24..ec1d1914477 100644 --- a/tools/python/create_resource.py +++ b/tools/python/create_resource.py @@ -11,25 +11,43 @@ # def write_resource(outfile, line, macro, type, extension): +def create_line(name, res_name, path, file, ext): + line = '{:30s}'.format(name) + ' ' + '{:12s}'.format(res_name) + line = line + 'DISCARDABLE L"' + path + '/' + line = line + file + '.' + ext + '"' + # line = '{:30s}'.format(params[1]) + ' ' + '{:12s}'.format(resource[2]) + # line = line + 'DISCARDABLE L"' + resource[3] + '/' + # line = line + params[2].strip(' \n').replace('"','') + resource[4] + '"' + outfile.write(line + '\n') # Copy of read line (with replaced field) + if debug: + print(line) + ## return line + def write_resource(outfile, line, resource): - line = line.replace(resource[0]+'(','') - line = line.replace(')','') - params = line.split(',') + # line = line.replace(resource[0]+'(','') + # line = line.replace(')','') + # params = line.split(',') + params = line.split(' ') # if debug: - if len(params) == 2: - line = '{:30s}'.format(params[0]) + ' ' + '{:12s}'.format(resource[1]) - line = line + 'DISCARDABLE L"' + resource[2] + '/' - line = line + params[1].strip(' \n').replace('"','') + resource[3] + '"' + if len(params) >= 2: + if resource[0] == 'bitmap_icon_scaled ': + basename = params[2].strip(' \n').replace('"','') + create_line(params[1], resource[2], resource[3], basename + '_96', resource[4]) + create_line(params[1] + '_HD', resource[2], resource[3], basename + '_160', resource[4]) + create_line(params[1] + '_UHD', resource[2], resource[3], basename + '_300', resource[4]) + else: + create_line(params[1], resource[2], resource[3], params[2].strip(' \n').replace('"',''), resource[4]) # if len(line) > 0: # outfile.write(line.replace('/', '\\\\') + '\n') # Copy of read line (with replaced field) - outfile.write(line + '\n') # Copy of read line (with replaced field) - if debug: - print(line) + else: + outfile.write(line + '\n') def write_line(outfile, line): line = line.strip() - if line.startswith('#include') or \ + if line.startswith('//'): + print('!!\n') + elif line.startswith('#include') or \ line.startswith('ID') or \ line.startswith('#if') or \ line.startswith('#else') or \ @@ -59,12 +77,20 @@ def write_line(outfile, line): src_location1 = sys.argv[3] src_location2 = sys.argv[4] -res_array.append(['BITMAP_ICON', 'BITMAP', src_location2 + '/icons', '.bmp']) -res_array.append(['BITMAP_BITMAP', 'BITMAP', src_location1 + '/bitmaps', '.bmp']) -res_array.append(['BITMAP_GRAPHIC','BITMAP', src_location2 + '/graphics', '.bmp']) -res_array.append(['HATCH_BITMAP', 'BITMAP', src_location1 + '/bitmaps', '.bmp']) -res_array.append(['SOUND', 'WAVE', src_location1 + '/sound', '.wav']) -res_array.append(['ICON_ICON', 'ICON', src_location1 + '/bitmaps', '.ico']) +### res_array.append(['BITMAP_ICON', 'BITMAP', src_location2 + '/icons', '.bmp']) +### res_array.append(['BITMAP_BITMAP', 'BITMAP', src_location1 + '/bitmaps', '.bmp']) +### res_array.append(['BITMAP_GRAPHIC','BITMAP', src_location2 + '/graphics', '.bmp']) +### res_array.append(['HATCH_BITMAP', 'BITMAP', src_location1 + '/bitmaps', '.bmp']) +### res_array.append(['SOUND', 'WAVE', src_location1 + '/sound', '.wav']) +### res_array.append(['ICON_ICON', 'ICON', src_location1 + '/bitmaps', '.ico']) + +# res_array.append(['bitmap_icon ', 'BITMAP', src_location2 + '/icons', '.bmp']) +res_array.append(['bitmap_icon_scaled ', 'BITMAP_ICON', 'BITMAP', src_location2 + '/icons', 'bmp']) +res_array.append(['bitmap_bitmap ', 'BITMAP_BITMAP', 'BITMAP', src_location1 + '/bitmaps', 'bmp']) +res_array.append(['bitmap_graphic ', 'BITMAP_GRAPHIC','BITMAP', src_location2 + '/graphics', 'bmp']) +res_array.append(['hatch_bitmap ', 'HATCH_BITMAP', 'BITMAP', src_location1 + '/bitmaps', 'bmp']) +res_array.append(['sound ' 'SOUND', 'WAVE', src_location1 + '/sound', 'wav']) +res_array.append(['app_icon ', 'ICON_ICON', 'ICON', src_location1 + '/bitmaps', 'ico']) if len(sys.argv) < 2: print('to less arguments: ', len(sys.argv)) From c70ba8dae2f00df261eae553d9080b7e1ed84d55 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 21 Mar 2024 08:00:41 +0100 Subject: [PATCH 282/403] [OV] OpenVarioBaseMenu - definition OPENVARIO_BASEMENU -> Segmentation Fault? --- src/OpenVario/ExtraWidget.cpp | 6 +++--- src/OpenVario/System/SystemMenuWidget.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/OpenVario/ExtraWidget.cpp b/src/OpenVario/ExtraWidget.cpp index 3c3f272db59..21ba47d1bb4 100644 --- a/src/OpenVario/ExtraWidget.cpp +++ b/src/OpenVario/ExtraWidget.cpp @@ -18,7 +18,7 @@ #include "OpenVario/System/OpenVarioDevice.hpp" #include "OpenVario/System/OpenVarioTools.hpp" -#ifndef OPENVARIO_BASEMENU +#if 1 // Segmentation fault? def OPENVARIO_BASEMENU # include "UIActions.hpp" # include "ui/window/ContainerWindow.hpp" #endif @@ -44,7 +44,7 @@ void ExtraWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { AddButton(_("Upgrade Firmware"), [this]() { -#ifdef OPENVARIO_BASEMENU +#if 0 // Segmentation fault? def OPENVARIO_BASEMENU exit(START_UPGRADE); #else // OPENVARIO_BASEMENU ContainerWindow::SetExitValue(START_UPGRADE); @@ -57,7 +57,7 @@ void ExtraWidget::Prepare([[maybe_unused]] ContainerWindow &parent, AddButton(_("Calibrate Touch"), [this]() { // the programm exit in OpenSoar looks complete different fro OpenVarioBaseMenu -#ifdef OPENVARIO_BASEMENU +#if 0 // Segmentation fault? def OPENVARIO_BASEMENU exit(LAUNCH_TOUCH_CALIBRATE); #else // OPENVARIO_BASEMENU ContainerWindow::SetExitValue(LAUNCH_TOUCH_CALIBRATE); diff --git a/src/OpenVario/System/SystemMenuWidget.cpp b/src/OpenVario/System/SystemMenuWidget.cpp index 34ba4a62543..8859167fd98 100644 --- a/src/OpenVario/System/SystemMenuWidget.cpp +++ b/src/OpenVario/System/SystemMenuWidget.cpp @@ -41,7 +41,7 @@ #include #include -#ifndef OPENVARIO_BASEMENU +#if 1 // Segmentation fault? def OPENVARIO_BASEMENU # include "ui/window/ContainerWindow.hpp" # include "UIActions.hpp" #endif @@ -140,7 +140,7 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { AddButton(_("Upgrade Firmware"), [this]() { -#ifdef OPENVARIO_BASEMENU +#if 0 // Segmentation fault? def OPENVARIO_BASEMENU exit(START_UPGRADE); #else // OPENVARIO_BASEMENU ContainerWindow::SetExitValue(START_UPGRADE); @@ -177,7 +177,7 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, AddButton(_("Calibrate Touch"), [this]() { // the programm exit in OpenSoar looks complete different fro OpenVarioBaseMenu -#ifdef OPENVARIO_BASEMENU +#if 0 // Segmentation fault? def OPENVARIO_BASEMENU exit(LAUNCH_TOUCH_CALIBRATE); #else // OPENVARIO_BASEMENU ContainerWindow::SetExitValue(LAUNCH_TOUCH_CALIBRATE); From f9e542ae970424df2f4a937c01c3ee137bf319f5 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 21 Mar 2024 08:47:46 +0100 Subject: [PATCH 283/403] [build]Makefile - remove ov.mk from (normal LINUX build) all builds --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index 9a830c483f0..a658fbf539e 100644 --- a/Makefile +++ b/Makefile @@ -274,6 +274,12 @@ ifeq ($(TARGET_IS_KOBO),y) include $(topdir)/build/kobo.mk endif +# ifeq ($(TARGET_IS_OPENVARIO),y) +# ifeq ($(USE_POLL_EVENT),y) +# include $(topdir)/build/ov.mk +# endif +# endif + include $(topdir)/build/hot.mk include $(topdir)/build/nolto.mk From d32b366b583bfa49d75e7ef3b4908915e3df5cc6 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 21 Mar 2024 09:19:56 +0100 Subject: [PATCH 284/403] [OV] SystemSettingsWidget.cpp - add header ProgramVersion.h --- src/OpenVario/SystemSettingsWidget.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/OpenVario/SystemSettingsWidget.cpp b/src/OpenVario/SystemSettingsWidget.cpp index 1b6357a8771..1f643431141 100644 --- a/src/OpenVario/SystemSettingsWidget.cpp +++ b/src/OpenVario/SystemSettingsWidget.cpp @@ -22,6 +22,7 @@ #include "./LogFile.hpp" #include "UIActions.hpp" #include "UtilsSettings.hpp" +#include "ProgramVersion.h" #include "OpenVario/System/OpenVarioDevice.hpp" #include "OpenVario/System/WifiDialogOV.hpp" From cf71f5b48f64854357eed693554b5fbc870fc695 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 21 Mar 2024 09:30:50 +0100 Subject: [PATCH 285/403] [OV] SystemSettingsWidget.cpp - remove obsolete outcommented lines --- src/OpenVario/SystemSettingsWidget.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/OpenVario/SystemSettingsWidget.cpp b/src/OpenVario/SystemSettingsWidget.cpp index 1f643431141..b6710430011 100644 --- a/src/OpenVario/SystemSettingsWidget.cpp +++ b/src/OpenVario/SystemSettingsWidget.cpp @@ -135,14 +135,12 @@ SystemSettingsWidget::Prepare(ContainerWindow &parent, brightness = ovdevice.brightness * 10; - AddReadOnly(_("Current FW"), _("Current firmware version of OpenVario"), #if defined(PROGRAM_VERSION) _T(PROGRAM_VERSION)); #else _T("7.42.21.3")); #endif - // std::string_view version = PROGRAM_VERSION; AddFile(_("OV-Firmware"), _("Current firmware file version of OpenVario"), "OVImage", _T("*.img.gz\0"), FileType::IMAGE); // no callback... , this); From 4cce3e35025f1707d2eff462d7b65f39b0446708 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 21 Mar 2024 09:32:54 +0100 Subject: [PATCH 286/403] [Config/OV] Version.cpp - describe OpenVario Version as 'OpenVario' (not 'Linux') --- src/Version.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Version.cpp b/src/Version.cpp index a076bc4d467..68fa676f5ca 100644 --- a/src/Version.cpp +++ b/src/Version.cpp @@ -14,6 +14,8 @@ #define TARGET "Android" #elif defined(KOBO) #define TARGET "Kobo" +#elif defined(IS_OPENVARIO) + #define TARGET "OpenVario" #elif defined(__linux__) #define TARGET "Linux" #elif defined(__APPLE__) From 0953d779bb4eea3496c3c758cd981632fdcfd3e8 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 21 Mar 2024 09:35:04 +0100 Subject: [PATCH 287/403] [build] version.mk - Config: set GIT_COMMIT_ID for all builds --- build/version.mk | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build/version.mk b/build/version.mk index 3c0c75bc4c1..fc0fae6ed77 100644 --- a/build/version.mk +++ b/build/version.mk @@ -23,10 +23,11 @@ $(info GIT_COMMIT_ID is $(GIT_COMMIT_ID) ) $(info RELEASE_COMMIT_ID is $(RELEASE_COMMIT_ID) ) # only append the commit id for unreleased builds (no release tag) +VERSION_CPPFLAGS += -DGIT_COMMIT_ID=\"$(GIT_COMMIT_ID)\" +FULL_VERSION := $(FULL_VERSION)~$(GIT_COMMIT_ID) ifneq ($(GIT_COMMIT_ID),$(RELEASE_COMMIT_ID) ) $(info Git commits: HEAD = $(GIT_COMMIT_ID) vs. RELEASE = $(RELEASE_COMMIT_ID) ) - VERSION_CPPFLAGS += -DGIT_COMMIT_ID=\"$(GIT_COMMIT_ID)\" - FULL_VERSION := $(FULL_VERSION)~$(GIT_COMMIT_ID) + VERSION_CPPFLAGS += -DRELEASE_COMMIT_ID=\"$(RELEASE_COMMIT_ID)\" endif $(call SRC_TO_OBJ,$(SRC)/Version.cpp): $(topdir)/VERSION.txt From 8df7163ec8d9dad0daf44d13373feffaf7fe7d7f Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 21 Mar 2024 09:54:22 +0100 Subject: [PATCH 288/403] [Version] Version.cpp - check git commit --- src/Version.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Version.cpp b/src/Version.cpp index 68fa676f5ca..85c6d53cc30 100644 --- a/src/Version.cpp +++ b/src/Version.cpp @@ -34,9 +34,9 @@ #define VERSION_SUFFIX "" #ifdef GIT_COMMIT_ID -#define GIT_SUFFIX "~git#" GIT_COMMIT_ID +# define GIT_SUFFIX "~git#" GIT_COMMIT_ID #else -#define GIT_SUFFIX +# define GIT_SUFFIX #endif const TCHAR OpenSoar_Version[] = _T(VERSION); From ea12d3b55ebd8bc0882657c7a9610f8406f01bce Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 21 Mar 2024 17:52:17 +0100 Subject: [PATCH 289/403] [OV] OpenVario menu - reorder the menu fields --- src/OpenVario/DisplaySettingsWidget.cpp | 97 ++++++++++++++++++++++++- src/OpenVario/ExtraWidget.cpp | 13 +++- src/OpenVario/SystemSettingsWidget.cpp | 54 +++----------- 3 files changed, 113 insertions(+), 51 deletions(-) diff --git a/src/OpenVario/DisplaySettingsWidget.cpp b/src/OpenVario/DisplaySettingsWidget.cpp index 34a281b95cf..04e65a09c32 100644 --- a/src/OpenVario/DisplaySettingsWidget.cpp +++ b/src/OpenVario/DisplaySettingsWidget.cpp @@ -6,6 +6,9 @@ #include "Dialogs/ProcessDialog.hpp" #include "Dialogs/WidgetDialog.hpp" #include "DisplayOrientation.hpp" +#include "Form/DataField/Listener.hpp" +#include "Form/DataField/Enum.hpp" +#include "Form/DataField/Integer.hpp" #include "Hardware/DisplayDPI.hpp" #include "Hardware/DisplayGlue.hpp" #include "Hardware/RotateDisplay.hpp" @@ -14,11 +17,13 @@ #include "Profile/Map.hpp" #include "Screen/Layout.hpp" #include "UIGlobals.hpp" +#include "UIActions.hpp" #include "system/FileUtil.hpp" #include "system/Process.hpp" #include "ui/event/KeyCode.hpp" #include "ui/event/Timer.hpp" #include "ui/window/Init.hpp" +#include "UtilsSettings.hpp" #include "Language/Language.hpp" @@ -31,6 +36,7 @@ #include "OpenVario/DisplaySettingsWidget.hpp" #include "OpenVario/System/Setting/RotationWidget.hpp" #include "OpenVario/System/Setting/WifiWidget.hpp" +#include "OpenVario/System/OpenVarioTools.hpp" #ifndef _WIN32 #include @@ -41,26 +47,82 @@ #include #include -class DisplaySettingsWidget final : public RowFormWidget { +enum ControlIndex { + ROTATION, + BRIGHTNESS, + + TOUCH_CALIBRATION, + +}; + + static constexpr StaticEnumChoice rotation_list[] = { + // { DisplayOrientation::DEFAULT, _T("default") }, + {DisplayOrientation::LANDSCAPE, _T("Landscape (0°)")}, + {DisplayOrientation::PORTRAIT, _T("Portrait (90°)")}, + {DisplayOrientation::REVERSE_LANDSCAPE, _T("Rev. Landscape (180°)")}, + {DisplayOrientation::REVERSE_PORTRAIT, _T("rev. Portrait (270°)")}, + nullptr}; + +class DisplaySettingsWidget final : public RowFormWidget, DataFieldListener { public: DisplaySettingsWidget() noexcept : RowFormWidget(UIGlobals::GetDialogLook()) {} -private: /* virtual methods from class Widget */ void Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept override; + bool Save(bool &changed) noexcept override; + // bool CheckChanged(bool &changed) noexcept; + +private: + /* methods from DataFieldListener */ + void OnModified(DataField &df) noexcept override; + + unsigned brightness; }; + +void DisplaySettingsWidget::OnModified([[maybe_unused]] DataField &df) noexcept { + if (IsDataField(ROTATION, df)) { + // ShowMessageBox(_T("Set Rotation"), _T("Rotation"), MB_OK); + // ovdevice.SetRotation((DisplayOrientation)((const DataFieldEnum + // &)df).GetValue()); + // UI::TopWindow::SetExitValue(EXIT_RESTART); + // UIActions::SignalShutdown(true); + } else if (IsDataField(BRIGHTNESS, df)) { + // const DataFieldInteger &dfi = (const DataFieldInteger &)df; + // (DataFieldInteger*)df) + ovdevice.SetBrightness(((const DataFieldInteger &)df).GetValue() / 10); + } +} + + void DisplaySettingsWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { + + brightness = ovdevice.brightness * 10; + +#ifdef ADD_ROTATION_BUTTON AddButton(_("Screen Rotation"), [this](){ - return ShowRotationSettingsWidget(UIGlobals::GetMainWindow(), GetLook()); + return ShowRotationSettingsWidget(UIGlobals::GetMainWindow(), GetLook()); }); +#endif + AddEnum(_("Rotation"), _("Rotation Display OpenVario"), rotation_list, + (unsigned)ovdevice.rotation, this); + + AddInteger(_("Brightness"), _("Brightness Display OpenVario"), _T("%d%%"), + _T("%d%%"), 10, 100, 10, brightness, this); + + AddButton(_("Calibrate Touch"), [this]() { + // the programm exit in OpenSoar looks complete different fro OpenVarioBaseMenu + ContainerWindow::SetExitValue(LAUNCH_TOUCH_CALIBRATE); + UIActions::SignalShutdown(true); + return mrOK; + }); // AddButton(_("Setting Brightness"), [this](){ -// return ShowSettingBrightnessWidget(UIGlobals::GetMainWindow(), GetLook()); + // return ShowSettingBrightnessWidget(UIGlobals::GetMainWindow(), GetLook()); // }); // uint32_t iTest = 0; @@ -68,6 +130,33 @@ DisplaySettingsWidget::Prepare([[maybe_unused]] ContainerWindow &parent, // 10, 1, iTest); } +bool +DisplaySettingsWidget::Save([[maybe_unused]] bool &_changed) noexcept +{ +bool changed = false; +// bool restart = false; +if (SaveValueInteger(BRIGHTNESS, "Brightness", brightness)) { + ovdevice.SetBrightness(brightness / 10); + changed = true; +} +if (SaveValueEnum(ROTATION, ovdevice.rotation)) { + // ovdevice.SetRotation( + // (DisplayOrientation)((const DataFieldEnum &)df).GetValue()); + ovdevice.SetRotation(ovdevice.rotation); + // restart = true; +#if 0 // defined(OPENVARIO_BASEMENU) + changed = true; +#else + require_restart = changed = true; +#endif +} + +_changed = changed; +return true; +} + + + bool ShowDisplaySettingsWidget(ContainerWindow &parent, const DialogLook &look) noexcept { diff --git a/src/OpenVario/ExtraWidget.cpp b/src/OpenVario/ExtraWidget.cpp index 21ba47d1bb4..6078f682139 100644 --- a/src/OpenVario/ExtraWidget.cpp +++ b/src/OpenVario/ExtraWidget.cpp @@ -43,6 +43,13 @@ class ExtraWidget final : public RowFormWidget { void ExtraWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { +#if 0 + std::string ImageFile = ""; + AddFile(_("Upgrade Firmware"), + _("Upgrade Firmware (.img.gz) "), + ImageFile, _T("*.img.gz\0"), FileType::IMAGE); + +#else AddButton(_("Upgrade Firmware"), [this]() { #if 0 // Segmentation fault? def OPENVARIO_BASEMENU exit(START_UPGRADE); @@ -52,10 +59,10 @@ void ExtraWidget::Prepare([[maybe_unused]] ContainerWindow &parent, return mrOK; // START_UPGRADE; #endif }); +#endif + /* deprecated: */ AddButton(_("Calibrate Sensors"), CalibrateSensors); - AddButton(_("Calibrate Sensors"), CalibrateSensors); - - AddButton(_("Calibrate Touch"), [this]() { + /* deprecated: */ AddButton(_("Calibrate Touch"), [this]() { // the programm exit in OpenSoar looks complete different fro OpenVarioBaseMenu #if 0 // Segmentation fault? def OPENVARIO_BASEMENU exit(LAUNCH_TOUCH_CALIBRATE); diff --git a/src/OpenVario/SystemSettingsWidget.cpp b/src/OpenVario/SystemSettingsWidget.cpp index b6710430011..23d6418fae7 100644 --- a/src/OpenVario/SystemSettingsWidget.cpp +++ b/src/OpenVario/SystemSettingsWidget.cpp @@ -21,10 +21,10 @@ #include "Dialogs/Message.hpp" #include "./LogFile.hpp" #include "UIActions.hpp" -#include "UtilsSettings.hpp" #include "ProgramVersion.h" #include "OpenVario/System/OpenVarioDevice.hpp" +#include "OpenVario/System/OpenVarioTools.hpp" #include "OpenVario/System/WifiDialogOV.hpp" @@ -35,13 +35,12 @@ enum ControlIndex { FW_VERSION, FIRMWARE, ENABLED, - ROTATION, - BRIGHTNESS, SENSORD, VARIOD, SSH, TIMEOUT, WIFI_BUTTON, + SENSOR_CAL, #ifdef _DEBUG INTEGERTEST, @@ -67,8 +66,6 @@ class SystemSettingsWidget final : public RowFormWidget, DataFieldListener { private: /* methods from DataFieldListener */ void OnModified(DataField &df) noexcept override; - - unsigned brightness; }; #endif static constexpr StaticEnumChoice timeout_list[] = { @@ -90,20 +87,11 @@ class SystemSettingsWidget final : public RowFormWidget, DataFieldListener { nullptr }; - static constexpr StaticEnumChoice rotation_list[] = { - // { DisplayOrientation::DEFAULT, _T("default") }, - { DisplayOrientation::LANDSCAPE, _T("Landscape (0°)") }, - { DisplayOrientation::PORTRAIT, _T("Portrait (90°)") }, - { DisplayOrientation::REVERSE_LANDSCAPE, _T("Rev. Landscape (180°)") }, - { DisplayOrientation::REVERSE_PORTRAIT, _T("rev. Portrait (270°)")}, - nullptr - }; - void SystemSettingsWidget::SetEnabled([[maybe_unused]] bool enabled) noexcept { // this disabled itself: SetRowEnabled(ENABLED, enabled); - SetRowEnabled(BRIGHTNESS, enabled); + // SetRowEnabled(BRIGHTNESS, enabled); SetRowEnabled(TIMEOUT, enabled); } @@ -113,13 +101,6 @@ SystemSettingsWidget::OnModified([[maybe_unused]] DataField &df) noexcept if (IsDataField(ENABLED, df)) { // const DataFieldBoolean &dfb = ; SetEnabled(((const DataFieldBoolean &)df).GetValue()); - } else if (IsDataField(ROTATION, df)) { - // ShowMessageBox(_T("Set Rotation"), _T("Rotation"), MB_OK); - // ovdevice.SetRotation((DisplayOrientation)((const DataFieldEnum &)df).GetValue()); - } else if (IsDataField(BRIGHTNESS, df)) { - // const DataFieldInteger &dfi = (const DataFieldInteger &)df; - // (DataFieldInteger*)df) - ovdevice.SetBrightness(((const DataFieldInteger &)df).GetValue() / 10); } else if (IsDataField(FIRMWARE, df)) { // (DataFieldInteger*)df) // ConvertString @@ -133,9 +114,7 @@ SystemSettingsWidget::Prepare(ContainerWindow &parent, { RowFormWidget::Prepare(parent, rc); - brightness = ovdevice.brightness * 10; - - AddReadOnly(_("Current FW"), _("Current firmware version of OpenVario"), + AddReadOnly(_("Current OpenSoar"), _("Current firmware version of OpenVario"), #if defined(PROGRAM_VERSION) _T(PROGRAM_VERSION)); #else @@ -148,12 +127,6 @@ SystemSettingsWidget::Prepare(ContainerWindow &parent, _("Settings Enabled"), _("Enable the Settings Page"), ovdevice.enabled, this); - AddEnum(_("Rotation"), _("Rotation Display OpenVario"), - rotation_list, (unsigned)ovdevice.rotation, this); - - AddInteger(_("Brightness"), - _("Brightness Display OpenVario"), _T("%d%%"), _T("%d%%"), 10, - 100, 10, brightness, this); AddBoolean(_("SensorD"), _("Enable the SensorD"), ovdevice.sensord, this); AddBoolean(_("VarioD"), _("Enable the VarioD"), ovdevice.variod, this); AddEnum(_("SSH"), _("Enable the SSH Connection"), enable_list, @@ -165,6 +138,10 @@ SystemSettingsWidget::Prepare(ContainerWindow &parent, _T("Settings Wifi"), [this]() { ShowWifiDialog(); }); + + AddButton(_("Calibrate Sensors"), CalibrateSensors); + + #ifdef _DEBUG AddInteger(_("IntegerTest"), _("IntegerTest."), _T("%d"), _T("%d"), 0, @@ -188,7 +165,7 @@ SystemSettingsWidget::Save([[maybe_unused]] bool &_changed) noexcept if (SaveValue(ENABLED, "Enabled", ovdevice.enabled, false)) { ovdevice.settings.insert_or_assign("Enabled", - ovdevice.brightness ? "True" : "False"); + ovdevice.enabled ? "True" : "False"); changed = true; } @@ -198,11 +175,6 @@ SystemSettingsWidget::Save([[maybe_unused]] bool &_changed) noexcept changed = true; } - if (SaveValueInteger(BRIGHTNESS, "Brightness", brightness)) { - ovdevice.SetBrightness(brightness/10); - changed = true; - } - #ifdef _DEBUG if (SaveValueInteger(INTEGERTEST, "iTest", ovdevice.iTest)) { ovdevice.settings.insert_or_assign( @@ -220,12 +192,6 @@ SystemSettingsWidget::Save([[maybe_unused]] bool &_changed) noexcept WriteConfigFile(ovdevice.settings, ovdevice.GetSettingsConfig()); } - if (SaveValueEnum(ROTATION, ovdevice.rotation)) { - // ovdevice.SetRotation(ovdevice.rotation); - // restart = true; - require_restart = changed = true; - } - if (SaveValueEnum(SSH, ovdevice.ssh)) ovdevice.SetSSHStatus((SSHStatus)ovdevice.ssh); @@ -239,6 +205,7 @@ SystemSettingsWidget::Save([[maybe_unused]] bool &_changed) noexcept return true; } +// this has only defined in OpenVarioBaseMenu... bool ShowSystemSettingsWidget(ContainerWindow &parent, const DialogLook &look) noexcept @@ -260,4 +227,3 @@ CreateSystemSettingsWidget() noexcept } - From 273695d597028681b178ca63ed9bd39737bf7171 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 27 Mar 2024 15:06:32 +0100 Subject: [PATCH 290/403] [OV] OpenSoar.cpp - add static function Finishing ### trial with moving InitAudio and ShutdownAudio to GlobalPCM-Mixer, but hided --- src/OpenSoar.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/OpenSoar.cpp b/src/OpenSoar.cpp index 4ede2361370..aeb9089f874 100644 --- a/src/OpenSoar.cpp +++ b/src/OpenSoar.cpp @@ -92,9 +92,7 @@ static const char *const Usage = "\n" #endif ; -static int -Main() -{ +static int Main() { ScreenGlobalInit screen_init; #if defined(__APPLE__) && !TARGET_OS_IPHONE @@ -113,9 +111,14 @@ Main() ScopeGlobalAsioThread global_asio_thread; const Net::ScopeInit net_init(asio_thread->GetEventLoop()); +#ifdef EXTERNAL_AUDIO_INIT + InitAudio(&asio_thread->GetEventLoop()); + // How I get this variables to live up to the end? +#else ScopeGlobalPCMMixer global_pcm_mixer(asio_thread->GetEventLoop()); ScopeGlobalPCMResourcePlayer global_pcm_resouce_player; ScopeGlobalVolumeController global_volume_controller; +#endif // Perform application initialization and run loop int ret = EXIT_FAILURE; @@ -124,6 +127,10 @@ Main() Shutdown(); +#ifdef EXTERNAL_AUDIO_INIT + ShutdownAudio(); +#endif + DisallowLanguage(); Fonts::Deinitialize(); @@ -133,7 +140,7 @@ Main() return ret; } -int +static int Finishing(int ret) { LogString("Finishing"); switch (ret) { @@ -174,7 +181,8 @@ try { do { { rerun = false; - UI::TopWindow::SetExitValue(0); + // UI::TopWindow::SetExitValue(0); + #ifdef _WIN32 if (UIGlobals::CommandLine == nullptr) UIGlobals::CommandLine = GetCommandLine(); @@ -194,6 +202,7 @@ try { // Write startup note + version to logfile LogFormat(_T("Starting OpenSoar %s"), OpenSoar_ProductToken); + // int ret = Main(); #if defined(__APPLE__) && TARGET_OS_IPHONE @@ -207,8 +216,9 @@ try { ret = UI::TopWindow::GetExitValue(); #endif rerun = (ret == EXIT_RESTART); + if (rerun) + UI::TopWindow::SetExitValue(0); } while (rerun); - return Finishing(ret); } catch (...) { PrintException(std::current_exception()); From 422e188c6951962a47b20f6877cd83c541bfa902 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sun, 24 Mar 2024 17:19:33 +0100 Subject: [PATCH 291/403] DumpPort.cpp - bugfix: don't make an exception at a closed port, this will crashing the application! --- src/Device/Port/DumpPort.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Device/Port/DumpPort.cpp b/src/Device/Port/DumpPort.cpp index 971f1a74926..df25b21f308 100644 --- a/src/Device/Port/DumpPort.cpp +++ b/src/Device/Port/DumpPort.cpp @@ -8,6 +8,8 @@ #include #include +using std::string_view_literals::operator""sv; + #ifdef __clang__ /* true, the nullptr cast below is a bad kludge */ #pragma GCC diagnostic ignored "-Wnull-dereference" @@ -58,10 +60,15 @@ DumpPort::Write(std::span src) std::size_t nbytes; try { nbytes = port->Write(src); - } catch (...) { - if (enabled) - LogFmt("Write({})=error", src.size()); - throw; +// } catch (...) { + } catch (std::exception &e) { + if (e.what() == "Port is closed"sv) { + return 0; + } else { + if (enabled) + LogFmt("Write({})=error", src.size()); + throw; + } } if (enabled) { From 982c30eca7d45f3e7101386fd35b81d8ee225c29 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 26 Mar 2024 10:59:30 +0100 Subject: [PATCH 292/403] OpenSoar-News.md - Bugfix TCP-Client --- OpenSoar-News.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OpenSoar-News.md b/OpenSoar-News.md index 0cdf5400cec..0722b7a5a05 100644 --- a/OpenSoar-News.md +++ b/OpenSoar-News.md @@ -1,5 +1,7 @@ OpenSoar Version 7.41.21.1 - not yet released --------------- +* TCP Port - Bugfix on closing the TCP client as receiver on this port: + By closing the receiver OpenSoar crashed! * End of program with (short) restart, reboot, shutdown and normal program end * OpenVario menu inserted * OpenVario: From 82782eb165ce57945cd933c50ac5f3b2ae30a140 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 26 Mar 2024 11:55:56 +0100 Subject: [PATCH 293/403] [OV] dlgConfiguration.cpp - code alignment --- src/Dialogs/Settings/dlgConfiguration.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Dialogs/Settings/dlgConfiguration.cpp b/src/Dialogs/Settings/dlgConfiguration.cpp index 516c6d0d484..dde48f6b695 100644 --- a/src/Dialogs/Settings/dlgConfiguration.cpp +++ b/src/Dialogs/Settings/dlgConfiguration.cpp @@ -165,7 +165,7 @@ static constexpr TabMenuPage openvario_pages[] = { #endif static constexpr TabMenuGroup main_menu_captions[] = { - {N_("Basic Settings"), basic_pages}, + { N_("Basic Settings"), basic_pages}, { N_("Map Display"), map_pages }, { N_("Glide Computer"), computer_pages }, { N_("Gauges"), gauge_pages }, @@ -173,7 +173,7 @@ static constexpr TabMenuGroup main_menu_captions[] = { { N_("Look"), look_pages }, { N_("Setup"), setup_pages }, #ifdef IS_OPENVARIO - {N_("OpenVario"), openvario_pages}, + { N_("OpenVario"), openvario_pages}, #endif }; From a66615c0cb7317ca891facde38df8c55fef983ea Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 26 Mar 2024 11:58:00 +0100 Subject: [PATCH 294/403] Device/DeviceEditWidget.cpp - code bug: use #ifdef _WIN32 instead of #if _WIN32 --- src/Dialogs/Device/DeviceEditWidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Dialogs/Device/DeviceEditWidget.cpp b/src/Dialogs/Device/DeviceEditWidget.cpp index 5e7e75118a8..31a84550eb2 100644 --- a/src/Dialogs/Device/DeviceEditWidget.cpp +++ b/src/Dialogs/Device/DeviceEditWidget.cpp @@ -390,7 +390,7 @@ FinishPortField(DeviceConfig &config, const DataFieldEnum &df) noexcept case DeviceConfig::PortType::BLE_HM10: case DeviceConfig::PortType::BLE_SENSOR: /* Bluetooth */ -#if _WIN32 +#ifdef _WIN32 // identical with Serial Port if (new_type == config.port_type && StringIsEqual(config.path, df.GetAsString())) From e29011f5dce650fecfabd6a5a73329f73ac60931 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 26 Mar 2024 12:07:51 +0100 Subject: [PATCH 295/403] LocalPath.cpp - replace TODO --- src/LocalPath.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LocalPath.cpp b/src/LocalPath.cpp index 8b433a23cda..d1ebe277c7c 100644 --- a/src/LocalPath.cpp +++ b/src/LocalPath.cpp @@ -314,12 +314,12 @@ InitialiseDataPath() if (data_paths.empty()) throw std::runtime_error("No data path found"); } + // TODO: delete the old cache directory in OpenSoarData? #ifdef ANDROID cache_path = context->GetExternalCacheDir(Java::GetEnv()); if (cache_path == nullptr) throw std::runtime_error("No Android cache directory"); - // TODO: delete the old cache directory in OpenSoarData? #else cache_path = LocalPath(_T("cache")); #endif From e6cd290a1896ba1b9c38fe8a316ab38f33e46f77 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 26 Mar 2024 12:10:15 +0100 Subject: [PATCH 296/403] [Log] LogFile.cpp - the log file is generated in the STANDARD data path always please don't search for this in the caller argument path '-datapath=' --- src/LogFile.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/LogFile.cpp b/src/LogFile.cpp index ae8b90feaf4..17779c7a063 100644 --- a/src/LogFile.cpp +++ b/src/LogFile.cpp @@ -16,7 +16,8 @@ #include -#include +#include +#include // UNICODE??? #include #include @@ -39,12 +40,14 @@ OpenLog() if (!initialised) { initialised = true; + + /* Unfortunately on program start the LocalPath pointed to the 'standard' + * local path - and not to the user local path set with the caller argument + * '-datapath=' + * A handler for this is possible but make the management much complicated! + */ + path = LocalPath(_T("OpenSoar")); -#ifdef IS_OPENVARIO - path = LocalPath(ovdevice.GetExeName().c_str()); -#else - path = LocalPath(_T("xcsoar.log")); -#endif /* delete the obsolete log file */ File::Delete(path + _T("-startup.log")); auto back_path = path + _T("-old.log"); From a2c75e85902ed9055ac2e0b87c235d2064787e48 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 26 Mar 2024 21:10:18 +0100 Subject: [PATCH 297/403] Widget/LargeTextWidget.hpp - use #ifdef _UNICODE instead of #if _UNICODE --- src/Widget/LargeTextWidget.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Widget/LargeTextWidget.hpp b/src/Widget/LargeTextWidget.hpp index 358bbcc9ba8..dcb7cbfd0ae 100644 --- a/src/Widget/LargeTextWidget.hpp +++ b/src/Widget/LargeTextWidget.hpp @@ -6,7 +6,7 @@ #include "WindowWidget.hpp" #include -#if _UNICODE +#ifdef _UNICODE #include #endif @@ -25,7 +25,7 @@ class LargeTextWidget : public WindowWidget { :look(_look), text(_text) {} void SetText(const TCHAR *text) noexcept; -#if _UNICODE +#ifdef _UNICODE void SetText(const char *text) noexcept; void SetText(const std::string_view text) noexcept; #endif From 013ad79f8c0f23df1126c5d493a1e6d7e1ba32fe Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 26 Mar 2024 14:47:48 +0100 Subject: [PATCH 298/403] [OV] DisplaySettingsWidget.cpp - change file from ANSI to UTF8 --- src/OpenVario/DisplaySettingsWidget.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/OpenVario/DisplaySettingsWidget.cpp b/src/OpenVario/DisplaySettingsWidget.cpp index 04e65a09c32..bf7651e583b 100644 --- a/src/OpenVario/DisplaySettingsWidget.cpp +++ b/src/OpenVario/DisplaySettingsWidget.cpp @@ -57,10 +57,10 @@ enum ControlIndex { static constexpr StaticEnumChoice rotation_list[] = { // { DisplayOrientation::DEFAULT, _T("default") }, - {DisplayOrientation::LANDSCAPE, _T("Landscape (0°)")}, - {DisplayOrientation::PORTRAIT, _T("Portrait (90°)")}, - {DisplayOrientation::REVERSE_LANDSCAPE, _T("Rev. Landscape (180°)")}, - {DisplayOrientation::REVERSE_PORTRAIT, _T("rev. Portrait (270°)")}, + {DisplayOrientation::LANDSCAPE, _T("Landscape (0°)")}, + {DisplayOrientation::PORTRAIT, _T("Portrait (90°)")}, + {DisplayOrientation::REVERSE_LANDSCAPE, _T("Rev. Landscape (180°)")}, + {DisplayOrientation::REVERSE_PORTRAIT, _T("rev. Portrait (270°)")}, nullptr}; class DisplaySettingsWidget final : public RowFormWidget, DataFieldListener { From 4dd2c674791b47f9e0406770cdde7055be915212 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 26 Mar 2024 23:26:30 +0100 Subject: [PATCH 299/403] [Vol] InputEventsSettings.cpp - extend the eventSounds handler with Volume --- src/Input/InputEventsSettings.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/Input/InputEventsSettings.cpp b/src/Input/InputEventsSettings.cpp index b20394622c8..49c3241c55c 100644 --- a/src/Input/InputEventsSettings.cpp +++ b/src/Input/InputEventsSettings.cpp @@ -28,15 +28,25 @@ InputEvents::eventSounds(const TCHAR *misc) { SoundSettings &settings = CommonInterface::SetUISettings().sound; // bool OldEnableSoundVario = EnableSoundVario; - + bool enabled = settings.vario.enabled; if (StringIsEqual(misc, _T("toggle"))) - settings.vario.enabled = !settings.vario.enabled; + settings.vario.enabled = !enabled; else if (StringIsEqual(misc, _T("on"))) settings.vario.enabled = true; else if (StringIsEqual(misc, _T("off"))) settings.vario.enabled = false; - else if (StringIsEqual(misc, _T("show"))) { - if (settings.vario.enabled) + else if (StringIsEqual(misc, _T("quieter"))) { + settings.vario.volume = settings.vario.volume / 2; + if (settings.vario.volume < 1) // settings.vario.max_volume) + settings.vario.volume = 1; // don't switch to off! + // settings.vario.enabled = false; + } else if (StringIsEqual(misc, _T("louder"))) { + settings.vario.volume = settings.vario.volume * 2; + if (settings.vario.volume > 100) // settings.vario.max_volume) + settings.vario.volume = 100; + // settings.vario.enabled = false; + } else if (StringIsEqual(misc, _T("show"))) { + if (enabled) Message::AddMessage(_("Vario sounds on")); else Message::AddMessage(_("Vario sounds off")); @@ -44,7 +54,8 @@ InputEvents::eventSounds(const TCHAR *misc) } AudioVarioGlue::Configure(settings.vario); - Profile::Set(ProfileKeys::SoundAudioVario, settings.vario.enabled); + if (settings.vario.enabled != enabled) + Profile::Set(ProfileKeys::SoundAudioVario, settings.vario.enabled); } void From b33562cc2e702ccd17491dc718453edaa482dcc7 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 19 Mar 2024 17:43:29 +0100 Subject: [PATCH 300/403] [Vol] AudioVarioConfigPanel.cpp - react on modified Audio on/off and uppercase for all enums - needed class DataFieldListener --- .../Settings/Panels/AudioVarioConfigPanel.cpp | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/Dialogs/Settings/Panels/AudioVarioConfigPanel.cpp b/src/Dialogs/Settings/Panels/AudioVarioConfigPanel.cpp index 0f56753d9b4..08aecd6f0e2 100644 --- a/src/Dialogs/Settings/Panels/AudioVarioConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/AudioVarioConfigPanel.cpp @@ -2,11 +2,14 @@ // Copyright The XCSoar Project #include "AudioVarioConfigPanel.hpp" +#include "Dialogs/Message.hpp" #include "Profile/Keys.hpp" #include "Language/Language.hpp" #include "Interface.hpp" #include "Widget/RowFormWidget.hpp" +#include "Form/DataField/Boolean.hpp" #include "Form/DataField/Float.hpp" +#include "Form/DataField/Listener.hpp" #include "UIGlobals.hpp" #include "Audio/Features.hpp" #include "Audio/VarioGlue.hpp" @@ -14,8 +17,8 @@ #include "Formatter/UserUnits.hpp" enum ControlIndex { - Enabled, - Volume, + ENABLED, + VOLUME, DEAD_BAND_ENABLED, SPACER, MIN_FREQUENCY, @@ -27,7 +30,7 @@ enum ControlIndex { }; -class AudioVarioConfigPanel final : public RowFormWidget { +class AudioVarioConfigPanel final : public RowFormWidget, DataFieldListener { public: AudioVarioConfigPanel() :RowFormWidget(UIGlobals::GetDialogLook()) {} @@ -35,8 +38,23 @@ class AudioVarioConfigPanel final : public RowFormWidget { public: void Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept override; bool Save(bool &changed) noexcept override; + +private: + /* methods from DataFieldListener */ + void OnModified(DataField &df) noexcept override; }; +void +AudioVarioConfigPanel::OnModified([[maybe_unused]] DataField &df) noexcept +{ + if (IsDataField(ENABLED, df)) { + bool enabled = ((const DataFieldBoolean &)df).GetValue(); + // SetEnabled(((const DataFieldBoolean &)df).GetValue()); + ShowMessageBox(enabled ? _T("Audio enabled") : _T("disabled"), + _T("Audio-Enable"), 0); //MB_OK); + } +} + void AudioVarioConfigPanel::Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept @@ -50,7 +68,7 @@ AudioVarioConfigPanel::Prepare(ContainerWindow &parent, AddBoolean(_("Audio vario"), _("Emulate the sound of an electronic vario."), - settings.enabled); + settings.enabled, this); AddInteger(_("Volume"), nullptr, _T("%u %%"), _T("%u"), 0, 100, 1, settings.volume); @@ -112,10 +130,10 @@ AudioVarioConfigPanel::Save(bool &changed) noexcept auto &settings = CommonInterface::SetUISettings().sound.vario; - changed |= SaveValue(Enabled, ProfileKeys::SoundAudioVario, + changed |= SaveValue(ENABLED, ProfileKeys::SoundAudioVario, settings.enabled); - changed |= SaveValueInteger(Volume, ProfileKeys::SoundVolume, + changed |= SaveValueInteger(VOLUME, ProfileKeys::SoundVolume, settings.volume); changed |= SaveValue(DEAD_BAND_ENABLED, ProfileKeys::VarioDeadBandEnabled, From ed94893611c377d39a7b336838fcd3b2af886d10 Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 22 Mar 2024 13:54:00 +0100 Subject: [PATCH 301/403] [Vol] VarioGlue.cpp - don't stop the player, set the volume to 0 only --- src/Audio/VarioGlue.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Audio/VarioGlue.cpp b/src/Audio/VarioGlue.cpp index 176b83d8363..efbd3a8c5c1 100644 --- a/src/Audio/VarioGlue.cpp +++ b/src/Audio/VarioGlue.cpp @@ -76,8 +76,11 @@ AudioVarioGlue::Configure(const VarioSoundSettings &settings) synthesiser->SetPeriods(settings.min_period_ms, settings.max_period_ms); synthesiser->SetDeadBandRange(settings.min_dead, settings.max_dead); player->Start(*synthesiser); - } else - player->Stop(); + } else { + synthesiser->SetVolume(0); + player->Start(*synthesiser); + // player->Stop(); + } } void From a451585f468fb5898455b50b143733edeb4c2c06 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 26 Mar 2024 18:34:22 +0100 Subject: [PATCH 302/403] [Vol] Audio/Sound settings with QuickMenu --- Data/Input/default.xci | 20 ++++++++++++++++++-- Data/Input/defaultOV.xci | 20 ++++++++++++++++++-- src/Dialogs/Dialogs.h | 6 ++++-- src/Dialogs/dlgQuickMenu.cpp | 4 ++-- src/Input/InputEventsActions.cpp | 4 ++-- 5 files changed, 44 insertions(+), 10 deletions(-) diff --git a/Data/Input/default.xci b/Data/Input/default.xci index b73607f734a..2704c6c13bf 100644 --- a/Data/Input/default.xci +++ b/Data/Input/default.xci @@ -1272,12 +1272,28 @@ event=AirSpace toggle label=Airspace\n$(AirspaceToggleActionName) location=34 +mode=RemoteStick +type=key +data=0 +event=Sounds quiter +event=QuickMenu 58 +label=Vario Audio Quieter +location=57 + mode=RemoteStick type=key data=0 event=Sounds toggle -event=Mode default -label=Audio On/Off +event=QuickMenu 58 +label=Vario Audio On/Off +location=58 + +mode=RemoteStick +type=key +data=0 +event=Sounds louder +event=QuickMenu 58 +label=Vario Audio Louder location=59 mode=RemoteStick diff --git a/Data/Input/defaultOV.xci b/Data/Input/defaultOV.xci index 7b6c49ece60..5d71c61a2ca 100644 --- a/Data/Input/defaultOV.xci +++ b/Data/Input/defaultOV.xci @@ -1272,12 +1272,28 @@ event=AirSpace toggle label=Airspace\n$(AirspaceToggleActionName) location=34 +mode=RemoteStick +type=key +data=0 +event=Sounds quiter +event=QuickMenu 58 +label=Vario Audio Quieter +location=57 + mode=RemoteStick type=key data=0 event=Sounds toggle -event=Mode default -label=Audio On/Off +event=QuickMenu 58 +label=Vario Audio On/Off +location=58 + +mode=RemoteStick +type=key +data=0 +event=Sounds louder +event=QuickMenu 58 +label=Vario Audio Louder location=59 mode=RemoteStick diff --git a/src/Dialogs/Dialogs.h b/src/Dialogs/Dialogs.h index 799a7d63077..7784df25fc2 100644 --- a/src/Dialogs/Dialogs.h +++ b/src/Dialogs/Dialogs.h @@ -3,6 +3,8 @@ #pragma once +#include + namespace UI { class SingleWindow; } void dlgBasicSettingsShowModal(); @@ -17,5 +19,5 @@ void dlgStatusShowModal(int page); void dlgCreditsShowModal(UI::SingleWindow &parent); -void -dlgQuickMenuShowModal(UI::SingleWindow &parent) noexcept; +void dlgQuickMenuShowModal(UI::SingleWindow & parent, + const TCHAR *mode) noexcept; diff --git a/src/Dialogs/dlgQuickMenu.cpp b/src/Dialogs/dlgQuickMenu.cpp index 1170aeed6d2..5cae5f12961 100644 --- a/src/Dialogs/dlgQuickMenu.cpp +++ b/src/Dialogs/dlgQuickMenu.cpp @@ -271,8 +271,8 @@ ShowQuickMenu(UI::SingleWindow &parent, const Menu &menu) noexcept return dialog.GetWidget().clicked_event; } -void -dlgQuickMenuShowModal(UI::SingleWindow &parent) noexcept +void dlgQuickMenuShowModal(UI::SingleWindow &parent, + [[maybe_unused]] const TCHAR *mode) noexcept { const auto *menu = InputEvents::GetMenu(_T("RemoteStick")); if (menu == nullptr) diff --git a/src/Input/InputEventsActions.cpp b/src/Input/InputEventsActions.cpp index f84292f60ea..55df874323a 100644 --- a/src/Input/InputEventsActions.cpp +++ b/src/Input/InputEventsActions.cpp @@ -785,9 +785,9 @@ InputEvents::eventWeather(const TCHAR *misc) } void -InputEvents::eventQuickMenu([[maybe_unused]] const TCHAR *misc) +InputEvents::eventQuickMenu(const TCHAR *misc) { - dlgQuickMenuShowModal(*CommonInterface::main_window); + dlgQuickMenuShowModal(*CommonInterface::main_window, misc); } void From 64258a64eb27e41b01637be3317aaf193f358248 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 26 Mar 2024 23:58:17 +0100 Subject: [PATCH 303/403] [Vol] VarioGlue.cpp - cleanup the work around for swiching off at linux --- src/Audio/VarioGlue.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Audio/VarioGlue.cpp b/src/Audio/VarioGlue.cpp index efbd3a8c5c1..41a08212c7f 100644 --- a/src/Audio/VarioGlue.cpp +++ b/src/Audio/VarioGlue.cpp @@ -75,12 +75,19 @@ AudioVarioGlue::Configure(const VarioSoundSettings &settings) settings.max_frequency); synthesiser->SetPeriods(settings.min_period_ms, settings.max_period_ms); synthesiser->SetDeadBandRange(settings.min_dead, settings.max_dead); +#ifdef ANDROID player->Start(*synthesiser); } else { + player->Stop(); + } +#else + } else { + /* WorkAround: don't stop the player on Linux: player->Stop(); + * this never cannot switching on the sound! */ synthesiser->SetVolume(0); - player->Start(*synthesiser); - // player->Stop(); } + player->Start(*synthesiser); +#endif } void From d2311812935aceb9c509db51cc64b54c0f3d0e6f Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 19 Mar 2024 17:11:01 +0100 Subject: [PATCH 304/403] [Vol] CMake - add GlobalPCMMixer.* to cmake --- src/Audio/CMakeSource.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Audio/CMakeSource.cmake b/src/Audio/CMakeSource.cmake index 7f496b3cfa9..e7d0fe49da1 100644 --- a/src/Audio/CMakeSource.cmake +++ b/src/Audio/CMakeSource.cmake @@ -2,6 +2,8 @@ set(_SOURCES Audio/Settings.cpp Audio/Sound.cpp Audio/VarioSettings.cpp + + Audio/GlobalPCMMixer.cpp ) From 3eb5618db81936449359b1e3bda2ce8e435683cc Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 27 Mar 2024 14:53:17 +0100 Subject: [PATCH 305/403] [Vol] Audio/GlobalPCMMixer.cpp - add function InitAudio and ShutdownAudio for test reasons --- src/Audio/GlobalPCMMixer.cpp | 29 ++++++++++++++++++++++++++++- src/Audio/GlobalPCMMixer.hpp | 4 +++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/Audio/GlobalPCMMixer.cpp b/src/Audio/GlobalPCMMixer.cpp index cc436637aaa..772a07d672e 100644 --- a/src/Audio/GlobalPCMMixer.cpp +++ b/src/Audio/GlobalPCMMixer.cpp @@ -2,14 +2,24 @@ // Copyright The XCSoar Project #include "GlobalPCMMixer.hpp" -#include "PCMPlayerFactory.hpp" #include "PCMMixer.hpp" +#ifndef _WIN32 +#include "PCMPlayerFactory.hpp" +#endif +#include "GlobalPCMResourcePlayer.hpp" +#include "GlobalVolumeController.hpp" + +#include "event/Loop.hxx" #include #include PCMMixer *pcm_mixer = nullptr; +ScopeGlobalPCMMixer *global_pcm_mixer = nullptr; +ScopeGlobalPCMResourcePlayer *global_pcm_resouce_player = nullptr; +ScopeGlobalVolumeController *global_volume_controller = nullptr; +#ifndef _WIN32 void InitialisePCMMixer(EventLoop &event_loop) { @@ -28,3 +38,20 @@ DeinitialisePCMMixer() delete pcm_mixer; pcm_mixer = nullptr; } + +#endif + +void InitAudio(EventLoop *_loop) { + // How I get this variables to live up to the end? + EventLoop *loop = _loop; + global_pcm_mixer = new ScopeGlobalPCMMixer(*loop); + global_pcm_resouce_player = new ScopeGlobalPCMResourcePlayer; + global_volume_controller = new ScopeGlobalVolumeController; +} + +void ShutdownAudio() { + // How I get this variables to live up to the end? + delete global_pcm_mixer; + delete global_pcm_resouce_player; + delete global_volume_controller; +} diff --git a/src/Audio/GlobalPCMMixer.hpp b/src/Audio/GlobalPCMMixer.hpp index 6f75f683656..64f16029ba5 100644 --- a/src/Audio/GlobalPCMMixer.hpp +++ b/src/Audio/GlobalPCMMixer.hpp @@ -3,11 +3,13 @@ #pragma once - #include "Features.hpp" class EventLoop; +void InitAudio(EventLoop *loop); +void ShutdownAudio(); + #ifdef HAVE_PCM_MIXER class PCMMixer; From d87a418ae30427d3ab37b5c5ce48e62077ae855b Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 27 Mar 2024 15:03:36 +0100 Subject: [PATCH 306/403] [Vol] GlobalPCMMixer.* - use define EXTERNAL_AUDIO_INIT for moving this funktions from Main to here --- src/Audio/GlobalPCMMixer.cpp | 21 +++++++++++++++------ src/Audio/GlobalPCMMixer.hpp | 3 +++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/Audio/GlobalPCMMixer.cpp b/src/Audio/GlobalPCMMixer.cpp index 772a07d672e..ee12c0db1a9 100644 --- a/src/Audio/GlobalPCMMixer.cpp +++ b/src/Audio/GlobalPCMMixer.cpp @@ -6,18 +6,25 @@ #ifndef _WIN32 #include "PCMPlayerFactory.hpp" #endif -#include "GlobalPCMResourcePlayer.hpp" -#include "GlobalVolumeController.hpp" -#include "event/Loop.hxx" +// #define EXTERNAL_AUDIO_INIT + +#ifdef EXTERNAL_AUDIO_INIT +# include "GlobalPCMResourcePlayer.hpp" +# include "GlobalVolumeController.hpp" + +# include "event/Loop.hxx" +#endif #include #include PCMMixer *pcm_mixer = nullptr; -ScopeGlobalPCMMixer *global_pcm_mixer = nullptr; -ScopeGlobalPCMResourcePlayer *global_pcm_resouce_player = nullptr; -ScopeGlobalVolumeController *global_volume_controller = nullptr; +#ifdef EXTERNAL_AUDIO_INIT + ScopeGlobalPCMMixer *global_pcm_mixer = nullptr; + ScopeGlobalPCMResourcePlayer *global_pcm_resouce_player = nullptr; + ScopeGlobalVolumeController *global_volume_controller = nullptr; +#endif #ifndef _WIN32 void @@ -41,6 +48,7 @@ DeinitialisePCMMixer() #endif +#ifdef EXTERNAL_AUDIO_INIT void InitAudio(EventLoop *_loop) { // How I get this variables to live up to the end? EventLoop *loop = _loop; @@ -55,3 +63,4 @@ void ShutdownAudio() { delete global_pcm_resouce_player; delete global_volume_controller; } +#endif diff --git a/src/Audio/GlobalPCMMixer.hpp b/src/Audio/GlobalPCMMixer.hpp index 64f16029ba5..ec9fe8aefda 100644 --- a/src/Audio/GlobalPCMMixer.hpp +++ b/src/Audio/GlobalPCMMixer.hpp @@ -6,9 +6,12 @@ #include "Features.hpp" class EventLoop; +// #define EXTERNAL_AUDIO_INIT +#ifdef EXTERNAL_AUDIO_INIT void InitAudio(EventLoop *loop); void ShutdownAudio(); +#endif #ifdef HAVE_PCM_MIXER class PCMMixer; From c9a1a507b2c43fe17b3c97e36b074a878ce776eb Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 26 Mar 2024 11:10:55 +0100 Subject: [PATCH 307/403] [XCI] add key 'X' for all and reorder shutdown in OV --- Data/Input/default.xci | 6 ++++++ Data/Input/defaultOV.xci | 27 ++++++++++++++++----------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/Data/Input/default.xci b/Data/Input/default.xci index 2704c6c13bf..34a348a0c4f 100644 --- a/Data/Input/default.xci +++ b/Data/Input/default.xci @@ -82,6 +82,12 @@ type=key data=ESCAPE event=Mode default +mode=default pan Nav1 Nav2 Display1 Display2 Config1 Config2 Config3 Info1 Info2 Menu Vario1 Vario2 +type=key +data=X +event=Shutdown shutdown +event=Mode default + mode=default pan type=key data=ESCAPE diff --git a/Data/Input/defaultOV.xci b/Data/Input/defaultOV.xci index 5d71c61a2ca..117d97d98b4 100644 --- a/Data/Input/defaultOV.xci +++ b/Data/Input/defaultOV.xci @@ -82,6 +82,12 @@ type=key data=ESCAPE event=Mode default +mode=default pan Nav1 Nav2 Display1 Display2 Config1 Config2 Config3 Info1 Info2 Menu Vario1 Vario2 +type=key +data=X +event=Shutdown shutdown +event=Mode default + mode=default pan type=key data=ESCAPE @@ -1299,34 +1305,33 @@ location=59 mode=RemoteStick type=key data=0 -event=Exit restart +event=Exit system event=Mode default -label=Restart -location=60 +label=Quit +location=63 -# OpenVario only: mode=RemoteStick type=key data=0 -event=Shutdown reboot +event=Exit restart event=Mode default -label=Reboot +label=Restart location=61 # OpenVario only: mode=RemoteStick type=key data=0 -event=Shutdown shutdown +event=Shutdown reboot event=Mode default -label=Shutdown +label=Reboot location=62 +# OpenVario only: mode=RemoteStick type=key data=0 -event=Exit system +event=Shutdown shutdown event=Mode default -label=Quit +label=Shutdown location=63 - From 50dafdfad54b48a8d3c9db9bb9e2885466b21643 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 27 Mar 2024 15:25:16 +0100 Subject: [PATCH 308/403] [XCI] use correct serial batch for quick buttons --- Data/Input/default.xci | 11 +++++++---- Data/Input/defaultOV.xci | 12 ++++++++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Data/Input/default.xci b/Data/Input/default.xci index 34a348a0c4f..2f22007de8d 100644 --- a/Data/Input/default.xci +++ b/Data/Input/default.xci @@ -1281,24 +1281,27 @@ location=34 mode=RemoteStick type=key data=0 -event=Sounds quiter -event=QuickMenu 58 +event=QuickMenu 57 +event=Mode default +event=Sounds quieter label=Vario Audio Quieter location=57 mode=RemoteStick type=key data=0 -event=Sounds toggle event=QuickMenu 58 +event=Mode default +event=Sounds toggle label=Vario Audio On/Off location=58 mode=RemoteStick type=key data=0 +event=QuickMenu 59 +event=Mode default event=Sounds louder -event=QuickMenu 58 label=Vario Audio Louder location=59 diff --git a/Data/Input/defaultOV.xci b/Data/Input/defaultOV.xci index 117d97d98b4..6e95ee51d64 100644 --- a/Data/Input/defaultOV.xci +++ b/Data/Input/defaultOV.xci @@ -1278,27 +1278,31 @@ event=AirSpace toggle label=Airspace\n$(AirspaceToggleActionName) location=34 + mode=RemoteStick type=key data=0 -event=Sounds quiter -event=QuickMenu 58 +event=QuickMenu 57 +event=Mode default +event=Sounds quieter label=Vario Audio Quieter location=57 mode=RemoteStick type=key data=0 -event=Sounds toggle event=QuickMenu 58 +event=Mode default +event=Sounds toggle label=Vario Audio On/Off location=58 mode=RemoteStick type=key data=0 +event=QuickMenu 59 +event=Mode default event=Sounds louder -event=QuickMenu 58 label=Vario Audio Louder location=59 From 66ee8436abc922bbd6ce424d17f19d82a366e86b Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 27 Mar 2024 15:33:02 +0100 Subject: [PATCH 309/403] [XCI] add Audio menu for controlling Volume and so on --- Data/Input/default.xci | 4 ++-- Data/Input/defaultOV.xci | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/Data/Input/default.xci b/Data/Input/default.xci index 2f22007de8d..41ac2eec581 100644 --- a/Data/Input/default.xci +++ b/Data/Input/default.xci @@ -1323,8 +1323,8 @@ location=63 # ------------- -# Define AudioMenu buttons for -# Vario app must be connected as device A +# Define AudioMenu buttons for Audio app +# - the PCM mixer controlled by OpenSoar # ------------- mode=AudioMenu diff --git a/Data/Input/defaultOV.xci b/Data/Input/defaultOV.xci index 6e95ee51d64..6cdac974f75 100644 --- a/Data/Input/defaultOV.xci +++ b/Data/Input/defaultOV.xci @@ -1339,3 +1339,42 @@ event=Shutdown shutdown event=Mode default label=Shutdown location=63 + +# ------------- +# Define AudioMenu buttons for Audio app +# - the PCM mixer controlled by OpenSoar +# ------------- + +mode=AudioMenu +type=key +data=DOWN +event=Sounds quieter +label=VOLUME- (DOWN) +location=1 + +mode=AudioMenu +type=key +data=RETURN +event=Sounds toggle +label=VOLUME ON/OFF (ENTER) +location=2 + +mode=AudioMenu +type=key +data=UP +event=Sounds louder +label=VOLUME+ (UP) +location=3 + +mode=AudioMenu +type=key +data=ESCAPE +event=Mode default +label=BACK (ESC) +location=5 + +mode=default RemoteStick +type=key +data=M +event=Mode AudioMenu + From 2b21bbf71c1263d714dc227a2470b03ea612f9e1 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 27 Mar 2024 16:55:25 +0100 Subject: [PATCH 310/403] [XCI] add key 'X' handler to exit --- Data/Input/default.xci | 9 ++++++++- Data/Input/defaultOV.xci | 15 ++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Data/Input/default.xci b/Data/Input/default.xci index 41ac2eec581..7d2a4d0ba6e 100644 --- a/Data/Input/default.xci +++ b/Data/Input/default.xci @@ -1319,7 +1319,7 @@ data=0 event=Exit system event=Mode default label=Quit -location=63 +location=61 # ------------- @@ -1360,3 +1360,10 @@ type=key data=M event=Mode AudioMenu +mode=default +type=key +data=X +event=Exit system + + + diff --git a/Data/Input/defaultOV.xci b/Data/Input/defaultOV.xci index 6cdac974f75..2da4570a33d 100644 --- a/Data/Input/defaultOV.xci +++ b/Data/Input/defaultOV.xci @@ -1309,17 +1309,17 @@ location=59 mode=RemoteStick type=key data=0 -event=Exit system +event=Exit restart event=Mode default -label=Quit -location=63 +label=Restart +location=60 mode=RemoteStick type=key data=0 -event=Exit restart +event=Exit system event=Mode default -label=Restart +label=Quit location=61 # OpenVario only: @@ -1378,3 +1378,8 @@ type=key data=M event=Mode AudioMenu +mode=default +type=key +data=X +event=Shutdown shutdown + From 2d5ca7e87548b9f2b18dbd7fee60f03cbae9d937 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 2 Apr 2024 20:52:43 +0200 Subject: [PATCH 311/403] [XCI] cleanup key events --- Data/Input/default.xci | 11 ++++++----- Data/Input/defaultOV.xci | 8 ++------ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Data/Input/default.xci b/Data/Input/default.xci index 7d2a4d0ba6e..9b542a4b5e7 100644 --- a/Data/Input/default.xci +++ b/Data/Input/default.xci @@ -85,7 +85,7 @@ event=Mode default mode=default pan Nav1 Nav2 Display1 Display2 Config1 Config2 Config3 Info1 Info2 Menu Vario1 Vario2 type=key data=X -event=Shutdown shutdown +event=Exit system event=Mode default mode=default pan @@ -1360,10 +1360,11 @@ type=key data=M event=Mode AudioMenu -mode=default -type=key -data=X -event=Exit system +## look line 85 +## mode=default +## type=key +## data=X +## event=Exit system diff --git a/Data/Input/defaultOV.xci b/Data/Input/defaultOV.xci index 2da4570a33d..8bfeea9fd60 100644 --- a/Data/Input/defaultOV.xci +++ b/Data/Input/defaultOV.xci @@ -88,8 +88,7 @@ data=X event=Shutdown shutdown event=Mode default -mode=default pan -type=key +mode=default pantype=key data=ESCAPE event=Page restore @@ -1378,8 +1377,5 @@ type=key data=M event=Mode AudioMenu -mode=default -type=key -data=X -event=Shutdown shutdown +## Shutdown looks line 85 From 59ad97e220b72f93ffc8c0e7aaddc9bcab273b20 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 9 Apr 2024 09:07:37 +0200 Subject: [PATCH 312/403] [build] - OV/XCI -use special defaultOV.xci instead of general default.xci --- build/generate.mk | 8 +++++++- build/gettext.mk | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/build/generate.mk b/build/generate.mk index c1581f2a0f2..99351228833 100644 --- a/build/generate.mk +++ b/build/generate.mk @@ -43,7 +43,13 @@ $(OUT)/include/InputEvents_Char2NE.cpp: $(SRC)/Input/InputQueue.hpp \ XCI_LIST = default XCI_HEADERS = $(patsubst %,$(OUT)/include/InputEvents_%.cpp,$(XCI_LIST)) -$(OUT)/include/InputEvents_default.cpp: $(topdir)/Data/Input/default.xci \ +ifeq ($(TARGET_IS_OPENVARIO),y) + GETTEXT_EVENTS = Data/Input/defaultOV.xci +else + GETTEXT_EVENTS = Data/Input/default.xci +endif + +$(OUT)/include/InputEvents_default.cpp: $(topdir)/$(GETTEXT_EVENTS) \ $(topdir)/tools/xci2cpp.pl \ | $(OUT)/include/dirstamp @$(NQ)echo " GEN $@" diff --git a/build/gettext.mk b/build/gettext.mk index 0cb0b3d9c82..dc6dcee4bd7 100644 --- a/build/gettext.mk +++ b/build/gettext.mk @@ -13,7 +13,12 @@ GETTEXT_SOURCES = $(XCSOAR_SOURCES) \ $(LIBCOMPUTER_SOURCES) \ $(wildcard $(SRC)/Dialogs/Device/Vega/*Parameters.hpp) \ $(SRC)/Weather/Rasp/RaspStore.cpp -GETTEXT_EVENTS = Data/Input/default.xci + +ifeq ($(TARGET_IS_OPENVARIO),y) + GETTEXT_EVENTS = Data/Input/defaultOV.xci +else + GETTEXT_EVENTS = Data/Input/default.xci +endif $(OUT)/po/cpp.pot: $(GETTEXT_SOURCES) | $(OUT)/po/dirstamp @$(NQ)echo " GEN $@" From d757acd523a6913bbbdf5ebdf30daeb939f03157 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 27 Mar 2024 23:54:32 +0100 Subject: [PATCH 313/403] [OV] dlgConfiguration.cpp - coding style: use brackets {} instead a ';' for an empty command --- src/Dialogs/Settings/dlgConfiguration.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/Dialogs/Settings/dlgConfiguration.cpp b/src/Dialogs/Settings/dlgConfiguration.cpp index dde48f6b695..59a7b0552de 100644 --- a/src/Dialogs/Settings/dlgConfiguration.cpp +++ b/src/Dialogs/Settings/dlgConfiguration.cpp @@ -396,23 +396,20 @@ OnSaveClicked(WidgetDialog &dialog) /** * close dialog from menu page. from content, goes to menu page */ -static void -OnCloseClicked(WidgetDialog &dialog) -{ - if (pager->GetCurrentIndex() == 0) +static void OnCloseClicked(WidgetDialog &dialog) { + if (pager->GetCurrentIndex() == 0) { dialog.SetModalResult(mrOK); - else { - - CreateWindowWidget *w = &(CreateWindowWidget&)pager->GetCurrentWidget(); + } else { + CreateWindowWidget *w = &(CreateWindowWidget &)pager->GetCurrentWidget(); bool changed = false; - if (w->Save(changed)) + if (w->Save(changed)) { // if (w.prepared && !w.widget->Save(changed)) - ; - // return ; + // return ; -// return true; + // return true; + } - pager->ClickPage(0); + pager->ClickPage(0); } } From df0cb9de2d46364d2bce8b3572179258b6d835d4 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 2 Apr 2024 12:53:33 +0200 Subject: [PATCH 314/403] ProcessDialog.cpp - std::string has no conversion method to TCHAR --- src/Dialogs/ProcessDialog.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Dialogs/ProcessDialog.cpp b/src/Dialogs/ProcessDialog.cpp index bb5e47c43a2..8b6041c807c 100644 --- a/src/Dialogs/ProcessDialog.cpp +++ b/src/Dialogs/ProcessDialog.cpp @@ -94,8 +94,7 @@ ProcessWidget::Start() printf("%s\n", arg); ss << arg << ' '; } - SetText(ss.str()); - // system(ss.str().c_str()); + system(ss.str().c_str()); #else auto dev_null = OpenReadOnly("/dev/null"); From d049d337e47ef478df4b2d9f2c7785b458d0e5f7 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 2 Apr 2024 17:37:35 +0200 Subject: [PATCH 315/403] [CMake] OV - add definition TARGET_IS_OPENVARIO, like *.mk files --- Data/CMakeLists.txt | 6 +----- build/cmake/WinMSVC.cmake | 7 +++++-- src/Input/CMakeSource.cmake | 9 +++++++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Data/CMakeLists.txt b/Data/CMakeLists.txt index ec09285db79..d3450968d7f 100644 --- a/Data/CMakeLists.txt +++ b/Data/CMakeLists.txt @@ -283,11 +283,7 @@ endif() ${_INCLUDE_OUTPUT}/InputEvents_default.cpp ) -if (1) -set(DEFAULT_XCI ${_DATA_INPUT}/Input/defaultOV.xci) -else() -set(DEFAULT_XCI ${_DATA_INPUT}/Input/default.xci) -endif() + set(DEFAULT_XCI ${_DATA_INPUT}/Input/${DEFAULT_XCI_FILE}) add_custom_command(OUTPUT ${_INCLUDE_OUTPUT}/InputCppFiles.txt COMMENT Create InputEvents_*.cpp! COMMAND ${CMAKE_COMMAND} -E make_directory ${_INCLUDE_OUTPUT} diff --git a/build/cmake/WinMSVC.cmake b/build/cmake/WinMSVC.cmake index 04e6cfbd373..e6e64d5ee47 100644 --- a/build/cmake/WinMSVC.cmake +++ b/build/cmake/WinMSVC.cmake @@ -5,8 +5,11 @@ set(LIB_SUFFIX ".lib") # "a") # ??? add_compile_definitions(PROJECT_OUTPUT_FOLDER=${OUTPUT_FOLDER}) # only in DEBUG-Version--- -#add_definitions(-DIS_OPENVARIO) # add special OpenVario functions -add_compile_definitions(IS_OPENVARIO) # add special OpenVario functions +set(TARGET_IS_OPENVARIO ON) +# add special OpenVario functions +if (TARGET_IS_OPENVARIO) + add_compile_definitions(IS_OPENVARIO) +endif() #------------------------------- add_compile_definitions(__MSVC__) #******************************************************************************** diff --git a/src/Input/CMakeSource.cmake b/src/Input/CMakeSource.cmake index 1938f938d1a..601d3c1f035 100644 --- a/src/Input/CMakeSource.cmake +++ b/src/Input/CMakeSource.cmake @@ -20,8 +20,13 @@ set(_SOURCES Input/TaskEventObserver.cpp ) +if (TARGET_IS_OPENVARIO) + set(DEFAULT_XCI_FILE defaultOV.xci) +else() + set(DEFAULT_XCI_FILE default.xci) +endif() + set(SCRIPT_FILES - ../../Data/Input/default.xci - ../../Data/Input/defaultOV.xci + ../../Data/Input/${DEFAULT_XCI_FILE} CMakeSource.cmake ) From 22ad39d362dbf246a5def7743d1b46f6d70fe97a Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 2 Apr 2024 20:57:50 +0200 Subject: [PATCH 316/403] [OV] CMake - use defaultOV.xci file --- Data/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Data/CMakeLists.txt b/Data/CMakeLists.txt index d3450968d7f..41a6217b0e8 100644 --- a/Data/CMakeLists.txt +++ b/Data/CMakeLists.txt @@ -283,7 +283,8 @@ endif() ${_INCLUDE_OUTPUT}/InputEvents_default.cpp ) - set(DEFAULT_XCI ${_DATA_INPUT}/Input/${DEFAULT_XCI_FILE}) + set(DEFAULT_XCI ${_DATA_INPUT}/Input/defaultOV.xci) + # set(DEFAULT_XCI ${_DATA_INPUT}/Input/${DEFAULT_XCI_FILE}) add_custom_command(OUTPUT ${_INCLUDE_OUTPUT}/InputCppFiles.txt COMMENT Create InputEvents_*.cpp! COMMAND ${CMAKE_COMMAND} -E make_directory ${_INCLUDE_OUTPUT} From c8e8004ab062e9c59af320ae7781060a1628ade2 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sat, 13 Apr 2024 10:20:55 +0200 Subject: [PATCH 317/403] [Vol] - defaultOV.xci use ExpandMacros for better display of Volume state --- Data/Input/defaultOV.xci | 12 ++++++------ src/Menu/ExpandMacros.cpp | 13 +++++++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Data/Input/defaultOV.xci b/Data/Input/defaultOV.xci index 8bfeea9fd60..6008905cf22 100644 --- a/Data/Input/defaultOV.xci +++ b/Data/Input/defaultOV.xci @@ -1284,7 +1284,7 @@ data=0 event=QuickMenu 57 event=Mode default event=Sounds quieter -label=Vario Audio Quieter +label=Vario Audio Quieter$(CheckAudioQuiet) location=57 mode=RemoteStick @@ -1293,7 +1293,7 @@ data=0 event=QuickMenu 58 event=Mode default event=Sounds toggle -label=Vario Audio On/Off +label=Vario Audio\n$(AudioOnOff) location=58 mode=RemoteStick @@ -1302,7 +1302,7 @@ data=0 event=QuickMenu 59 event=Mode default event=Sounds louder -label=Vario Audio Louder +label=Vario Audio Louder$(CheckAudioLoud) location=59 mode=RemoteStick @@ -1348,21 +1348,21 @@ mode=AudioMenu type=key data=DOWN event=Sounds quieter -label=VOLUME- (DOWN) +label=VOLUME- (DOWN)$(CheckAudioQuiet) location=1 mode=AudioMenu type=key data=RETURN event=Sounds toggle -label=VOLUME ON/OFF (ENTER) +label=VOLUME $(AudioOnOff)\n(ENTER) location=2 mode=AudioMenu type=key data=UP event=Sounds louder -label=VOLUME+ (UP) +label=VOLUME+ (UP)$(CheckAudioLoud) location=3 mode=AudioMenu diff --git a/src/Menu/ExpandMacros.cpp b/src/Menu/ExpandMacros.cpp index ffbc0e2e833..f65d504dce7 100644 --- a/src/Menu/ExpandMacros.cpp +++ b/src/Menu/ExpandMacros.cpp @@ -260,6 +260,8 @@ LookupMacro(tstring_view name, bool &invalid) noexcept if (value != nullptr) return value; + auto vario_sound = CommonInterface::SetUISettings().sound.vario; + if (name ==_T("CheckFLARM")) { invalid |= !Basic().flarm.status.available; return nullptr; @@ -291,6 +293,17 @@ LookupMacro(tstring_view name, bool &invalid) noexcept } else if (name == _T("CheckTerrain")) { invalid |= !Calculated().terrain_valid; return nullptr; + } else if (name == _T("AudioOnOff")) { + StaticString<10> s; + s.Format(_T("(%u/7)"), + vario_sound.volume > 0 ? 1 + (unsigned)log2(vario_sound.volume) : 0); + return vario_sound.enabled ? s.c_str() : _T("-"); + } else if (name == _T("CheckAudioQuiet")) { + invalid |= !vario_sound.enabled || vario_sound.volume <= 1; + return nullptr; + } else if (name == _T("CheckAudioLoud")) { + invalid |= !vario_sound.enabled || vario_sound.volume >= 100; + return nullptr; } else if (name == _T("LoggerActive")) { return backend_components->igc_logger != nullptr && backend_components->igc_logger->IsLoggerActive() From 76938abb8eb2905d82ad99b8d4e4a4cbc957763b Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 2 Apr 2024 20:55:01 +0200 Subject: [PATCH 318/403] [Events] Input/InputEvents.cpp - if lua event handled don't call the xci event! --- src/Input/InputEvents.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Input/InputEvents.cpp b/src/Input/InputEvents.cpp index 060e19f72be..9d22a3bd1f8 100644 --- a/src/Input/InputEvents.cpp +++ b/src/Input/InputEvents.cpp @@ -332,7 +332,7 @@ InputEvents::ProcessKey(Mode mode, unsigned key_code) noexcept #endif if (Lua::FireKey(key_code)) { - // return true; + return true; } // Which key - can be defined locally or at default (fall back to default) From 73f8413e087fa368ccc0666663092e394cea6388 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 2 Apr 2024 21:04:05 +0200 Subject: [PATCH 319/403] [Events] InputEventsActions.cpp - remove dependency from UI::TopWindow::GetExitValue() and make the 'force' option dependence from option parameter --- src/Input/InputEventsActions.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Input/InputEventsActions.cpp b/src/Input/InputEventsActions.cpp index 55df874323a..e11892cf7a9 100644 --- a/src/Input/InputEventsActions.cpp +++ b/src/Input/InputEventsActions.cpp @@ -626,15 +626,18 @@ InputEvents::eventBrightness([[maybe_unused]] const TCHAR *misc) void InputEvents::eventExit([[maybe_unused]] const TCHAR *misc) { - if (UI::TopWindow::GetExitValue() == 0) { + bool force = false; if (StringIsEqual(misc, _T("system"))) { // return value on UNIX(32) is only a Byte? UI::TopWindow::SetExitValue(EXIT_SYSTEM); // 20000); + } else if (StringIsEqual(misc, _T("force"))) { + // return value on UNIX(32) is only a Byte? + UI::TopWindow::SetExitValue(EXIT_SYSTEM); // 20000); + force = true; } else if (StringIsEqual(misc, _T("restart"))) { UI::TopWindow::SetExitValue(EXIT_RESTART); } - } - UIActions::SignalShutdown(false); + UIActions::SignalShutdown(force); } #if 1 // def IS_OPENVARIO @@ -642,13 +645,11 @@ InputEvents::eventExit([[maybe_unused]] const TCHAR *misc) void InputEvents::eventShutdown([[maybe_unused]] const TCHAR *misc) { - if (UI::TopWindow::GetExitValue() == 0) { if (StringIsEqual(misc, _T("reboot"))) { UI::TopWindow::SetExitValue(EXIT_REBOOT); // 20001); } else if (StringIsEqual(misc, _T("shutdown"))) { UI::TopWindow::SetExitValue(EXIT_SHUTDOWN); // 20002); } - } UIActions::SignalShutdown(false); } From 1f73f27ed9acad4616067dff578762c29a1c5000 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 1 Apr 2024 14:28:28 +0200 Subject: [PATCH 320/403] [Config] OpenSoar.config - increase version number to 7.42.21.3 (pre release) --- OpenSoar.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSoar.config b/OpenSoar.config index 3c23358c1ef..a379ae2d6a0 100644 --- a/OpenSoar.config +++ b/OpenSoar.config @@ -1,4 +1,4 @@ PROGRAM_NAME=OpenSoar -PROGRAM_VERSION=7.42.21.2 +PROGRAM_VERSION=7.42.21.3 ANDROID_VERSIONCODE=21 ANDROID_PACKAGE=de.opensoar From c53ce99c62ed02b0895ac63bea5276e7516dc308 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 1 Apr 2024 12:38:36 +0200 Subject: [PATCH 321/403] [Android] CMake - add Android (with EXCLUDE_FROM_ALL build) --- CMakeLists.txt | 2 + src/Android/CMakeLists.txt | 8 ++-- src/Android/CMakeSource.cmake | 90 +++++++++++++++++------------------ 3 files changed, 52 insertions(+), 48 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ef2549034c6..669d58cefa8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -360,6 +360,8 @@ add_subdirectory(src) # libOpenSoar! add_subdirectory(src/OpenVario) # libOpenSoar! +add_subdirectory(src/Android) # Android -> EXCLUDE_FROM_ALL TRUE + list(APPEND SOURCE_FILES "src/OpenSoar.cpp") # list(APPEND SOURCE_FILES "src/Version.cpp") ## configure_file( diff --git a/src/Android/CMakeLists.txt b/src/Android/CMakeLists.txt index 72731d5fda4..ec1682560d9 100644 --- a/src/Android/CMakeLists.txt +++ b/src/Android/CMakeLists.txt @@ -7,7 +7,6 @@ endif() # project(${TARGET_NAME} CXX) # Your project name -include(CMakeSource.cmake) # organize the files in subdirectories include(CMakeSource.cmake) set(SOURCE_FILES ) @@ -57,6 +56,9 @@ add_library(${TARGET_NAME} ${XCSOAR_LIB_TYPE} target_link_libraries(${TARGET_NAME} PUBLIC io Engine) # message(FATAL_ERROR "Stop!") -set_target_properties(${TARGET_NAME} PROPERTIES FOLDER Libs) +set_target_properties(${TARGET_NAME} PROPERTIES + FOLDER _Main + EXCLUDE_FROM_ALL TRUE +) -add_dependencies(${TARGET_NAME} util) +# add_dependencies(${TARGET_NAME} _Main) diff --git a/src/Android/CMakeSource.cmake b/src/Android/CMakeSource.cmake index e691ac5c632..27432100969 100644 --- a/src/Android/CMakeSource.cmake +++ b/src/Android/CMakeSource.cmake @@ -1,50 +1,50 @@ set(_SOURCES -XCSOAR_SOURCES += \ - java/Global.cxx \ - java/Object.cxx \ - java/String.cxx \ - java/Exception.cxx \ - java/File.cxx \ - java/Path.cxx \ - java/InputStream.cxx \ - java/URL.cxx \ - java/Closeable.cxx \ - Device/AndroidSensors.cpp \ - Device/Port/AndroidPort.cpp \ - Device/Port/AndroidBluetoothPort.cpp \ - Device/Port/AndroidIOIOUartPort.cpp \ - Device/Port/AndroidUsbSerialPort.cpp \ - Android/NativeView.cpp \ - Android/Environment.cpp \ - Android/Bitmap.cpp \ - Android/Product.cpp \ - Android/InternalSensors.cpp \ - Android/SoundUtil.cpp \ - Android/TextUtil.cpp \ - Android/EventBridge.cpp \ - Android/NativePortListener.cpp \ - Android/NativeInputListener.cpp \ - Android/PortBridge.cpp \ - Android/Sensor.cpp \ - Android/BluetoothHelper.cpp \ - Android/NativeDetectDeviceListener.cpp \ - Android/NativeSensorListener.cpp \ - Android/Battery.cpp \ - Android/GliderLink.cpp \ - Android/DownloadManager.cpp \ - Android/Vibrator.cpp \ - Android/Context.cpp \ - Android/BMP085Device.cpp \ - Android/I2CbaroDevice.cpp \ - Android/NunchuckDevice.cpp \ - Android/VoltageDevice.cpp \ - Android/IOIOHelper.cpp \ - Android/UsbSerialHelper.cpp \ - Android/TextEntryDialog.cpp \ - Android/FileProvider.cpp \ - Android/Main.cpp - + ${SRC}/java/Global.cxx + ${SRC}/java/Object.cxx + ${SRC}/java/String.cxx + ${SRC}/java/Exception.cxx + ${SRC}/java/File.cxx + ${SRC}/java/Path.cxx + ${SRC}/java/InputStream.cxx + ${SRC}/java/URL.cxx + ${SRC}/java/Closeable.cxx + + ${SRC}/Device/AndroidSensors.cpp + ${SRC}/Device/Port/AndroidPort.cpp + ${SRC}/Device/Port/AndroidBluetoothPort.cpp + ${SRC}/Device/Port/AndroidIOIOUartPort.cpp + ${SRC}/Device/Port/AndroidUsbSerialPort.cpp + + NativeView.cpp + Environment.cpp + Bitmap.cpp + Product.cpp + InternalSensors.cpp + SoundUtil.cpp + TextUtil.cpp + EventBridge.cpp + NativePortListener.cpp + NativeInputListener.cpp + PortBridge.cpp + Sensor.cpp + BluetoothHelper.cpp + NativeDetectDeviceListener.cpp + NativeSensorListener.cpp + Battery.cpp + GliderLink.cpp + DownloadManager.cpp + Vibrator.cpp + Context.cpp + BMP085Device.cpp + I2CbaroDevice.cpp + NunchuckDevice.cpp + VoltageDevice.cpp + IOIOHelper.cpp + UsbSerialHelper.cpp + TextEntryDialog.cpp + FileProvider.cpp + Main.cpp ) set(SCRIPT_FILES From cb3ced3df2b00a52bb5828dee15c9e2e0ceb850b Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 1 Apr 2024 12:39:33 +0200 Subject: [PATCH 322/403] [Android] Main.cpp - do the Shutdown before rerun --- src/Android/Main.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Android/Main.cpp b/src/Android/Main.cpp index 127209e3f56..f4aa82ee1ce 100644 --- a/src/Android/Main.cpp +++ b/src/Android/Main.cpp @@ -213,7 +213,7 @@ try { bool rerun = false; do { - rerun = false; + // rerun = false; UI::TopWindow::SetExitValue(0); #endif const std::scoped_lock shutdown_lock{shutdown_mutex}; @@ -326,17 +326,18 @@ try { CommonInterface::main_window->RunEventLoop(); } + Shutdown(); #ifdef ANDROID_RERUN unsigned ret = UI::TopWindow::GetExitValue(); rerun = (ret == EXIT_RESTART); - if (rerun) { - env->DeleteGlobalRef(permission_manager); - DeinitialiseDataPath(); - } + // if (rerun) { + // env->DeleteGlobalRef(permission_manager); + // DeinitialiseDataPath(); + // } } while (rerun); #endif - Shutdown(); +// Shutdown(); } catch (...) { /* if an error occurs, rethrow the C++ exception as Java exception, to be displayed by the Java glue code */ From 861484da25969a1f04e962ce4a5fa53aaa71a0dd Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 3 Apr 2024 22:48:35 +0200 Subject: [PATCH 323/403] [Resource] - switch to OpenSoar.ico --- Data/bitmaps/xcsoarswift.ico | Bin 22230 -> 0 bytes Data/resources.txt | 3 ++- 2 files changed, 2 insertions(+), 1 deletion(-) delete mode 100644 Data/bitmaps/xcsoarswift.ico diff --git a/Data/bitmaps/xcsoarswift.ico b/Data/bitmaps/xcsoarswift.ico deleted file mode 100644 index a48ff01227b1be120a432f64ff2864a70e6978a3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 22230 zcmc(H1wdBW)AyjRuDk1&-PoPjf?!Ze8c3tkAl=>F-Q5q}pp-$Vh^W|I>)M^G&Nt^G zEXMA>??2w}=wpZhJq zvcUig7k<3|5#aJKJ@5G;m&);`wB7INej331MF2BdnFM;p)k6`8@Uh=d!}xLIz(`*g zygb}NLSQBoJ8OZ&(%DcMVh3xM3qXL{TF5lp3=1cXf@EVkNHN(0dA7>HvsZ_3!!2N~ zupTmO)S%Qu4+=dDpuoozc>dO4s3ZfST4G=#y$memR>EfC#ZVSt20Tw)aM6;398Uuf zoj(o=?d71%O$ibmc0y^m9n>cIP(C3jwwHpXb0$Mkuo-MvF%QnvWx~En9>nOa09VBY z;IM5z7)#9piN)g~%US}G9hD%=b_WPAodZP?wy<{jJje{Rgx35J5STj+_T`2^dwD!G z=0$*qr8Z=SyMp>QDTwiR0)w535aMYEK^}H+v+E%EyV*iwxGzkaI3Dg?JO)nICeTp9 zgQvGILTy<-)K!&$hN=>nnVNu~>O4>v;Rk>9g^*_@1oqqJftJ`bP!*XB+XeZd$ZjpT zDK7*I`8i;?X(nijPJ^IbOTkw|01P(H1f?~TL2dmE(34*Ybtx{86=)9IHwr>sx(^gY zIzU6F9~8y9K}TggbW|n6nTAZ*vQY%~7sbN41Nm^eDG%!MqTuwtd}ysm1#f#JXedgA zEA2IK@o*JfJ5~p7HoM_g*M7Khq6w~bHb7jkJKQ|g41N~MuwW)XRHpe;Sv+ViPlk*r zFW6U>3c;SXaPv$XINO@R!<%Qp%gz8CEc8KO;aqUDHv>BhLl9lJ25w%v1Z!3wvq5Clr^If`yeWq@-oS22pV^F*OHYUw_c1_wU}lho?`U z0aBh1A3nhQ_wVW1JNV;|Kj8K2*YN7qD|qqZ1r!z*LR?%NL_|bDSXdaiySsyvlM~q3 z*np|2DeT_88w?B#Kwn=U^z`&VM@I*=w6tKyjvb((p#cgC3LqpT1WT4IfklfJ!TkC2 zVfO6VFm>uwm@;JwOrAU$#*7&QqeqX1QKLq2izJ-|m2L97c5de`=|@dnU2d_}=6M`GXDsNHTBsOu!{H?0=K)m_j!5J>;i3gznT%`r+>5IlR?b{!p6}@EIsAVf%(5smlgFF6E!C3QlbZ>}D=XHmTA@b-N^kTsFbtOx@f0*%%{9Qjg@x`ma+mb; zXB)XEecMP6K5b)5%cpH@`ER$e<%?7XAt2X{OVJr{AS>Ciz(?AtJ3$S_ZT$h%cTQt+$+5m$4LU zBZW+B@y)`EXt7YBv}!4A-YAl6Bul%Bh1?3-pJ=Y@2dIXuE63@as-bzjc+x4HbD! zWvNFi<7oFFCS6mSAMNjy9_iVT8$nOn%i?npt&~Av+IXn&x1e{M z!GDJs7wB3OO!Xkm0xs^4xTwz%eBqQYu@T%2a?TYgNeiHwFvUjZhF| zL2^P6q!^2k>>&=B=Aw{fA_|#SlF%4w3^{(r5a*-~&iV?F;9&$6@g7i-7Je+u=l80}LNF6z0vD1wQUh;B0RVzMih2wNo7)-nj_^ix+{DgB@6yn?XZ; z9VF{71Rs@okYT(WvdmV2@)~|>_Zrx?dLm?72!W%*e9)Dc4q7B*#Tl%G2%Y8NM{<@k z$%|&Pvmw_?7}Cvzz)Nj0u;fwkgt*eNj| zN<6ngl(`h_PqKu@3{N;*5D0~l_K+QH1(k{JP@dolC9%#>8084O2z%I<699WNd|`iH z2sC5|LS?cSG#5rdd6G9At%!$X)yYs8?*%9JrbAalHl&0&LuE!NC%>ILSOl$=X>jpS z1)Og!gZ4c+aOp@5C$l+P8p6G+U9eSB5CWZcgQl7Sydjxu^2D()fA%ym($xULl}o`u zXD3`bbp-C+I0q)X^Q^hP#cy z$=Q{Y!I=E@=FJ;;`SK+^d-e<-KYk4N@85^(*RR9r)2HF+(W8)?n+w6g!QkQH0rvLx zU}9pz$zXKa3wgo|D-| zjvNWYh7E%uLxwR{o|ptKfCLB@m?Lm%yt}KD<=8eyuymy4<9~z{-Cq-WYag>YDhkR z@#1OYyxB_x+D1&K(V8$}FyDhm&-l8Ica@J{MN{b6)2EvzESoTU82^~j6My;T*MS3d z9`HSUbnf`c>fw!#A3b{Xc+EF*of1LgUh3~&zb^pP`2iBb@P8HsLz<18VaIi}ZsyLJ6)KZzM}N-H;rY8A%C$H%W0YrS*#?yZxZokc5aZ{GOr&b=dh z;#I_x#gyB$)Jaf?lWPC{_uu=$@so$d6t%Bky>a{Qz1G^D2}*5kC0dyYD%!VMI0na0 zb(p0n?y|ak`TFhlb~CA}wzl#eT4~z1e!F$^=8cO0C;HuKN{La|G_ksT?dGjpO*DWd zc~$iC`t>XQj&%WCyxnf5otT;~v2&N^u6Q>7##gRizk2y{KPwZ>a{x!L-MD%4fObKl zMnYm@61~1~^zh+}mo8oEXRMxS2ynh%KdZ}Eu2m(ar)Frd>}_r5&-cG@Q9mzDO{HYk zacdJx6Jz57^^Dk(tnSzJYgnF>m64I2mAdcbzD$X1wKR>4tlZq**KKVTW%;=|Bm?D~ zGM7wC%Sg}3<>mKz-PWd8Sy7zN%gxd4)QzQg`Nc(_yrvsHy^4y`;-c#6;^MN>($C*= z_e|`mG^niX`w}1j#0l{q09@Vy2)_oHcopC$SAaoH0R0*0ny&}&51}U=i<|z;Kj{ysFeL6fRUhD4WMmiP+l0ml9 zo~8&nB%g%olD@>2bS&N`(3BDg=j#h0TxBIhYm1R?W((;T)&c_q{u@b%1G~V zEI$g4?=6BfQyD62Go+cxL##o!jN-2;0R@gKkW2E(n`e(8N?QcdO(elVVKpQgZGvL= zU65w00{({EAlqFRo*XHG)WkT5RhvgLi!|grY=y?~-4JH20Vk?b;Xr*2Sc{H?fNj&E z%yt80S%^Zy?)6aX!E{B^5M!+bsV+Mq%Ud6Kfu@j6a!FZ~13W%a1G_c0KtoOh9IDKK z&X#&;YpjOyf^2wl_a?-sOaPwA638$V;PgE)`m5knmNlF!bOoNTHZ-NWK&-Pi9LV&7 zb2V}B;&>5UZA^vVnzLzd_Mp8u2x>^Tai}B~y6UsxR!24b-qi%B50pYdN;m}hdBMB4 zui?$B7vSsT4HwRzgA>O)p{=zAf@Ob%6s_rytv?I0OqWBQs|d-5E1}Xs7&1&(L$vNP z2-+zC=CZR$)>r|0BzI(y3=*!r4Dzf=p0iv-eJ=<}MytV7wOiiEw-+P*+9qfVR|J#I zOW;VNK3uK}fRYFccy=@sY7?E|SV=JC23x@8`ZzdJ7zE{UPLLmN3wzVN;UF&<+KMAc z#)^jetUzcXxuT;g0nYEsh7)_zNGB8rEoDh0OYq>_!9uvuS_*qe{<=hZpeslBz|~{* zaGT_=Q%9QM{X-fh7Fu<=Ml*Rw}1Z~{&@cZ+h&AJ$ zhw&39fvBW37@6C^2JwxcscQ%^Ng0q=Pz=#AvGD!_5}hAFWtRagSiB7Mjm%+-f-;y} zJHQT2UEurXd&tV+fxVMEgoQ^!NohG%H;`nFRj_H36sLdE(AdGrJhb~kV`C!(1qFef zogJ8)n}adwvgmBa>5+Er+67F0QC3#wbV*ybYyk-g30S^-IS2>{a5^O>ugse_kJBsB zW&@KZO@av%CU80>CZqiF%P*XaGI;P{;QKOAmFBMIODtV2zkK(_6DcVv2Nsr??Qk$R zxBUAo4wTl++FDv#+DuYAMbFIa@3TmmnOR%d+gVvT8c8OCyrh-Ag{gzoU)5o4ZORhc z(y7!@(ho8g7&<#SIht6Q5m{f5&BrHcYUt?X=xAe0LDCr@b)Jc>qm#3Knu{F|9g&W&<%gD;O7;kcPcC<5-`n-npojZ5LZ*@1`w19|^l!u}lV(B{v zrteVkm9cSjwlVFSf#j-lMBwG-)}0#e8<(%#q%Q$*qmI#hpzeBwnv7xJ3`|?V{=ff_ z$H%v~W9>>wmt^AKCGYu26#I}#&pQ2_SqAg&M(4k3zKn1Czst(XdY8q=*AVBqb04MG z$@`G??hkrU*VR@MVe4#TA?4bgfiK{E>*cpE-}EQ(n{qT(9n_}uxA=%dWnx=;l()Ro zs!awP^_PCEfX_uXwxjOD^8s(){?Y%B{&{>?DLI_yd()qRGu`}38t^qqX~&o!yL>FK#`jZeRQ>g36`+dJb$SO!~@71B#q zrnY^^fBE_iNsD~vyVHN@*k+*TqBi$r-2qCqe?K4JxxEMJ%4xZs-HN3fQ%}Bs`f9-I z0dMdYORvRO;VG%_eyjcf-#gOh4(QLO__ zdLOQ}Zj;pCetu8C0rcqAE39i05Brf{n$j6-;NzScF>rq8(Q;8gvq)_^xuRZ<;(J(=99?#{6p=W zdDDOWb?k(1se&Q=GrnbE!k{rfFRp!6c;!vr+Y;7*RIx^+8S=;5w{>Deei{5LOEhTW z&>vv;hV=VF5_`?p(hWEZ)!bn*f8bSnSw0Q z=3%oGMTU&%R`JbV5!3W?!2RrR{!Ct?tw}f9lSgk@KawRHzKGHX2+bB25*{Hmdx%)g zlY(b2uXIc2CF;6IAMqaDz5Uy7=QC8+|2RZgNJwzeEM?^YA7L)64!_j(xS*im?Qb-F zAY;vRu>#)1!Yj{SygGDIO>nb+fRB&RqD6eliax?V^j}yot(NzgGF;Img9t$2#BkmA zNB1Anlftf!WIsWl9Uj7)`S{|M{e66V0s;hMvadX(6H37oT8=m2QnuHuILdJC`a^p3 z@{DehijR;GrH=|#3 z6@~X7@=o1Ki;$P|@Y@=z5u*_q#<2%JKJiPZ3Loa&%gMQW_s-pd&g>30(=J`TcK`m> z_NGf>DY4N}UTfB@3FuCK`^c&5Id|^d`JMfHaJnK{O{bL7-+FY1PEt9KuO2H$U8IedIt>A(G^HSjjc8FwFCuhLNul-ok=8FU`qVUMmC)KuS6^$Jx|QVQadv!9NR z&gy}`pDF9OrTvqKqVk#zH2+i2oH}*tNNsh6Zd%Zq(4a7t;NIlyLR&XQG$AR{%PW+E zS25&%lOiS{Af}t5Hp;_aX}yYy$|uSB_>$Ek{Nw{el}HmC?4=4t-$ZYTj0_L*5>ZwP z3keSo|13ElUz~<&csL#PgF}Kt=mOpK~(q+c2& zhQz4G#KgwN{$+CZA}KL3fzGwD;Sv&&ad8Q8f19}br8?!IOzH^(!|xQPy1EOsRkk;OFj%t%OQEq2<%t1K4gUUL~;**#^v+Bar)9d=IzaWNIt z6T8x5R`BOBd)#gN`On0zteCIV)AaE<7x&P|>`Lr8(apu|D9i49;)z`MaP98thn{}v z?Wd-X{npcuuRr!{Pd{^7_-?xuKNT%P-~)C=`t+Z<=zsgeM;QhZekDvMEFsX+13AKW zg7QZwP%J}OOIS#lK=_HkHU?J4zY_XWCPwx2F+&H-teG=1SZ3MyCWY0LE-MR9eyAio z<%PoPiO-cb%)7s7$+(L`vqv<|9QRYqpaK0z^8s54s|k|`KM+`1|I^UZ=Fzjq|17gj zkiX18a>gT@&GXQC`vUY*U5tJjOVC?s4yJkQV|IiK+RD#D6Y1HwYr`~@SvKMBk|{$g zz8^Tif+}Qm2oQ!71`z%(^rM%92&~Ohl!PXQS+Zn|O!a4$@p>IF1y4l=XNaq&|I)~*N>{7hw zY@~#7?gm&9W`woA+mUA}h*{=>T>Yu~3$eX8jJO5jog0@h#m59=Jxwsx&kV~WEO2kg zE-bKFi!nM&(Or2FYKu)r;kl!lsSZ7Y5MdaB^)(BFl9G~klB(&%tXZ>g=+L1^=QxUo z;mFZraQckdsIyZAizDr@+EWg*jF(_-kUGA6e2=T2I4cexF$#wb8_vc2lcwM%NpTE! zGsY6H?U+b?!RCt&jmOFvBWkI>U4%sh*5AzkK`SFO^MSayBu<_@1?e2gfs~-w7n7$> zNAmr^nmAi5EzINUW|8#c|`teSz`gC*ZvK3otD`qqlz2^Y^Bk zOYfX4^syw&9P2}N;9h@4tP4`ZT7PBCcioDR4N>^ODB8042=v-;ItYJ5gzi zG>VI^L-7r3QA&Ir%4}GLQetb{$Y$+I^@j*Zl_Tx&_pG+mFS4&qpo=z@Ym zLO6Z;^iM$fkfg=l`UM4rP*!>qHpLoam5U_i1)HP1tTgr0!cX$Ca;8q5feRN4py>Lw z=;GpXk(qi~{c*;dOi1U3WCNr%wu#o)Ml7+DLSCd3E*4mdq;c;B*-?-VA6)%(Fhw(S z3oHxPqq=1=+{2vuZDnuTo_vd_PEB=1%nmfiBA*=?qQCBg;G!v^V@8ZvPu25f*(;Y8 zI4WbVl{~F4ISyH-(pVp;hI*PBNP3T6u=?-bz01|ltm~%_mSUlmG^Y4la&`Aj%dXe0 z-+&pxG%i$DzNHK%8Azh1${LhhG`WK6mUP*+ZD78O_W1%w4a~7ppt`s9f@iq}d12PL zYPBGe-KZC&5AN;%-@5i;nV%MtzNhznPuexYBFGE1#!`C)8rRKSxhW>{=&iN^m4xTh z;Q-{LEmTL8dYe8fbk@QgYZanFxfj_M+i_2%Davo&jH_3#=0HahOifMgt^dQjH`q{` zg;G+|C@3h1BoHI%jga(5=;z^#Z7G&miIv&!0!)8NK!QT#$tZPnz65)$^fy7ClO~m`ftj}I7-p~)jb(-JeABO=VsVHKe^r$0i(-Fs%yHGh z92f0gWI6A`J;Bzfqoa)^-}Y4Xk1>gbC@Lz7!LF8=MeQ%f#+p(*nj46fp?1jgF~)391I+T!$0!>OG*gne#^zsRqsxG* zw7|3F2_BdiWI=qxq!(m|$K2Qe+`3Hx<>cfzuyH+p{CIEucQ3YMYgQ)5%hKbpKH3q1%{h4w`7FC{FqcZcm0ixe@s_nZZ~P<$$>%mK<_| z%&{TS1ARQ*k@46bkgpp)c<_L$pA=kpyr~FzK_-|H8;B~Z>b>cD(rapJVMbgC)>Byp zp_Z6IbcEXN!mXmqN!`$0e|>(uc2i*-RwjF65z$Z(VT)xk4p^8Gi#vAiLeh!$g6zOZ zzI$B#FJHbwKYxELPY=b)I7iG*ibP#KgWj|~`P69qe7ro6mlA=ciM|-=YWQAc`QqS- z6DLX%4SeOPL1UZCQy(|vg=2ZV3)UpLVQoPQnp;@X*lTF@PY-O$ zkHtO7ZdjQUgMt3OsHboENj_E%8LZI6%mO_<+>yuQogy%~h{;30=Er#^9w>;w=Hgha z$WKFS8(SoQo-bfzWQ0$iJmK2U<{@cCxir4MzSvNlhWm2@kbDEMmKTTF$Jrw^zr&3+#f9f^iU#z^wW7hr95b#upK z$2xoGAMGK%>8z}6F(V}b8%xu%r6dlU3nQ_mI0g?EP+Sy+2lK;de4THS)``iZJ@Ut{ z`uc`PVc`+z>gtMQ>qpkdY@AtJ$#IE;y@L~$7i8k$+8jK0x~sQ-I>q*;=}Bv3VvYep z!Pva74v$o&Vq>O1lC1{oGyOj7){r-*y8FssK>O)BTGxB4s;d4-OH0GBh)DGG@CLMpe0&b*`N#cPkdY~)|cnvp|W^9 z$P2+%YCA)WmstYU{ki-}kGcct02h!3L;rl&vHhox9>kNab=bAP6i?Kq;-R82Y%L7O zwxS4Z$q&WbSI%-YT))tT&DD8$pr!y@_Y~r>hC)2CHv^B9MB<_1NIX)WfJZBnupq{r zN45Nw{M|zW7q_(V246Z_mv*^*51!dyh{yM2;L)l?Y%h<)BV{pon94m_pMxLXzrzQ= zUBUK}2<#}2!J}o-T)iw!M|CpgOUL7TGd>i?dq-2j|C95_Cv;ruXw<*b(Rk-ldo7-8 zF2PfcIn=gv?5s(_qg3CG(`_6LC--LJF{1A{^%HA*7o{WbGCaCB>q{Cnkh&LK)e)=HITjmw^A$1*r{~eS0FQ5q`Q#{K)lBx_fD-XV3$> z{LA1%GZ*jaM| zVGdzAf$`xD1g26KBdjN|GvX4$OaeO-Gd%{=fv__EF9Yj8Hh<}>5ExHbFnZ`<*=5s) z+len8n!1m zqT$9_@3#w1IxjF~XbP39LtuI`HtiWtX5-81{7(ed=WMRdX1XK#hUT8Png9muSb||h zYm^@8W(-$xI;2z+Ax@7({*suiFMyr3Y23MjN9Xhe{bd+uu!`EYoXg8}C`^~b^jpe8 zldsGs9UIlb=GHm_KY^{Qf42<-sEna&<_zC#yJhYPf1;V`yrOiwX-+XAy%*8iqlfCz zMWq=EU~{G$$4egGJdfm~K_ER8>8rT5k-m(zg_Y&0vY2a!k<_dYQcK4*e>F(rTNe6Ze8Eat^*wH z?58cm8H?@KVvYA^tRh`miK7_iS**rP<7Jp>MlrR6=`Y!svUzE}c`j;+&v-n2%#UG2 z1Jfh3Hn9HutGUGbo9RYpkRE2Ug@r}5r>AE#xdL2swlzn0CmRe8aL0n=P&`1gZcB;{ zmN`pe2G!5{^iSG_F@5(E+?Qz6OZ&Tbe_(B48YV{gQ5l{X73_oA33P7aMd4wdAL+By zG23h3k?16BAQKz9-MfmxR+d z{`~XLoX+vrUw`H9hYlZslc!8WWmPrgrN!dWf&eUb6s5XXkPbnFbgU~ehjgL$ub%3q z|H6d}q&FPZou71=OpnPhdh9q{B_x90bdGE-PsXMQIuBBRkna-53j%g7<=UVtG2`** zUj};+jf^+3{gLsd-a!5+-;rOiBb^bRGTk6qj!EY^j03x77%^hRS0S-U2KN-v*(h2M z)ASc$ZGb9XI<~Kuc6QOw(D2o~eaoD{KM9>29q?d|KjvAlCI0oX4cs`)L-lo2uMQm0 z&xD8;A+Y(~yB5eJ!hpOYZ~6QCzt+~#MIq7+(YIkpAHyJhBJ+=!NOgw=`r@VinHb>h ziupyQpU|I@lJd7@OrJ3eB_ubYiScgiIMj??HHn-)o3(+>C0}&`w345To0g7mBD!}F z<`H`55mh$u%9ShM-n(~i%&lA3M32-J9LY_MLs|K)NPg12I@qu2ZTmix*eK2EnJ-?v z_zC^Aj=oyPI#F>&n@gR$C69@9w=pJlXyyFQp;iU%`2v5C&4dr0q6n-Pdrr2F8J?l#I^z(EkedHEgzG4+Jef!MWb2!YMw*Z$c zU5;X6;-u?UMsrh>PDx2g##grymi7>@xo+;rOiPL1^K2wY-z!QyaRX+Vt;0O?b$GHW z26t)cAo<|`EtsC*^B^lL%jMawq=H?wNyxKWk7))%xIao4YxCkzOyh=r z1pXePXg6kMO+F)7=#pEL{ATW%bk}uyh%#+T|e248sKeH9ce1S}pO*G~@=;!T$3l=Q+D(Jh7 zFZ%z+)yr5Npic8$3=d^EkRDP0t9kpDDI+U~jm61$faX|^=_cA2H(`dEH0^5=7`SsS z*+3T_BeL1t8OP`kF_2kaN-$8}eF0(T*o4}XIHkHA)(l}hZZava>DqlcTQ}YY@ zpZ%1DPHuMf~S$`Ffsh+$4=hNTDPw$zbY`!G99P4r5-%ex zaM8hBJF-_Xo6cXLh-^2d>EXz1Q1r1Yhjr`LA=$S%JI2kMH@~2tJ-B}T8s_KcbM^%C z@gdub4tGuNL0DW|jC=Oh;k_Fd@Z5eL9xVyS#yD#%aU+`z>(7t0q|=waQ3jjQXU9fd zGjDPPk5l$C;;WL@xs}1;@ zhb1K?NPgYeSr&oCZu(f{s*CwfTA2Hp-7DQj4P%VAqo0;6iV4h&>!CkCz&fQY$Oa3& zjWCzlshCacFTf+)RaJU0%F4+j`EvaYRsZ~o*;$z_fIb{TWfe7SPI1L_8sBUu>O&5n z(veO!yjXK(4A9$*5=-aA68+r#DG0HREDv|UB7ZZ?BRf=%8`<0b0!1ErSezP0`_e|v zj!|D<|IdW}O^TwTBF-kIsHBYb83AOIQ^ySIqf8e~%yy-|>_bNe*+S#2)i7|k0$A2{1WZEY=*4EqKD z=}S8K5hKaE$Y|cbe?Mo>Bl#W4ZyL|jIp^N(8+c)VF1FgX|M$8ne*O!I869_T*(YL2_i|#*xhtg<4^1VhrWk{6)UL<(Qh9k!>RxOG7L$!+Q zuBqft6zQacChF3MiS{*w;RG(!W`*YM$qvQxBu~y(O5g5aez;9H$XB5_$`1FJ^Kd8G zUCGz=s~~6QFX(r6amC`ibh5iT5-rrX1qm1w9Q@V%eamHXbx24sHWX%JYi=Y~#yXRY z*90RRHBof+!ek%=A>$A)D~m%IW)T7xkA1ok7!* zNhZol!koCk_YRf@rQY7&q4XJy3ZtEcs*JE7_Z7w8YUD*?ZJHle#Jf=&9I+zK2~X}V zBztrK(%)zJTYOGGTgz5fR$LxWFK;|iSAvxZE?5*{jrG|<*i^|ww*S&M)PGwpvoSNM ztM5cB8#~O&&BL>2&(@Os&uk1#r^U{}{r6;rdhE-O!o8URTs@6B!FZ&hf^40B$j*lU zgwN*>>wjjq?aAlr?t!iK6}T@i49lYJurl5W4-}H^w2FrXxtZL4=tQqOc&1RX8NmN2os4XEv`xR`K`G)8ao?{v8<$! zv%!ANUjDUb2?+_G%pZ2c?AU$Nvbj`Tm{0c9V%*OQ!|DWQtcr8Qh74cMM&C+jq!zNf zHrM2HXsOP{)~XC_E}=OWY}HA0exg62F&Iw18}n&ysQdZ(gw&MeT`eyyLT_I`&VJ5h z<$r=6ok{3BGm_u@k?lu)1ASNa)%&x-T9@?|Y60jjF5cj70;+_J@Qr9*yi_i0Qpkm_=DazWC6a{hm8?J@laeVdQ;J=<4dNxlKK zRb)49t-^f`d+_1oZk=;a8`zlqRbKYo+|r7(#WUZYR4qfwh6gw>M8u-p^wP>a((vBJztW#HQ>3LLlzT4d(nc z_L0v9{Z*DT<3{}Q$-H57_YF^A8z#F`L(jLGGzV6d?1+r2l@1I{vcN5JL2i> zgPED+FLAIQPmzxt^BLGrzDNgnp|~&058G?fKaqj}xFB;$b>xA1H`= zVyd-``H%ld=&LL2rT3pM&bL+>TsTzy{_MdL@_EQ4KZ!VOE2cUKZPY)XgN;Y$-Yk4i zdVdyPKEBKOR{Pk@8qv^38w3e#bTA^#01}=h~|4E*z@D zv(2S=irR6aE{p0*rMa6(zA!`s^=&(&hv+&=J}r;#-s0MD<@kQ`Z3*vw$BhA{txUjU z)CVj-`Lb|j(fEF-&J4*A5?aD+;{QqeY0pr=*+Z3D7Y^54zIeDA>2I~*nFEE?mOS#i z$?Eojsii)wN#@$Zp1*zd0w0hsN(Z%zJ@58~NvHIg*wv83<)!bo@la)Qds2{-JXQ4H zvS0VMp?xp!r?YKUrWcM>pS(;yJoHDO{`8&MUqC)Oc}RcriR7kqB!3os{roAOrFNcf z%;kJ*&K@Yhvj>X^g?}8b$v9A&7OX*q|6lnJ^tOYTd;c@7)gtFwt3xifRd-xERP&7a z0nvBwoWIY-Hrm&S&fm@*#_K1V@I3heo!wvjpmT3t^TE;-kL);a=I6m|p8pbW=_TYp zaKXmpTub?~uI93xT?a}%PaPRRNv$%9E)-M564GntX~ezm{l1Davd1v!V@w5b z_dPKc)WkjbGIss={QoL$`dHuRG5470dtz#rD| Date: Wed, 3 Apr 2024 22:50:26 +0200 Subject: [PATCH 324/403] thread/Async.cpp - send SendNotification only if env isn't deleted --- src/Job/Async.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Job/Async.cpp b/src/Job/Async.cpp index ddab9c4617e..7004c38d7a6 100644 --- a/src/Job/Async.cpp +++ b/src/Job/Async.cpp @@ -49,6 +49,7 @@ AsyncJobRunner::Wait() Thread::Join(); delete env; + env = nullptr; if (exception) /* rethrow the exception that was thrown by Job::Run() in the @@ -75,8 +76,7 @@ AsyncJobRunner::Run() noexcept the calling thread in Wait() */ exception = std::current_exception(); } - - if (notify != NULL && !env->IsCancelled()) + if (notify != nullptr && env != nullptr && !env->IsCancelled()) notify->SendNotification(); running.store(false, std::memory_order_relaxed); From a51f008c2f7690bebb736eee7a38ede7f441150a Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 5 Apr 2024 11:33:07 +0200 Subject: [PATCH 325/403] [InfoBox] layout - add 4 portrait layouts with vario * TOP_8_VARIO_BOTTOM_5 = 27, * TOP_8_VARIO_BOTTOM_10 = 28, * TOP_12_VARIO = 29, * TOP_16_VARIO = 30, --- .../Settings/Panels/LayoutConfigPanel.cpp | 8 ++ src/InfoBoxes/InfoBoxLayout.cpp | 107 ++++++++++++++++++ src/InfoBoxes/InfoBoxSettings.hpp | 4 + src/Profile/InfoBoxConfig.cpp | 3 + 4 files changed, 122 insertions(+) diff --git a/src/Dialogs/Settings/Panels/LayoutConfigPanel.cpp b/src/Dialogs/Settings/Panels/LayoutConfigPanel.cpp index e71d19ad1af..dea50181b40 100644 --- a/src/Dialogs/Settings/Panels/LayoutConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/LayoutConfigPanel.cpp @@ -106,6 +106,14 @@ static constexpr StaticEnumChoice info_box_geometry_list[] = { N_("4 Top or Left") }, { InfoBoxSettings::Geometry::BOTTOM_RIGHT_4, N_("4 Bottom or Right") }, + { InfoBoxSettings::Geometry::TOP_8_VARIO_BOTTOM_5, + N_("8 Top + Vario + 5 Bottom (Portrait)") }, + { InfoBoxSettings::Geometry::TOP_8_VARIO_BOTTOM_10, + N_("8 Top + Vario + 10 Bottom (Portrait)") }, + { InfoBoxSettings::Geometry::TOP_12_VARIO, + N_("12 Top + Vario (Portrait)") }, + { InfoBoxSettings::Geometry::TOP_16_VARIO, + N_("16 Top + Vario (Portrait)") }, nullptr }; diff --git a/src/InfoBoxes/InfoBoxLayout.cpp b/src/InfoBoxes/InfoBoxLayout.cpp index ff3453e2029..ce19c456a68 100644 --- a/src/InfoBoxes/InfoBoxLayout.cpp +++ b/src/InfoBoxes/InfoBoxLayout.cpp @@ -20,6 +20,10 @@ static constexpr unsigned char geometry_counts[] = { 12, // 3 rows X 4 boxes 15, // 3 rows X 5 boxes 18, // 3 rows X 6 boxes + 13, // TOP_8_VARIO_BOTTOM_5: 2 rows X 4 + 1 row x 5 (= 8 + 5) + 18, // TOP_8_VARIO_BOTTOM_10: 2 rows X 4 + 2 row x 5 (= 8 + 10) + 12, // TOP_12_VARIO: 3 rows X 4 boxes (= 12 + 0) + 16, // TOP_16_VARIO: 4 rows X 4 boxes (= 16 + 0) }; namespace InfoBoxLayout { @@ -232,6 +236,74 @@ InfoBoxLayout::Calculate(PixelRect rc, InfoBoxSettings::Geometry geometry) noexc rc.left, rc.top, rc.bottom); break; +//----------------------------- + case InfoBoxSettings::Geometry::TOP_8_VARIO_BOTTOM_5: + layout.vario.left = rc.right - layout.control_size.width; + layout.vario.right = rc.right; + layout.vario.top = rc.top; + layout.vario.bottom = rc.top + layout.control_size.height * 2; + + right = layout.vario.left; + rc.top = MakeTopRow(layout, layout.positions, 4, rc.left, right, rc.top); + rc.top = MakeTopRow(layout, layout.positions + 4, 4, rc.left, right, rc.top); + // layout.control_size.height = layout.control_size.width * 0.9; + + rc.bottom = MakeBottomRow(layout, layout.positions + 8, 5, rc.left, + rc.right, rc.bottom); + break; +//----------------------------- + case InfoBoxSettings::Geometry::TOP_8_VARIO_BOTTOM_10: + layout.vario.left = rc.right - layout.control_size.width; + layout.vario.right = rc.right; + layout.vario.top = rc.top; + layout.vario.bottom = rc.top + layout.control_size.height * 2; + + right = layout.vario.left; + rc.top = MakeTopRow(layout, layout.positions, 4, rc.left, + right, rc.top); + rc.top = MakeTopRow(layout, layout.positions + 4, 4, rc.left, + right, rc.top); + + rc.bottom = MakeBottomRow(layout, layout.positions + 8, 5, rc.left, + rc.right, rc.bottom); + rc.bottom = MakeBottomRow(layout, layout.positions + 13, 5, rc.left, + rc.right, rc.bottom); + break; +//----------------------------- + case InfoBoxSettings::Geometry::TOP_12_VARIO: + layout.vario.left = rc.right - (3 * layout.control_size.width) / 2; + layout.vario.right = rc.right; + layout.vario.top = rc.top; + layout.vario.bottom = rc.top + 4 * layout.control_size.height; + + right = layout.vario.left; + rc.top = MakeTopRow(layout, layout.positions, 4, rc.left, + right, rc.top); + rc.top = MakeTopRow(layout, layout.positions + 4, 4, rc.left, + right, rc.top); + rc.top = MakeTopRow(layout, layout.positions + 8, 4, rc.left, + right, rc.top); + + break; +//----------------------------- + case InfoBoxSettings::Geometry::TOP_16_VARIO: + layout.vario.left = rc.right - (3 * layout.control_size.width) / 2; + layout.vario.right = rc.right; + layout.vario.top = rc.top; + layout.vario.bottom = rc.top + 4 * layout.control_size.height; + + right = layout.vario.left; + rc.top = MakeTopRow(layout, layout.positions, 4, rc.left, + right, rc.top); + rc.top = MakeTopRow(layout, layout.positions + 4, 4, rc.left, + right, rc.top); + rc.top = MakeTopRow(layout, layout.positions + 8, 4, rc.left, + right, rc.top); + rc.top = MakeTopRow(layout, layout.positions + 12, 4, rc.left, + right, rc.top); + + break; +//----------------------------- case InfoBoxSettings::Geometry::BOTTOM_RIGHT_12: case InfoBoxSettings::Geometry::OBSOLETE_BOTTOM_RIGHT_12: if (layout.landscape) { @@ -459,6 +531,11 @@ InfoBoxLayout::ValidateGeometry(InfoBoxSettings::Geometry geometry, case InfoBoxSettings::Geometry::TOP_8_VARIO: return InfoBoxSettings::Geometry::LEFT_6_RIGHT_3_VARIO; + case InfoBoxSettings::Geometry::TOP_8_VARIO_BOTTOM_5: + case InfoBoxSettings::Geometry::TOP_8_VARIO_BOTTOM_10: + case InfoBoxSettings::Geometry::TOP_12_VARIO: + case InfoBoxSettings::Geometry::TOP_16_VARIO: + return InfoBoxSettings::Geometry::LEFT_12_RIGHT_3_VARIO; } } else { /* portrait and square */ @@ -505,6 +582,10 @@ InfoBoxLayout::ValidateGeometry(InfoBoxSettings::Geometry geometry, case InfoBoxSettings::Geometry::OBSOLETE_TOP_LEFT_4: case InfoBoxSettings::Geometry::OBSOLETE_BOTTOM_RIGHT_4: case InfoBoxSettings::Geometry::TOP_8_VARIO: + case InfoBoxSettings::Geometry::TOP_8_VARIO_BOTTOM_5: + case InfoBoxSettings::Geometry::TOP_8_VARIO_BOTTOM_10: + case InfoBoxSettings::Geometry::TOP_12_VARIO: + case InfoBoxSettings::Geometry::TOP_16_VARIO: break; } } @@ -593,6 +674,12 @@ InfoBoxLayout::CalcInfoBoxSizes(Layout &layout, PixelSize screen_size, layout.control_size.width); break; + case InfoBoxSettings::Geometry::TOP_8_VARIO_BOTTOM_5: + case InfoBoxSettings::Geometry::TOP_8_VARIO_BOTTOM_10: + layout.control_size.width = screen_size.width / 5; + // preserve relative shape + layout.control_size.height = layout.control_size.width * 0.9; + break; case InfoBoxSettings::Geometry::TOP_8_VARIO: // calculate control dimensions layout.control_size.width = 2 * screen_size.width / (layout.count + 2); @@ -600,6 +687,14 @@ InfoBoxLayout::CalcInfoBoxSizes(Layout &layout, PixelSize screen_size, layout.control_size.width); break; + case InfoBoxSettings::Geometry::TOP_12_VARIO: + case InfoBoxSettings::Geometry::TOP_16_VARIO: + // calculate control dimensions + // layout.control_size.width = 2 * screen_size.width / (layout.count + 2); + layout.control_size.width = (2 * screen_size.width) / 11; + layout.control_size.height = CalculateInfoBoxRowHeight( + screen_size.height, layout.control_size.width); + break; case InfoBoxSettings::Geometry::RIGHT_9_VARIO: case InfoBoxSettings::Geometry::LEFT_6_RIGHT_3_VARIO: // calculate control dimensions @@ -852,9 +947,21 @@ InfoBoxLayout::GetBorder(InfoBoxSettings::Geometry geometry, bool landscape, break; case InfoBoxSettings::Geometry::TOP_8_VARIO: + case InfoBoxSettings::Geometry::TOP_12_VARIO: + case InfoBoxSettings::Geometry::TOP_16_VARIO: border |= BORDERBOTTOM|BORDERRIGHT; break; + case InfoBoxSettings::Geometry::TOP_8_VARIO_BOTTOM_5: + case InfoBoxSettings::Geometry::TOP_8_VARIO_BOTTOM_10: + if (!((i == 0) || (i == 4))) + border |= BORDERLEFT; + if (i < 8) + border |= BORDERTOP; + else + border |= BORDERBOTTOM; + break; + case InfoBoxSettings::Geometry::LEFT_6_RIGHT_3_VARIO: if (i != 0) border |= BORDERTOP; diff --git a/src/InfoBoxes/InfoBoxSettings.hpp b/src/InfoBoxes/InfoBoxSettings.hpp index 4eb07283571..95b96f5eed4 100644 --- a/src/InfoBoxes/InfoBoxSettings.hpp +++ b/src/InfoBoxes/InfoBoxSettings.hpp @@ -107,6 +107,10 @@ struct InfoBoxSettings { /** 18 infoboxes 3X6 split bottom/top or left/right */ SPLIT_3X6 = 26, + TOP_8_VARIO_BOTTOM_5 = 27, + TOP_8_VARIO_BOTTOM_10 = 28, + TOP_12_VARIO = 29, + TOP_16_VARIO = 30, } geometry; bool use_colors; diff --git a/src/Profile/InfoBoxConfig.cpp b/src/Profile/InfoBoxConfig.cpp index 33c6280f0aa..5cfb46c4f69 100644 --- a/src/Profile/InfoBoxConfig.cpp +++ b/src/Profile/InfoBoxConfig.cpp @@ -96,6 +96,9 @@ Profile::Load(const ProfileMap &map, InfoBoxSettings &settings) case InfoBoxSettings::Geometry::TOP_LEFT_4: case InfoBoxSettings::Geometry::BOTTOM_RIGHT_4: case InfoBoxSettings::Geometry::SPLIT_3X6: + case InfoBoxSettings::Geometry::TOP_8_VARIO_BOTTOM_5: + case InfoBoxSettings::Geometry::TOP_8_VARIO_BOTTOM_10: + case InfoBoxSettings::Geometry::TOP_12_VARIO: break; case InfoBoxSettings::Geometry::OBSOLETE_TOP_LEFT_4: From 4338d0dc4c0d17bdd68a8302a561b8252ba7ca00 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 9 Apr 2024 14:10:11 +0200 Subject: [PATCH 326/403] [OV] FileMenuWidget.cpp - reorder, better designe (with AddLabel), add hided bzutton 'Backup Image' --- src/OpenVario/FileMenuWidget.cpp | 38 +++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/src/OpenVario/FileMenuWidget.cpp b/src/OpenVario/FileMenuWidget.cpp index 19f3ec0e10d..340aba119f4 100644 --- a/src/OpenVario/FileMenuWidget.cpp +++ b/src/OpenVario/FileMenuWidget.cpp @@ -38,8 +38,8 @@ void FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { StaticString<60> title; - title.Format(_("Download %s IGC files to USB (WIP)"),main_app); - AddButton(title, [](){ + + AddButton(_("Upload IGC Files to USB (WIP)"), []() { static constexpr const char *argv[] = { "/usr/bin/download-igc.sh", nullptr }; @@ -48,9 +48,11 @@ void FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, _("Download IGC Files"), argv); }); + //----------------------------------------------------- + title.Format(_(" - File Transfers %s Data"), main_app); + AddLabel(title); - title.Format(_("Download %s data files from OV to USB"), main_app); - AddButton(title, []() { + AddButton(_("Save: OpenVario -> USB"), []() { static constexpr const char *argv[] = { "/usr/bin/transfers.sh", "download-data", _main_app, nullptr }; @@ -60,8 +62,7 @@ void FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, _("Download files"), argv); }); - title.Format(_("Restore %s data files from USB"), main_app); - AddButton(title, []() { + AddButton(_("Restore: OpenVario <- USB"), []() { static constexpr const char *argv[] = {"/usr/bin/transfers.sh", "upload-data", _main_app, nullptr}; @@ -71,10 +72,11 @@ void FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, dialog_title, argv); }); - AddReadOnly(_T("--- System: ---")); + //----------------------------------------------------- + title.Format(_("- Complete System Data Transfers"), main_app); + AddLabel(title); // _T("---OpenSoar Data Files---")); - title.Format(_("System Backup: OpenVario and %s settings to USB"), main_app); - AddButton(title, []() { + AddButton(_("Backup: OpenVario System to USB"), []() { static constexpr const char *argv[] = {"/usr/bin/transfer-system.sh", "backup", _main_app, nullptr }; @@ -84,9 +86,7 @@ void FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, _("Backup System"), argv); }); - title.Format(_("System Restore: OpenVario and %s settings from USB"), - main_app); - AddButton(title, []() { + AddButton(_("Restore: OpenVario System from USB"), []() { static constexpr const char *argv[] = {"/usr/bin/transfer-system.sh", "restore", _main_app, nullptr }; @@ -95,6 +95,17 @@ void FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, _("Restore System"), argv); Display::Rotate(Display::DetectInitialOrientation()); }); + + auto btn = AddButton(_("Image Backup to USB (WIP)"), []() { + static constexpr const char *argv[] = {"/usr/bin/transfer-system.sh", + "restore", _main_app, nullptr + }; + RunProcessDialog(UIGlobals::GetMainWindow(), + UIGlobals::GetDialogLook(), + _("Backup Image"), argv); + Display::Rotate(Display::DetectInitialOrientation()); + }); + btn->SetEnabled(false); } bool @@ -113,4 +124,5 @@ std::unique_ptr CreateFileMenuWidget() noexcept { return std::make_unique(); } -#endif + +#endif // IS_OPENVARIO \ No newline at end of file From 0292725ef307af0235dbc8f2ff7d0ac6ecd489c7 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 9 Apr 2024 15:42:56 +0200 Subject: [PATCH 327/403] [OV] removed unused include --- src/OpenVario/System/OpenVarioDevice.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/OpenVario/System/OpenVarioDevice.cpp b/src/OpenVario/System/OpenVarioDevice.cpp index 47f45c32155..055001ce58e 100644 --- a/src/OpenVario/System/OpenVarioDevice.cpp +++ b/src/OpenVario/System/OpenVarioDevice.cpp @@ -28,7 +28,6 @@ #include "LocalPath.hpp" #include -#include " #ifndef _WIN32 #include From 85a0a6e537f11490a8123713ec8d9b9d7c246aad Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 10 Apr 2024 08:55:32 +0200 Subject: [PATCH 328/403] [OV] - add shutdown/Reboot events --- Data/Input/defaultOV.xci | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Data/Input/defaultOV.xci b/Data/Input/defaultOV.xci index 6008905cf22..a8102ac901d 100644 --- a/Data/Input/defaultOV.xci +++ b/Data/Input/defaultOV.xci @@ -88,6 +88,19 @@ data=X event=Shutdown shutdown event=Mode default +mode=default pan Nav1 Nav2 Display1 Display2 Config1 Config2 Config3 Info1 Info2 Menu Vario1 Vario2 +type=key +data=R +event=Shutdown reboot +event=Mode default + +# mode=default +mode=default pan Nav1 Nav2 Display1 Display2 Config1 Config2 Config3 Info1 Info2 Menu Vario1 Vario2 +type=key +data=Y +event=Exit restart +event=Mode default + mode=default pantype=key data=ESCAPE event=Page restore From 4d0cb7b7733b0e9849c7ac5a75b5fa0ffbee1bcc Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 10 Apr 2024 15:55:04 +0200 Subject: [PATCH 329/403] [OV] OpenVarioDevice - add mode for SetRotation to split the different parts flags: 1 - rotated the Software rotation routines 2 - set the (hardware-) /sys/class/graphics/fbcon/rotate file 4 - save it in system.uEnv on boot sector and in the map --- src/OpenVario/System/OpenVarioDevice.cpp | 18 +++++++++++------- src/OpenVario/System/OpenVarioDevice.hpp | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/OpenVario/System/OpenVarioDevice.cpp b/src/OpenVario/System/OpenVarioDevice.cpp index 055001ce58e..fe65100e51f 100644 --- a/src/OpenVario/System/OpenVarioDevice.cpp +++ b/src/OpenVario/System/OpenVarioDevice.cpp @@ -253,7 +253,7 @@ OpenVario_Device::GetRotation() } void -OpenVario_Device::SetRotation(DisplayOrientation orientation) +OpenVario_Device::SetRotation(DisplayOrientation orientation, int mode) { std::map> map; @@ -261,7 +261,8 @@ OpenVario_Device::SetRotation(DisplayOrientation orientation) if (map.contains("Rotation")) // this is wrong!!! map.erase("Rotation"); - Display::Rotate(orientation); + if (mode & 1) + Display::Rotate(orientation); int rotation = 0; switch (orientation) { @@ -278,6 +279,7 @@ OpenVario_Device::SetRotation(DisplayOrientation orientation) rotation = 3; break; }; + std::string rot_string = fmt::format_int{rotation}.c_str(); if (map["rotation"] != rot_string) { LogFormat("Set Rotation '%s' vs. '%s' (%d)", map["rotation"].c_str(), @@ -286,13 +288,15 @@ OpenVario_Device::SetRotation(DisplayOrientation orientation) if (map["rotation"] != rot_string) { - File::WriteExisting(Path(_T("/sys/class/graphics/fbcon/rotate")), + if (mode & 2) { + File::WriteExisting(Path(_T("/sys/class/graphics/fbcon/rotate")), rot_string.c_str()); + } - map.insert_or_assign("rotation", rot_string); - WriteConfigFile(map, system_config); - - // Restart??? + if (mode & 4) { + map.insert_or_assign("rotation", rot_string); + WriteConfigFile(map, system_config); + } } } diff --git a/src/OpenVario/System/OpenVarioDevice.hpp b/src/OpenVario/System/OpenVarioDevice.hpp index 94cbb3c26c9..c2f859d3975 100644 --- a/src/OpenVario/System/OpenVarioDevice.hpp +++ b/src/OpenVario/System/OpenVarioDevice.hpp @@ -106,7 +106,7 @@ class OpenVario_Device { uint_least8_t GetBrightness() noexcept; void SetBrightness(uint_least8_t value) noexcept; DisplayOrientation GetRotation(); - void SetRotation(DisplayOrientation orientation); + void SetRotation(DisplayOrientation orientation, int mode=0); bool GetSystemStatus(std::string_view system) noexcept; void SetSystemStatus(std::string_view system, bool value) noexcept; From c4319853da107ef9fecce5b9e199c1faa4f6bd7e Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 10 Apr 2024 14:22:18 +0200 Subject: [PATCH 330/403] [OV] DisplaySettingsWidget.cpp - cleanup code: remove unused RotateButton and - code style for OnModified ( and other places) --- src/OpenVario/DisplaySettingsWidget.cpp | 83 +++++++++++-------------- 1 file changed, 38 insertions(+), 45 deletions(-) diff --git a/src/OpenVario/DisplaySettingsWidget.cpp b/src/OpenVario/DisplaySettingsWidget.cpp index bf7651e583b..f022dfa7ec6 100644 --- a/src/OpenVario/DisplaySettingsWidget.cpp +++ b/src/OpenVario/DisplaySettingsWidget.cpp @@ -76,38 +76,46 @@ class DisplaySettingsWidget final : public RowFormWidget, DataFieldListener { private: /* methods from DataFieldListener */ void OnModified(DataField &df) noexcept override; + void RotateDisplay(DisplayOrientation orientation) noexcept; unsigned brightness; + ContainerWindow* parent; }; +void +DisplaySettingsWidget::RotateDisplay( + [[maybe_unused]] DisplayOrientation orientation) noexcept +{ + + // ShowMessageBox(_T("Set Rotation"), _T("Rotation"), MB_OK); + + // ovdevice.SetRotation(orientation); + + // UI::TopWindow::SetExitValue(EXIT_RESTART); + // UIActions::SignalShutdown(true); +} + -void DisplaySettingsWidget::OnModified([[maybe_unused]] DataField &df) noexcept { +void +DisplaySettingsWidget::OnModified([[maybe_unused]] DataField &df) noexcept +{ if (IsDataField(ROTATION, df)) { - // ShowMessageBox(_T("Set Rotation"), _T("Rotation"), MB_OK); - // ovdevice.SetRotation((DisplayOrientation)((const DataFieldEnum - // &)df).GetValue()); - // UI::TopWindow::SetExitValue(EXIT_RESTART); - // UIActions::SignalShutdown(true); + RotateDisplay((DisplayOrientation)((const DataFieldEnum &)df).GetValue()); } else if (IsDataField(BRIGHTNESS, df)) { - // const DataFieldInteger &dfi = (const DataFieldInteger &)df; - // (DataFieldInteger*)df) - ovdevice.SetBrightness(((const DataFieldInteger &)df).GetValue() / 10); + auto new_brightness = ((const DataFieldInteger &)df).GetValue(); + if (new_brightness != brightness) + ovdevice.SetBrightness(new_brightness / 10); } } void -DisplaySettingsWidget::Prepare([[maybe_unused]] ContainerWindow &parent, +DisplaySettingsWidget::Prepare([[maybe_unused]] ContainerWindow &_parent, [[maybe_unused]] const PixelRect &rc) noexcept { - + parent = &_parent; brightness = ovdevice.brightness * 10; -#ifdef ADD_ROTATION_BUTTON - AddButton(_("Screen Rotation"), [this](){ - return ShowRotationSettingsWidget(UIGlobals::GetMainWindow(), GetLook()); - }); -#endif AddEnum(_("Rotation"), _("Rotation Display OpenVario"), rotation_list, (unsigned)ovdevice.rotation, this); @@ -115,48 +123,33 @@ DisplaySettingsWidget::Prepare([[maybe_unused]] ContainerWindow &parent, _T("%d%%"), 10, 100, 10, brightness, this); AddButton(_("Calibrate Touch"), [this]() { - // the programm exit in OpenSoar looks complete different fro OpenVarioBaseMenu ContainerWindow::SetExitValue(LAUNCH_TOUCH_CALIBRATE); UIActions::SignalShutdown(true); return mrOK; }); - -// AddButton(_("Setting Brightness"), [this](){ - // return ShowSettingBrightnessWidget(UIGlobals::GetMainWindow(), GetLook()); -// }); - -// uint32_t iTest = 0; -// AddInteger(_("Brightness Test"), _("Setting Brightness."), _T("%d"), _T("%d"), 1, -// 10, 1, iTest); } bool -DisplaySettingsWidget::Save([[maybe_unused]] bool &_changed) noexcept -{ -bool changed = false; -// bool restart = false; -if (SaveValueInteger(BRIGHTNESS, "Brightness", brightness)) { - ovdevice.SetBrightness(brightness / 10); - changed = true; -} -if (SaveValueEnum(ROTATION, ovdevice.rotation)) { - // ovdevice.SetRotation( - // (DisplayOrientation)((const DataFieldEnum &)df).GetValue()); - ovdevice.SetRotation(ovdevice.rotation); - // restart = true; -#if 0 // defined(OPENVARIO_BASEMENU) +DisplaySettingsWidget::Save([[maybe_unused]] bool &_changed) noexcept { + bool changed = false; + // bool restart = false; + if (SaveValueInteger(BRIGHTNESS, "Brightness", brightness)) { + ovdevice.SetBrightness(brightness / 10); changed = true; -#else - require_restart = changed = true; -#endif -} + } + if (SaveValueEnum(ROTATION, ovdevice.rotation)) { + ovdevice.SetRotation(ovdevice.rotation, 4); + require_restart = changed = true; + UI::TopWindow::SetExitValue(EXIT_RESTART); + } -_changed = changed; -return true; + _changed = changed; + return true; } + bool ShowDisplaySettingsWidget(ContainerWindow &parent, const DialogLook &look) noexcept { From 715329aecc351c8c0405466e1426d755ddcd4617 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 10 Apr 2024 14:24:03 +0200 Subject: [PATCH 331/403] [OV] dlgConfiguration.cpp - Flag for usage of XCSoar style menu --- src/Dialogs/Settings/dlgConfiguration.cpp | 26 +++++++++++++---------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/Dialogs/Settings/dlgConfiguration.cpp b/src/Dialogs/Settings/dlgConfiguration.cpp index 59a7b0552de..b5ecd409ff8 100644 --- a/src/Dialogs/Settings/dlgConfiguration.cpp +++ b/src/Dialogs/Settings/dlgConfiguration.cpp @@ -77,6 +77,10 @@ #include +#if defined(__AUGUST__) // hide this code +// # define SPLIT_XCSOAR_MENU +#endif + static unsigned current_page; // TODO: eliminate global variables @@ -180,14 +184,14 @@ static constexpr TabMenuGroup main_menu_captions[] = { static void OnUserLevel(bool expert) noexcept; -#ifdef __AUGUST__ +#ifdef SPLIT_XCSOAR_MENU static void OnXCSoarStyle(bool expert) noexcept; #endif class ConfigurationExtraButtons final : public NullWidget { struct Layout { -#ifdef __AUGUST__ +#ifdef SPLIT_XCSOAR_MENU PixelRect expert, xcsoar_style, button2, button1; Layout(const PixelRect &rc) @@ -204,7 +208,7 @@ class ConfigurationExtraButtons final if (height >= 3 * max_control_height) { expert.bottom = expert.top + max_control_height; -#ifdef __AUGUST__ +#ifdef SPLIT_XCSOAR_MENU xcsoar_style.top = expert.bottom; xcsoar_style.bottom = xcsoar_style.top + max_control_height; #endif @@ -213,7 +217,7 @@ class ConfigurationExtraButtons final button2.top = button2.bottom - max_control_height; } else { expert.right = button2.left = unsigned(rc.left * 2 + rc.right) / 3; -#ifdef __AUGUST__ +#ifdef SPLIT_XCSOAR_MENU xcsoar_style.right = expert.right; #endif button2.right = button1.left = unsigned(rc.left + rc.right * 2) / 3; @@ -224,7 +228,7 @@ class ConfigurationExtraButtons final const DialogLook &look; CheckBoxControl expert; -#ifdef __AUGUST__ +#ifdef SPLIT_XCSOAR_MENU CheckBoxControl xcsoar_style; #endif Button button2, button1; @@ -271,7 +275,7 @@ class ConfigurationExtraButtons final expert.Create(parent, look, _("Expert"), layout.expert, style, [](bool value){ OnUserLevel(value); }); -#ifdef __AUGUST__ +#ifdef SPLIT_XCSOAR_MENU xcsoar_style.Create(parent, look, _("XCSoar"), layout.xcsoar_style, style, [](bool value){ OnXCSoarStyle(value); }); @@ -285,7 +289,7 @@ class ConfigurationExtraButtons final expert.SetState(CommonInterface::GetUISettings().dialog.expert); expert.MoveAndShow(layout.expert); -#ifdef __AUGUST__ +#ifdef SPLIT_XCSOAR_MENU xcsoar_style.SetState(CommonInterface::GetUISettings().dialog.xcsoar_style); xcsoar_style.MoveAndShow(layout.xcsoar_style); #endif @@ -303,7 +307,7 @@ class ConfigurationExtraButtons final void Hide() noexcept override { expert.FastHide(); -#ifdef __AUGUST__ +#ifdef SPLIT_XCSOAR_MENU xcsoar_style.FastHide(); #endif button2.FastHide(); @@ -327,7 +331,7 @@ class ConfigurationExtraButtons final void Move(const PixelRect &rc) noexcept override { Layout layout(rc); expert.Move(layout.expert); -#ifdef __AUGUST__ +#ifdef SPLIT_XCSOAR_MENU xcsoar_style.Move(layout.xcsoar_style); #endif button2.Move(layout.button2); @@ -366,7 +370,7 @@ OnUserLevel(bool expert) noexcept pager->PagerWidget::Move(pager->GetPosition()); } -#ifdef __AUGUST__ +#if defined(SPLIT_XCSOAR_MENU) static void OnXCSoarStyle(bool xcsoar_style) noexcept { @@ -433,7 +437,7 @@ void dlgConfigurationShowModal() look, _("Configuration")); pager = new ArrowPagerWidget(look.button, -#ifdef __AUGUST__ +#ifdef SPLIT_XCSOAR_MENU [&dialog](){ OnSaveClicked(dialog); }, #endif [&dialog](){ OnCloseClicked(dialog); }, From 8b0a32c34347ce94ec08860258c05f33018519b0 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 10 Apr 2024 15:42:38 +0200 Subject: [PATCH 332/403] [OV] dlgConfiguration.cpp make a Restart if announced after a Rotate --- src/Dialogs/Settings/dlgConfiguration.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Dialogs/Settings/dlgConfiguration.cpp b/src/Dialogs/Settings/dlgConfiguration.cpp index b5ecd409ff8..6efaf44a0ca 100644 --- a/src/Dialogs/Settings/dlgConfiguration.cpp +++ b/src/Dialogs/Settings/dlgConfiguration.cpp @@ -44,6 +44,9 @@ #include "UtilsSettings.hpp" #include "net/http/Features.hpp" #include "ui/window/SingleWindow.hpp" +#include "UIActions.hpp" + +#include "Hardware/RotateDisplay.hpp" #ifdef HAVE_PCM_PLAYER #include "Panels/AudioVarioConfigPanel.hpp" @@ -72,7 +75,6 @@ #include "OpenVario/DisplaySettingsWidget.hpp" #include "OpenVario/ExtraWidget.hpp" #include "OpenVario/System/OpenVarioDevice.hpp" -#include "UIActions.hpp" #endif #include @@ -453,11 +455,6 @@ void dlgConfigurationShowModal() return std::move(_menu); })); - -// #ifdef IS_OPENVARIO -// ovdevice.Initialise(); -// #endif - menu.InitMenu(main_menu_captions, ARRAY_SIZE(main_menu_captions)); /* restore last selected menu item */ @@ -474,6 +471,9 @@ void dlgConfigurationShowModal() /* save page number for next time this dialog is opened */ current_page = menu.GetCursor(); + if (UI::TopWindow::GetExitValue() == EXIT_RESTART) + UIActions::SignalShutdown(true); + if (dialog.GetChanged()) { Profile::Save(); if (require_restart) @@ -484,6 +484,12 @@ void dlgConfigurationShowModal() _T(""), MB_YESNO | MB_ICONQUESTION) == IDYES) { UI::TopWindow::SetExitValue(EXIT_RESTART); UIActions::SignalShutdown(true); + + /* OpenVario: + Rotation is stored in config.uEnv - and so you should use the default + * Rotation */ + // Display::RotateRestore(); + Display::Rotate(DisplayOrientation::DEFAULT); } #else ShowMessageBox(_("Changes to configuration saved. Restart XCSoar to " From 47ee94821e794e8986c4d8be189b4def47f46525 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 8 Apr 2024 16:01:25 +0200 Subject: [PATCH 333/403] [XCI/OV] - key extension for defaultOV.xci --- Data/Input/defaultOV.xci | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Data/Input/defaultOV.xci b/Data/Input/defaultOV.xci index a8102ac901d..abf57c1fd4e 100644 --- a/Data/Input/defaultOV.xci +++ b/Data/Input/defaultOV.xci @@ -1,6 +1,12 @@ # ------------------- # GlideComputerEvents # ------------------- +### directly to SetupSystem after Switch On +### mode=default +### type=gce +### data=STARTUP_REAL +### # event=KeyPressed UP UP ENTER +### event=Setup System mode=default type=gce @@ -1392,3 +1398,16 @@ event=Mode AudioMenu ## Shutdown looks line 85 +### call SetupSystem with 'p' +mode=default RemoteStick +type=key +data=P +event=Setup System + +### check using KeyPressed event with 'z' +mode=default RemoteStick +type=key +data=Z +event=KeyPressed P + + From 885bd262d5015d43c7cde159146da8f27efb403e Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 11 Apr 2024 12:05:15 +0200 Subject: [PATCH 334/403] [OV/XCI/Event] add event for 'Quit and Restart' to Event manager and QuickMenu --- Data/Input/defaultOV.xci | 7 ++++++- src/Input/InputEventsActions.cpp | 18 +++++++++++------- src/UIActions.cpp | 7 ++++++- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/Data/Input/defaultOV.xci b/Data/Input/defaultOV.xci index abf57c1fd4e..e0de4a6e34e 100644 --- a/Data/Input/defaultOV.xci +++ b/Data/Input/defaultOV.xci @@ -100,13 +100,18 @@ data=R event=Shutdown reboot event=Mode default -# mode=default mode=default pan Nav1 Nav2 Display1 Display2 Config1 Config2 Config3 Info1 Info2 Menu Vario1 Vario2 type=key data=Y event=Exit restart event=Mode default +mode=default pan Nav1 Nav2 Display1 Display2 Config1 Config2 Config3 Info1 Info2 Menu Vario1 Vario2 +type=key +data=N +event=Exit newstart +event=Mode default + mode=default pantype=key data=ESCAPE event=Page restore diff --git a/src/Input/InputEventsActions.cpp b/src/Input/InputEventsActions.cpp index e11892cf7a9..de1569aa01c 100644 --- a/src/Input/InputEventsActions.cpp +++ b/src/Input/InputEventsActions.cpp @@ -628,29 +628,33 @@ InputEvents::eventExit([[maybe_unused]] const TCHAR *misc) { bool force = false; if (StringIsEqual(misc, _T("system"))) { - // return value on UNIX(32) is only a Byte? - UI::TopWindow::SetExitValue(EXIT_SYSTEM); // 20000); + UI::TopWindow::SetExitValue(EXIT_SYSTEM); } else if (StringIsEqual(misc, _T("force"))) { - // return value on UNIX(32) is only a Byte? - UI::TopWindow::SetExitValue(EXIT_SYSTEM); // 20000); + UI::TopWindow::SetExitValue(EXIT_SYSTEM); force = true; } else if (StringIsEqual(misc, _T("restart"))) { UI::TopWindow::SetExitValue(EXIT_RESTART); +#if defined(IS_OPENVARIO) + } else if (StringIsEqual(misc, _T("newstart"))) { + UI::TopWindow::SetExitValue(EXIT_NEWSTART); +#endif } - UIActions::SignalShutdown(force); + UIActions::SignalShutdown(force); } -#if 1 // def IS_OPENVARIO +#if 1 // defined(IS_OPENVARIO) // Exits with real Shutdown only in systems where this is possible void InputEvents::eventShutdown([[maybe_unused]] const TCHAR *misc) { +#if defined(IS_OPENVARIO) if (StringIsEqual(misc, _T("reboot"))) { UI::TopWindow::SetExitValue(EXIT_REBOOT); // 20001); } else if (StringIsEqual(misc, _T("shutdown"))) { UI::TopWindow::SetExitValue(EXIT_SHUTDOWN); // 20002); } - UIActions::SignalShutdown(false); +#endif + UIActions::SignalShutdown(false); } #include "InputKeys.hpp" diff --git a/src/UIActions.cpp b/src/UIActions.cpp index 83d64840ade..9b10adf1460 100644 --- a/src/UIActions.cpp +++ b/src/UIActions.cpp @@ -35,14 +35,19 @@ UIActions::CheckShutdown() return true; switch (UI::TopWindow::GetExitValue()) { +#if defined(IS_OPENVARIO) case EXIT_REBOOT: return ShowMessageBox(_("Reboot System?"), _T("OpenSoar"), MB_YESNO | MB_ICONQUESTION) == IDYES; case EXIT_SHUTDOWN: return ShowMessageBox(_("Shutdown System?"), _T("OpenSoar"), MB_YESNO | MB_ICONQUESTION) == IDYES; + case EXIT_NEWSTART: + return ShowMessageBox(_("Quit and Restart OpenSoar?"), _T("OpenSoar"), + MB_YESNO | MB_ICONQUESTION) == IDYES; +#endif case EXIT_RESTART: - return ShowMessageBox(_("Short Restart?"), _T("OpenSoar"), + return ShowMessageBox(_("Short Internal Restart?"), _T("OpenSoar"), MB_YESNO | MB_ICONQUESTION) == IDYES; case EXIT_SYSTEM: From 855b4bdf76f34f2b1d6d25fe01a3466064ec417e Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 11 Apr 2024 12:13:03 +0200 Subject: [PATCH 335/403] [OV] - disabling Orientation setting in Layout Panel * at OpenVario the System orientation AND the OpenSoar orientation should * be equal always! --- src/Dialogs/Settings/Panels/LayoutConfigPanel.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Dialogs/Settings/Panels/LayoutConfigPanel.cpp b/src/Dialogs/Settings/Panels/LayoutConfigPanel.cpp index dea50181b40..d7d02fb3837 100644 --- a/src/Dialogs/Settings/Panels/LayoutConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/LayoutConfigPanel.cpp @@ -196,11 +196,19 @@ LayoutConfigPanel::Prepare(ContainerWindow &parent, ui_settings.display.full_screen); #endif +#if defined(IS_OPENVARIO) + /* moved to OpenVario->DisplaySettingsWidget! + * at OpenVario the System orientation AND the OpenSoar orientation should + * be equal always! + */ + AddDummy(); +#else if (Display::RotateSupported()) AddEnum(_("Display orientation"), _("Rotate the display on devices that support it."), display_orientation_list, (unsigned)ui_settings.display.orientation); else AddDummy(); +#endif AddEnum(_("Dark mode"), nullptr, dark_mode_list, (unsigned)ui_settings.dark_mode); @@ -265,12 +273,14 @@ LayoutConfigPanel::Save(bool &_changed) noexcept bool orientation_changed = false; +#if !defined(IS_OPENVARIO) if (Display::RotateSupported()) { orientation_changed = SaveValueEnum(MapOrientation, ProfileKeys::MapOrientation, ui_settings.display.orientation); changed |= orientation_changed; } +#endif changed |= SaveValueEnum(DarkMode, ProfileKeys::DarkMode, ui_settings.dark_mode); From c784d065c5af4b2dd5ac8340a650281c63c290bd Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 10 Apr 2024 16:27:40 +0200 Subject: [PATCH 336/403] [OV] Hardware/DisplayGlue.cpp - set initial orientation in case of OpenVario... direct to DisplayOrientation::DEFAULT --- src/Hardware/DisplayGlue.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Hardware/DisplayGlue.cpp b/src/Hardware/DisplayGlue.cpp index 0858c835c8c..1462599528c 100644 --- a/src/Hardware/DisplayGlue.cpp +++ b/src/Hardware/DisplayGlue.cpp @@ -77,7 +77,10 @@ Display::DetectInitialOrientation() { auto orientation = DisplayOrientation::DEFAULT; -#ifdef MESA_KMS +#if defined(IS_OPENVARIO) // && !defined(IS_OPENVARIO_CB2) + // On OpenVario the (SW-)display orientation should be default always + orientation = DisplayOrientation::DEFAULT; +#elif defined(MESA_KMS) // When running in DRM/KMS mode, infer the display orientation from the linux // console rotation. char buf[3]; From 39a10b6c904d2e3e5285ce13526b20980e6b97e3 Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 12 Apr 2024 15:31:12 +0200 Subject: [PATCH 337/403] [OV] opengl/TopCanvas.cpp - Workaround: Ask about the screen size at 1st call only ... and then never change it --- src/ui/canvas/opengl/TopCanvas.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ui/canvas/opengl/TopCanvas.cpp b/src/ui/canvas/opengl/TopCanvas.cpp index 1ab3d5ec89f..8533538cdbe 100644 --- a/src/ui/canvas/opengl/TopCanvas.cpp +++ b/src/ui/canvas/opengl/TopCanvas.cpp @@ -38,7 +38,14 @@ PixelSize TopCanvas::SetDisplayOrientation(DisplayOrientation orientation) noexcept { OpenGL::display_orientation = orientation; +#if defined (IS_OPENVARIO) + // Workaround: ask this one time .. and change it never + static const PixelSize _size(OpenGL::window_size.x, + OpenGL::window_size.y); + return SetupViewport(_size); +#else return SetupViewport({OpenGL::window_size.x, OpenGL::window_size.y}); +#endif } #endif From 4090787ac2de386d8cecac57bc245895ce9564e1 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 11 Apr 2024 08:17:51 +0200 Subject: [PATCH 338/403] [OV] - add Exit flag EXIT_NEWSTART for an external restart --- src/ui/window/ContainerWindow.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ui/window/ContainerWindow.hpp b/src/ui/window/ContainerWindow.hpp index ef57c88e266..64a66cc3756 100644 --- a/src/ui/window/ContainerWindow.hpp +++ b/src/ui/window/ContainerWindow.hpp @@ -21,15 +21,17 @@ enum ExitValues { EXIT_REBOOT = 201, // 20002); EXIT_SHUTDOWN = 202, // 20002); +#ifdef IS_OPENVARIO LAUNCH_SHELL = 203, LAUNCH_SHELL_STOP = 204, START_UPGRADE = 205, LAUNCH_TOUCH_CALIBRATE = 206, - -#ifdef IS_OPENVARIO EXIT_BASE_MENU = 207, #endif EXIT_RESTART = 208, +#ifdef IS_OPENVARIO + EXIT_NEWSTART = 209, +#endif }; /** From 3d28a33f548141fd3316def828a5c9a1415e2729 Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 12 Apr 2024 16:27:43 +0200 Subject: [PATCH 339/403] [OV] DisplaySettingsWidget.cpp - a handler for display rotation --- src/OpenVario/DisplaySettingsWidget.cpp | 46 +++++++++++++------------ 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/OpenVario/DisplaySettingsWidget.cpp b/src/OpenVario/DisplaySettingsWidget.cpp index f022dfa7ec6..32a78196d9d 100644 --- a/src/OpenVario/DisplaySettingsWidget.cpp +++ b/src/OpenVario/DisplaySettingsWidget.cpp @@ -15,6 +15,7 @@ #include "Look/DialogLook.hpp" #include "Profile/File.hpp" #include "Profile/Map.hpp" +#include "Profile/Profile.hpp" #include "Screen/Layout.hpp" #include "UIGlobals.hpp" #include "UIActions.hpp" @@ -24,6 +25,7 @@ #include "ui/event/Timer.hpp" #include "ui/window/Init.hpp" #include "UtilsSettings.hpp" +#include "LogFile.hpp" #include "Language/Language.hpp" @@ -78,24 +80,17 @@ class DisplaySettingsWidget final : public RowFormWidget, DataFieldListener { void OnModified(DataField &df) noexcept override; void RotateDisplay(DisplayOrientation orientation) noexcept; - unsigned brightness; + unsigned brightness = 0; + unsigned rotation = 0; + ContainerWindow* parent; }; -void -DisplaySettingsWidget::RotateDisplay( - [[maybe_unused]] DisplayOrientation orientation) noexcept -{ - - // ShowMessageBox(_T("Set Rotation"), _T("Rotation"), MB_OK); - - // ovdevice.SetRotation(orientation); - - // UI::TopWindow::SetExitValue(EXIT_RESTART); - // UIActions::SignalShutdown(true); +void DisplaySettingsWidget::RotateDisplay( + DisplayOrientation orientation) noexcept { + ovdevice.SetRotation(orientation, 1); // internal rotation only } - void DisplaySettingsWidget::OnModified([[maybe_unused]] DataField &df) noexcept { @@ -115,6 +110,10 @@ DisplaySettingsWidget::Prepare([[maybe_unused]] ContainerWindow &_parent, { parent = &_parent; brightness = ovdevice.brightness * 10; + ovdevice.rotation = ovdevice.GetRotation(); + rotation = (unsigned)ovdevice.rotation; + + LogFmt("Rotation-Init {}", rotation); AddEnum(_("Rotation"), _("Rotation Display OpenVario"), rotation_list, (unsigned)ovdevice.rotation, this); @@ -132,24 +131,27 @@ DisplaySettingsWidget::Prepare([[maybe_unused]] ContainerWindow &_parent, bool DisplaySettingsWidget::Save([[maybe_unused]] bool &_changed) noexcept { bool changed = false; - // bool restart = false; + if (SaveValueEnum(ROTATION, ovdevice.rotation)) { + /* On OpenVario never use another orientation as DEFAULT, because we set + * the correct value directly in the config.uEnv */ + Profile::Set(ProfileKeys::MapOrientation, + (unsigned)DisplayOrientation::DEFAULT); + ovdevice.SetRotation(ovdevice.rotation, 6); // fbcon and config.uEnv + // Now no restart necessary! + // UI::TopWindow::SetExitValue(EXIT_NEWSTART); + // require_restart = + changed = true; + } + if (SaveValueInteger(BRIGHTNESS, "Brightness", brightness)) { ovdevice.SetBrightness(brightness / 10); changed = true; } - if (SaveValueEnum(ROTATION, ovdevice.rotation)) { - ovdevice.SetRotation(ovdevice.rotation, 4); - require_restart = changed = true; - UI::TopWindow::SetExitValue(EXIT_RESTART); - } _changed = changed; return true; } - - - bool ShowDisplaySettingsWidget(ContainerWindow &parent, const DialogLook &look) noexcept { From eb5f7b7dced470a5be7548d68c143e31742a5935 Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 12 Apr 2024 17:21:43 +0200 Subject: [PATCH 340/403] [OV] - ui/window/custom/TopWindow.cpp write Rotation setting in log file --- src/ui/window/custom/TopWindow.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ui/window/custom/TopWindow.cpp b/src/ui/window/custom/TopWindow.cpp index f341a65af88..c9ac943b2ef 100644 --- a/src/ui/window/custom/TopWindow.cpp +++ b/src/ui/window/custom/TopWindow.cpp @@ -30,6 +30,8 @@ #include "Screen/Layout.hpp" #endif +#include "LogFile.hpp" + namespace UI { TopWindow::~TopWindow() noexcept @@ -84,6 +86,7 @@ TopWindow::SetDisplayOrientation(DisplayOrientation orientation) noexcept assert(screen != nullptr); Resize(screen->SetDisplayOrientation(orientation)); + LogFmt("TopWindow::SetDisplayOrientation ({})", (unsigned) orientation); } #endif From 096a98430e861e510ec89417e38f9bbed63d5c52 Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 12 Apr 2024 17:43:20 +0200 Subject: [PATCH 341/403] [OV] - Startup.cpp - start OpenSoar with OpenVario orientation (if available) --- src/Startup.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Startup.cpp b/src/Startup.cpp index ab6f2e07153..68ac73e20ad 100644 --- a/src/Startup.cpp +++ b/src/Startup.cpp @@ -112,6 +112,10 @@ #include "Android/NativeView.hpp" #endif +#ifdef IS_OPENVARIO +# include "OpenVario/System/OpenVarioDevice.hpp" +#endif + static TaskManager *task_manager; static GlideComputerEvents *glide_computer_events; static AllMonitors *all_monitors; @@ -252,7 +256,12 @@ Startup(UI::Display &display) style.Resizable(); #ifdef SOFTWARE_ROTATE_DISPLAY - style.InitialOrientation(Display::DetectInitialOrientation()); +# ifdef IS_OPENVARIO + style.InitialOrientation(ovdevice.GetRotation()); +# else + style.InitialOrientation(Display::DetectInitialOrientation()); +# endif + #endif MainWindow *const main_window = CommonInterface::main_window = From a2e1eae37997796e4804251517b46a8c0b2a8ce8 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sat, 13 Apr 2024 13:17:21 +0200 Subject: [PATCH 342/403] [OV] SystemSettingsWidget.cpp - remove ProgramTimeout from the app, this is needed in OpenVarioBaseMenu only! --- src/OpenVario/SystemSettingsWidget.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/OpenVario/SystemSettingsWidget.cpp b/src/OpenVario/SystemSettingsWidget.cpp index 23d6418fae7..46ed3533fbd 100644 --- a/src/OpenVario/SystemSettingsWidget.cpp +++ b/src/OpenVario/SystemSettingsWidget.cpp @@ -68,6 +68,8 @@ class SystemSettingsWidget final : public RowFormWidget, DataFieldListener { void OnModified(DataField &df) noexcept override; }; #endif + +#ifdef OPENVARIOBASEMENU static constexpr StaticEnumChoice timeout_list[] = { { 0, _T("immediately"), }, { 1, _T("1s"), }, @@ -79,6 +81,7 @@ class SystemSettingsWidget final : public RowFormWidget, DataFieldListener { { -1, _T("never"), }, nullptr }; +#endif static constexpr StaticEnumChoice enable_list[] = { { SSHStatus::ENABLED, _T("enabled"), }, @@ -92,7 +95,9 @@ SystemSettingsWidget::SetEnabled([[maybe_unused]] bool enabled) noexcept { // this disabled itself: SetRowEnabled(ENABLED, enabled); // SetRowEnabled(BRIGHTNESS, enabled); +#ifdef OPENVARIOBASEMENU SetRowEnabled(TIMEOUT, enabled); +#endif } void @@ -132,13 +137,18 @@ SystemSettingsWidget::Prepare(ContainerWindow &parent, AddEnum(_("SSH"), _("Enable the SSH Connection"), enable_list, ovdevice.ssh); +#ifdef OPENVARIOBASEMENU AddEnum(_("Program Timeout"), _("Timeout for Program Start."), timeout_list, ovdevice.timeout); +#else + AddDummy(); // Placeholder for enum enumeration +#endif - AddButton( + auto btnWifi = AddButton( _T("Settings Wifi"), [this]() { ShowWifiDialog(); }); - + btnWifi->SetEnabled(true); // dependend on availability? Missing: + AddButton(_("Calibrate Sensors"), CalibrateSensors); @@ -169,11 +179,13 @@ SystemSettingsWidget::Save([[maybe_unused]] bool &_changed) noexcept changed = true; } +#ifdef OPENVARIOBASEMENU if (SaveValueEnum(TIMEOUT, "Timeout", ovdevice.timeout)) { ovdevice.settings.insert_or_assign("Timeout", std::to_string(ovdevice.timeout)); changed = true; } +#endif #ifdef _DEBUG if (SaveValueInteger(INTEGERTEST, "iTest", ovdevice.iTest)) { From 5af6c79464be0e63452eeb7e3874b602ef5ebed0 Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 12 Apr 2024 16:21:12 +0200 Subject: [PATCH 343/403] dlgConfiguration.cpp - use directly restart function, restoring option on ESC --- src/Dialogs/Settings/dlgConfiguration.cpp | 24 +++++++---------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/Dialogs/Settings/dlgConfiguration.cpp b/src/Dialogs/Settings/dlgConfiguration.cpp index 6efaf44a0ca..508d8dfadf6 100644 --- a/src/Dialogs/Settings/dlgConfiguration.cpp +++ b/src/Dialogs/Settings/dlgConfiguration.cpp @@ -45,6 +45,7 @@ #include "net/http/Features.hpp" #include "ui/window/SingleWindow.hpp" #include "UIActions.hpp" +#include "LogFile.hpp" #include "Hardware/RotateDisplay.hpp" @@ -466,35 +467,24 @@ void dlgConfigurationShowModal() dialog.FinishPreliminary(pager); - dialog.ShowModal(); + auto modal_value = dialog.ShowModal(); /* save page number for next time this dialog is opened */ current_page = menu.GetCursor(); - if (UI::TopWindow::GetExitValue() == EXIT_RESTART) - UIActions::SignalShutdown(true); - + if (modal_value != mrOK) { + // check of restoring ? + } if (dialog.GetChanged()) { Profile::Save(); if (require_restart) -#if defined(IS_OPENVARIO) if (ShowMessageBox( _("Changes to configuration saved. Restart OpenSoar " "is needed to apply changes. Do you want restart immediately?"), _T(""), MB_YESNO | MB_ICONQUESTION) == IDYES) { - UI::TopWindow::SetExitValue(EXIT_RESTART); + if (UI::TopWindow::GetExitValue() == 0) + UI::TopWindow::SetExitValue(EXIT_RESTART); UIActions::SignalShutdown(true); - - /* OpenVario: - Rotation is stored in config.uEnv - and so you should use the default - * Rotation */ - // Display::RotateRestore(); - Display::Rotate(DisplayOrientation::DEFAULT); } -#else - ShowMessageBox(_("Changes to configuration saved. Restart XCSoar to " - "apply changes."), - _T(""), MB_OK); -#endif } } From afe59a260b846b00dfd959984933d19ea28f1f4e Mon Sep 17 00:00:00 2001 From: August2111 Date: Sat, 13 Apr 2024 20:21:23 +0200 Subject: [PATCH 344/403] [OV] - Enable handler for Touch calibration, don't enable Touch if not avail --- src/OpenVario/DisplaySettingsWidget.cpp | 21 +++++++++++++++++---- src/OpenVario/System/OpenVarioDevice.cpp | 1 + src/OpenVario/System/OpenVarioDevice.hpp | 1 + 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/OpenVario/DisplaySettingsWidget.cpp b/src/OpenVario/DisplaySettingsWidget.cpp index 32a78196d9d..f84442ac491 100644 --- a/src/OpenVario/DisplaySettingsWidget.cpp +++ b/src/OpenVario/DisplaySettingsWidget.cpp @@ -9,6 +9,7 @@ #include "Form/DataField/Listener.hpp" #include "Form/DataField/Enum.hpp" #include "Form/DataField/Integer.hpp" +#include "Form/DataField/Boolean.hpp" #include "Hardware/DisplayDPI.hpp" #include "Hardware/DisplayGlue.hpp" #include "Hardware/RotateDisplay.hpp" @@ -52,6 +53,7 @@ enum ControlIndex { ROTATION, BRIGHTNESS, + TOUCH_SCREEN, TOUCH_CALIBRATION, @@ -79,11 +81,13 @@ class DisplaySettingsWidget final : public RowFormWidget, DataFieldListener { /* methods from DataFieldListener */ void OnModified(DataField &df) noexcept override; void RotateDisplay(DisplayOrientation orientation) noexcept; + void SetEnabled(bool enabled) noexcept; unsigned brightness = 0; unsigned rotation = 0; ContainerWindow* parent; + }; void DisplaySettingsWidget::RotateDisplay( @@ -91,8 +95,11 @@ void DisplaySettingsWidget::RotateDisplay( ovdevice.SetRotation(orientation, 1); // internal rotation only } -void -DisplaySettingsWidget::OnModified([[maybe_unused]] DataField &df) noexcept +void DisplaySettingsWidget::SetEnabled([[maybe_unused]] bool enabled) noexcept { + SetRowEnabled(TOUCH_CALIBRATION, enabled); +} + +void DisplaySettingsWidget::OnModified([[maybe_unused]] DataField &df) noexcept { if (IsDataField(ROTATION, df)) { RotateDisplay((DisplayOrientation)((const DataFieldEnum &)df).GetValue()); @@ -100,6 +107,8 @@ DisplaySettingsWidget::OnModified([[maybe_unused]] DataField &df) noexcept auto new_brightness = ((const DataFieldInteger &)df).GetValue(); if (new_brightness != brightness) ovdevice.SetBrightness(new_brightness / 10); + } else if (IsDataField(TOUCH_SCREEN, df)) { + SetEnabled(((const DataFieldBoolean &)df).GetValue()); } } @@ -121,11 +130,14 @@ DisplaySettingsWidget::Prepare([[maybe_unused]] ContainerWindow &_parent, AddInteger(_("Brightness"), _("Brightness Display OpenVario"), _T("%d%%"), _T("%d%%"), 10, 100, 10, brightness, this); - AddButton(_("Calibrate Touch"), [this]() { + AddBoolean(_("Touch enabled"), _("Enabling the tTouch Screen"), ovdevice.touch, this); + + auto touchBtn = AddButton(_("Calibrate Touch"), [this]() { ContainerWindow::SetExitValue(LAUNCH_TOUCH_CALIBRATE); UIActions::SignalShutdown(true); return mrOK; }); + touchBtn->SetEnabled(ovdevice.touch); } bool @@ -140,7 +152,7 @@ DisplaySettingsWidget::Save([[maybe_unused]] bool &_changed) noexcept { // Now no restart necessary! // UI::TopWindow::SetExitValue(EXIT_NEWSTART); // require_restart = - changed = true; + changed = true; } if (SaveValueInteger(BRIGHTNESS, "Brightness", brightness)) { @@ -148,6 +160,7 @@ DisplaySettingsWidget::Save([[maybe_unused]] bool &_changed) noexcept { changed = true; } + changed |= SaveValue(TOUCH_SCREEN, "TouchScreen", ovdevice.touch, false); _changed = changed; return true; } diff --git a/src/OpenVario/System/OpenVarioDevice.cpp b/src/OpenVario/System/OpenVarioDevice.cpp index fe65100e51f..0e89b562778 100644 --- a/src/OpenVario/System/OpenVarioDevice.cpp +++ b/src/OpenVario/System/OpenVarioDevice.cpp @@ -165,6 +165,7 @@ void OpenVario_Device::ReadSettings() noexcept { #endif ReadBool(settings, "Enabled", enabled); + ReadBool(settings, "TouchScreen", touch); #ifdef _DEBUG ReadInteger(settings, "iTest", iTest); #endif diff --git a/src/OpenVario/System/OpenVarioDevice.hpp b/src/OpenVario/System/OpenVarioDevice.hpp index c2f859d3975..6088f3007a4 100644 --- a/src/OpenVario/System/OpenVarioDevice.hpp +++ b/src/OpenVario/System/OpenVarioDevice.hpp @@ -89,6 +89,7 @@ class OpenVario_Device { struct { bool enabled = true; + bool touch = false; unsigned brightness = 100; unsigned timeout = 5; DisplayOrientation rotation = DisplayOrientation::DEFAULT; From 150c5defeacd32d14164e117f649a82b43411ee7 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sat, 13 Apr 2024 20:24:59 +0200 Subject: [PATCH 345/403] [OV] Hide the OpenVarioTest page, use a define selection for Advanced Settings --- src/Dialogs/Settings/dlgConfiguration.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Dialogs/Settings/dlgConfiguration.cpp b/src/Dialogs/Settings/dlgConfiguration.cpp index 508d8dfadf6..ec33903e773 100644 --- a/src/Dialogs/Settings/dlgConfiguration.cpp +++ b/src/Dialogs/Settings/dlgConfiguration.cpp @@ -91,7 +91,7 @@ static ArrowPagerWidget *pager; static constexpr TabMenuPage basic_pages[] = { { N_("Site Files"), CreateSiteConfigPanel }, -#ifdef IS_OPENVARIO +#if defined(IS_OPENVARIO) && 0 // defined (__AUGUST__) { N_("TestOpenVario"), CreateSystemMenuWidget}, #endif { nullptr, nullptr } @@ -165,8 +165,10 @@ static constexpr TabMenuPage openvario_pages[] = { {N_("System Settings"), CreateSystemSettingsWidget}, {N_("Display Settings"), CreateDisplaySettingsWidget}, {N_("File Transfer"), CreateFileMenuWidget}, +#if 1 + // remove with better FW-Upgrade {N_("Advanced Menu (temp)"), CreateExtraWidget}, - // {N_("Advanced Settings (temp)"), CreateSystemMenuWidget}, +#endif { nullptr, nullptr } }; #endif From d55bfe8e9b1d2b59782b96b559082a80ee30693f Mon Sep 17 00:00:00 2001 From: August2111 Date: Sat, 13 Apr 2024 10:18:57 +0200 Subject: [PATCH 346/403] InputEventsSettings.cpp - if vario sound 0 and want to be increase set it to 2 * because the increase is an multiplier of 2 - with 0 it is not possible! --- src/Input/InputEventsSettings.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Input/InputEventsSettings.cpp b/src/Input/InputEventsSettings.cpp index 49c3241c55c..0bf2cc57079 100644 --- a/src/Input/InputEventsSettings.cpp +++ b/src/Input/InputEventsSettings.cpp @@ -41,7 +41,10 @@ InputEvents::eventSounds(const TCHAR *misc) settings.vario.volume = 1; // don't switch to off! // settings.vario.enabled = false; } else if (StringIsEqual(misc, _T("louder"))) { - settings.vario.volume = settings.vario.volume * 2; + if (settings.vario.volume > 0) + settings.vario.volume *= 2; + else + settings.vario.volume = 2; if (settings.vario.volume > 100) // settings.vario.max_volume) settings.vario.volume = 100; // settings.vario.enabled = false; From 64c02f88fed03253d1ebdb03eeb4ca3046ddbff0 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 19 Mar 2024 17:09:09 +0100 Subject: [PATCH 347/403] [build] [UTF8-Win] UNICODE - remove UNICODE, at last for WIN64 --- build/targets.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/targets.mk b/build/targets.mk index 83a5f43cd2b..709b1af1cad 100644 --- a/build/targets.mk +++ b/build/targets.mk @@ -455,7 +455,7 @@ endif ifeq ($(HAVE_MSVCRT),y) TARGET_CPPFLAGS += -DHAVE_MSVCRT - TARGET_CPPFLAGS += -DUNICODE -D_UNICODE + # TARGET_CPPFLAGS += -DUNICODE -D_UNICODE TARGET_CPPFLAGS += -DSTRICT endif From db467863713105ce29eb059368646a657bd999da Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 15 Apr 2024 13:57:44 +0200 Subject: [PATCH 348/403] [CMake] [UTF8-Win] UNICODE - remove UNICODE, at last for WIN64 --- build/cmake/WinMSVC.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build/cmake/WinMSVC.cmake b/build/cmake/WinMSVC.cmake index e6e64d5ee47..78d3406759e 100644 --- a/build/cmake/WinMSVC.cmake +++ b/build/cmake/WinMSVC.cmake @@ -21,8 +21,9 @@ if(AUGUST_SPECIAL) endif() #******************************************************************************** -add_compile_definitions(_UNICODE) -add_compile_definitions(UNICODE) # ??? +## add_compile_definitions(_UNICODE) +## add_compile_definitions(UNICODE) # ??? + add_compile_definitions(NO_ERROR_CHECK) # EnumBitSet funktioniert m.E. noch nicht korrekt!!!! add_compile_definitions(WIN32_LEAN_AND_MEAN) # warning C4996: 'xxx': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _wcsdup. See online help for details. From 58a46099e08775c3f72a7bd1a5617ef7e0248eec Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 20 Mar 2024 09:57:45 +0100 Subject: [PATCH 349/403] [UTF8-Win] Args.hpp - if not UNICODE tchar.h is missing on _WIN32 --- src/system/Args.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/system/Args.hpp b/src/system/Args.hpp index 9e60ca71207..d0570fedf96 100644 --- a/src/system/Args.hpp +++ b/src/system/Args.hpp @@ -10,6 +10,8 @@ #ifdef _UNICODE #include "system/ConvertPathName.hpp" +#else +#include #endif #include From f2e3da8929d404e5b8dd4caebb9264ac42037034 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 2 Apr 2024 13:00:28 +0200 Subject: [PATCH 350/403] [UTF8-Win] StaticString.hxx - removing _UNICODE there is to include StringCompare.hxx --- src/util/StaticString.hxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/StaticString.hxx b/src/util/StaticString.hxx index d018203676d..6af2a61b99c 100644 --- a/src/util/StaticString.hxx +++ b/src/util/StaticString.hxx @@ -7,6 +7,7 @@ #include "StringAPI.hxx" #include "StringUtil.hpp" #include "StringFormat.hpp" +#include "StringCompare.hxx" #include "UTF8.hpp" #include "ASCII.hxx" @@ -15,8 +16,7 @@ #include #ifdef _UNICODE -#include -#include "WStringCompare.hxx" +# include #endif bool From 87c696bc4a8c695352db63ad471f0ffdb3fafd3a Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 26 Mar 2024 08:43:13 +0100 Subject: [PATCH 351/403] [UTF8-Win] NON-UNICODE - add to functions: ToUTF8 and FromUTF8 --- src/util/UTF8Win.cpp | 36 ++++++++++++++++++++++++++++++++++++ src/util/UTF8Win.hpp | 16 ++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 src/util/UTF8Win.cpp create mode 100644 src/util/UTF8Win.hpp diff --git a/src/util/UTF8Win.cpp b/src/util/UTF8Win.cpp new file mode 100644 index 00000000000..e54caba84be --- /dev/null +++ b/src/util/UTF8Win.cpp @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project + +#include "UTF8.hpp" + +#ifdef _WIN32 +/* ATTENTION : codevct is dprecated with C++ 17 (and C++ 20) - what is +* the replacement for? */ +# include +# include +# include +#endif + +#ifdef _WIN32 + +std::string +ToUTF8(const std::string &str, const std::locale &loc) +{ + using wcvt = std::wstring_convert, char32_t>; + std::u32string wstr(str.size(), U'\0'); + std::use_facet>(loc).widen( + str.data(), str.data() + str.size(), &wstr[0]); + return wcvt{}.to_bytes(wstr.data(), wstr.data() + wstr.size()); +} + +std::string +FromUTF8(const std::string &str, const std::locale &loc) +{ + using wcvt = std::wstring_convert, char32_t>; + auto wstr = wcvt{}.from_bytes(str); + std::string result(wstr.size(), '0'); + std::use_facet>(loc).narrow( + wstr.data(), wstr.data() + wstr.size(), '?', &result[0]); + return result; +} +#endif \ No newline at end of file diff --git a/src/util/UTF8Win.hpp b/src/util/UTF8Win.hpp new file mode 100644 index 00000000000..055100483d3 --- /dev/null +++ b/src/util/UTF8Win.hpp @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The XCSoar Project + +#pragma once + + +#ifdef _WIN32 +// #include +#include +#include + +std::string ToUTF8(const std::string &str, + const std::locale &loc = std::locale{}); +std::string FromUTF8(const std::string &str, + const std::locale &loc = std::locale{}); +#endif \ No newline at end of file From 8ab135b7cc5236563c1b310848ce09fe936f54d0 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 15 Apr 2024 13:59:05 +0200 Subject: [PATCH 352/403] [build] NON-UNICODE - add to functions: ToUTF8 and FromUTF8 --- build/libutil.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build/libutil.mk b/build/libutil.mk index 7a5ea62d64a..1e93b405b4b 100644 --- a/build/libutil.mk +++ b/build/libutil.mk @@ -18,8 +18,11 @@ UTIL_SOURCES = \ $(UTIL_SRC_DIR)/StringStrip.cxx \ $(UTIL_SRC_DIR)/StringUtil.cpp + ifeq ($(HAVE_MSVCRT),y) UTIL_SOURCES += \ + $(UTIL_SRC_DIR)/UTF8Win.cpp \ + \ $(UTIL_SRC_DIR)/WASCII.cxx \ $(UTIL_SRC_DIR)/WStringCompare.cpp \ $(UTIL_SRC_DIR)/WStringStrip.cxx \ From f0d239b51da86660d95b5fcd15f8ee0a0a898414 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sun, 14 Apr 2024 16:22:03 +0200 Subject: [PATCH 353/403] [build] build/libutil.mk - formating --- build/libutil.mk | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build/libutil.mk b/build/libutil.mk index 1e93b405b4b..ac0dd04782b 100644 --- a/build/libutil.mk +++ b/build/libutil.mk @@ -18,11 +18,10 @@ UTIL_SOURCES = \ $(UTIL_SRC_DIR)/StringStrip.cxx \ $(UTIL_SRC_DIR)/StringUtil.cpp - ifeq ($(HAVE_MSVCRT),y) UTIL_SOURCES += \ $(UTIL_SRC_DIR)/UTF8Win.cpp \ - \ + \ $(UTIL_SRC_DIR)/WASCII.cxx \ $(UTIL_SRC_DIR)/WStringCompare.cpp \ $(UTIL_SRC_DIR)/WStringStrip.cxx \ From 01ddbaac423f5272d08c8af9a0457f45cab53e8d Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 15 Apr 2024 13:59:40 +0200 Subject: [PATCH 354/403] [CMake] NON-UNICODE - add to functions: ToUTF8 and FromUTF8 --- src/util/CMakeSource.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/util/CMakeSource.cmake b/src/util/CMakeSource.cmake index e039024d26a..7c034b0c91d 100644 --- a/src/util/CMakeSource.cmake +++ b/src/util/CMakeSource.cmake @@ -22,6 +22,8 @@ if(WIN32) util/WStringCompare.cxx util/WStringStrip.cxx util/WStringUtil.cpp + + util/UTF8Win.cpp ) endif() From f9b19e6f69a755722c1b982e33c12415775958d7 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 28 Mar 2024 12:14:20 +0100 Subject: [PATCH 355/403] [UTF8-Win] ui/canvas/gdi/Canvas - change drawing text to displaying utf-8 strings Extend parameter name 't' to better a description 'text' --- src/ui/canvas/gdi/Canvas.cpp | 32 ++++++++++++++++++++++++-------- src/ui/canvas/gdi/Canvas.hpp | 13 +++++-------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/ui/canvas/gdi/Canvas.cpp b/src/ui/canvas/gdi/Canvas.cpp index 413b130af1f..b4f911d0f80 100644 --- a/src/ui/canvas/gdi/Canvas.cpp +++ b/src/ui/canvas/gdi/Canvas.cpp @@ -10,6 +10,15 @@ #include +#include "util/UTF8Win.hpp" + + +static bool UTF8TextOut(HDC hdc, const PixelPoint &p, unsigned options, const RECT *lprect, + tstring_view lpString, const int *lpDx) { + std::string text = FromUTF8(lpString.data()); + return ::ExtTextOut(hdc, p.x, p.y, options, lprect, text.data(), text.size(), lpDx); +} + void Canvas::DrawLine(int ax, int ay, int bx, int by) { @@ -87,10 +96,12 @@ Canvas::DrawArc(PixelPoint center, unsigned radius, } const PixelSize -Canvas::CalcTextSize(tstring_view text) const noexcept +Canvas::CalcTextSize(tstring_view _text) const noexcept { assert(IsDefined()); + tstring_view text = FromUTF8(_text.data()); + SIZE size; ::GetTextExtentPoint(dc, text.data(), text.size(), &size); return PixelSize(size.cx, size.cy); @@ -111,7 +122,7 @@ Canvas::DrawText(PixelPoint p, tstring_view text) noexcept { assert(IsDefined()); - ::ExtTextOut(dc, p.x, p.y, 0, nullptr, text.data(), text.size(), nullptr); + UTF8TextOut(dc, p, 0, nullptr, text, nullptr); } void @@ -121,8 +132,7 @@ Canvas::DrawOpaqueText(PixelPoint p, const PixelRect &_rc, assert(IsDefined()); RECT rc = _rc; - ::ExtTextOut(dc, p.x, p.y, ETO_OPAQUE, &rc, - text.data(), text.size(), nullptr); + UTF8TextOut(dc, p, ETO_OPAQUE, &rc, text,nullptr); } void @@ -132,8 +142,7 @@ Canvas::DrawClippedText(PixelPoint p, const PixelRect &_rc, assert(IsDefined()); RECT rc = _rc; - ::ExtTextOut(dc, p.x, p.y, ETO_CLIPPED, &rc, - text.data(), text.size(), nullptr); + UTF8TextOut(dc, p, ETO_CLIPPED, &rc, text, nullptr); } void @@ -145,8 +154,7 @@ Canvas::DrawClippedText(PixelPoint p, unsigned width, RECT rc; ::SetRect(&rc, p.x, p.y, p.x + std::min(width, size.width), p.y + size.height); - ::ExtTextOut(dc, p.x, p.y, ETO_CLIPPED, &rc, - text.data(), text.size(), nullptr); + UTF8TextOut(dc, p, ETO_CLIPPED, &rc, text,nullptr); } void @@ -324,3 +332,11 @@ Canvas::AlphaBlend(PixelPoint dest_position, PixelSize dest_size, } #endif + +unsigned +Canvas::DrawFormattedText(RECT rc, tstring_view _text, unsigned format) { + format |= DT_NOPREFIX | DT_WORDBREAK; + std::string text = FromUTF8(_text.data()); + ::DrawText(dc, text.data(), text.size(), &rc, format); + return rc.bottom - rc.top; +} diff --git a/src/ui/canvas/gdi/Canvas.hpp b/src/ui/canvas/gdi/Canvas.hpp index ea16083c437..ddc575d3d15 100644 --- a/src/ui/canvas/gdi/Canvas.hpp +++ b/src/ui/canvas/gdi/Canvas.hpp @@ -227,7 +227,8 @@ class Canvas { const RECT rc = _rc; /* this hack allows filling a rectangle with a solid color, - without the need to create a HBRUSH */ + * without the need to create a HBRUSH + * Here is no need to use UTF8TextOut - because all strings are empty */ ::SetBkColor(dc, color); ::ExtTextOut(dc, rc.left, rc.top, ETO_OPAQUE, &rc, _T(""), 0, nullptr); } @@ -380,15 +381,11 @@ class Canvas { /** * Render text, clip it within the bounds of this Canvas. */ - void TextAutoClipped(PixelPoint p, tstring_view t) noexcept { - DrawText(p, t); + void TextAutoClipped(PixelPoint p, tstring_view text) noexcept { + DrawText(p, text); } - unsigned DrawFormattedText(RECT rc, tstring_view text, unsigned format) { - format |= DT_NOPREFIX | DT_WORDBREAK; - ::DrawText(dc, text.data(), text.size(), &rc, format); - return rc.bottom - rc.top; - } + unsigned DrawFormattedText(RECT rc, tstring_view _text, unsigned format); void Copy(PixelPoint dest_position, PixelSize dest_size, HDC src, PixelPoint src_position, From fe569442e0e749c6071a429d2c1344fef055fa2b Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 2 Apr 2024 11:35:34 +0200 Subject: [PATCH 356/403] [UTF8-Win] Language.cpp - gettext for _WIN32 w/o _UNICODE --- src/Language/Language.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Language/Language.cpp b/src/Language/Language.cpp index be0fbbb2c71..1b84d518860 100644 --- a/src/Language/Language.cpp +++ b/src/Language/Language.cpp @@ -112,9 +112,13 @@ gettext(const TCHAR* text) // Search for the english original string in the MO file const char *translation = mo_file->lookup(text); // Return either the translated string if found or the original - return translation != NULL && *translation != 0 && ValidateUTF8(translation) - ? translation - : text; +#if defined(_WIN32) + return translation != nullptr && *translation != 0 ? + translation : text; +#else + return translation != nullptr && *translation != 0 && + ValidateUTF8(translation) ? translation : text; +#endif #endif } From d640238110c2f080fadec88d05e1fb1587f88c00 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 2 Apr 2024 12:55:27 +0200 Subject: [PATCH 357/403] [UTF8-Win] PortDataField.cpp - with Windows there is a switchable std::string / std::wstring needed --- src/Dialogs/Device/PortDataField.cpp | 41 +++++++++++----------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/src/Dialogs/Device/PortDataField.cpp b/src/Dialogs/Device/PortDataField.cpp index fd3928b94ce..2d780bdbe66 100644 --- a/src/Dialogs/Device/PortDataField.cpp +++ b/src/Dialogs/Device/PortDataField.cpp @@ -16,6 +16,11 @@ # include "util/StringFormat.hpp" # include # include +#ifdef _UNICODE + typedef std::wstring tstring; +#else + typedef std::string tstring; +#endif #endif #ifdef ANDROID @@ -108,7 +113,7 @@ try { //------------------------------- RegistryKey bthenums{HKEY_LOCAL_MACHINE, _T("SYSTEM\\CurrentControlSet\\" "Enum\\BthEnum")}; - std::map bthmap; + std::map bthmap; for (unsigned k = 0;; ++k) { TCHAR dev_name[128]; TCHAR name[128]; @@ -116,7 +121,7 @@ try { if (!bthenums.EnumKey(k, std::span{dev_name})) break; - std::wstring map_name(dev_name); + tstring map_name(dev_name); if (!map_name.starts_with(_T("Dev_"))) continue; RegistryKey bthenum_dev{bthenums, dev_name}; @@ -127,14 +132,14 @@ try { if (!bthenum_key.GetValue(_T("FriendlyName"), friendly_name)) break; map_name = map_name.substr(4); - for (std::wstring::iterator it = map_name.begin(); it != map_name.end(); + for (tstring::iterator it = map_name.begin(); it != map_name.end(); ++it) *it = towlower(*it); bthmap[map_name] = friendly_name; // Left "Dev_" } RegistryKey bthle{HKEY_LOCAL_MACHINE, _T("SYSTEM\\CurrentControlSet\\" "Enum\\BthLE")}; - std::map blemap; + std::map blemap; for (unsigned k = 0;; ++k) { TCHAR dev_name[128]; TCHAR name[128]; @@ -142,7 +147,7 @@ try { if (!bthle.EnumKey(k, std::span{dev_name})) break; - std::wstring map_name(dev_name); + tstring map_name(dev_name); if (!map_name.starts_with(_T("Dev_"))) continue; RegistryKey bthle_dev{bthle, dev_name}; @@ -153,7 +158,7 @@ try { if (!bthle_key.GetValue(_T("FriendlyName"), friendly_name)) break; map_name = map_name.substr(4); - for (std::wstring::iterator it = map_name.begin(); it != map_name.end(); + for (tstring::iterator it = map_name.begin(); it != map_name.end(); ++it) *it = towlower(*it); blemap[map_name] = friendly_name; // Left "Dev_" @@ -188,19 +193,10 @@ try { // BlueTooth: "\\?\bthenum#" // USB: "\\?\usb#" // Normal: "\\?\acpi#" - an Kupschis Rechner! -#ifdef UNICODE - std::wstring dev = name1; -#else - std::string dev = name1; -#endif + tstring dev = name1; if (dev.starts_with(_T("\\\\?\\usb#"))) { -#ifdef UNICODE - std::vector strs; - std::wstring port_name; -#else - std::vector strs; - std::string port_name; -#endif + std::vector strs; + tstring port_name; boost::split(strs, name, boost::is_any_of("\\")); port_name = value; port_name += _T(" ("); @@ -209,13 +205,8 @@ try { AddPort(df, DeviceConfig::PortType::USB_SERIAL, value, port_name.c_str()); } else if (dev.starts_with(_T("\\\\?\\bthenum#"))) { -#ifdef UNICODE - std::vector strs; - std::wstring port_name; -#else - std::vector strs; - std::string port_name; -#endif + std::vector strs; + tstring port_name; boost::split(strs, name1, boost::is_any_of("#")); boost::split(strs, strs[2], boost::is_any_of("_")); if (strs[1] == _T("c00000000")) { From e7aae01f7db9cac0e4d605fd5b7739f06b7d3bfd Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 5 Apr 2024 21:33:13 +0200 Subject: [PATCH 358/403] [UTF8-Win] reduce to only one important function 'UTF8ToWide' - maybe move this to UTF8.cpp UTF8ToWide is very similar to the ConvertString functions... --- src/ui/canvas/gdi/Canvas.cpp | 35 ++++++++++++++++++++++++++--------- src/util/UTF8Win.cpp | 35 +++++++++-------------------------- src/util/UTF8Win.hpp | 6 ++---- 3 files changed, 37 insertions(+), 39 deletions(-) diff --git a/src/ui/canvas/gdi/Canvas.cpp b/src/ui/canvas/gdi/Canvas.cpp index b4f911d0f80..3b88942fddf 100644 --- a/src/ui/canvas/gdi/Canvas.cpp +++ b/src/ui/canvas/gdi/Canvas.cpp @@ -12,11 +12,25 @@ #include "util/UTF8Win.hpp" - -static bool UTF8TextOut(HDC hdc, const PixelPoint &p, unsigned options, const RECT *lprect, - tstring_view lpString, const int *lpDx) { - std::string text = FromUTF8(lpString.data()); - return ::ExtTextOut(hdc, p.x, p.y, options, lprect, text.data(), text.size(), lpDx); +static bool UTF8TextOut(HDC hdc, const PixelPoint &p, unsigned options, const RECT *r, + tstring_view _text, const int *lpDx) { + auto text = UTF8ToWide(_text); +#if 1 + return ::ExtTextOutW(hdc, p.x, p.y, options, r, text.c_str(), text.size(), + lpDx); +#else + unsigned format = DT_NOPREFIX | DT_WORDBREAK | DT_LEFT; + RECT rx = {p.x, p.y, 0, 0}; + int h = 0; + if (r) + rx = {r->left + p.x, r->top + p.y, r->right - r->left, r->bottom - r->top}; + + // calculate the rectangle... + h = ::DrawTextW(hdc, text.c_str(), text.size(), &rx, DT_CALCRECT); + // and paint... + h = ::DrawTextW(hdc, text.c_str(), text.size(), &rx, format); + return true; +#endif } void @@ -100,10 +114,12 @@ Canvas::CalcTextSize(tstring_view _text) const noexcept { assert(IsDefined()); - tstring_view text = FromUTF8(_text.data()); + // tstring_view text = UTF8ToWide(_text.data()); + auto text = UTF8ToWide(_text); + // std::wstring text = UTF8ToWide(_text.data()); SIZE size; - ::GetTextExtentPoint(dc, text.data(), text.size(), &size); + ::GetTextExtentPointW(dc, text.c_str(), text.size(), &size); return PixelSize(size.cx, size.cy); } @@ -336,7 +352,8 @@ Canvas::AlphaBlend(PixelPoint dest_position, PixelSize dest_size, unsigned Canvas::DrawFormattedText(RECT rc, tstring_view _text, unsigned format) { format |= DT_NOPREFIX | DT_WORDBREAK; - std::string text = FromUTF8(_text.data()); - ::DrawText(dc, text.data(), text.size(), &rc, format); + auto text = UTF8ToWide(_text); + + ::DrawTextW(dc, text.data(), text.size(), &rc, format); return rc.bottom - rc.top; } diff --git a/src/util/UTF8Win.cpp b/src/util/UTF8Win.cpp index e54caba84be..42c2add7458 100644 --- a/src/util/UTF8Win.cpp +++ b/src/util/UTF8Win.cpp @@ -2,35 +2,18 @@ // Copyright The XCSoar Project #include "UTF8.hpp" +#include "LogFile.hpp" #ifdef _WIN32 -/* ATTENTION : codevct is dprecated with C++ 17 (and C++ 20) - what is -* the replacement for? */ -# include -# include -# include -#endif - -#ifdef _WIN32 +#include -std::string -ToUTF8(const std::string &str, const std::locale &loc) +std::wstring +UTF8ToWide(const std::string_view s) { - using wcvt = std::wstring_convert, char32_t>; - std::u32string wstr(str.size(), U'\0'); - std::use_facet>(loc).widen( - str.data(), str.data() + str.size(), &wstr[0]); - return wcvt{}.to_bytes(wstr.data(), wstr.data() + wstr.size()); + int length = MultiByteToWideChar(CP_UTF8, 0, s.data(), s.size() + 1, nullptr, 0); + std::wstring w(length + 1, L'\0'); + MultiByteToWideChar(CP_UTF8, 0, s.data(), s.size() + 1, w.data(), length); + return w; } -std::string -FromUTF8(const std::string &str, const std::locale &loc) -{ - using wcvt = std::wstring_convert, char32_t>; - auto wstr = wcvt{}.from_bytes(str); - std::string result(wstr.size(), '0'); - std::use_facet>(loc).narrow( - wstr.data(), wstr.data() + wstr.size(), '?', &result[0]); - return result; -} -#endif \ No newline at end of file +#endif diff --git a/src/util/UTF8Win.hpp b/src/util/UTF8Win.hpp index 055100483d3..88c60d6ed1e 100644 --- a/src/util/UTF8Win.hpp +++ b/src/util/UTF8Win.hpp @@ -9,8 +9,6 @@ #include #include -std::string ToUTF8(const std::string &str, - const std::locale &loc = std::locale{}); -std::string FromUTF8(const std::string &str, - const std::locale &loc = std::locale{}); +std::wstring UTF8ToWide(const std::string_view s); + #endif \ No newline at end of file From 215357910c41cdea32d071f3432b0ffab1a4c42b Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 11 Apr 2024 10:59:38 +0200 Subject: [PATCH 359/403] (Pre-)Release v7.42.22.A --- OpenSoar-News.md | 55 ++++++++++++++++++++++++++--- OpenSoar.config | 4 +-- android/AndroidManifest.xml | 4 +-- android/testing/AndroidManifest.xml | 4 +-- 4 files changed, 56 insertions(+), 11 deletions(-) diff --git a/OpenSoar-News.md b/OpenSoar-News.md index 0722b7a5a05..127f15dc74d 100644 --- a/OpenSoar-News.md +++ b/OpenSoar-News.md @@ -1,12 +1,57 @@ -OpenSoar Version 7.41.21.1 - not yet released +OpenSoar Version 7.42.22 - not yet released --------------- + +OpenSoar Version 7.42.22.A - 2024/04/xx +--------------- +* System: add possibility to restart OpenSoar without exit to system * TCP Port - Bugfix on closing the TCP client as receiver on this port: By closing the receiver OpenSoar crashed! -* End of program with (short) restart, reboot, shutdown and normal program end -* OpenVario menu inserted +* End of program with (short) restart, newstart, reboot, shutdown and normal program end +* QuickMenu extended with + - Volume control + - several program ends (Reboot, Restart) +* User interface + - create a (simple) audio volume control menu (similar to the OpenVario control) +* Setup Menu + - add OpenVario menu (see next item) +* NMEA Settings: Better shows which USB or Bluetooth device is in use for serial devices on Windows (similar to Android) * OpenVario: - - WiFi selection -* start with OpenVarioBaseMenu, but hidden for normal user only + - WiFi selection, setting and enabling + - OpenVario menu inserted with + - (OpenVario) 'System Settings': Firmware, SensorD, VarioD, SSH, Wifi, Sensor Calibration + - 'Display Settings': (Device!) Rotation, Brightness, Touch Calibration + - 'File Transfer': IGC, OpenSoar data, system data + - split default.xci to defaultOV.xci +* Simulator: remove SIM option from standard, further available with option '-simulator' only +* Development + - rename src folder 'OV' in 'OpenVario' + - remove UNICODE define at Windows + - the 1st step before removing all UNICODE code parts, TCHAR, tstring + - all string handler works with UTF-8, also Windows too +* Bugfix: + - Display rotation on OpenVario on setting +* Open Issues + - Display rotation on Linux! + +#### XCSoar Version 7.42 - 2024/03/01 +* merge xcsoar 7.42 '9ee29aa606' +* ui + - new terrain ramp High Contrast + - fix unreadable icons in task manager and status dialog + - render icons at 300 dpi +* data files + - fix bogus "Latin-1 to UTF-8 conversion failed" error + - parse elevations in feet correctly in cup files + - ignore unit for radio frequency in airspace files +* devices + - validate wind direction +* Kobo + - Wifi setup, display signal level in dBm for new models + - scale icons on hi-dpi displays (e.g. Clara HD) +* user interface + - new mountain pass and bridge icons +* Android + - update 'white list' of USB devices with more PIDs for SoftRF Academy OpenSoar Version 7.41.21 - 2023/12/28 --------------- diff --git a/OpenSoar.config b/OpenSoar.config index a379ae2d6a0..8b890ab7191 100644 --- a/OpenSoar.config +++ b/OpenSoar.config @@ -1,4 +1,4 @@ PROGRAM_NAME=OpenSoar -PROGRAM_VERSION=7.42.21.3 -ANDROID_VERSIONCODE=21 +PROGRAM_VERSION=7.42.22.A +ANDROID_VERSIONCODE=22 ANDROID_PACKAGE=de.opensoar diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 84a6c90a982..3384e19b175 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -2,8 +2,8 @@ + android:versionCode="22" + android:versionName="7.42.22"> + android:versionCode="22" + android:versionName="7.42.22"> Date: Tue, 16 Apr 2024 18:50:53 +0200 Subject: [PATCH 360/403] Profile/InfoBoxConfig.cpp - missing switch case TOP_16_VARIO --- src/Profile/InfoBoxConfig.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Profile/InfoBoxConfig.cpp b/src/Profile/InfoBoxConfig.cpp index 5cfb46c4f69..7024d8490c1 100644 --- a/src/Profile/InfoBoxConfig.cpp +++ b/src/Profile/InfoBoxConfig.cpp @@ -99,6 +99,7 @@ Profile::Load(const ProfileMap &map, InfoBoxSettings &settings) case InfoBoxSettings::Geometry::TOP_8_VARIO_BOTTOM_5: case InfoBoxSettings::Geometry::TOP_8_VARIO_BOTTOM_10: case InfoBoxSettings::Geometry::TOP_12_VARIO: + case InfoBoxSettings::Geometry::TOP_16_VARIO: break; case InfoBoxSettings::Geometry::OBSOLETE_TOP_LEFT_4: From 749bb040b551f9139159871aecfe23cfc23129b2 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 16 Apr 2024 19:18:47 +0200 Subject: [PATCH 361/403] Dialogs/NumberEntry.cpp - display enum type DATA_ANGLE --- src/Dialogs/NumberEntry.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Dialogs/NumberEntry.cpp b/src/Dialogs/NumberEntry.cpp index dd5fe095202..46c1a0ba5bb 100644 --- a/src/Dialogs/NumberEntry.cpp +++ b/src/Dialogs/NumberEntry.cpp @@ -35,6 +35,7 @@ NumberEntryDialog(TWidgetDialog &dialog, entry->CreateSigned(client_area, client_area.GetClientRect(), control_style, length, 0); break; + case DATA_ANGLE: // TODO(August2111): check of correctness case DATA_UNSIGNED: entry->CreateUnsigned(client_area, client_area.GetClientRect(), control_style, length, 0); From 51b227e1c8b8866dbc4f7ef60bb061ab29b4f981 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 16 Apr 2024 09:54:42 +0200 Subject: [PATCH 362/403] Input/InputEventsActions.cpp - bugfix: use typedef const TCHAR*' insted of 'char*' --- src/Input/InputEventsActions.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Input/InputEventsActions.cpp b/src/Input/InputEventsActions.cpp index de1569aa01c..18980744a54 100644 --- a/src/Input/InputEventsActions.cpp +++ b/src/Input/InputEventsActions.cpp @@ -664,33 +664,33 @@ void InputEvents::eventKeyPressed(const TCHAR *misc) { // std::map keys; - for (char *p = (char *)misc; *p != 0; p++) { + for (auto *p = misc; *p != 0; p++) { if (*p != ' ') { - char c[2] = {*p, 0}; + TCHAR c[2] = {*p, 0}; if (!strncmp(p, "LEFT", strlen("LEFT"))) { - c[0] = KEY_LEFT; + c[0] = (TCHAR) KEY_LEFT; p += strlen("LEFT") ; } else if (!strncmp(p, "RIGHT", strlen("RIGHT"))) { - c[0] = KEY_RIGHT; + c[0] = (TCHAR) KEY_RIGHT; p += strlen("RIGHT") ; } else if (!strncmp(p, "UP", strlen("UP"))) { - c[0] = KEY_UP; + c[0] = (TCHAR) KEY_UP; p += strlen("UP") ; } else if (!strncmp(p, "DOWN", strlen("DOWN"))) { - c[0] = KEY_DOWN; + c[0] = (TCHAR) KEY_DOWN; p += strlen("DOWN") ; } else if (!strncmp(p, "ESCAPE", strlen("ESCAPE"))) { - c[0] = KEY_ESCAPE; + c[0] = (TCHAR) KEY_ESCAPE; p += strlen("ESCAPE") ; } else if (!strncmp(p, "ENTER", strlen("ENTER"))) { - c[0] = KEY_RETURN; + c[0] = (TCHAR) KEY_RETURN; p += strlen("ENTER") ; } else if (!strncmp(p, "RETURN", strlen("RETURN"))) { - c[0] = KEY_RETURN; + c[0] = (TCHAR) KEY_RETURN; p += strlen("RETURN") ; } ParseKeyCode(c); - } + } } } #endif From 34c45c393b8b2ea49b36f141d5594130edf76bde Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 16 Apr 2024 17:10:50 +0200 Subject: [PATCH 363/403] InputEventsActions.cpp - process the parsed key to the system --- src/Input/InputEventsActions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Input/InputEventsActions.cpp b/src/Input/InputEventsActions.cpp index 18980744a54..0ae903c2340 100644 --- a/src/Input/InputEventsActions.cpp +++ b/src/Input/InputEventsActions.cpp @@ -689,7 +689,7 @@ InputEvents::eventKeyPressed(const TCHAR *misc) c[0] = (TCHAR) KEY_RETURN; p += strlen("RETURN") ; } - ParseKeyCode(c); + ProcessKey(MODE_MENU, ParseKeyCode((const TCHAR *)c)); } } } From 20eed379dd300d73af565467836a53f12c8655a0 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 16 Apr 2024 19:59:15 +0200 Subject: [PATCH 364/403] system/Process.cpp - remove unnecessary function declaration Windows: in Start function use the parameter argv (bugfix unused parameter) --- src/system/Process.cpp | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/src/system/Process.cpp b/src/system/Process.cpp index 06b8b033da1..27871e47a2d 100644 --- a/src/system/Process.cpp +++ b/src/system/Process.cpp @@ -103,14 +103,18 @@ Start(const char *const *argv) noexcept return Wait(pid) == 0; #elif defined(_WIN32) + LogFormat("Process.cpp - on Windows no Start() function"); + for (unsigned count = 0; argv[count] != nullptr; count++) { + LogFormat("Process.cpp - Start, Arg %u: %s", count, argv[count]); + std::cout << argv[count] << ' '; + } + return false; #else error "Unknown system" #endif } -int Run(const char *const *argv) noexcept; - #define PROCESS_DEBUG_OUTPUT 0 int Run(const char *const *argv) noexcept @@ -151,36 +155,10 @@ try { return -1; } -#if 0 -int -// Run(std::filesystem::path output_path, const char *const *argv) noexcept { -// Run(const Path &output_path, const char *argv, ...) noexcept { -Run(const Path &output_path, const char *argv, ...) noexcept { - output = output_path; -#if 1 - const char *arglist[0x10]; - va_list argptr; - const char *arg = argv; - va_start(argptr, argv); - unsigned idx = 0; - while (arg != nullptr) { - arglist[idx++] = arg; - arg = va_arg(argptr, const char *); - } - // _Result = _vfprintf_l(stdout, argv, nullptr, _ArgList); - va_end(argptr); - arglist[idx] = nullptr; // finally -#else - const char *const arglist[]{argv, nullptr}; -#endif - return Run(arglist); -} -#else int Run(const Path &output_path, const char *const *argv) noexcept { output = output_path; return Run(argv); } -#endif \ No newline at end of file From b33ee1f2866364112c3e3e0c720cf75f462b7c36 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 16 Apr 2024 19:43:33 +0200 Subject: [PATCH 365/403] [Workaround] StringCompare.hxx - StringIsEqual with string_view is in (older?) targets ambiguous with StringIsEqual with const char* --- src/util/StringCompare.hxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util/StringCompare.hxx b/src/util/StringCompare.hxx index 579752187cf..76b1a39d30e 100644 --- a/src/util/StringCompare.hxx +++ b/src/util/StringCompare.hxx @@ -18,6 +18,8 @@ StringIsEmpty(const char *string) noexcept return *string == 0; } +#if 0 // ambiguous with StringAPI.hpp->StringIsEqual(const char *a, const char *b) +// TODO(August2111) - at the end this should be the used function [[gnu::pure]] static inline bool StringIsEqual(std::string_view a, std::string_view b) noexcept @@ -25,6 +27,7 @@ StringIsEqual(std::string_view a, std::string_view b) noexcept return a.size() == b.size() && StringIsEqual(a.data(), b.data(), b.size()); } +#endif [[gnu::pure]] static inline bool From 199f373e410fcae5c5b1be5815905ecef62c0d8b Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 16 Apr 2024 20:55:48 +0200 Subject: [PATCH 366/403] [Bugfix] for developing: with Kobo the this pointer in this call has to be used --- src/Form/Form.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Form/Form.hpp b/src/Form/Form.hpp index 89f98ffda2d..c8a7eb5d791 100644 --- a/src/Form/Form.hpp +++ b/src/Form/Form.hpp @@ -143,7 +143,7 @@ class WndForm : public ContainerWindow auto SetFocusButtonCallback(Button *button) noexcept { return [this, button]() { - if (button) + if (this->IsDefined() && button != nullptr) button->SetFocus(); }; } From ecac21d648314cc9d939e186e30e51bc2aee63f0 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 17 Apr 2024 16:49:43 +0200 Subject: [PATCH 367/403] [WorkAround] call of NMEAChecksum in MacOS makes problems --- src/Device/Util/NMEAReader.cpp | 5 +++++ src/NMEA/Checksum.cpp | 10 ++++++++++ src/NMEA/Checksum.hpp | 5 +++++ test/src/AddChecksum.cpp | 5 +++++ 4 files changed, 25 insertions(+) diff --git a/src/Device/Util/NMEAReader.cpp b/src/Device/Util/NMEAReader.cpp index 8b4344a043e..a3a18af6e0d 100644 --- a/src/Device/Util/NMEAReader.cpp +++ b/src/Device/Util/NMEAReader.cpp @@ -50,7 +50,12 @@ PortNMEAReader::GetLine() /* verify the checksum following the asterisk (two hex digits) */ +#if defined(__APPLE__) && (!defined(TARGET_OS_IPHONE) || !TARGET_OS_IPHONE) + // MacOS workaround + const uint8_t calculated_checksum = NMEAChecksum(start); +#else // MacOS const uint8_t calculated_checksum = NMEAChecksum({start, asterisk}); +#endif // MacOS const char checksum_buffer[3] = { asterisk[1], asterisk[2], 0 }; char *endptr; diff --git a/src/NMEA/Checksum.cpp b/src/NMEA/Checksum.cpp index 2737f55b57c..70dd3174020 100644 --- a/src/NMEA/Checksum.cpp +++ b/src/NMEA/Checksum.cpp @@ -25,7 +25,12 @@ VerifyNMEAChecksum(const char *p) noexcept return false; uint8_t ReadCheckSum = (unsigned char)ReadCheckSum2; +#if defined(__APPLE__) && (!defined(TARGET_OS_IPHONE) || !TARGET_OS_IPHONE) + // MacOS workaround + uint8_t CalcCheckSum = NMEAChecksum(p); +#else // MacOS uint8_t CalcCheckSum = NMEAChecksum({p, asterisk}); +#endif // MacOS return CalcCheckSum == ReadCheckSum; } @@ -37,5 +42,10 @@ AppendNMEAChecksum(char *p) noexcept const std::size_t length = strlen(p); +#if defined(__APPLE__) && (!defined(TARGET_OS_IPHONE) || !TARGET_OS_IPHONE) + // MacOS workaround + sprintf(p + length, "*%02X", NMEAChecksum(p)); +#else // MacOS sprintf(p + length, "*%02X", NMEAChecksum({p, length})); +#endif // MacOS } diff --git a/src/NMEA/Checksum.hpp b/src/NMEA/Checksum.hpp index cb0e8577958..c5806e83fdc 100644 --- a/src/NMEA/Checksum.hpp +++ b/src/NMEA/Checksum.hpp @@ -25,7 +25,12 @@ NMEAChecksum(std::convertible_to auto &&_src) noexcept if (*p == '$' || *p == '!') ++p; +#if defined(__APPLE__) && (!defined(TARGET_OS_IPHONE) || !TARGET_OS_IPHONE) + // MacOS workaround + while (*p != 0 && *p != '*') +#else // MACOS while (*p != 0) +#endif // MACOS checksum ^= static_cast(*p++); return checksum; diff --git a/test/src/AddChecksum.cpp b/test/src/AddChecksum.cpp index 4df3bb79ce7..1584533d0e2 100644 --- a/test/src/AddChecksum.cpp +++ b/test/src/AddChecksum.cpp @@ -26,7 +26,12 @@ int main() } printf("%.*s*%02x\n", (int)(end - buffer), buffer, +#if defined(__APPLE__) && (!defined(TARGET_OS_IPHONE) || !TARGET_OS_IPHONE) + // MacOS workaround + NMEAChecksum(start)); +#else // MacOS NMEAChecksum({start, end})); +#endif // MacOS } return 0; From e09478c695ae29112296021c479de3ea3cc25218 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sat, 20 Apr 2024 13:21:12 +0200 Subject: [PATCH 368/403] Device/Port/ConfiguredPort.cpp - WindowsPort(..) is a static function --- src/Device/Port/ConfiguredPort.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Device/Port/ConfiguredPort.cpp b/src/Device/Port/ConfiguredPort.cpp index c58103785f0..1e10d86f962 100644 --- a/src/Device/Port/ConfiguredPort.cpp +++ b/src/Device/Port/ConfiguredPort.cpp @@ -64,8 +64,7 @@ WrapPort(const DeviceConfig &config, PortListener *listener, } #if defined(_WIN32) -//void -const TCHAR * +static const TCHAR * WindowsPort(TCHAR buffer[], const DeviceConfig &config) { if (config.path.empty()) throw std::runtime_error("No port path configured"); From 1d533c208f7d1c0afcfde3c7522de123f71208b5 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sun, 21 Apr 2024 22:16:02 +0200 Subject: [PATCH 369/403] Dialogs/Device/PortDataField.cpp - remove unused 'type1' --- src/Dialogs/Device/PortDataField.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Dialogs/Device/PortDataField.cpp b/src/Dialogs/Device/PortDataField.cpp index 2d780bdbe66..a53a68ff3f6 100644 --- a/src/Dialogs/Device/PortDataField.cpp +++ b/src/Dialogs/Device/PortDataField.cpp @@ -185,7 +185,6 @@ try { "Control\\COM Name Arbiter\\Devices")}; TCHAR name1[0x200]; - DWORD type1; if (!devices.GetValue(value, name1)) break; From 8a96ea6d0cae91e6df606c4744a7de723923b564 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sat, 20 Apr 2024 17:24:01 +0200 Subject: [PATCH 370/403] GdiPlusBitmap.cpp - needs a wide string (not an utf-8) --- src/ui/canvas/gdi/GdiPlusBitmap.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ui/canvas/gdi/GdiPlusBitmap.cpp b/src/ui/canvas/gdi/GdiPlusBitmap.cpp index 047772492f0..7c614be28f5 100644 --- a/src/ui/canvas/gdi/GdiPlusBitmap.cpp +++ b/src/ui/canvas/gdi/GdiPlusBitmap.cpp @@ -9,6 +9,9 @@ using std::min; // to avoid the missing 'min' in the gdiplush headers using std::max; // to avoid the missing 'max' in the gdiplush headers #endif // _MSC_VER +// #include "util/UTF8.hpp" +#include "util/UTF8Win.hpp" + #include #include #include @@ -38,11 +41,13 @@ GdiLoadImage(const TCHAR* filename) HBITMAP result = nullptr; #ifdef _UNICODE // TCHAR has to be WCHAR in GdiPlus Gdiplus::Bitmap bitmap(filename, false); +#else + Gdiplus::Bitmap bitmap(UTF8ToWide(filename).c_str(), false); +#endif // _UNICODE if (bitmap.GetLastStatus() != Gdiplus::Ok) return nullptr; const Gdiplus::Color color = Gdiplus::Color::White; if (bitmap.GetHBITMAP(color, &result) != Gdiplus::Ok) return nullptr; -#endif // _UNICODE return result; } From 8663621832663f23fbcad05b6716ac901a69b994 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sun, 21 Apr 2024 23:29:09 +0200 Subject: [PATCH 371/403] util/UTF8Win.cpp - include UTF8Win.hpp instead of UTF8.hpp (missing decl.) util/UTF8Win.hpp - coding style --- src/util/UTF8Win.cpp | 2 +- src/util/UTF8Win.hpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/util/UTF8Win.cpp b/src/util/UTF8Win.cpp index 42c2add7458..55ffd4d35fe 100644 --- a/src/util/UTF8Win.cpp +++ b/src/util/UTF8Win.cpp @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright The XCSoar Project -#include "UTF8.hpp" +#include "UTF8Win.hpp" #include "LogFile.hpp" #ifdef _WIN32 diff --git a/src/util/UTF8Win.hpp b/src/util/UTF8Win.hpp index 88c60d6ed1e..51e97c9d3ea 100644 --- a/src/util/UTF8Win.hpp +++ b/src/util/UTF8Win.hpp @@ -9,6 +9,7 @@ #include #include -std::wstring UTF8ToWide(const std::string_view s); +std::wstring +UTF8ToWide(const std::string_view s); #endif \ No newline at end of file From ec30e7e762ea6910b8297de6267417725dadb9a3 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 22 Apr 2024 08:00:45 +0200 Subject: [PATCH 372/403] [Bugfix] Creating MakeResource.hpp on Android: Due to the parallel build process there very often a mismatch beween built MakeResource.hpp, deleting and overwriting With this workaround this should never happens TODO: Check of make a new build with changed resources.txt --- build/resource.mk | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/build/resource.mk b/build/resource.mk index d4bdbf18bfc..ce0333128ef 100644 --- a/build/resource.mk +++ b/build/resource.mk @@ -195,12 +195,20 @@ $(TARGET_OUTPUT_DIR)/resources.txt: Data/resources.txt | $(TARGET_OUTPUT_DIR)/di @$(NQ)echo " CPP $@" $(Q)cat $< |$(CC) -E -o $@ -I$(OUT)/include $(TARGET_CPPFLAGS) $(OPENGL_CPPFLAGS) $(GDI_CPPFLAGS) - +ifeq ($(TARGET_IS_ANDROID),y) + +$(TARGET_OUTPUT_DIR)/include/MakeResource.hpp: $(TARGET_OUTPUT_DIR)/resources.txt tools/GenerateMakeResource.pl | $(TARGET_OUTPUT_DIR)/include/dirstamp + @$(NQ)echo " GEN $@" + $(Q)$(PERL) tools/GenerateMakeResource.pl <$< >$(TARGET_OUTPUT_DIR)/$(ANDROID_APK_LIB_ABI)/MakeResource.hpp.tmp + $(Q)mv -n $(TARGET_OUTPUT_DIR)/$(ANDROID_APK_LIB_ABI)/MakeResource.hpp.tmp $@ + +else + $(TARGET_OUTPUT_DIR)/include/MakeResource.hpp: $(TARGET_OUTPUT_DIR)/resources.txt tools/GenerateMakeResource.pl | $(TARGET_OUTPUT_DIR)/include/dirstamp @$(NQ)echo " GEN $@" $(Q)$(PERL) tools/GenerateMakeResource.pl <$< >$@.tmp $(Q)mv $@.tmp $@ -ifeq ($(TARGET_IS_ANDROID),n) ifeq ($(USE_WIN32_RESOURCES),y) RESOURCE_FILES += $(BMP_BITMAPS) From 5abee4c983bd7156b7a22c496722539c6c9dcbcd Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 22 Apr 2024 12:44:19 +0200 Subject: [PATCH 373/403] [OV] remove "Advanced Menu (temp.)" (ExtraMenu.cpp) from normal build --- src/Dialogs/Settings/dlgConfiguration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Dialogs/Settings/dlgConfiguration.cpp b/src/Dialogs/Settings/dlgConfiguration.cpp index ec33903e773..80d0d2430a7 100644 --- a/src/Dialogs/Settings/dlgConfiguration.cpp +++ b/src/Dialogs/Settings/dlgConfiguration.cpp @@ -165,7 +165,7 @@ static constexpr TabMenuPage openvario_pages[] = { {N_("System Settings"), CreateSystemSettingsWidget}, {N_("Display Settings"), CreateDisplaySettingsWidget}, {N_("File Transfer"), CreateFileMenuWidget}, -#if 1 +#if _DEBUG // remove with better FW-Upgrade {N_("Advanced Menu (temp)"), CreateExtraWidget}, #endif From cd54aabb4da0541c6430b12902d2f6bd2bf50018 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 22 Apr 2024 12:46:21 +0200 Subject: [PATCH 374/403] [OV] - SystemSettingsWidget.cpp - use temporary a add. button for FW upgrade --- src/OpenVario/SystemSettingsWidget.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/OpenVario/SystemSettingsWidget.cpp b/src/OpenVario/SystemSettingsWidget.cpp index 46ed3533fbd..53a30ae8f42 100644 --- a/src/OpenVario/SystemSettingsWidget.cpp +++ b/src/OpenVario/SystemSettingsWidget.cpp @@ -158,6 +158,14 @@ SystemSettingsWidget::Prepare(ContainerWindow &parent, 99999, 1, ovdevice.iTest); #endif +#if 1 + AddButton(_("Upgrade Firmware (temp.)"), [this]() { + ContainerWindow::SetExitValue(START_UPGRADE); + UIActions::SignalShutdown(false); + return mrOK; // START_UPGRADE; + }); +#endif + SetEnabled(ovdevice.enabled); } From 40eb010adea0db1fef54eeea34c7e048861dae72 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 11 Apr 2024 10:59:38 +0200 Subject: [PATCH 375/403] (Pre-)Release v7.42.22.A --- OpenSoar-News.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/OpenSoar-News.md b/OpenSoar-News.md index 127f15dc74d..6dee76ae5d9 100644 --- a/OpenSoar-News.md +++ b/OpenSoar-News.md @@ -1,20 +1,15 @@ -OpenSoar Version 7.42.22 - not yet released ---------------- - -OpenSoar Version 7.42.22.A - 2024/04/xx +OpenSoar Version 7.42.22.A - 2024/04/21 - PreRelease A to 7.42.22 --------------- * System: add possibility to restart OpenSoar without exit to system * TCP Port - Bugfix on closing the TCP client as receiver on this port: - By closing the receiver OpenSoar crashed! * End of program with (short) restart, newstart, reboot, shutdown and normal program end * QuickMenu extended with - Volume control - several program ends (Reboot, Restart) * User interface - - create a (simple) audio volume control menu (similar to the OpenVario control) + - create a (simple) audio volume control menu (similar to the OpenVario control) in the default event file * Setup Menu - add OpenVario menu (see next item) -* NMEA Settings: Better shows which USB or Bluetooth device is in use for serial devices on Windows (similar to Android) * OpenVario: - WiFi selection, setting and enabling - OpenVario menu inserted with @@ -22,6 +17,8 @@ OpenSoar Version 7.42.22.A - 2024/04/xx - 'Display Settings': (Device!) Rotation, Brightness, Touch Calibration - 'File Transfer': IGC, OpenSoar data, system data - split default.xci to defaultOV.xci +* NMEA Settings: Better shows which USB or Bluetooth device is in use for serial devices on Windows (similar to Android) +* Driver/Larus - extend with bidirectional settings parameters $PLARS * Simulator: remove SIM option from standard, further available with option '-simulator' only * Development - rename src folder 'OV' in 'OpenVario' @@ -31,7 +28,9 @@ OpenSoar Version 7.42.22.A - 2024/04/xx * Bugfix: - Display rotation on OpenVario on setting * Open Issues - - Display rotation on Linux! + - Display rotation on Linux behaves wrong! + - OV-Firmware Download don't work (SetupMenu->OpenVario->SystemSettings) + - OV-WiFi work only with one wifi connection and only with a Wifi access WITH password properly! #### XCSoar Version 7.42 - 2024/03/01 * merge xcsoar 7.42 '9ee29aa606' From bf228d3004fcf5999573d578150dc949e488ad23 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sat, 20 Apr 2024 14:53:52 +0200 Subject: [PATCH 376/403] [UTF8] remove UNICODE code from src and test --- src/Device/Descriptor.cpp | 26 ------ src/Device/Descriptor.hpp | 8 -- src/Device/Driver/AltairPro.cpp | 19 ---- src/Device/Driver/CAI302/Declare.cpp | 16 ---- src/Device/Driver/EW.cpp | 16 ---- src/Device/Driver/FLARM/Device.cpp | 36 -------- src/Device/Driver/FLARM/Device.hpp | 8 -- src/Device/Driver/IMI/Protocol/Conversion.cpp | 13 +-- src/Device/Driver/IMI/Protocol/Conversion.hpp | 2 +- src/Device/Driver/Vega/Parser.cpp | 4 - src/Device/Driver/Volkslogger/Declare.cpp | 17 ---- src/Device/Port/ConfiguredPort.cpp | 3 +- src/Dialogs/Device/PortDataField.cpp | 4 - src/Dialogs/FileManager.cpp | 12 --- src/Dialogs/TouchTextEntry.cpp | 2 - src/FLARM/FlarmNetReader.cpp | 13 --- src/FLARM/FlarmNetRecord.hpp | 6 -- src/FLARM/Id.cpp | 20 ----- src/FLARM/Id.hpp | 10 --- src/Form/CharacterButton.cpp | 7 -- src/Formatter/HexColor.cpp | 24 ----- src/Formatter/HexColor.hpp | 10 --- src/Formatter/IGCFilenameFormatter.cpp | 45 ---------- src/Formatter/IGCFilenameFormatter.hpp | 10 --- src/Formatter/TimeFormatter.cpp | 19 ---- src/Formatter/TimeFormatter.hpp | 13 --- src/IGC/IGCString.cpp | 22 ----- src/IGC/IGCString.hpp | 16 ---- src/Language/Language.cpp | 52 +---------- src/LogFile.cpp | 44 +--------- src/LogFile.hpp | 9 -- src/Profile/Map.hpp | 8 -- src/Profile/PathValue.cpp | 24 ----- src/Profile/ProfileMap.cpp | 10 --- src/Profile/ProfileMap.hpp | 5 -- src/Profile/StringValue.cpp | 28 ------ src/Topography/XShape.cpp | 8 -- src/Tracking/LiveTrack24/Client.cpp | 6 -- src/VALI-XCS.cpp | 7 +- src/Weather/NOAAStore.cpp | 48 ---------- src/Weather/NOAAStore.hpp | 16 ---- src/Widget/LargeTextWidget.cpp | 18 ---- src/Widget/LargeTextWidget.hpp | 7 -- src/XML/Parser.cpp | 2 +- src/io/BufferedOutputStream.cxx | 46 ---------- src/io/BufferedOutputStream.hxx | 23 ----- src/io/KeyValueFileWriter.cpp | 18 ---- src/io/KeyValueFileWriter.hpp | 7 -- src/io/StringConverter.cpp | 66 -------------- src/lib/fmt/tchar.hxx | 11 --- src/net/SocketError.cxx | 15 ---- src/system/Args.hpp | 24 ----- src/system/ConvertPathName.hpp | 26 ------ src/system/FileUtil.cpp | 12 --- src/system/FileUtil.hpp | 6 -- src/system/Path.cpp | 12 --- src/system/Path.hpp | 9 +- src/ui/canvas/custom/Cache.cpp | 12 --- src/ui/canvas/custom/LibTiff.cpp | 4 - src/ui/canvas/custom/MoreCanvas.cpp | 3 - src/ui/canvas/freetype/Font.cpp | 10 --- src/ui/canvas/gdi/GdiPlusBitmap.cpp | 4 - src/ui/canvas/memory/Canvas.cpp | 19 ---- src/ui/canvas/opengl/Canvas.cpp | 20 ----- src/ui/window/sdl/TopWindow.cpp | 9 -- src/util/ASCII.hxx | 4 - src/util/CharUtil.hxx | 4 - src/util/ConvertString.cpp | 76 +--------------- src/util/ConvertString.hpp | 88 +------------------ src/util/IterableSplitString.hxx | 6 -- src/util/NumberParser.hpp | 77 ---------------- src/util/StaticString.cxx | 14 --- src/util/StaticString.hxx | 47 ---------- src/util/StringAPI.hxx | 4 - src/util/StringBuilder.cxx | 7 -- src/util/StringCompare.hxx | 4 - src/util/StringFormat.hpp | 4 - src/util/StringStrip.hxx | 4 - src/util/StringUtil.hpp | 4 - src/util/TruncateString.cpp | 28 ------ src/util/TruncateString.hpp | 6 -- src/util/UTF8.hpp | 4 +- src/util/tstring.hpp | 4 - src/util/tstring_view.hxx | 4 - test/src/FakeLogFile.cpp | 16 ---- test/src/TestUTF8.cpp | 7 -- 86 files changed, 15 insertions(+), 1446 deletions(-) diff --git a/src/Device/Descriptor.cpp b/src/Device/Descriptor.cpp index a8e820adce4..18d9fd1647c 100644 --- a/src/Device/Descriptor.cpp +++ b/src/Device/Descriptor.cpp @@ -771,21 +771,6 @@ DeviceDescriptor::WriteNMEA(const char *line, } } -#ifdef _UNICODE -bool -DeviceDescriptor::WriteNMEA(const TCHAR *line, - OperationEnvironment &env) noexcept -{ - assert(line != nullptr); - - if (port == nullptr) - return false; - - WideToACPConverter narrow{line}; - return narrow.IsValid() && WriteNMEA(narrow, env); -} -#endif - bool DeviceDescriptor::PutMacCready(double value, OperationEnvironment &env) noexcept @@ -1249,17 +1234,6 @@ DeviceDescriptor::LockSetErrorMessage(const TCHAR *msg) noexcept error_message = msg; } -#ifdef _UNICODE - -inline void -DeviceDescriptor::LockSetErrorMessage(const char *msg) noexcept -{ - if (const UTF8ToWideConverter tmsg(msg); tmsg.IsValid()) - LockSetErrorMessage(tmsg); -} - -#endif - void DeviceDescriptor::OnJobFinished() noexcept { diff --git a/src/Device/Descriptor.hpp b/src/Device/Descriptor.hpp index b314304e10f..a1c1f215386 100644 --- a/src/Device/Descriptor.hpp +++ b/src/Device/Descriptor.hpp @@ -529,10 +529,6 @@ class DeviceDescriptor final void ForwardLine(const char *line); bool WriteNMEA(const char *line, OperationEnvironment &env) noexcept; -#ifdef _UNICODE - bool WriteNMEA(const TCHAR *line, OperationEnvironment &env) noexcept; -#endif - bool PutMacCready(double mac_cready, OperationEnvironment &env) noexcept; bool PutBugs(double bugs, OperationEnvironment &env) noexcept; bool PutBallast(double fraction, double overload, @@ -582,10 +578,6 @@ class DeviceDescriptor final private: void LockSetErrorMessage(const TCHAR *msg) noexcept; -#ifdef _UNICODE - void LockSetErrorMessage(const char *msg) noexcept; -#endif - void OnJobFinished() noexcept; /* virtual methods from class PortListener */ diff --git a/src/Device/Driver/AltairPro.cpp b/src/Device/Driver/AltairPro.cpp index b3b051cc137..20c4c7c1ecd 100644 --- a/src/Device/Driver/AltairPro.cpp +++ b/src/Device/Driver/AltairPro.cpp @@ -35,11 +35,6 @@ class AltairProDevice : public AbstractDevice { bool PropertySetGet(const char *name, const char *value, std::span dest, OperationEnvironment &env); -#ifdef _UNICODE - bool PropertySetGet(const char *name, const TCHAR *value, - std::span dest, - OperationEnvironment &env); -#endif public: AltairProDevice(Port &_port):port(_port){} @@ -224,20 +219,6 @@ AltairProDevice::PropertySetGet(const char *name, const char *value, return false; } -#ifdef _UNICODE -bool -AltairProDevice::PropertySetGet(const char *name, const TCHAR *_value, - std::span dest, - OperationEnvironment &env) -{ - const WideToACPConverter value{_value}; - if (!value.IsValid()) - throw std::runtime_error("Invalid string"); - - return PropertySetGet(name, value, dest, env); -} -#endif - void AltairProDevice::PutTurnPoint(const char *propertyName, const Waypoint *waypoint, diff --git a/src/Device/Driver/CAI302/Declare.cpp b/src/Device/Driver/CAI302/Declare.cpp index a5383325dea..cc29c77b629 100644 --- a/src/Device/Driver/CAI302/Declare.cpp +++ b/src/Device/Driver/CAI302/Declare.cpp @@ -9,27 +9,11 @@ #include #include -#ifdef _UNICODE -#include -#endif - static void convert_string(char *dest, size_t size, const TCHAR *src) { -#ifdef _UNICODE - size_t length = _tcslen(src); - if (length >= size) - length = size - 1; - - int length2 = ::WideCharToMultiByte(CP_ACP, 0, src, length, dest, size, - nullptr, nullptr); - if (length2 < 0) - length2 = 0; - dest[length2] = '\0'; -#else strncpy(dest, src, size - 1); dest[size - 1] = '\0'; -#endif } static void diff --git a/src/Device/Driver/EW.cpp b/src/Device/Driver/EW.cpp index 4cb6b8b61f1..cce5e33296d 100644 --- a/src/Device/Driver/EW.cpp +++ b/src/Device/Driver/EW.cpp @@ -23,10 +23,6 @@ #include #include "Waypoint/Waypoint.hpp" -#ifdef _UNICODE -#include -#endif - // Additional sentance for EW support class EWDevice : public AbstractDevice { @@ -88,20 +84,8 @@ EWDevice::TryConnect(OperationEnvironment &env) static void convert_string(char *dest, size_t size, const TCHAR *src) { -#ifdef _UNICODE - size_t length = _tcslen(src); - if (length >= size) - length = size - 1; - - int length2 = ::WideCharToMultiByte(CP_ACP, 0, src, length, dest, size, - nullptr, nullptr); - if (length2 < 0) - length2 = 0; - dest[length2] = '\0'; -#else strncpy(dest, src, size - 1); dest[size - 1] = '\0'; -#endif } bool diff --git a/src/Device/Driver/FLARM/Device.cpp b/src/Device/Driver/FLARM/Device.cpp index 557ace4b608..86804e5e5f3 100644 --- a/src/Device/Driver/FLARM/Device.cpp +++ b/src/Device/Driver/FLARM/Device.cpp @@ -221,42 +221,6 @@ FlarmDevice::SetConfig(const char *setting, const char *value, return ExpectChecksum(port, NMEAChecksum(expected_answer), env); } -#ifdef _UNICODE - -bool -FlarmDevice::GetConfig(const char *setting, TCHAR *buffer, size_t length, - OperationEnvironment &env) -{ - char narrow_buffer[90]; - if (!GetConfig(setting, narrow_buffer, ARRAY_SIZE(narrow_buffer), env)) - return false; - - if (StringIsEmpty(narrow_buffer)) { - *buffer = _T('\0'); - return true; - } - - UTF8ToWideConverter wide(narrow_buffer); - if (!wide.IsValid()) - return false; - - CopyTruncateString(buffer, length, wide); - return true; -} - -bool -FlarmDevice::SetConfig(const char *setting, const TCHAR *value, - OperationEnvironment &env) -{ - WideToUTF8Converter narrow_value(value); - if (!narrow_value.IsValid()) - return false; - - return SetConfig(setting, narrow_value, env); -} - -#endif - void FlarmDevice::Restart(OperationEnvironment &env) { diff --git a/src/Device/Driver/FLARM/Device.hpp b/src/Device/Driver/FLARM/Device.hpp index c88762dbb0b..c7d71e7e322 100644 --- a/src/Device/Driver/FLARM/Device.hpp +++ b/src/Device/Driver/FLARM/Device.hpp @@ -124,14 +124,6 @@ class FlarmDevice: public AbstractDevice OperationEnvironment &env); bool SetConfig(const char *setting, const char *value, OperationEnvironment &env); - -#ifdef _UNICODE - bool GetConfig(const char *setting, TCHAR *buffer, size_t length, - OperationEnvironment &env); - bool SetConfig(const char *setting, const TCHAR *value, - OperationEnvironment &env); -#endif - bool DeclareInternal(const Declaration &declaration, OperationEnvironment &env); diff --git a/src/Device/Driver/IMI/Protocol/Conversion.cpp b/src/Device/Driver/IMI/Protocol/Conversion.cpp index 9a74b4b6ae7..d19dada56a9 100644 --- a/src/Device/Driver/IMI/Protocol/Conversion.cpp +++ b/src/Device/Driver/IMI/Protocol/Conversion.cpp @@ -7,23 +7,16 @@ #include "Engine/Waypoint/Waypoint.hpp" #include "time/Calendar.hxx" -#ifdef _UNICODE -#include -#endif - static constexpr unsigned IMI_SECONDS_IN_MINUTE = 60; static constexpr unsigned IMI_SECONDS_IN_HOUR = 60*60; static constexpr unsigned IMI_SECONDS_IN_DAY = 24*60*60; void -IMI::ConvertToChar(const TCHAR* unicode, char* ascii, int outSize) +IMI::ConvertToChar(const TCHAR* dest, char* ascii, int outSize) { -#ifdef _UNICODE - WideCharToMultiByte(CP_ACP, 0, unicode, -1, ascii, outSize, "?", nullptr); -#else - strncpy(ascii, unicode, outSize - 1); + // this is only a copy (n) function) + strncpy(ascii, dest, outSize - 1); ascii[outSize - 1] = 0; -#endif } IMI::AngleConverter::AngleConverter(Angle angle) diff --git a/src/Device/Driver/IMI/Protocol/Conversion.hpp b/src/Device/Driver/IMI/Protocol/Conversion.hpp index 74d45755f04..147254d5686 100644 --- a/src/Device/Driver/IMI/Protocol/Conversion.hpp +++ b/src/Device/Driver/IMI/Protocol/Conversion.hpp @@ -31,7 +31,7 @@ struct AngleConverter { }; void -ConvertToChar(const TCHAR* unicode, char* ascii, int outSize); +ConvertToChar(const TCHAR* dest, char* ascii, int outSize); BrokenDateTime ConvertToDateTime(IMIDATETIMESEC in); diff --git a/src/Device/Driver/Vega/Parser.cpp b/src/Device/Driver/Vega/Parser.cpp index 662f2a91520..197ee49b5b9 100644 --- a/src/Device/Driver/Vega/Parser.cpp +++ b/src/Device/Driver/Vega/Parser.cpp @@ -9,10 +9,6 @@ #include #include -#ifdef _UNICODE -#include -#endif - using std::string_view_literals::operator""sv; static bool diff --git a/src/Device/Driver/Volkslogger/Declare.cpp b/src/Device/Driver/Volkslogger/Declare.cpp index 6ac47342e87..978dd9c87a0 100644 --- a/src/Device/Driver/Volkslogger/Declare.cpp +++ b/src/Device/Driver/Volkslogger/Declare.cpp @@ -9,30 +9,13 @@ #include "dbbconv.h" #include "Engine/Waypoint/Waypoint.hpp" -#ifdef _UNICODE -#include -#endif - #include static void CopyToNarrowBuffer(char *dest, size_t max_size, const TCHAR *src) { -#ifdef _UNICODE - size_t src_length = _tcslen(src); - if (src_length >= max_size) - src_length = max_size - 1; - - int dest_length = WideCharToMultiByte(CP_ACP, 0, src, src_length, - dest, max_size - 1, - nullptr, nullptr); - if (dest_length < 0) - dest_length = 0; - dest[dest_length] = 0; -#else strncpy(dest, src, max_size - 1); dest[max_size - 1] = 0; -#endif } static void diff --git a/src/Device/Port/ConfiguredPort.cpp b/src/Device/Port/ConfiguredPort.cpp index 1e10d86f962..62450e8e5fa 100644 --- a/src/Device/Port/ConfiguredPort.cpp +++ b/src/Device/Port/ConfiguredPort.cpp @@ -71,8 +71,7 @@ WindowsPort(TCHAR buffer[], const DeviceConfig &config) { // the usual windows style of device names: _tcscpy(buffer, _T("\\\\.\\")); - _tcscat(buffer, config.path.c_str()); - return buffer; + _tcscat(buffer, config.path.c_str());return buffer; } #endif diff --git a/src/Dialogs/Device/PortDataField.cpp b/src/Dialogs/Device/PortDataField.cpp index a53a68ff3f6..2e406fbd611 100644 --- a/src/Dialogs/Device/PortDataField.cpp +++ b/src/Dialogs/Device/PortDataField.cpp @@ -16,12 +16,8 @@ # include "util/StringFormat.hpp" # include # include -#ifdef _UNICODE - typedef std::wstring tstring; -#else typedef std::string tstring; #endif -#endif #ifdef ANDROID #include "java/Global.hxx" diff --git a/src/Dialogs/FileManager.cpp b/src/Dialogs/FileManager.cpp index f78c1e2a866..78304ada0d8 100644 --- a/src/Dialogs/FileManager.cpp +++ b/src/Dialogs/FileManager.cpp @@ -58,18 +58,6 @@ FindRemoteFile(const FileRepository &repository, const char *name) return repository.FindByName(name); } -#ifdef _UNICODE -[[gnu::pure]] -static const AvailableFile * -FindRemoteFile(const FileRepository &repository, const TCHAR *name) -{ - const WideToUTF8Converter name2(name); - if (!name2.IsValid()) - return nullptr; - - return FindRemoteFile(repository, name2); -} -#endif [[gnu::pure]] static bool diff --git a/src/Dialogs/TouchTextEntry.cpp b/src/Dialogs/TouchTextEntry.cpp index 3e855ff6fed..1a932f0d828 100644 --- a/src/Dialogs/TouchTextEntry.cpp +++ b/src/Dialogs/TouchTextEntry.cpp @@ -92,12 +92,10 @@ FormCharacter(unsigned ch) if (ch < 0x20) return false; -#ifndef _UNICODE if (ch >= 0x80) /* TODO: ASCII only for now, because we don't have proper UTF-8 support yet */ return false; -#endif DoCharacter((TCHAR)ch); return true; diff --git a/src/FLARM/FlarmNetReader.cpp b/src/FLARM/FlarmNetReader.cpp index 5f0277ec908..7280694733e 100644 --- a/src/FLARM/FlarmNetReader.cpp +++ b/src/FLARM/FlarmNetReader.cpp @@ -9,10 +9,7 @@ #include "io/LineReader.hpp" #include "io/FileLineReader.hpp" -#ifndef _UNICODE #include "util/UTF8.hpp" -#endif - #include #include @@ -27,10 +24,7 @@ static void LoadString(const char *bytes, size_t length, TCHAR *res, [[maybe_unused]] size_t res_size) { const char *const end = bytes + length * 2; - -#ifndef _UNICODE const char *const limit = res + res_size - 2; -#endif TCHAR *p = res; @@ -44,24 +38,17 @@ LoadString(const char *bytes, size_t length, TCHAR *res, [[maybe_unused]] size_t /* FLARMNet files are ISO-Latin-1, which is kind of short-sighted */ const unsigned char ch = (unsigned char)strtoul(tmp, NULL, 16); -#ifdef _UNICODE - /* Latin-1 can be converted to WIN32 wchar_t by casting */ - *p++ = ch; -#else /* convert to UTF-8 on all other platforms */ if (p >= limit) break; p = Latin1ToUTF8(ch, p); -#endif } *p = 0; -#ifndef _UNICODE assert(ValidateUTF8(res)); -#endif // Trim the string of any additional spaces StripRight(res); diff --git a/src/FLARM/FlarmNetRecord.hpp b/src/FLARM/FlarmNetRecord.hpp index 7a894848d98..cf84d6f768f 100644 --- a/src/FLARM/FlarmNetRecord.hpp +++ b/src/FLARM/FlarmNetRecord.hpp @@ -10,15 +10,9 @@ class FlarmId; static constexpr std::size_t LatinBufferSize(std::size_t size) noexcept { -#ifdef _UNICODE -/* with wide characters, the exact size of the FLARMNet database field - (plus one for the terminator) is just right, ... */ - return size; -#else /* ..., but when we convert Latin-1 to UTF-8, we need a little bit more buffer */ return size * 3 / 2 + 1; -#endif } /** diff --git a/src/FLARM/Id.cpp b/src/FLARM/Id.cpp index 1b28a6b5cdb..962b273ccc1 100644 --- a/src/FLARM/Id.cpp +++ b/src/FLARM/Id.cpp @@ -5,10 +5,6 @@ #include -#ifdef _UNICODE -#include -#endif - #include FlarmId @@ -17,14 +13,6 @@ FlarmId::Parse(const char *input, char **endptr_r) noexcept return FlarmId(strtol(input, endptr_r, 16)); } -#ifdef _UNICODE -FlarmId -FlarmId::Parse(const TCHAR *input, TCHAR **endptr_r) noexcept -{ - return FlarmId(_tcstol(input, endptr_r, 16)); -} -#endif - const char * FlarmId::Format(char *buffer) const noexcept { @@ -32,11 +20,3 @@ FlarmId::Format(char *buffer) const noexcept return buffer; } -#ifdef _UNICODE -const TCHAR * -FlarmId::Format(TCHAR *buffer) const noexcept -{ - *fmt::format_to(buffer, _T("{:X}"), value) = 0; - return buffer; -} -#endif diff --git a/src/FLARM/Id.hpp b/src/FLARM/Id.hpp index 7c4eb6faf72..a6ceff7ed3e 100644 --- a/src/FLARM/Id.hpp +++ b/src/FLARM/Id.hpp @@ -6,10 +6,6 @@ #include #include // for the defaulted spaceship operator -#ifdef _UNICODE -#include -#endif - /** * The identification number of a FLARM traffic. */ @@ -40,12 +36,6 @@ class FlarmId { const FlarmId &) noexcept = default; static FlarmId Parse(const char *input, char **endptr_r) noexcept; -#ifdef _UNICODE - static FlarmId Parse(const TCHAR *input, TCHAR **endptr_r) noexcept; -#endif const char *Format(char *buffer) const noexcept; -#ifdef _UNICODE - const TCHAR *Format(TCHAR *buffer) const noexcept; -#endif }; diff --git a/src/Form/CharacterButton.cpp b/src/Form/CharacterButton.cpp index a6105209fcc..60392415afa 100644 --- a/src/Form/CharacterButton.cpp +++ b/src/Form/CharacterButton.cpp @@ -3,10 +3,7 @@ #include "Form/CharacterButton.hpp" #include "util/CharUtil.hxx" - -#ifndef _UNICODE #include "util/UTF8.hpp" -#endif #include @@ -41,12 +38,8 @@ CharacterButton::SetCharacter(unsigned _character) noexcept character = _character; -#ifdef _UNICODE - const TCHAR buffer[2] = { TCHAR(character), _T('\0') }; -#else char buffer[7]; *UnicodeToUTF8(character, buffer) = '\0'; -#endif SetCaption(buffer); } diff --git a/src/Formatter/HexColor.cpp b/src/Formatter/HexColor.cpp index 158c87e7ef7..7beaaae0186 100644 --- a/src/Formatter/HexColor.cpp +++ b/src/Formatter/HexColor.cpp @@ -38,27 +38,3 @@ ParseHexColor(const char *buffer, RGB8Color &color) return true; } -#ifdef _UNICODE - -bool -ParseHexColor(const TCHAR *buffer, RGB8Color &color) -{ - if (*buffer != _T('#')) - return false; - - buffer++; - - TCHAR *endptr; - unsigned value = ParseUnsigned(buffer, &endptr, 16); - if (endptr != buffer + 6) - return false; - - uint8_t r = value >> 16; - uint8_t g = value >> 8; - uint8_t b = value; - - color = RGB8Color(r, g, b); - return true; -} - -#endif diff --git a/src/Formatter/HexColor.hpp b/src/Formatter/HexColor.hpp index c8f3e457a9b..458dc9c8b03 100644 --- a/src/Formatter/HexColor.hpp +++ b/src/Formatter/HexColor.hpp @@ -3,10 +3,6 @@ #pragma once -#ifdef _UNICODE -#include -#endif - #include class RGB8Color; @@ -20,9 +16,3 @@ FormatHexColor(char *buffer, size_t size, const RGB8Color color); bool ParseHexColor(const char *buffer, RGB8Color &color); -#ifdef _UNICODE - -bool -ParseHexColor(const TCHAR *buffer, RGB8Color &color); - -#endif diff --git a/src/Formatter/IGCFilenameFormatter.cpp b/src/Formatter/IGCFilenameFormatter.cpp index e6d48b6203b..85309895f90 100644 --- a/src/Formatter/IGCFilenameFormatter.cpp +++ b/src/Formatter/IGCFilenameFormatter.cpp @@ -5,10 +5,6 @@ #include "time/BrokenDate.hpp" #include "util/StringFormat.hpp" -#ifdef _UNICODE -#include -#endif - #include #include @@ -61,44 +57,3 @@ FormatIGCFilenameLong(TCHAR* buffer, const BrokenDate &date, manufacturer, logger_id, flight_number); } -#ifdef _UNICODE - -void -FormatIGCFilename(TCHAR* buffer, const BrokenDate &date, - char manufacturer, const char *logger_id, - unsigned flight_number) -{ - assert(logger_id != NULL); - assert(strlen(logger_id) == 3); - - TCHAR logger_id_t[4]; - /* poor man's char->TCHAR converted; this works because we know - we're dealing with ASCII only */ - std::copy_n(logger_id, 4, logger_id_t); - - FormatIGCFilename(buffer, date, (TCHAR)manufacturer, logger_id_t, - flight_number); -} - -void -FormatIGCFilenameLong(TCHAR* buffer, const BrokenDate &date, - const char *manufacturer, const char *logger_id, - unsigned flight_number) -{ - assert(manufacturer != NULL); - assert(strlen(manufacturer) == 3); - - assert(logger_id != NULL); - assert(strlen(logger_id) == 3); - - TCHAR manufacturer_t[4], logger_id_t[4]; - /* poor man's char->TCHAR converted; this works because we know - we're dealing with ASCII only */ - std::copy_n(manufacturer, 4, manufacturer_t); - std::copy_n(logger_id, 4, logger_id_t); - - FormatIGCFilenameLong(buffer, date, manufacturer_t, logger_id_t, - flight_number); -} - -#endif diff --git a/src/Formatter/IGCFilenameFormatter.hpp b/src/Formatter/IGCFilenameFormatter.hpp index eae431d1fcb..3d35e0bcdcd 100644 --- a/src/Formatter/IGCFilenameFormatter.hpp +++ b/src/Formatter/IGCFilenameFormatter.hpp @@ -14,13 +14,3 @@ void FormatIGCFilenameLong(TCHAR* buffer, const BrokenDate &date, const TCHAR *manufacturer, const TCHAR *logger_id, unsigned flight_number); -#ifdef _UNICODE - -void FormatIGCFilename(TCHAR* buffer, const BrokenDate &date, - char manufacturer, const char *logger_id, - unsigned flight_number); -void FormatIGCFilenameLong(TCHAR* buffer, const BrokenDate &date, - const char *manufacturer, const char *logger_id, - unsigned flight_number); - -#endif diff --git a/src/Formatter/TimeFormatter.cpp b/src/Formatter/TimeFormatter.cpp index 3357fee6bee..7b0cb7faab8 100644 --- a/src/Formatter/TimeFormatter.cpp +++ b/src/Formatter/TimeFormatter.cpp @@ -17,15 +17,6 @@ FormatISO8601(char *buffer, const BrokenDate &date) noexcept date.year, date.month, date.day); } -#ifdef _UNICODE -void -FormatISO8601(TCHAR *buffer, const BrokenDate &date) noexcept -{ - _stprintf(buffer, _T("%04u-%02u-%02u"), - date.year, date.month, date.day); -} -#endif - void FormatISO8601(char *buffer, const BrokenDateTime &stamp) noexcept { @@ -34,16 +25,6 @@ FormatISO8601(char *buffer, const BrokenDateTime &stamp) noexcept stamp.hour, stamp.minute, stamp.second); } -#ifdef _UNICODE -void -FormatISO8601(TCHAR *buffer, const BrokenDateTime &stamp) noexcept -{ - _stprintf(buffer, _T("%04u-%02u-%02uT%02u:%02u:%02uZ"), - stamp.year, stamp.month, stamp.day, - stamp.hour, stamp.minute, stamp.second); -} -#endif - void FormatTime(TCHAR *buffer, FloatDuration _time) noexcept { diff --git a/src/Formatter/TimeFormatter.hpp b/src/Formatter/TimeFormatter.hpp index 3a73cb431b0..6d171382040 100644 --- a/src/Formatter/TimeFormatter.hpp +++ b/src/Formatter/TimeFormatter.hpp @@ -14,25 +14,12 @@ struct BrokenDateTime; void FormatISO8601(char *buffer, const BrokenDate &date) noexcept; -#ifdef _UNICODE -void -FormatISO8601(TCHAR *buffer, const BrokenDate &date) noexcept; -#endif - /** * Format a UTC time stamp in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ). */ void FormatISO8601(char *buffer, const BrokenDateTime &stamp) noexcept; -#ifdef _UNICODE -/** - * Format a UTC time stamp in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ). - */ -void -FormatISO8601(TCHAR *buffer, const BrokenDateTime &stamp) noexcept; -#endif - void FormatTime(TCHAR *buffer, FloatDuration time) noexcept; diff --git a/src/IGC/IGCString.cpp b/src/IGC/IGCString.cpp index a644d5f833e..10552a9a333 100644 --- a/src/IGC/IGCString.cpp +++ b/src/IGC/IGCString.cpp @@ -24,25 +24,3 @@ CopyIGCString(char *dest, char *dest_limit, const char *src) noexcept return dest; } -#ifdef _UNICODE - -char * -CopyIGCString(char *dest, char *dest_limit, const TCHAR *src) noexcept -{ - assert(dest != nullptr); - assert(dest_limit > dest); - assert(src != nullptr); - - while (*src != '\0') { - TCHAR ch = *src++; - if (IsValidIGCChar(ch)) { - *dest++ = ch; - if (dest == dest_limit) - break; - } - } - - return dest; -} - -#endif diff --git a/src/IGC/IGCString.hpp b/src/IGC/IGCString.hpp index 0833abcc40a..a1006ab4a36 100644 --- a/src/IGC/IGCString.hpp +++ b/src/IGC/IGCString.hpp @@ -3,10 +3,6 @@ #pragma once -#ifdef _UNICODE -#include -#endif - /** * Is this a "reserved" character? * @@ -34,14 +30,6 @@ IsValidIGCChar(char ch) noexcept return ch >= 0x20 && ch <= 0x7e && !IsReservedIGCChar(ch); } -#ifdef _UNICODE -static constexpr bool -IsValidIGCChar(TCHAR ch) noexcept -{ - return ch >= 0x20 && ch <= 0x7e && !IsReservedIGCChar(char(ch)); -} -#endif - /** * Copy a null-terminated string to a buffer to be written to an IGC * file. If the string is too long for the buffer, it is truncated. @@ -50,7 +38,3 @@ IsValidIGCChar(TCHAR ch) noexcept char * CopyIGCString(char *dest, char *dest_limit, const char *src) noexcept; -#ifdef _UNICODE -char * -CopyIGCString(char *dest, char *dest_limit, const TCHAR *src) noexcept; -#endif diff --git a/src/Language/Language.cpp b/src/Language/Language.cpp index 1b84d518860..08cf2fc9978 100644 --- a/src/Language/Language.cpp +++ b/src/Language/Language.cpp @@ -14,22 +14,10 @@ #else -#ifdef _UNICODE -#include -#endif - #include "MOFile.hpp" const MOFile *mo_file; -#ifdef _UNICODE -#include "util/Macros.hpp" -#include "util/tstring.hpp" -#include -typedef std::map translation_map; -static translation_map translations; -#endif - #ifndef NDEBUG static bool language_allowed = false; @@ -74,41 +62,6 @@ gettext(const TCHAR* text) if (StringIsEmpty(text) || mo_file == NULL) return text; -#ifdef _UNICODE - // Try to lookup the english string in the map of cached TCHAR translations - const tstring text2(text); - translation_map::const_iterator it = translations.find(text2); - if (it != translations.end()) - // Return the looked up translation - return it->second.c_str(); - - // Convert the english TCHAR string to char - char original[4096]; - - // If the conversion failed -> use the english original string - if (::WideCharToMultiByte(CP_UTF8, 0, text, -1, - original, sizeof(original), NULL, NULL) <= 0) - return text; - - // Lookup the converted english char string in the MO file - const char *translation = mo_file->lookup(original); - // If the lookup failed -> use the english original string - if (translation == NULL || *translation == 0 || - strcmp(original, translation) == 0) - return text; - - // Convert the translated char string to TCHAR - TCHAR translation2[4096]; - if (::MultiByteToWideChar(CP_UTF8, 0, translation, -1, translation2, - ARRAY_SIZE(translation2)) <= 0) - return text; - - // Add the translated TCHAR string to the cache map for the next time - translations[text2] = translation2; - - // Return the translated TCHAR string - return translations[text2].c_str(); -#else // Search for the english original string in the MO file const char *translation = mo_file->lookup(text); // Return either the translated string if found or the original @@ -119,15 +72,12 @@ gettext(const TCHAR* text) return translation != nullptr && *translation != 0 && ValidateUTF8(translation) ? translation : text; #endif -#endif } +// Unicode rudiment(?): void reset_gettext_cache() { -#ifdef _UNICODE - translations.clear(); -#endif } #endif /* !HAVE_POSIX */ diff --git a/src/LogFile.cpp b/src/LogFile.cpp index 17779c7a063..f04632d2c5b 100644 --- a/src/LogFile.cpp +++ b/src/LogFile.cpp @@ -17,7 +17,7 @@ #include #include -#include // UNICODE??? +// #include // Unicode??? #include #include @@ -127,48 +127,6 @@ LogFormat(const char *fmt, ...) noexcept LogString(buf); } -#ifdef _UNICODE - -static void -LogString(std::wstring_view s) noexcept -{ - try { - auto fos = OpenLog(); - BufferedOutputStream bos{fos}; - - bos.Write('['); - - { - char time_buffer[32]; - FormatISO8601(time_buffer, BrokenDateTime::NowUTC()); - bos.Write(time_buffer); - } - - bos.Write("] "); - bos.Write(s); - bos.NewLine(); - - bos.Flush(); - fos.Commit(); - } catch (...) { - } -} - -void -LogFormat(const wchar_t *Str, ...) noexcept -{ - wchar_t buf[MAX_PATH]; - va_list ap; - - va_start(ap, Str); - std::vswprintf(buf, std::size(buf), Str, ap); - va_end(ap); - - LogString(buf); -} - -#endif - void LogError(std::exception_ptr e) noexcept { diff --git a/src/LogFile.hpp b/src/LogFile.hpp index afc1422c2d9..38ff25991b4 100644 --- a/src/LogFile.hpp +++ b/src/LogFile.hpp @@ -13,10 +13,6 @@ #include #include -#ifdef _UNICODE -#include -#endif - void LogVFmt(fmt::string_view format_str, fmt::format_args args) noexcept; @@ -53,11 +49,6 @@ gcc_printf(1, 2) void LogFormat(const char *fmt, ...) noexcept; -#ifdef _UNICODE -void -LogFormat(const wchar_t *fmt, ...) noexcept; -#endif - #if !defined(NDEBUG) #define LogDebug(...) LogFmt(__VA_ARGS__) diff --git a/src/Profile/Map.hpp b/src/Profile/Map.hpp index e92a7a9d7e8..00640a6117f 100644 --- a/src/Profile/Map.hpp +++ b/src/Profile/Map.hpp @@ -103,10 +103,6 @@ class ProfileMap { return Get(key, std::span{value.data(), value.capacity()}); } -#ifdef _UNICODE - void Set(std::string_view key, const TCHAR *value) noexcept; -#endif - // numeric values bool Get(std::string_view key, int &value) const noexcept; @@ -177,12 +173,8 @@ class ProfileMap { /** * Gets a path from the profile and return its base name only. */ -#ifdef _UNICODE - BasicAllocatedString GetPathBase(std::string_view key) const noexcept; -#else [[gnu::pure]] StringPointer GetPathBase(std::string_view key) const noexcept; -#endif void SetPath(std::string_view key, Path value) noexcept; diff --git a/src/Profile/PathValue.cpp b/src/Profile/PathValue.cpp index d7e47675fc8..3daaa3aaf4a 100644 --- a/src/Profile/PathValue.cpp +++ b/src/Profile/PathValue.cpp @@ -9,10 +9,6 @@ #include "util/StringCompare.hxx" #include "util/StringPointer.hxx" -#ifdef _UNICODE -#include "util/AllocatedString.hxx" -#endif - #include /* for MAX_PATH */ AllocatedPath @@ -51,24 +47,6 @@ BackslashBaseName(const TCHAR *p) noexcept return Path(p).GetBase(); } -#ifdef _UNICODE - -BasicAllocatedString -ProfileMap::GetPathBase(std::string_view key) const noexcept -{ - TCHAR buffer[MAX_PATH]; - if (!Get(key, std::span{buffer})) - return nullptr; - - const TCHAR *base = BackslashBaseName(buffer).c_str(); - if (base == nullptr) - return nullptr; - - return BasicAllocatedString(base); -} - -#else - StringPointer ProfileMap::GetPathBase(std::string_view key) const noexcept { @@ -79,8 +57,6 @@ ProfileMap::GetPathBase(std::string_view key) const noexcept return path; } -#endif - void ProfileMap::SetPath(std::string_view key, Path value) noexcept { diff --git a/src/Profile/ProfileMap.cpp b/src/Profile/ProfileMap.cpp index d09da6adb15..5562b545a5e 100644 --- a/src/Profile/ProfileMap.cpp +++ b/src/Profile/ProfileMap.cpp @@ -77,16 +77,6 @@ Profile::Set(std::string_view key, const char *value) noexcept map.Set(key, value); } -#ifdef _UNICODE - -void -Profile::Set(std::string_view key, const TCHAR *value) noexcept -{ - map.Set(key, value); -} - -#endif - void Profile::Set(std::string_view key, int value) noexcept { diff --git a/src/Profile/ProfileMap.hpp b/src/Profile/ProfileMap.hpp index 0c1b962fad7..ed009ff9510 100644 --- a/src/Profile/ProfileMap.hpp +++ b/src/Profile/ProfileMap.hpp @@ -59,11 +59,6 @@ Get(std::string_view key, std::span value) noexcept; void Set(std::string_view key, const char *value) noexcept; -#ifdef _UNICODE -void -Set(std::string_view key, const TCHAR *value) noexcept; -#endif - bool Get(std::string_view key, int &value) noexcept; diff --git a/src/Profile/StringValue.cpp b/src/Profile/StringValue.cpp index c96b2f6a6d0..37c57b7043b 100644 --- a/src/Profile/StringValue.cpp +++ b/src/Profile/StringValue.cpp @@ -6,12 +6,6 @@ #include "util/TruncateString.hpp" #include "util/Macros.hpp" -#ifdef _UNICODE -#include "util/Macros.hpp" - -#include -#endif - bool ProfileMap::Get(std::string_view key, std::span value) const noexcept { @@ -21,32 +15,10 @@ ProfileMap::Get(std::string_view key, std::span value) const noexcept return false; } -#ifdef _UNICODE - int result = MultiByteToWideChar(CP_UTF8, 0, src, -1, - value.data(), value.size()); - return result > 0; -#else if (!ValidateUTF8(src)) return false; CopyTruncateString(value.data(), value.size(), src); return true; -#endif -} - -#ifdef _UNICODE - -void -ProfileMap::Set(std::string_view key, const TCHAR *value) noexcept -{ - char buffer[MAX_PATH]; - int length = WideCharToMultiByte(CP_UTF8, 0, value, -1, - buffer, ARRAY_SIZE(buffer), - nullptr, nullptr); - if (length <= 0) - return; - - Set(key, buffer); } -#endif diff --git a/src/Topography/XShape.cpp b/src/Topography/XShape.cpp index 55b67db4ffa..c74852cbfd9 100644 --- a/src/Topography/XShape.cpp +++ b/src/Topography/XShape.cpp @@ -14,10 +14,6 @@ #include "ui/canvas/opengl/Triangulate.hpp" #endif -#ifdef _UNICODE -#include "util/ConvertString.hpp" -#endif - #include #include @@ -35,14 +31,10 @@ ImportLabel(const char *src) noexcept StringIsEqual(src, "UNK")) return nullptr; -#ifdef _UNICODE - return ConvertUTF8ToWide(src); -#else if (!ValidateUTF8(src)) return nullptr; return BasicAllocatedString(src); -#endif } /** diff --git a/src/Tracking/LiveTrack24/Client.cpp b/src/Tracking/LiveTrack24/Client.cpp index e00bf9eeb6f..98e0ee11c52 100644 --- a/src/Tracking/LiveTrack24/Client.cpp +++ b/src/Tracking/LiveTrack24/Client.cpp @@ -81,13 +81,7 @@ Client::StartTracking(SessionID session, const TCHAR *username, if (!username2.IsValid() || !password2.IsValid() || !vname2.IsValid()) throw std::runtime_error("WideToUTF8Converter failed"); -#ifdef _UNICODE - NarrowString<32> version; - version.SetASCII(OpenSoar_VersionLong); -#else const char *version = OpenSoar_VersionLong; -#endif - NarrowString<2048> url; url.Format("http://%s/track.php?leolive=2&sid=%u&pid=%u&" "client=%s&v=%s&user=%s&pass=%s&vtype=%u&vname=%s", diff --git a/src/VALI-XCS.cpp b/src/VALI-XCS.cpp index faa6d081a47..8f3ca7736d1 100644 --- a/src/VALI-XCS.cpp +++ b/src/VALI-XCS.cpp @@ -65,12 +65,7 @@ RunValidate(Path path) int main(int argc, char* argv[]) try { - printf("Vali XCS for the XCSoar Flight Computer Version " -#ifdef _UNICODE - "%S\n", -#else - "%s\n", -#endif + printf("Vali XCS for the XCSoar Flight Computer Version %s\n", OpenSoar_Version); if (argc > 1 && strcmp(argv[1], "-?") != 0) { diff --git a/src/Weather/NOAAStore.cpp b/src/Weather/NOAAStore.cpp index 323f2c84fb4..375ca2b7bb8 100644 --- a/src/Weather/NOAAStore.cpp +++ b/src/Weather/NOAAStore.cpp @@ -3,27 +3,6 @@ #include "NOAAStore.hpp" -#ifdef _UNICODE -#include "util/Macros.hpp" -#include "util/ConvertString.hpp" - -#include -#endif - -#ifdef _UNICODE - -const TCHAR * -NOAAStore::Item::GetCodeT() const -{ - static TCHAR code2[ARRAY_SIZE(Item::code)]; - if (MultiByteToWideChar(CP_UTF8, 0, code, -1, code2, ARRAY_SIZE(code2)) <= 0) - return _T(""); - - return code2; -} - -#endif - bool NOAAStore::IsValidCode(const char *code) { @@ -38,22 +17,6 @@ NOAAStore::IsValidCode(const char *code) return true; } -#ifdef _UNICODE -bool -NOAAStore::IsValidCode(const TCHAR* code) -{ - for (unsigned i = 0; i < 4; ++i) - if (! ((code[i] >= _T('A') && code[i] <= _T('Z')) || - (code[i] >= _T('0') && code[i] <= _T('9')))) - return false; - - if (code[4] != _T('\0')) - return false; - - return true; -} -#endif - NOAAStore::iterator NOAAStore::AddStation(const char *code) { @@ -74,14 +37,3 @@ NOAAStore::AddStation(const char *code) return --end(); } -#ifdef _UNICODE -NOAAStore::iterator -NOAAStore::AddStation(const TCHAR *code) -{ - assert(IsValidCode(code)); - - WideToUTF8Converter code2(code); - assert(code2.IsValid()); - return AddStation(code2); -} -#endif diff --git a/src/Weather/NOAAStore.hpp b/src/Weather/NOAAStore.hpp index 88b77252fd6..e6deea99f27 100644 --- a/src/Weather/NOAAStore.hpp +++ b/src/Weather/NOAAStore.hpp @@ -9,10 +9,6 @@ #include -#ifdef _UNICODE -#include -#endif - class NOAAStore { public: @@ -34,18 +30,12 @@ class NOAAStore * (even with different objects) may Invalidate the previous * return value. May be called only from the main thread. */ -#ifdef _UNICODE - [[gnu::pure]] - const TCHAR *GetCodeT() const; -#else const char *GetCodeT() const { return code; } -#endif }; typedef std::list StationContainer; - StationContainer stations; public: @@ -81,9 +71,6 @@ class NOAAStore * @param code Four letter code of the station/airport (upper case) */ static bool IsValidCode(const char *code); -#ifdef _UNICODE - static bool IsValidCode(const TCHAR *code); -#endif /** * Add a station to the set of stations for which @@ -91,9 +78,6 @@ class NOAAStore * @param code Four letter code of the station/airport (upper case) */ iterator AddStation(const char *code); -#ifdef _UNICODE - iterator AddStation(const TCHAR *code); -#endif /** * Returns the amount of stations in the array diff --git a/src/Widget/LargeTextWidget.cpp b/src/Widget/LargeTextWidget.cpp index 7a6c05d644b..b3f85878806 100644 --- a/src/Widget/LargeTextWidget.cpp +++ b/src/Widget/LargeTextWidget.cpp @@ -5,9 +5,6 @@ #include "ui/control/LargeTextWindow.hpp" #include "Look/DialogLook.hpp" -#ifdef _UNICODE -# include "util/ConvertString.hpp" -#endif void LargeTextWidget::SetText(const TCHAR *text) noexcept { @@ -15,21 +12,6 @@ LargeTextWidget::SetText(const TCHAR *text) noexcept w.SetText(text); } -#ifdef _UNICODE -// Maybe this is against MaxK XCSoar rules, but this makes the life much easier -void -LargeTextWidget::SetText(const char *text) noexcept -{ - SetText(ConvertACPToWide(text).c_str()); -} - -void -LargeTextWidget::SetText(std::string_view text) noexcept -{ - SetText(text.data()); -} -#endif - void LargeTextWidget::Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept { diff --git a/src/Widget/LargeTextWidget.hpp b/src/Widget/LargeTextWidget.hpp index dcb7cbfd0ae..3404483eb4a 100644 --- a/src/Widget/LargeTextWidget.hpp +++ b/src/Widget/LargeTextWidget.hpp @@ -6,9 +6,6 @@ #include "WindowWidget.hpp" #include -#ifdef _UNICODE -#include -#endif struct DialogLook; @@ -25,10 +22,6 @@ class LargeTextWidget : public WindowWidget { :look(_look), text(_text) {} void SetText(const TCHAR *text) noexcept; -#ifdef _UNICODE - void SetText(const char *text) noexcept; - void SetText(const std::string_view text) noexcept; -#endif /* virtual methods from class Widget */ void Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept override; bool SetFocus() noexcept override; diff --git a/src/XML/Parser.cpp b/src/XML/Parser.cpp index d6b845f7a47..612182e00a2 100644 --- a/src/XML/Parser.cpp +++ b/src/XML/Parser.cpp @@ -185,7 +185,7 @@ FromXMLString(std::string_view src) noexcept return nullptr; } - // XXX convert to UTF-8 if !_UNICODE + // XXX convert to UTF-8 if !UNI-CODE char ch = (char)i; if (ch == 0) ch = ' '; diff --git a/src/io/BufferedOutputStream.cxx b/src/io/BufferedOutputStream.cxx index 0c706e8b771..15a47cf716f 100644 --- a/src/io/BufferedOutputStream.cxx +++ b/src/io/BufferedOutputStream.cxx @@ -11,11 +11,6 @@ #include -#ifdef _UNICODE -#include "system/Error.hxx" -#include -#endif - bool BufferedOutputStream::AppendToBuffer(std::span src) noexcept { @@ -60,47 +55,6 @@ BufferedOutputStream::VFmt(fmt::string_view format_str, fmt::format_args args) return Write(std::as_bytes(std::span{b.data(), b.size()})); } -#ifdef _UNICODE - -void -BufferedOutputStream::WriteWideToUTF8(std::wstring_view src) -{ - if (src.empty()) - return; - - auto r = buffer.Write(); - if (r.empty()) { - Flush(); - r = buffer.Write(); - } - - int length = WideCharToMultiByte(CP_UTF8, 0, src.data(), src.size(), - (char *)r.data(), r.size(), - nullptr, nullptr); - if (length <= 0) { - const auto error = GetLastError(); - if (error != ERROR_INSUFFICIENT_BUFFER) - throw MakeLastError(error, "UTF-8 conversion failed"); - - /* how much buffer do we need? */ - length = WideCharToMultiByte(CP_UTF8, 0, src.data(), src.size(), - nullptr, 0, nullptr, nullptr); - if (length <= 0) - throw MakeLastError(error, "UTF-8 conversion failed"); - - /* grow the buffer and try again */ - length = WideCharToMultiByte(CP_UTF8, 0, src.data(), src.size(), - (char *)buffer.Write(length), length, - nullptr, nullptr); - if (length <= 0) - throw MakeLastError(error, "UTF-8 conversion failed"); - } - - buffer.Append(length); -} - -#endif - void BufferedOutputStream::Flush() { diff --git a/src/io/BufferedOutputStream.hxx b/src/io/BufferedOutputStream.hxx index 660bd479d21..8853297729e 100644 --- a/src/io/BufferedOutputStream.hxx +++ b/src/io/BufferedOutputStream.hxx @@ -15,10 +15,6 @@ #include #include -#ifdef _UNICODE -#include -#endif - class OutputStream; /** @@ -82,22 +78,6 @@ public: #endif } -#ifdef _UNICODE - /** - * Write one wide character. - */ - void Write(const wchar_t &ch) { - WriteWideToUTF8({&ch, 1}); - } - - /** - * Write a wide string. - */ - void Write(std::wstring_view src) { - WriteWideToUTF8(src); - } -#endif - /** * Finish the current line. */ @@ -123,9 +103,6 @@ public: private: bool AppendToBuffer(std::span src) noexcept; -#ifdef _UNICODE - void WriteWideToUTF8(std::wstring_view src); -#endif }; /** diff --git a/src/io/KeyValueFileWriter.cpp b/src/io/KeyValueFileWriter.cpp index e6abb0d0780..563df5e4ffd 100644 --- a/src/io/KeyValueFileWriter.cpp +++ b/src/io/KeyValueFileWriter.cpp @@ -8,10 +8,6 @@ #include #include -#ifdef _UNICODE -#include -#endif - void KeyValueFileWriter::Write(const char *key, const char *value) { @@ -27,17 +23,3 @@ KeyValueFileWriter::Write(const char *key, const char *value) os.Fmt("{}=\"{}\"\n", key, value); } -#ifdef _UNICODE - -void -KeyValueFileWriter::Write(const char *key, const TCHAR *value) -{ - char buffer[1024]; - int result = WideCharToMultiByte(CP_UTF8, 0, value, -1, - buffer, ARRAY_SIZE(buffer), - nullptr, nullptr); - if (result > 0) - Write(key, buffer); -} - -#endif diff --git a/src/io/KeyValueFileWriter.hpp b/src/io/KeyValueFileWriter.hpp index c5e9a627c28..65040d0ba3d 100644 --- a/src/io/KeyValueFileWriter.hpp +++ b/src/io/KeyValueFileWriter.hpp @@ -3,10 +3,6 @@ #pragma once -#ifdef _UNICODE -#include -#endif - class BufferedOutputStream; class KeyValueFileWriter { @@ -17,7 +13,4 @@ class KeyValueFileWriter { void Write(const char *key, const char *value); -#ifdef _UNICODE - void Write(const char *key, const TCHAR *value); -#endif }; diff --git a/src/io/StringConverter.cpp b/src/io/StringConverter.cpp index 1361e0a19c2..fa24ab83be7 100644 --- a/src/io/StringConverter.cpp +++ b/src/io/StringConverter.cpp @@ -10,23 +10,6 @@ #include #include -#ifdef _UNICODE -#include "system/Error.hxx" -#include -#endif - -#ifdef _UNICODE - -static constexpr TCHAR * -iso_latin_1_to_tchar(TCHAR *dest, std::string_view src) noexcept -{ - for (unsigned char ch : src) - *dest++ = ch; - return dest; -} - -#endif - char * StringConverter::DetectStrip(char *src) noexcept { @@ -74,35 +57,6 @@ StringConverter::Convert(char *narrow) { narrow = DetectStrip(narrow); -#ifdef _UNICODE - const std::string_view src{narrow}; - - TCHAR *t = tbuffer.get(src.size() + 1); - assert(t != nullptr); - - if (src.empty()) { - t[0] = _T('\0'); - return t; - } - - switch (charset) { - case Charset::ISO_LATIN_1: - *iso_latin_1_to_tchar(t, src) = _T('\0'); - break; - - default: - int length = MultiByteToWideChar(CP_UTF8, 0, src.data(), src.size(), - t, src.size()); - if (length == 0) - throw MakeLastError("Failed to convert string"); - - t[length] = _T('\0'); - - break; - } - - return t; -#else switch (charset) { size_t buffer_size; const char *utf8; @@ -128,7 +82,6 @@ StringConverter::Convert(char *narrow) /* unreachable */ gcc_unreachable(); -#endif } tstring_view @@ -138,24 +91,6 @@ StringConverter::Convert(std::string_view src) if (src.empty()) return {}; -#ifdef _UNICODE - TCHAR *t = tbuffer.get(src.size()); - assert(t != nullptr); - - switch (charset) { - case Charset::ISO_LATIN_1: - iso_latin_1_to_tchar(t, src); - return {t, src.size()}; - - default: - int length = MultiByteToWideChar(CP_UTF8, 0, src.data(), src.size(), - t, src.size()); - if (length == 0) - throw MakeLastError("Failed to convert string"); - - return {t, std::size_t(length)}; - } -#else switch (charset) { size_t buffer_size; @@ -181,5 +116,4 @@ StringConverter::Convert(std::string_view src) /* unreachable */ gcc_unreachable(); -#endif } diff --git a/src/lib/fmt/tchar.hxx b/src/lib/fmt/tchar.hxx index 9f9a9762f28..2cf40af2312 100644 --- a/src/lib/fmt/tchar.hxx +++ b/src/lib/fmt/tchar.hxx @@ -5,18 +5,7 @@ #include -#ifdef _UNICODE - -#include - -using fmt_tstring_view = fmt::wstring_view; -using fmt_tformat_context = fmt::wformat_context; -using fmt_tformat_args = fmt::wformat_args; - -#else - using fmt_tstring_view = fmt::string_view; using fmt_tformat_context = fmt::format_context; using fmt_tformat_args = fmt::format_args; -#endif diff --git a/src/net/SocketError.cxx b/src/net/SocketError.cxx index 1b1dceb1bc7..bcae6e090c8 100644 --- a/src/net/SocketError.cxx +++ b/src/net/SocketError.cxx @@ -11,12 +11,7 @@ SocketErrorMessage::SocketErrorMessage(socket_error_t code) noexcept { -#ifdef _UNICODE - wchar_t buffer[msg_size]; -#else auto *buffer = msg; -#endif - DWORD nbytes = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK, @@ -26,16 +21,6 @@ SocketErrorMessage::SocketErrorMessage(socket_error_t code) noexcept strcpy(msg, "Unknown error"); return; } - -#ifdef _UNICODE - auto length = WideCharToMultiByte(CP_UTF8, 0, buffer, -1, - msg, std::size(msg), - nullptr, nullptr); - if (length <= 0) { - strcpy(msg, "WideCharToMultiByte() error"); - return; - } -#endif } #else diff --git a/src/system/Args.hpp b/src/system/Args.hpp index d0570fedf96..d33b3c59560 100644 --- a/src/system/Args.hpp +++ b/src/system/Args.hpp @@ -8,11 +8,7 @@ #include "util/NumberParser.hpp" #include "system/Path.hpp" -#ifdef _UNICODE -#include "system/ConvertPathName.hpp" -#else #include -#endif #include #include @@ -102,12 +98,6 @@ class Args { name = ""; } -#ifdef _UNICODE - void ParseCommandLine(const TCHAR *_cmdline) { - WideToACPConverter convert(_cmdline); - ParseCommandLine(convert); - } -#endif #endif Args &operator=(const Args &other) = delete; @@ -176,29 +166,15 @@ class Args { const char *p = ExpectNext(); assert(p != nullptr); -#ifdef _UNICODE - PathName convert(p); - return tstring(((Path)convert).c_str()); -#else return tstring(p); -#endif } -#ifdef _UNICODE - AllocatedPath ExpectNextPath() { - const char *p = ExpectNext(); - assert(p != nullptr); - - return AllocatedPath(PathName(p)); - } -#else Path ExpectNextPath() { const char *p = ExpectNext(); assert(p != nullptr); return Path(p); } -#endif void ExpectEnd() { if (!IsEmpty()) diff --git a/src/system/ConvertPathName.hpp b/src/system/ConvertPathName.hpp index 7ff51a17ea2..19d5c0be829 100644 --- a/src/system/ConvertPathName.hpp +++ b/src/system/ConvertPathName.hpp @@ -6,14 +6,7 @@ #include "Path.hpp" #include "util/Compiler.h" -#ifdef _UNICODE -#include "util/ConvertString.hpp" -#include "util/LightString.hxx" - -#include -#else #include "util/StringPointer.hxx" -#endif /** * Representation of a file name. It is automatically converted to @@ -22,23 +15,13 @@ * must not be Invalidated. */ class PathName { -#ifdef _UNICODE - typedef LightString Value; -#else typedef StringPointer<> Value; -#endif - Value value; public: explicit PathName(Value::const_pointer _value) noexcept :value(_value) {} -#ifdef _UNICODE - explicit PathName(const char *_value) noexcept - :value(ConvertACPToWide(_value)) {} -#endif - public: bool IsDefined() const noexcept { return !value.IsNull(); @@ -55,22 +38,13 @@ class PathName { * original input string; it must not be Invalidated. */ class NarrowPathName { -#ifdef _UNICODE - typedef LightString Value; -#else typedef StringPointer<> Value; -#endif Value value; public: -#ifdef _UNICODE - explicit NarrowPathName(Path _value) noexcept - :value(ConvertWideToACP(_value.c_str())) {} -#else explicit NarrowPathName(Path _value) noexcept :value(_value.c_str()) {} -#endif public: bool IsDefined() const noexcept { diff --git a/src/system/FileUtil.cpp b/src/system/FileUtil.cpp index 7b1f077b87e..730362fe9ca 100644 --- a/src/system/FileUtil.cpp +++ b/src/system/FileUtil.cpp @@ -304,18 +304,6 @@ File::IsCharDev(Path path) noexcept #endif // HAVE_POSIX -#if defined(_WIN32) && defined(UNICODE) - -bool -File::Exists(const char *path) noexcept -{ - DWORD attributes = GetFileAttributesA(path); - return attributes != INVALID_FILE_ATTRIBUTES && - (attributes & FILE_ATTRIBUTE_DIRECTORY) == 0; -} - -#endif - uint64_t File::GetSize(Path path) noexcept { diff --git a/src/system/FileUtil.hpp b/src/system/FileUtil.hpp index 5e2520117ff..33d7a45b815 100644 --- a/src/system/FileUtil.hpp +++ b/src/system/FileUtil.hpp @@ -110,12 +110,6 @@ IsCharDev(Path path) noexcept; #endif // HAVE_POSIX -#if defined(_WIN32) && defined(UNICODE) -[[gnu::pure]] -bool -Exists(const char *path) noexcept; -#endif - /** * Deletes the given file * @param path Path to the file that should be deleted diff --git a/src/system/Path.cpp b/src/system/Path.cpp index b2801da6fff..e27eb2197d9 100644 --- a/src/system/Path.cpp +++ b/src/system/Path.cpp @@ -7,10 +7,6 @@ #include "util/StringAPI.hxx" #include "util/CharUtil.hxx" -#ifdef _UNICODE -#include "util/ConvertString.hpp" -#endif - #include #include @@ -21,15 +17,7 @@ Path::ToUTF8() const noexcept if (*this == nullptr) return std::string(); -#ifdef _UNICODE - const WideToUTF8Converter utf8(c_str()); - if (!utf8.IsValid()) - return std::string(); - - return (const char *)utf8; -#else return c_str(); -#endif } AllocatedPath diff --git a/src/system/Path.hpp b/src/system/Path.hpp index bb25a60bd10..c13ac17e780 100644 --- a/src/system/Path.hpp +++ b/src/system/Path.hpp @@ -9,10 +9,6 @@ #include #include -#ifdef _UNICODE -#include -#endif - #include class AllocatedPath; @@ -26,11 +22,8 @@ class AllocatedPath; */ class Path { public: -#ifdef _UNICODE - using char_type = wchar_t; -#else using char_type = char; -#endif + using value_type = StringPointer; using const_pointer = value_type::const_pointer; using pointer = value_type::pointer; diff --git a/src/ui/canvas/custom/Cache.cpp b/src/ui/canvas/custom/Cache.cpp index 04d0837a544..10ffc58e51b 100644 --- a/src/ui/canvas/custom/Cache.cpp +++ b/src/ui/canvas/custom/Cache.cpp @@ -15,10 +15,6 @@ #include "thread/Mutex.hxx" #endif -#ifdef UNICODE -#include "util/ConvertString.hpp" -#endif - #include #include @@ -169,11 +165,7 @@ TextCache::GetSize(const Font &font, std::string_view text) noexcept if (const PixelSize *cached = size_cache.Get(key)) return *cached; -#ifdef UNICODE - PixelSize size = font.TextSize(UTF8ToWideConverter(text)); -#else PixelSize size = font.TextSize(text); -#endif key.Allocate(); size_cache.Put(std::move(key), size); @@ -223,11 +215,7 @@ TextCache::Get(const Font &font, std::string_view text) noexcept /* render the text into a OpenGL texture */ #if defined(USE_FREETYPE) || defined(USE_APPKIT) || defined(USE_UIKIT) -#ifdef UNICODE - UTF8ToWideConverter text2(text); -#else std::string_view text2 = text; -#endif PixelSize size = font.TextSize(text2); size_t buffer_size = font.BufferSize(size); if (buffer_size == 0) diff --git a/src/ui/canvas/custom/LibTiff.cpp b/src/ui/canvas/custom/LibTiff.cpp index b8b6adfc9c0..2952f8f331b 100644 --- a/src/ui/canvas/custom/LibTiff.cpp +++ b/src/ui/canvas/custom/LibTiff.cpp @@ -26,11 +26,7 @@ TiffOpen(Path path, const char *mode) XTIFFInitialize(); #endif -#ifdef _UNICODE - return TIFFOpenW(path.c_str(), mode); -#else return TIFFOpen(path.c_str(), mode); -#endif } class TiffLoader { diff --git a/src/ui/canvas/custom/MoreCanvas.cpp b/src/ui/canvas/custom/MoreCanvas.cpp index 00405b5266d..f5faa3ddd42 100644 --- a/src/ui/canvas/custom/MoreCanvas.cpp +++ b/src/ui/canvas/custom/MoreCanvas.cpp @@ -40,10 +40,7 @@ unsigned Canvas::DrawFormattedText(const PixelRect r, const tstring_view text, const unsigned format) noexcept { -#ifndef UNICODE assert(ValidateUTF8(text)); -#endif - if (font == nullptr) return 0; diff --git a/src/ui/canvas/freetype/Font.cpp b/src/ui/canvas/freetype/Font.cpp index 517e2e87034..6a1a278b0aa 100644 --- a/src/ui/canvas/freetype/Font.cpp +++ b/src/ui/canvas/freetype/Font.cpp @@ -14,9 +14,7 @@ #include "thread/Mutex.hxx" #endif -#ifndef _UNICODE #include "util/UTF8.hpp" -#endif #if defined(__clang__) && defined(__arm__) /* work around warning: 'register' storage class specifier is @@ -81,15 +79,9 @@ NextChar(tstring_view &s) noexcept { assert(!s.empty()); -#ifdef _UNICODE - const unsigned ch = s.front(); - s.remove_prefix(1); - return ch; -#else auto n = NextUTF8(s.data()); s.remove_prefix(n.second - s.data()); return n.first; -#endif } void @@ -213,9 +205,7 @@ Font::Destroy() noexcept static void ForEachChar(tstring_view text, std::invocable auto f) { -#ifndef _UNICODE assert(ValidateUTF8(text)); -#endif while (!text.empty()) { const unsigned ch = NextChar(text); diff --git a/src/ui/canvas/gdi/GdiPlusBitmap.cpp b/src/ui/canvas/gdi/GdiPlusBitmap.cpp index 7c614be28f5..d48daf8ff24 100644 --- a/src/ui/canvas/gdi/GdiPlusBitmap.cpp +++ b/src/ui/canvas/gdi/GdiPlusBitmap.cpp @@ -39,11 +39,7 @@ HBITMAP GdiLoadImage(const TCHAR* filename) { HBITMAP result = nullptr; -#ifdef _UNICODE // TCHAR has to be WCHAR in GdiPlus - Gdiplus::Bitmap bitmap(filename, false); -#else Gdiplus::Bitmap bitmap(UTF8ToWide(filename).c_str(), false); -#endif // _UNICODE if (bitmap.GetLastStatus() != Gdiplus::Ok) return nullptr; const Gdiplus::Color color = Gdiplus::Color::White; diff --git a/src/ui/canvas/memory/Canvas.cpp b/src/ui/canvas/memory/Canvas.cpp index a4552183638..b3816477310 100644 --- a/src/ui/canvas/memory/Canvas.cpp +++ b/src/ui/canvas/memory/Canvas.cpp @@ -17,10 +17,6 @@ #include "util/UTF8.hpp" #endif -#ifdef UNICODE -#include "util/ConvertString.hpp" -#endif - #include #include #include @@ -202,12 +198,8 @@ Canvas::DrawArc(PixelPoint center, unsigned radius, const PixelSize Canvas::CalcTextSize(tstring_view text) const noexcept { -#ifdef UNICODE - const WideToUTF8Converter text2(text); -#else const std::string_view text2 = text; assert(ValidateUTF8(text)); -#endif PixelSize size = { 0, 0 }; @@ -230,11 +222,7 @@ RenderText(const Font *font, tstring_view text) noexcept assert(font->IsDefined()); -#ifdef UNICODE - return TextCache::Get(*font, WideToUTF8Converter(text)); -#else return TextCache::Get(*font, text); -#endif } template @@ -270,10 +258,7 @@ CopyTextRectangle(SDLRasterCanvas &canvas, int x, int y, void Canvas::DrawText(PixelPoint p, tstring_view text) noexcept { -#ifndef UNICODE assert(ValidateUTF8(text)); -#endif - auto s = RenderText(font, text); if (!s) return; @@ -287,9 +272,7 @@ Canvas::DrawText(PixelPoint p, tstring_view text) noexcept void Canvas::DrawTransparentText(PixelPoint p, tstring_view text) noexcept { -#ifndef UNICODE assert(ValidateUTF8(text)); -#endif auto s = RenderText(font, text); if (s.data == nullptr) @@ -314,9 +297,7 @@ void Canvas::DrawClippedText(PixelPoint p, unsigned width, tstring_view text) noexcept { -#ifndef UNICODE assert(ValidateUTF8(text)); -#endif auto s = RenderText(font, text); if (s.data == nullptr) diff --git a/src/ui/canvas/opengl/Canvas.cpp b/src/ui/canvas/opengl/Canvas.cpp index e206ce03bcc..5aa15615228 100644 --- a/src/ui/canvas/opengl/Canvas.cpp +++ b/src/ui/canvas/opengl/Canvas.cpp @@ -25,10 +25,6 @@ #include #include -#ifdef UNICODE -#include "util/ConvertString.hpp" -#endif - #ifndef NDEBUG #include "util/UTF8.hpp" #endif @@ -541,12 +537,8 @@ Canvas::DrawFocusRectangle(PixelRect rc) noexcept const PixelSize Canvas::CalcTextSize(tstring_view text) const noexcept { -#ifdef UNICODE - const WideToUTF8Converter text2(text); -#else const std::string_view text2 = text; assert(ValidateUTF8(text)); -#endif PixelSize size = { 0, 0 }; @@ -574,12 +566,8 @@ PrepareColoredAlphaTexture(Color color) noexcept void Canvas::DrawText(PixelPoint p, tstring_view text) noexcept { -#ifdef UNICODE - const WideToUTF8Converter text2(text); -#else const std::string_view text2 = text; assert(ValidateUTF8(text)); -#endif assert(offset == OpenGL::translate); @@ -608,12 +596,8 @@ Canvas::DrawText(PixelPoint p, tstring_view text) noexcept void Canvas::DrawTransparentText(PixelPoint p, tstring_view text) noexcept { -#ifdef UNICODE - const WideToUTF8Converter text2(text); -#else const std::string_view text2 = text; assert(ValidateUTF8(text)); -#endif assert(offset == OpenGL::translate); @@ -640,12 +624,8 @@ void Canvas::DrawClippedText(PixelPoint p, PixelSize size, tstring_view text) noexcept { -#ifdef UNICODE - const WideToUTF8Converter text2(text); -#else const std::string_view text2 = text; assert(ValidateUTF8(text)); -#endif assert(offset == OpenGL::translate); diff --git a/src/ui/window/sdl/TopWindow.cpp b/src/ui/window/sdl/TopWindow.cpp index 3d8a018a61a..1fc4e5543e3 100644 --- a/src/ui/window/sdl/TopWindow.cpp +++ b/src/ui/window/sdl/TopWindow.cpp @@ -7,10 +7,6 @@ #include "lib/fmt/RuntimeError.hxx" #include "util/UTF8.hpp" -#ifdef UNICODE -#include "util/ConvertString.hpp" -#endif - #include #include @@ -57,12 +53,7 @@ void TopWindow::CreateNative(const TCHAR *_text, PixelSize new_size, TopWindowStyle style) { -#ifdef UNICODE - const WideToUTF8Converter text(_text); -#else const char *text = _text; -#endif - const bool full_screen = style.GetFullScreen(); const bool resizable = style.GetResizable(); const Uint32 flags = MakeSDLFlags(full_screen, resizable); diff --git a/src/util/ASCII.hxx b/src/util/ASCII.hxx index 5db82db7d0b..780eec6c6c3 100644 --- a/src/util/ASCII.hxx +++ b/src/util/ASCII.hxx @@ -6,10 +6,6 @@ #include #include -#ifdef _UNICODE -#include "WASCII.hxx" -#endif - /** * Copy all ASCII characters to the destination string * (i.e. 0x01..0x7f), ignoring the others. In the worst case, the diff --git a/src/util/CharUtil.hxx b/src/util/CharUtil.hxx index 3f111b3ac42..19780fa6442 100644 --- a/src/util/CharUtil.hxx +++ b/src/util/CharUtil.hxx @@ -3,10 +3,6 @@ #pragma once -#ifdef _UNICODE -#include "WCharUtil.hxx" -#endif - constexpr bool IsASCII(const unsigned char ch) noexcept { diff --git a/src/util/ConvertString.cpp b/src/util/ConvertString.cpp index f4f3c343c63..c8ad89883e8 100644 --- a/src/util/ConvertString.cpp +++ b/src/util/ConvertString.cpp @@ -3,79 +3,5 @@ #include "ConvertString.hpp" -#ifdef _UNICODE -#include -static BasicAllocatedString -ConvertToWide(const char *p, UINT codepage) noexcept -{ - assert(p != nullptr); - - int length = MultiByteToWideChar(codepage, 0, p, -1, nullptr, 0); - if (length <= 0) - return nullptr; - - wchar_t *buffer = new wchar_t[length]; - length = MultiByteToWideChar(codepage, 0, p, -1, buffer, length); - if (length <= 0) { - delete[] buffer; - return nullptr; - } - - return BasicAllocatedString::Donate(buffer); -} - -BasicAllocatedString -ConvertUTF8ToWide(const char *p) noexcept -{ - assert(p != nullptr); - - return ConvertToWide(p, CP_UTF8); -} - -BasicAllocatedString -ConvertACPToWide(const char *p) noexcept -{ - assert(p != nullptr); - - return ConvertToWide(p, CP_ACP); -} - -static AllocatedString -ConvertFromWide(const wchar_t *p, UINT codepage) noexcept -{ - assert(p != nullptr); - - int length = WideCharToMultiByte(codepage, 0, p, -1, nullptr, 0, - nullptr, nullptr); - if (length <= 0) - return nullptr; - - char *buffer = new char[length]; - length = WideCharToMultiByte(codepage, 0, p, -1, buffer, length, - nullptr, nullptr); - if (length <= 0) { - delete[] buffer; - return nullptr; - } - - return AllocatedString::Donate(buffer); -} - -AllocatedString -ConvertWideToUTF8(const wchar_t *p) noexcept -{ - assert(p != nullptr); - - return ConvertFromWide(p, CP_UTF8); -} - -AllocatedString -ConvertWideToACP(const wchar_t *p) noexcept -{ - assert(p != nullptr); - - return ConvertFromWide(p, CP_ACP); -} - -#endif +// removed w/o Unicode \ No newline at end of file diff --git a/src/util/ConvertString.hpp b/src/util/ConvertString.hpp index 078442c6a3c..a049359124d 100644 --- a/src/util/ConvertString.hpp +++ b/src/util/ConvertString.hpp @@ -5,97 +5,39 @@ #include "UTF8.hpp" -#ifdef _UNICODE -# define _W(text) (UTF8ToWideConverter(text).c_str()) -# define _A(text) (WideToUTF8Converter(text).c_str()) -#else -# define _W(text) (text) -# define _A(text) (text) -#endif +#define _W(text) (text) +#define _A(text) (text) - - -#ifdef _UNICODE -#include "AllocatedString.hxx" -#else #include "StringPointer.hxx" -#endif #include -#ifdef _UNICODE - -#include - -/** - * @return nullptr on error - */ -[[gnu::nonnull]] -BasicAllocatedString -ConvertUTF8ToWide(const char *p) noexcept; - -/** - * @return nullptr on error - */ -[[gnu::nonnull]] -BasicAllocatedString -ConvertACPToWide(const char *p) noexcept; - -/** - * @return nullptr on error - */ -[[gnu::nonnull]] -AllocatedString -ConvertWideToUTF8(const wchar_t *p) noexcept; - -/** - * @return nullptr on error - */ -[[gnu::nonnull]] -AllocatedString -ConvertWideToACP(const wchar_t *p) noexcept; - -#endif - /** * Convert a UTF-8 string to a TCHAR string. The source buffer passed * to the constructor must be valid as long as this object is being * used. */ class UTF8ToWideConverter { -#ifdef _UNICODE - typedef BasicAllocatedString Value; -#else typedef StringPointer<> Value; -#endif typedef typename Value::const_pointer const_pointer; Value value; public: -#ifdef _UNICODE - UTF8ToWideConverter(const char *_value) noexcept - :value(ConvertUTF8ToWide(_value)) {} -#else UTF8ToWideConverter(const_pointer _value) noexcept :value(_value) { assert(_value != nullptr); } -#endif UTF8ToWideConverter(const UTF8ToWideConverter &other) = delete; UTF8ToWideConverter &operator=(const UTF8ToWideConverter &other) = delete; [[gnu::pure]] bool IsValid() const noexcept { -#ifdef _UNICODE - return value != nullptr; -#else assert(value != nullptr); return ValidateUTF8(value.c_str()); -#endif } const_pointer c_str() const noexcept { @@ -116,39 +58,26 @@ class UTF8ToWideConverter { * constructor must be valid as long as this object is being used. */ class WideToUTF8Converter { -#ifdef _UNICODE - typedef AllocatedString Value; -#else typedef StringPointer<> Value; -#endif typedef typename Value::const_pointer const_pointer; Value value; public: -#ifdef _UNICODE - WideToUTF8Converter(const wchar_t *_value) noexcept - :value(ConvertWideToUTF8(_value)) {} -#else WideToUTF8Converter(const_pointer _value) noexcept :value(_value) { assert(_value != nullptr); } -#endif WideToUTF8Converter(const WideToUTF8Converter &other) = delete; WideToUTF8Converter &operator=(const WideToUTF8Converter &other) = delete; [[gnu::pure]] bool IsValid() const noexcept { -#ifdef _UNICODE - return value != nullptr; -#else assert(value != nullptr); return true; -#endif } const_pointer c_str() const noexcept { @@ -170,39 +99,26 @@ class WideToUTF8Converter { * object is being used. */ class WideToACPConverter { -#ifdef _UNICODE - typedef AllocatedString Value; -#else typedef StringPointer<> Value; -#endif typedef typename Value::const_pointer const_pointer; Value value; public: -#ifdef _UNICODE - WideToACPConverter(const wchar_t *_value) noexcept - :value(ConvertWideToACP(_value)) {} -#else WideToACPConverter(const_pointer _value) noexcept :value(_value) { assert(_value != nullptr); } -#endif WideToACPConverter(const WideToACPConverter &other) = delete; WideToACPConverter &operator=(const WideToACPConverter &other) = delete; [[gnu::pure]] bool IsValid() const noexcept { -#ifdef _UNICODE - return value != nullptr; -#else assert(value != nullptr); return true; -#endif } const_pointer c_str() const noexcept { diff --git a/src/util/IterableSplitString.hxx b/src/util/IterableSplitString.hxx index 9349f76ea53..81f76c8c592 100644 --- a/src/util/IterableSplitString.hxx +++ b/src/util/IterableSplitString.hxx @@ -94,10 +94,4 @@ public: }; using IterableSplitString = BasicIterableSplitString; - -#ifdef _UNICODE -using WIterableSplitString = BasicIterableSplitString; -using TIterableSplitString = WIterableSplitString; -#else using TIterableSplitString = IterableSplitString; -#endif diff --git a/src/util/NumberParser.hpp b/src/util/NumberParser.hpp index 4dbdb0538b0..0b60513f5bc 100644 --- a/src/util/NumberParser.hpp +++ b/src/util/NumberParser.hpp @@ -7,10 +7,6 @@ #include #include -#ifdef _UNICODE -#include -#endif - static inline double ParseDouble(const char *p, char **endptr=nullptr) { @@ -19,40 +15,6 @@ ParseDouble(const char *p, char **endptr=nullptr) return (double)strtod(p, endptr); } -#ifdef _UNICODE -static inline double -ParseDouble(const wchar_t *p, wchar_t **endptr) -{ - assert(p != nullptr); - - return (double)wcstod(p, endptr); -} - -#ifdef _WIN32 -#include -#ifdef __MINGW64_VERSION_MAJOR -#if __MINGW64_VERSION_MAJOR == 3 && __MINGW64_VERSION_MINOR == 1 -#define BUGGY_WCSTOD -#endif -#endif -#endif - -static inline double -ParseDouble(const wchar_t *p) -{ - assert(p != nullptr); - -#ifdef BUGGY_WCSTOD - /* workaround for mingw64 3.1 bug to avoid nullptr dereference */ - wchar_t *dummy; - return ParseDouble(p, &dummy); -#else - return ParseDouble(p, nullptr); -#endif -} - -#endif - static inline unsigned ParseUnsigned(const char *p, char **endptr=nullptr, int base=10) { @@ -61,16 +23,6 @@ ParseUnsigned(const char *p, char **endptr=nullptr, int base=10) return (unsigned)strtoul(p, endptr, base); } -#ifdef _UNICODE -static inline unsigned -ParseUnsigned(const wchar_t *p, wchar_t **endptr=nullptr, int base=10) -{ - assert(p != nullptr); - - return (unsigned)wcstoul(p, endptr, base); -} -#endif - static inline int ParseInt(const char *p, char **endptr=nullptr, int base=10) { @@ -79,16 +31,6 @@ ParseInt(const char *p, char **endptr=nullptr, int base=10) return (int)strtol(p, endptr, base); } -#ifdef _UNICODE -static inline int -ParseInt(const wchar_t *p, wchar_t **endptr=nullptr, int base=10) -{ - assert(p != nullptr); - - return (int)wcstol(p, endptr, base); -} -#endif - static inline uint64_t ParseUint64(const char *p, char **endptr=nullptr, int base=10) { @@ -97,16 +39,6 @@ ParseUint64(const char *p, char **endptr=nullptr, int base=10) return strtoull(p, endptr, base); } -#ifdef _UNICODE -static inline uint64_t -ParseUint64(const wchar_t *p, wchar_t **endptr=nullptr, int base=10) -{ - assert(p != nullptr); - - return wcstoull(p, endptr, base); -} -#endif - static inline int64_t ParseInt64(const char *p, char **endptr=nullptr, int base=10) { @@ -115,12 +47,3 @@ ParseInt64(const char *p, char **endptr=nullptr, int base=10) return strtoll(p, endptr, base); } -#ifdef _UNICODE -static inline int64_t -ParseInt64(const wchar_t *p, wchar_t **endptr=nullptr, int base=10) -{ - assert(p != nullptr); - - return wcstoll(p, endptr, base); -} -#endif diff --git a/src/util/StaticString.cxx b/src/util/StaticString.cxx index 03fa5edb01f..c670185c5bd 100644 --- a/src/util/StaticString.cxx +++ b/src/util/StaticString.cxx @@ -3,10 +3,6 @@ #include "StaticString.hxx" -#ifdef _UNICODE -#include -#endif - bool CopyUTF8(char *dest, size_t dest_size, const char *src) noexcept { @@ -18,13 +14,3 @@ CopyUTF8(char *dest, size_t dest_size, const char *src) noexcept return true; } -#ifdef _UNICODE - -bool -CopyUTF8(wchar_t *dest, size_t dest_size, const char *src) noexcept -{ - int result = MultiByteToWideChar(CP_UTF8, 0, src, -1, dest, dest_size); - return result > 0; -} - -#endif diff --git a/src/util/StaticString.hxx b/src/util/StaticString.hxx index 6af2a61b99c..88a0c46f69e 100644 --- a/src/util/StaticString.hxx +++ b/src/util/StaticString.hxx @@ -15,18 +15,9 @@ #include #include -#ifdef _UNICODE -# include -#endif - bool CopyUTF8(char *dest, size_t dest_size, const char *src) noexcept; -#ifdef _UNICODE -bool -CopyUTF8(wchar_t *dest, size_t dest_size, const char *src) noexcept; -#endif - /** * A string with a maximum size known at compile time. */ @@ -80,13 +71,6 @@ public: *end = SENTINEL; } -#ifdef _UNICODE - void SetASCII(std::wstring_view src) noexcept { - pointer end = ::CopyASCII(data(), capacity() - 1, src); - *end = SENTINEL; - } -#endif - /** * Eliminate all non-ASCII characters. */ @@ -305,35 +289,4 @@ public: } }; -#ifdef _UNICODE - -/** - * A string with a maximum size known at compile time. - * This is the TCHAR-based sister of the NarrowString class. - */ -template -class StaticString: public StaticStringBase -{ - typedef StaticStringBase Base; - -public: - using typename Base::value_type; - using typename Base::reference; - using typename Base::pointer; - using typename Base::const_pointer; - using typename Base::const_iterator; - using typename Base::size_type; - - using Base::Base; - using Base::operator=; - using Base::operator+=; - - void CropIncompleteUTF8() noexcept { - /* this is a wchar_t string, it's not multi-byte, - therefore we have no incomplete sequences */ - } -}; - -#else #define StaticString NarrowString -#endif diff --git a/src/util/StringAPI.hxx b/src/util/StringAPI.hxx index a38185d1f12..4c0025dd590 100644 --- a/src/util/StringAPI.hxx +++ b/src/util/StringAPI.hxx @@ -5,10 +5,6 @@ #include -#ifdef _UNICODE -#include "WStringAPI.hxx" -#endif - [[gnu::pure]] [[gnu::nonnull]] static inline size_t StringLength(const char *p) noexcept diff --git a/src/util/StringBuilder.cxx b/src/util/StringBuilder.cxx index 6264084208a..5737a368d0e 100644 --- a/src/util/StringBuilder.cxx +++ b/src/util/StringBuilder.cxx @@ -6,10 +6,6 @@ #include -#ifdef _UNICODE -#include -#endif - #include #include @@ -49,6 +45,3 @@ BasicStringBuilder::Format(const_pointer fmt, ...) Extend(n); } -#ifdef _UNICODE -template class BasicStringBuilder; -#endif diff --git a/src/util/StringCompare.hxx b/src/util/StringCompare.hxx index 76b1a39d30e..8d7525ad0ee 100644 --- a/src/util/StringCompare.hxx +++ b/src/util/StringCompare.hxx @@ -5,10 +5,6 @@ #include "StringAPI.hxx" -#ifdef _UNICODE -#include "WStringCompare.hxx" -#endif - #include [[gnu::pure]] [[gnu::nonnull]] diff --git a/src/util/StringFormat.hpp b/src/util/StringFormat.hpp index ac26587a977..73dea28ceac 100644 --- a/src/util/StringFormat.hpp +++ b/src/util/StringFormat.hpp @@ -3,10 +3,6 @@ #pragma once -#ifdef _UNICODE -#include "WStringFormat.hpp" -#endif - #include template diff --git a/src/util/StringStrip.hxx b/src/util/StringStrip.hxx index 5032858e5bd..11c229822f4 100644 --- a/src/util/StringStrip.hxx +++ b/src/util/StringStrip.hxx @@ -6,10 +6,6 @@ #include #include -#ifdef _UNICODE -#include "WStringStrip.hxx" -#endif - /** * Skips whitespace at the beginning of the string, and returns the * first non-whitespace character. If the string has no diff --git a/src/util/StringUtil.hpp b/src/util/StringUtil.hpp index eb5354e44ba..1120dd99459 100644 --- a/src/util/StringUtil.hpp +++ b/src/util/StringUtil.hpp @@ -6,10 +6,6 @@ #include #include -#ifdef _UNICODE -#include "WStringUtil.hpp" -#endif - /** * Copy a string. If the buffer is too small, then the string is * truncated. This is a safer version of strncpy(). diff --git a/src/util/TruncateString.cpp b/src/util/TruncateString.cpp index aa80cbcb45c..20641f908ef 100644 --- a/src/util/TruncateString.cpp +++ b/src/util/TruncateString.cpp @@ -24,25 +24,6 @@ CopyTruncateString(char *dest, size_t dest_size, const char *src) return CropIncompleteUTF8(dest); } -#ifdef _UNICODE - -TCHAR * -CopyTruncateString(TCHAR *dest, size_t dest_size, const TCHAR *src) -{ - assert(dest != nullptr); - assert(dest_size > 0); - assert(src != nullptr); - - size_t src_length = StringLength(src); - size_t copy = std::min(src_length, dest_size - 1); - - auto *p = std::copy_n(src, copy, dest); - *p = _T('\0'); - return p; -} - -#endif - TCHAR * CopyTruncateString(TCHAR *dest, size_t dest_size, const TCHAR *src, size_t truncate) @@ -51,14 +32,5 @@ CopyTruncateString(TCHAR *dest, size_t dest_size, assert(dest_size > 0); assert(src != nullptr); -#ifdef _UNICODE - size_t src_length = StringLength(src); - size_t copy = std::min({src_length, truncate, dest_size - 1}); - - auto *p = std::copy_n(src, copy, dest); - *p = _T('\0'); - return p; -#else return CopyTruncateStringUTF8({dest, dest_size}, src, truncate); -#endif } diff --git a/src/util/TruncateString.hpp b/src/util/TruncateString.hpp index 1a8102bf7b9..3393dfcd2c5 100644 --- a/src/util/TruncateString.hpp +++ b/src/util/TruncateString.hpp @@ -16,12 +16,6 @@ */ char * CopyTruncateString(char *dest, size_t dest_size, const char *src); - -#ifdef _UNICODE -TCHAR * -CopyTruncateString(TCHAR *dest, size_t dest_size, const TCHAR *src); -#endif - /** * Copy a string to a buffer, truncating it if the buffer is not large * enough. At most #truncate characters will be copied. No partial diff --git a/src/util/UTF8.hpp b/src/util/UTF8.hpp index 4fa9f033beb..b3fba5c01f4 100644 --- a/src/util/UTF8.hpp +++ b/src/util/UTF8.hpp @@ -136,10 +136,10 @@ CopyTruncateStringUTF8(std::span dest, const char *src, std::size_t truncate) noexcept; /** - * Decode the next UNICODE character. + * Decode the next UTF-8 character. * * @param p a null-terminated valid UTF-8 string - * @return a pair containing the next UNICODE character code and a + * @return a pair containing the next UTF-8(?) character code and a * pointer to the first byte of the following character or 0 if * already at the end of the string */ diff --git a/src/util/tstring.hpp b/src/util/tstring.hpp index 450ebd5d5b2..4901fbda465 100644 --- a/src/util/tstring.hpp +++ b/src/util/tstring.hpp @@ -5,8 +5,4 @@ #include -#ifdef _UNICODE -using tstring = std::wstring; -#else using tstring = std::string; -#endif diff --git a/src/util/tstring_view.hxx b/src/util/tstring_view.hxx index 4ab300776da..65f44557eba 100644 --- a/src/util/tstring_view.hxx +++ b/src/util/tstring_view.hxx @@ -5,8 +5,4 @@ #include -#ifdef _UNICODE -using tstring_view = std::wstring_view; -#else using tstring_view = std::string_view; -#endif diff --git a/test/src/FakeLogFile.cpp b/test/src/FakeLogFile.cpp index b2e6508ba61..4eef768f0af 100644 --- a/test/src/FakeLogFile.cpp +++ b/test/src/FakeLogFile.cpp @@ -41,22 +41,6 @@ LogFormat(const char *fmt, ...) noexcept fputc('\n', stderr); } -#ifdef _UNICODE - -void -LogFormat(const wchar_t *fmt, ...) noexcept -{ - va_list ap; - - va_start(ap, fmt); - vfwprintf(stderr, fmt, ap); - va_end(ap); - - fputc('\n', stderr); -} - -#endif - void LogError(std::exception_ptr e) noexcept { diff --git a/test/src/TestUTF8.cpp b/test/src/TestUTF8.cpp index 81b304495b1..b7d0d2fb6d7 100644 --- a/test/src/TestUTF8.cpp +++ b/test/src/TestUTF8.cpp @@ -89,8 +89,6 @@ MyValidateUTF8(const char *p) } } -#ifndef _UNICODE - static constexpr struct { const char *src; size_t truncate, dest_size; @@ -125,7 +123,6 @@ TestTruncateString() } } -#endif int main() { @@ -134,9 +131,7 @@ int main() 2 * ARRAY_SIZE(length) + 4 * ARRAY_SIZE(crop) + ARRAY_SIZE(latin1_chars) + -#ifndef _UNICODE ARRAY_SIZE(truncate_string_tests) + -#endif 9 + 27); for (auto i : valid) { @@ -170,9 +165,7 @@ int main() ok1(end == buffer + strlen(buffer)); } -#ifndef _UNICODE TestTruncateString(); -#endif { const char *p = "foo\xe7\x9b\xae"; From 9ebcdcb5c458ed9e88e432ac0cb18c63a2c2edb7 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sun, 21 Apr 2024 12:53:03 +0200 Subject: [PATCH 377/403] [UTF8] Replace _tcsXXX functions through strXXX functions 142 replacements in src/* 2 replacements in test/* --- src/Audio/Sound.cpp | 4 +-- src/Device/Config.cpp | 2 +- src/Device/Driver/LX/Declare.cpp | 2 +- src/Device/Port/ConfiguredPort.cpp | 8 ++--- src/Dialogs/Airspace/dlgAirspaceWarnings.cpp | 6 ++-- src/Dialogs/KnobTextEntry.cpp | 2 +- src/Dialogs/Task/Manager/TaskListPanel.cpp | 4 +-- src/Dialogs/Task/dlgTaskHelpers.cpp | 30 ++++++++-------- src/Dialogs/TouchTextEntry.cpp | 2 +- src/Dialogs/Traffic/FlarmTrafficDetails.cpp | 4 +-- src/Dialogs/Traffic/TeamCodeDialog.cpp | 2 +- src/Dialogs/Weather/NOAAList.cpp | 2 +- src/Engine/Airspace/AbstractAirspace.cpp | 2 +- src/Form/DataField/Enum.cpp | 8 ++--- src/Form/DataField/File.cpp | 12 +++---- src/Form/DataField/Password.cpp | 4 +-- src/Form/DataField/Prefix.cpp | 2 +- src/Formatter/AirspaceUserUnitsFormatter.cpp | 6 ++-- src/Formatter/AngleFormatter.cpp | 4 +-- src/Formatter/IGCFilenameFormatter.cpp | 6 ++-- src/Formatter/TimeFormatter.cpp | 18 +++++----- src/Gauge/BigTrafficWidget.cpp | 2 +- src/Gauge/GaugeVario.cpp | 2 +- src/InfoBoxes/Content/Thermal.cpp | 2 +- src/Input/InputEventsMap.cpp | 2 +- src/Input/InputEventsSettings.cpp | 2 +- src/Logger/Logger.cpp | 8 ++--- src/Logger/LoggerImpl.cpp | 2 +- src/Look/FontDescription.cpp | 2 +- src/Menu/MenuData.hpp | 2 +- src/PopupMessage.cpp | 6 ++-- src/Renderer/FlightStatisticsRenderer.cpp | 2 +- src/Renderer/WaypointRenderer.cpp | 8 ++--- src/Task/ValidationErrorStrings.cpp | 6 ++-- src/Waypoint/WaypointFilter.cpp | 2 +- src/Weather/METARParser.cpp | 34 +++++++++---------- src/Weather/NOAAFormatter.cpp | 4 +-- src/system/FileUtil.cpp | 30 ++++++++-------- src/system/Path.cpp | 2 +- src/system/PathName.cpp | 2 +- src/ui/canvas/custom/MoreCanvas.cpp | 4 +-- src/ui/control/gdi/LargeTextWindow.cpp | 2 +- src/unix/tchar.h | 11 ------ src/util/EscapeBackslash.cpp | 2 +- src/util/RadixTree.hpp | 2 +- test/data/wp_parser/MBG08.xcm | Bin 1768125 -> 1768124 bytes test/src/RunNOAADownloader.cpp | 2 +- test/src/RunWaveComputer.cpp | 2 +- 48 files changed, 132 insertions(+), 143 deletions(-) diff --git a/src/Audio/Sound.cpp b/src/Audio/Sound.cpp index 651ee7b5fd4..cbe5c80f233 100644 --- a/src/Audio/Sound.cpp +++ b/src/Audio/Sound.cpp @@ -23,13 +23,13 @@ PlayResource(const TCHAR *resource_name) { #ifdef ANDROID - if (_tcsstr(resource_name, _T(".wav"))) + if (strstr(resource_name, _T(".wav"))) return SoundUtil::PlayExternal(Java::GetEnv(), context->Get(), resource_name); return SoundUtil::Play(Java::GetEnv(), context->Get(), resource_name); #elif defined(_WIN32) - if (_tcsstr(resource_name, TEXT(".wav"))) + if (strstr(resource_name, TEXT(".wav"))) return sndPlaySound(resource_name, SND_ASYNC | SND_NODEFAULT); ResourceLoader::Data data = ResourceLoader::Load(resource_name, _T("WAVE")); diff --git a/src/Device/Config.cpp b/src/Device/Config.cpp index 08076a1837a..45f689b9ae9 100644 --- a/src/Device/Config.cpp +++ b/src/Device/Config.cpp @@ -123,7 +123,7 @@ DeviceConfig::MaybeBluetooth(PortType port_type, [[maybe_unused]] const TCHAR *p return true; #ifdef HAVE_POSIX - if (port_type == PortType::SERIAL && _tcsstr(path, _T("/rfcomm")) != nullptr) + if (port_type == PortType::SERIAL && strstr(path, _T("/rfcomm")) != nullptr) return true; #endif diff --git a/src/Device/Driver/LX/Declare.cpp b/src/Device/Driver/LX/Declare.cpp index 39c9f99de2d..8b0fbd3ee73 100644 --- a/src/Device/Driver/LX/Declare.cpp +++ b/src/Device/Driver/LX/Declare.cpp @@ -18,7 +18,7 @@ static void copy_space_padded(char dest[], const TCHAR src[], unsigned int len) { - const unsigned slen = _tcslen(src); + const unsigned slen = strlen(src); for(unsigned i = 0; i < (len - 1); i++) { if (i < slen) dest[i] = (char)std::max((src[i] & 0x7f), 0x20); diff --git a/src/Device/Port/ConfiguredPort.cpp b/src/Device/Port/ConfiguredPort.cpp index 62450e8e5fa..83f56caae48 100644 --- a/src/Device/Port/ConfiguredPort.cpp +++ b/src/Device/Port/ConfiguredPort.cpp @@ -70,8 +70,8 @@ WindowsPort(TCHAR buffer[], const DeviceConfig &config) { throw std::runtime_error("No port path configured"); // the usual windows style of device names: - _tcscpy(buffer, _T("\\\\.\\")); - _tcscat(buffer, config.path.c_str());return buffer; + strcpy(buffer, _T("\\\\.\\")); + strcat(buffer, config.path.c_str());return buffer; } #endif @@ -240,8 +240,8 @@ OpenPortInternal(EventLoop &event_loop, Cares::Channel &cares, throw std::runtime_error("No port path configured"); // the usual windows style of device names: - _tcscpy(buffer, _T("\\\\.\\")); - _tcscat(buffer, config.path.c_str()); + strcpy(buffer, _T("\\\\.\\")); + strcat(buffer, config.path.c_str()); path = buffer; #else throw std::runtime_error("Android USB serial not available"); diff --git a/src/Dialogs/Airspace/dlgAirspaceWarnings.cpp b/src/Dialogs/Airspace/dlgAirspaceWarnings.cpp index 8b42dc7b6d5..401fd94c49c 100644 --- a/src/Dialogs/Airspace/dlgAirspaceWarnings.cpp +++ b/src/Dialogs/Airspace/dlgAirspaceWarnings.cpp @@ -326,15 +326,15 @@ AirspaceWarningListWidget::OnPaintItem(Canvas &canvas, (int)solution.elapsed_time.count()); if (solution.distance > 0) - _stprintf(buffer + _tcslen(buffer), _T(" dist %d m"), + _stprintf(buffer + strlen(buffer), _T(" dist %d m"), (int)solution.distance); else { /* the airspace is right above or below us - show the vertical distance */ - _tcscat(buffer, _T(" vertical ")); + strcat(buffer, _T(" vertical ")); auto delta = solution.altitude - CommonInterface::Basic().nav_altitude; - FormatRelativeUserAltitude(delta, buffer + _tcslen(buffer), true); + FormatRelativeUserAltitude(delta, buffer + strlen(buffer), true); } row_renderer.DrawSecondRow(canvas, text_rc, buffer); diff --git a/src/Dialogs/KnobTextEntry.cpp b/src/Dialogs/KnobTextEntry.cpp index ac2ff6d0f9c..3496893b7bd 100644 --- a/src/Dialogs/KnobTextEntry.cpp +++ b/src/Dialogs/KnobTextEntry.cpp @@ -83,7 +83,7 @@ class KnobTextEntryWindow final : public PaintWindow { } void MoveCursor() { - if (cursor >= _tcslen(buffer)) + if (cursor >= strlen(buffer)) buffer[cursor + 1] = 0; lettercursor = FindEntryLetter(ToUpperASCII(buffer[cursor])); diff --git a/src/Dialogs/Task/Manager/TaskListPanel.cpp b/src/Dialogs/Task/Manager/TaskListPanel.cpp index 23c5ba7dc11..753baa31999 100644 --- a/src/Dialogs/Task/Manager/TaskListPanel.cpp +++ b/src/Dialogs/Task/Manager/TaskListPanel.cpp @@ -245,8 +245,8 @@ TaskListPanel::DeleteTask() static bool ClearSuffix(TCHAR *p, const TCHAR *suffix) { - size_t length = _tcslen(p); - size_t suffix_length = _tcslen(suffix); + size_t length = strlen(p); + size_t suffix_length = strlen(suffix); if (length <= suffix_length) return false; diff --git a/src/Dialogs/Task/dlgTaskHelpers.cpp b/src/Dialogs/Task/dlgTaskHelpers.cpp index 5a8080a0161..94259698364 100644 --- a/src/Dialogs/Task/dlgTaskHelpers.cpp +++ b/src/Dialogs/Task/dlgTaskHelpers.cpp @@ -37,33 +37,33 @@ TaskSummaryShape(const OrderedTask *task, TCHAR *text) break; case 1: - _tcscpy(text, _("Unknown")); + strcpy(text, _("Unknown")); break; case 2: - _tcscpy(text, _("Goal")); + strcpy(text, _("Goal")); FAIShape = true; break; case 3: if (task->GetFactory().IsClosed()) { - _tcscpy(text, _("Out and return")); + strcpy(text, _("Out and return")); FAIShape = true; } else - _tcscpy(text, _("Two legs")); + strcpy(text, _("Two legs")); break; case 4: if (!task->GetFactory().IsUnique() ||!task->GetFactory().IsClosed()) - _tcscpy(text, _("Three legs")); + strcpy(text, _("Three legs")); else if (FAITriangleValidator::Validate(*task)) { - _tcscpy(text, _("FAI triangle")); + strcpy(text, _("FAI triangle")); FAIShape = true; } else - _tcscpy(text, _("non-FAI triangle")); + strcpy(text, _("non-FAI triangle")); break; default: @@ -157,7 +157,7 @@ OrderedTaskPointRadiusLabel(const ObservationZonePoint &ozp, TCHAR* buffer) { switch (ozp.GetShape()) { case ObservationZone::Shape::FAI_SECTOR: - _tcscpy(buffer, _("FAI quadrant")); + strcpy(buffer, _("FAI quadrant")); return; case ObservationZone::Shape::SECTOR: @@ -180,7 +180,7 @@ OrderedTaskPointRadiusLabel(const ObservationZonePoint &ozp, TCHAR* buffer) return; case ObservationZone::Shape::MAT_CYLINDER: - _tcscpy(buffer, _("MAT cylinder")); + strcpy(buffer, _("MAT cylinder")); return; case ObservationZone::Shape::CUSTOM_KEYHOLE: @@ -190,23 +190,23 @@ OrderedTaskPointRadiusLabel(const ObservationZonePoint &ozp, TCHAR* buffer) return; case ObservationZone::Shape::DAEC_KEYHOLE: - _tcscpy(buffer, _("DAeC Keyhole")); + strcpy(buffer, _("DAeC Keyhole")); return; case ObservationZone::Shape::BGAFIXEDCOURSE: - _tcscpy(buffer, _("BGA Fixed Course")); + strcpy(buffer, _("BGA Fixed Course")); return; case ObservationZone::Shape::BGAENHANCEDOPTION: - _tcscpy(buffer, _("BGA Enhanced Option")); + strcpy(buffer, _("BGA Enhanced Option")); return; case ObservationZone::Shape::BGA_START: - _tcscpy(buffer, _("BGA Start Sector")); + strcpy(buffer, _("BGA Start Sector")); return; case ObservationZone::Shape::SYMMETRIC_QUADRANT: - _tcscpy(buffer, _("Symmetric quadrant")); + strcpy(buffer, _("Symmetric quadrant")); return; } @@ -223,7 +223,7 @@ OrderedTaskSave(OrderedTask &task) const auto tasks_path = MakeLocalPath(_T("tasks")); - _tcscat(fname, _T(".tsk")); + strcat(fname, _T(".tsk")); task.SetName(fname); SaveTask(AllocatedPath::Build(tasks_path, fname), task); return true; diff --git a/src/Dialogs/TouchTextEntry.cpp b/src/Dialogs/TouchTextEntry.cpp index 1a932f0d828..67ef72563bd 100644 --- a/src/Dialogs/TouchTextEntry.cpp +++ b/src/Dialogs/TouchTextEntry.cpp @@ -219,7 +219,7 @@ TouchTextEntry(TCHAR *text, size_t width, if (!StringIsEmpty(text)) { CopyTruncateString(edittext, width, text); - cursor = _tcslen(text); + cursor = strlen(text); } UpdateTextboxProp(); diff --git a/src/Dialogs/Traffic/FlarmTrafficDetails.cpp b/src/Dialogs/Traffic/FlarmTrafficDetails.cpp index 138bddc8464..fd1377c15ea 100644 --- a/src/Dialogs/Traffic/FlarmTrafficDetails.cpp +++ b/src/Dialogs/Traffic/FlarmTrafficDetails.cpp @@ -157,7 +157,7 @@ FlarmTrafficDetailsWidget::UpdateChanging(const MoreData &basic) // Fill distance/direction field if (target_ok) { FormatUserDistanceSmart(target->distance, tmp, true, 20, 1000); - TCHAR *p = tmp + _tcslen(tmp); + TCHAR *p = tmp + strlen(tmp); *p++ = _T(' '); FormatAngleDelta(p, 20, target->Bearing() - basic.track); value = tmp; @@ -171,7 +171,7 @@ FlarmTrafficDetailsWidget::UpdateChanging(const MoreData &basic) TCHAR *p = tmp; if (target->altitude_available) { FormatUserAltitude(target->altitude, p); - p += _tcslen(p); + p += strlen(p); *p++ = _T(' '); } diff --git a/src/Dialogs/Traffic/TeamCodeDialog.cpp b/src/Dialogs/Traffic/TeamCodeDialog.cpp index 1ab9ec885c8..96c6687381b 100644 --- a/src/Dialogs/Traffic/TeamCodeDialog.cpp +++ b/src/Dialogs/Traffic/TeamCodeDialog.cpp @@ -167,7 +167,7 @@ TeamCodeWidget::OnFlarmLockClicked() TeamCodeSettings &settings = CommonInterface::SetComputerSettings().team_code; TCHAR newTeamFlarmCNTarget[decltype(settings.team_flarm_callsign)::capacity()]; - _tcscpy(newTeamFlarmCNTarget, settings.team_flarm_callsign.c_str()); + strcpy(newTeamFlarmCNTarget, settings.team_flarm_callsign.c_str()); if (!TextEntryDialog(newTeamFlarmCNTarget, 4)) return; diff --git a/src/Dialogs/Weather/NOAAList.cpp b/src/Dialogs/Weather/NOAAList.cpp index 0b3c825b70d..767da7cc258 100644 --- a/src/Dialogs/Weather/NOAAList.cpp +++ b/src/Dialogs/Weather/NOAAList.cpp @@ -162,7 +162,7 @@ NOAAListWidget::AddClicked() if (!TextEntryDialog(code, 5, _("Airport ICAO code"))) return; - if (_tcslen(code) != 4) { + if (strlen(code) != 4) { ShowMessageBox(_("Please enter the FOUR letter code of the desired station."), _("Error"), MB_OK); return; diff --git a/src/Engine/Airspace/AbstractAirspace.cpp b/src/Engine/Airspace/AbstractAirspace.cpp index a85c8f0f178..51b2a0471e0 100644 --- a/src/Engine/Airspace/AbstractAirspace.cpp +++ b/src/Engine/Airspace/AbstractAirspace.cpp @@ -172,7 +172,7 @@ AbstractAirspace::Intercept(const AircraftState &state, bool AbstractAirspace::MatchNamePrefix(const TCHAR *prefix) const noexcept { - size_t prefix_length = _tcslen(prefix); + size_t prefix_length = strlen(prefix); return StringIsEqualIgnoreCase(name.c_str(), prefix, prefix_length); } diff --git a/src/Form/DataField/Enum.cpp b/src/Form/DataField/Enum.cpp index 443e4e4271a..184f70ddb98 100644 --- a/src/Form/DataField/Enum.cpp +++ b/src/Form/DataField/Enum.cpp @@ -27,7 +27,7 @@ DataFieldEnum::Entry::SetString(const TCHAR *_string) noexcept if (display_string != string) free(display_string); - display_string = string = _tcsdup(_string); + display_string = string = strdup(_string); } void @@ -35,7 +35,7 @@ DataFieldEnum::Entry::SetDisplayString(const TCHAR *_string) noexcept { if (display_string != string) free(display_string); - display_string = _tcsdup(_string); + display_string = strdup(_string); } void @@ -47,10 +47,10 @@ DataFieldEnum::Entry::Set(unsigned _id, const TCHAR *_string, SetString(_string); if (_display_string != nullptr) - display_string = _tcsdup(_display_string); + display_string = strdup(_display_string); free(help); - help = _help ? _tcsdup(_help) : nullptr; + help = _help ? strdup(_help) : nullptr; } unsigned diff --git a/src/Form/DataField/File.cpp b/src/Form/DataField/File.cpp index 0f08e90a331..214c52b9929 100644 --- a/src/Form/DataField/File.cpp +++ b/src/Form/DataField/File.cpp @@ -77,7 +77,7 @@ FileDataField::ScanDirectoryTop(const TCHAR *filter) noexcept { if (!loaded) { if (!postponed_patterns.full() && - _tcslen(filter) < PatternList::value_type().capacity()) { + strlen(filter) < PatternList::value_type().capacity()) { postponed_patterns.append() = filter; return; } else @@ -94,7 +94,7 @@ void FileDataField::ScanMultiplePatterns(const TCHAR *patterns) noexcept { size_t length; - while ((length = _tcslen(patterns)) > 0) { + while ((length = strlen(patterns)) > 0) { ScanDirectoryTop(patterns); patterns += length + 1; } @@ -335,10 +335,10 @@ FileDataField::CreateComboList([[maybe_unused]] const TCHAR *reference) const no if (found) { /* yes - append the absolute path to allow the user to see the difference */ - _tcscpy(buffer, path.c_str()); - _tcscat(buffer, _T(" (")); - _tcscat(buffer, files[i].path.c_str()); - _tcscat(buffer, _T(")")); + strcpy(buffer, path.c_str()); + strcat(buffer, _T(" (")); + strcat(buffer, files[i].path.c_str()); + strcat(buffer, _T(")")); display_string = buffer; } diff --git a/src/Form/DataField/Password.cpp b/src/Form/DataField/Password.cpp index 650c2ca9bc1..79c2ca1b077 100644 --- a/src/Form/DataField/Password.cpp +++ b/src/Form/DataField/Password.cpp @@ -9,7 +9,7 @@ const TCHAR * PasswordDataField::GetAsDisplayString() const noexcept { const TCHAR *obfuscated = _T("********************************"); - const size_t obfuscated_length = _tcslen(obfuscated); - size_t length = std::min(_tcsclen(GetAsString()), obfuscated_length); + const size_t obfuscated_length = strlen(obfuscated); + size_t length = std::min(strlen(GetAsString()), obfuscated_length); return obfuscated + (obfuscated_length - length); } diff --git a/src/Form/DataField/Prefix.cpp b/src/Form/DataField/Prefix.cpp index d386ac761dc..8c555664285 100644 --- a/src/Form/DataField/Prefix.cpp +++ b/src/Form/DataField/Prefix.cpp @@ -47,7 +47,7 @@ PrefixDataField::Dec() noexcept TCHAR next; if (current == _T('\0')) - next = chars[_tcslen(chars) - 1]; + next = chars[strlen(chars) - 1]; else { const TCHAR *p = current != _T('\0') ? StringFind(chars, current) diff --git a/src/Formatter/AirspaceUserUnitsFormatter.cpp b/src/Formatter/AirspaceUserUnitsFormatter.cpp index b709e0faba4..add16592cd5 100644 --- a/src/Formatter/AirspaceUserUnitsFormatter.cpp +++ b/src/Formatter/AirspaceUserUnitsFormatter.cpp @@ -18,7 +18,7 @@ AirspaceFormatter::FormatAltitudeShort(TCHAR *buffer, switch (altitude.reference) { case AltitudeReference::AGL: if (altitude.altitude_above_terrain <= 0) - _tcscpy(buffer, _T("GND")); + strcpy(buffer, _T("GND")); else if (include_unit) StringFormatUnsafe(buffer, _T("%d %s AGL"), @@ -56,13 +56,13 @@ AirspaceFormatter::FormatAltitude(TCHAR *buffer, Units::GetUserAltitudeUnit() == Unit::METER) /* additionally show airspace altitude in feet, because aviation charts usually print altitudes in feet */ - StringFormatUnsafe(buffer + _tcslen(buffer), _T(" (%d %s)"), + StringFormatUnsafe(buffer + strlen(buffer), _T(" (%d %s)"), iround(Units::ToUserUnit(altitude.altitude, Unit::FEET)), Units::GetUnitName(Unit::FEET)); if (altitude.reference != AltitudeReference::MSL && altitude.altitude > 0) - StringFormatUnsafe(buffer + _tcslen(buffer), _T(" %d %s"), + StringFormatUnsafe(buffer + strlen(buffer), _T(" %d %s"), iround(Units::ToUserAltitude(altitude.altitude)), Units::GetAltitudeName()); } diff --git a/src/Formatter/AngleFormatter.cpp b/src/Formatter/AngleFormatter.cpp index b8d98df48c0..7866d34bb47 100644 --- a/src/Formatter/AngleFormatter.cpp +++ b/src/Formatter/AngleFormatter.cpp @@ -39,7 +39,7 @@ FormatAngleDelta(TCHAR *buffer, size_t size, Angle value) else if (degrees < -1) StringFormat(buffer, size, _T("«%u°"), unsigned(-degrees)); else - _tcscpy(buffer, _T("« * »")); + strcpy(buffer, _T("« * »")); } void @@ -52,5 +52,5 @@ FormatVerticalAngleDelta(TCHAR *buffer, size_t size, Angle value) if (degrees < -1 || degrees > 1) StringFormat(buffer, size, _T("%+d°"), int(degrees)); else - _tcscpy(buffer, _T("--")); + strcpy(buffer, _T("--")); } diff --git a/src/Formatter/IGCFilenameFormatter.cpp b/src/Formatter/IGCFilenameFormatter.cpp index 85309895f90..d80f1d3acf6 100644 --- a/src/Formatter/IGCFilenameFormatter.cpp +++ b/src/Formatter/IGCFilenameFormatter.cpp @@ -25,7 +25,7 @@ FormatIGCFilename(TCHAR* buffer, const BrokenDate &date, unsigned flight_number) { assert(logger_id != NULL); - assert(_tcslen(logger_id) == 3); + assert(strlen(logger_id) == 3); TCHAR cyear = NumToIGCChar(date.year % 10); TCHAR cmonth = NumToIGCChar(date.month); @@ -47,10 +47,10 @@ FormatIGCFilenameLong(TCHAR* buffer, const BrokenDate &date, // XYZ represents manufacturer code assert(manufacturer != NULL); - assert(_tcslen(manufacturer) == 3); + assert(strlen(manufacturer) == 3); assert(logger_id != NULL); - assert(_tcslen(logger_id) == 3); + assert(strlen(logger_id) == 3); StringFormatUnsafe(buffer, _T("%04u-%02u-%02u-%s-%s-%02u.igc"), date.year, date.month, date.day, diff --git a/src/Formatter/TimeFormatter.cpp b/src/Formatter/TimeFormatter.cpp index 7b0cb7faab8..80b49c40382 100644 --- a/src/Formatter/TimeFormatter.cpp +++ b/src/Formatter/TimeFormatter.cpp @@ -71,12 +71,12 @@ void FormatTimeTwoLines(TCHAR *buffer1, TCHAR *buffer2, std::chrono::seconds _time) noexcept { if (_time >= std::chrono::hours{24}) { - _tcscpy(buffer1, _T(">24h")); + strcpy(buffer1, _T(">24h")); buffer2[0] = '\0'; return; } if (_time <= -std::chrono::hours{24}) { - _tcscpy(buffer1, _T("<-24h")); + strcpy(buffer1, _T("<-24h")); buffer2[0] = '\0'; return; } @@ -187,30 +187,30 @@ FormatTimespanSmart(TCHAR *buffer, std::chrono::seconds timespan, if (show_days) { component_buffer.Format(_T("%u days"), days); - _tcscat(buffer, component_buffer); + strcat(buffer, component_buffer); } if (show_hours) { if (!StringIsEmpty(buffer)) - _tcscat(buffer, separator); + strcat(buffer, separator); component_buffer.Format(_T("%u h"), hours); - _tcscat(buffer, component_buffer); + strcat(buffer, component_buffer); } if (show_minutes) { if (!StringIsEmpty(buffer)) - _tcscat(buffer, separator); + strcat(buffer, separator); component_buffer.Format(_T("%u min"), minutes); - _tcscat(buffer, component_buffer); + strcat(buffer, component_buffer); } if (show_seconds) { if (!StringIsEmpty(buffer)) - _tcscat(buffer, separator); + strcat(buffer, separator); component_buffer.Format(_T("%u sec"), seconds); - _tcscat(buffer, component_buffer); + strcat(buffer, component_buffer); } } diff --git a/src/Gauge/BigTrafficWidget.cpp b/src/Gauge/BigTrafficWidget.cpp index 18942abd580..29e292ccc78 100644 --- a/src/Gauge/BigTrafficWidget.cpp +++ b/src/Gauge/BigTrafficWidget.cpp @@ -420,7 +420,7 @@ FlarmTrafficControl::PaintID(Canvas &canvas, PixelRect rc, canvas.Select(look.call_sign_font); font_size = look.call_sign_font.GetHeight(); - _tcscpy(buffer, traffic.name); + strcpy(buffer, traffic.name); } else { canvas.Select(look.info_labels_font); font_size = look.info_labels_font.GetHeight(); diff --git a/src/Gauge/GaugeVario.cpp b/src/Gauge/GaugeVario.cpp index 323a19f8fc4..281e7bfdce4 100644 --- a/src/Gauge/GaugeVario.cpp +++ b/src/Gauge/GaugeVario.cpp @@ -507,7 +507,7 @@ GaugeVario::RenderValue(Canvas &canvas, const LabelValueGeometry &g, canvas.SetBackgroundColor(look.background_color); canvas.DrawOpaqueText(text_position, rc, label); di.label.last_width = width; - _tcscpy(di.label.last_text, label); + strcpy(di.label.last_text, label); } else { canvas.DrawText(text_position, label); } diff --git a/src/InfoBoxes/Content/Thermal.cpp b/src/InfoBoxes/Content/Thermal.cpp index 0f46b9c75cd..35897330237 100644 --- a/src/InfoBoxes/Content/Thermal.cpp +++ b/src/InfoBoxes/Content/Thermal.cpp @@ -220,7 +220,7 @@ UpdateInfoBoxCircleDiameter(InfoBoxData &data) noexcept StaticString<16> duration_buffer; duration_buffer.Format(_T("%u s"), int(circle_duration)); - _tcscpy (buffer, duration_buffer); + strcpy (buffer, duration_buffer); data.SetComment (buffer); } diff --git a/src/Input/InputEventsMap.cpp b/src/Input/InputEventsMap.cpp index 65e1a121fb8..76ec71635c8 100644 --- a/src/Input/InputEventsMap.cpp +++ b/src/Input/InputEventsMap.cpp @@ -82,7 +82,7 @@ InputEvents::eventZoom(const TCHAR* misc) Message::AddMessage(_("Circling zoom off")); } else { TCHAR *endptr; - double zoom = _tcstod(misc, &endptr); + double zoom = strtod(misc, &endptr); if (endptr == misc) return; diff --git a/src/Input/InputEventsSettings.cpp b/src/Input/InputEventsSettings.cpp index 0bf2cc57079..9389b291d47 100644 --- a/src/Input/InputEventsSettings.cpp +++ b/src/Input/InputEventsSettings.cpp @@ -452,7 +452,7 @@ InputEvents::sub_TerrainTopography(int vswitch) else _stprintf(buf, _T("\r\n%s / "), _("Off")); - _tcscat(buf, settings_map.terrain.enable + strcat(buf, settings_map.terrain.enable ? _("On") : _("Off")); Message::AddMessage(_("Topography/Terrain"), buf); diff --git a/src/Logger/Logger.cpp b/src/Logger/Logger.cpp index 8bf8ac0f2b6..d20d45a63ef 100644 --- a/src/Logger/Logger.cpp +++ b/src/Logger/Logger.cpp @@ -69,15 +69,15 @@ Logger::GUIStartLogger(const NMEAInfo& gps_info, if (task) { if (!noAsk) { TCHAR TaskMessage[1024]; - _tcscpy(TaskMessage, _T("Start Logger With Declaration\r\n")); + strcpy(TaskMessage, _T("Start Logger With Declaration\r\n")); if (decl.Size()) { for (unsigned i = 0; i< decl.Size(); ++i) { - _tcscat(TaskMessage, decl.GetName(i)); - _tcscat(TaskMessage, _T("\r\n")); + strcat(TaskMessage, decl.GetName(i)); + strcat(TaskMessage, _T("\r\n")); } } else { - _tcscat(TaskMessage, _T("None")); + strcat(TaskMessage, _T("None")); } if (ShowMessageBox(TaskMessage, _("Start Logger"), diff --git a/src/Logger/LoggerImpl.cpp b/src/Logger/LoggerImpl.cpp index 78133088da6..02a287107b2 100644 --- a/src/Logger/LoggerImpl.cpp +++ b/src/Logger/LoggerImpl.cpp @@ -265,7 +265,7 @@ LoggerImpl::StartLogger(const NMEAInfo &gps_info, // chars must be legal in file names char logger_id[4]; - unsigned asset_length = _tcslen(asset_number); + unsigned asset_length = strlen(asset_number); for (unsigned i = 0; i < 3; i++) logger_id[i] = i < asset_length && IsAlphaNumericASCII(asset_number[i]) ? asset_number[i] : _T('A'); diff --git a/src/Look/FontDescription.cpp b/src/Look/FontDescription.cpp index 444b66ea1fb..4d55b42737b 100644 --- a/src/Look/FontDescription.cpp +++ b/src/Look/FontDescription.cpp @@ -37,7 +37,7 @@ FontDescription::Init(const TCHAR *face, logfont.lfPitchAndFamily = (monospace ? FIXED_PITCH : VARIABLE_PITCH) | FF_DONTCARE; - _tcscpy(logfont.lfFaceName, face); + strcpy(logfont.lfFaceName, face); } #endif diff --git a/src/Menu/MenuData.hpp b/src/Menu/MenuData.hpp index 3fa83a48cac..945290967ad 100644 --- a/src/Menu/MenuData.hpp +++ b/src/Menu/MenuData.hpp @@ -32,7 +32,7 @@ class MenuItem { */ [[gnu::pure]] bool IsDynamic() const noexcept { - return label != nullptr && _tcsstr(label, _T("$(")) != nullptr; + return label != nullptr && strstr(label, _T("$(")) != nullptr; } }; diff --git a/src/PopupMessage.cpp b/src/PopupMessage.cpp index 65f5f9c4c7c..cbeb6119cbb 100644 --- a/src/PopupMessage.cpp +++ b/src/PopupMessage.cpp @@ -318,10 +318,10 @@ PopupMessage::AddMessage(const TCHAR* text, const TCHAR *data) noexcept // TODO code: consider what is a sensible size? if (msg.visible) { TCHAR msgcache[1024]; - _tcscpy(msgcache, text); + strcpy(msgcache, text); if (data != nullptr) { - _tcscat(msgcache, _T(" ")); - _tcscat(msgcache, data); + strcat(msgcache, _T(" ")); + strcat(msgcache, data); } AddMessage(msg.delay, MSG_USERINTERFACE, msgcache); diff --git a/src/Renderer/FlightStatisticsRenderer.cpp b/src/Renderer/FlightStatisticsRenderer.cpp index d0d69cd8219..43b1cda8b2e 100644 --- a/src/Renderer/FlightStatisticsRenderer.cpp +++ b/src/Renderer/FlightStatisticsRenderer.cpp @@ -343,7 +343,7 @@ FlightStatisticsRenderer::CaptionTask(TCHAR *sTmp, const DerivedInfo &derived) n if (!task_stats.task_valid || !derived.task_stats.total.remaining.IsDefined()) { - _tcscpy(sTmp, _("No task")); + strcpy(sTmp, _("No task")); } else { const auto d_remaining = derived.task_stats.total.remaining.GetDistance(); if (task_stats.has_targets) { diff --git a/src/Renderer/WaypointRenderer.cpp b/src/Renderer/WaypointRenderer.cpp index 2733906b220..4ae7a388299 100644 --- a/src/Renderer/WaypointRenderer.cpp +++ b/src/Renderer/WaypointRenderer.cpp @@ -168,7 +168,7 @@ class WaypointVisitorMap final projection.GetScreenAngle()), labels(projection.GetScreenRect()) { - _tcscpy(altitude_unit, Units::GetAltitudeName()); + strcpy(altitude_unit, Units::GetAltitudeName()); } @@ -197,7 +197,7 @@ class WaypointVisitorMap final case WaypointRendererSettings::DisplayTextType::FIRST_WORD: CopyTruncateString(buffer, buffer_size, way_point.name.c_str()); TCHAR *tmp; - tmp = _tcsstr(buffer, _T(" ")); + tmp = strstr(buffer, _T(" ")); if (tmp != nullptr) tmp[0] = '\0'; break; @@ -243,7 +243,7 @@ class WaypointVisitorMap final if (!GradientValid(gr)) return; - size_t length = _tcslen(buffer); + size_t length = strlen(buffer); if (length > 0) buffer[length++] = _T(':'); @@ -268,7 +268,7 @@ class WaypointVisitorMap final if (settings.arrival_height_display == WaypointRendererSettings::ArrivalHeightDisplay::NONE) return; - size_t length = _tcslen(buffer); + size_t length = strlen(buffer); int uah_glide = (int)Units::ToUserAltitude(reach.direct); int uah_terrain = (int)Units::ToUserAltitude(reach.terrain); diff --git a/src/Task/ValidationErrorStrings.cpp b/src/Task/ValidationErrorStrings.cpp index 65bcde13246..75a97c7d181 100644 --- a/src/Task/ValidationErrorStrings.cpp +++ b/src/Task/ValidationErrorStrings.cpp @@ -38,9 +38,9 @@ getTaskValidationErrors(const TaskValidationErrorSet v) continue; const TCHAR *current = gettext(validation_error_strings[i]); - if (_tcslen(err) + _tcslen(current) + 1 < MAX_PATH) { - _tcscat(err, current); - _tcscat(err, _T("\n")); + if (strlen(err) + strlen(current) + 1 < MAX_PATH) { + strcat(err, current); + strcat(err, _T("\n")); } } diff --git a/src/Waypoint/WaypointFilter.cpp b/src/Waypoint/WaypointFilter.cpp index d9da1a55ddd..99e3dcb05f2 100644 --- a/src/Waypoint/WaypointFilter.cpp +++ b/src/Waypoint/WaypointFilter.cpp @@ -85,7 +85,7 @@ WaypointFilter::CompareDirection(const Waypoint &waypoint, inline bool WaypointFilter::CompareName(const Waypoint &waypoint, const TCHAR *name) { - return StringIsEqualIgnoreCase(waypoint.name.c_str(), name, _tcslen(name)); + return StringIsEqualIgnoreCase(waypoint.name.c_str(), name, strlen(name)); } inline bool diff --git a/src/Weather/METARParser.cpp b/src/Weather/METARParser.cpp index 9f475ebc9a7..98b4e4a7f88 100644 --- a/src/Weather/METARParser.cpp +++ b/src/Weather/METARParser.cpp @@ -30,7 +30,7 @@ class METARLine { public: /** Constructor. Duplicates the const input to be able to tokenize it. */ METARLine(const TCHAR *line) - :start(_tcsdup(line)), data(start), end(start + _tcslen(line)) + :start(strdup(line)), data(start), end(start + strlen(line)) { // Trim possible = character at the end (End-of-METAR character) if (start != end && *(end - 1) == _T('=')) { @@ -67,7 +67,7 @@ class METARLine { static bool DetectICAOCodeToken(const TCHAR *token) { - if (_tcslen(token) != 4) + if (strlen(token) != 4) return false; for (unsigned i = 0; i < 4; i++) { @@ -85,7 +85,7 @@ DetectICAOCodeToken(const TCHAR *token) static bool DetectTimeCodeToken(const TCHAR *token) { - if (_tcslen(token) != 7) + if (strlen(token) != 7) return false; return token[6] == _T('Z') || token[6] == _T('z'); @@ -97,7 +97,7 @@ ParseTimeCode(const TCHAR *token, ParsedMETAR &parsed) assert(DetectTimeCodeToken(token)); TCHAR *endptr; - unsigned time_code = _tcstod(token, &endptr); + unsigned time_code = strtod(token, &endptr); if (endptr == NULL || endptr == token) return false; @@ -117,7 +117,7 @@ ParseTimeCode(const TCHAR *token, ParsedMETAR &parsed) static bool DetectWindToken(const TCHAR *token) { - unsigned length = _tcslen(token); + unsigned length = strlen(token); if (length != 8 && length != 7) return false; @@ -146,7 +146,7 @@ ParseWind(const TCHAR *token, ParsedMETAR &parsed) return true; TCHAR *endptr; - unsigned wind_code = _tcstod(token, &endptr); + unsigned wind_code = strtod(token, &endptr); if (endptr == NULL || endptr == token) return false; @@ -169,14 +169,14 @@ ParseWind(const TCHAR *token, ParsedMETAR &parsed) static bool DetectCAVOK(const TCHAR *token) { - return (_tcslen(token) == 5 && StringIsEqualIgnoreCase(token, _T("CAVOK"))); + return (strlen(token) == 5 && StringIsEqualIgnoreCase(token, _T("CAVOK"))); } /** Detects a token with exactly 5 digits */ static bool DetectVisibilityToken(const TCHAR *token) { - if (_tcslen(token) != 4) + if (strlen(token) != 4) return false; for (unsigned i = 0; i < 4; ++i) @@ -192,7 +192,7 @@ ParseVisibility(const TCHAR *token, ParsedMETAR &parsed) assert(DetectVisibilityToken(token)); TCHAR *endptr; - parsed.visibility = _tcstol(token, &endptr, 10); + parsed.visibility = strtol(token, &endptr, 10); if (endptr == NULL || endptr == token) return false; @@ -207,7 +207,7 @@ ParseVisibility(const TCHAR *token, ParsedMETAR &parsed) static bool DetectTemperaturesToken(const TCHAR *token) { - unsigned length = _tcslen(token); + unsigned length = strlen(token); bool minus_possible = true; bool divider_found = false; @@ -239,7 +239,7 @@ ParseTemperature(const TCHAR *token, double &temperature) token++; TCHAR *endptr; - int _temperature = _tcstod(token, &endptr); + int _temperature = strtod(token, &endptr); if (endptr == NULL || endptr == token) return NULL; @@ -274,7 +274,7 @@ ParseTemperatures(const TCHAR *token, ParsedMETAR &parsed) static bool DetectAdditionalTemperaturesToken(const TCHAR *token) { - if (_tcslen(token) != 9) + if (strlen(token) != 9) return false; if (token[0] != _T('T') && token[0] != _T('t')) @@ -297,7 +297,7 @@ ParseAdditionalTemperatures(const TCHAR *token, ParsedMETAR &parsed) token++; TCHAR *endptr; - long temperature_code = _tcstol(token, &endptr, 10); + long temperature_code = strtol(token, &endptr, 10); if (endptr == NULL || endptr == token) return false; @@ -320,7 +320,7 @@ ParseAdditionalTemperatures(const TCHAR *token, ParsedMETAR &parsed) static bool DetectQNHToken(const TCHAR *token) { - unsigned length = _tcslen(token); + unsigned length = strlen(token); // International style if (token[0] == _T('Q') || token[0] == _T('q')) @@ -343,7 +343,7 @@ ParseQNH(const TCHAR *token, ParsedMETAR &parsed) token++; TCHAR *endptr; - unsigned hpa = _tcstod(token, &endptr); + unsigned hpa = strtod(token, &endptr); if (endptr == NULL || endptr == token) return false; @@ -357,7 +357,7 @@ ParseQNH(const TCHAR *token, ParsedMETAR &parsed) token++; TCHAR *endptr; - unsigned inch_hg = _tcstod(token, &endptr); + unsigned inch_hg = strtod(token, &endptr); if (endptr == NULL || endptr == token) return false; @@ -529,7 +529,7 @@ METARParser::ParseDecoded(const METAR::ContentString &decoded, // Nov 04, 2011 - 07:50 PM EDT / 2011.11.04 2350 UTC const TCHAR *start = decoded.c_str(); - const TCHAR *end = start + _tcslen(start); + const TCHAR *end = start + strlen(start); const auto *opening_brace = StringFind(start, _T('(')); const auto *closing_brace = StringFind(start, _T(')')); const auto *line_break = StringFind(start, _T('\n')); diff --git a/src/Weather/NOAAFormatter.cpp b/src/Weather/NOAAFormatter.cpp index 41c662e9fe2..c9b560a9f0b 100644 --- a/src/Weather/NOAAFormatter.cpp +++ b/src/Weather/NOAAFormatter.cpp @@ -33,7 +33,7 @@ class NOAALineSplitter if (!line_break) { // if no line break was found start = NULL; - return Range(line_start, _tcslen(line_start)); + return Range(line_start, strlen(line_start)); } unsigned length = line_break - line_start; @@ -45,7 +45,7 @@ class NOAALineSplitter static bool CheckTitle(const TCHAR *title, size_t title_length, const TCHAR *check) { - if (_tcslen(check) != title_length) + if (strlen(check) != title_length) return false; return std::equal(title, title + title_length, check); diff --git a/src/system/FileUtil.cpp b/src/system/FileUtil.cpp index 730362fe9ca..afca409b235 100644 --- a/src/system/FileUtil.cpp +++ b/src/system/FileUtil.cpp @@ -94,16 +94,16 @@ ScanFiles(File::Visitor &visitor, Path sPath, if (sPath != nullptr) // e.g. "/test/data/something" - _tcscpy(DirPath, sPath.c_str()); + strcpy(DirPath, sPath.c_str()); else DirPath[0] = 0; // "/test/data/something/" - _tcscat(DirPath, _T(DIR_SEPARATOR_S)); - _tcscpy(FileName, DirPath); + strcat(DirPath, _T(DIR_SEPARATOR_S)); + strcpy(FileName, DirPath); // "/test/data/something/*.igc" - _tcscat(FileName, filter); + strcat(FileName, filter); // Find the first matching file WIN32_FIND_DATA FindFileData; @@ -119,9 +119,9 @@ ScanFiles(File::Visitor &visitor, Path sPath, !(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && checkFilter(FindFileData.cFileName, filter)) { // "/test/data/something/" - _tcscpy(FileName, DirPath); + strcpy(FileName, DirPath); // "/test/data/something/blubb.txt" - _tcscat(FileName, FindFileData.cFileName); + strcat(FileName, FindFileData.cFileName); // Call visitor with the file that was found visitor.Visit(Path(FileName), Path(FindFileData.cFileName)); } @@ -157,8 +157,8 @@ ScanDirectories(File::Visitor &visitor, bool recursive, return false; TCHAR FileName[MAX_PATH]; - _tcscpy(FileName, sPath.c_str()); - size_t FileNameLength = _tcslen(FileName); + strcpy(FileName, sPath.c_str()); + size_t FileNameLength = strlen(FileName); FileName[FileNameLength++] = '/'; struct dirent *ent; @@ -167,7 +167,7 @@ ScanDirectories(File::Visitor &visitor, bool recursive, if (*ent->d_name == _T('.')) continue; - _tcscpy(FileName + FileNameLength, ent->d_name); + strcpy(FileName + FileNameLength, ent->d_name); struct stat st; if (stat(FileName, &st) < 0) @@ -192,8 +192,8 @@ ScanDirectories(File::Visitor &visitor, bool recursive, if (sPath != nullptr) { // e.g. "/test/data/something" - _tcscpy(DirPath, sPath.c_str()); - _tcscpy(FileName, sPath.c_str()); + strcpy(DirPath, sPath.c_str()); + strcpy(FileName, sPath.c_str()); } else { DirPath[0] = 0; FileName[0] = 0; @@ -207,9 +207,9 @@ ScanDirectories(File::Visitor &visitor, bool recursive, return true; // "test/data/something/" - _tcscat(DirPath, _T(DIR_SEPARATOR_S)); + strcat(DirPath, _T(DIR_SEPARATOR_S)); // "test/data/something/*" - _tcscat(FileName, _T(DIR_SEPARATOR_S "*")); + strcat(FileName, _T(DIR_SEPARATOR_S "*")); // Find the first file WIN32_FIND_DATA FindFileData; @@ -224,9 +224,9 @@ ScanDirectories(File::Visitor &visitor, bool recursive, if (!IsDots(FindFileData.cFileName) && (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { // "test/data/something/" - _tcscpy(FileName, DirPath); + strcpy(FileName, DirPath); // "test/data/something/SUBFOLDER" - _tcscat(FileName, FindFileData.cFileName); + strcat(FileName, FindFileData.cFileName); // Scan subfolder for matching files too ScanDirectories(visitor, true, Path(FileName), filter); } diff --git a/src/system/Path.cpp b/src/system/Path.cpp index e27eb2197d9..0d657fd3955 100644 --- a/src/system/Path.cpp +++ b/src/system/Path.cpp @@ -66,7 +66,7 @@ Path::IsBase() const noexcept assert(*this != nullptr); #ifdef _WIN32 - return _tcspbrk(c_str(), _T("/\\")) == nullptr; + return strpbrk(c_str(), _T("/\\")) == nullptr; #else return StringFind(c_str(), _T('/')) == nullptr; #endif diff --git a/src/system/PathName.cpp b/src/system/PathName.cpp index f853d88b1ff..3ad4a53d33b 100644 --- a/src/system/PathName.cpp +++ b/src/system/PathName.cpp @@ -32,5 +32,5 @@ ReplaceBaseName(TCHAR *path, const TCHAR *new_base) ++q; else q = path; - _tcscpy(q, new_base); + strcpy(q, new_base); } diff --git a/src/ui/canvas/custom/MoreCanvas.cpp b/src/ui/canvas/custom/MoreCanvas.cpp index f5faa3ddd42..0c93d26327f 100644 --- a/src/ui/canvas/custom/MoreCanvas.cpp +++ b/src/ui/canvas/custom/MoreCanvas.cpp @@ -74,7 +74,7 @@ Canvas::DrawFormattedText(const PixelRect r, const tstring_view text, // simple wordbreak algorithm. looks for single spaces only, no tabs, // no grouping of multiple spaces - for (size_t i = 0; i < len; i += _tcslen(duplicated + i) + 1) { + for (size_t i = 0; i < len; i += strlen(duplicated + i) + 1) { PixelSize sz = CalcTextSize(duplicated + i); TCHAR *prev_p = nullptr; @@ -103,7 +103,7 @@ Canvas::DrawFormattedText(const PixelRect r, const tstring_view text, int y = (format & DT_VCENTER) && lines < max_lines ? (r.top + r.bottom - lines * skip) / 2 : r.top; - for (size_t i = 0; i < len; i += _tcslen(duplicated + i) + 1) { + for (size_t i = 0; i < len; i += strlen(duplicated + i) + 1) { if (duplicated[i] != _T('\0')) { int x; if (format & (DT_RIGHT | DT_CENTER)) { diff --git a/src/ui/control/gdi/LargeTextWindow.cpp b/src/ui/control/gdi/LargeTextWindow.cpp index b37d9bd8094..8196c171b4c 100644 --- a/src/ui/control/gdi/LargeTextWindow.cpp +++ b/src/ui/control/gdi/LargeTextWindow.cpp @@ -20,7 +20,7 @@ void LargeTextWindow::SetText(const TCHAR *text) { // Replace \n by \r\r\n to enable usage of line-breaks in edit control - unsigned size = _tcslen(text); + unsigned size = strlen(text); const std::unique_ptr allocation(new TCHAR[size * 3 + 1]); TCHAR *buffer = allocation.get(); diff --git a/src/unix/tchar.h b/src/unix/tchar.h index 542823c6cde..9267c31f376 100644 --- a/src/unix/tchar.h +++ b/src/unix/tchar.h @@ -18,20 +18,9 @@ typedef char TCHAR; #define _ftprintf fprintf #define _vftprintf vfprintf #define _fputts fputs -#define _tcsdup strdup -#define _tcscpy strcpy -#define _tcscmp strcmp -#define _tcslen strlen -#define _tcsclen strlen -#define _tcsstr strstr -#define _tcspbrk strpbrk -#define _tcscat strcat #define _T(x) x #define _topen open #define _tfopen fopen #define _TEOF EOF #define _putts puts #define _stscanf sscanf - -#define _tcstol strtol -#define _tcstod strtod diff --git a/src/util/EscapeBackslash.cpp b/src/util/EscapeBackslash.cpp index a6f435c0b15..738d3107376 100644 --- a/src/util/EscapeBackslash.cpp +++ b/src/util/EscapeBackslash.cpp @@ -36,5 +36,5 @@ UnescapeBackslash(tstring_view old_string) noexcept buffer[used++] = _T('\0'); - return _tcsdup(buffer); + return strdup(buffer); } diff --git a/src/util/RadixTree.hpp b/src/util/RadixTree.hpp index 3f622476904..dadb81304e6 100644 --- a/src/util/RadixTree.hpp +++ b/src/util/RadixTree.hpp @@ -182,7 +182,7 @@ class RadixTree { */ Node *CreateLeaf(const TCHAR *label, const T &value) const { Node *top = new Node(label), *bottom = top; - while (_tcslen(label) >= Node::label.capacity()) { + while (strlen(label) >= Node::label.capacity()) { /* label too long for the Node's StaticString, create another child Node */ diff --git a/test/data/wp_parser/MBG08.xcm b/test/data/wp_parser/MBG08.xcm index 101d6d59dcd3f2b4743e3074657c8d9875adbb83..634e545e08f46732d9438623132cb28bfe9350d7 100644 GIT binary patch delta 79 zcmdn{HG9w3?1mP`7N!>F7M2#)7Pc1l7LFFq7OocV7M>Q~7QPn#7J(MQ7NHj57LgXw eEnF7M2#)7Pc1l7LFFq7OocV7M>Q~7QPn#7J(MQ7NHj57LgXw fEn= 9999) - _tcscpy(buffer, _T("unlimited")); + strcpy(buffer, _T("unlimited")); else { FormatUserDistanceSmart(parsed.visibility, buffer); } diff --git a/test/src/RunWaveComputer.cpp b/test/src/RunWaveComputer.cpp index 862fda4f701..9d993ad2b13 100644 --- a/test/src/RunWaveComputer.cpp +++ b/test/src/RunWaveComputer.cpp @@ -43,7 +43,7 @@ int main(int argc, char **argv) if (w.time.IsDefined()) FormatTime(time_buffer, w.time); else - _tcscpy(time_buffer, _T("?")); + strcpy(time_buffer, _T("?")); _tprintf(_T("wave: t=%s location=%f,%f a=%f,%f b=%f,%f location=%s normal=%f\n"), time_buffer, From 17a2fdaa59889905f6a3f2bf01603a881ae059be Mon Sep 17 00:00:00 2001 From: August2111 Date: Sun, 21 Apr 2024 18:34:59 +0200 Subject: [PATCH 378/403] [UTF8] Replace TCHAR with char in src/* and test/* in src: 2053 items in test: 93 items in tools: 2 items --- src/ActionInterface.cpp | 4 +- src/ActionInterface.hpp | 4 +- src/Audio/PCMResourcePlayer.cpp | 2 +- src/Audio/PCMResourcePlayer.hpp | 2 +- src/Audio/Sound.cpp | 2 +- src/Audio/Sound.hpp | 2 +- src/Compatibility/path.h | 2 +- src/CrossSection/AirspaceXSRenderer.cpp | 2 +- src/Device/Config.cpp | 12 +- src/Device/Config.hpp | 6 +- src/Device/Declaration.hpp | 4 +- src/Device/Descriptor.cpp | 26 +-- src/Device/Descriptor.hpp | 10 +- src/Device/Driver.cpp | 4 +- src/Device/Driver.hpp | 12 +- src/Device/Driver/AR62xx.cpp | 12 +- src/Device/Driver/ATR833/Device.cpp | 4 +- src/Device/Driver/ATR833/Device.hpp | 4 +- src/Device/Driver/AirControlDisplay.cpp | 4 +- src/Device/Driver/CAI302/Declare.cpp | 2 +- src/Device/Driver/CAI302/Manage.cpp | 2 +- src/Device/Driver/EW.cpp | 2 +- src/Device/Driver/EWMicroRecorder.cpp | 6 +- src/Device/Driver/FLARM/Device.cpp | 24 +-- src/Device/Driver/FLARM/Device.hpp | 24 +-- src/Device/Driver/IMI/Protocol/Conversion.cpp | 2 +- src/Device/Driver/IMI/Protocol/Conversion.hpp | 2 +- src/Device/Driver/KRT2.cpp | 18 +- src/Device/Driver/LX/Declare.cpp | 2 +- src/Device/Driver/LX/NanoDeclare.cpp | 2 +- src/Device/Driver/Volkslogger/Declare.cpp | 2 +- src/Device/Driver/XCOM760.cpp | 8 +- src/Device/MultipleDevices.cpp | 6 +- src/Device/MultipleDevices.hpp | 6 +- src/Device/Port/AndroidBluetoothPort.cpp | 4 +- src/Device/Port/AndroidBluetoothPort.hpp | 4 +- src/Device/Port/AndroidIOIOUartPort.hpp | 2 +- src/Device/Port/ConfiguredPort.cpp | 10 +- src/Device/Port/SerialPort.cpp | 2 +- src/Device/Port/SerialPort.hpp | 2 +- src/Device/Port/TTYPort.cpp | 2 +- src/Device/Port/TTYPort.hpp | 2 +- src/Device/Register.cpp | 6 +- src/Device/Register.hpp | 6 +- src/Dialogs/Airspace/AirspaceList.cpp | 16 +- src/Dialogs/Airspace/dlgAirspace.cpp | 2 +- src/Dialogs/Airspace/dlgAirspaceWarnings.cpp | 4 +- src/Dialogs/CoDialog.cpp | 4 +- src/Dialogs/CoDialog.hpp | 2 +- src/Dialogs/CoFunctionDialog.hpp | 2 +- src/Dialogs/ComboPicker.cpp | 14 +- src/Dialogs/ComboPicker.hpp | 10 +- src/Dialogs/DataField.cpp | 6 +- src/Dialogs/DataField.hpp | 4 +- src/Dialogs/DateEntry.cpp | 2 +- src/Dialogs/DateEntry.hpp | 2 +- src/Dialogs/Device/DeviceEditWidget.cpp | 12 +- src/Dialogs/Device/DeviceListDialog.cpp | 8 +- src/Dialogs/Device/PortDataField.cpp | 36 ++-- src/Dialogs/Device/PortDataField.hpp | 4 +- src/Dialogs/Device/PortMonitor.cpp | 2 +- src/Dialogs/Device/PortPicker.cpp | 6 +- src/Dialogs/Device/PortPicker.hpp | 2 +- .../Device/Vega/VegaConfigurationDialog.cpp | 2 +- src/Dialogs/Device/Vega/VegaDemoDialog.cpp | 2 +- .../Device/Vega/VegaParametersWidget.cpp | 18 +- .../Device/Vega/VegaParametersWidget.hpp | 14 +- src/Dialogs/Dialogs.h | 2 +- src/Dialogs/DownloadFilePicker.cpp | 2 +- src/Dialogs/Error.cpp | 6 +- src/Dialogs/Error.hpp | 6 +- src/Dialogs/FileManager.cpp | 18 +- src/Dialogs/FilePicker.cpp | 8 +- src/Dialogs/FilePicker.hpp | 6 +- src/Dialogs/GeoPointEntry.cpp | 2 +- src/Dialogs/GeoPointEntry.hpp | 2 +- src/Dialogs/HelpDialog.cpp | 4 +- src/Dialogs/HelpDialog.hpp | 2 +- src/Dialogs/JobDialog.cpp | 2 +- src/Dialogs/JobDialog.hpp | 6 +- src/Dialogs/KnobTextEntry.cpp | 20 +-- src/Dialogs/ListPicker.cpp | 10 +- src/Dialogs/ListPicker.hpp | 8 +- src/Dialogs/Message.cpp | 2 +- src/Dialogs/Message.hpp | 2 +- src/Dialogs/NumberEntry.cpp | 6 +- src/Dialogs/NumberEntry.hpp | 6 +- src/Dialogs/Plane/PlaneDetailsDialog.cpp | 2 +- src/Dialogs/Plane/PlaneListDialog.cpp | 4 +- src/Dialogs/Plane/PolarShapeEditWidget.cpp | 4 +- src/Dialogs/ProcessDialog.cpp | 2 +- src/Dialogs/ProcessDialog.hpp | 2 +- src/Dialogs/ProfileListDialog.cpp | 6 +- src/Dialogs/ProfilePasswordDialog.cpp | 6 +- src/Dialogs/ProgressDialog.cpp | 2 +- src/Dialogs/ProgressDialog.hpp | 4 +- src/Dialogs/Settings/Panels/ConfigPanel.hpp | 2 +- .../Settings/Panels/InterfaceConfigPanel.cpp | 4 +- .../Settings/Panels/PagesConfigPanel.cpp | 10 +- .../Panels/TaskDefaultsConfigPanel.cpp | 4 +- .../Settings/Panels/TrackingConfigPanel.cpp | 2 +- src/Dialogs/Settings/WindSettingsPanel.cpp | 2 +- src/Dialogs/Settings/dlgConfigInfoboxes.cpp | 14 +- src/Dialogs/Settings/dlgConfiguration.cpp | 6 +- src/Dialogs/StartupDialog.cpp | 4 +- src/Dialogs/StatusPanels/RulesStatusPanel.cpp | 2 +- .../StatusPanels/SystemStatusPanel.cpp | 6 +- src/Dialogs/Task/Manager/TaskEditPanel.cpp | 4 +- src/Dialogs/Task/Manager/TaskListPanel.cpp | 14 +- src/Dialogs/Task/MutateTaskPointDialog.cpp | 2 +- src/Dialogs/Task/dlgTaskHelpers.cpp | 16 +- src/Dialogs/Task/dlgTaskHelpers.hpp | 8 +- src/Dialogs/TextEntry.cpp | 4 +- src/Dialogs/TextEntry.hpp | 22 +-- src/Dialogs/TimeEntry.cpp | 2 +- src/Dialogs/TimeEntry.hpp | 2 +- src/Dialogs/TouchTextEntry.cpp | 10 +- src/Dialogs/Tracking/CloudEnableDialog.cpp | 2 +- src/Dialogs/Traffic/FlarmTrafficDetails.cpp | 20 +-- src/Dialogs/Traffic/TeamCodeDialog.cpp | 4 +- src/Dialogs/Traffic/TrafficDialogs.hpp | 2 +- src/Dialogs/Traffic/TrafficList.cpp | 10 +- src/Dialogs/Waypoint/WaypointInfoWidget.cpp | 10 +- src/Dialogs/Waypoint/WaypointInfoWidget.hpp | 2 +- src/Dialogs/Waypoint/WaypointList.cpp | 14 +- src/Dialogs/Waypoint/dlgWaypointDetails.cpp | 2 +- src/Dialogs/Weather/MapOverlayWidget.cpp | 12 +- src/Dialogs/Weather/NOAAList.cpp | 2 +- src/Dialogs/Weather/PCMetDialog.cpp | 4 +- src/Dialogs/Weather/RASPDialog.cpp | 6 +- src/Dialogs/Weather/WeatherDialog.cpp | 2 +- src/Dialogs/Weather/WeatherDialog.hpp | 2 +- src/Dialogs/WidgetDialog.cpp | 14 +- src/Dialogs/WidgetDialog.hpp | 20 +-- src/Dialogs/dlgAnalysis.cpp | 12 +- src/Dialogs/dlgCredits.cpp | 8 +- src/Dialogs/dlgQuickMenu.cpp | 6 +- src/Engine/Airspace/AbstractAirspace.cpp | 2 +- src/Engine/Airspace/AbstractAirspace.hpp | 6 +- src/Engine/Airspace/AirspaceSorter.hpp | 2 +- src/Engine/Contest/Solvers/Contests.cpp | 4 +- src/Engine/Contest/Solvers/Contests.hpp | 2 +- src/Engine/Waypoint/Waypoints.cpp | 14 +- src/Engine/Waypoint/Waypoints.hpp | 8 +- src/FLARM/Computer.cpp | 2 +- src/FLARM/Details.cpp | 8 +- src/FLARM/Details.hpp | 8 +- src/FLARM/Error.cpp | 8 +- src/FLARM/Error.hpp | 8 +- src/FLARM/FlarmNetDatabase.cpp | 6 +- src/FLARM/FlarmNetDatabase.hpp | 6 +- src/FLARM/FlarmNetReader.cpp | 6 +- src/FLARM/List.hpp | 4 +- src/FLARM/NameDatabase.cpp | 10 +- src/FLARM/NameDatabase.hpp | 12 +- src/FLARM/NameFile.cpp | 2 +- src/FLARM/Traffic.cpp | 4 +- src/FLARM/Traffic.hpp | 2 +- src/FLARM/TrafficDatabases.cpp | 8 +- src/FLARM/TrafficDatabases.hpp | 6 +- src/Form/Button.cpp | 8 +- src/Form/Button.hpp | 8 +- src/Form/ButtonPanel.cpp | 4 +- src/Form/ButtonPanel.hpp | 4 +- src/Form/CharacterButton.cpp | 4 +- src/Form/CharacterButton.hpp | 2 +- src/Form/Control.cpp | 2 +- src/Form/Control.hpp | 10 +- src/Form/DataField/Angle.cpp | 10 +- src/Form/DataField/Angle.hpp | 10 +- src/Form/DataField/Base.cpp | 6 +- src/Form/DataField/Base.hpp | 8 +- src/Form/DataField/Boolean.cpp | 6 +- src/Form/DataField/Boolean.hpp | 8 +- src/Form/DataField/ComboList.cpp | 6 +- src/Form/DataField/ComboList.hpp | 22 +-- src/Form/DataField/Date.cpp | 2 +- src/Form/DataField/Date.hpp | 4 +- src/Form/DataField/Enum.cpp | 44 ++--- src/Form/DataField/Enum.hpp | 70 ++++---- src/Form/DataField/File.cpp | 20 +-- src/Form/DataField/File.hpp | 12 +- src/Form/DataField/Float.cpp | 10 +- src/Form/DataField/Float.hpp | 14 +- src/Form/DataField/GeoPoint.cpp | 2 +- src/Form/DataField/GeoPoint.hpp | 4 +- src/Form/DataField/Integer.cpp | 12 +- src/Form/DataField/Integer.hpp | 12 +- src/Form/DataField/Number.cpp | 6 +- src/Form/DataField/Number.hpp | 4 +- src/Form/DataField/Password.cpp | 4 +- src/Form/DataField/Password.hpp | 4 +- src/Form/DataField/Prefix.cpp | 24 +-- src/Form/DataField/Prefix.hpp | 10 +- src/Form/DataField/RoughTime.cpp | 6 +- src/Form/DataField/RoughTime.hpp | 4 +- src/Form/DataField/String.cpp | 6 +- src/Form/DataField/String.hpp | 12 +- src/Form/DataField/Time.cpp | 10 +- src/Form/DataField/Time.hpp | 10 +- src/Form/DigitEntry.cpp | 4 +- src/Form/Edit.cpp | 6 +- src/Form/Edit.hpp | 12 +- src/Form/Form.cpp | 10 +- src/Form/Form.hpp | 12 +- src/Form/Frame.cpp | 2 +- src/Form/Frame.hpp | 4 +- src/Form/TabDisplay.cpp | 6 +- src/Form/TabDisplay.hpp | 4 +- src/Form/TabMenuData.hpp | 4 +- src/Form/TabMenuDisplay.cpp | 4 +- src/Form/TabMenuDisplay.hpp | 8 +- src/Formatter/AirspaceFormatter.cpp | 14 +- src/Formatter/AirspaceFormatter.hpp | 14 +- src/Formatter/AirspaceUserUnitsFormatter.cpp | 4 +- src/Formatter/AngleFormatter.cpp | 10 +- src/Formatter/AngleFormatter.hpp | 24 +-- src/Formatter/ByteSizeFormatter.cpp | 10 +- src/Formatter/ByteSizeFormatter.hpp | 2 +- src/Formatter/GeoPointFormatter.cpp | 22 +-- src/Formatter/GeoPointFormatter.hpp | 14 +- src/Formatter/GlideRatioFormatter.cpp | 2 +- src/Formatter/GlideRatioFormatter.hpp | 2 +- src/Formatter/IGCFilenameFormatter.cpp | 18 +- src/Formatter/IGCFilenameFormatter.hpp | 8 +- src/Formatter/LocalTimeFormatter.cpp | 2 +- src/Formatter/LocalTimeFormatter.hpp | 6 +- src/Formatter/TimeFormatter.cpp | 12 +- src/Formatter/TimeFormatter.hpp | 28 +-- src/Formatter/Units.cpp | 30 ++-- src/Formatter/Units.hpp | 26 +-- src/Formatter/UserGeoPointFormatter.cpp | 10 +- src/Formatter/UserGeoPointFormatter.hpp | 14 +- src/Formatter/UserUnits.cpp | 34 ++-- src/Formatter/UserUnits.hpp | 48 ++--- src/Gauge/BigThermalAssistantWindow.cpp | 2 +- src/Gauge/BigTrafficWidget.cpp | 14 +- src/Gauge/FlarmTrafficWindow.cpp | 4 +- src/Gauge/GaugeVario.cpp | 10 +- src/Gauge/GaugeVario.hpp | 4 +- src/Gauge/ThermalAssistantRenderer.cpp | 4 +- src/HorizonWidget.cpp | 2 +- src/IGC/Generator.cpp | 2 +- src/IGC/Generator.hpp | 2 +- src/IGC/IGCWriter.cpp | 18 +- src/IGC/IGCWriter.hpp | 18 +- src/InfoBoxes/Content/Factory.cpp | 30 ++-- src/InfoBoxes/Content/Factory.hpp | 6 +- src/InfoBoxes/Content/MacCready.cpp | 2 +- src/InfoBoxes/Content/Other.cpp | 2 +- src/InfoBoxes/Content/Radio.cpp | 2 +- src/InfoBoxes/Content/Thermal.cpp | 4 +- src/InfoBoxes/Content/Trace.cpp | 2 +- src/InfoBoxes/Content/Weather.cpp | 6 +- src/InfoBoxes/Data.cpp | 6 +- src/InfoBoxes/Data.hpp | 12 +- src/InfoBoxes/Format.cpp | 4 +- src/InfoBoxes/InfoBoxManager.cpp | 4 +- src/InfoBoxes/InfoBoxWindow.cpp | 2 +- src/InfoBoxes/InfoBoxWindow.hpp | 4 +- src/InfoBoxes/Panel/ATCReference.cpp | 4 +- src/InfoBoxes/Panel/Panel.hpp | 4 +- src/Input/InputConfig.hpp | 8 +- src/Input/InputDefaults.cpp | 8 +- src/Input/InputEvents.cpp | 22 +-- src/Input/InputEvents.hpp | 164 +++++++++--------- src/Input/InputEventsActions.cpp | 88 +++++----- src/Input/InputEventsAirspace.cpp | 6 +- src/Input/InputEventsDevice.cpp | 8 +- src/Input/InputEventsLua.cpp | 6 +- src/Input/InputEventsMap.cpp | 6 +- src/Input/InputEventsPage.cpp | 2 +- src/Input/InputEventsSettings.cpp | 40 ++--- src/Input/InputEventsTask.cpp | 22 +-- src/Input/InputEventsThermalAssistant.cpp | 2 +- src/Input/InputEventsTraffic.cpp | 8 +- src/Input/InputEventsVega.cpp | 2 +- src/Input/InputKeys.cpp | 4 +- src/Input/InputKeys.hpp | 2 +- src/Input/InputLookup.cpp | 10 +- src/Input/InputLookup.hpp | 6 +- src/Input/InputParser.cpp | 6 +- src/Input/InputQueue.hpp | 2 +- src/Kobo/FakeSymbols.cpp | 4 +- src/Kobo/NetworkDialog.cpp | 2 +- src/Kobo/PowerOff.cpp | 8 +- src/Kobo/ToolsDialog.cpp | 2 +- src/Kobo/WifiDialog.cpp | 2 +- src/Language/Language.cpp | 4 +- src/Language/Language.hpp | 2 +- src/Language/LanguageGlue.cpp | 4 +- src/Language/Table.hpp | 4 +- src/LocalPath.cpp | 20 +-- src/LocalPath.hpp | 8 +- src/Logger/ExternalLogger.cpp | 4 +- src/Logger/Logger.cpp | 4 +- src/Logger/Logger.hpp | 2 +- src/Logger/LoggerImpl.cpp | 6 +- src/Logger/LoggerImpl.hpp | 4 +- src/Look/AutoFont.cpp | 2 +- src/Look/AutoFont.hpp | 2 +- src/Look/FontDescription.cpp | 2 +- src/Look/FontDescription.hpp | 2 +- src/Look/StandardFonts.hpp | 4 +- src/MainWindow.cpp | 4 +- src/MainWindow.hpp | 4 +- src/MapWindow/GlueMapWindow.hpp | 2 +- src/MapWindow/GlueMapWindowEvents.cpp | 4 +- src/MapWindow/GlueMapWindowOverlays.cpp | 10 +- src/MapWindow/Items/MapItem.hpp | 2 +- src/MapWindow/Items/RaspMapItem.hpp | 2 +- src/MapWindow/Items/TrafficBuilder.cpp | 2 +- src/MapWindow/MapWindowTask.cpp | 2 +- src/MapWindow/MapWindowTraffic.cpp | 4 +- src/MapWindow/Overlay.hpp | 2 +- src/MapWindow/OverlayBitmap.hpp | 2 +- src/Menu/ButtonLabel.cpp | 28 +-- src/Menu/ButtonLabel.hpp | 6 +- src/Menu/ExpandMacros.cpp | 14 +- src/Menu/Glue.cpp | 4 +- src/Menu/Glue.hpp | 2 +- src/Menu/MenuBar.cpp | 2 +- src/Menu/MenuBar.hpp | 2 +- src/Menu/MenuData.cpp | 2 +- src/Menu/MenuData.hpp | 4 +- src/Message.cpp | 2 +- src/Message.hpp | 2 +- src/Monitor/AirspaceWarningMonitor.cpp | 2 +- src/Monitor/MatTaskMonitor.cpp | 2 +- src/OpenVario/ExtraWidget.cpp | 6 +- src/OpenVario/FileMenuWidget.cpp | 6 +- src/OpenVario/System/WifiDialogOV.cpp | 2 +- src/Operation/ConsoleOperationEnvironment.cpp | 4 +- src/Operation/ConsoleOperationEnvironment.hpp | 4 +- src/Operation/MessageOperationEnvironment.cpp | 2 +- src/Operation/MessageOperationEnvironment.hpp | 2 +- src/Operation/Operation.cpp | 4 +- src/Operation/Operation.hpp | 8 +- .../PluggableOperationEnvironment.cpp | 4 +- .../PluggableOperationEnvironment.hpp | 4 +- src/Operation/PopupOperationEnvironment.cpp | 2 +- src/Operation/PopupOperationEnvironment.hpp | 2 +- src/Operation/ProxyOperationEnvironment.cpp | 4 +- src/Operation/ProxyOperationEnvironment.hpp | 4 +- .../ThreadedOperationEnvironment.cpp | 4 +- .../ThreadedOperationEnvironment.hpp | 8 +- src/Operation/VerboseOperationEnvironment.cpp | 2 +- src/Operation/VerboseOperationEnvironment.hpp | 2 +- src/PageSettings.cpp | 8 +- src/PageSettings.hpp | 4 +- src/Polar/PolarStore.hpp | 2 +- src/PopupMessage.cpp | 8 +- src/PopupMessage.hpp | 6 +- src/Profile/DeviceConfig.cpp | 2 +- src/Profile/Map.hpp | 8 +- src/Profile/PathValue.cpp | 6 +- src/Profile/ProfileMap.cpp | 2 +- src/Profile/ProfileMap.hpp | 4 +- src/Profile/StringValue.cpp | 2 +- src/ProgressGlue.cpp | 2 +- src/ProgressGlue.hpp | 2 +- src/ProgressWindow.cpp | 2 +- src/ProgressWindow.hpp | 2 +- src/RadioFrequency.cpp | 4 +- src/RadioFrequency.hpp | 2 +- src/Renderer/AirspaceLabelRenderer.cpp | 4 +- src/Renderer/AirspaceListRenderer.cpp | 4 +- src/Renderer/BarographRenderer.cpp | 2 +- src/Renderer/BarographRenderer.hpp | 2 +- src/Renderer/ChartRenderer.cpp | 16 +- src/Renderer/ChartRenderer.hpp | 16 +- src/Renderer/ClimbChartRenderer.cpp | 2 +- src/Renderer/ClimbChartRenderer.hpp | 2 +- src/Renderer/CuRenderer.cpp | 2 +- src/Renderer/CuRenderer.hpp | 2 +- src/Renderer/FinalGlideBarRenderer.cpp | 2 +- src/Renderer/FlightListRenderer.cpp | 2 +- src/Renderer/FlightStatisticsRenderer.cpp | 4 +- src/Renderer/FlightStatisticsRenderer.hpp | 4 +- src/Renderer/GlidePolarRenderer.cpp | 2 +- src/Renderer/GlidePolarRenderer.hpp | 2 +- src/Renderer/MacCreadyRenderer.cpp | 2 +- src/Renderer/MacCreadyRenderer.hpp | 2 +- src/Renderer/MapItemListRenderer.cpp | 8 +- src/Renderer/NOAAListRenderer.cpp | 2 +- src/Renderer/TabRenderer.cpp | 2 +- src/Renderer/TabRenderer.hpp | 2 +- src/Renderer/TaskLegRenderer.cpp | 2 +- src/Renderer/TaskSpeedRenderer.cpp | 2 +- src/Renderer/TaskSpeedRenderer.hpp | 2 +- src/Renderer/TextInBox.cpp | 6 +- src/Renderer/TextInBox.hpp | 4 +- src/Renderer/TextRowRenderer.cpp | 10 +- src/Renderer/TextRowRenderer.hpp | 10 +- src/Renderer/TwoTextRowsRenderer.cpp | 8 +- src/Renderer/TwoTextRowsRenderer.hpp | 8 +- src/Renderer/UnitSymbolRenderer.cpp | 4 +- src/Renderer/VarioBarRenderer.cpp | 2 +- src/Renderer/WaypointLabelList.cpp | 2 +- src/Renderer/WaypointLabelList.hpp | 4 +- src/Renderer/WaypointListRenderer.cpp | 4 +- src/Renderer/WaypointRenderer.cpp | 10 +- src/ResourceLoader.cpp | 2 +- src/ResourceLoader.hpp | 2 +- src/StatusMessage.cpp | 2 +- src/StatusMessage.hpp | 6 +- src/Task/Serialiser.cpp | 10 +- src/Task/TaskFileIGC.cpp | 2 +- src/Task/TaskStore.cpp | 2 +- src/Task/TypeStrings.cpp | 16 +- src/Task/TypeStrings.hpp | 8 +- src/Task/ValidationErrorStrings.cpp | 8 +- src/Task/ValidationErrorStrings.hpp | 2 +- src/Task/XCTrackTaskDecoder.cpp | 2 +- src/TeamActions.cpp | 2 +- src/TeamActions.hpp | 2 +- src/TeamCode/Settings.cpp | 2 +- src/TeamCode/Settings.hpp | 2 +- src/TeamCode/TeamCode.cpp | 14 +- src/TeamCode/TeamCode.hpp | 4 +- src/Terrain/RasterTerrain.cpp | 2 +- src/Topography/TopographyFileRenderer.cpp | 2 +- src/Topography/XShape.cpp | 4 +- src/Topography/XShape.hpp | 4 +- src/Tracking/LiveTrack24/Client.cpp | 10 +- src/Tracking/LiveTrack24/Client.hpp | 10 +- src/Tracking/SkyLines/Handler.hpp | 2 +- src/Tracking/TrackingGlue.cpp | 2 +- src/Tracking/TrackingGlue.hpp | 2 +- src/TransponderCode.cpp | 8 +- src/TransponderCode.hpp | 4 +- src/UIGlobals.cpp | 2 +- src/UIGlobals.hpp | 2 +- src/UIUtil/GestureManager.cpp | 8 +- src/UIUtil/GestureManager.hpp | 4 +- src/UIUtil/TrackingGestureManager.cpp | 2 +- src/UIUtil/TrackingGestureManager.hpp | 2 +- src/Units/Descriptor.cpp | 2 +- src/Units/Descriptor.hpp | 4 +- src/Units/Units.cpp | 16 +- src/Units/Units.hpp | 16 +- src/Units/UnitsGlue.cpp | 4 +- src/Units/UnitsStore.cpp | 4 +- src/Units/UnitsStore.hpp | 2 +- src/Version.cpp | 10 +- src/Version.hpp | 10 +- src/Waypoint/WaypointDetailsReader.cpp | 4 +- src/Waypoint/WaypointFilter.cpp | 2 +- src/Waypoint/WaypointFilter.hpp | 2 +- src/Waypoint/WaypointReaderZander.cpp | 2 +- src/Weather/METARParser.cpp | 64 +++---- src/Weather/NOAAFormatter.cpp | 24 +-- src/Weather/NOAAStore.hpp | 2 +- src/Weather/PCMet/Images.hpp | 4 +- src/Weather/PCMet/Overlays.cpp | 4 +- src/Weather/Rasp/RaspCache.cpp | 4 +- src/Weather/Rasp/RaspCache.hpp | 4 +- src/Weather/Rasp/RaspRenderer.cpp | 2 +- src/Weather/Rasp/RaspRenderer.hpp | 2 +- src/Weather/Rasp/RaspStore.cpp | 2 +- src/Weather/Rasp/RaspStore.hpp | 12 +- src/Weather/Rasp/RaspStyle.hpp | 2 +- src/Widget/ButtonWidget.cpp | 2 +- src/Widget/ButtonWidget.hpp | 2 +- src/Widget/EditRowFormWidget.cpp | 58 +++---- src/Widget/KeyboardWidget.cpp | 12 +- src/Widget/KeyboardWidget.hpp | 6 +- src/Widget/LargeTextWidget.cpp | 2 +- src/Widget/LargeTextWidget.hpp | 6 +- src/Widget/OffsetButtonsWidget.cpp | 2 +- src/Widget/OffsetButtonsWidget.hpp | 4 +- src/Widget/ProfileRowFormWidget.cpp | 8 +- src/Widget/ProgressWidget.cpp | 4 +- src/Widget/ProgressWidget.hpp | 4 +- src/Widget/QuestionWidget.cpp | 4 +- src/Widget/QuestionWidget.hpp | 10 +- src/Widget/RowFormWidget.cpp | 8 +- src/Widget/RowFormWidget.hpp | 98 +++++------ src/Widget/TabWidget.cpp | 4 +- src/Widget/TabWidget.hpp | 4 +- src/Widget/TextListWidget.hpp | 2 +- src/Widget/TextWidget.cpp | 2 +- src/Widget/TextWidget.hpp | 2 +- src/Widget/UnitRowFormWidget.cpp | 10 +- src/XML/DataNode.hpp | 2 +- src/io/DataFile.cpp | 2 +- src/io/DataFile.hpp | 2 +- src/io/FileCache.cpp | 6 +- src/io/FileCache.hpp | 8 +- src/io/StringConverter.cpp | 2 +- src/io/StringConverter.hpp | 6 +- src/lua/InputEvent.cpp | 6 +- src/lua/InputEvent.hpp | 4 +- src/system/Args.hpp | 2 +- src/system/FileUtil.cpp | 20 +-- src/system/FileUtil.hpp | 2 +- src/system/PathName.cpp | 14 +- src/system/PathName.hpp | 2 +- src/system/RunFile.cpp | 2 +- src/system/RunFile.hpp | 2 +- src/system/WindowsRegistry.hpp | 10 +- src/ui/canvas/custom/MoreCanvas.cpp | 6 +- src/ui/canvas/gdi/GdiPlusBitmap.cpp | 2 +- src/ui/canvas/gdi/GdiPlusBitmap.hpp | 2 +- src/ui/control/LargeTextWindow.hpp | 2 +- src/ui/control/TerminalWindow.hpp | 2 +- src/ui/control/custom/LargeTextWindow.cpp | 4 +- src/ui/control/gdi/LargeTextWindow.cpp | 10 +- src/ui/window/PaintWindow.hpp | 4 +- src/ui/window/SingleWindow.hpp | 4 +- src/ui/window/TopWindow.hpp | 10 +- src/ui/window/Window.hpp | 2 +- src/ui/window/custom/TopWindow.cpp | 2 +- src/ui/window/gdi/TopWindow.cpp | 2 +- src/ui/window/gdi/Window.cpp | 4 +- src/ui/window/sdl/TopWindow.cpp | 2 +- src/ui/window/wayland/TopWindow.cpp | 2 +- src/ui/window/x11/TopWindow.cpp | 2 +- src/unix/tchar.h | 1 - src/util/ConvertString.hpp | 6 +- src/util/DollarExpand.hpp | 4 +- src/util/EscapeBackslash.cpp | 2 +- src/util/RadixTree.hpp | 98 +++++------ src/util/TruncateString.cpp | 6 +- src/util/TruncateString.hpp | 6 +- test/src/FakeDialogs.cpp | 8 +- test/src/FakeHelpDialog.cpp | 2 +- test/src/FakeLanguage.cpp | 4 +- test/src/FakeListPicker.cpp | 4 +- test/src/FakeMessage.cpp | 4 +- test/src/FakeProfile.cpp | 2 +- test/src/FlightTable.cpp | 2 +- test/src/KeyCodeDumper.cpp | 2 +- test/src/LoadImage.cpp | 2 +- test/src/RunAirspaceWarningDialog.cpp | 4 +- test/src/RunCanvas.cpp | 2 +- test/src/RunChartRenderer.cpp | 2 +- test/src/RunCirclingWind.cpp | 2 +- test/src/RunDeclare.cpp | 6 +- test/src/RunEnableNMEA.cpp | 2 +- test/src/RunExternalWind.cpp | 2 +- test/src/RunFlarmUtils.cpp | 12 +- test/src/RunFlyingComputer.cpp | 4 +- test/src/RunIGCWriter.cpp | 2 +- test/src/RunInputParser.cpp | 8 +- test/src/RunListControl.cpp | 2 +- test/src/RunNOAADownloader.cpp | 8 +- test/src/RunProfileListDialog.cpp | 4 +- test/src/RunRenderOZ.cpp | 2 +- test/src/RunTaskEditorDialog.cpp | 2 +- test/src/RunTextEntry.cpp | 2 +- test/src/RunWaveComputer.cpp | 2 +- test/src/RunWindComputer.cpp | 2 +- test/src/RunWindEKF.cpp | 2 +- test/src/TestAirspaceParser.cpp | 2 +- test/src/TestByteSizeFormatter.cpp | 2 +- test/src/TestGRecord.cpp | 2 +- test/src/TestGeoPointFormatter.cpp | 6 +- test/src/TestIGCFilenameFormatter.cpp | 6 +- test/src/TestPolars.cpp | 6 +- test/src/TestRadixTree.cpp | 6 +- test/src/TestTimeFormatter.cpp | 16 +- test/src/TestTransponderCode.cpp | 2 +- test/src/TestUnitsFormatter.cpp | 22 +-- test/src/TestWaypoints.cpp | 6 +- tools/GenerateResources.pl | 4 +- tools/xci2cpp.pl | 2 +- 567 files changed, 2028 insertions(+), 2031 deletions(-) diff --git a/src/ActionInterface.cpp b/src/ActionInterface.cpp index 6852528b7af..7c73772b4e1 100644 --- a/src/ActionInterface.cpp +++ b/src/ActionInterface.cpp @@ -260,7 +260,7 @@ ActionInterface::SendUIState() noexcept void ActionInterface::SetActiveFrequency(const RadioFrequency freq, - const TCHAR *freq_name, + const char *freq_name, bool to_devices) noexcept { assert(freq.IsDefined()); @@ -289,7 +289,7 @@ ActionInterface::SetActiveFrequency(const RadioFrequency freq, void ActionInterface::SetStandbyFrequency(const RadioFrequency freq, - const TCHAR *freq_name, + const char *freq_name, bool to_devices) noexcept { assert(freq.IsDefined()); diff --git a/src/ActionInterface.hpp b/src/ActionInterface.hpp index 71a0195e5a6..306dbce509c 100644 --- a/src/ActionInterface.hpp +++ b/src/ActionInterface.hpp @@ -101,7 +101,7 @@ SendUIState() noexcept; * @param to_devices send the new setting to all devices? */ void -SetActiveFrequency(RadioFrequency freq, const TCHAR *freq_name, +SetActiveFrequency(RadioFrequency freq, const char *freq_name, bool to_devices=true) noexcept; /** @@ -111,7 +111,7 @@ SetActiveFrequency(RadioFrequency freq, const TCHAR *freq_name, * @param to_devices send the new setting to all devices? */ void -SetStandbyFrequency(RadioFrequency freq, const TCHAR *freq_name, +SetStandbyFrequency(RadioFrequency freq, const char *freq_name, bool to_devices=true) noexcept; /** diff --git a/src/Audio/PCMResourcePlayer.cpp b/src/Audio/PCMResourcePlayer.cpp index 8e9aa6ec86d..eafc5c508f7 100644 --- a/src/Audio/PCMResourcePlayer.cpp +++ b/src/Audio/PCMResourcePlayer.cpp @@ -17,7 +17,7 @@ PCMResourcePlayer::PCMResourcePlayer() : } bool -PCMResourcePlayer::PlayResource(const TCHAR *resource_name) +PCMResourcePlayer::PlayResource(const char *resource_name) { PCMBufferDataSource::PCMData pcm_data = FromBytesStrict( diff --git a/src/Audio/PCMResourcePlayer.hpp b/src/Audio/PCMResourcePlayer.hpp index d103d81045c..773ff7438f9 100644 --- a/src/Audio/PCMResourcePlayer.hpp +++ b/src/Audio/PCMResourcePlayer.hpp @@ -28,5 +28,5 @@ class PCMResourcePlayer { PCMResourcePlayer(PCMResourcePlayer &) = delete; PCMResourcePlayer &operator=(PCMResourcePlayer &) = delete; - bool PlayResource(const TCHAR *resource_name); + bool PlayResource(const char *resource_name); }; diff --git a/src/Audio/Sound.cpp b/src/Audio/Sound.cpp index cbe5c80f233..7f4a1bc7dae 100644 --- a/src/Audio/Sound.cpp +++ b/src/Audio/Sound.cpp @@ -19,7 +19,7 @@ #endif bool -PlayResource(const TCHAR *resource_name) +PlayResource(const char *resource_name) { #ifdef ANDROID diff --git a/src/Audio/Sound.hpp b/src/Audio/Sound.hpp index 1de754d49cf..e8c7b822bd9 100644 --- a/src/Audio/Sound.hpp +++ b/src/Audio/Sound.hpp @@ -5,4 +5,4 @@ #include -bool PlayResource(const TCHAR *resource_name); +bool PlayResource(const char *resource_name); diff --git a/src/Compatibility/path.h b/src/Compatibility/path.h index 6047f38a403..697a20b229e 100644 --- a/src/Compatibility/path.h +++ b/src/Compatibility/path.h @@ -18,7 +18,7 @@ #endif /* !_WIN32 */ static inline bool -IsDirSeparator(TCHAR ch) +IsDirSeparator(char ch) { #ifdef _WIN32 // at Windows both separators are possible!!! diff --git a/src/CrossSection/AirspaceXSRenderer.cpp b/src/CrossSection/AirspaceXSRenderer.cpp index f2a26afa358..02dc3b3428f 100644 --- a/src/CrossSection/AirspaceXSRenderer.cpp +++ b/src/CrossSection/AirspaceXSRenderer.cpp @@ -168,7 +168,7 @@ AirspaceIntersectionVisitorSlice::Render(const AbstractAirspace &as) const max_x -= Layout::GetTextPadding(); /* draw the airspace name */ - const TCHAR *name = as.GetName(); + const char *name = as.GetName(); if (name != nullptr && !StringIsEmpty(name) && min_x < max_x) { canvas.SetBackgroundTransparent(); canvas.SetTextColor(COLOR_BLACK); diff --git a/src/Device/Config.cpp b/src/Device/Config.cpp index 45f689b9ae9..25230bfbac1 100644 --- a/src/Device/Config.cpp +++ b/src/Device/Config.cpp @@ -113,7 +113,7 @@ DeviceConfig::ShouldReopenOnTimeout() const noexcept } bool -DeviceConfig::MaybeBluetooth(PortType port_type, [[maybe_unused]] const TCHAR *path) noexcept +DeviceConfig::MaybeBluetooth(PortType port_type, [[maybe_unused]] const char *path) noexcept { /* note: RFCOMM_SERVER is not considered here because this function is used to check for the K6-Bt protocol, but the K6-Bt @@ -192,8 +192,8 @@ DeviceConfig::Clear() noexcept // dump_port = true; } -const TCHAR * -DeviceConfig::GetPortName(TCHAR *buffer, size_t max_size) const noexcept +const char * +DeviceConfig::GetPortName(char *buffer, size_t max_size) const noexcept { switch (port_type) { case PortType::DISABLED: @@ -203,7 +203,7 @@ DeviceConfig::GetPortName(TCHAR *buffer, size_t max_size) const noexcept return path.c_str(); case PortType::BLE_SENSOR: { - const TCHAR *name = bluetooth_mac.c_str(); + const char *name = bluetooth_mac.c_str(); #ifdef ANDROID if (bluetooth_helper != nullptr) { const char *name2 = @@ -221,7 +221,7 @@ DeviceConfig::GetPortName(TCHAR *buffer, size_t max_size) const noexcept } case PortType::BLE_HM10: { - const TCHAR *name = bluetooth_mac.c_str(); + const char *name = bluetooth_mac.c_str(); #ifdef ANDROID if (bluetooth_helper != nullptr) { const char *name2 = @@ -239,7 +239,7 @@ DeviceConfig::GetPortName(TCHAR *buffer, size_t max_size) const noexcept } case PortType::RFCOMM: { - const TCHAR *name = bluetooth_mac.c_str(); + const char *name = bluetooth_mac.c_str(); #ifdef ANDROID if (bluetooth_helper != nullptr) { const char *name2 = diff --git a/src/Device/Config.hpp b/src/Device/Config.hpp index 44734ac6ea4..eb8e604b730 100644 --- a/src/Device/Config.hpp +++ b/src/Device/Config.hpp @@ -322,7 +322,7 @@ struct DeviceConfig { } [[gnu::pure]] - static bool MaybeBluetooth(PortType port_type, const TCHAR *path) noexcept; + static bool MaybeBluetooth(PortType port_type, const char *path) noexcept; [[gnu::pure]] bool MaybeBluetooth() const noexcept; @@ -411,7 +411,7 @@ struct DeviceConfig { return UsesTCPPort(port_type); } - constexpr bool IsDriver(const TCHAR *name) const noexcept { + constexpr bool IsDriver(const char *name) const noexcept { return UsesDriver() && driver_name.equals(name); } @@ -467,5 +467,5 @@ struct DeviceConfig { * Generates a human-readable (localised) port name. */ [[gnu::pure]] - const TCHAR *GetPortName(TCHAR *buffer, size_t max_size) const noexcept; + const char *GetPortName(char *buffer, size_t max_size) const noexcept; }; diff --git a/src/Device/Declaration.hpp b/src/Device/Declaration.hpp index 5f71e8f7416..6bde2da857f 100644 --- a/src/Device/Declaration.hpp +++ b/src/Device/Declaration.hpp @@ -59,12 +59,12 @@ struct Declaration { } [[gnu::pure]] - const TCHAR *GetName(const unsigned i) const { + const char *GetName(const unsigned i) const { return turnpoints[i].waypoint.name.c_str(); } [[gnu::pure]] - const TCHAR *GetShortName(const unsigned i) const { + const char *GetShortName(const unsigned i) const { return turnpoints[i].waypoint.shortname.c_str(); } diff --git a/src/Device/Descriptor.cpp b/src/Device/Descriptor.cpp index 18d9fd1647c..65e7c82a328 100644 --- a/src/Device/Descriptor.cpp +++ b/src/Device/Descriptor.cpp @@ -388,8 +388,8 @@ try { } catch (...) { const auto e = std::current_exception(); - TCHAR name_buffer[64]; - const TCHAR *name = config.GetPortName(name_buffer, 64); + char name_buffer[64]; + const char *name = config.GetPortName(name_buffer, 64); LogError(e, _A(name)); @@ -399,7 +399,7 @@ try { StaticString<256> msg; msg.Format(_T("%s: %s (%s)"), _("Unable to open port"), name, - (const TCHAR *)what); + (const char *)what); env.SetErrorMessage(msg); } @@ -407,8 +407,8 @@ try { } if (port == nullptr) { - TCHAR name_buffer[64]; - const TCHAR *name = config.GetPortName(name_buffer, 64); + char name_buffer[64]; + const char *name = config.GetPortName(name_buffer, 64); StaticString<256> msg; msg.Format(_T("%s: %s."), _("Unable to open port"), name); @@ -466,7 +466,7 @@ DeviceDescriptor::Open(OperationEnvironment &env) assert(!IsOccupied()); assert(open_job == nullptr); - TCHAR buffer[64]; + char buffer[64]; LogFormat(_T("Opening device %s"), config.GetPortName(buffer, 64)); #ifdef ANDROID @@ -555,7 +555,7 @@ DeviceDescriptor::AutoReopen(OperationEnvironment &env) !reopen_clock.CheckUpdate(std::chrono::seconds(30))) return; - TCHAR buffer[64]; + char buffer[64]; LogFormat(_T("Reconnecting to device %s"), config.GetPortName(buffer, 64)); InputEvents::processGlideComputer(GCE_COMMPORT_RESTART); @@ -585,7 +585,7 @@ DeviceDescriptor::EnableNMEA(OperationEnvironment &env) noexcept return success; } -const TCHAR * +const char * DeviceDescriptor::GetDisplayName() const noexcept { return driver != nullptr @@ -594,7 +594,7 @@ DeviceDescriptor::GetDisplayName() const noexcept } bool -DeviceDescriptor::IsDriver(const TCHAR *name) const noexcept +DeviceDescriptor::IsDriver(const char *name) const noexcept { return driver != nullptr ? StringIsEqual(driver->name, name) @@ -917,7 +917,7 @@ DeviceDescriptor::PutPilotEvent(OperationEnvironment &env) noexcept bool DeviceDescriptor::PutActiveFrequency(RadioFrequency frequency, - const TCHAR *name, + const char *name, OperationEnvironment &env) noexcept { assert(InMainThread()); @@ -943,7 +943,7 @@ DeviceDescriptor::PutActiveFrequency(RadioFrequency frequency, bool DeviceDescriptor::PutStandbyFrequency(RadioFrequency frequency, - const TCHAR *name, + const char *name, OperationEnvironment &env) noexcept { assert(InMainThread()); @@ -1228,7 +1228,7 @@ DeviceDescriptor::OnCalculatedUpdate(const MoreData &basic, } inline void -DeviceDescriptor::LockSetErrorMessage(const TCHAR *msg) noexcept +DeviceDescriptor::LockSetErrorMessage(const char *msg) noexcept { const std::lock_guard lock{mutex}; error_message = msg; @@ -1266,7 +1266,7 @@ void DeviceDescriptor::PortError(const char *msg) noexcept { { - TCHAR buffer[64]; + char buffer[64]; LogFormat(_T("Error on device %s: %s"), config.GetPortName(buffer, 64), msg); } diff --git a/src/Device/Descriptor.hpp b/src/Device/Descriptor.hpp index a1c1f215386..a5620fd88f9 100644 --- a/src/Device/Descriptor.hpp +++ b/src/Device/Descriptor.hpp @@ -420,12 +420,12 @@ class DeviceDescriptor final */ bool EnableNMEA(OperationEnvironment &env) noexcept; - const TCHAR *GetDisplayName() const noexcept; + const char *GetDisplayName() const noexcept; /** * Compares the driver's name. */ - bool IsDriver(const TCHAR *name) const noexcept; + bool IsDriver(const char *name) const noexcept; [[gnu::pure]] bool CanDeclare() const noexcept; @@ -536,10 +536,10 @@ class DeviceDescriptor final bool PutVolume(unsigned volume, OperationEnvironment &env) noexcept; bool PutPilotEvent(OperationEnvironment &env) noexcept; bool PutActiveFrequency(RadioFrequency frequency, - const TCHAR *name, + const char *name, OperationEnvironment &env) noexcept; bool PutStandbyFrequency(RadioFrequency frequency, - const TCHAR *name, + const char *name, OperationEnvironment &env) noexcept; bool PutTransponderCode(TransponderCode code, OperationEnvironment &env) noexcept; bool PutQNH(AtmosphericPressure pres, @@ -577,7 +577,7 @@ class DeviceDescriptor final const DerivedInfo &calculated) noexcept; private: - void LockSetErrorMessage(const TCHAR *msg) noexcept; + void LockSetErrorMessage(const char *msg) noexcept; void OnJobFinished() noexcept; /* virtual methods from class PortListener */ diff --git a/src/Device/Driver.cpp b/src/Device/Driver.cpp index c4cfaa2fcf3..76399405b84 100644 --- a/src/Device/Driver.cpp +++ b/src/Device/Driver.cpp @@ -66,7 +66,7 @@ AbstractDevice::PutPilotEvent([[maybe_unused]] OperationEnvironment &env) bool AbstractDevice::PutActiveFrequency([[maybe_unused]] RadioFrequency frequency, - [[maybe_unused]] const TCHAR *name, + [[maybe_unused]] const char *name, [[maybe_unused]] OperationEnvironment &env) { return true; @@ -74,7 +74,7 @@ AbstractDevice::PutActiveFrequency([[maybe_unused]] RadioFrequency frequency, bool AbstractDevice::PutStandbyFrequency([[maybe_unused]] RadioFrequency frequency, - [[maybe_unused]] const TCHAR *name, + [[maybe_unused]] const char *name, [[maybe_unused]] OperationEnvironment &env) { return true; diff --git a/src/Device/Driver.hpp b/src/Device/Driver.hpp index f24fa17988b..6e925fab66a 100644 --- a/src/Device/Driver.hpp +++ b/src/Device/Driver.hpp @@ -115,7 +115,7 @@ class Device { * @return true on success */ virtual bool PutActiveFrequency(RadioFrequency frequency, - const TCHAR *name, + const char *name, OperationEnvironment &env) = 0; /** @@ -126,7 +126,7 @@ class Device { * @return true on success */ virtual bool PutStandbyFrequency(RadioFrequency frequency, - const TCHAR *name, + const char *name, OperationEnvironment &env) = 0; /** @@ -249,10 +249,10 @@ class AbstractDevice : public Device { bool PutVolume(unsigned volume, OperationEnvironment &env) override; bool PutPilotEvent(OperationEnvironment &env) override; bool PutActiveFrequency(RadioFrequency frequency, - const TCHAR *name, + const char *name, OperationEnvironment &env) override; bool PutStandbyFrequency(RadioFrequency frequency, - const TCHAR *name, + const char *name, OperationEnvironment &env) override; bool PutTransponderCode(TransponderCode code, OperationEnvironment &env) override; @@ -351,12 +351,12 @@ struct DeviceRegister { * The internal name of the driver, i.e. the one that is stored in * the profile. */ - const TCHAR *name; + const char *name; /** * The human-readable name of this driver. */ - const TCHAR *display_name; + const char *display_name; /** * A bit set describing the features of this driver. diff --git a/src/Device/Driver/AR62xx.cpp b/src/Device/Driver/AR62xx.cpp index 5c8c419809f..1e50177993c 100644 --- a/src/Device/Driver/AR62xx.cpp +++ b/src/Device/Driver/AR62xx.cpp @@ -152,7 +152,7 @@ class AR62xxDevice final : public AbstractDevice { */ int SetAR620xStation(uint8_t *command, int active_passive, - double f_frequency, const TCHAR* station) noexcept; + double f_frequency, const char* station) noexcept; /* * Parses the messages which XCSoar receives from the radio. @@ -191,14 +191,14 @@ class AR62xxDevice final : public AbstractDevice { * Sets the active frequency on the radio. */ virtual bool PutActiveFrequency(RadioFrequency frequency, - const TCHAR *name, + const char *name, OperationEnvironment &env) override; /** * Sets the standby frequency on the radio. */ virtual bool PutStandbyFrequency(RadioFrequency frequency, - const TCHAR *name, + const char *name, OperationEnvironment &env) override; /** @@ -431,7 +431,7 @@ int AR62xxDevice::SetAR620xStation(uint8_t *command, int active_passive, double f_frequency, - [[maybe_unused]] const TCHAR *station) noexcept + [[maybe_unused]] const char *station) noexcept { unsigned int len = 0; @@ -583,7 +583,7 @@ AR62xxDevice::AR620xConvertAnswer(uint8_t *sz_command, */ bool AR62xxDevice::PutActiveFrequency(RadioFrequency frequency, - const TCHAR* name, + const char* name, OperationEnvironment &env) { unsigned int ufreq = frequency.GetKiloHertz(); @@ -602,7 +602,7 @@ AR62xxDevice::PutActiveFrequency(RadioFrequency frequency, */ bool AR62xxDevice::PutStandbyFrequency(RadioFrequency frequency, - const TCHAR *name, + const char *name, OperationEnvironment &env) { unsigned int ufreq = frequency.GetKiloHertz(); diff --git a/src/Device/Driver/ATR833/Device.cpp b/src/Device/Driver/ATR833/Device.cpp index ca2194569cc..eb0aa24fad0 100644 --- a/src/Device/Driver/ATR833/Device.cpp +++ b/src/Device/Driver/ATR833/Device.cpp @@ -140,7 +140,7 @@ ATR833Device::HandleMessage(std::span src, bool ATR833Device::PutActiveFrequency(RadioFrequency frequency, - [[maybe_unused]] const TCHAR *name, + [[maybe_unused]] const char *name, OperationEnvironment &env) { ATRBuffer buffer(SETACTIVE); @@ -151,7 +151,7 @@ ATR833Device::PutActiveFrequency(RadioFrequency frequency, bool ATR833Device::PutStandbyFrequency(RadioFrequency frequency, - [[maybe_unused]] const TCHAR *name, + [[maybe_unused]] const char *name, OperationEnvironment &env) { ATRBuffer buffer(SETSTANDBY); diff --git a/src/Device/Driver/ATR833/Device.hpp b/src/Device/Driver/ATR833/Device.hpp index 87d2123409b..c8116315df5 100644 --- a/src/Device/Driver/ATR833/Device.hpp +++ b/src/Device/Driver/ATR833/Device.hpp @@ -22,10 +22,10 @@ class ATR833Device final : public AbstractDevice { bool DataReceived(std::span s, NMEAInfo &info) noexcept override; bool PutActiveFrequency(RadioFrequency frequency, - const TCHAR *name, + const char *name, OperationEnvironment &env) override; bool PutStandbyFrequency(RadioFrequency frequency, - const TCHAR *name, + const char *name, OperationEnvironment &env) override; bool EnableNMEA(OperationEnvironment &env) override; void OnSysTicker() override; diff --git a/src/Device/Driver/AirControlDisplay.cpp b/src/Device/Driver/AirControlDisplay.cpp index b6da6404f67..dac78143cc5 100644 --- a/src/Device/Driver/AirControlDisplay.cpp +++ b/src/Device/Driver/AirControlDisplay.cpp @@ -120,7 +120,7 @@ class ACDDevice : public AbstractDevice { OperationEnvironment &env) override; bool PutVolume(unsigned volume, OperationEnvironment &env) override; bool PutStandbyFrequency(RadioFrequency frequency, - const TCHAR *name, + const char *name, OperationEnvironment &env) override; bool PutTransponderCode(TransponderCode code, OperationEnvironment &env) override; void OnSensorUpdate(const MoreData &basic) override; @@ -148,7 +148,7 @@ ACDDevice::PutVolume(unsigned volume, OperationEnvironment &env) bool ACDDevice::PutStandbyFrequency(RadioFrequency frequency, - [[maybe_unused]] const TCHAR *name, + [[maybe_unused]] const char *name, OperationEnvironment &env) { char buffer[100]; diff --git a/src/Device/Driver/CAI302/Declare.cpp b/src/Device/Driver/CAI302/Declare.cpp index cc29c77b629..fe6fcf26188 100644 --- a/src/Device/Driver/CAI302/Declare.cpp +++ b/src/Device/Driver/CAI302/Declare.cpp @@ -10,7 +10,7 @@ #include static void -convert_string(char *dest, size_t size, const TCHAR *src) +convert_string(char *dest, size_t size, const char *src) { strncpy(dest, src, size - 1); dest[size - 1] = '\0'; diff --git a/src/Device/Driver/CAI302/Manage.cpp b/src/Device/Driver/CAI302/Manage.cpp index 71c7c23ecd9..a579efbbb3c 100644 --- a/src/Device/Driver/CAI302/Manage.cpp +++ b/src/Device/Driver/CAI302/Manage.cpp @@ -202,7 +202,7 @@ CAI302Device::ReadNavpoint(unsigned index, CAI302::Navpoint &navpoint, } static void -ToASCII(char *dest, size_t dest_size, const TCHAR *src) +ToASCII(char *dest, size_t dest_size, const char *src) { char *end = dest + dest_size - 1; while (*src != _T('\0') && dest < end) diff --git a/src/Device/Driver/EW.cpp b/src/Device/Driver/EW.cpp index cce5e33296d..1df43c0ab36 100644 --- a/src/Device/Driver/EW.cpp +++ b/src/Device/Driver/EW.cpp @@ -82,7 +82,7 @@ EWDevice::TryConnect(OperationEnvironment &env) } static void -convert_string(char *dest, size_t size, const TCHAR *src) +convert_string(char *dest, size_t size, const char *src) { strncpy(dest, src, size - 1); dest[size - 1] = '\0'; diff --git a/src/Device/Driver/EWMicroRecorder.cpp b/src/Device/Driver/EWMicroRecorder.cpp index 937302e6752..f04951070f7 100644 --- a/src/Device/Driver/EWMicroRecorder.cpp +++ b/src/Device/Driver/EWMicroRecorder.cpp @@ -179,7 +179,7 @@ CleanString(char *p) * Clean a string and write it to the Port. */ static void -WriteCleanString(Port &port, const TCHAR *p, +WriteCleanString(Port &port, const char *p, OperationEnvironment &env, std::chrono::steady_clock::duration timeout) { @@ -202,7 +202,7 @@ WriteLabel(Port &port, const char *name, OperationEnvironment &env) * Write a name/value pair to the EW microRecorder. */ static void -WritePair(Port &port, const char *name, const TCHAR *value, +WritePair(Port &port, const char *name, const char *value, OperationEnvironment &env) { WriteLabel(port, name, env); @@ -215,7 +215,7 @@ WriteGeoPoint(Port &port, const GeoPoint &value, OperationEnvironment &env) { int DegLat, DegLon; double tmp, MinLat, MinLon; - TCHAR NoS, EoW; + char NoS, EoW; // prepare latitude tmp = (double)value.latitude.Degrees(); diff --git a/src/Device/Driver/FLARM/Device.cpp b/src/Device/Driver/FLARM/Device.cpp index 86804e5e5f3..87794af87dd 100644 --- a/src/Device/Driver/FLARM/Device.cpp +++ b/src/Device/Driver/FLARM/Device.cpp @@ -94,80 +94,80 @@ FlarmDevice::SetBaudRate(unsigned baud_id, OperationEnvironment &env) } bool -FlarmDevice::GetPilot(TCHAR *buffer, size_t length, OperationEnvironment &env) +FlarmDevice::GetPilot(char *buffer, size_t length, OperationEnvironment &env) { return GetConfig("PILOT", buffer, length, env); } bool -FlarmDevice::SetPilot(const TCHAR *pilot_name, OperationEnvironment &env) +FlarmDevice::SetPilot(const char *pilot_name, OperationEnvironment &env) { return SetConfig("PILOT", pilot_name, env); } bool -FlarmDevice::GetCoPilot(TCHAR *buffer, size_t length, +FlarmDevice::GetCoPilot(char *buffer, size_t length, OperationEnvironment &env) { return GetConfig("COPIL", buffer, length, env); } bool -FlarmDevice::SetCoPilot(const TCHAR *copilot_name, OperationEnvironment &env) +FlarmDevice::SetCoPilot(const char *copilot_name, OperationEnvironment &env) { return SetConfig("COPIL", copilot_name, env); } bool -FlarmDevice::GetPlaneType(TCHAR *buffer, size_t length, +FlarmDevice::GetPlaneType(char *buffer, size_t length, OperationEnvironment &env) { return GetConfig("GLIDERTYPE", buffer, length, env); } bool -FlarmDevice::SetPlaneType(const TCHAR *plane_type, OperationEnvironment &env) +FlarmDevice::SetPlaneType(const char *plane_type, OperationEnvironment &env) { return SetConfig("GLIDERTYPE", plane_type, env); } bool -FlarmDevice::GetPlaneRegistration(TCHAR *buffer, size_t length, +FlarmDevice::GetPlaneRegistration(char *buffer, size_t length, OperationEnvironment &env) { return GetConfig("GLIDERID", buffer, length, env); } bool -FlarmDevice::SetPlaneRegistration(const TCHAR *registration, +FlarmDevice::SetPlaneRegistration(const char *registration, OperationEnvironment &env) { return SetConfig("GLIDERID", registration, env); } bool -FlarmDevice::GetCompetitionId(TCHAR *buffer, size_t length, +FlarmDevice::GetCompetitionId(char *buffer, size_t length, OperationEnvironment &env) { return GetConfig("COMPID", buffer, length, env); } bool -FlarmDevice::SetCompetitionId(const TCHAR *competition_id, +FlarmDevice::SetCompetitionId(const char *competition_id, OperationEnvironment &env) { return SetConfig("COMPID", competition_id, env); } bool -FlarmDevice::GetCompetitionClass(TCHAR *buffer, size_t length, +FlarmDevice::GetCompetitionClass(char *buffer, size_t length, OperationEnvironment &env) { return GetConfig("COMPCLASS", buffer, length, env); } bool -FlarmDevice::SetCompetitionClass(const TCHAR *competition_class, +FlarmDevice::SetCompetitionClass(const char *competition_class, OperationEnvironment &env) { return SetConfig("COMPCLASS", competition_class, env); diff --git a/src/Device/Driver/FLARM/Device.hpp b/src/Device/Driver/FLARM/Device.hpp index c7d71e7e322..71dd9207d2d 100644 --- a/src/Device/Driver/FLARM/Device.hpp +++ b/src/Device/Driver/FLARM/Device.hpp @@ -83,23 +83,23 @@ class FlarmDevice: public AbstractDevice OperationEnvironment &env) override; bool PutPilotEvent(OperationEnvironment &env) override; - bool GetPilot(TCHAR *buffer, size_t length, OperationEnvironment &env); - bool SetPilot(const TCHAR *pilot_name, OperationEnvironment &env); - bool GetCoPilot(TCHAR *buffer, size_t length, OperationEnvironment &env); - bool SetCoPilot(const TCHAR *copilot_name, OperationEnvironment &env); - bool GetPlaneType(TCHAR *buffer, size_t length, OperationEnvironment &env); - bool SetPlaneType(const TCHAR *plane_type, OperationEnvironment &env); - bool GetPlaneRegistration(TCHAR *buffer, size_t length, + bool GetPilot(char *buffer, size_t length, OperationEnvironment &env); + bool SetPilot(const char *pilot_name, OperationEnvironment &env); + bool GetCoPilot(char *buffer, size_t length, OperationEnvironment &env); + bool SetCoPilot(const char *copilot_name, OperationEnvironment &env); + bool GetPlaneType(char *buffer, size_t length, OperationEnvironment &env); + bool SetPlaneType(const char *plane_type, OperationEnvironment &env); + bool GetPlaneRegistration(char *buffer, size_t length, OperationEnvironment &env); - bool SetPlaneRegistration(const TCHAR *registration, + bool SetPlaneRegistration(const char *registration, OperationEnvironment &env); - bool GetCompetitionId(TCHAR *buffer, size_t length, + bool GetCompetitionId(char *buffer, size_t length, OperationEnvironment &env); - bool SetCompetitionId(const TCHAR *competition_id, + bool SetCompetitionId(const char *competition_id, OperationEnvironment &env); - bool GetCompetitionClass(TCHAR *buffer, size_t length, + bool GetCompetitionClass(char *buffer, size_t length, OperationEnvironment &env); - bool SetCompetitionClass(const TCHAR *competition_class, + bool SetCompetitionClass(const char *competition_class, OperationEnvironment &env); bool GetStealthMode(bool &enabled, OperationEnvironment &env); diff --git a/src/Device/Driver/IMI/Protocol/Conversion.cpp b/src/Device/Driver/IMI/Protocol/Conversion.cpp index d19dada56a9..ae6b845c716 100644 --- a/src/Device/Driver/IMI/Protocol/Conversion.cpp +++ b/src/Device/Driver/IMI/Protocol/Conversion.cpp @@ -12,7 +12,7 @@ static constexpr unsigned IMI_SECONDS_IN_HOUR = 60*60; static constexpr unsigned IMI_SECONDS_IN_DAY = 24*60*60; void -IMI::ConvertToChar(const TCHAR* dest, char* ascii, int outSize) +IMI::ConvertToChar(const char* dest, char* ascii, int outSize) { // this is only a copy (n) function) strncpy(ascii, dest, outSize - 1); diff --git a/src/Device/Driver/IMI/Protocol/Conversion.hpp b/src/Device/Driver/IMI/Protocol/Conversion.hpp index 147254d5686..6276a73eebe 100644 --- a/src/Device/Driver/IMI/Protocol/Conversion.hpp +++ b/src/Device/Driver/IMI/Protocol/Conversion.hpp @@ -31,7 +31,7 @@ struct AngleConverter { }; void -ConvertToChar(const TCHAR* dest, char* ascii, int outSize); +ConvertToChar(const char* dest, char* ascii, int outSize); BrokenDateTime ConvertToDateTime(IMIDATETIMESEC in); diff --git a/src/Device/Driver/KRT2.cpp b/src/Device/Driver/KRT2.cpp index 5bc161b7d4d..ee1b2723b17 100644 --- a/src/Device/Driver/KRT2.cpp +++ b/src/Device/Driver/KRT2.cpp @@ -102,7 +102,7 @@ class KRT2Device final : public AbstractDevice { * @param name Name of the radio station. * @return Name of the radio station (printable ASCII, MAX_NAME_LENGTH characters). */ - static void GetStationName(char *station_name, const TCHAR *name); + static void GetStationName(char *station_name, const char *name); /** * Sends the frequency to the radio. * @@ -116,7 +116,7 @@ class KRT2Device final : public AbstractDevice { */ bool PutFrequency(std::byte cmd, RadioFrequency frequency, - const TCHAR *name, + const char *name, OperationEnvironment &env); void LockSetResponse(std::byte _response) noexcept { @@ -156,13 +156,13 @@ class KRT2Device final : public AbstractDevice { * Sets the active frequency on the radio. */ virtual bool PutActiveFrequency(RadioFrequency frequency, - const TCHAR *name, + const char *name, OperationEnvironment &env) override; /** * Sets the standby frequency on the radio. */ virtual bool PutStandbyFrequency(RadioFrequency frequency, - const TCHAR *name, + const char *name, OperationEnvironment &env) override; /** * Receives and handles data from the radio. @@ -251,14 +251,14 @@ KRT2Device::DataReceived(std::span s, } inline void -KRT2Device::GetStationName(char *station_name, const TCHAR *name) +KRT2Device::GetStationName(char *station_name, const char *name) { if(name == nullptr) name = _T(""); size_t s_idx = 0; //!< Source name index size_t d_idx = 0; //!< Destination name index - TCHAR c; //!< Character at source name index + char c; //!< Character at source name index while ((c = name[s_idx++])) { // KRT2 supports printable ASCII only @@ -376,7 +376,7 @@ KRT2Device::HandleMessage(std::span src, bool KRT2Device::PutFrequency(std::byte cmd, RadioFrequency frequency, - const TCHAR *name, + const char *name, OperationEnvironment &env) { stx_msg msg; @@ -392,7 +392,7 @@ KRT2Device::PutFrequency(std::byte cmd, bool KRT2Device::PutActiveFrequency(RadioFrequency frequency, - const TCHAR *name, + const char *name, OperationEnvironment &env) { return PutFrequency(ACTIVE_FREQUENCY, frequency, name, env); @@ -400,7 +400,7 @@ KRT2Device::PutActiveFrequency(RadioFrequency frequency, bool KRT2Device::PutStandbyFrequency(RadioFrequency frequency, - const TCHAR *name, + const char *name, OperationEnvironment &env) { return PutFrequency(STANDBY_FREQUENCY, frequency, name, env); diff --git a/src/Device/Driver/LX/Declare.cpp b/src/Device/Driver/LX/Declare.cpp index 8b0fbd3ee73..904d1e7d120 100644 --- a/src/Device/Driver/LX/Declare.cpp +++ b/src/Device/Driver/LX/Declare.cpp @@ -16,7 +16,7 @@ * len characters with last char = '\0' */ static void -copy_space_padded(char dest[], const TCHAR src[], unsigned int len) +copy_space_padded(char dest[], const char src[], unsigned int len) { const unsigned slen = strlen(src); for(unsigned i = 0; i < (len - 1); i++) { diff --git a/src/Device/Driver/LX/NanoDeclare.cpp b/src/Device/Driver/LX/NanoDeclare.cpp index 42eb7af79a7..dadde8fc941 100644 --- a/src/Device/Driver/LX/NanoDeclare.cpp +++ b/src/Device/Driver/LX/NanoDeclare.cpp @@ -45,7 +45,7 @@ static bool NanoWriteDeclString(Port &port, OperationEnvironment &env, PortNMEAReader &reader, unsigned row, unsigned n_rows, - const char *prefix, const TCHAR *value) + const char *prefix, const char *value) { WideToUTF8Converter narrow_value(value); if (!narrow_value.IsValid()) diff --git a/src/Device/Driver/Volkslogger/Declare.cpp b/src/Device/Driver/Volkslogger/Declare.cpp index 978dd9c87a0..df3ad51c30a 100644 --- a/src/Device/Driver/Volkslogger/Declare.cpp +++ b/src/Device/Driver/Volkslogger/Declare.cpp @@ -12,7 +12,7 @@ #include static void -CopyToNarrowBuffer(char *dest, size_t max_size, const TCHAR *src) +CopyToNarrowBuffer(char *dest, size_t max_size, const char *src) { strncpy(dest, src, max_size - 1); dest[max_size - 1] = 0; diff --git a/src/Device/Driver/XCOM760.cpp b/src/Device/Driver/XCOM760.cpp index 62415b6edf3..ac8f92b596d 100644 --- a/src/Device/Driver/XCOM760.cpp +++ b/src/Device/Driver/XCOM760.cpp @@ -18,10 +18,10 @@ class XCOM760Device : public AbstractDevice { /* virtual methods from class Device */ bool PutVolume(unsigned volume, OperationEnvironment &env) override; bool PutActiveFrequency(RadioFrequency frequency, - const TCHAR *name, + const char *name, OperationEnvironment &env) override; bool PutStandbyFrequency(RadioFrequency frequency, - const TCHAR *name, + const char *name, OperationEnvironment &env) override; }; @@ -36,7 +36,7 @@ XCOM760Device::PutVolume(unsigned volume, OperationEnvironment &env) bool XCOM760Device::PutActiveFrequency(RadioFrequency frequency, - [[maybe_unused]] const TCHAR *name, + [[maybe_unused]] const char *name, OperationEnvironment &env) { char szTmp[32]; @@ -49,7 +49,7 @@ XCOM760Device::PutActiveFrequency(RadioFrequency frequency, bool XCOM760Device::PutStandbyFrequency(RadioFrequency frequency, - [[maybe_unused]] const TCHAR *name, + [[maybe_unused]] const char *name, OperationEnvironment &env) { char szTmp[32]; diff --git a/src/Device/MultipleDevices.cpp b/src/Device/MultipleDevices.cpp index 8eab36e48bd..d2b4fd91cb8 100644 --- a/src/Device/MultipleDevices.cpp +++ b/src/Device/MultipleDevices.cpp @@ -67,7 +67,7 @@ MultipleDevices::HasVega() const noexcept } void -MultipleDevices::VegaWriteNMEA(const TCHAR *text, +MultipleDevices::VegaWriteNMEA(const char *text, OperationEnvironment &env) noexcept { for (DeviceDescriptor *i : devices) @@ -114,7 +114,7 @@ MultipleDevices::PutPilotEvent(OperationEnvironment &env) noexcept void MultipleDevices::PutActiveFrequency(RadioFrequency frequency, - const TCHAR *name, + const char *name, OperationEnvironment &env) noexcept { for (DeviceDescriptor *i : devices) @@ -123,7 +123,7 @@ MultipleDevices::PutActiveFrequency(RadioFrequency frequency, void MultipleDevices::PutStandbyFrequency(RadioFrequency frequency, - const TCHAR *name, + const char *name, OperationEnvironment &env) noexcept { for (DeviceDescriptor *i : devices) diff --git a/src/Device/MultipleDevices.hpp b/src/Device/MultipleDevices.hpp index fd627f4a464..f7a4c73a453 100644 --- a/src/Device/MultipleDevices.hpp +++ b/src/Device/MultipleDevices.hpp @@ -70,7 +70,7 @@ class MultipleDevices final : PortListener { [[gnu::pure]] bool HasVega() const noexcept; - void VegaWriteNMEA(const TCHAR *text, OperationEnvironment &env) noexcept; + void VegaWriteNMEA(const char *text, OperationEnvironment &env) noexcept; void PutMacCready(double mac_cready, OperationEnvironment &env) noexcept; void PutBugs(double bugs, OperationEnvironment &env) noexcept; @@ -78,9 +78,9 @@ class MultipleDevices final : PortListener { OperationEnvironment &env) noexcept; void PutVolume(unsigned volume, OperationEnvironment &env) noexcept; void PutPilotEvent(OperationEnvironment &env) noexcept; - void PutActiveFrequency(RadioFrequency frequency, const TCHAR *name, + void PutActiveFrequency(RadioFrequency frequency, const char *name, OperationEnvironment &env) noexcept; - void PutStandbyFrequency(RadioFrequency frequency, const TCHAR *name, + void PutStandbyFrequency(RadioFrequency frequency, const char *name, OperationEnvironment &env) noexcept; void PutTransponderCode(TransponderCode code, OperationEnvironment &env) noexcept; void PutQNH(AtmosphericPressure pres, OperationEnvironment &env) noexcept; diff --git a/src/Device/Port/AndroidBluetoothPort.cpp b/src/Device/Port/AndroidBluetoothPort.cpp index 57c179a8392..87ff5ebb357 100644 --- a/src/Device/Port/AndroidBluetoothPort.cpp +++ b/src/Device/Port/AndroidBluetoothPort.cpp @@ -10,7 +10,7 @@ std::unique_ptr OpenAndroidBluetoothPort(BluetoothHelper &bluetooth_helper, - const TCHAR *address, PortListener *listener, + const char *address, PortListener *listener, DataHandler &handler) { assert(address != nullptr); @@ -31,7 +31,7 @@ OpenAndroidBluetoothServerPort(BluetoothHelper &bluetooth_helper, std::unique_ptr OpenAndroidBleHm10Port(BluetoothHelper &bluetooth_helper, - const TCHAR *address, PortListener *listener, + const char *address, PortListener *listener, DataHandler &handler) { assert(address != nullptr); diff --git a/src/Device/Port/AndroidBluetoothPort.hpp b/src/Device/Port/AndroidBluetoothPort.hpp index 43092828722..59ff9124773 100644 --- a/src/Device/Port/AndroidBluetoothPort.hpp +++ b/src/Device/Port/AndroidBluetoothPort.hpp @@ -15,7 +15,7 @@ class DataHandler; std::unique_ptr OpenAndroidBluetoothPort(BluetoothHelper &bluetooth_helper, - const TCHAR *address, PortListener *_listener, + const char *address, PortListener *_listener, DataHandler &_handler); std::unique_ptr @@ -24,5 +24,5 @@ OpenAndroidBluetoothServerPort(BluetoothHelper &bluetooth_helper, std::unique_ptr OpenAndroidBleHm10Port(BluetoothHelper &bluetooth_helper, - const TCHAR *address, PortListener *_listener, + const char *address, PortListener *_listener, DataHandler &_handler); diff --git a/src/Device/Port/AndroidIOIOUartPort.hpp b/src/Device/Port/AndroidIOIOUartPort.hpp index c3d9ac6626a..8137d092d0c 100644 --- a/src/Device/Port/AndroidIOIOUartPort.hpp +++ b/src/Device/Port/AndroidIOIOUartPort.hpp @@ -17,7 +17,7 @@ namespace AndroidIOIOUartPort { static inline unsigned getNumberUarts() { return 4; } - static inline const TCHAR *getPortHelp(unsigned UartID) { + static inline const char *getPortHelp(unsigned UartID) { switch (UartID) { case 0: return _T("IOIO external board Uart: pin3=out, pin4=in"); diff --git a/src/Device/Port/ConfiguredPort.cpp b/src/Device/Port/ConfiguredPort.cpp index 83f56caae48..01b189a26d0 100644 --- a/src/Device/Port/ConfiguredPort.cpp +++ b/src/Device/Port/ConfiguredPort.cpp @@ -42,7 +42,7 @@ * See http://msdn.microsoft.com/en-us/library/bb202042.aspx */ static bool -DetectGPS([[maybe_unused]] TCHAR *path, [[maybe_unused]] std::size_t path_max_size) +DetectGPS([[maybe_unused]] char *path, [[maybe_unused]] std::size_t path_max_size) { return false; } @@ -64,8 +64,8 @@ WrapPort(const DeviceConfig &config, PortListener *listener, } #if defined(_WIN32) -static const TCHAR * -WindowsPort(TCHAR buffer[], const DeviceConfig &config) { +static const char * +WindowsPort(char buffer[], const DeviceConfig &config) { if (config.path.empty()) throw std::runtime_error("No port path configured"); @@ -85,8 +85,8 @@ OpenPortInternal(EventLoop &event_loop, Cares::Channel &cares, const DeviceConfig &config, PortListener *listener, DataHandler &handler) { - const TCHAR *path = nullptr; - TCHAR buffer[MAX_PATH]; + const char *path = nullptr; + char buffer[MAX_PATH]; switch (config.port_type) { case DeviceConfig::PortType::DISABLED: diff --git a/src/Device/Port/SerialPort.cpp b/src/Device/Port/SerialPort.cpp index 8ec09e9156b..0874833b9a5 100644 --- a/src/Device/Port/SerialPort.cpp +++ b/src/Device/Port/SerialPort.cpp @@ -34,7 +34,7 @@ SerialPort::~SerialPort() noexcept } void -SerialPort::Open(const TCHAR *path, unsigned _baud_rate) +SerialPort::Open(const char *path, unsigned _baud_rate) { assert(!Thread::IsInside()); diff --git a/src/Device/Port/SerialPort.hpp b/src/Device/Port/SerialPort.hpp index c4ba3a54ab9..64f6391e8b8 100644 --- a/src/Device/Port/SerialPort.hpp +++ b/src/Device/Port/SerialPort.hpp @@ -38,7 +38,7 @@ class SerialPort : public BufferedPort, protected StoppableThread * * Throws on error. */ - void Open(const TCHAR *path, unsigned baud_rate); + void Open(const char *path, unsigned baud_rate); protected: bool SetRxTimeout(unsigned Timeout); diff --git a/src/Device/Port/TTYPort.cpp b/src/Device/Port/TTYPort.cpp index 1e34690ba79..13c1f740945 100644 --- a/src/Device/Port/TTYPort.cpp +++ b/src/Device/Port/TTYPort.cpp @@ -164,7 +164,7 @@ TTYPort::Drain() } void -TTYPort::Open(const TCHAR *path, unsigned baud_rate) +TTYPort::Open(const char *path, unsigned baud_rate) { auto fd = OpenTTY(path, baud_rate); ::SetBaudrate(TTYDescriptor(fd), baud_rate); diff --git a/src/Device/Port/TTYPort.hpp b/src/Device/Port/TTYPort.hpp index 18267304d52..6b6488bd041 100644 --- a/src/Device/Port/TTYPort.hpp +++ b/src/Device/Port/TTYPort.hpp @@ -38,7 +38,7 @@ class TTYPort : public BufferedPort * * Throws on error. */ - void Open(const TCHAR *path, unsigned baud_rate); + void Open(const char *path, unsigned baud_rate); /** * Opens this object with a new pseudo-terminal. This is only used diff --git a/src/Device/Register.cpp b/src/Device/Register.cpp index 9d943b5b423..bdbefdfe340 100644 --- a/src/Device/Register.cpp +++ b/src/Device/Register.cpp @@ -103,7 +103,7 @@ GetDriverByIndex(unsigned i) } const struct DeviceRegister * -FindDriverByName(const TCHAR *name) +FindDriverByName(const char *name) { for (auto i = driver_list; *i != nullptr; ++i) { const DeviceRegister &driver = **i; @@ -114,8 +114,8 @@ FindDriverByName(const TCHAR *name) return driver_list[0]; } -const TCHAR * -FindDriverDisplayName(const TCHAR *name) +const char * +FindDriverDisplayName(const char *name) { assert(name != nullptr); diff --git a/src/Device/Register.hpp b/src/Device/Register.hpp index 904d04b7bfd..4482b1c992a 100644 --- a/src/Device/Register.hpp +++ b/src/Device/Register.hpp @@ -18,12 +18,12 @@ GetDriverByIndex(unsigned i); [[gnu::pure]] const DeviceRegister * -FindDriverByName(const TCHAR *name); +FindDriverByName(const char *name); /** * Find the driver with the specified name, and return its display * name. If no such driver was found, the specified name is returned. */ [[gnu::pure]] -const TCHAR * -FindDriverDisplayName(const TCHAR *name); +const char * +FindDriverDisplayName(const char *name); diff --git a/src/Dialogs/Airspace/AirspaceList.cpp b/src/Dialogs/Airspace/AirspaceList.cpp index a57f35d32cc..fccc68a26f6 100644 --- a/src/Dialogs/Airspace/AirspaceList.cpp +++ b/src/Dialogs/Airspace/AirspaceList.cpp @@ -206,7 +206,7 @@ AirspaceListWidget::UpdateList() if (dialog_state.type != WILDCARD) data.cls = (AirspaceClass)dialog_state.type; - const TCHAR *name_filter = filter_widget.GetValueString(NAME); + const char *name_filter = filter_widget.GetValueString(NAME); if (!StringIsEmpty(name_filter)) data.name_prefix = name_filter; @@ -297,10 +297,10 @@ AirspaceListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, } [[gnu::pure]] -static const TCHAR * -GetHeadingString(TCHAR *buffer) +static const char * +GetHeadingString(char *buffer) { - TCHAR heading[32]; + char heading[32]; FormatBearing(heading, ARRAY_SIZE(heading), CommonInterface::Basic().attitude.heading); @@ -330,7 +330,7 @@ AirspaceFilterWidget::Update() DataFieldEnum &direction_df = *(DataFieldEnum *) direction_control.GetDataField(); - TCHAR buffer[64]; + char buffer[64]; direction_df.replaceEnumText(0, GetHeadingString(buffer)); direction_control.RefreshDisplay(); } @@ -344,8 +344,8 @@ FillDistanceEnum(DataFieldEnum &df) 25, 50, 75, 100, 150, 250, 500, 1000 }; - TCHAR buffer[64]; - const TCHAR *unit = Units::GetDistanceName(); + char buffer[64]; + const char *unit = Units::GetDistanceName(); for (unsigned i = 0; i < ARRAY_SIZE(distances); ++i) { StringFormatUnsafe(buffer, _T("%u %s"), distances[i], unit); df.AddChoice(distances[i], buffer); @@ -357,7 +357,7 @@ FillDistanceEnum(DataFieldEnum &df) static void FillDirectionEnum(DataFieldEnum &df) { - TCHAR buffer[64]; + char buffer[64]; df.AddChoice(WILDCARD, _T("*")); df.AddChoice(0, GetHeadingString(buffer)); diff --git a/src/Dialogs/Airspace/dlgAirspace.cpp b/src/Dialogs/Airspace/dlgAirspace.cpp index cc6ea4be7df..14d52da0be8 100644 --- a/src/Dialogs/Airspace/dlgAirspace.cpp +++ b/src/Dialogs/Airspace/dlgAirspace.cpp @@ -70,7 +70,7 @@ AirspaceSettingsListWidget::OnPaintItem(Canvas &canvas, PixelRect rc, CommonInterface::GetMapSettings().airspace; const AirspaceLook &look = CommonInterface::main_window->GetLook().map.airspace; - const TCHAR *const name = AirspaceFormatter::GetClass((AirspaceClass)i); + const char *const name = AirspaceFormatter::GetClass((AirspaceClass)i); if (color_mode) { int second_x = row_renderer.NextColumn(canvas, rc, name); diff --git a/src/Dialogs/Airspace/dlgAirspaceWarnings.cpp b/src/Dialogs/Airspace/dlgAirspaceWarnings.cpp index 401fd94c49c..90ff357a83f 100644 --- a/src/Dialogs/Airspace/dlgAirspaceWarnings.cpp +++ b/src/Dialogs/Airspace/dlgAirspaceWarnings.cpp @@ -269,7 +269,7 @@ AirspaceWarningListWidget::OnPaintItem(Canvas &canvas, const PixelRect paint_rc, unsigned i) noexcept { - TCHAR buffer[128]; + char buffer[128]; // This constant defines the margin that should be respected // for renderring within the paint_rc area. @@ -343,7 +343,7 @@ AirspaceWarningListWidget::OnPaintItem(Canvas &canvas, /* draw the warning state indicator */ Color state_color; - const TCHAR *state_text; + const char *state_text; if (warning.IsInside()) { state_color = warning.IsActive() ? inside_color : inside_ack_color; diff --git a/src/Dialogs/CoDialog.cpp b/src/Dialogs/CoDialog.cpp index aa3f9a5a687..8966a0373a6 100644 --- a/src/Dialogs/CoDialog.cpp +++ b/src/Dialogs/CoDialog.cpp @@ -28,7 +28,7 @@ class CoDialog { public: CoDialog(UI::SingleWindow &parent, const DialogLook &dialog_look, - const TCHAR *caption, + const char *caption, PluggableOperationEnvironment *_env) noexcept :dialog(parent, dialog_look, caption), inject_task(asio_thread->GetEventLoop()) @@ -69,7 +69,7 @@ class CoDialog { bool ShowCoDialog(UI::SingleWindow &parent, const DialogLook &dialog_look, - const TCHAR *caption, Co::InvokeTask task, + const char *caption, Co::InvokeTask task, PluggableOperationEnvironment *env) { CoDialog dialog{parent, dialog_look, caption, env}; diff --git a/src/Dialogs/CoDialog.hpp b/src/Dialogs/CoDialog.hpp index 1616083ffae..6bc8a8d8320 100644 --- a/src/Dialogs/CoDialog.hpp +++ b/src/Dialogs/CoDialog.hpp @@ -21,5 +21,5 @@ namespace Co { class InvokeTask; } */ bool ShowCoDialog(UI::SingleWindow &parent, const DialogLook &dialog_look, - const TCHAR *caption, Co::InvokeTask task, + const char *caption, Co::InvokeTask task, PluggableOperationEnvironment *env); diff --git a/src/Dialogs/CoFunctionDialog.hpp b/src/Dialogs/CoFunctionDialog.hpp index e9a34be3eb5..276804f4cbe 100644 --- a/src/Dialogs/CoFunctionDialog.hpp +++ b/src/Dialogs/CoFunctionDialog.hpp @@ -17,7 +17,7 @@ template [[nodiscard]] std::optional ShowCoFunctionDialog(UI::SingleWindow &parent, const DialogLook &dialog_look, - const TCHAR *caption, Co::Task &&task, + const char *caption, Co::Task &&task, PluggableOperationEnvironment *env) { ReturnValue value; diff --git a/src/Dialogs/ComboPicker.cpp b/src/Dialogs/ComboPicker.cpp index 4d10d101f2c..98164e0fecd 100644 --- a/src/Dialogs/ComboPicker.cpp +++ b/src/Dialogs/ComboPicker.cpp @@ -31,18 +31,18 @@ class ComboPickerSupport : public ListItemRenderer { } }; -static const TCHAR* +static const char* OnItemHelp(unsigned i) { return (*ComboListPopup)[i].help_text.c_str(); } int -ComboPicker(const TCHAR *caption, +ComboPicker(const char *caption, const ComboList &combo_list, - const TCHAR *help_text, + const char *help_text, bool enable_item_help, - const TCHAR *extra_caption) + const char *extra_caption) { ComboListPopup = &combo_list; @@ -58,11 +58,11 @@ ComboPicker(const TCHAR *caption, } bool -ComboPicker(const TCHAR *caption, DataField &df, - const TCHAR *help_text) +ComboPicker(const char *caption, DataField &df, + const char *help_text) { StaticString<256> buffer; - const TCHAR *reference = nullptr; + const char *reference = nullptr; while (true) { const ComboList combo_list = df.CreateComboList(reference); diff --git a/src/Dialogs/ComboPicker.hpp b/src/Dialogs/ComboPicker.hpp index fc6476f03a9..2f4ae895a2c 100644 --- a/src/Dialogs/ComboPicker.hpp +++ b/src/Dialogs/ComboPicker.hpp @@ -9,16 +9,16 @@ class ComboList; class DataField; int -ComboPicker(const TCHAR *caption, +ComboPicker(const char *caption, const ComboList &combo_list, - const TCHAR *help_text = nullptr, + const char *help_text = nullptr, bool enable_item_help = false, - const TCHAR *extra_caption=nullptr); + const char *extra_caption=nullptr); /** * @return true if the user has selected a new value (though it may be * equal to the old one) */ bool -ComboPicker(const TCHAR *caption, DataField &df, - const TCHAR *help_text = nullptr); +ComboPicker(const char *caption, DataField &df, + const char *help_text = nullptr); diff --git a/src/Dialogs/DataField.cpp b/src/Dialogs/DataField.cpp index 7e475c573b6..f5b40646193 100644 --- a/src/Dialogs/DataField.cpp +++ b/src/Dialogs/DataField.cpp @@ -24,8 +24,8 @@ #include bool -EditDataFieldDialog(const TCHAR *caption, DataField &df, - const TCHAR *help_text) +EditDataFieldDialog(const char *caption, DataField &df, + const char *help_text) { const auto type = df.GetType(); if (type == DataField::Type::FILE) { @@ -85,7 +85,7 @@ EditDataFieldDialog(const TCHAR *caption, DataField &df, type == DataField::Type::PREFIX) { auto &sdf = static_cast(df); - const TCHAR *value = sdf.GetValue(); + const char *value = sdf.GetValue(); assert(value != nullptr); StaticString buffer(value); diff --git a/src/Dialogs/DataField.hpp b/src/Dialogs/DataField.hpp index e9c9ecc42f8..da666c45029 100644 --- a/src/Dialogs/DataField.hpp +++ b/src/Dialogs/DataField.hpp @@ -13,5 +13,5 @@ class DataField; * @return true if the value has been modified */ bool -EditDataFieldDialog(const TCHAR *caption, DataField &df, - const TCHAR *help_text); +EditDataFieldDialog(const char *caption, DataField &df, + const char *help_text); diff --git a/src/Dialogs/DateEntry.cpp b/src/Dialogs/DateEntry.cpp index e84452b50cf..dd1742a6cb5 100644 --- a/src/Dialogs/DateEntry.cpp +++ b/src/Dialogs/DateEntry.cpp @@ -10,7 +10,7 @@ #include "UIGlobals.hpp" bool -DateEntryDialog(const TCHAR *caption, BrokenDate &value, +DateEntryDialog(const char *caption, BrokenDate &value, bool nullable) { // create the dialog diff --git a/src/Dialogs/DateEntry.hpp b/src/Dialogs/DateEntry.hpp index 34678140de9..def9730b97b 100644 --- a/src/Dialogs/DateEntry.hpp +++ b/src/Dialogs/DateEntry.hpp @@ -8,5 +8,5 @@ struct BrokenDate; bool -DateEntryDialog(const TCHAR *caption, BrokenDate &value, +DateEntryDialog(const char *caption, BrokenDate &value, bool nullable=false); diff --git a/src/Dialogs/Device/DeviceEditWidget.cpp b/src/Dialogs/Device/DeviceEditWidget.cpp index 31a84550eb2..142e6e50a9c 100644 --- a/src/Dialogs/Device/DeviceEditWidget.cpp +++ b/src/Dialogs/Device/DeviceEditWidget.cpp @@ -95,8 +95,8 @@ FillEngineType(DataFieldEnum &dfe) noexcept } static bool -EditPortCallback(const TCHAR *caption, DataField &df, - [[maybe_unused]] const TCHAR *help_text) noexcept +EditPortCallback(const char *caption, DataField &df, + [[maybe_unused]] const char *help_text) noexcept { return PortPicker((DataFieldEnum &)df, caption); } @@ -140,7 +140,7 @@ DeviceEditWidget::SetConfig(const DeviceConfig &_config) noexcept static bool SupportsBulkBaudRate(const DataField &df) noexcept { - const TCHAR *driver_name = df.GetAsString(); + const char *driver_name = df.GetAsString(); if (driver_name == nullptr) return false; @@ -155,7 +155,7 @@ SupportsBulkBaudRate(const DataField &df) noexcept static bool CanReceiveSettings(const DataField &df) noexcept { - const TCHAR *driver_name = df.GetAsString(); + const char *driver_name = df.GetAsString(); if (driver_name == nullptr) return false; @@ -170,7 +170,7 @@ CanReceiveSettings(const DataField &df) noexcept static bool CanSendSettings(const DataField &df) noexcept { - const TCHAR *driver_name = df.GetAsString(); + const char *driver_name = df.GetAsString(); if (driver_name == nullptr) return false; @@ -185,7 +185,7 @@ CanSendSettings(const DataField &df) noexcept static bool CanPassThrough(const DataField &df) noexcept { - const TCHAR *driver_name = df.GetAsString(); + const char *driver_name = df.GetAsString(); if (driver_name == nullptr) return false; diff --git a/src/Dialogs/Device/DeviceListDialog.cpp b/src/Dialogs/Device/DeviceListDialog.cpp index f494e136e67..f8d19c506db 100644 --- a/src/Dialogs/Device/DeviceListDialog.cpp +++ b/src/Dialogs/Device/DeviceListDialog.cpp @@ -369,15 +369,15 @@ DeviceListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, const unsigned margin = Layout::GetTextPadding(); - TCHAR port_name_buffer[128]; - const TCHAR *port_name = + char port_name_buffer[128]; + const char *port_name = config.GetPortName(port_name_buffer, ARRAY_SIZE(port_name_buffer)); StaticString<256> text(_T("A: ")); text[0u] += idx; if (config.UsesDriver()) { - const TCHAR *driver_name = FindDriverDisplayName(config.driver_name); + const char *driver_name = FindDriverDisplayName(config.driver_name); text.AppendFormat(_("%s on %s"), driver_name, port_name); } else { @@ -390,7 +390,7 @@ DeviceListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, /* show a list of features that are available in the second row */ StaticString<256> buffer; - const TCHAR *status; + const char *status; if (flags.alive) { if (flags.location) { buffer = _("GPS fix"); diff --git a/src/Dialogs/Device/PortDataField.cpp b/src/Dialogs/Device/PortDataField.cpp index 2e406fbd611..57231e4407f 100644 --- a/src/Dialogs/Device/PortDataField.cpp +++ b/src/Dialogs/Device/PortDataField.cpp @@ -30,7 +30,7 @@ static constexpr struct { DeviceConfig::PortType type; - const TCHAR *label; + const char *label; } port_types[] = { { DeviceConfig::PortType::DISABLED, N_("Disabled") }, #ifdef HAVE_INTERNAL_GPS @@ -62,8 +62,8 @@ static constexpr unsigned num_port_types = std::size(port_types) - 1; static unsigned AddPort(DataFieldEnum &df, DeviceConfig::PortType type, - const TCHAR *text, const TCHAR *display_string=nullptr, - const TCHAR *help=nullptr) noexcept + const char *text, const char *display_string=nullptr, + const char *help=nullptr) noexcept { /* the upper 16 bit is the port type, and the lower 16 bit is a serial number to make the enum id unique */ @@ -111,9 +111,9 @@ try { "Enum\\BthEnum")}; std::map bthmap; for (unsigned k = 0;; ++k) { - TCHAR dev_name[128]; - TCHAR name[128]; - TCHAR friendly_name[128]; + char dev_name[128]; + char name[128]; + char friendly_name[128]; if (!bthenums.EnumKey(k, std::span{dev_name})) break; @@ -137,9 +137,9 @@ try { "Enum\\BthLE")}; std::map blemap; for (unsigned k = 0;; ++k) { - TCHAR dev_name[128]; - TCHAR name[128]; - TCHAR friendly_name[128]; + char dev_name[128]; + char name[128]; + char friendly_name[128]; if (!bthle.EnumKey(k, std::span{dev_name})) break; @@ -165,8 +165,8 @@ try { RegistryKey serialcomm{HKEY_LOCAL_MACHINE, _T("Hardware\\DeviceMap\\SerialComm")}; for (unsigned i = 0;; ++i) { - TCHAR name[128]; - TCHAR value[64]; + char name[128]; + char value[64]; DWORD type; if (!serialcomm.EnumValue(i, std::span{name}, &type, @@ -179,7 +179,7 @@ try { RegistryKey devices {HKEY_LOCAL_MACHINE, _T("SYSTEM\\CurrentControlSet\\" "Control\\COM Name Arbiter\\Devices")}; - TCHAR name1[0x200]; + char name1[0x200]; if (!devices.GetValue(value, name1)) break; @@ -251,7 +251,7 @@ FillPortTypes(DataFieldEnum &df, const DeviceConfig &config) noexcept // maybe this is to check with the tests! static void SetPort(DataFieldEnum &df, DeviceConfig::PortType type, - const TCHAR *value) noexcept + const char *value) noexcept { assert(value != nullptr); @@ -279,12 +279,12 @@ static void FillSerialPorts(DataFieldEnum &df, void SetBluetoothPort(DataFieldEnum &df, DeviceConfig::PortType type, - const TCHAR *bluetooth_mac) noexcept + const char *bluetooth_mac) noexcept { assert(bluetooth_mac != nullptr); if (!df.SetValue(bluetooth_mac)) { - const TCHAR *name = nullptr; + const char *name = nullptr; #ifdef ANDROID if (bluetooth_helper != nullptr) name = bluetooth_helper->GetNameFromAddress(Java::GetEnv(), @@ -320,8 +320,8 @@ FillAndroidIOIOPorts([[maybe_unused]] DataFieldEnum &df, [[maybe_unused]] const #if defined(ANDROID) df.EnableItemHelp(true); - TCHAR tempID[4]; - TCHAR tempName[15]; + char tempID[4]; + char tempName[15]; for (unsigned i = 0; i < AndroidIOIOUartPort::getNumberUarts(); i++) { StringFormatUnsafe(tempID, _T("%u"), i); StringFormat(tempName, sizeof(tempName), _T("IOIO UART %u"), i); @@ -347,7 +347,7 @@ FillPorts(DataFieldEnum &df, const DeviceConfig &config) noexcept void UpdatePortEntry(DataFieldEnum &df, DeviceConfig::PortType type, - const TCHAR *value, const TCHAR *name) noexcept + const char *value, const char *name) noexcept { for (std::size_t i = 0, n = df.Count(); i < n; ++i) { const auto &item = df[i]; diff --git a/src/Dialogs/Device/PortDataField.hpp b/src/Dialogs/Device/PortDataField.hpp index 2cf7fc6eec0..ae191900369 100644 --- a/src/Dialogs/Device/PortDataField.hpp +++ b/src/Dialogs/Device/PortDataField.hpp @@ -14,11 +14,11 @@ FillPorts(DataFieldEnum &df, const DeviceConfig &config) noexcept; void UpdatePortEntry(DataFieldEnum &df, DeviceConfig::PortType type, - const TCHAR *value, const TCHAR *name) noexcept; + const char *value, const char *name) noexcept; void SetBluetoothPort(DataFieldEnum &df, DeviceConfig::PortType type, - const TCHAR *bluetooth_mac) noexcept; + const char *bluetooth_mac) noexcept; void SetDevicePort(DataFieldEnum &df, const DeviceConfig &config) noexcept; diff --git a/src/Dialogs/Device/PortMonitor.cpp b/src/Dialogs/Device/PortMonitor.cpp index 96c8c58de62..a03f7c51431 100644 --- a/src/Dialogs/Device/PortMonitor.cpp +++ b/src/Dialogs/Device/PortMonitor.cpp @@ -155,7 +155,7 @@ ShowPortMonitor(DeviceDescriptor &device) { const Look &look = UIGlobals::GetLook(); - std::array buffer; + std::array buffer; StaticString<128> caption; caption.Format(_T("%s: %s"), _("Port monitor"), device.GetConfig().GetPortName(buffer.data(), buffer.size())); diff --git a/src/Dialogs/Device/PortPicker.cpp b/src/Dialogs/Device/PortPicker.cpp index 223f36bf435..f1d0c28b677 100644 --- a/src/Dialogs/Device/PortPicker.cpp +++ b/src/Dialogs/Device/PortPicker.cpp @@ -36,7 +36,7 @@ class PortListItemRenderer final { void PaintItem(Canvas &canvas, PixelRect rc, const ComboList::Item &item) noexcept { - if (const TCHAR *text = ToDisplayString(DeviceConfig::PortType(item.int_value >> 16)); + if (const char *text = ToDisplayString(DeviceConfig::PortType(item.int_value >> 16)); text != nullptr) rc.right = row_renderer.DrawRightColumn(canvas, rc, text); @@ -44,7 +44,7 @@ class PortListItemRenderer final { } private: - static const TCHAR *ToDisplayString(DeviceConfig::PortType type) noexcept { + static const char *ToDisplayString(DeviceConfig::PortType type) noexcept { switch (type) { case DeviceConfig::PortType::RFCOMM: return _T("Bluetooth"); @@ -282,7 +282,7 @@ PortPickerWidget::OnDetectedNotification() noexcept #endif bool -PortPicker(DataFieldEnum &df, const TCHAR *caption) noexcept +PortPicker(DataFieldEnum &df, const char *caption) noexcept { TWidgetDialog dialog(WidgetDialog::Full{}, UIGlobals::GetMainWindow(), diff --git a/src/Dialogs/Device/PortPicker.hpp b/src/Dialogs/Device/PortPicker.hpp index a63d9fa423a..2c18c6bd00d 100644 --- a/src/Dialogs/Device/PortPicker.hpp +++ b/src/Dialogs/Device/PortPicker.hpp @@ -8,4 +8,4 @@ class DataFieldEnum; #include bool -PortPicker(DataFieldEnum &df, const TCHAR *caption) noexcept; +PortPicker(DataFieldEnum &df, const char *caption) noexcept; diff --git a/src/Dialogs/Device/Vega/VegaConfigurationDialog.cpp b/src/Dialogs/Device/Vega/VegaConfigurationDialog.cpp index a8734579af5..9d23650e5ab 100644 --- a/src/Dialogs/Device/Vega/VegaConfigurationDialog.cpp +++ b/src/Dialogs/Device/Vega/VegaConfigurationDialog.cpp @@ -25,7 +25,7 @@ #include "Look/DialogLook.hpp" #include "Operation/MessageOperationEnvironment.hpp" -static const TCHAR *const captions[] = { +static const char *const captions[] = { _T(" 1 Hardware"), _T(" 2 Calibration"), _T(" 3 Audio Modes"), diff --git a/src/Dialogs/Device/Vega/VegaDemoDialog.cpp b/src/Dialogs/Device/Vega/VegaDemoDialog.cpp index 3c6e2ffa2bf..9a656cb9aed 100644 --- a/src/Dialogs/Device/Vega/VegaDemoDialog.cpp +++ b/src/Dialogs/Device/Vega/VegaDemoDialog.cpp @@ -29,7 +29,7 @@ VegaWriteDemo() if (!last_time.CheckUpdate(std::chrono::milliseconds(250))) return; - TCHAR dbuf[100]; + char dbuf[100]; _stprintf(dbuf, _T("PDVDD,%d,%d"), iround(VegaDemoW * 10), iround(VegaDemoV * 10)); diff --git a/src/Dialogs/Device/Vega/VegaParametersWidget.cpp b/src/Dialogs/Device/Vega/VegaParametersWidget.cpp index 9a44c687a61..422a5c6088e 100644 --- a/src/Dialogs/Device/Vega/VegaParametersWidget.cpp +++ b/src/Dialogs/Device/Vega/VegaParametersWidget.cpp @@ -10,18 +10,18 @@ #include void -VegaParametersWidget::AddBoolean(const char *name, const TCHAR *label, - const TCHAR *help) +VegaParametersWidget::AddBoolean(const char *name, const char *label, + const char *help) { AddParameter(name); RowFormWidget::AddBoolean(label, help); } void -VegaParametersWidget::AddInteger(const char *name, const TCHAR *label, - const TCHAR *help, +VegaParametersWidget::AddInteger(const char *name, const char *label, + const char *help, int min_value, int max_value, - const TCHAR *format) + const char *format) { AddParameter(name); RowFormWidget::AddInteger(label, help, format, format, @@ -29,8 +29,8 @@ VegaParametersWidget::AddInteger(const char *name, const TCHAR *label, } void -VegaParametersWidget::AddEnum(const char *name, const TCHAR *label, - const TCHAR *help, const StaticEnumChoice *list) +VegaParametersWidget::AddEnum(const char *name, const char *label, + const char *help, const StaticEnumChoice *list) { AddParameter(name); RowFormWidget::AddEnum(label, help, list); @@ -41,8 +41,8 @@ VegaParametersWidget::AddParameter(const StaticParameter &p) { assert(p.label != NULL); - const TCHAR *label = gettext(p.label); - const TCHAR *help = p.help != NULL ? gettext(p.help) : NULL; + const char *label = gettext(p.label); + const char *help = p.help != NULL ? gettext(p.help) : NULL; switch (p.type) { case DataField::Type::BOOLEAN: diff --git a/src/Dialogs/Device/Vega/VegaParametersWidget.hpp b/src/Dialogs/Device/Vega/VegaParametersWidget.hpp index f7b515bcd56..6119b2ff9f7 100644 --- a/src/Dialogs/Device/Vega/VegaParametersWidget.hpp +++ b/src/Dialogs/Device/Vega/VegaParametersWidget.hpp @@ -16,13 +16,13 @@ class VegaParametersWidget : public RowFormWidget { const char *name; - const TCHAR *label, *help; + const char *label, *help; const StaticEnumChoice *choices; int min_value, max_value, step; - const TCHAR *format; + const char *format; }; private: @@ -66,11 +66,11 @@ class VegaParametersWidget : public RowFormWidget { public: /* methods to construct the form */ - void AddBoolean(const char *name, const TCHAR *label, - const TCHAR *help=NULL); - void AddInteger(const char *name, const TCHAR *label, const TCHAR *help, - int min_value, int max_value, const TCHAR *format); - void AddEnum(const char *name, const TCHAR *label, const TCHAR *help, + void AddBoolean(const char *name, const char *label, + const char *help=NULL); + void AddInteger(const char *name, const char *label, const char *help, + int min_value, int max_value, const char *format); + void AddEnum(const char *name, const char *label, const char *help, const StaticEnumChoice *list); private: diff --git a/src/Dialogs/Dialogs.h b/src/Dialogs/Dialogs.h index 7784df25fc2..8e010918b84 100644 --- a/src/Dialogs/Dialogs.h +++ b/src/Dialogs/Dialogs.h @@ -20,4 +20,4 @@ void dlgStatusShowModal(int page); void dlgCreditsShowModal(UI::SingleWindow &parent); void dlgQuickMenuShowModal(UI::SingleWindow & parent, - const TCHAR *mode) noexcept; + const char *mode) noexcept; diff --git a/src/Dialogs/DownloadFilePicker.cpp b/src/Dialogs/DownloadFilePicker.cpp index 8678c5613e8..5460097d886 100644 --- a/src/Dialogs/DownloadFilePicker.cpp +++ b/src/Dialogs/DownloadFilePicker.cpp @@ -375,7 +375,7 @@ AllocatedPath DownloadFilePicker(FileType file_type) { if (!Net::DownloadManager::IsAvailable()) { - const TCHAR *message = + const char *message = _("The file manager is not available on this device."); ShowMessageBox(message, _("File Manager"), MB_OK); return nullptr; diff --git a/src/Dialogs/Error.cpp b/src/Dialogs/Error.cpp index 196a4ae298f..6cce59fef8f 100644 --- a/src/Dialogs/Error.cpp +++ b/src/Dialogs/Error.cpp @@ -8,15 +8,15 @@ #include "util/StaticString.hxx" void -ShowError(std::exception_ptr e, const TCHAR *caption) noexcept +ShowError(std::exception_ptr e, const char *caption) noexcept { ShowMessageBox(UTF8ToWideConverter(GetFullMessage(e).c_str()), caption, MB_OK|MB_ICONEXCLAMATION); } void -ShowError(const TCHAR *msg, std::exception_ptr e, - const TCHAR *caption) noexcept +ShowError(const char *msg, std::exception_ptr e, + const char *caption) noexcept { StaticString<1024> buffer; buffer.Format(_T("%s\n%s"), msg, diff --git a/src/Dialogs/Error.hpp b/src/Dialogs/Error.hpp index 46dcd6c1856..2ddb7579c25 100644 --- a/src/Dialogs/Error.hpp +++ b/src/Dialogs/Error.hpp @@ -7,8 +7,8 @@ #include void -ShowError(std::exception_ptr e, const TCHAR *caption) noexcept; +ShowError(std::exception_ptr e, const char *caption) noexcept; void -ShowError(const TCHAR *msg, std::exception_ptr e, - const TCHAR *caption) noexcept; +ShowError(const char *msg, std::exception_ptr e, + const char *caption) noexcept; diff --git a/src/Dialogs/FileManager.cpp b/src/Dialogs/FileManager.cpp index 78304ada0d8..3da9eca4b61 100644 --- a/src/Dialogs/FileManager.cpp +++ b/src/Dialogs/FileManager.cpp @@ -61,13 +61,13 @@ FindRemoteFile(const FileRepository &repository, const char *name) [[gnu::pure]] static bool -CanDownload(const FileRepository &repository, const TCHAR *name) +CanDownload(const FileRepository &repository, const char *name) { return FindRemoteFile(repository, name) != nullptr; } static bool -UpdateAvailable(const FileRepository &repository, const TCHAR *name) +UpdateAvailable(const FileRepository &repository, const char *name) { const AvailableFile *remote_file = FindRemoteFile(repository, name); @@ -102,7 +102,7 @@ class ManagedFileListWidget DownloadStatus download_status; - void Set(const TCHAR *_name, const DownloadStatus *_download_status, + void Set(const char *_name, const DownloadStatus *_download_status, bool _failed, bool _out_of_date) { name = _name; @@ -233,7 +233,7 @@ class ManagedFileListWidget } [[gnu::pure]] - int FindItem(const TCHAR *name) const noexcept; + int FindItem(const char *name) const noexcept; void LoadRepositoryFile(); void RefreshList(); @@ -303,7 +303,7 @@ ManagedFileListWidget::Unprepare() noexcept } int -ManagedFileListWidget::FindItem(const TCHAR *name) const noexcept +ManagedFileListWidget::FindItem(const char *name) const noexcept { for (auto i = items.begin(), end = items.end(); i != end; ++i) if (StringIsEqual(i->name, name)) @@ -429,14 +429,14 @@ ManagedFileListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, unsigned(file.download_status.position * 100 / file.download_status.size)); } else { - TCHAR size[32]; + char size[32]; FormatByteSize(size, ARRAY_SIZE(size), file.download_status.position); text.Format(_T("%s (%s)"), _("Downloading"), size); } row_renderer.DrawRightFirstRow(canvas, rc, text); } else if (file.failed) { - const TCHAR *text = _("Error"); + const char *text = _("Error"); row_renderer.DrawRightFirstRow(canvas, rc, text); } @@ -539,7 +539,7 @@ AddFileListItemRenderer::OnPaintItem(Canvas &canvas, const PixelRect rc, row_renderer.DrawSecondRow(canvas, rc, description); if (file.update_date.IsPlausible()) { - TCHAR string_buffer[21]; + char string_buffer[21]; FormatISO8601(string_buffer, file.update_date); row_renderer.DrawRightSecondRow(canvas, rc, string_buffer); } @@ -776,7 +776,7 @@ ShowFileManager() } #endif - const TCHAR *message = + const char *message = _("The file manager is not available on this device."); ShowMessageBox(message, _("File Manager"), MB_OK); diff --git a/src/Dialogs/FilePicker.cpp b/src/Dialogs/FilePicker.cpp index 6b64e28cd11..40e0d67757a 100644 --- a/src/Dialogs/FilePicker.cpp +++ b/src/Dialogs/FilePicker.cpp @@ -14,14 +14,14 @@ #endif bool -FilePicker(const TCHAR *caption, FileDataField &df, - const TCHAR *help_text) +FilePicker(const char *caption, FileDataField &df, + const char *help_text) { ComboList combo_list = df.CreateComboList(nullptr); if (combo_list.size() == 0) return false; - const TCHAR *extra_caption = nullptr; + const char *extra_caption = nullptr; #ifdef HAVE_DOWNLOAD_MANAGER // with FileType::IGC don't show the 'Download'-Button! if (df.GetFileType() != FileType::IGC && @@ -52,7 +52,7 @@ FilePicker(const TCHAR *caption, FileDataField &df, } AllocatedPath -FilePicker(const TCHAR *caption, const TCHAR *patterns) +FilePicker(const char *caption, const char *patterns) { assert(patterns != nullptr); diff --git a/src/Dialogs/FilePicker.hpp b/src/Dialogs/FilePicker.hpp index e0a8de4f9df..8302581ad48 100644 --- a/src/Dialogs/FilePicker.hpp +++ b/src/Dialogs/FilePicker.hpp @@ -9,8 +9,8 @@ class AllocatedPath; class FileDataField; bool -FilePicker(const TCHAR *caption, FileDataField &df, - const TCHAR *help_text = nullptr); +FilePicker(const char *caption, FileDataField &df, + const char *help_text = nullptr); /** * Ask the user to pick a file from the data directory. @@ -21,4 +21,4 @@ FilePicker(const TCHAR *caption, FileDataField &df, * cancelled the dialog or if there are no matching files */ AllocatedPath -FilePicker(const TCHAR *caption, const TCHAR *patterns); +FilePicker(const char *caption, const char *patterns); diff --git a/src/Dialogs/GeoPointEntry.cpp b/src/Dialogs/GeoPointEntry.cpp index fc30dec1fd3..5e2505d0e28 100644 --- a/src/Dialogs/GeoPointEntry.cpp +++ b/src/Dialogs/GeoPointEntry.cpp @@ -11,7 +11,7 @@ #include "Geo/GeoPoint.hpp" bool -GeoPointEntryDialog(const TCHAR *caption, GeoPoint &value, +GeoPointEntryDialog(const char *caption, GeoPoint &value, const CoordinateFormat format, bool nullable) { diff --git a/src/Dialogs/GeoPointEntry.hpp b/src/Dialogs/GeoPointEntry.hpp index aab7d787522..1c2a190d8ac 100644 --- a/src/Dialogs/GeoPointEntry.hpp +++ b/src/Dialogs/GeoPointEntry.hpp @@ -10,6 +10,6 @@ enum class CoordinateFormat : uint8_t; struct GeoPoint; bool -GeoPointEntryDialog(const TCHAR *caption, GeoPoint &value, +GeoPointEntryDialog(const char *caption, GeoPoint &value, CoordinateFormat format, bool nullable=false); diff --git a/src/Dialogs/HelpDialog.cpp b/src/Dialogs/HelpDialog.cpp index b0a68fa73a2..cd65430d9c6 100644 --- a/src/Dialogs/HelpDialog.cpp +++ b/src/Dialogs/HelpDialog.cpp @@ -11,11 +11,11 @@ #include void -HelpDialog(const TCHAR *Caption, const TCHAR *HelpText) +HelpDialog(const char *Caption, const char *HelpText) { assert(HelpText != nullptr); - const TCHAR *prefix = _("Help"); + const char *prefix = _("Help"); StaticString<100> full_caption; if (Caption != nullptr) { diff --git a/src/Dialogs/HelpDialog.hpp b/src/Dialogs/HelpDialog.hpp index f7a79791122..de811cad6e8 100644 --- a/src/Dialogs/HelpDialog.hpp +++ b/src/Dialogs/HelpDialog.hpp @@ -6,4 +6,4 @@ #include void -HelpDialog(const TCHAR *caption, const TCHAR *text); +HelpDialog(const char *caption, const char *text); diff --git a/src/Dialogs/JobDialog.cpp b/src/Dialogs/JobDialog.cpp index 0cd6f474194..b0b04bc8fbf 100644 --- a/src/Dialogs/JobDialog.cpp +++ b/src/Dialogs/JobDialog.cpp @@ -26,7 +26,7 @@ class DialogJobThread : public JobThread { bool JobDialog(SingleWindow &parent, const DialogLook &dialog_look, - const TCHAR *caption, + const char *caption, Job &job, bool cancellable) { ProgressDialog form(parent, dialog_look, caption); diff --git a/src/Dialogs/JobDialog.hpp b/src/Dialogs/JobDialog.hpp index e680657a353..626bbe053a5 100644 --- a/src/Dialogs/JobDialog.hpp +++ b/src/Dialogs/JobDialog.hpp @@ -22,18 +22,18 @@ class Job; */ bool JobDialog(UI::SingleWindow &parent, const DialogLook &dialog_look, - const TCHAR *caption, Job &job, + const char *caption, Job &job, bool cancellable=false); class DialogJobRunner : public JobRunner { UI::SingleWindow &parent; const DialogLook &dialog_look; - const TCHAR *caption; + const char *caption; bool cancellable; public: DialogJobRunner(UI::SingleWindow &_parent, const DialogLook &_dialog_look, - const TCHAR *_caption, bool _cancellable=false) + const char *_caption, bool _cancellable=false) :parent(_parent), dialog_look(_dialog_look), caption(_caption), cancellable(_cancellable) {} diff --git a/src/Dialogs/KnobTextEntry.cpp b/src/Dialogs/KnobTextEntry.cpp index 3496893b7bd..80ac0ec8a6f 100644 --- a/src/Dialogs/KnobTextEntry.cpp +++ b/src/Dialogs/KnobTextEntry.cpp @@ -27,7 +27,7 @@ enum Buttons { static constexpr size_t MAX_TEXTENTRY = 40; -static constexpr TCHAR EntryLetters[] = +static constexpr char EntryLetters[] = _T(" ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.-"); static constexpr unsigned MAXENTRYLETTERS = ARRAY_SIZE(EntryLetters) - 1; @@ -39,7 +39,7 @@ static constexpr unsigned MAXENTRYLETTERS = ARRAY_SIZE(EntryLetters) - 1; */ [[gnu::const]] static unsigned -FindEntryLetter(TCHAR ch) +FindEntryLetter(char ch) { for (unsigned i = 0; i < (int)MAXENTRYLETTERS; ++i) if (EntryLetters[i] == ch) @@ -54,17 +54,17 @@ class KnobTextEntryWindow final : public PaintWindow { unsigned int cursor; int lettercursor; - TCHAR buffer[MAX_TEXTENTRY]; + char buffer[MAX_TEXTENTRY]; public: - KnobTextEntryWindow(const TCHAR *text, size_t width) + KnobTextEntryWindow(const char *text, size_t width) :max_width(std::min(MAX_TEXTENTRY, width)), cursor(0), lettercursor(0) { CopyTruncateString(buffer, max_width, text); MoveCursor(); } - TCHAR *GetValue() { + char *GetValue() { return buffer; } @@ -165,18 +165,18 @@ KnobTextEntryWindow::OnPaint(Canvas &canvas) noexcept } class KnobTextEntryWidget final : public WindowWidget { - const TCHAR *const text; + const char *const text; const size_t width; public: - KnobTextEntryWidget(const TCHAR *_text, size_t _width) noexcept + KnobTextEntryWidget(const char *_text, size_t _width) noexcept :text(_text), width(_width) {} auto &GetWindow() noexcept { return (KnobTextEntryWindow &)WindowWidget::GetWindow(); } - TCHAR *GetValue() { + char *GetValue() { return GetWindow().GetValue(); } @@ -212,8 +212,8 @@ KnobTextEntryWidget::CreateButtons(WidgetDialog &dialog) } void -KnobTextEntry(TCHAR *text, size_t width, - const TCHAR *caption) +KnobTextEntry(char *text, size_t width, + const char *caption) { if (width == 0) width = MAX_TEXTENTRY; diff --git a/src/Dialogs/ListPicker.cpp b/src/Dialogs/ListPicker.cpp index 9828b905eeb..c6e59515aff 100644 --- a/src/Dialogs/ListPicker.cpp +++ b/src/Dialogs/ListPicker.cpp @@ -34,7 +34,7 @@ class ListPickerWidget : public ListWidget { UpdateHelp(GetList().GetCursorIndex()); }}; - const TCHAR *const caption, *const help_text; + const char *const caption, *const help_text; ItemHelpCallback_t item_help_callback; TextWidget *help_widget; TwoWidgets *two_widgets; @@ -44,7 +44,7 @@ class ListPickerWidget : public ListWidget { unsigned _row_height, ListItemRenderer &_item_renderer, WndForm &_dialog, - const TCHAR *_caption, const TCHAR *_help_text) noexcept + const char *_caption, const char *_help_text) noexcept :num_items(_num_items), initial_value(_initial_value), row_height(_row_height), visible(false), @@ -119,13 +119,13 @@ class ListPickerWidget : public ListWidget { }; int -ListPicker(const TCHAR *caption, +ListPicker(const char *caption, unsigned num_items, unsigned initial_value, unsigned item_height, ListItemRenderer &item_renderer, bool update, - const TCHAR *help_text, + const char *help_text, ItemHelpCallback_t _itemhelp_callback, - const TCHAR *extra_caption) + const char *extra_caption) { assert(num_items <= 0x7fffffff); assert((num_items == 0 && initial_value == 0) || initial_value < num_items); diff --git a/src/Dialogs/ListPicker.hpp b/src/Dialogs/ListPicker.hpp index de9bd4a90fa..8af81ed002e 100644 --- a/src/Dialogs/ListPicker.hpp +++ b/src/Dialogs/ListPicker.hpp @@ -8,7 +8,7 @@ class ListItemRenderer; /** returns string of item's help text **/ -typedef const TCHAR* (*ItemHelpCallback_t)(unsigned item); +typedef const char* (*ItemHelpCallback_t)(unsigned item); /** * Shows a list dialog and lets the user pick an item. @@ -26,10 +26,10 @@ typedef const TCHAR* (*ItemHelpCallback_t)(unsigned item); * the user clicked the "extra" button */ int -ListPicker(const TCHAR *caption, +ListPicker(const char *caption, unsigned num_items, unsigned initial_value, unsigned item_height, ListItemRenderer &item_renderer, bool update = false, - const TCHAR *help_text = nullptr, + const char *help_text = nullptr, ItemHelpCallback_t itemhelp_callback = nullptr, - const TCHAR *extra_caption=nullptr); + const char *extra_caption=nullptr); diff --git a/src/Dialogs/Message.cpp b/src/Dialogs/Message.cpp index b38bbd8c69e..7f3ed09e553 100644 --- a/src/Dialogs/Message.cpp +++ b/src/Dialogs/Message.cpp @@ -16,7 +16,7 @@ #include int -ShowMessageBox(const TCHAR *text, const TCHAR *caption, +ShowMessageBox(const char *text, const char *caption, unsigned flags) noexcept { assert(text != NULL); diff --git a/src/Dialogs/Message.hpp b/src/Dialogs/Message.hpp index a0e9d2cd466..c08de0debc0 100644 --- a/src/Dialogs/Message.hpp +++ b/src/Dialogs/Message.hpp @@ -44,5 +44,5 @@ enum { * @return */ int -ShowMessageBox(const TCHAR *text, const TCHAR *caption, +ShowMessageBox(const char *text, const char *caption, unsigned flags) noexcept; diff --git a/src/Dialogs/NumberEntry.cpp b/src/Dialogs/NumberEntry.cpp index 46c1a0ba5bb..69759cced86 100644 --- a/src/Dialogs/NumberEntry.cpp +++ b/src/Dialogs/NumberEntry.cpp @@ -62,7 +62,7 @@ NumberEntryDialog(TWidgetDialog &dialog, // ---------------------------------------------------------------------------- /** NumberEntryDialog for big signed numbers -> SIGNED with +/-! */ bool -NumberEntryDialog(const TCHAR *caption, int &value, unsigned length) { +NumberEntryDialog(const char *caption, int &value, unsigned length) { TWidgetDialog dialog(WidgetDialog::Auto{}, UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), caption); @@ -75,7 +75,7 @@ NumberEntryDialog(const TCHAR *caption, int &value, unsigned length) { // ---------------------------------------------------------------------------- /** NumberEntryDialog for big unsigned numbers -> UNSIGNED! */ bool -NumberEntryDialog(const TCHAR *caption, unsigned &value, unsigned length) { +NumberEntryDialog(const char *caption, unsigned &value, unsigned length) { TWidgetDialog dialog(WidgetDialog::Auto{}, UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), caption); @@ -88,7 +88,7 @@ NumberEntryDialog(const TCHAR *caption, unsigned &value, unsigned length) { // ---------------------------------------------------------------------------- /** NumberEntryDialog for big angle values */ bool -AngleEntryDialog(const TCHAR *caption, Angle &value) { +AngleEntryDialog(const char *caption, Angle &value) { TWidgetDialog dialog(WidgetDialog::Auto{}, UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), caption); diff --git a/src/Dialogs/NumberEntry.hpp b/src/Dialogs/NumberEntry.hpp index 3966dd1f55c..a4057cb452f 100644 --- a/src/Dialogs/NumberEntry.hpp +++ b/src/Dialogs/NumberEntry.hpp @@ -9,12 +9,12 @@ class Angle; /** NumberEntryDialog for big unsigned numbers -> SIGNED with +/-! */ bool -NumberEntryDialog(const TCHAR *caption, +NumberEntryDialog(const char *caption, int &value, unsigned length); /** NumberEntryDialog for big unsigned numbers -> UNSIGNED! */ bool -NumberEntryDialog(const TCHAR *caption, +NumberEntryDialog(const char *caption, unsigned &value, unsigned length); -bool AngleEntryDialog(const TCHAR *caption, Angle &value); +bool AngleEntryDialog(const char *caption, Angle &value); diff --git a/src/Dialogs/Plane/PlaneDetailsDialog.cpp b/src/Dialogs/Plane/PlaneDetailsDialog.cpp index b969b20647b..37ef1b7e249 100644 --- a/src/Dialogs/Plane/PlaneDetailsDialog.cpp +++ b/src/Dialogs/Plane/PlaneDetailsDialog.cpp @@ -68,7 +68,7 @@ PlaneEditWidget::UpdateCaption() noexcept void PlaneEditWidget::UpdatePolarButton() noexcept { - const TCHAR *caption = _("Polar"); + const char *caption = _("Polar"); StaticString<64> buffer; if (!plane.polar_name.empty()) { buffer.Format(_T("%s: %s"), caption, plane.polar_name.c_str()); diff --git a/src/Dialogs/Plane/PlaneListDialog.cpp b/src/Dialogs/Plane/PlaneListDialog.cpp index fbb62d16a92..9f7464c3d7a 100644 --- a/src/Dialogs/Plane/PlaneListDialog.cpp +++ b/src/Dialogs/Plane/PlaneListDialog.cpp @@ -195,7 +195,7 @@ PlaneListWidget::LoadWithDialog(unsigned i) noexcept { bool result = Load(i); if (!result) { - const TCHAR *title = _("Error"); + const char *title = _("Error"); StaticString<256> text; text.Format(_("Activating plane \"%s\" failed."), list[i].name.c_str()); @@ -257,7 +257,7 @@ PlaneListWidget::EditClicked(bool copy) noexcept const unsigned index = GetList().GetCursorIndex(); const Path old_path = list[index].path; - const TCHAR *old_filename = list[index].name; + const char *old_filename = list[index].name; Plane plane; PlaneGlue::ReadFile(plane, old_path); diff --git a/src/Dialogs/Plane/PolarShapeEditWidget.cpp b/src/Dialogs/Plane/PolarShapeEditWidget.cpp index 483f2eba28e..a5acd5c9c3f 100644 --- a/src/Dialogs/Plane/PolarShapeEditWidget.cpp +++ b/src/Dialogs/Plane/PolarShapeEditWidget.cpp @@ -107,8 +107,8 @@ PolarShapeEditWidget::Prepare(ContainerWindow &parent, const unsigned width = _rc.GetWidth(), height = _rc.GetHeight(); - const TCHAR *v_text = _("Polar V"); - const TCHAR *w_text = _("Polar W"); + const char *v_text = _("Polar V"); + const char *w_text = _("Polar W"); const unsigned row_height = height / 2; const unsigned label_width = 2 * Layout::GetTextPadding() + diff --git a/src/Dialogs/ProcessDialog.cpp b/src/Dialogs/ProcessDialog.cpp index 8b6041c807c..5a1d7932b87 100644 --- a/src/Dialogs/ProcessDialog.cpp +++ b/src/Dialogs/ProcessDialog.cpp @@ -246,7 +246,7 @@ ProcessWidget::Unprepare() noexcept int RunProcessDialog(UI::SingleWindow &parent, const DialogLook &dialog_look, - const TCHAR *caption, + const char *caption, const char *const*argv, std::function on_exit) noexcept { diff --git a/src/Dialogs/ProcessDialog.hpp b/src/Dialogs/ProcessDialog.hpp index 20ce0231901..50d47f08bfd 100644 --- a/src/Dialogs/ProcessDialog.hpp +++ b/src/Dialogs/ProcessDialog.hpp @@ -13,6 +13,6 @@ namespace UI { class SingleWindow; } int RunProcessDialog(UI::SingleWindow &parent, const DialogLook &dialog_look, - const TCHAR *caption, + const char *caption, const char *const*argv, std::function on_exit={}) noexcept; diff --git a/src/Dialogs/ProfileListDialog.cpp b/src/Dialogs/ProfileListDialog.cpp index 8f6328349f3..895392dc2b2 100644 --- a/src/Dialogs/ProfileListDialog.cpp +++ b/src/Dialogs/ProfileListDialog.cpp @@ -28,7 +28,7 @@ class ProfileListWidget final StaticString<32> name; AllocatedPath path; - ListItem(const TCHAR *_name, Path _path) + ListItem(const char *_name, Path _path) :name(_name), path(_path) {} bool operator<(const ListItem &i2) const { @@ -89,7 +89,7 @@ class ProfileListWidget final protected: /* virtual methods from TextListWidget */ - const TCHAR *GetRowText(unsigned i) const noexcept override { + const char *GetRowText(unsigned i) const noexcept override { return list[i].name; } @@ -262,7 +262,7 @@ ProfileListWidget::CopyClicked() } static bool -ConfirmDeleteProfile(const TCHAR *name) +ConfirmDeleteProfile(const char *name) { StaticString<256> tmp; StaticString<256> tmp_name(name); diff --git a/src/Dialogs/ProfilePasswordDialog.cpp b/src/Dialogs/ProfilePasswordDialog.cpp index 8ce8243126f..396238d9861 100644 --- a/src/Dialogs/ProfilePasswordDialog.cpp +++ b/src/Dialogs/ProfilePasswordDialog.cpp @@ -33,12 +33,12 @@ CheckProfilePassword(const ProfileMap &map) { /* oh no, profile passwords are not truly secure! */ - BasicStringBuffer profile_password; + BasicStringBuffer profile_password; if (!map.Get(ProfileKeys::Password, profile_password)) /* not password protected */ return ProfilePasswordResult::UNPROTECTED; - BasicStringBuffer user_password; + BasicStringBuffer user_password; user_password.clear(); if (!TextEntryDialog(user_password, _("Enter your password"))) return ProfilePasswordResult::CANCEL; @@ -78,7 +78,7 @@ CheckProfilePasswordResult(ProfilePasswordResult result) bool SetProfilePasswordDialog(ProfileMap &map) { - BasicStringBuffer new_password; + BasicStringBuffer new_password; new_password.clear(); if (!TextEntryDialog(new_password, _("Enter a new password"))) return false; diff --git a/src/Dialogs/ProgressDialog.cpp b/src/Dialogs/ProgressDialog.cpp index d34fee5ba9d..ef473d841db 100644 --- a/src/Dialogs/ProgressDialog.cpp +++ b/src/Dialogs/ProgressDialog.cpp @@ -13,7 +13,7 @@ using namespace UI; ProgressDialog::ProgressDialog(SingleWindow &parent, const DialogLook &dialog_look, - const TCHAR *caption) + const char *caption) :WndForm(parent, dialog_look, parent.GetClientRect(), caption), progress(GetClientAreaWindow()) { diff --git a/src/Dialogs/ProgressDialog.hpp b/src/Dialogs/ProgressDialog.hpp index fec6e1c3608..510c7639fae 100644 --- a/src/Dialogs/ProgressDialog.hpp +++ b/src/Dialogs/ProgressDialog.hpp @@ -20,13 +20,13 @@ class ProgressDialog public: ProgressDialog(UI::SingleWindow &parent, const DialogLook &dialog_look, - const TCHAR *caption); + const char *caption); void AddCancelButton(std::function &&callback={}); /* virtual methods from class OperationEnvironment */ - void SetText(const TCHAR *text) noexcept override { + void SetText(const char *text) noexcept override { progress.SetMessage(text); } diff --git a/src/Dialogs/Settings/Panels/ConfigPanel.hpp b/src/Dialogs/Settings/Panels/ConfigPanel.hpp index fc34ed2802a..8f8ada20099 100644 --- a/src/Dialogs/Settings/Panels/ConfigPanel.hpp +++ b/src/Dialogs/Settings/Panels/ConfigPanel.hpp @@ -7,7 +7,7 @@ #include namespace ConfigPanel { -void BorrowExtraButton(unsigned i, const TCHAR *caption, +void BorrowExtraButton(unsigned i, const char *caption, std::function callback) noexcept; void ReturnExtraButton(unsigned i); }; diff --git a/src/Dialogs/Settings/Panels/InterfaceConfigPanel.cpp b/src/Dialogs/Settings/Panels/InterfaceConfigPanel.cpp index 6ba76ae5a9c..08b16af41c2 100644 --- a/src/Dialogs/Settings/Panels/InterfaceConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/InterfaceConfigPanel.cpp @@ -86,7 +86,7 @@ InterfaceConfigPanel::Prepare(ContainerWindow &parent, DataFieldEnum &df = *(DataFieldEnum *)wp_dpi->GetDataField(); df.AddChoice(0, _("Automatic")); for (const unsigned *dpi = dpi_choices; dpi != dpi_choices_end; ++dpi) { - TCHAR buffer[20]; + char buffer[20]; _stprintf(buffer, _("%d dpi"), *dpi); df.AddChoice(*dpi, buffer); } @@ -213,7 +213,7 @@ InterfaceConfigPanel::Save(bool &_changed) noexcept old_base = old_value; AllocatedPath buffer = nullptr; - const TCHAR *new_value, *new_base; + const char *new_value, *new_base; switch (df.GetValue()) { case 0: diff --git a/src/Dialogs/Settings/Panels/PagesConfigPanel.cpp b/src/Dialogs/Settings/Panels/PagesConfigPanel.cpp index d3072cae298..753a3486468 100644 --- a/src/Dialogs/Settings/Panels/PagesConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/PagesConfigPanel.cpp @@ -193,11 +193,11 @@ PageLayoutEditWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_ ib_list, IBP_AUTO, this); DataFieldEnum &ib = *(DataFieldEnum *)wp->GetDataField(); for (unsigned i = 0; i < InfoBoxSettings::MAX_PANELS; ++i) { - const TCHAR cruise_help[] = N_("For cruise mode. Displayed when 'Auto' is selected and ship is below final glide altitude"); - const TCHAR circling_help[] = N_("For circling mode. Displayed when 'Auto' is selected and ship is circling"); - const TCHAR final_glide_help[] = N_("For final glide mode. Displayed when 'Auto' is selected and ship is above final glide altitude"); - const TCHAR *display_text = gettext(info_box_settings.panels[i].name); - const TCHAR *help_text = N_("A custom InfoBox set"); + const char cruise_help[] = N_("For cruise mode. Displayed when 'Auto' is selected and ship is below final glide altitude"); + const char circling_help[] = N_("For circling mode. Displayed when 'Auto' is selected and ship is circling"); + const char final_glide_help[] = N_("For final glide mode. Displayed when 'Auto' is selected and ship is above final glide altitude"); + const char *display_text = gettext(info_box_settings.panels[i].name); + const char *help_text = N_("A custom InfoBox set"); switch (i) { case 0: help_text = circling_help; diff --git a/src/Dialogs/Settings/Panels/TaskDefaultsConfigPanel.cpp b/src/Dialogs/Settings/Panels/TaskDefaultsConfigPanel.cpp index 4654962ff1f..a63e59f6d27 100644 --- a/src/Dialogs/Settings/Panels/TaskDefaultsConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/TaskDefaultsConfigPanel.cpp @@ -58,8 +58,8 @@ TaskDefaultsConfigPanel::OnModified(DataField &df) noexcept SetFinishLabel(); } -static const TCHAR *const Caption_GateWidth = N_("Gate width"); -static const TCHAR *const Caption_Radius = N_("Radius"); +static const char *const Caption_GateWidth = N_("Gate width"); +static const char *const Caption_Radius = N_("Radius"); void TaskDefaultsConfigPanel::SetStartLabel() diff --git a/src/Dialogs/Settings/Panels/TrackingConfigPanel.cpp b/src/Dialogs/Settings/Panels/TrackingConfigPanel.cpp index e810b7d0e92..85caa2d119e 100644 --- a/src/Dialogs/Settings/Panels/TrackingConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/TrackingConfigPanel.cpp @@ -245,7 +245,7 @@ static bool SaveKey(const RowFormWidget &form, unsigned idx, std::string_view profile_key, uint64_t &value_r) { - const TCHAR *const s = form.GetValueString(idx); + const char *const s = form.GetValueString(idx); uint64_t value = ParseUint64(s, nullptr, 16); if (value == value_r) return false; diff --git a/src/Dialogs/Settings/WindSettingsPanel.cpp b/src/Dialogs/Settings/WindSettingsPanel.cpp index 7c85349695c..332d1d44f97 100644 --- a/src/Dialogs/Settings/WindSettingsPanel.cpp +++ b/src/Dialogs/Settings/WindSettingsPanel.cpp @@ -164,7 +164,7 @@ WindSettingsPanel::UpdateVector() noexcept const DerivedInfo &calculated = CommonInterface::Calculated(); const WindSettings &settings = CommonInterface::SetComputerSettings().wind; - const TCHAR *source = nullptr; + const char *source = nullptr; switch (manual_modified ? DerivedInfo::WindSource::MANUAL : calculated.wind_source) { diff --git a/src/Dialogs/Settings/dlgConfigInfoboxes.cpp b/src/Dialogs/Settings/dlgConfigInfoboxes.cpp index 61fd72fefd0..483b18280df 100644 --- a/src/Dialogs/Settings/dlgConfigInfoboxes.cpp +++ b/src/Dialogs/Settings/dlgConfigInfoboxes.cpp @@ -214,12 +214,12 @@ InfoBoxesConfigWidget::Prepare(ContainerWindow &parent, const Layout layout(rc, geometry); AddText(_("Name"), nullptr, - allow_name_change ? (const TCHAR *)data.name : gettext(data.name)); + allow_name_change ? (const char *)data.name : gettext(data.name)); SetReadOnly(NAME, !allow_name_change); DataFieldEnum *dfe = new DataFieldEnum(this); for (unsigned i = 0; i < layout.info_boxes.count; ++i) { - TCHAR label[32]; + char label[32]; _stprintf(label, _T("%u"), i + 1); dfe->addEnumText(label, i); } @@ -228,8 +228,8 @@ InfoBoxesConfigWidget::Prepare(ContainerWindow &parent, dfe = new DataFieldEnum(this); for (unsigned i = InfoBoxFactory::MIN_TYPE_VAL; i < InfoBoxFactory::NUM_TYPES; i++) { - const TCHAR *name = InfoBoxFactory::GetName((InfoBoxFactory::Type) i); - const TCHAR *desc = InfoBoxFactory::GetDescription((InfoBoxFactory::Type) i); + const char *name = InfoBoxFactory::GetName((InfoBoxFactory::Type) i); + const char *desc = InfoBoxFactory::GetDescription((InfoBoxFactory::Type) i); if (name != NULL) dfe->addEnumText(gettext(name), i, desc != NULL ? gettext(desc) : NULL); } @@ -237,8 +237,8 @@ InfoBoxesConfigWidget::Prepare(ContainerWindow &parent, for (unsigned i = InfoBoxFactory::e_NUM_AREA_2nd; i < InfoBoxFactory::NUM_TYPES_2nd; i++) { const InfoBoxFactory::Type type = (InfoBoxFactory::Type) (i); - const TCHAR *name = InfoBoxFactory::GetName(type); - const TCHAR *desc = InfoBoxFactory::GetDescription(type); + const char *name = InfoBoxFactory::GetName(type); + const char *desc = InfoBoxFactory::GetDescription(type); if (name != NULL) dfe->addEnumText(gettext(name), type, desc != NULL ? gettext(desc) : NULL); @@ -389,7 +389,7 @@ InfoBoxPreview::OnPaint(Canvas &canvas) noexcept canvas.DrawRectangle(PixelRect{PixelSize{canvas.GetWidth() - 1, canvas.GetHeight() - 1}}); InfoBoxFactory::Type type = parent->GetContents(i); - const TCHAR *caption = type < InfoBoxFactory::NUM_TYPES + const char *caption = type < InfoBoxFactory::NUM_TYPES ? InfoBoxFactory::GetCaption(type) : NULL; if (caption == NULL) diff --git a/src/Dialogs/Settings/dlgConfiguration.cpp b/src/Dialogs/Settings/dlgConfiguration.cpp index 80d0d2430a7..5a07aeeac15 100644 --- a/src/Dialogs/Settings/dlgConfiguration.cpp +++ b/src/Dialogs/Settings/dlgConfiguration.cpp @@ -345,7 +345,7 @@ class ConfigurationExtraButtons final }; void -ConfigPanel::BorrowExtraButton(unsigned i, const TCHAR *caption, +ConfigPanel::BorrowExtraButton(unsigned i, const char *caption, std::function callback) noexcept { ConfigurationExtraButtons &extra = @@ -427,8 +427,8 @@ OnPageFlipped(WidgetDialog &dialog, TabMenuDisplay &menu) { menu.OnPageFlipped(); - TCHAR buffer[128]; - const TCHAR *caption = menu.GetCaption(buffer, ARRAY_SIZE(buffer)); + char buffer[128]; + const char *caption = menu.GetCaption(buffer, ARRAY_SIZE(buffer)); if (caption == nullptr) caption = _("Configuration"); dialog.SetCaption(caption); diff --git a/src/Dialogs/StartupDialog.cpp b/src/Dialogs/StartupDialog.cpp index 2388fc558d2..9082cb36f46 100644 --- a/src/Dialogs/StartupDialog.cpp +++ b/src/Dialogs/StartupDialog.cpp @@ -118,8 +118,8 @@ class StartupWidget final : public RowFormWidget { }; static bool -SelectProfileCallback([[maybe_unused]] const TCHAR *caption, [[maybe_unused]] DataField &_df, - [[maybe_unused]] const TCHAR *help_text) noexcept +SelectProfileCallback([[maybe_unused]] const char *caption, [[maybe_unused]] DataField &_df, + [[maybe_unused]] const char *help_text) noexcept { FileDataField &df = (FileDataField &)_df; diff --git a/src/Dialogs/StatusPanels/RulesStatusPanel.cpp b/src/Dialogs/StatusPanels/RulesStatusPanel.cpp index e601cd9a78c..bf6bedfc96d 100644 --- a/src/Dialogs/StatusPanels/RulesStatusPanel.cpp +++ b/src/Dialogs/StatusPanels/RulesStatusPanel.cpp @@ -28,7 +28,7 @@ enum Controls { void RulesStatusPanel::Refresh() noexcept { - TCHAR Temp[80]; + char Temp[80]; const DerivedInfo &calculated = CommonInterface::Calculated(); const TaskStats &task_stats = calculated.ordered_task_stats; diff --git a/src/Dialogs/StatusPanels/SystemStatusPanel.cpp b/src/Dialogs/StatusPanels/SystemStatusPanel.cpp index 163f3395862..f08254a7a79 100644 --- a/src/Dialogs/StatusPanels/SystemStatusPanel.cpp +++ b/src/Dialogs/StatusPanels/SystemStatusPanel.cpp @@ -25,7 +25,7 @@ enum Controls { }; [[gnu::pure]] -static const TCHAR * +static const char * GetGPSStatus(const NMEAInfo &basic) noexcept { if (!basic.alive) @@ -38,7 +38,7 @@ GetGPSStatus(const NMEAInfo &basic) noexcept return N_("3D fix"); } -static const TCHAR *const net_state_strings[] = { +static const char *const net_state_strings[] = { N_("Unknown"), N_("Disconnected"), N_("Connected"), @@ -46,7 +46,7 @@ static const TCHAR *const net_state_strings[] = { }; [[gnu::pure]] -static const TCHAR * +static const char * ToString(NetState state) noexcept { return gettext(net_state_strings[unsigned(state)]); diff --git a/src/Dialogs/Task/Manager/TaskEditPanel.cpp b/src/Dialogs/Task/Manager/TaskEditPanel.cpp index 1d051c75187..884bcc2be0e 100644 --- a/src/Dialogs/Task/Manager/TaskEditPanel.cpp +++ b/src/Dialogs/Task/Manager/TaskEditPanel.cpp @@ -151,7 +151,7 @@ TaskEditPanel::RefreshView() UpdateButtons(); { - TCHAR text[300]; + char text[300]; OrderedTaskSummary(ordered_task, text, false); summary.SetText(text); } @@ -221,7 +221,7 @@ TaskEditPanel::OnPaintItem(Canvas &canvas, const PixelRect rc, const unsigned padding = Layout::GetTextPadding(); const unsigned line_height = rc.GetHeight(); - TCHAR buffer[120]; + char buffer[120]; // Draw "Add turnpoint" label if (DrawListIndex == ordered_task->TaskSize()) { diff --git a/src/Dialogs/Task/Manager/TaskListPanel.cpp b/src/Dialogs/Task/Manager/TaskListPanel.cpp index 753baa31999..e155a1455fc 100644 --- a/src/Dialogs/Task/Manager/TaskListPanel.cpp +++ b/src/Dialogs/Task/Manager/TaskListPanel.cpp @@ -98,7 +98,7 @@ class TaskListPanel final const OrderedTask *get_cursor_task(); [[gnu::pure]] - const TCHAR *get_cursor_name(); + const char *get_cursor_name(); private: /* virtual methods from class ListControl::Handler */ @@ -141,7 +141,7 @@ TaskListPanel::get_cursor_task() return ordered_task; } -const TCHAR * +const char * TaskListPanel::get_cursor_name() { const unsigned cursor_index = GetList().GetCursorIndex(); @@ -173,7 +173,7 @@ TaskListPanel::RefreshView() if (ordered_task == nullptr) { summary.SetText(_T("")); } else { - TCHAR text[300]; + char text[300]; OrderedTaskSummary(ordered_task, text, false); summary.SetText(text); } @@ -228,7 +228,7 @@ TaskListPanel::DeleteTask() return; } - const TCHAR *fname = task_store.GetName(cursor_index); + const char *fname = task_store.GetName(cursor_index); StaticString<1024> text; text.Format(_T("%s\n(%s)"), _("Delete the selected task?"), fname); @@ -243,14 +243,14 @@ TaskListPanel::DeleteTask() } static bool -ClearSuffix(TCHAR *p, const TCHAR *suffix) +ClearSuffix(char *p, const char *suffix) { size_t length = strlen(p); size_t suffix_length = strlen(suffix); if (length <= suffix_length) return false; - TCHAR *q = p + length - suffix_length; + char *q = p + length - suffix_length; if (!StringIsEqualIgnoreCase(q, suffix)) return false; @@ -265,7 +265,7 @@ TaskListPanel::RenameTask() if (cursor_index >= task_store.Size()) return; - const TCHAR *oldname = task_store.GetName(cursor_index); + const char *oldname = task_store.GetName(cursor_index); StaticString<40> newname(oldname); if (ClearSuffix(newname.buffer(), _T(".cup"))) { diff --git a/src/Dialogs/Task/MutateTaskPointDialog.cpp b/src/Dialogs/Task/MutateTaskPointDialog.cpp index b4d2fb8e849..77905b789e1 100644 --- a/src/Dialogs/Task/MutateTaskPointDialog.cpp +++ b/src/Dialogs/Task/MutateTaskPointDialog.cpp @@ -18,7 +18,7 @@ static TrivialArray point_types; -static const TCHAR * +static const char * TPTypeItemHelp(unsigned i) { return OrderedTaskPointDescription(point_types[i]); diff --git a/src/Dialogs/Task/dlgTaskHelpers.cpp b/src/Dialogs/Task/dlgTaskHelpers.cpp index 94259698364..d80af94b26c 100644 --- a/src/Dialogs/Task/dlgTaskHelpers.cpp +++ b/src/Dialogs/Task/dlgTaskHelpers.cpp @@ -28,7 +28,7 @@ * @return True if FAI shape */ static bool -TaskSummaryShape(const OrderedTask *task, TCHAR *text) +TaskSummaryShape(const OrderedTask *task, char *text) { bool FAIShape = false; switch (task->TaskSize()) { @@ -73,16 +73,16 @@ TaskSummaryShape(const OrderedTask *task, TCHAR *text) return FAIShape; } void -OrderedTaskSummary(const OrderedTask *task, TCHAR *text, bool linebreaks) +OrderedTaskSummary(const OrderedTask *task, char *text, bool linebreaks) { const TaskStats &stats = task->GetStats(); - TCHAR summary_shape[100]; + char summary_shape[100]; bool FAIShape = TaskSummaryShape(task, summary_shape); TaskValidationErrorSet validation_errors; if (FAIShape || task->GetFactoryType() == TaskFactoryType::FAI_GENERAL) validation_errors = task->GetFactory().ValidateFAIOZs(); - TCHAR linebreak[3]; + char linebreak[3]; if (linebreaks) { linebreak[0] = '\n'; linebreak[1] = 0; @@ -127,8 +127,8 @@ OrderedTaskSummary(const OrderedTask *task, TCHAR *text, bool linebreaks) } void -OrderedTaskPointLabel(TaskPointType type, const TCHAR *name, - unsigned index, TCHAR* buffer) +OrderedTaskPointLabel(TaskPointType type, const char *name, + unsigned index, char* buffer) { switch (type) { case TaskPointType::START: @@ -153,7 +153,7 @@ OrderedTaskPointLabel(TaskPointType type, const TCHAR *name, } void -OrderedTaskPointRadiusLabel(const ObservationZonePoint &ozp, TCHAR* buffer) +OrderedTaskPointRadiusLabel(const ObservationZonePoint &ozp, char* buffer) { switch (ozp.GetShape()) { case ObservationZone::Shape::FAI_SECTOR: @@ -217,7 +217,7 @@ OrderedTaskPointRadiusLabel(const ObservationZonePoint &ozp, TCHAR* buffer) bool OrderedTaskSave(OrderedTask &task) { - TCHAR fname[69] = _T(""); + char fname[69] = _T(""); if (!TextEntryDialog(fname, 64, _("Enter a task name"))) return false; diff --git a/src/Dialogs/Task/dlgTaskHelpers.hpp b/src/Dialogs/Task/dlgTaskHelpers.hpp index 21f19ddc0df..b2e8559fdbd 100644 --- a/src/Dialogs/Task/dlgTaskHelpers.hpp +++ b/src/Dialogs/Task/dlgTaskHelpers.hpp @@ -17,13 +17,13 @@ class ObservationZonePoint; * @param linebreaks True if each summary item should be separated with a line break */ void -OrderedTaskSummary(const OrderedTask *task, TCHAR *text, bool linebreaks); +OrderedTaskSummary(const OrderedTask *task, char *text, bool linebreaks); void -OrderedTaskPointLabel(TaskPointType type, const TCHAR *name, - unsigned index, TCHAR *buffer); +OrderedTaskPointLabel(TaskPointType type, const char *name, + unsigned index, char *buffer); -void OrderedTaskPointRadiusLabel(const ObservationZonePoint &ozp, TCHAR* radius); +void OrderedTaskPointRadiusLabel(const ObservationZonePoint &ozp, char* radius); bool OrderedTaskSave(OrderedTask &task); diff --git a/src/Dialogs/TextEntry.cpp b/src/Dialogs/TextEntry.cpp index 309a90f4b42..9e02b140f05 100644 --- a/src/Dialogs/TextEntry.cpp +++ b/src/Dialogs/TextEntry.cpp @@ -7,8 +7,8 @@ #include "Asset.hpp" bool -TextEntryDialog(TCHAR *text, size_t width, - const TCHAR *caption, AllowedCharacters accb, +TextEntryDialog(char *text, size_t width, + const char *caption, AllowedCharacters accb, bool default_shift_state) { switch (UIGlobals::GetDialogSettings().text_input_style) { diff --git a/src/Dialogs/TextEntry.hpp b/src/Dialogs/TextEntry.hpp index 0175b5f7805..7398070c88a 100644 --- a/src/Dialogs/TextEntry.hpp +++ b/src/Dialogs/TextEntry.hpp @@ -8,18 +8,18 @@ #include #include -typedef std::function AllowedCharacters; +typedef std::function AllowedCharacters; bool -TextEntryDialog(TCHAR *text, size_t size, - const TCHAR *caption=nullptr, +TextEntryDialog(char *text, size_t size, + const char *caption=nullptr, AllowedCharacters ac=AllowedCharacters(), bool default_shift_state = true); template static inline bool -TextEntryDialog(BasicStringBuffer &text, - const TCHAR *caption=NULL, +TextEntryDialog(BasicStringBuffer &text, + const char *caption=NULL, AllowedCharacters accb=AllowedCharacters(), bool default_shift_state = true) { @@ -29,8 +29,8 @@ TextEntryDialog(BasicStringBuffer &text, template static inline bool -TextEntryDialog(BasicStringBuffer &text, - const TCHAR *caption, +TextEntryDialog(BasicStringBuffer &text, + const char *caption, bool default_shift_state) { AllowedCharacters accb=AllowedCharacters(); @@ -39,11 +39,11 @@ TextEntryDialog(BasicStringBuffer &text, } void -KnobTextEntry(TCHAR *text, size_t width, - const TCHAR *caption); +KnobTextEntry(char *text, size_t width, + const char *caption); bool -TouchTextEntry(TCHAR *text, size_t size, - const TCHAR *caption=nullptr, +TouchTextEntry(char *text, size_t size, + const char *caption=nullptr, AllowedCharacters ac=AllowedCharacters(), bool default_shift_state = true); diff --git a/src/Dialogs/TimeEntry.cpp b/src/Dialogs/TimeEntry.cpp index 5b2d3fa12b3..8a563509ab5 100644 --- a/src/Dialogs/TimeEntry.cpp +++ b/src/Dialogs/TimeEntry.cpp @@ -15,7 +15,7 @@ enum { }; bool -TimeEntryDialog(const TCHAR *caption, RoughTime &value, +TimeEntryDialog(const char *caption, RoughTime &value, RoughTimeDelta time_zone, bool nullable) { /* create the dialog */ diff --git a/src/Dialogs/TimeEntry.hpp b/src/Dialogs/TimeEntry.hpp index e08ab5e7344..e454b0cc4dc 100644 --- a/src/Dialogs/TimeEntry.hpp +++ b/src/Dialogs/TimeEntry.hpp @@ -9,5 +9,5 @@ class RoughTime; class RoughTimeDelta; bool -TimeEntryDialog(const TCHAR *caption, RoughTime &value, +TimeEntryDialog(const char *caption, RoughTime &value, RoughTimeDelta time_zone, bool nullable=false); diff --git a/src/Dialogs/TouchTextEntry.cpp b/src/Dialogs/TouchTextEntry.cpp index 67ef72563bd..653360226ed 100644 --- a/src/Dialogs/TouchTextEntry.cpp +++ b/src/Dialogs/TouchTextEntry.cpp @@ -24,7 +24,7 @@ static AllowedCharacters AllowedCharactersCallback; static constexpr size_t MAX_TEXTENTRY = 40; static unsigned int cursor = 0; static size_t max_width; -static TCHAR edittext[MAX_TEXTENTRY]; +static char edittext[MAX_TEXTENTRY]; static void UpdateAllowedCharacters() @@ -60,7 +60,7 @@ OnBackspace() } static bool -DoCharacter(TCHAR character) +DoCharacter(char character) { if (cursor >= max_width - 1) return false; @@ -97,7 +97,7 @@ FormCharacter(unsigned ch) support yet */ return false; - DoCharacter((TCHAR)ch); + DoCharacter((char)ch); return true; } @@ -110,8 +110,8 @@ ClearText() } bool -TouchTextEntry(TCHAR *text, size_t width, - const TCHAR *caption, +TouchTextEntry(char *text, size_t width, + const char *caption, AllowedCharacters accb, bool default_shift_state) { diff --git a/src/Dialogs/Tracking/CloudEnableDialog.cpp b/src/Dialogs/Tracking/CloudEnableDialog.cpp index 345a33c9688..d82989c16d9 100644 --- a/src/Dialogs/Tracking/CloudEnableDialog.cpp +++ b/src/Dialogs/Tracking/CloudEnableDialog.cpp @@ -48,7 +48,7 @@ CloudEnableDialog() noexcept return; #endif - const TCHAR *msg = _("The XCSoar project is currently developing a revolutionary service which allows sharing thermal/wave locations and more with other pilots.\n" + const char *msg = _("The XCSoar project is currently developing a revolutionary service which allows sharing thermal/wave locations and more with other pilots.\n" "Do you wish to participate in the field test? This means that your position, thermal/wave locations and other weather data will be transmitted to our test server. You can disable it at any time in the \"Tracking\" settings.\n" "Please help us improve XCSoar!"); diff --git a/src/Dialogs/Traffic/FlarmTrafficDetails.cpp b/src/Dialogs/Traffic/FlarmTrafficDetails.cpp index fd1377c15ea..1c32b525819 100644 --- a/src/Dialogs/Traffic/FlarmTrafficDetails.cpp +++ b/src/Dialogs/Traffic/FlarmTrafficDetails.cpp @@ -146,8 +146,8 @@ FlarmTrafficDetailsWidget::Hide() noexcept void FlarmTrafficDetailsWidget::UpdateChanging(const MoreData &basic) { - TCHAR tmp[40]; - const TCHAR *value; + char tmp[40]; + const char *value; const FlarmTraffic* target = basic.flarm.traffic.FindTraffic(target_id); @@ -157,7 +157,7 @@ FlarmTrafficDetailsWidget::UpdateChanging(const MoreData &basic) // Fill distance/direction field if (target_ok) { FormatUserDistanceSmart(target->distance, tmp, true, 20, 1000); - TCHAR *p = tmp + strlen(tmp); + char *p = tmp + strlen(tmp); *p++ = _T(' '); FormatAngleDelta(p, 20, target->Bearing() - basic.track); value = tmp; @@ -168,7 +168,7 @@ FlarmTrafficDetailsWidget::UpdateChanging(const MoreData &basic) // Fill altitude field if (target_ok) { - TCHAR *p = tmp; + char *p = tmp; if (target->altitude_available) { FormatUserAltitude(target->altitude, p); p += strlen(p); @@ -202,8 +202,8 @@ FlarmTrafficDetailsWidget::UpdateChanging(const MoreData &basic) void FlarmTrafficDetailsWidget::Update() { - TCHAR tmp[200], tmp_id[7]; - const TCHAR *value; + char tmp[200], tmp_id[7]; + const char *value; // Set the dialog caption StringFormatUnsafe(tmp, _T("%s (%s)"), @@ -243,7 +243,7 @@ FlarmTrafficDetailsWidget::Update() const FlarmTraffic* target = CommonInterface::Basic().flarm.traffic.FindTraffic(target_id); - const TCHAR* actype; + const char* actype; if (target == nullptr || (actype = FlarmTraffic::GetTypeString(target->type)) == nullptr) actype = _T("--"); @@ -254,15 +254,15 @@ FlarmTrafficDetailsWidget::Update() // Fill the callsign field (+ registration) // note: don't use target->Name here since it is not updated // yet if it was changed - const TCHAR* cs = FlarmDetails::LookupCallsign(target_id); + const char* cs = FlarmDetails::LookupCallsign(target_id); if (cs != nullptr && cs[0] != 0) { try { - BasicStringBuilder builder(tmp, ARRAY_SIZE(tmp)); + BasicStringBuilder builder(tmp, ARRAY_SIZE(tmp)); builder.Append(cs); if (record) builder.Append(_T(" ("), record->registration.c_str(), _T(")")); value = tmp; - } catch (BasicStringBuilder::Overflow) { + } catch (BasicStringBuilder::Overflow) { value = cs; } } else diff --git a/src/Dialogs/Traffic/TeamCodeDialog.cpp b/src/Dialogs/Traffic/TeamCodeDialog.cpp index 96c6687381b..292109179bb 100644 --- a/src/Dialogs/Traffic/TeamCodeDialog.cpp +++ b/src/Dialogs/Traffic/TeamCodeDialog.cpp @@ -144,7 +144,7 @@ TeamCodeWidget::OnSetWaypointClicked() inline void TeamCodeWidget::OnCodeClicked() { - TCHAR newTeammateCode[10]; + char newTeammateCode[10]; CopyTruncateString(newTeammateCode, ARRAY_SIZE(newTeammateCode), CommonInterface::GetComputerSettings().team_code.team_code.GetCode()); @@ -166,7 +166,7 @@ TeamCodeWidget::OnFlarmLockClicked() { TeamCodeSettings &settings = CommonInterface::SetComputerSettings().team_code; - TCHAR newTeamFlarmCNTarget[decltype(settings.team_flarm_callsign)::capacity()]; + char newTeamFlarmCNTarget[decltype(settings.team_flarm_callsign)::capacity()]; strcpy(newTeamFlarmCNTarget, settings.team_flarm_callsign.c_str()); if (!TextEntryDialog(newTeamFlarmCNTarget, 4)) diff --git a/src/Dialogs/Traffic/TrafficDialogs.hpp b/src/Dialogs/Traffic/TrafficDialogs.hpp index 184c85e3cfa..6bb28f3b2c9 100644 --- a/src/Dialogs/Traffic/TrafficDialogs.hpp +++ b/src/Dialogs/Traffic/TrafficDialogs.hpp @@ -17,4 +17,4 @@ void TrafficListDialog(); FlarmId -PickFlarmTraffic(const TCHAR *title, FlarmId array[], unsigned count); +PickFlarmTraffic(const char *title, FlarmId array[], unsigned count); diff --git a/src/Dialogs/Traffic/TrafficList.cpp b/src/Dialogs/Traffic/TrafficList.cpp index a6fafddee62..df63bf446ef 100644 --- a/src/Dialogs/Traffic/TrafficList.cpp +++ b/src/Dialogs/Traffic/TrafficList.cpp @@ -78,7 +78,7 @@ class TrafficListWidget : public ListWidget, public DataFieldListener, bool loaded = false; const FlarmNetRecord *record; - const TCHAR *callsign; + const char *callsign; /** * This object's location. Check GeoPoint::IsValid(). @@ -356,7 +356,7 @@ TrafficListWidget::UpdateList() items.clear(); last_update.Clear(); - const TCHAR *callsign = filter_widget->GetValueString(CALLSIGN); + const char *callsign = filter_widget->GetValueString(CALLSIGN); if (!StringIsEmpty(callsign)) { FlarmId ids[30]; unsigned count = FlarmDetails::FindIdsByCallSign(callsign, ids, 30); @@ -571,7 +571,7 @@ TrafficListWidget::OnPaintItem(Canvas &canvas, PixelRect rc, item.AutoLoad(); const FlarmNetRecord *record = item.record; - const TCHAR *callsign = item.callsign; + const char *callsign = item.callsign; const DialogLook &look = UIGlobals::GetDialogLook(); const Font &name_font = *look.list.font_bold; @@ -580,7 +580,7 @@ TrafficListWidget::OnPaintItem(Canvas &canvas, PixelRect rc, const unsigned text_padding = Layout::GetTextPadding(); const unsigned frame_padding = text_padding / 2; - TCHAR tmp_id[10]; + char tmp_id[10]; item.id.Format(tmp_id); canvas.Select(name_font); @@ -765,7 +765,7 @@ TrafficListDialog() } FlarmId -PickFlarmTraffic(const TCHAR *title, FlarmId array[], unsigned count) +PickFlarmTraffic(const char *title, FlarmId array[], unsigned count) { assert(count > 0); diff --git a/src/Dialogs/Waypoint/WaypointInfoWidget.cpp b/src/Dialogs/Waypoint/WaypointInfoWidget.cpp index dfa032edcf6..e04854dc106 100644 --- a/src/Dialogs/Waypoint/WaypointInfoWidget.cpp +++ b/src/Dialogs/Waypoint/WaypointInfoWidget.cpp @@ -19,8 +19,8 @@ #include "Formatter/AngleFormatter.hpp" #include "Formatter/UserGeoPointFormatter.hpp" -static const TCHAR * -FormatGlideResult(TCHAR *buffer, size_t size, +static const char * +FormatGlideResult(char *buffer, size_t size, const GlideResult &result, const GlideSettings &settings) noexcept { @@ -42,12 +42,12 @@ FormatGlideResult(TCHAR *buffer, size_t size, } void -WaypointInfoWidget::AddGlideResult(const TCHAR *label, +WaypointInfoWidget::AddGlideResult(const char *label, const GlideResult &result) noexcept { const ComputerSettings &settings = CommonInterface::GetComputerSettings(); - TCHAR buffer[64]; + char buffer[64]; AddReadOnly(label, nullptr, FormatGlideResult(buffer, ARRAY_SIZE(buffer), result, settings.task.glide)); @@ -103,7 +103,7 @@ WaypointInfoWidget::Prepare(ContainerWindow &parent, if (!buffer.empty()) buffer += _T("; "); - TCHAR length_buffer[16]; + char length_buffer[16]; FormatSmallUserDistance(length_buffer, waypoint->runway.GetLength()); buffer += length_buffer; } diff --git a/src/Dialogs/Waypoint/WaypointInfoWidget.hpp b/src/Dialogs/Waypoint/WaypointInfoWidget.hpp index d208a2f4ce5..52f34533ecb 100644 --- a/src/Dialogs/Waypoint/WaypointInfoWidget.hpp +++ b/src/Dialogs/Waypoint/WaypointInfoWidget.hpp @@ -16,7 +16,7 @@ struct WaypointInfoWidget : public RowFormWidget { WaypointInfoWidget(const DialogLook &look, WaypointPtr _waypoint) noexcept :RowFormWidget(look), waypoint(std::move(_waypoint)) {} - void AddGlideResult(const TCHAR *label, const GlideResult &result) noexcept; + void AddGlideResult(const char *label, const GlideResult &result) noexcept; /* methods from Widget */ void Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept override; diff --git a/src/Dialogs/Waypoint/WaypointList.cpp b/src/Dialogs/Waypoint/WaypointList.cpp index 86ffaffc7b5..56bde04d531 100644 --- a/src/Dialogs/Waypoint/WaypointList.cpp +++ b/src/Dialogs/Waypoint/WaypointList.cpp @@ -57,7 +57,7 @@ static constexpr int direction_filter_items[] = { -1, -1, 0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330 }; -static const TCHAR *const type_filter_items[] = { +static const char *const type_filter_items[] = { _T("*"), _T("Airport"), _T("Landable"), _T("Turnpoint"), _T("Start"), @@ -218,8 +218,8 @@ class WaypointListButtons : public RowFormWidget { static WaypointListDialogState dialog_state; -static const TCHAR * -GetDirectionData(TCHAR *buffer, size_t size, int direction_filter_index, +static const char * +GetDirectionData(char *buffer, size_t size, int direction_filter_index, Angle heading) { if (direction_filter_index == 0) @@ -242,7 +242,7 @@ WaypointFilterWidget::Update(Angle _last_heading) DataFieldEnum &direction_df = *(DataFieldEnum *) direction_control.GetDataField(); - TCHAR buffer[22]; + char buffer[22]; direction_df.replaceEnumText(1, GetDirectionData(buffer, ARRAY_SIZE(buffer), 1, last_heading)); direction_control.RefreshDisplay(); @@ -319,8 +319,8 @@ WaypointListWidget::Prepare(ContainerWindow &parent, static DataField * CreateNameDataField(Waypoints &waypoints, DataFieldListener *listener) { - return new PrefixDataField(_T(""), [&waypoints](const TCHAR *prefix){ - static TCHAR buffer[256]; + return new PrefixDataField(_T(""), [&waypoints](const char *prefix){ + static char buffer[256]; return waypoints.SuggestNamePrefix(prefix, buffer, ARRAY_SIZE(buffer)); }, listener); } @@ -342,7 +342,7 @@ CreateDistanceDataField(DataFieldListener *listener) static DataField * CreateDirectionDataField(DataFieldListener *listener, Angle last_heading) { - TCHAR buffer[22]; + char buffer[22]; DataFieldEnum *df = new DataFieldEnum(listener); for (unsigned i = 0; i < ARRAY_SIZE(direction_filter_items); i++) df->addEnumText(GetDirectionData(buffer, ARRAY_SIZE(buffer), i, diff --git a/src/Dialogs/Waypoint/dlgWaypointDetails.cpp b/src/Dialogs/Waypoint/dlgWaypointDetails.cpp index ca5c4f9b22f..1fd361e1150 100644 --- a/src/Dialogs/Waypoint/dlgWaypointDetails.cpp +++ b/src/Dialogs/Waypoint/dlgWaypointDetails.cpp @@ -616,7 +616,7 @@ UpdateCaption(WndForm *form, const Waypoint &waypoint) buffer.Format(_T("%s: %s"), _("Waypoint"), waypoint.name.c_str()); std::string_view key{}; - const TCHAR *name = nullptr; + const char *name = nullptr; switch (waypoint.origin) { case WaypointOrigin::NONE: diff --git a/src/Dialogs/Weather/MapOverlayWidget.cpp b/src/Dialogs/Weather/MapOverlayWidget.cpp index 44f737ecb00..1a1009958c5 100644 --- a/src/Dialogs/Weather/MapOverlayWidget.cpp +++ b/src/Dialogs/Weather/MapOverlayWidget.cpp @@ -49,7 +49,7 @@ class WeatherMapOverlayListWidget final :name(_pc_met.label.c_str()), path(_pc_met.path.c_str()), pc_met(new PCMet::OverlayInfo(std::move(_pc_met))) {} - Item(const TCHAR *_name, Path _path) + Item(const char *_name, Path _path) :name(_name), path(_path) {} bool operator<(const Item &other) const { @@ -80,7 +80,7 @@ class WeatherMapOverlayListWidget final void CreateButtons(ButtonPanel &buttons); private: - int FindItemByName(const TCHAR *name) const { + int FindItemByName(const char *name) const { unsigned i = 0; for (const auto &item : items) { if (item.name == name) @@ -156,7 +156,7 @@ class WeatherMapOverlayListWidget final } /* virtual methods from TextListWidget */ - const TCHAR *GetRowText(unsigned i) const noexcept override { + const char *GetRowText(unsigned i) const noexcept override { return items[i].name.c_str(); } @@ -185,7 +185,7 @@ class WeatherMapOverlayListWidget final } private: - void SetOverlay(Path path, const TCHAR *label=nullptr); + void SetOverlay(Path path, const char *label=nullptr); void UseClicked(unsigned i); @@ -307,7 +307,7 @@ SetupOverlay(MapOverlayBitmap &bmp, Path::const_pointer name) } void -WeatherMapOverlayListWidget::SetOverlay(Path path, const TCHAR *label) +WeatherMapOverlayListWidget::SetOverlay(Path path, const char *label) { auto *map = UIGlobals::GetMap(); if (map == nullptr) @@ -339,7 +339,7 @@ WeatherMapOverlayListWidget::UseClicked(unsigned i) return; } - const TCHAR *label = nullptr; + const char *label = nullptr; auto &item = items[i]; if (item.pc_met) { const auto &info = *item.pc_met; diff --git a/src/Dialogs/Weather/NOAAList.cpp b/src/Dialogs/Weather/NOAAList.cpp index 767da7cc258..c8f9a5d9007 100644 --- a/src/Dialogs/Weather/NOAAList.cpp +++ b/src/Dialogs/Weather/NOAAList.cpp @@ -158,7 +158,7 @@ UpdateTask(NOAAStore::Item &item, ProgressListener &progress) noexcept inline void NOAAListWidget::AddClicked() { - TCHAR code[5] = _T(""); + char code[5] = _T(""); if (!TextEntryDialog(code, 5, _("Airport ICAO code"))) return; diff --git a/src/Dialogs/Weather/PCMetDialog.cpp b/src/Dialogs/Weather/PCMetDialog.cpp index 8bed39c58da..ffef9932494 100644 --- a/src/Dialogs/Weather/PCMetDialog.cpp +++ b/src/Dialogs/Weather/PCMetDialog.cpp @@ -88,7 +88,7 @@ class ImageAreaListWidget final : public TextListWidget { protected: /* virtual methods from TextListWidget */ - const TCHAR *GetRowText(unsigned i) const noexcept override { + const char *GetRowText(unsigned i) const noexcept override { return areas[i].display_name; } @@ -126,7 +126,7 @@ class ImageTypeListWidget final : public TextListWidget { protected: /* virtual methods from TextListWidget */ - const TCHAR *GetRowText(unsigned i) const noexcept override { + const char *GetRowText(unsigned i) const noexcept override { return PCMet::image_types[i].display_name; } diff --git a/src/Dialogs/Weather/RASPDialog.cpp b/src/Dialogs/Weather/RASPDialog.cpp index 4e57b6cfc86..502282e01b0 100644 --- a/src/Dialogs/Weather/RASPDialog.cpp +++ b/src/Dialogs/Weather/RASPDialog.cpp @@ -55,11 +55,11 @@ RASPSettingsPanel::FillItemControl() noexcept df.AddChoice(-1, _T("none"), _T("none"), nullptr); for (unsigned i = 0; i < rasp->GetItemCount(); i++) { const auto &mi = rasp->GetItemInfo(i); - const TCHAR *label = mi.label; + const char *label = mi.label; if (label != nullptr) label = gettext(label); - const TCHAR *help = mi.help; + const char *help = mi.help; if (help != nullptr) help = gettext(help); @@ -86,7 +86,7 @@ RASPSettingsPanel::UpdateTimeControl() noexcept time_df.addEnumText(_("Now")); rasp->ForEachTime(item_index, [&time_df](BrokenTime t){ - TCHAR timetext[10]; + char timetext[10]; _stprintf(timetext, _T("%02u:%02u"), t.hour, t.minute); time_df.addEnumText(timetext, t.GetMinuteOfDay()); }); diff --git a/src/Dialogs/Weather/WeatherDialog.cpp b/src/Dialogs/Weather/WeatherDialog.cpp index ac39f71cfc6..16af2592232 100644 --- a/src/Dialogs/Weather/WeatherDialog.cpp +++ b/src/Dialogs/Weather/WeatherDialog.cpp @@ -29,7 +29,7 @@ SetTitle(WndForm &form, const TabWidget &pager) } void -ShowWeatherDialog(const TCHAR *page) +ShowWeatherDialog(const char *page) { const DialogLook &look = UIGlobals::GetDialogLook(); diff --git a/src/Dialogs/Weather/WeatherDialog.hpp b/src/Dialogs/Weather/WeatherDialog.hpp index b8a14ec53df..71e372ed4e2 100644 --- a/src/Dialogs/Weather/WeatherDialog.hpp +++ b/src/Dialogs/Weather/WeatherDialog.hpp @@ -6,4 +6,4 @@ #include void -ShowWeatherDialog(const TCHAR *page); +ShowWeatherDialog(const char *page); diff --git a/src/Dialogs/WidgetDialog.cpp b/src/Dialogs/WidgetDialog.cpp index 6742bd663a6..da330ab4461 100644 --- a/src/Dialogs/WidgetDialog.cpp +++ b/src/Dialogs/WidgetDialog.cpp @@ -30,7 +30,7 @@ WidgetDialog::WidgetDialog(const DialogLook &look) } WidgetDialog::WidgetDialog(SingleWindow &parent, const DialogLook &look, - const PixelRect &rc, const TCHAR *caption, + const PixelRect &rc, const char *caption, Widget *_widget) noexcept :WndForm(parent, look, rc, caption, GetDialogStyle()), buttons(GetClientAreaWindow(), look.button), @@ -42,7 +42,7 @@ WidgetDialog::WidgetDialog(SingleWindow &parent, const DialogLook &look, } WidgetDialog::WidgetDialog(Auto, SingleWindow &parent, const DialogLook &look, - const TCHAR *caption) noexcept + const char *caption) noexcept :WndForm(parent, look, parent.GetClientRect(), caption, GetDialogStyle()), buttons(GetClientAreaWindow(), look.button), widget(GetClientAreaWindow()), @@ -51,7 +51,7 @@ WidgetDialog::WidgetDialog(Auto, SingleWindow &parent, const DialogLook &look, } WidgetDialog::WidgetDialog(Auto tag, SingleWindow &parent, const DialogLook &look, - const TCHAR *caption, + const char *caption, Widget *_widget) noexcept :WidgetDialog(tag, parent, look, caption) { @@ -60,7 +60,7 @@ WidgetDialog::WidgetDialog(Auto tag, SingleWindow &parent, const DialogLook &loo } WidgetDialog::WidgetDialog(Full, SingleWindow &parent, const DialogLook &look, - const TCHAR *caption) noexcept + const char *caption) noexcept :WndForm(parent, look, parent.GetClientRect(), caption, GetDialogStyle()), buttons(GetClientAreaWindow(), look.button), widget(GetClientAreaWindow()), @@ -69,7 +69,7 @@ WidgetDialog::WidgetDialog(Full, SingleWindow &parent, const DialogLook &look, } WidgetDialog::WidgetDialog(Full tag, SingleWindow &parent, const DialogLook &look, - const TCHAR *caption, + const char *caption, Widget *_widget) noexcept :WidgetDialog(tag, parent, look, caption) { @@ -238,7 +238,7 @@ WidgetDialog::OnAnyKeyDown(unsigned key_code) noexcept bool DefaultWidgetDialog(SingleWindow &parent, const DialogLook &look, - const TCHAR *caption, const PixelRect &rc, Widget &widget) + const char *caption, const PixelRect &rc, Widget &widget) { WidgetDialog dialog(parent, look, rc, caption, &widget); dialog.AddButton(_("OK"), mrOK); @@ -254,7 +254,7 @@ DefaultWidgetDialog(SingleWindow &parent, const DialogLook &look, bool DefaultWidgetDialog(SingleWindow &parent, const DialogLook &look, - const TCHAR *caption, Widget &widget) + const char *caption, Widget &widget) { WidgetDialog dialog(WidgetDialog::Auto{}, parent, look, caption, &widget); dialog.AddButton(_("OK"), mrOK); diff --git a/src/Dialogs/WidgetDialog.hpp b/src/Dialogs/WidgetDialog.hpp index 40f229369e4..647fd57f41f 100644 --- a/src/Dialogs/WidgetDialog.hpp +++ b/src/Dialogs/WidgetDialog.hpp @@ -28,7 +28,7 @@ class WidgetDialog : public WndForm { explicit WidgetDialog(const DialogLook &look); WidgetDialog(UI::SingleWindow &parent, const DialogLook &look, - const PixelRect &rc, const TCHAR *caption, + const PixelRect &rc, const char *caption, Widget *widget) noexcept; struct Auto {}; @@ -38,14 +38,14 @@ class WidgetDialog : public WndForm { * Call FinishPreliminary() to resume building the dialog. */ WidgetDialog(Auto, UI::SingleWindow &parent, const DialogLook &look, - const TCHAR *caption) noexcept; + const char *caption) noexcept; /** * Create a dialog with an automatic size (by * Widget::GetMinimumSize() and Widget::GetMaximumSize()). */ WidgetDialog(Auto, UI::SingleWindow &parent, const DialogLook &look, - const TCHAR *caption, Widget *widget) noexcept; + const char *caption, Widget *widget) noexcept; struct Full {}; @@ -54,13 +54,13 @@ class WidgetDialog : public WndForm { * Call FinishPreliminary() to resume building the dialog. */ WidgetDialog(Full, UI::SingleWindow &parent, const DialogLook &look, - const TCHAR *caption) noexcept; + const char *caption) noexcept; /** * Create a full-screen dialog. */ WidgetDialog(Full, UI::SingleWindow &parent, const DialogLook &look, - const TCHAR *caption, Widget *widget) noexcept; + const char *caption, Widget *widget) noexcept; virtual ~WidgetDialog(); @@ -98,16 +98,16 @@ class WidgetDialog : public WndForm { return buttons.Add(std::move(renderer), std::move(callback)); } - Button *AddButton(const TCHAR *caption, + Button *AddButton(const char *caption, Button::Callback callback) noexcept { return buttons.Add(caption, std::move(callback)); } - Button *AddButton(const TCHAR *caption, int modal_result) { + Button *AddButton(const char *caption, int modal_result) { return AddButton(caption, MakeModalResultCallback(modal_result)); } - Button *AddSymbolButton(const TCHAR *caption, + Button *AddSymbolButton(const char *caption, Button::Callback callback) noexcept { return buttons.AddSymbol(caption, std::move(callback)); } @@ -173,8 +173,8 @@ class TWidgetDialog final : public WidgetDialog { */ bool DefaultWidgetDialog(UI::SingleWindow &parent, const DialogLook &look, - const TCHAR *caption, const PixelRect &rc, Widget &widget); + const char *caption, const PixelRect &rc, Widget &widget); bool DefaultWidgetDialog(UI::SingleWindow &parent, const DialogLook &look, - const TCHAR *caption, Widget &widget); + const char *caption, Widget &widget); diff --git a/src/Dialogs/dlgAnalysis.cpp b/src/Dialogs/dlgAnalysis.cpp index dd4c7ef6ef1..7f859b29ed2 100644 --- a/src/Dialogs/dlgAnalysis.cpp +++ b/src/Dialogs/dlgAnalysis.cpp @@ -145,12 +145,12 @@ class AnalysisWidget final : public NullWidget { } void SetCalcVisibility(bool visible); - void SetCalcCaption(const TCHAR *caption); + void SetCalcCaption(const char *caption); void NextPage(int step); void Update(); - void OnGesture(const TCHAR *gesture); + void OnGesture(const char *gesture); private: void OnCalcClicked(); @@ -303,7 +303,7 @@ AnalysisWidget::SetCalcVisibility(bool visible) } void -AnalysisWidget::SetCalcCaption(const TCHAR *caption) +AnalysisWidget::SetCalcCaption(const char *caption) { details_button.SetCaption(caption); SetCalcVisibility(!StringIsEmpty(caption)); @@ -443,7 +443,7 @@ ChartControl::UpdateCrossSection(const MoreData &basic, void AnalysisWidget::Update() { - TCHAR sTmp[1000]; + char sTmp[1000]; const ComputerSettings &settings_computer = blackboard.GetComputerSettings(); const DerivedInfo &calculated = blackboard.Calculated(); @@ -586,7 +586,7 @@ AnalysisWidget::NextPage(int Step) } void -AnalysisWidget::OnGesture(const TCHAR *gesture) +AnalysisWidget::OnGesture(const char *gesture) { if (StringIsEqual(gesture, _T("R"))) NextPage(-1); @@ -619,7 +619,7 @@ ChartControl::OnMouseUp([[maybe_unused]] PixelPoint p) noexcept dragging = false; ReleaseCapture(); - const TCHAR *gesture = gestures.Finish(); + const char *gesture = gestures.Finish(); if (gesture != NULL) analysis_widget.OnGesture(gesture); } diff --git a/src/Dialogs/dlgCredits.cpp b/src/Dialogs/dlgCredits.cpp index 57b973491d5..5320cc3eb4d 100644 --- a/src/Dialogs/dlgCredits.cpp +++ b/src/Dialogs/dlgCredits.cpp @@ -68,7 +68,7 @@ LogoPageWindow::OnPaint(Canvas &canvas) noexcept canvas.SetTextColor(COLOR_BLACK); x = middle; - const TCHAR *version = _T("Version: "); + const char *version = _T("Version: "); PixelSize ts = canvas.CalcTextSize(version); PixelSize ts2 = canvas.CalcTextSize(OpenSoar_VersionString); x = middle - ((ts.width + ts2.width) / 2 ); @@ -80,7 +80,7 @@ LogoPageWindow::OnPaint(Canvas &canvas) noexcept #ifdef GIT_COMMIT_ID y += ts.height + Layout::FastScale(2); x = middle; - const TCHAR *git = _T("git: "); + const char *git = _T("git: "); ts = canvas.CalcTextSize(git); ts2 = canvas.CalcTextSize(_T(GIT_COMMIT_ID)); x = middle - ((ts.width + ts2.width) / 2 ); @@ -91,8 +91,8 @@ LogoPageWindow::OnPaint(Canvas &canvas) noexcept #endif y += Layout::FastScale(8); - const TCHAR *visit = _T("Vist us at:"); - const TCHAR *url = _T("https://xcsoar.org"); + const char *visit = _T("Vist us at:"); + const char *url = _T("https://xcsoar.org"); ts = canvas.CalcTextSize(visit); ts2 = canvas.CalcTextSize(url); x = middle - (ts.width / 2); diff --git a/src/Dialogs/dlgQuickMenu.cpp b/src/Dialogs/dlgQuickMenu.cpp index 5cae5f12961..00b83411e5a 100644 --- a/src/Dialogs/dlgQuickMenu.cpp +++ b/src/Dialogs/dlgQuickMenu.cpp @@ -31,7 +31,7 @@ class QuickMenuButtonRenderer final : public ButtonRenderer { public: explicit QuickMenuButtonRenderer(const DialogLook &_look, - const TCHAR *_caption) noexcept + const char *_caption) noexcept :look(_look), caption(_caption) { text_renderer.SetCenter(); text_renderer.SetVCenter(); @@ -149,7 +149,7 @@ QuickMenu::Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept if (!menuItem.IsDefined()) continue; - TCHAR buffer[100]; + char buffer[100]; const auto expanded = ButtonLabel::Expand(menuItem.label, std::span{buffer}); if (!expanded.visible) @@ -272,7 +272,7 @@ ShowQuickMenu(UI::SingleWindow &parent, const Menu &menu) noexcept } void dlgQuickMenuShowModal(UI::SingleWindow &parent, - [[maybe_unused]] const TCHAR *mode) noexcept + [[maybe_unused]] const char *mode) noexcept { const auto *menu = InputEvents::GetMenu(_T("RemoteStick")); if (menu == nullptr) diff --git a/src/Engine/Airspace/AbstractAirspace.cpp b/src/Engine/Airspace/AbstractAirspace.cpp index 51b2a0471e0..1cba550a2c8 100644 --- a/src/Engine/Airspace/AbstractAirspace.cpp +++ b/src/Engine/Airspace/AbstractAirspace.cpp @@ -170,7 +170,7 @@ AbstractAirspace::Intercept(const AircraftState &state, } bool -AbstractAirspace::MatchNamePrefix(const TCHAR *prefix) const noexcept +AbstractAirspace::MatchNamePrefix(const char *prefix) const noexcept { size_t prefix_length = strlen(prefix); return StringIsEqualIgnoreCase(name.c_str(), prefix, prefix_length); diff --git a/src/Engine/Airspace/AbstractAirspace.hpp b/src/Engine/Airspace/AbstractAirspace.hpp index 1321164c4c8..418af46ed87 100644 --- a/src/Engine/Airspace/AbstractAirspace.hpp +++ b/src/Engine/Airspace/AbstractAirspace.hpp @@ -241,7 +241,7 @@ class AbstractAirspace { * @return Type as text of airspace */ [[gnu::pure]] - const TCHAR *GetType() const noexcept { + const char *GetType() const noexcept { return astype.c_str(); } @@ -320,7 +320,7 @@ class AbstractAirspace { #endif [[gnu::pure]] - const TCHAR *GetName() const noexcept { + const char *GetName() const noexcept { return name.c_str(); } @@ -328,7 +328,7 @@ class AbstractAirspace { * Returns true if the name begins with the specified string. */ [[gnu::pure]] - bool MatchNamePrefix(const TCHAR *prefix) const noexcept; + bool MatchNamePrefix(const char *prefix) const noexcept; [[gnu::pure]] RadioFrequency GetRadioFrequency() const noexcept { diff --git a/src/Engine/Airspace/AirspaceSorter.hpp b/src/Engine/Airspace/AirspaceSorter.hpp index dad66f9ffcc..5fb6d197936 100644 --- a/src/Engine/Airspace/AirspaceSorter.hpp +++ b/src/Engine/Airspace/AirspaceSorter.hpp @@ -58,7 +58,7 @@ struct AirspaceFilterData { /** * Show only airspaces with a name beginning with this string. */ - const TCHAR *name_prefix = nullptr; + const char *name_prefix = nullptr; /** * Show only airspaces with a direction deviating less than 18 diff --git a/src/Engine/Contest/Solvers/Contests.cpp b/src/Engine/Contest/Solvers/Contests.cpp index 2eb4e4736a0..df7f18199cb 100644 --- a/src/Engine/Contest/Solvers/Contests.cpp +++ b/src/Engine/Contest/Solvers/Contests.cpp @@ -4,7 +4,7 @@ #include "Contests.hpp" #include "util/Macros.hpp" -static const TCHAR *const contest_to_string[] = { +static const char *const contest_to_string[] = { _T("OLC Sprint"), _T("OLC FAI"), _T("OLC Classic"), @@ -23,7 +23,7 @@ static const TCHAR *const contest_to_string[] = { _T("None"), }; -const TCHAR* +const char* ContestToString(Contest contest) noexcept { unsigned i = (unsigned)contest; diff --git a/src/Engine/Contest/Solvers/Contests.hpp b/src/Engine/Contest/Solvers/Contests.hpp index d2566b83bc1..9bc162d330a 100644 --- a/src/Engine/Contest/Solvers/Contests.hpp +++ b/src/Engine/Contest/Solvers/Contests.hpp @@ -9,5 +9,5 @@ enum class Contest : uint8_t; [[gnu::const]] -const TCHAR * +const char * ContestToString(Contest contest) noexcept; diff --git a/src/Engine/Waypoint/Waypoints.cpp b/src/Engine/Waypoint/Waypoints.cpp index cfabbd4b2df..200a01c4eef 100644 --- a/src/Engine/Waypoint/Waypoints.cpp +++ b/src/Engine/Waypoint/Waypoints.cpp @@ -13,7 +13,7 @@ Waypoints::WaypointNameTree::Get(tstring_view name) const noexcept if (name.size() >= NORMALIZE_BUFFER_SIZE) return {}; - TCHAR normalized_name[NORMALIZE_BUFFER_SIZE]; + char normalized_name[NORMALIZE_BUFFER_SIZE]; NormalizeSearchString(normalized_name, name); return RadixTree::Get(normalized_name, nullptr); } @@ -25,20 +25,20 @@ Waypoints::WaypointNameTree::VisitNormalisedPrefix(tstring_view prefix, if (prefix.size() >= NORMALIZE_BUFFER_SIZE) return; - TCHAR normalized[NORMALIZE_BUFFER_SIZE]; + char normalized[NORMALIZE_BUFFER_SIZE]; NormalizeSearchString(normalized, prefix); VisitPrefix(normalized, visitor); } -TCHAR * +char * Waypoints::WaypointNameTree::SuggestNormalisedPrefix(tstring_view prefix, - TCHAR *dest, + char *dest, size_t max_length) const noexcept { if (prefix.size() >= NORMALIZE_BUFFER_SIZE) return nullptr; - TCHAR normalized[NORMALIZE_BUFFER_SIZE]; + char normalized[NORMALIZE_BUFFER_SIZE]; NormalizeSearchString(normalized, prefix); return Suggest(normalized, dest, max_length); } @@ -46,7 +46,7 @@ Waypoints::WaypointNameTree::SuggestNormalisedPrefix(tstring_view prefix, inline void Waypoints::WaypointNameTree::Add(WaypointPtr wp) noexcept { - AllocatedArray buffer(wp->name.length() + 1); + AllocatedArray buffer(wp->name.length() + 1); NormalizeSearchString(buffer.data(), wp->name); RadixTree::Add(buffer.data(), wp); @@ -60,7 +60,7 @@ Waypoints::WaypointNameTree::Add(WaypointPtr wp) noexcept inline void Waypoints::WaypointNameTree::Remove(const WaypointPtr &wp) noexcept { - AllocatedArray buffer(wp->name.length() + 1); + AllocatedArray buffer(wp->name.length() + 1); NormalizeSearchString(buffer.data(), wp->name); RadixTree::Remove(buffer.data(), wp); diff --git a/src/Engine/Waypoint/Waypoints.hpp b/src/Engine/Waypoint/Waypoints.hpp index 0b6f49458cc..70f9cb12d7c 100644 --- a/src/Engine/Waypoint/Waypoints.hpp +++ b/src/Engine/Waypoint/Waypoints.hpp @@ -47,8 +47,8 @@ class Waypoints { WaypointPtr Get(tstring_view name) const noexcept; void VisitNormalisedPrefix(tstring_view prefix, const WaypointVisitor &visitor) const; - TCHAR *SuggestNormalisedPrefix(tstring_view prefix, - TCHAR *dest, size_t max_length) const noexcept; + char *SuggestNormalisedPrefix(tstring_view prefix, + char *dest, size_t max_length) const noexcept; void Add(WaypointPtr wp) noexcept; void Remove(const WaypointPtr &wp) noexcept; }; @@ -289,8 +289,8 @@ class Waypoints { * prefix. */ [[gnu::pure]] - TCHAR *SuggestNamePrefix(tstring_view prefix, - TCHAR *dest, size_t max_length) const noexcept { + char *SuggestNamePrefix(tstring_view prefix, + char *dest, size_t max_length) const noexcept { return name_tree.SuggestNormalisedPrefix(prefix, dest, max_length); } diff --git a/src/FLARM/Computer.cpp b/src/FLARM/Computer.cpp index 2b1323a8709..09e577c70fc 100644 --- a/src/FLARM/Computer.cpp +++ b/src/FLARM/Computer.cpp @@ -47,7 +47,7 @@ FlarmComputer::Process(FlarmData &flarm, const FlarmData &last_flarm, // if we don't know the target's name yet if (!traffic.HasName()) { // lookup the name of this target's id - const TCHAR *fname = FlarmDetails::LookupCallsign(traffic.id); + const char *fname = FlarmDetails::LookupCallsign(traffic.id); if (fname != NULL) traffic.name = fname; } diff --git a/src/FLARM/Details.cpp b/src/FLARM/Details.cpp index 907fc32a9ca..1317a36fb30 100644 --- a/src/FLARM/Details.cpp +++ b/src/FLARM/Details.cpp @@ -21,7 +21,7 @@ LookupRecord(FlarmId id) noexcept return traffic_databases->flarm_net.FindRecordById(id); } -const TCHAR * +const char * LookupCallsign(FlarmId id) noexcept { if (traffic_databases == nullptr) @@ -31,7 +31,7 @@ LookupCallsign(FlarmId id) noexcept } FlarmId -LookupId(const TCHAR *cn) noexcept +LookupId(const char *cn) noexcept { assert(traffic_databases != nullptr); @@ -39,7 +39,7 @@ LookupId(const TCHAR *cn) noexcept } bool -AddSecondaryItem(FlarmId id, const TCHAR *name) noexcept +AddSecondaryItem(FlarmId id, const char *name) noexcept { assert(id.IsDefined()); assert(traffic_databases != nullptr); @@ -48,7 +48,7 @@ AddSecondaryItem(FlarmId id, const TCHAR *name) noexcept } unsigned -FindIdsByCallSign(const TCHAR *cn, FlarmId array[], unsigned size) noexcept +FindIdsByCallSign(const char *cn, FlarmId array[], unsigned size) noexcept { assert(cn != NULL); assert(!StringIsEmpty(cn)); diff --git a/src/FLARM/Details.hpp b/src/FLARM/Details.hpp index 20b8e5ca7f6..b508f8e6520 100644 --- a/src/FLARM/Details.hpp +++ b/src/FLARM/Details.hpp @@ -27,7 +27,7 @@ LookupRecord(FlarmId id) noexcept; * @return The corresponding callsign if found, otherwise NULL */ [[gnu::pure]] -const TCHAR * +const char * LookupCallsign(FlarmId id) noexcept; /** @@ -38,7 +38,7 @@ LookupCallsign(FlarmId id) noexcept; */ [[gnu::pure]] FlarmId -LookupId(const TCHAR *cn) noexcept; +LookupId(const char *cn) noexcept; /** * Adds a FLARM details couple (callsign + FLARM id) @@ -48,9 +48,9 @@ LookupId(const TCHAR *cn) noexcept; * @return True if successfully added, False otherwise */ bool -AddSecondaryItem(FlarmId id, const TCHAR *name) noexcept; +AddSecondaryItem(FlarmId id, const char *name) noexcept; unsigned -FindIdsByCallSign(const TCHAR *cn, FlarmId array[], unsigned size) noexcept; +FindIdsByCallSign(const char *cn, FlarmId array[], unsigned size) noexcept; } // namespace FlarmDetails diff --git a/src/FLARM/Error.cpp b/src/FLARM/Error.cpp index 54ebcc3ee92..f87c3f394ad 100644 --- a/src/FLARM/Error.cpp +++ b/src/FLARM/Error.cpp @@ -5,14 +5,14 @@ #include "util/Macros.hpp" #include "Language/Language.hpp" -static const TCHAR *const severity_strings[] = { +static const char *const severity_strings[] = { N_("No error"), N_("Information"), N_("Reduced functionality"), N_("Fatal problem"), }; -const TCHAR * +const char * FlarmError::ToString(Severity severity) noexcept { unsigned i = (unsigned)severity; @@ -23,7 +23,7 @@ FlarmError::ToString(Severity severity) noexcept static constexpr struct { FlarmError::Code code; - const TCHAR *string; + const char *string; } error_strings[] = { { FlarmError::Code::FIRMWARE_TIMEOUT, N_("Firmware timeout") }, { FlarmError::Code::POWER, N_("Power") }, @@ -41,7 +41,7 @@ static constexpr struct { { FlarmError::Code::OTHER, nullptr } }; -const TCHAR * +const char * FlarmError::ToString(Code code) noexcept { for (auto i = error_strings; i->string != nullptr; ++i) diff --git a/src/FLARM/Error.hpp b/src/FLARM/Error.hpp index ef42478290e..8115c2ac664 100644 --- a/src/FLARM/Error.hpp +++ b/src/FLARM/Error.hpp @@ -74,7 +74,7 @@ struct FlarmError { * value. */ [[gnu::const]] - static const TCHAR *ToString(Severity severity) noexcept; + static const char *ToString(Severity severity) noexcept; /** * Returns a human-readable translatable string for the given value. @@ -82,15 +82,15 @@ struct FlarmError { * value. */ [[gnu::const]] - static const TCHAR *ToString(Code code) noexcept; + static const char *ToString(Code code) noexcept; [[gnu::pure]] - const TCHAR *GetSeverityString() const noexcept { + const char *GetSeverityString() const noexcept { return ToString(severity); } [[gnu::pure]] - const TCHAR *GetCodeString() const noexcept { + const char *GetCodeString() const noexcept { return ToString(code); } }; diff --git a/src/FLARM/FlarmNetDatabase.cpp b/src/FLARM/FlarmNetDatabase.cpp index 2790a396259..1a9c44c6363 100644 --- a/src/FLARM/FlarmNetDatabase.cpp +++ b/src/FLARM/FlarmNetDatabase.cpp @@ -18,7 +18,7 @@ FlarmNetDatabase::Insert(const FlarmNetRecord &record) noexcept } const FlarmNetRecord * -FlarmNetDatabase::FindFirstRecordByCallSign(const TCHAR *cn) const noexcept +FlarmNetDatabase::FindFirstRecordByCallSign(const char *cn) const noexcept { for (const auto &[id, record] : map) { assert(id.IsDefined()); @@ -31,7 +31,7 @@ FlarmNetDatabase::FindFirstRecordByCallSign(const TCHAR *cn) const noexcept } unsigned -FlarmNetDatabase::FindRecordsByCallSign(const TCHAR *cn, +FlarmNetDatabase::FindRecordsByCallSign(const char *cn, const FlarmNetRecord *array[], [[maybe_unused]] unsigned size) const noexcept { @@ -48,7 +48,7 @@ FlarmNetDatabase::FindRecordsByCallSign(const TCHAR *cn, } unsigned -FlarmNetDatabase::FindIdsByCallSign(const TCHAR *cn, FlarmId array[], +FlarmNetDatabase::FindIdsByCallSign(const char *cn, FlarmId array[], [[maybe_unused]] unsigned size) const noexcept { unsigned count = 0; diff --git a/src/FLARM/FlarmNetDatabase.hpp b/src/FLARM/FlarmNetDatabase.hpp index 63cf07abd6c..ee0a6d5a21d 100644 --- a/src/FLARM/FlarmNetDatabase.hpp +++ b/src/FLARM/FlarmNetDatabase.hpp @@ -46,12 +46,12 @@ class FlarmNetDatabase { * @return FLARMNetRecord object */ [[gnu::pure]] - const FlarmNetRecord *FindFirstRecordByCallSign(const TCHAR *cn) const noexcept; + const FlarmNetRecord *FindFirstRecordByCallSign(const char *cn) const noexcept; - unsigned FindRecordsByCallSign(const TCHAR *cn, + unsigned FindRecordsByCallSign(const char *cn, const FlarmNetRecord *array[], unsigned size) const noexcept; - unsigned FindIdsByCallSign(const TCHAR *cn, FlarmId array[], + unsigned FindIdsByCallSign(const char *cn, FlarmId array[], unsigned size) const noexcept; [[gnu::pure]] diff --git a/src/FLARM/FlarmNetReader.cpp b/src/FLARM/FlarmNetReader.cpp index 7280694733e..651c664e744 100644 --- a/src/FLARM/FlarmNetReader.cpp +++ b/src/FLARM/FlarmNetReader.cpp @@ -21,12 +21,12 @@ * @param res Pointer to be written in */ static void -LoadString(const char *bytes, size_t length, TCHAR *res, [[maybe_unused]] size_t res_size) +LoadString(const char *bytes, size_t length, char *res, [[maybe_unused]] size_t res_size) { const char *const end = bytes + length * 2; const char *const limit = res + res_size - 2; - TCHAR *p = res; + char *p = res; char tmp[3]; tmp[2] = 0; @@ -82,7 +82,7 @@ LoadRecord(FlarmNetRecord &record, const char *line) LoadString(line + 158, 7, record.frequency); // Terminate callsign string on first whitespace - for (TCHAR *i = record.callsign.buffer(); *i != _T('\0'); ++i) + for (char *i = record.callsign.buffer(); *i != _T('\0'); ++i) if (IsWhitespaceFast(*i)) *i = _T('\0'); diff --git a/src/FLARM/List.hpp b/src/FLARM/List.hpp index 120364403e0..da06a0ed140 100644 --- a/src/FLARM/List.hpp +++ b/src/FLARM/List.hpp @@ -121,7 +121,7 @@ struct TrafficList { * @param name the name or call sign * @return the FLARM_TRAFFIC pointer, NULL if not found */ - constexpr FlarmTraffic *FindTraffic(const TCHAR *name) noexcept { + constexpr FlarmTraffic *FindTraffic(const char *name) noexcept { for (auto &traffic : list) if (traffic.name.equals(name)) return &traffic; @@ -135,7 +135,7 @@ struct TrafficList { * @param name the name or call sign * @return the FLARM_TRAFFIC pointer, NULL if not found */ - constexpr const FlarmTraffic *FindTraffic(const TCHAR *name) const noexcept { + constexpr const FlarmTraffic *FindTraffic(const char *name) const noexcept { for (const auto &traffic : list) if (traffic.name.equals(name)) return &traffic; diff --git a/src/FLARM/NameDatabase.cpp b/src/FLARM/NameDatabase.cpp index bb83dcf98c1..a858aa28e4c 100644 --- a/src/FLARM/NameDatabase.cpp +++ b/src/FLARM/NameDatabase.cpp @@ -16,7 +16,7 @@ FlarmNameDatabase::Find(FlarmId id) const noexcept } int -FlarmNameDatabase::Find(const TCHAR *name) const noexcept +FlarmNameDatabase::Find(const char *name) const noexcept { assert(name != nullptr); @@ -27,7 +27,7 @@ FlarmNameDatabase::Find(const TCHAR *name) const noexcept return -1; } -const TCHAR * +const char * FlarmNameDatabase::Get(FlarmId id) const noexcept { int i = Find(id); @@ -38,7 +38,7 @@ FlarmNameDatabase::Get(FlarmId id) const noexcept } FlarmId -FlarmNameDatabase::Get(const TCHAR *name) const noexcept +FlarmNameDatabase::Get(const char *name) const noexcept { int i = Find(name); if (i < 0) @@ -48,7 +48,7 @@ FlarmNameDatabase::Get(const TCHAR *name) const noexcept } unsigned -FlarmNameDatabase::Get(const TCHAR *name, +FlarmNameDatabase::Get(const char *name, FlarmId *buffer, unsigned max) const noexcept { assert(name != nullptr); @@ -64,7 +64,7 @@ FlarmNameDatabase::Get(const TCHAR *name, } bool -FlarmNameDatabase::Set(FlarmId id, const TCHAR *name) noexcept +FlarmNameDatabase::Set(FlarmId id, const char *name) noexcept { assert(id.IsDefined()); assert(name != nullptr); diff --git a/src/FLARM/NameDatabase.hpp b/src/FLARM/NameDatabase.hpp index 6d081780432..ba416132c53 100644 --- a/src/FLARM/NameDatabase.hpp +++ b/src/FLARM/NameDatabase.hpp @@ -17,7 +17,7 @@ class FlarmNameDatabase { StaticString<21> name; Record() = default; - Record(FlarmId _id, const TCHAR *_name) noexcept + Record(FlarmId _id, const char *_name) noexcept :id(_id), name(_name) {} }; @@ -41,10 +41,10 @@ class FlarmNameDatabase { } [[gnu::pure]] - const TCHAR *Get(FlarmId id) const noexcept; + const char *Get(FlarmId id) const noexcept; [[gnu::pure]] - FlarmId Get(const TCHAR *name) const noexcept; + FlarmId Get(const char *name) const noexcept; /** * Look up all records with the specified name. @@ -52,15 +52,15 @@ class FlarmNameDatabase { * @param max the maximum size of the given buffer * @return the number of items copied to the given buffer */ - unsigned Get(const TCHAR *name, + unsigned Get(const char *name, FlarmId *buffer, unsigned max) const noexcept; - bool Set(FlarmId id, const TCHAR *name) noexcept; + bool Set(FlarmId id, const char *name) noexcept; protected: [[gnu::pure]] int Find(FlarmId id) const noexcept; [[gnu::pure]] - int Find(const TCHAR *name) const noexcept; + int Find(const char *name) const noexcept; }; diff --git a/src/FLARM/NameFile.cpp b/src/FLARM/NameFile.cpp index 56f1b57b348..3a2e7cab1dd 100644 --- a/src/FLARM/NameFile.cpp +++ b/src/FLARM/NameFile.cpp @@ -33,7 +33,7 @@ LoadFlarmNameFile(BufferedReader &reader, FlarmNameDatabase &db) void SaveFlarmNameFile(BufferedOutputStream &writer, FlarmNameDatabase &db) { - TCHAR id[16]; + char id[16]; for (const auto &i : db) { assert(i.id.IsDefined()); diff --git a/src/FLARM/Traffic.cpp b/src/FLARM/Traffic.cpp index 624418f963e..aee6ec4fc89 100644 --- a/src/FLARM/Traffic.cpp +++ b/src/FLARM/Traffic.cpp @@ -3,14 +3,14 @@ #include "FLARM/Traffic.hpp" -static constexpr const TCHAR *acTypes[] = { +static constexpr const char *acTypes[] = { _T("Unknown"), _T("Glider"), _T("TowPlane"), _T("Helicopter"), _T("Parachute"), _T("DropPlane"), _T("HangGlider"), _T("ParaGlider"), _T("PoweredAircraft"), _T("JetAircraft"), _T("FlyingSaucer"), _T("Balloon"), _T("Airship"), _T("UAV"), _T("Unknown"), _T("StaticObject") }; -const TCHAR * +const char * FlarmTraffic::GetTypeString(AircraftType type) noexcept { std::size_t index = static_cast(type); diff --git a/src/FLARM/Traffic.hpp b/src/FLARM/Traffic.hpp index 9ba70cca35d..d85d6ac871a 100644 --- a/src/FLARM/Traffic.hpp +++ b/src/FLARM/Traffic.hpp @@ -164,7 +164,7 @@ struct FlarmTraffic { } [[gnu::const]] - static const TCHAR *GetTypeString(AircraftType type) noexcept; + static const char *GetTypeString(AircraftType type) noexcept; void Update(const FlarmTraffic &other) noexcept; }; diff --git a/src/FLARM/TrafficDatabases.cpp b/src/FLARM/TrafficDatabases.cpp index c577833d6fd..b0e20d699ab 100644 --- a/src/FLARM/TrafficDatabases.cpp +++ b/src/FLARM/TrafficDatabases.cpp @@ -4,11 +4,11 @@ #include "TrafficDatabases.hpp" #include "util/StringCompare.hxx" -const TCHAR * +const char * TrafficDatabases::FindNameById(FlarmId id) const noexcept { // try to find flarm from userFile - const TCHAR *name = flarm_names.Get(id); + const char *name = flarm_names.Get(id); if (name != nullptr) return name; @@ -21,7 +21,7 @@ TrafficDatabases::FindNameById(FlarmId id) const noexcept } FlarmId -TrafficDatabases::FindIdByName(const TCHAR *name) const noexcept +TrafficDatabases::FindIdByName(const char *name) const noexcept { assert(!StringIsEmpty(name)); @@ -39,7 +39,7 @@ TrafficDatabases::FindIdByName(const TCHAR *name) const noexcept } unsigned -TrafficDatabases::FindIdsByName(const TCHAR *name, +TrafficDatabases::FindIdsByName(const char *name, FlarmId *buffer, unsigned max) const noexcept { assert(!StringIsEmpty(name)); diff --git a/src/FLARM/TrafficDatabases.hpp b/src/FLARM/TrafficDatabases.hpp index 18c4e2a4e84..010f8e44208 100644 --- a/src/FLARM/TrafficDatabases.hpp +++ b/src/FLARM/TrafficDatabases.hpp @@ -36,10 +36,10 @@ struct TrafficDatabases { } [[gnu::pure]] - const TCHAR *FindNameById(FlarmId id) const noexcept; + const char *FindNameById(FlarmId id) const noexcept; [[gnu::pure]] [[gnu::nonnull]] - FlarmId FindIdByName(const TCHAR *name) const noexcept; + FlarmId FindIdByName(const char *name) const noexcept; /** * Look up all records with the specified name. @@ -48,6 +48,6 @@ struct TrafficDatabases { * @return the number of items copied to the given buffer */ [[gnu::nonnull]] - unsigned FindIdsByName(const TCHAR *name, + unsigned FindIdsByName(const char *name, FlarmId *buffer, unsigned max) const noexcept; }; diff --git a/src/Form/Button.cpp b/src/Form/Button.cpp index bd187900c2e..8a2c50386c6 100644 --- a/src/Form/Button.cpp +++ b/src/Form/Button.cpp @@ -15,7 +15,7 @@ Button::Button(ContainerWindow &parent, const PixelRect &rc, } Button::Button(ContainerWindow &parent, const ButtonLook &look, - const TCHAR *caption, const PixelRect &rc, + const char *caption, const PixelRect &rc, WindowStyle style, Callback _callback) noexcept { @@ -40,7 +40,7 @@ Button::Create(ContainerWindow &parent, void Button::Create(ContainerWindow &parent, const ButtonLook &look, - const TCHAR *caption, const PixelRect &rc, + const char *caption, const PixelRect &rc, WindowStyle style) { Create(parent, rc, style, std::make_unique(look, caption)); @@ -58,7 +58,7 @@ Button::Create(ContainerWindow &parent, const PixelRect &rc, void Button::Create(ContainerWindow &parent, const ButtonLook &look, - const TCHAR *caption, const PixelRect &rc, + const char *caption, const PixelRect &rc, WindowStyle style, Callback _callback) noexcept { Create(parent, rc, style, @@ -67,7 +67,7 @@ Button::Create(ContainerWindow &parent, const ButtonLook &look, } void -Button::SetCaption(const TCHAR *caption) +Button::SetCaption(const char *caption) { assert(caption != nullptr); diff --git a/src/Form/Button.hpp b/src/Form/Button.hpp index 8ebd33f4f43..43d92e75f88 100644 --- a/src/Form/Button.hpp +++ b/src/Form/Button.hpp @@ -43,7 +43,7 @@ class Button : public PaintWindow { Callback _callback) noexcept; Button(ContainerWindow &parent, const ButtonLook &look, - const TCHAR *caption, const PixelRect &rc, + const char *caption, const PixelRect &rc, WindowStyle style, Callback _callback) noexcept; @@ -55,7 +55,7 @@ class Button : public PaintWindow { WindowStyle style, std::unique_ptr _renderer); void Create(ContainerWindow &parent, const ButtonLook &look, - const TCHAR *caption, const PixelRect &rc, + const char *caption, const PixelRect &rc, WindowStyle style); void Create(ContainerWindow &parent, const PixelRect &rc, @@ -63,7 +63,7 @@ class Button : public PaintWindow { Callback _callback) noexcept; void Create(ContainerWindow &parent, const ButtonLook &look, - const TCHAR *caption, const PixelRect &rc, + const char *caption, const PixelRect &rc, WindowStyle style, Callback _callback) noexcept; @@ -87,7 +87,7 @@ class Button : public PaintWindow { * #TextButtonRenderer and may only be used if created with a * #TextButtonRenderer instance. */ - void SetCaption(const TCHAR *caption); + void SetCaption(const char *caption); void SetSelected(bool _selected); diff --git a/src/Form/ButtonPanel.cpp b/src/Form/ButtonPanel.cpp index a49ef17390f..93f8c4855c9 100644 --- a/src/Form/ButtonPanel.cpp +++ b/src/Form/ButtonPanel.cpp @@ -56,14 +56,14 @@ ButtonPanel::Add(std::unique_ptr &&renderer, } Button * -ButtonPanel::Add(const TCHAR *caption, Button::Callback callback) noexcept +ButtonPanel::Add(const char *caption, Button::Callback callback) noexcept { return Add(std::make_unique(look, caption), std::move(callback)); } Button * -ButtonPanel::AddSymbol(const TCHAR *caption, +ButtonPanel::AddSymbol(const char *caption, Button::Callback callback) noexcept { return Add(std::make_unique(look, caption), diff --git a/src/Form/ButtonPanel.hpp b/src/Form/ButtonPanel.hpp index 6301e6bef0b..95a47e19703 100644 --- a/src/Form/ButtonPanel.hpp +++ b/src/Form/ButtonPanel.hpp @@ -56,13 +56,13 @@ class ButtonPanel { Button *Add(std::unique_ptr &&renderer, Button::Callback callback) noexcept; - Button *Add(const TCHAR *caption, Button::Callback callback) noexcept; + Button *Add(const char *caption, Button::Callback callback) noexcept; /** * Add a symbol button. The caption is one of the "special" * #WndSymbolButton strings. */ - Button *AddSymbol(const TCHAR *caption, Button::Callback callback) noexcept; + Button *AddSymbol(const char *caption, Button::Callback callback) noexcept; /** * Assign a hot key to the most recently added button. diff --git a/src/Form/CharacterButton.cpp b/src/Form/CharacterButton.cpp index 60392415afa..cbd2b777aa3 100644 --- a/src/Form/CharacterButton.cpp +++ b/src/Form/CharacterButton.cpp @@ -9,7 +9,7 @@ void CharacterButton::Create(ContainerWindow &parent, const ButtonLook &look, - const TCHAR *text, PixelRect rc, + const char *text, PixelRect rc, OnCharacterCallback _on_character, unsigned _character, const WindowStyle style) noexcept { @@ -25,7 +25,7 @@ unsigned CharacterButton::GetUpperCharacter() const noexcept { unsigned result = character; - if (result < 0x80 && IsLowerAlphaASCII((TCHAR)result)) + if (result < 0x80 && IsLowerAlphaASCII((char)result)) result -= 'a' - 'A'; return result; } diff --git a/src/Form/CharacterButton.hpp b/src/Form/CharacterButton.hpp index 15f1308963f..babfae468a7 100644 --- a/src/Form/CharacterButton.hpp +++ b/src/Form/CharacterButton.hpp @@ -18,7 +18,7 @@ class CharacterButton : public Button { public: void Create(ContainerWindow &parent, const ButtonLook &look, - const TCHAR *text, PixelRect rc, + const char *text, PixelRect rc, OnCharacterCallback on_character, unsigned character, const WindowStyle _style=WindowStyle()) noexcept; diff --git a/src/Form/Control.cpp b/src/Form/Control.cpp index 2e412cc595e..1e04fa2bbe1 100644 --- a/src/Form/Control.cpp +++ b/src/Form/Control.cpp @@ -11,7 +11,7 @@ WindowControl::WindowControl() noexcept } void -WindowControl::SetCaption(const TCHAR *Value) noexcept +WindowControl::SetCaption(const char *Value) noexcept { if (Value == nullptr) Value = _T(""); diff --git a/src/Form/Control.hpp b/src/Form/Control.hpp index ae91b8afc6a..1a7ee4ec7ad 100644 --- a/src/Form/Control.hpp +++ b/src/Form/Control.hpp @@ -21,7 +21,7 @@ class WindowControl : public PaintWindow { private: /** Helptext of the Control */ - const TCHAR *help_text = nullptr; + const char *help_text = nullptr; public: WindowControl() noexcept; @@ -46,7 +46,7 @@ class WindowControl : public PaintWindow { * Returns the Caption/Text of the Control * @return The Caption/Text of the Control */ - const TCHAR *GetCaption() const noexcept { + const char *GetCaption() const noexcept { return caption.c_str(); } @@ -54,17 +54,17 @@ class WindowControl : public PaintWindow { * Sets the Caption/Text of the Control * @param Value The new Caption/Text of the Control */ - void SetCaption(const TCHAR *Value) noexcept; + void SetCaption(const char *Value) noexcept; /** * Sets the Helptext of the Control * @param Value The new Helptext of the Control */ - void SetHelpText(const TCHAR *_help_text) noexcept { + void SetHelpText(const char *_help_text) noexcept { help_text = _help_text; } - const TCHAR *GetHelpText() const noexcept { + const char *GetHelpText() const noexcept { return help_text; } }; diff --git a/src/Form/DataField/Angle.cpp b/src/Form/DataField/Angle.cpp index a8b74de9fdf..9b67cce2771 100644 --- a/src/Form/DataField/Angle.cpp +++ b/src/Form/DataField/Angle.cpp @@ -50,14 +50,14 @@ AngleDataField::ModifyValue(Angle _value) noexcept Modified(); } -const TCHAR * +const char * AngleDataField::GetAsString() const noexcept { _stprintf(string_buffer, _T("%u"), GetIntegerValue()); return string_buffer; } -const TCHAR * +const char * AngleDataField::GetAsDisplayString() const noexcept { _stprintf(string_buffer, _T("%u°"), GetIntegerValue()); @@ -77,7 +77,7 @@ AngleDataField::Dec() noexcept } void -AngleDataField::SetFromCombo(int i, [[maybe_unused]] const TCHAR *s) noexcept +AngleDataField::SetFromCombo(int i, [[maybe_unused]] const char *s) noexcept { assert(i >= 0); assert(unsigned(i) < MAX); @@ -88,14 +88,14 @@ AngleDataField::SetFromCombo(int i, [[maybe_unused]] const TCHAR *s) noexcept static void AppendComboValue(ComboList &combo_list, unsigned value) noexcept { - TCHAR buffer1[16], buffer2[16]; + char buffer1[16], buffer2[16]; _stprintf(buffer1, _T("%u"), value); _stprintf(buffer2, _T("%u°"), value); combo_list.Append(value, buffer1, buffer2); } ComboList -AngleDataField::CreateComboList([[maybe_unused]] const TCHAR *reference) const noexcept +AngleDataField::CreateComboList([[maybe_unused]] const char *reference) const noexcept { ComboList combo_list; diff --git a/src/Form/DataField/Angle.hpp b/src/Form/DataField/Angle.hpp index 4992c7982d4..19a759268f9 100644 --- a/src/Form/DataField/Angle.hpp +++ b/src/Form/DataField/Angle.hpp @@ -22,7 +22,7 @@ class AngleDataField final : public DataField { /** * For GetAsString(). Must be mutable because the method is const. */ - mutable TCHAR string_buffer[16]; + mutable char string_buffer[16]; public: AngleDataField(unsigned _value, unsigned _step, bool _fine, @@ -78,12 +78,12 @@ class AngleDataField final : public DataField { void ModifyValue(Angle _value) noexcept; /* virtual methods from class DataField */ - const TCHAR *GetAsString() const noexcept override; - const TCHAR *GetAsDisplayString() const noexcept override; + const char *GetAsString() const noexcept override; + const char *GetAsDisplayString() const noexcept override; void Inc() noexcept override; void Dec() noexcept override; - ComboList CreateComboList(const TCHAR *reference) const noexcept override; - void SetFromCombo(int i, const TCHAR *s) noexcept override; + ComboList CreateComboList(const char *reference) const noexcept override; + void SetFromCombo(int i, const char *s) noexcept override; }; diff --git a/src/Form/DataField/Base.cpp b/src/Form/DataField/Base.cpp index 7852ce55eb2..6d4a34bb8bf 100644 --- a/src/Form/DataField/Base.cpp +++ b/src/Form/DataField/Base.cpp @@ -35,20 +35,20 @@ DataField::Dec() noexcept { } -const TCHAR * +const char * DataField::GetAsString() const noexcept { return nullptr; } -const TCHAR * +const char * DataField::GetAsDisplayString() const noexcept { return GetAsString(); } ComboList -DataField::CreateComboList([[maybe_unused]] const TCHAR *reference) const noexcept +DataField::CreateComboList([[maybe_unused]] const char *reference) const noexcept { return ComboList(); } diff --git a/src/Form/DataField/Base.hpp b/src/Form/DataField/Base.hpp index 2baa41ae7e0..a251ccd9f10 100644 --- a/src/Form/DataField/Base.hpp +++ b/src/Form/DataField/Base.hpp @@ -84,10 +84,10 @@ class DataField virtual void Dec() noexcept; [[gnu::pure]] - virtual const TCHAR *GetAsString() const noexcept; + virtual const char *GetAsString() const noexcept; [[gnu::pure]] - virtual const TCHAR *GetAsDisplayString() const noexcept; + virtual const char *GetAsDisplayString() const noexcept; virtual void EnableItemHelp([[maybe_unused]] bool value) noexcept {}; @@ -99,10 +99,10 @@ class DataField * "default" reference */ [[gnu::pure]] - virtual ComboList CreateComboList(const TCHAR *reference) const noexcept; + virtual ComboList CreateComboList(const char *reference) const noexcept; virtual void SetFromCombo([[maybe_unused]] int iDataFieldIndex, - [[maybe_unused]] const TCHAR *sValue) noexcept + [[maybe_unused]] const char *sValue) noexcept { /* this method must be implemented by all classes which also implement CreateComboList() */ diff --git a/src/Form/DataField/Boolean.cpp b/src/Form/DataField/Boolean.cpp index 9e007b7d8ef..a78b5f8f179 100644 --- a/src/Form/DataField/Boolean.cpp +++ b/src/Form/DataField/Boolean.cpp @@ -5,7 +5,7 @@ #include "ComboList.hpp" ComboList -DataFieldBoolean::CreateComboList([[maybe_unused]] const TCHAR *reference) const noexcept +DataFieldBoolean::CreateComboList([[maybe_unused]] const char *reference) const noexcept { ComboList combo_list; combo_list.Append(false, false_text); @@ -16,12 +16,12 @@ DataFieldBoolean::CreateComboList([[maybe_unused]] const TCHAR *reference) const } void -DataFieldBoolean::SetFromCombo(int i, const TCHAR *) noexcept +DataFieldBoolean::SetFromCombo(int i, const char *) noexcept { ModifyValue(i != 0); } -const TCHAR * +const char * DataFieldBoolean::GetAsString() const noexcept { return mValue ? true_text : false_text; diff --git a/src/Form/DataField/Boolean.hpp b/src/Form/DataField/Boolean.hpp index 8c55dba337b..cde56e2e256 100644 --- a/src/Form/DataField/Boolean.hpp +++ b/src/Form/DataField/Boolean.hpp @@ -15,7 +15,7 @@ class DataFieldBoolean final : public DataField { public: DataFieldBoolean(bool _value, - const TCHAR *_true_text, const TCHAR *_false_text, + const char *_true_text, const char *_false_text, DataFieldListener *listener=nullptr) noexcept :DataField(Type::BOOLEAN, true, listener), mValue(_value), @@ -39,7 +39,7 @@ class DataFieldBoolean final : public DataField { /* virtual methods from class DataField */ void Inc() noexcept override; void Dec() noexcept override; - const TCHAR *GetAsString() const noexcept override; - ComboList CreateComboList(const TCHAR *reference) const noexcept override; - void SetFromCombo(int i, const TCHAR *s) noexcept override; + const char *GetAsString() const noexcept override; + ComboList CreateComboList(const char *reference) const noexcept override; + void SetFromCombo(int i, const char *s) noexcept override; }; diff --git a/src/Form/DataField/ComboList.cpp b/src/Form/DataField/ComboList.cpp index a70e48ba4f4..a8ec0438baf 100644 --- a/src/Form/DataField/ComboList.cpp +++ b/src/Form/DataField/ComboList.cpp @@ -7,9 +7,9 @@ #include ComboList::Item::Item(int _int_value, - const TCHAR *_string_value, - const TCHAR *_display_string, - const TCHAR *_help_text) noexcept + const char *_string_value, + const char *_display_string, + const char *_help_text) noexcept :int_value(_int_value), string_value(_string_value), display_string(_display_string), diff --git a/src/Form/DataField/ComboList.hpp b/src/Form/DataField/ComboList.hpp index 25b500a97a0..28b4145bbc7 100644 --- a/src/Form/DataField/ComboList.hpp +++ b/src/Form/DataField/ComboList.hpp @@ -20,9 +20,9 @@ class ComboList { tstring display_string; tstring help_text; - Item(int _int_value, const TCHAR *_string_value, - const TCHAR *_display_string, - const TCHAR *_help_text = nullptr) noexcept; + Item(int _int_value, const char *_string_value, + const char *_display_string, + const char *_help_text = nullptr) noexcept; Item(const Item &other) = delete; Item &operator=(const Item &other) = delete; @@ -69,26 +69,26 @@ class ComboList { } unsigned Append(int int_value, - const TCHAR *string_value, - const TCHAR *display_string, - const TCHAR *help_text = nullptr) noexcept { + const char *string_value, + const char *display_string, + const char *help_text = nullptr) noexcept { unsigned i = items.size(); items.emplace_back(int_value, string_value, display_string, help_text); return i; } - unsigned Append(const TCHAR *string_value, - const TCHAR *display_string, - const TCHAR *help_text = nullptr) noexcept { + unsigned Append(const char *string_value, + const char *display_string, + const char *help_text = nullptr) noexcept { return Append(items.size(), string_value, display_string, help_text); } - unsigned Append(int int_value, const TCHAR *string_value) noexcept { + unsigned Append(int int_value, const char *string_value) noexcept { return Append(int_value, string_value, string_value); } - unsigned Append(const TCHAR *string_value) noexcept { + unsigned Append(const char *string_value) noexcept { return Append(string_value, string_value); } diff --git a/src/Form/DataField/Date.cpp b/src/Form/DataField/Date.cpp index ff8c31e646c..b26de8ffc68 100644 --- a/src/Form/DataField/Date.cpp +++ b/src/Form/DataField/Date.cpp @@ -4,7 +4,7 @@ #include "Date.hpp" #include "Formatter/TimeFormatter.hpp" -const TCHAR * +const char * DataFieldDate::GetAsString() const noexcept { FormatISO8601(string_buffer, value); diff --git a/src/Form/DataField/Date.hpp b/src/Form/DataField/Date.hpp index 194445e295d..1d8bf102331 100644 --- a/src/Form/DataField/Date.hpp +++ b/src/Form/DataField/Date.hpp @@ -9,7 +9,7 @@ class DataFieldDate final : public DataField { BrokenDate value; - mutable TCHAR string_buffer[OUTBUFFERSIZE + 1]; + mutable char string_buffer[OUTBUFFERSIZE + 1]; public: DataFieldDate(BrokenDate _value, DataFieldListener *listener) noexcept @@ -31,5 +31,5 @@ class DataFieldDate final : public DataField { Modified(); } - const TCHAR *GetAsString() const noexcept override; + const char *GetAsString() const noexcept override; }; diff --git a/src/Form/DataField/Enum.cpp b/src/Form/DataField/Enum.cpp index 184f70ddb98..6907310bd1e 100644 --- a/src/Form/DataField/Enum.cpp +++ b/src/Form/DataField/Enum.cpp @@ -21,7 +21,7 @@ DataFieldEnum::Entry::~Entry() noexcept } void -DataFieldEnum::Entry::SetString(const TCHAR *_string) noexcept +DataFieldEnum::Entry::SetString(const char *_string) noexcept { free(string); if (display_string != string) @@ -31,7 +31,7 @@ DataFieldEnum::Entry::SetString(const TCHAR *_string) noexcept } void -DataFieldEnum::Entry::SetDisplayString(const TCHAR *_string) noexcept +DataFieldEnum::Entry::SetDisplayString(const char *_string) noexcept { if (display_string != string) free(display_string); @@ -39,9 +39,9 @@ DataFieldEnum::Entry::SetDisplayString(const TCHAR *_string) noexcept } void -DataFieldEnum::Entry::Set(unsigned _id, const TCHAR *_string, - const TCHAR *_display_string, - const TCHAR *_help) noexcept +DataFieldEnum::Entry::Set(unsigned _id, const char *_string, + const char *_display_string, + const char *_help) noexcept { id = _id; SetString(_string); @@ -61,16 +61,16 @@ DataFieldEnum::GetValue() const noexcept } void -DataFieldEnum::replaceEnumText(std::size_t i, const TCHAR *Text) noexcept +DataFieldEnum::replaceEnumText(std::size_t i, const char *Text) noexcept { if (i <= entries.size()) entries[i].SetString(Text); } bool -DataFieldEnum::AddChoice(unsigned id, const TCHAR *text, - const TCHAR *display_string, - const TCHAR *help) noexcept +DataFieldEnum::AddChoice(unsigned id, const char *text, + const char *display_string, + const char *help) noexcept { if (entries.full()) return false; @@ -84,7 +84,7 @@ void DataFieldEnum::AddChoices(const StaticEnumChoice *p) noexcept { while (p->display_string != nullptr) { - const TCHAR *help = p->help; + const char *help = p->help; if (help != nullptr) help = gettext(help); @@ -94,8 +94,8 @@ DataFieldEnum::AddChoices(const StaticEnumChoice *p) noexcept } unsigned -DataFieldEnum::addEnumText(const TCHAR *Text, const TCHAR *display_string, - const TCHAR *_help) noexcept +DataFieldEnum::addEnumText(const char *Text, const char *display_string, + const char *_help) noexcept { if (entries.full()) return 0; @@ -107,13 +107,13 @@ DataFieldEnum::addEnumText(const TCHAR *Text, const TCHAR *display_string, } void -DataFieldEnum::addEnumTexts(const TCHAR *const*list) noexcept +DataFieldEnum::addEnumTexts(const char *const*list) noexcept { while (*list != nullptr) addEnumText(*list++); } -const TCHAR * +const char * DataFieldEnum::GetAsString() const noexcept { if (entries.empty()) { @@ -125,7 +125,7 @@ DataFieldEnum::GetAsString() const noexcept } } -const TCHAR * +const char * DataFieldEnum::GetAsDisplayString() const noexcept { if (entries.empty()) { @@ -137,7 +137,7 @@ DataFieldEnum::GetAsDisplayString() const noexcept } } -const TCHAR * +const char * DataFieldEnum::GetHelp() const noexcept { if (entries.empty()) { @@ -157,7 +157,7 @@ DataFieldEnum::SetValue(unsigned Value) noexcept } bool -DataFieldEnum::SetValue(const TCHAR *text) noexcept +DataFieldEnum::SetValue(const char *text) noexcept { int i = Find(text); if (i < 0) @@ -179,7 +179,7 @@ DataFieldEnum::ModifyValue(unsigned new_value) noexcept } bool -DataFieldEnum::ModifyValue(const TCHAR *text) noexcept +DataFieldEnum::ModifyValue(const char *text) noexcept { int i = Find(text); if (i < 0) @@ -190,7 +190,7 @@ DataFieldEnum::ModifyValue(const TCHAR *text) noexcept } int -DataFieldEnum::SetStringAutoAdd(const TCHAR *text) noexcept +DataFieldEnum::SetStringAutoAdd(const char *text) noexcept { int index = Find(text); if (index >= 0) { @@ -247,7 +247,7 @@ DataFieldEnum::Sort(std::size_t startindex) noexcept } ComboList -DataFieldEnum::CreateComboList([[maybe_unused]] const TCHAR *reference_string) const noexcept +DataFieldEnum::CreateComboList([[maybe_unused]] const char *reference_string) const noexcept { ComboList combo_list; @@ -260,13 +260,13 @@ DataFieldEnum::CreateComboList([[maybe_unused]] const TCHAR *reference_string) c } void -DataFieldEnum::SetFromCombo(int i, const TCHAR *) noexcept +DataFieldEnum::SetFromCombo(int i, const char *) noexcept { ModifyValue(i); } int -DataFieldEnum::Find(const TCHAR *text) const noexcept +DataFieldEnum::Find(const char *text) const noexcept { assert(text != nullptr); diff --git a/src/Form/DataField/Enum.hpp b/src/Form/DataField/Enum.hpp index e641ed14542..035ea55c81b 100644 --- a/src/Form/DataField/Enum.hpp +++ b/src/Form/DataField/Enum.hpp @@ -14,8 +14,8 @@ */ struct StaticEnumChoice { unsigned id; - const TCHAR *display_string; - const TCHAR *help; + const char *display_string; + const char *help; constexpr StaticEnumChoice(std::nullptr_t n) noexcept :id(0), display_string(n), help(n) {} @@ -23,8 +23,8 @@ struct StaticEnumChoice { template requires(std::is_same_v || std::is_same_v || std::is_enum_v) - constexpr StaticEnumChoice(T _id, const TCHAR *_display_string, - const TCHAR *_help=nullptr) noexcept + constexpr StaticEnumChoice(T _id, const char *_display_string, + const char *_help=nullptr) noexcept :id(static_cast(_id)), display_string(_display_string), help(_help) {} }; @@ -32,9 +32,9 @@ class DataFieldEnum final : public DataField { public: class Entry { unsigned id; - TCHAR *string; - TCHAR *display_string; - TCHAR *help; + char *string; + char *display_string; + char *help; public: Entry() noexcept:string(nullptr), display_string(nullptr), help(nullptr) {} @@ -67,23 +67,23 @@ class DataFieldEnum final : public DataField { return id; } - const TCHAR *GetString() const noexcept { + const char *GetString() const noexcept { return string; } - const TCHAR *GetDisplayString() const noexcept { + const char *GetDisplayString() const noexcept { return display_string; } - const TCHAR *GetHelp() const noexcept { + const char *GetHelp() const noexcept { return help; } - void SetString(const TCHAR *_string) noexcept; - void SetDisplayString(const TCHAR *_string) noexcept; - void Set(unsigned _id, const TCHAR *_string, - const TCHAR *_display_string=nullptr, - const TCHAR *_help=nullptr) noexcept; + void SetString(const char *_string) noexcept; + void SetDisplayString(const char *_string) noexcept; + void Set(unsigned _id, const char *_string, + const char *_display_string=nullptr, + const char *_help=nullptr) noexcept; }; private: @@ -98,13 +98,13 @@ class DataFieldEnum final : public DataField { unsigned GetValue() const noexcept; [[gnu::pure]] - bool Exists(const TCHAR *text) const noexcept { + bool Exists(const char *text) const noexcept { return Find(text) >= 0; } - void replaceEnumText(std::size_t index, const TCHAR *Text) noexcept; + void replaceEnumText(std::size_t index, const char *Text) noexcept; - void SetDisplayString(std::size_t index, const TCHAR *_string) noexcept { + void SetDisplayString(std::size_t index, const char *_string) noexcept { entries[index].SetDisplayString(_string); } @@ -117,9 +117,9 @@ class DataFieldEnum final : public DataField { value = 0; } - bool AddChoice(unsigned id, const TCHAR *text, - const TCHAR *display_string=nullptr, - const TCHAR *help=nullptr) noexcept; + bool AddChoice(unsigned id, const char *text, + const char *display_string=nullptr, + const char *help=nullptr) noexcept; /** * Add choices from the specified nullptr-terminated list (the last @@ -128,19 +128,19 @@ class DataFieldEnum final : public DataField { */ void AddChoices(const StaticEnumChoice *list) noexcept; - bool addEnumText(const TCHAR *text, unsigned id, - const TCHAR *help=nullptr) noexcept { + bool addEnumText(const char *text, unsigned id, + const char *help=nullptr) noexcept { return AddChoice(id, text, nullptr, help); } - unsigned addEnumText(const TCHAR *Text, const TCHAR *display_string=nullptr, - const TCHAR *ItemHelpText=nullptr) noexcept; - void addEnumTexts(const TCHAR *const*list) noexcept; + unsigned addEnumText(const char *Text, const char *display_string=nullptr, + const char *ItemHelpText=nullptr) noexcept; + void addEnumTexts(const char *const*list) noexcept; /** * @return help of current enum item or nullptr if current item has no help */ - const TCHAR *GetHelp() const noexcept; + const char *GetHelp() const noexcept; /** * @param value True if display item help in text box below picker @@ -165,7 +165,7 @@ class DataFieldEnum final : public DataField { * @return false if an item with the specified text was not found, * and therefore the value was not changed */ - bool SetValue(const TCHAR *text) noexcept; + bool SetValue(const char *text) noexcept; bool ModifyValue(unsigned new_value) noexcept; @@ -175,7 +175,7 @@ class DataFieldEnum final : public DataField { return ModifyValue(unsigned(value)); } - bool ModifyValue(const TCHAR *text) noexcept; + bool ModifyValue(const char *text) noexcept; /** * Set the value to the specified string. If there is no choice @@ -183,7 +183,7 @@ class DataFieldEnum final : public DataField { * * @return the new integer value */ - int SetStringAutoAdd(const TCHAR *text) noexcept; + int SetStringAutoAdd(const char *text) noexcept; void Sort(std::size_t startindex = 0) noexcept; @@ -199,17 +199,17 @@ class DataFieldEnum final : public DataField { /* virtual methods from class DataField */ void Inc() noexcept override; void Dec() noexcept override; - const TCHAR *GetAsString() const noexcept override; - const TCHAR *GetAsDisplayString() const noexcept override; - ComboList CreateComboList(const TCHAR *reference) const noexcept override; - void SetFromCombo(int iDataFieldIndex, const TCHAR *sValue) noexcept override; + const char *GetAsString() const noexcept override; + const char *GetAsDisplayString() const noexcept override; + ComboList CreateComboList(const char *reference) const noexcept override; + void SetFromCombo(int iDataFieldIndex, const char *sValue) noexcept override; protected: /** * Finds an entry with the specified text. Returns -1 if not found. */ [[gnu::pure]] - int Find(const TCHAR *text) const noexcept; + int Find(const char *text) const noexcept; [[gnu::pure]] int Find(unsigned id) const noexcept; diff --git a/src/Form/DataField/File.cpp b/src/Form/DataField/File.cpp index 214c52b9929..14b0556e254 100644 --- a/src/Form/DataField/File.cpp +++ b/src/Form/DataField/File.cpp @@ -20,9 +20,9 @@ */ [[gnu::pure]] static bool -IsInternalFile(const TCHAR *str) noexcept +IsInternalFile(const char *str) noexcept { - static const TCHAR *const ifiles[] = { + static const char *const ifiles[] = { _T("xcsoar-checklist.txt"), _T("xcsoar-flarm.txt"), _T("xcsoar-marks.txt"), @@ -73,7 +73,7 @@ FileDataField::FileDataField(DataFieldListener *listener) noexcept postponed_value(nullptr) {} void -FileDataField::ScanDirectoryTop(const TCHAR *filter) noexcept +FileDataField::ScanDirectoryTop(const char *filter) noexcept { if (!loaded) { if (!postponed_patterns.full() && @@ -91,7 +91,7 @@ FileDataField::ScanDirectoryTop(const TCHAR *filter) noexcept } void -FileDataField::ScanMultiplePatterns(const TCHAR *patterns) noexcept +FileDataField::ScanMultiplePatterns(const char *patterns) noexcept { size_t length; while ((length = strlen(patterns)) > 0) { @@ -209,7 +209,7 @@ FileDataField::AddNull() noexcept item.path = Path(_T("")); } -const TCHAR * +const char * FileDataField::GetAsString() const noexcept { if (!loaded && postponed_value != nullptr) @@ -221,7 +221,7 @@ FileDataField::GetAsString() const noexcept return _T(""); } -const TCHAR * +const char * FileDataField::GetAsDisplayString() const noexcept { if (!loaded && postponed_value != nullptr) { @@ -305,7 +305,7 @@ FileDataField::Sort() noexcept } ComboList -FileDataField::CreateComboList([[maybe_unused]] const TCHAR *reference) const noexcept +FileDataField::CreateComboList([[maybe_unused]] const char *reference) const noexcept { /* sorry for the const_cast .. this method keeps the promise of not modifying the object, given that one does not count filling the @@ -314,7 +314,7 @@ FileDataField::CreateComboList([[maybe_unused]] const TCHAR *reference) const no ComboList combo_list; - TCHAR buffer[MAX_PATH]; + char buffer[MAX_PATH]; for (unsigned i = 0; i < files.size(); i++) { const Path path = files[i].filename; @@ -331,7 +331,7 @@ FileDataField::CreateComboList([[maybe_unused]] const TCHAR *reference) const no } } - const TCHAR *display_string = path.c_str(); + const char *display_string = path.c_str(); if (found) { /* yes - append the absolute path to allow the user to see the difference */ @@ -351,7 +351,7 @@ FileDataField::CreateComboList([[maybe_unused]] const TCHAR *reference) const no } void -FileDataField::SetFromCombo(int i, const TCHAR *) noexcept +FileDataField::SetFromCombo(int i, const char *) noexcept { ModifyIndex(i); } diff --git a/src/Form/DataField/File.hpp b/src/Form/DataField/File.hpp index 666c0ae2ce5..1f2764d53f7 100644 --- a/src/Form/DataField/File.hpp +++ b/src/Form/DataField/File.hpp @@ -147,13 +147,13 @@ class FileDataField final : public DataField { /** Sorts the filelist by filenames */ void Sort() noexcept; - void ScanDirectoryTop(const TCHAR *filter) noexcept; + void ScanDirectoryTop(const char *filter) noexcept; /** * Scan multiple shell patterns. Each pattern is terminated by a * null byte, and the list ends with an empty pattern. */ - void ScanMultiplePatterns(const TCHAR *patterns) noexcept; + void ScanMultiplePatterns(const char *patterns) noexcept; /** For use by other classes */ [[gnu::pure]] @@ -165,10 +165,10 @@ class FileDataField final : public DataField { /* virtual methods from class DataField */ void Inc() noexcept override; void Dec() noexcept override; - const TCHAR *GetAsString() const noexcept override; - const TCHAR *GetAsDisplayString() const noexcept override; - ComboList CreateComboList(const TCHAR *reference) const noexcept override; - void SetFromCombo(int i, const TCHAR *s) noexcept override; + const char *GetAsString() const noexcept override; + const char *GetAsDisplayString() const noexcept override; + ComboList CreateComboList(const char *reference) const noexcept override; + void SetFromCombo(int i, const char *s) noexcept override; protected: void EnsureLoaded() noexcept; diff --git a/src/Form/DataField/Float.cpp b/src/Form/DataField/Float.cpp index 0c5318d0941..24508cf14a2 100644 --- a/src/Form/DataField/Float.cpp +++ b/src/Form/DataField/Float.cpp @@ -10,14 +10,14 @@ static bool DataFieldKeyUp = false; -const TCHAR * +const char * DataFieldFloat::GetAsString() const noexcept { _stprintf(mOutBuf, edit_format, (double)mValue); return mOutBuf; } -const TCHAR * +const char * DataFieldFloat::GetAsDisplayString() const noexcept { _stprintf(mOutBuf, display_format, (double)mValue, unit.c_str()); @@ -84,7 +84,7 @@ DataFieldFloat::SpeedUp(bool keyup) noexcept } void -DataFieldFloat::SetFromCombo([[maybe_unused]] int iDataFieldIndex, const TCHAR *sValue) noexcept +DataFieldFloat::SetFromCombo([[maybe_unused]] int iDataFieldIndex, const char *sValue) noexcept { ModifyValue(ParseDouble(sValue)); } @@ -93,14 +93,14 @@ void DataFieldFloat::AppendComboValue(ComboList &combo_list, double value) const noexcept { - TCHAR a[decltype(edit_format)::capacity()], b[decltype(display_format)::capacity()]; + char a[decltype(edit_format)::capacity()], b[decltype(display_format)::capacity()]; _stprintf(a, edit_format, (double)value); _stprintf(b, display_format, (double)value, unit.c_str()); combo_list.Append(a, b); } ComboList -DataFieldFloat::CreateComboList(const TCHAR *reference_string) const noexcept +DataFieldFloat::CreateComboList(const char *reference_string) const noexcept { const auto reference = reference_string != nullptr ? ParseDouble(reference_string) diff --git a/src/Form/DataField/Float.hpp b/src/Form/DataField/Float.hpp index 366c087f267..8965b8b9064 100644 --- a/src/Form/DataField/Float.hpp +++ b/src/Form/DataField/Float.hpp @@ -17,13 +17,13 @@ class DataFieldFloat final : public NumberDataField { StaticString<8> unit; - mutable TCHAR mOutBuf[OUTBUFFERSIZE+1]; + mutable char mOutBuf[OUTBUFFERSIZE+1]; protected: double SpeedUp(bool keyup) noexcept; public: - DataFieldFloat(const TCHAR *edit_format, const TCHAR *display_format, + DataFieldFloat(const char *edit_format, const char *display_format, double _min, double _max, double _value, double _step, bool _fine, DataFieldListener *listener=nullptr) noexcept @@ -32,7 +32,7 @@ class DataFieldFloat final : public NumberDataField { mSpeedup(0), mFine(_fine), unit(_T("")) {} - void SetUnits(const TCHAR *text) noexcept { + void SetUnits(const char *text) noexcept { unit = text; } @@ -65,10 +65,10 @@ class DataFieldFloat final : public NumberDataField { /* virtual methods from class DataField */ void Inc() noexcept override; void Dec() noexcept override; - const TCHAR *GetAsString() const noexcept override; - const TCHAR *GetAsDisplayString() const noexcept override; - ComboList CreateComboList(const TCHAR *reference) const noexcept override; - void SetFromCombo(int iDataFieldIndex, const TCHAR *sValue) noexcept override; + const char *GetAsString() const noexcept override; + const char *GetAsDisplayString() const noexcept override; + ComboList CreateComboList(const char *reference) const noexcept override; + void SetFromCombo(int iDataFieldIndex, const char *sValue) noexcept override; protected: void AppendComboValue(ComboList &combo_list, double value) const noexcept; diff --git a/src/Form/DataField/GeoPoint.cpp b/src/Form/DataField/GeoPoint.cpp index 8c30f5ba0d9..32c6363f9c6 100644 --- a/src/Form/DataField/GeoPoint.cpp +++ b/src/Form/DataField/GeoPoint.cpp @@ -14,7 +14,7 @@ GeoPointDataField::ModifyValue(GeoPoint _value) noexcept Modified(); } -const TCHAR * +const char * GeoPointDataField::GetAsString() const noexcept { if (!value.IsValid()) diff --git a/src/Form/DataField/GeoPoint.hpp b/src/Form/DataField/GeoPoint.hpp index e7b16a275ca..4ca541987cf 100644 --- a/src/Form/DataField/GeoPoint.hpp +++ b/src/Form/DataField/GeoPoint.hpp @@ -18,7 +18,7 @@ class GeoPointDataField final : public DataField { /** * For GetAsString(). Must be mutable because the method is const. */ - mutable TCHAR string_buffer[64]; + mutable char string_buffer[64]; public: GeoPointDataField(GeoPoint _value, CoordinateFormat _format, @@ -41,5 +41,5 @@ class GeoPointDataField final : public DataField { void ModifyValue(GeoPoint _value) noexcept; /* virtual methods from class DataField */ - const TCHAR *GetAsString() const noexcept override; + const char *GetAsString() const noexcept override; }; diff --git a/src/Form/DataField/Integer.cpp b/src/Form/DataField/Integer.cpp index fb58a957a5d..bfd57af4624 100644 --- a/src/Form/DataField/Integer.cpp +++ b/src/Form/DataField/Integer.cpp @@ -11,19 +11,19 @@ static bool datafield_key_up = false; [[gnu::pure]] static int -ParseString(const TCHAR *s) noexcept +ParseString(const char *s) noexcept { return ParseInt(s); } -const TCHAR * +const char * DataFieldInteger::GetAsString() const noexcept { _stprintf(output_buffer, edit_format, value); return output_buffer; } -const TCHAR * +const char * DataFieldInteger::GetAsDisplayString() const noexcept { _stprintf(output_buffer, display_format, value); @@ -83,14 +83,14 @@ void DataFieldInteger::AppendComboValue(ComboList &combo_list, int value) const noexcept { - TCHAR a[decltype(edit_format)::capacity()], b[decltype(display_format)::capacity()]; + char a[decltype(edit_format)::capacity()], b[decltype(display_format)::capacity()]; _stprintf(a, edit_format, value); _stprintf(b, display_format, value); combo_list.Append(combo_list.size(), a, b); } ComboList -DataFieldInteger::CreateComboList(const TCHAR *reference_string) const noexcept +DataFieldInteger::CreateComboList(const char *reference_string) const noexcept { const int reference = reference_string != nullptr ? ParseString(reference_string) @@ -144,7 +144,7 @@ DataFieldInteger::CreateComboList(const TCHAR *reference_string) const noexcept void DataFieldInteger::SetFromCombo([[maybe_unused]] int index, - const TCHAR *value) noexcept + const char *value) noexcept { SetAsInteger(ParseString(value)); } diff --git a/src/Form/DataField/Integer.hpp b/src/Form/DataField/Integer.hpp index 97ace528407..35b3cf556db 100644 --- a/src/Form/DataField/Integer.hpp +++ b/src/Form/DataField/Integer.hpp @@ -15,13 +15,13 @@ class DataFieldInteger final : public NumberDataField PeriodClock last_step; int speedup; - mutable TCHAR output_buffer[OUTBUFFERSIZE + 1]; + mutable char output_buffer[OUTBUFFERSIZE + 1]; protected: int SpeedUp(bool keyup) noexcept; public: - DataFieldInteger(const TCHAR *edit_format, const TCHAR *display_format, + DataFieldInteger(const char *edit_format, const char *display_format, int _min, int _max, int _value, int _step, DataFieldListener *listener=nullptr) noexcept :NumberDataField(Type::INTEGER, @@ -66,10 +66,10 @@ class DataFieldInteger final : public NumberDataField /* virtual methods from class DataField */ void Inc() noexcept override; void Dec() noexcept override; - const TCHAR *GetAsString() const noexcept override; - const TCHAR *GetAsDisplayString() const noexcept override; - ComboList CreateComboList(const TCHAR *reference) const noexcept override; - void SetFromCombo(int iDataFieldIndex, const TCHAR *sValue) noexcept override; + const char *GetAsString() const noexcept override; + const char *GetAsDisplayString() const noexcept override; + ComboList CreateComboList(const char *reference) const noexcept override; + void SetFromCombo(int iDataFieldIndex, const char *sValue) noexcept override; protected: void AppendComboValue(ComboList &combo_list, int value) const noexcept; diff --git a/src/Form/DataField/Number.cpp b/src/Form/DataField/Number.cpp index d399f4da8b4..4f4251b5d27 100644 --- a/src/Form/DataField/Number.cpp +++ b/src/Form/DataField/Number.cpp @@ -4,8 +4,8 @@ #include "Number.hpp" NumberDataField::NumberDataField(Type type, bool support_combo, - const TCHAR *_edit_format, - const TCHAR *_display_format, + const char *_edit_format, + const char *_display_format, DataFieldListener *listener) noexcept :DataField(type, support_combo, listener), edit_format(_edit_format), display_format(_display_format) @@ -13,7 +13,7 @@ NumberDataField::NumberDataField(Type type, bool support_combo, } void -NumberDataField::SetFormat(const TCHAR *text) noexcept +NumberDataField::SetFormat(const char *text) noexcept { edit_format = text; display_format = text; diff --git a/src/Form/DataField/Number.hpp b/src/Form/DataField/Number.hpp index 45e8375c077..7722c7acc6c 100644 --- a/src/Form/DataField/Number.hpp +++ b/src/Form/DataField/Number.hpp @@ -12,10 +12,10 @@ class NumberDataField : public DataField { StaticString<32> display_format; public: - void SetFormat(const TCHAR *text) noexcept; + void SetFormat(const char *text) noexcept; protected: NumberDataField(Type type, bool support_combo, - const TCHAR *edit_format, const TCHAR *display_format, + const char *edit_format, const char *display_format, DataFieldListener *listener=nullptr) noexcept; }; diff --git a/src/Form/DataField/Password.cpp b/src/Form/DataField/Password.cpp index 79c2ca1b077..a8f14dceea6 100644 --- a/src/Form/DataField/Password.cpp +++ b/src/Form/DataField/Password.cpp @@ -5,10 +5,10 @@ #include -const TCHAR * +const char * PasswordDataField::GetAsDisplayString() const noexcept { - const TCHAR *obfuscated = _T("********************************"); + const char *obfuscated = _T("********************************"); const size_t obfuscated_length = strlen(obfuscated); size_t length = std::min(strlen(GetAsString()), obfuscated_length); return obfuscated + (obfuscated_length - length); diff --git a/src/Form/DataField/Password.hpp b/src/Form/DataField/Password.hpp index 758e5d193f8..99876496319 100644 --- a/src/Form/DataField/Password.hpp +++ b/src/Form/DataField/Password.hpp @@ -11,10 +11,10 @@ */ class PasswordDataField final : public DataFieldString { public: - PasswordDataField(const TCHAR *initial_value, + PasswordDataField(const char *initial_value, DataFieldListener *listener=nullptr) noexcept :DataFieldString(initial_value, listener) {} /* virtual methods from class DataField */ - const TCHAR *GetAsDisplayString() const noexcept override; + const char *GetAsDisplayString() const noexcept override; }; diff --git a/src/Form/DataField/Prefix.cpp b/src/Form/DataField/Prefix.cpp index 8c555664285..c703e0093d4 100644 --- a/src/Form/DataField/Prefix.cpp +++ b/src/Form/DataField/Prefix.cpp @@ -5,10 +5,10 @@ #include "util/StringAPI.hxx" #include "util/StringCompare.hxx" -const TCHAR * +const char * PrefixDataField::GetAsDisplayString() const noexcept { - const TCHAR *s = DataFieldString::GetAsDisplayString(); + const char *s = DataFieldString::GetAsDisplayString(); if (StringIsEmpty(s)) s = _T("*"); return s; @@ -17,39 +17,39 @@ PrefixDataField::GetAsDisplayString() const noexcept void PrefixDataField::Inc() noexcept { - const TCHAR *chars = GetAllowedCharacters(); + const char *chars = GetAllowedCharacters(); if (StringIsEmpty(chars)) return; - const TCHAR current = GetAsString()[0]; - const TCHAR *p = current != _T('\0') + const char current = GetAsString()[0]; + const char *p = current != _T('\0') ? StringFind(chars, current) : nullptr; - TCHAR next; + char next; if (p == nullptr) next = chars[0]; else next = p[1]; - const TCHAR new_value[2] = { next, _T('\0') }; + const char new_value[2] = { next, _T('\0') }; ModifyValue(new_value); } void PrefixDataField::Dec() noexcept { - const TCHAR *chars = GetAllowedCharacters(); + const char *chars = GetAllowedCharacters(); if (StringIsEmpty(chars)) return; - const TCHAR current = GetAsString()[0]; + const char current = GetAsString()[0]; - TCHAR next; + char next; if (current == _T('\0')) next = chars[strlen(chars) - 1]; else { - const TCHAR *p = current != _T('\0') + const char *p = current != _T('\0') ? StringFind(chars, current) : nullptr; @@ -59,6 +59,6 @@ PrefixDataField::Dec() noexcept next = _T('\0'); } - const TCHAR new_value[2] = { next, _T('\0') }; + const char new_value[2] = { next, _T('\0') }; ModifyValue(new_value); } diff --git a/src/Form/DataField/Prefix.hpp b/src/Form/DataField/Prefix.hpp index 21ce01a6f64..23d8225727e 100644 --- a/src/Form/DataField/Prefix.hpp +++ b/src/Form/DataField/Prefix.hpp @@ -9,19 +9,19 @@ class PrefixDataField final : public DataFieldString { public: - typedef std::function AllowedCharactersFunction; + typedef std::function AllowedCharactersFunction; private: AllowedCharactersFunction allowed_characters; public: - PrefixDataField(const TCHAR *value, + PrefixDataField(const char *value, AllowedCharactersFunction _allowed_characters, DataFieldListener *listener=nullptr) noexcept :DataFieldString(Type::PREFIX, value, listener), allowed_characters(_allowed_characters) {} - PrefixDataField(const TCHAR *value=_T(""), + PrefixDataField(const char *value=_T(""), DataFieldListener *listener=nullptr) noexcept :DataFieldString(Type::PREFIX, value, listener) {} @@ -32,11 +32,11 @@ class PrefixDataField final : public DataFieldString { /* virtual methods from class DataField */ void Inc() noexcept override; void Dec() noexcept override; - const TCHAR *GetAsDisplayString() const noexcept override; + const char *GetAsDisplayString() const noexcept override; protected: [[gnu::pure]] - const TCHAR *GetAllowedCharacters() const noexcept { + const char *GetAllowedCharacters() const noexcept { return allowed_characters ? allowed_characters(_T("")) : _T("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); diff --git a/src/Form/DataField/RoughTime.cpp b/src/Form/DataField/RoughTime.cpp index e95dba7b268..cf7d7637579 100644 --- a/src/Form/DataField/RoughTime.cpp +++ b/src/Form/DataField/RoughTime.cpp @@ -6,7 +6,7 @@ #include -static TCHAR buffer[8]; +static char buffer[8]; void RoughTimeDataField::ModifyValue(RoughTime _value) noexcept @@ -18,7 +18,7 @@ RoughTimeDataField::ModifyValue(RoughTime _value) noexcept Modified(); } -const TCHAR * +const char * RoughTimeDataField::GetAsString() const noexcept { if (!value.IsValid()) @@ -28,7 +28,7 @@ RoughTimeDataField::GetAsString() const noexcept return buffer; } -const TCHAR * +const char * RoughTimeDataField::GetAsDisplayString() const noexcept { if (!value.IsValid()) diff --git a/src/Form/DataField/RoughTime.hpp b/src/Form/DataField/RoughTime.hpp index f91b9f5585f..463d6f2869c 100644 --- a/src/Form/DataField/RoughTime.hpp +++ b/src/Form/DataField/RoughTime.hpp @@ -51,6 +51,6 @@ class RoughTimeDataField final : public DataField { /* virtual methods from class DataField */ void Inc() noexcept override; void Dec() noexcept override; - const TCHAR *GetAsString() const noexcept override; - const TCHAR *GetAsDisplayString() const noexcept override; + const char *GetAsString() const noexcept override; + const char *GetAsDisplayString() const noexcept override; }; diff --git a/src/Form/DataField/String.cpp b/src/Form/DataField/String.cpp index 8b7f8302218..af5c62881c2 100644 --- a/src/Form/DataField/String.cpp +++ b/src/Form/DataField/String.cpp @@ -4,7 +4,7 @@ #include "String.hpp" void -DataFieldString::ModifyValue(const TCHAR *new_value) noexcept +DataFieldString::ModifyValue(const char *new_value) noexcept { if (new_value == mValue) return; @@ -14,12 +14,12 @@ DataFieldString::ModifyValue(const TCHAR *new_value) noexcept } void -DataFieldString::SetValue(const TCHAR *Value) noexcept +DataFieldString::SetValue(const char *Value) noexcept { mValue = Value; } -const TCHAR * +const char * DataFieldString::GetAsString() const noexcept { return GetValue(); diff --git a/src/Form/DataField/String.hpp b/src/Form/DataField/String.hpp index d2ed3f5be37..7aac503da2a 100644 --- a/src/Form/DataField/String.hpp +++ b/src/Form/DataField/String.hpp @@ -13,22 +13,22 @@ class DataFieldString: public DataField StaticString mValue; protected: - DataFieldString(Type _type, const TCHAR *_value, + DataFieldString(Type _type, const char *_value, DataFieldListener *listener=nullptr) noexcept :DataField(_type, false, listener), mValue(_value) {} public: - DataFieldString(const TCHAR *_value, + DataFieldString(const char *_value, DataFieldListener *listener=nullptr) noexcept :DataField(Type::STRING, false, listener), mValue(_value) {} - const TCHAR *GetValue() const noexcept { + const char *GetValue() const noexcept { return mValue.c_str(); } - void SetValue(const TCHAR *new_value) noexcept; - void ModifyValue(const TCHAR *new_value) noexcept; + void SetValue(const char *new_value) noexcept; + void ModifyValue(const char *new_value) noexcept; /* virtual methods from class DataField */ - const TCHAR *GetAsString() const noexcept override; + const char *GetAsString() const noexcept override; }; diff --git a/src/Form/DataField/Time.cpp b/src/Form/DataField/Time.cpp index d84ab277656..7476264c22d 100644 --- a/src/Form/DataField/Time.cpp +++ b/src/Form/DataField/Time.cpp @@ -9,14 +9,14 @@ static bool data_field_key_up = false; -const TCHAR * +const char * DataFieldTime::GetAsString() const noexcept { StringFormatUnsafe(string_buffer, _T("%d"), value); return string_buffer; } -const TCHAR * +const char * DataFieldTime::GetAsDisplayString() const noexcept { FormatTimespanSmart(string_buffer, std::chrono::seconds{value}, max_tokens); @@ -61,7 +61,7 @@ DataFieldTime::SpeedUp(bool key_up) noexcept void DataFieldTime::SetFromCombo(int data_field_index, - [[maybe_unused]] const TCHAR *value_string) noexcept + [[maybe_unused]] const char *value_string) noexcept { ModifyValue(std::chrono::seconds{data_field_index}); } @@ -70,14 +70,14 @@ void DataFieldTime::AppendComboValue(ComboList &combo_list, std::chrono::seconds value) const noexcept { - TCHAR buffer2[32]; + char buffer2[32]; StringFormatUnsafe(buffer2, _T("%ld"), (long)value.count()); combo_list.Append(value.count(), buffer2, FormatTimespanSmart(value, max_tokens)); } ComboList -DataFieldTime::CreateComboList(const TCHAR *reference_string) const noexcept +DataFieldTime::CreateComboList(const char *reference_string) const noexcept { const auto reference = reference_string != nullptr ? std::chrono::seconds{ParseInt(reference_string)} diff --git a/src/Form/DataField/Time.hpp b/src/Form/DataField/Time.hpp index 64d15207ecf..9ac84d29c09 100644 --- a/src/Form/DataField/Time.hpp +++ b/src/Form/DataField/Time.hpp @@ -16,7 +16,7 @@ class DataFieldTime final : public DataField { PeriodClock last_step; uint8_t speedup; - mutable TCHAR string_buffer[OUTBUFFERSIZE + 1]; + mutable char string_buffer[OUTBUFFERSIZE + 1]; protected: int SpeedUp(bool keyup) noexcept; @@ -64,10 +64,10 @@ class DataFieldTime final : public DataField { /* virtual methods from class DataField */ void Inc() noexcept override; void Dec() noexcept override; - const TCHAR *GetAsString() const noexcept override; - const TCHAR *GetAsDisplayString() const noexcept override; - ComboList CreateComboList(const TCHAR *reference) const noexcept override; - void SetFromCombo(int data_field_index, const TCHAR *value_string) noexcept override; + const char *GetAsString() const noexcept override; + const char *GetAsDisplayString() const noexcept override; + ComboList CreateComboList(const char *reference) const noexcept override; + void SetFromCombo(int data_field_index, const char *value_string) noexcept override; protected: void AppendComboValue(ComboList &combo_list, std::chrono::seconds value) const noexcept; diff --git a/src/Form/DigitEntry.cpp b/src/Form/DigitEntry.cpp index a72700bf041..9f70ef9ae65 100644 --- a/src/Form/DigitEntry.cpp +++ b/src/Form/DigitEntry.cpp @@ -996,7 +996,7 @@ DigitEntry::OnPaint(Canvas &canvas) noexcept rc.top = top; rc.bottom = bottom; - TCHAR buffer[5]; + char buffer[5]; for (unsigned i = 0; i < length; ++i) { const Column &c = columns[i]; @@ -1015,7 +1015,7 @@ DigitEntry::OnPaint(Canvas &canvas) noexcept canvas.SetBackgroundColor(look.background_color); } - const TCHAR *text = buffer; + const char *text = buffer; buffer[1] = _T('\0'); switch (c.type) { diff --git a/src/Form/Edit.cpp b/src/Form/Edit.cpp index f308bb64e1a..a599c286159 100644 --- a/src/Form/Edit.cpp +++ b/src/Form/Edit.cpp @@ -75,7 +75,7 @@ WndProperty::OnKillFocus() noexcept } WndProperty::WndProperty(ContainerWindow &parent, const DialogLook &_look, - const TCHAR *Caption, + const char *Caption, const PixelRect &rc, int CaptionWidth, const WindowStyle style) noexcept @@ -97,7 +97,7 @@ WndProperty::WndProperty(const DialogLook &_look) noexcept void WndProperty::Create(ContainerWindow &parent, const PixelRect &rc, - const TCHAR *_caption, + const char *_caption, unsigned _caption_width, const WindowStyle style=WindowStyle()) noexcept { @@ -340,7 +340,7 @@ WndProperty::OnPaint(Canvas &canvas) noexcept } void -WndProperty::SetText(const TCHAR *_value) noexcept +WndProperty::SetText(const char *_value) noexcept { assert(_value != nullptr); diff --git a/src/Form/Edit.hpp b/src/Form/Edit.hpp index 26d9cd71af3..de75053dc4b 100644 --- a/src/Form/Edit.hpp +++ b/src/Form/Edit.hpp @@ -16,8 +16,8 @@ class ContainerWindow; * an editable field (the Editor). */ class WndProperty : public WindowControl { - typedef bool (*EditCallback)(const TCHAR *caption, DataField &df, - const TCHAR *help_text); + typedef bool (*EditCallback)(const char *caption, DataField &df, + const char *help_text); const DialogLook &look; @@ -45,7 +45,7 @@ class WndProperty : public WindowControl { * @param CaptionWidth Width of the Caption of the Control */ WndProperty(ContainerWindow &parent, const DialogLook &look, - const TCHAR *Caption, + const char *Caption, const PixelRect &rc, int CaptionWidth, const WindowStyle style) noexcept; @@ -55,7 +55,7 @@ class WndProperty : public WindowControl { ~WndProperty() noexcept; void Create(ContainerWindow &parent, const PixelRect &rc, - const TCHAR *_caption, + const char *_caption, unsigned _caption_width, const WindowStyle style) noexcept; @@ -126,7 +126,7 @@ class WndProperty : public WindowControl { edit_callback = _ec; } - const TCHAR *GetText() const noexcept { + const char *GetText() const noexcept { return value.c_str(); } @@ -134,7 +134,7 @@ class WndProperty : public WindowControl { * Sets the Editors text to the given Value * @param Value The new text of the Editor Control */ - void SetText(const TCHAR *_value) noexcept; + void SetText(const char *_value) noexcept; private: /** diff --git a/src/Form/Form.cpp b/src/Form/Form.cpp index 307fa97abe5..59c5f654b61 100644 --- a/src/Form/Form.cpp +++ b/src/Form/Form.cpp @@ -46,7 +46,7 @@ WndForm::WndForm(const DialogLook &_look) WndForm::WndForm(SingleWindow &main_window, const DialogLook &_look, const PixelRect &rc, - const TCHAR *Caption, + const char *Caption, const WindowStyle style) :look(_look) { @@ -54,7 +54,7 @@ WndForm::WndForm(SingleWindow &main_window, const DialogLook &_look, } WndForm::WndForm(SingleWindow &main_window, const DialogLook &_look, - const TCHAR *caption, + const char *caption, const WindowStyle style) noexcept :WndForm(main_window, _look, main_window.GetClientRect(), caption, style) { @@ -62,7 +62,7 @@ WndForm::WndForm(SingleWindow &main_window, const DialogLook &_look, void WndForm::Create(SingleWindow &main_window, const PixelRect &rc, - const TCHAR *_caption, const WindowStyle style) + const char *_caption, const WindowStyle style) { if (_caption != nullptr) caption = _caption; @@ -78,7 +78,7 @@ WndForm::Create(SingleWindow &main_window, const PixelRect &rc, void WndForm::Create(SingleWindow &main_window, - const TCHAR *_caption, const WindowStyle style) + const char *_caption, const WindowStyle style) { Create(main_window, main_window.GetClientRect(), _caption, style); } @@ -525,7 +525,7 @@ WndForm::OnPaint(Canvas &canvas) noexcept } void -WndForm::SetCaption(const TCHAR *_caption) +WndForm::SetCaption(const char *_caption) { if (_caption == nullptr) _caption = _T(""); diff --git a/src/Form/Form.hpp b/src/Form/Form.hpp index c8a7eb5d791..c0670c0c30a 100644 --- a/src/Form/Form.hpp +++ b/src/Form/Form.hpp @@ -77,25 +77,25 @@ class WndForm : public ContainerWindow */ WndForm(UI::SingleWindow &_main_window, const DialogLook &_look, const PixelRect &rc, - const TCHAR *caption=nullptr, + const char *caption=nullptr, const WindowStyle style = WindowStyle()); /** * Construct a full-screen dialog. */ WndForm(UI::SingleWindow &_main_window, const DialogLook &_look, - const TCHAR *caption=nullptr, + const char *caption=nullptr, const WindowStyle style={}) noexcept; void Create(UI::SingleWindow &main_window, const PixelRect &rc, - const TCHAR *caption=nullptr, + const char *caption=nullptr, const WindowStyle style=WindowStyle()); /** * Create a full-screen dialog. */ void Create(UI::SingleWindow &main_window, - const TCHAR *caption=nullptr, + const char *caption=nullptr, const WindowStyle style=WindowStyle()); protected: @@ -158,12 +158,12 @@ class WndForm : public ContainerWindow int ShowModal(); - const TCHAR *GetCaption() const { + const char *GetCaption() const { return caption.c_str(); } /** Set the titlebar text */ - void SetCaption(const TCHAR *_caption); + void SetCaption(const char *_caption); /** from class Window */ void OnCreate() override; diff --git a/src/Form/Frame.cpp b/src/Form/Frame.cpp index de44d6742d2..d779e99c4b5 100644 --- a/src/Form/Frame.cpp +++ b/src/Form/Frame.cpp @@ -36,7 +36,7 @@ WndFrame::SetVAlignCenter() noexcept } void -WndFrame::SetText(const TCHAR *_text) noexcept +WndFrame::SetText(const char *_text) noexcept { text = _text; text_renderer.InvalidateLayout(); diff --git a/src/Form/Frame.hpp b/src/Form/Frame.hpp index a26e665bdf3..99b0579bab8 100644 --- a/src/Form/Frame.hpp +++ b/src/Form/Frame.hpp @@ -35,11 +35,11 @@ class WndFrame : public PaintWindow { void SetAlignCenter() noexcept; void SetVAlignCenter() noexcept; - const TCHAR *GetText() const noexcept { + const char *GetText() const noexcept { return text.c_str(); } - void SetText(const TCHAR *_text) noexcept; + void SetText(const char *_text) noexcept; void SetTextColor(const Color &color) noexcept { text_color = color; diff --git a/src/Form/TabDisplay.cpp b/src/Form/TabDisplay.cpp index 7009ae38645..53d65b0dcf9 100644 --- a/src/Form/TabDisplay.cpp +++ b/src/Form/TabDisplay.cpp @@ -24,7 +24,7 @@ class TabDisplay::Button { PixelRect rc; public: - Button(const TCHAR *_caption, const MaskedIcon *_icon) noexcept + Button(const char *_caption, const MaskedIcon *_icon) noexcept :icon(_icon) { caption = _caption; @@ -193,13 +193,13 @@ TabDisplay::CalculateLayout() noexcept } void -TabDisplay::Add(const TCHAR *caption, const MaskedIcon *icon) noexcept +TabDisplay::Add(const char *caption, const MaskedIcon *icon) noexcept { buttons.append(new Button(caption, icon)); CalculateLayout(); } -const TCHAR * +const char * TabDisplay::GetCaption(unsigned i) const noexcept { return buttons[i]->caption.c_str(); diff --git a/src/Form/TabDisplay.hpp b/src/Form/TabDisplay.hpp index cd0021fd9fe..cfa85a70bb1 100644 --- a/src/Form/TabDisplay.hpp +++ b/src/Form/TabDisplay.hpp @@ -62,10 +62,10 @@ class TabDisplay final : public PaintWindow void UpdateLayout(const PixelRect &rc, bool _vertical) noexcept; - void Add(const TCHAR *caption, const MaskedIcon *icon=nullptr) noexcept; + void Add(const char *caption, const MaskedIcon *icon=nullptr) noexcept; [[gnu::pure]] - const TCHAR *GetCaption(unsigned i) const noexcept; + const char *GetCaption(unsigned i) const noexcept; void SetCurrentIndex(unsigned i) noexcept { if (i == current_index) diff --git a/src/Form/TabMenuData.hpp b/src/Form/TabMenuData.hpp index 219b3fd3bd3..41f1999fad7 100644 --- a/src/Form/TabMenuData.hpp +++ b/src/Form/TabMenuData.hpp @@ -10,13 +10,13 @@ class Widget; struct TabMenuPage { - const TCHAR *menu_caption; + const char *menu_caption; std::unique_ptr (*Load)(); }; struct TabMenuGroup { - const TCHAR *caption; + const char *caption; const TabMenuPage *pages; }; diff --git a/src/Form/TabMenuDisplay.cpp b/src/Form/TabMenuDisplay.cpp index 1d9df6b9dd8..574a747f5b7 100644 --- a/src/Form/TabMenuDisplay.cpp +++ b/src/Form/TabMenuDisplay.cpp @@ -47,8 +47,8 @@ TabMenuDisplay::InitMenu(const TabMenuGroup groups[], } } -const TCHAR * -TabMenuDisplay::GetCaption(TCHAR buffer[], size_t size) const noexcept +const char * +TabMenuDisplay::GetCaption(char buffer[], size_t size) const noexcept { const unsigned page = pager.GetCurrentIndex(); if (page >= PAGE_OFFSET) { diff --git a/src/Form/TabMenuDisplay.hpp b/src/Form/TabMenuDisplay.hpp index c34b3409b26..e67a71d3dfb 100644 --- a/src/Form/TabMenuDisplay.hpp +++ b/src/Form/TabMenuDisplay.hpp @@ -33,7 +33,7 @@ class TabMenuDisplay final : public PaintWindow struct SubMenuButton { //TODO MainMenuButton *group; unsigned main_menu_index; - const TCHAR *caption; + const char *caption; PixelRect rc; @@ -50,7 +50,7 @@ class TabMenuDisplay final : public PaintWindow * class that holds the main menu button and info */ struct MainMenuButton { - const TCHAR *caption; + const char *caption; PixelRect rc; @@ -151,7 +151,7 @@ class TabMenuDisplay final : public PaintWindow */ void InitMenu(const TabMenuGroup groups[], unsigned n_groups) noexcept; - const TCHAR *GetCaption(TCHAR buffer[], size_t size) const noexcept; + const char *GetCaption(char buffer[], size_t size) const noexcept; /** * Call this from PagerWidget's OnPageFlipped callback. It moves @@ -181,7 +181,7 @@ class TabMenuDisplay final : public PaintWindow return buttons.size(); } - const TCHAR *GetPageParentCaption(unsigned page) const noexcept { + const char *GetPageParentCaption(unsigned page) const noexcept { assert(page < GetNumPages()); return main_menu_buttons[buttons[page].main_menu_index].caption; diff --git a/src/Formatter/AirspaceFormatter.cpp b/src/Formatter/AirspaceFormatter.cpp index 0dfdbb40bc1..635404fdaf7 100644 --- a/src/Formatter/AirspaceFormatter.cpp +++ b/src/Formatter/AirspaceFormatter.cpp @@ -5,7 +5,7 @@ #include "Engine/Airspace/AbstractAirspace.hpp" #include "util/Macros.hpp" -static const TCHAR *const airspace_class_names[] = { +static const char *const airspace_class_names[] = { _T("Unknown"), _T("Restricted"), _T("Prohibited"), @@ -31,7 +31,7 @@ static_assert(ARRAY_SIZE(airspace_class_names) == "number of airspace class names does not match number of " "airspace classes"); -static const TCHAR *const airspace_class_short_names[] = { +static const char *const airspace_class_short_names[] = { _T("?"), _T("R"), _T("P"), @@ -57,7 +57,7 @@ static_assert(ARRAY_SIZE(airspace_class_short_names) == "number of airspace class short names does not match number of " "airspace classes"); -const TCHAR * +const char * AirspaceFormatter::GetClass(AirspaceClass airspace_class) { unsigned i = (unsigned)airspace_class; @@ -66,7 +66,7 @@ AirspaceFormatter::GetClass(AirspaceClass airspace_class) airspace_class_names[i] : NULL; } -const TCHAR * +const char * AirspaceFormatter::GetClassShort(AirspaceClass airspace_class) { unsigned i = (unsigned)airspace_class; @@ -75,19 +75,19 @@ AirspaceFormatter::GetClassShort(AirspaceClass airspace_class) airspace_class_short_names[i] : NULL; } -const TCHAR * +const char * AirspaceFormatter::GetClass(const AbstractAirspace &airspace) { return GetClass(airspace.GetClass()); } -const TCHAR * +const char * AirspaceFormatter::GetClassShort(const AbstractAirspace &airspace) { return GetClassShort(airspace.GetClass()); } -const TCHAR * +const char * AirspaceFormatter::GetType(const AbstractAirspace &airspace) { return airspace.GetType(); diff --git a/src/Formatter/AirspaceFormatter.hpp b/src/Formatter/AirspaceFormatter.hpp index 4a8801953c9..25feba521d5 100644 --- a/src/Formatter/AirspaceFormatter.hpp +++ b/src/Formatter/AirspaceFormatter.hpp @@ -14,28 +14,28 @@ namespace AirspaceFormatter { /** Returns the airspace class as text. */ [[gnu::const]] -const TCHAR *GetClass(AirspaceClass airspace_class); +const char *GetClass(AirspaceClass airspace_class); /** Returns the airspace class as short text. */ [[gnu::const]] -const TCHAR *GetClassShort(AirspaceClass airspace_class); +const char *GetClassShort(AirspaceClass airspace_class); /** Returns the class of the airspace as text. */ [[gnu::pure]] -const TCHAR *GetClass(const AbstractAirspace &airspace); +const char *GetClass(const AbstractAirspace &airspace); /** Returns the class of the airspace as short text. */ [[gnu::pure]] -const TCHAR *GetClassShort(const AbstractAirspace &airspace); +const char *GetClassShort(const AbstractAirspace &airspace); /** Returns the airspace altitude limit as text with unit. */ - void FormatAltitude(TCHAR *buffer, const AirspaceAltitude &altitude); + void FormatAltitude(char *buffer, const AirspaceAltitude &altitude); /** Returns the airspace altitude limit as short text with unit. */ - void FormatAltitudeShort(TCHAR *buffer, const AirspaceAltitude &altitude, + void FormatAltitudeShort(char *buffer, const AirspaceAltitude &altitude, bool include_unit = true); /** Returns the type of the airspace as text. */ [[gnu::pure]] -const TCHAR *GetType(const AbstractAirspace &airspace); +const char *GetType(const AbstractAirspace &airspace); } diff --git a/src/Formatter/AirspaceUserUnitsFormatter.cpp b/src/Formatter/AirspaceUserUnitsFormatter.cpp index add16592cd5..d450180ebcc 100644 --- a/src/Formatter/AirspaceUserUnitsFormatter.cpp +++ b/src/Formatter/AirspaceUserUnitsFormatter.cpp @@ -11,7 +11,7 @@ #include void -AirspaceFormatter::FormatAltitudeShort(TCHAR *buffer, +AirspaceFormatter::FormatAltitudeShort(char *buffer, const AirspaceAltitude &altitude, bool include_unit) { @@ -46,7 +46,7 @@ AirspaceFormatter::FormatAltitudeShort(TCHAR *buffer, } void -AirspaceFormatter::FormatAltitude(TCHAR *buffer, +AirspaceFormatter::FormatAltitude(char *buffer, const AirspaceAltitude &altitude) { FormatAltitudeShort(buffer, altitude); diff --git a/src/Formatter/AngleFormatter.cpp b/src/Formatter/AngleFormatter.cpp index 7866d34bb47..202193e9cda 100644 --- a/src/Formatter/AngleFormatter.cpp +++ b/src/Formatter/AngleFormatter.cpp @@ -9,8 +9,8 @@ #include void -FormatBearing(TCHAR *buffer, size_t size, unsigned value_degrees, - const TCHAR *suffix) +FormatBearing(char *buffer, size_t size, unsigned value_degrees, + const char *suffix) { assert(buffer != NULL); assert(size >= 8); @@ -22,13 +22,13 @@ FormatBearing(TCHAR *buffer, size_t size, unsigned value_degrees, } void -FormatBearing(TCHAR *buffer, size_t size, Angle value, const TCHAR *suffix) +FormatBearing(char *buffer, size_t size, Angle value, const char *suffix) { FormatBearing(buffer, size, lround(value.AsBearing().Degrees()), suffix); } void -FormatAngleDelta(TCHAR *buffer, size_t size, Angle value) +FormatAngleDelta(char *buffer, size_t size, Angle value) { assert(buffer != NULL); assert(size >= 8); @@ -43,7 +43,7 @@ FormatAngleDelta(TCHAR *buffer, size_t size, Angle value) } void -FormatVerticalAngleDelta(TCHAR *buffer, size_t size, Angle value) +FormatVerticalAngleDelta(char *buffer, size_t size, Angle value) { assert(buffer != NULL); assert(size >= 8); diff --git a/src/Formatter/AngleFormatter.hpp b/src/Formatter/AngleFormatter.hpp index 21491ac9015..4d9ee0f2b46 100644 --- a/src/Formatter/AngleFormatter.hpp +++ b/src/Formatter/AngleFormatter.hpp @@ -13,42 +13,42 @@ class Angle; void -FormatBearing(TCHAR *buffer, size_t size, unsigned degrees_value, - const TCHAR *suffix = NULL); +FormatBearing(char *buffer, size_t size, unsigned degrees_value, + const char *suffix = NULL); void -FormatBearing(TCHAR *buffer, size_t size, Angle value, - const TCHAR *suffix = NULL); +FormatBearing(char *buffer, size_t size, Angle value, + const char *suffix = NULL); [[gnu::const]] -static inline BasicStringBuffer +static inline BasicStringBuffer FormatBearing(unsigned degrees_value) { - BasicStringBuffer buffer; + BasicStringBuffer buffer; FormatBearing(buffer.data(), buffer.capacity(), degrees_value); return buffer; } [[gnu::const]] -static inline BasicStringBuffer +static inline BasicStringBuffer FormatBearing(Angle value) { - BasicStringBuffer buffer; + BasicStringBuffer buffer; FormatBearing(buffer.data(), buffer.capacity(), value); return buffer; } void -FormatAngleDelta(TCHAR *buffer, size_t size, Angle value); +FormatAngleDelta(char *buffer, size_t size, Angle value); [[gnu::const]] -static inline BasicStringBuffer +static inline BasicStringBuffer FormatAngleDelta(Angle value) { - BasicStringBuffer buffer; + BasicStringBuffer buffer; FormatAngleDelta(buffer.data(), buffer.capacity(), value); return buffer; } void -FormatVerticalAngleDelta(TCHAR *buffer, size_t size, Angle value); +FormatVerticalAngleDelta(char *buffer, size_t size, Angle value); diff --git a/src/Formatter/ByteSizeFormatter.cpp b/src/Formatter/ByteSizeFormatter.cpp index f05c4bf39bf..33f869e34f0 100644 --- a/src/Formatter/ByteSizeFormatter.cpp +++ b/src/Formatter/ByteSizeFormatter.cpp @@ -8,22 +8,22 @@ #include void -FormatByteSize(TCHAR *buffer, size_t size, unsigned long bytes, bool simple) +FormatByteSize(char *buffer, size_t size, unsigned long bytes, bool simple) { assert(buffer != NULL); assert(size >= 8); - static const TCHAR *const units[] = { _T("B"), _T("KB"), _T("MB"), _T("GB") }; - static const TCHAR *const simple_units[] = { _T("B"), _T("K"), _T("M"), _T("G") }; + static const char *const units[] = { _T("B"), _T("KB"), _T("MB"), _T("GB") }; + static const char *const simple_units[] = { _T("B"), _T("K"), _T("M"), _T("G") }; double value = bytes; unsigned i = 0; for (; value >= 1024 && i < ARRAY_SIZE(units)-1; i++, value /= 1024); - const TCHAR *unit = simple ? simple_units[i] : units[i]; + const char *unit = simple ? simple_units[i] : units[i]; - const TCHAR *format; + const char *format; if (value >= 100 || i == 0) format = simple ? _T("%.0f%s") : _T("%.0f %s"); else if (value >= 10) diff --git a/src/Formatter/ByteSizeFormatter.hpp b/src/Formatter/ByteSizeFormatter.hpp index fc477a9cef9..cdcf70c450d 100644 --- a/src/Formatter/ByteSizeFormatter.hpp +++ b/src/Formatter/ByteSizeFormatter.hpp @@ -6,5 +6,5 @@ #include #include -void FormatByteSize(TCHAR *buffer, size_t size, +void FormatByteSize(char *buffer, size_t size, unsigned long bytes, bool simple = false); diff --git a/src/Formatter/GeoPointFormatter.cpp b/src/Formatter/GeoPointFormatter.cpp index 201178c1994..d4beae37b04 100644 --- a/src/Formatter/GeoPointFormatter.cpp +++ b/src/Formatter/GeoPointFormatter.cpp @@ -24,13 +24,13 @@ #include "util/StringAPI.hxx" bool -FormatLongitude(Angle longitude, TCHAR *buffer, size_t size, +FormatLongitude(Angle longitude, char *buffer, size_t size, CoordinateFormat format) { int dd, mm, ss; // Calculate Longitude sign - TCHAR sign = longitude.IsNegative() ? _T('W') : _T('E'); + char sign = longitude.IsNegative() ? _T('W') : _T('E'); double mlong(longitude.AbsoluteDegrees()); @@ -93,13 +93,13 @@ FormatLongitude(Angle longitude, TCHAR *buffer, size_t size, } bool -FormatLatitude(Angle latitude, TCHAR *buffer, size_t size, +FormatLatitude(Angle latitude, char *buffer, size_t size, CoordinateFormat format) { int dd, mm, ss; // Calculate Latitude sign - TCHAR sign = latitude.IsNegative() ? _T('S') : _T('N'); + char sign = latitude.IsNegative() ? _T('S') : _T('N'); double mlat(latitude.AbsoluteDegrees()); @@ -161,9 +161,9 @@ FormatLatitude(Angle latitude, TCHAR *buffer, size_t size, return true; } -static TCHAR * -FormatUTM(const GeoPoint &location, TCHAR *buffer, size_t size, - TCHAR separator = _T(' ')) +static char * +FormatUTM(const GeoPoint &location, char *buffer, size_t size, + char separator = _T(' ')) { UTM utm = UTM::FromGeoPoint(location); StringFormat(buffer, size, _T("%u%c%c%.0f%c%.0f"), @@ -173,9 +173,9 @@ FormatUTM(const GeoPoint &location, TCHAR *buffer, size_t size, return buffer; } -TCHAR * -FormatGeoPoint(const GeoPoint &location, TCHAR *buffer, size_t size, - CoordinateFormat format, TCHAR separator) +char * +FormatGeoPoint(const GeoPoint &location, char *buffer, size_t size, + CoordinateFormat format, char separator) { if (format == CoordinateFormat::UTM) return FormatUTM(location, buffer, size, separator); @@ -183,7 +183,7 @@ FormatGeoPoint(const GeoPoint &location, TCHAR *buffer, size_t size, if (!FormatLatitude(location.latitude, buffer, size, format)) return nullptr; - TCHAR *end = buffer + size, *p = buffer + StringLength(buffer); + char *end = buffer + size, *p = buffer + StringLength(buffer); if (p >= end) return nullptr; diff --git a/src/Formatter/GeoPointFormatter.hpp b/src/Formatter/GeoPointFormatter.hpp index 31b23bd2344..5eddc8c3a6e 100644 --- a/src/Formatter/GeoPointFormatter.hpp +++ b/src/Formatter/GeoPointFormatter.hpp @@ -18,7 +18,7 @@ struct GeoPoint; * @param buffer buffer string to write to (pointer) * @param size Size of the buffer */ -bool FormatLongitude(Angle longitude, TCHAR *buffer, size_t size, +bool FormatLongitude(Angle longitude, char *buffer, size_t size, CoordinateFormat format); /** @@ -27,21 +27,21 @@ bool FormatLongitude(Angle longitude, TCHAR *buffer, size_t size, * @param buffer buffer string to write to (pointer) * @param size Size of the buffer */ -bool FormatLatitude(Angle latitude, TCHAR *buffer, size_t size, +bool FormatLatitude(Angle latitude, char *buffer, size_t size, CoordinateFormat format); /** * Convert a GeoPoint into a formatted string. */ -TCHAR *FormatGeoPoint(const GeoPoint &location, TCHAR *buffer, size_t size, - CoordinateFormat format, TCHAR separator = _T(' ')); +char *FormatGeoPoint(const GeoPoint &location, char *buffer, size_t size, + CoordinateFormat format, char separator = _T(' ')); [[gnu::pure]] -static inline BasicStringBuffer +static inline BasicStringBuffer FormatGeoPoint(const GeoPoint &location, CoordinateFormat format, - TCHAR separator = _T(' ')) + char separator = _T(' ')) { - BasicStringBuffer buffer; + BasicStringBuffer buffer; auto result = FormatGeoPoint(location, buffer.data(), buffer.capacity(), format, separator); if (result == nullptr) diff --git a/src/Formatter/GlideRatioFormatter.cpp b/src/Formatter/GlideRatioFormatter.cpp index 8c15bc83735..2f24a83ee22 100644 --- a/src/Formatter/GlideRatioFormatter.cpp +++ b/src/Formatter/GlideRatioFormatter.cpp @@ -8,7 +8,7 @@ #include void -FormatGlideRatio(TCHAR *buffer, size_t size, double gr) +FormatGlideRatio(char *buffer, size_t size, double gr) { assert(buffer != NULL); assert(size >= 8); diff --git a/src/Formatter/GlideRatioFormatter.hpp b/src/Formatter/GlideRatioFormatter.hpp index f990bbb4044..c1fc5671205 100644 --- a/src/Formatter/GlideRatioFormatter.hpp +++ b/src/Formatter/GlideRatioFormatter.hpp @@ -7,4 +7,4 @@ #include void -FormatGlideRatio(TCHAR *buffer, size_t size, double gr); +FormatGlideRatio(char *buffer, size_t size, double gr); diff --git a/src/Formatter/IGCFilenameFormatter.cpp b/src/Formatter/IGCFilenameFormatter.cpp index d80f1d3acf6..030535294cb 100644 --- a/src/Formatter/IGCFilenameFormatter.cpp +++ b/src/Formatter/IGCFilenameFormatter.cpp @@ -8,7 +8,7 @@ #include #include -static TCHAR +static char NumToIGCChar(unsigned num) { assert(num <= 35); @@ -20,17 +20,17 @@ NumToIGCChar(unsigned num) } void -FormatIGCFilename(TCHAR* buffer, const BrokenDate &date, - TCHAR manufacturer, const TCHAR *logger_id, +FormatIGCFilename(char* buffer, const BrokenDate &date, + char manufacturer, const char *logger_id, unsigned flight_number) { assert(logger_id != NULL); assert(strlen(logger_id) == 3); - TCHAR cyear = NumToIGCChar(date.year % 10); - TCHAR cmonth = NumToIGCChar(date.month); - TCHAR cday = NumToIGCChar(date.day); - TCHAR cflight = NumToIGCChar(flight_number); + char cyear = NumToIGCChar(date.year % 10); + char cmonth = NumToIGCChar(date.month); + char cday = NumToIGCChar(date.day); + char cflight = NumToIGCChar(flight_number); StringFormatUnsafe(buffer, _T("%c%c%c%c%s%c.igc"), cyear, cmonth, cday, @@ -38,8 +38,8 @@ FormatIGCFilename(TCHAR* buffer, const BrokenDate &date, } void -FormatIGCFilenameLong(TCHAR* buffer, const BrokenDate &date, - const TCHAR *manufacturer, const TCHAR *logger_id, +FormatIGCFilenameLong(char* buffer, const BrokenDate &date, + const char *manufacturer, const char *logger_id, unsigned flight_number) { // 2003-12-31-XYZ-987-01.igc diff --git a/src/Formatter/IGCFilenameFormatter.hpp b/src/Formatter/IGCFilenameFormatter.hpp index 3d35e0bcdcd..d5c92f38ff8 100644 --- a/src/Formatter/IGCFilenameFormatter.hpp +++ b/src/Formatter/IGCFilenameFormatter.hpp @@ -7,10 +7,10 @@ struct BrokenDate; -void FormatIGCFilename(TCHAR* buffer, const BrokenDate &date, - TCHAR manufacturer, const TCHAR *logger_id, +void FormatIGCFilename(char* buffer, const BrokenDate &date, + char manufacturer, const char *logger_id, unsigned flight_number); -void FormatIGCFilenameLong(TCHAR* buffer, const BrokenDate &date, - const TCHAR *manufacturer, const TCHAR *logger_id, +void FormatIGCFilenameLong(char* buffer, const BrokenDate &date, + const char *manufacturer, const char *logger_id, unsigned flight_number); diff --git a/src/Formatter/LocalTimeFormatter.cpp b/src/Formatter/LocalTimeFormatter.cpp index 9b3be827e06..5cb219c3982 100644 --- a/src/Formatter/LocalTimeFormatter.cpp +++ b/src/Formatter/LocalTimeFormatter.cpp @@ -7,7 +7,7 @@ #include "time/RoughTime.hpp" void -FormatLocalTimeHHMM(TCHAR *buffer, TimeStamp time, +FormatLocalTimeHHMM(char *buffer, TimeStamp time, RoughTimeDelta utc_offset) noexcept { FormatTimeHHMM(buffer, TimeLocal(time, utc_offset)); diff --git a/src/Formatter/LocalTimeFormatter.hpp b/src/Formatter/LocalTimeFormatter.hpp index 3d0f0c3e576..eae8d44be67 100644 --- a/src/Formatter/LocalTimeFormatter.hpp +++ b/src/Formatter/LocalTimeFormatter.hpp @@ -18,15 +18,15 @@ class RoughTimeDelta; * @param time UTC time of day [seconds] */ void -FormatLocalTimeHHMM(TCHAR *buffer, TimeStamp time, +FormatLocalTimeHHMM(char *buffer, TimeStamp time, RoughTimeDelta utc_offset) noexcept; [[gnu::const]] -static inline BasicStringBuffer +static inline BasicStringBuffer FormatLocalTimeHHMM(TimeStamp time, RoughTimeDelta utc_offset) noexcept { - BasicStringBuffer buffer; + BasicStringBuffer buffer; FormatLocalTimeHHMM(buffer.data(), time, utc_offset); return buffer; } diff --git a/src/Formatter/TimeFormatter.cpp b/src/Formatter/TimeFormatter.cpp index 80b49c40382..8b8fb7b7207 100644 --- a/src/Formatter/TimeFormatter.cpp +++ b/src/Formatter/TimeFormatter.cpp @@ -26,7 +26,7 @@ FormatISO8601(char *buffer, const BrokenDateTime &stamp) noexcept } void -FormatTime(TCHAR *buffer, FloatDuration _time) noexcept +FormatTime(char *buffer, FloatDuration _time) noexcept { if (_time.count() < 0) { *buffer++ = _T('-'); @@ -39,7 +39,7 @@ FormatTime(TCHAR *buffer, FloatDuration _time) noexcept } void -FormatTimeLong(TCHAR *buffer, FloatDuration _time) noexcept +FormatTimeLong(char *buffer, FloatDuration _time) noexcept { if (_time.count() < 0) { *buffer++ = _T('-'); @@ -56,7 +56,7 @@ FormatTimeLong(TCHAR *buffer, FloatDuration _time) noexcept } void -FormatSignedTimeHHMM(TCHAR *buffer, std::chrono::seconds _time) noexcept +FormatSignedTimeHHMM(char *buffer, std::chrono::seconds _time) noexcept { if (_time.count() < 0) { *buffer++ = _T('-'); @@ -68,7 +68,7 @@ FormatSignedTimeHHMM(TCHAR *buffer, std::chrono::seconds _time) noexcept } void -FormatTimeTwoLines(TCHAR *buffer1, TCHAR *buffer2, std::chrono::seconds _time) noexcept +FormatTimeTwoLines(char *buffer1, char *buffer2, std::chrono::seconds _time) noexcept { if (_time >= std::chrono::hours{24}) { strcpy(buffer1, _T(">24h")); @@ -123,9 +123,9 @@ CalculateTimespanComponents(unsigned timespan, unsigned &days, unsigned &hours, } void -FormatTimespanSmart(TCHAR *buffer, std::chrono::seconds timespan, +FormatTimespanSmart(char *buffer, std::chrono::seconds timespan, unsigned max_tokens, - const TCHAR *separator) noexcept + const char *separator) noexcept { assert(max_tokens > 0 && max_tokens <= 4); diff --git a/src/Formatter/TimeFormatter.hpp b/src/Formatter/TimeFormatter.hpp index 6d171382040..684092e3c41 100644 --- a/src/Formatter/TimeFormatter.hpp +++ b/src/Formatter/TimeFormatter.hpp @@ -21,16 +21,16 @@ void FormatISO8601(char *buffer, const BrokenDateTime &stamp) noexcept; void -FormatTime(TCHAR *buffer, FloatDuration time) noexcept; +FormatTime(char *buffer, FloatDuration time) noexcept; static inline void -FormatTime(TCHAR *buffer, TimeStamp time) noexcept +FormatTime(char *buffer, TimeStamp time) noexcept { FormatTime(buffer, time.ToDuration()); } void -FormatTimeLong(TCHAR *buffer, FloatDuration time) noexcept; +FormatTimeLong(char *buffer, FloatDuration time) noexcept; /** * precedes with "-" if time is negative @@ -38,13 +38,13 @@ FormatTimeLong(TCHAR *buffer, FloatDuration time) noexcept; * @param time input seconds */ void -FormatSignedTimeHHMM(TCHAR *buffer, std::chrono::seconds time) noexcept; +FormatSignedTimeHHMM(char *buffer, std::chrono::seconds time) noexcept; [[gnu::const]] -static inline BasicStringBuffer +static inline BasicStringBuffer FormatSignedTimeHHMM(std::chrono::seconds time) noexcept { - BasicStringBuffer buffer; + BasicStringBuffer buffer; FormatSignedTimeHHMM(buffer.data(), time); return buffer; } @@ -57,7 +57,7 @@ FormatSignedTimeHHMM(FloatDuration time) noexcept } static inline void -FormatTimeHHMM(TCHAR *buffer, TimeStamp time) noexcept +FormatTimeHHMM(char *buffer, TimeStamp time) noexcept { FormatSignedTimeHHMM(buffer, time.Cast()); } @@ -83,20 +83,20 @@ FormatTimeHHMM(TimeStamp time) noexcept * @param d input seconds */ void -FormatTimeTwoLines(TCHAR *buffer1, TCHAR *buffer2, +FormatTimeTwoLines(char *buffer1, char *buffer2, std::chrono::seconds time) noexcept; void -FormatTimespanSmart(TCHAR *buffer, std::chrono::seconds timespan, +FormatTimespanSmart(char *buffer, std::chrono::seconds timespan, unsigned max_tokens = 1, - const TCHAR *separator = _T(" ")) noexcept; + const char *separator = _T(" ")) noexcept; [[gnu::const]] -static inline BasicStringBuffer +static inline BasicStringBuffer FormatTimespanSmart(std::chrono::seconds timespan, unsigned max_tokens = 1, - const TCHAR *separator = _T(" ")) noexcept + const char *separator = _T(" ")) noexcept { - BasicStringBuffer buffer; + BasicStringBuffer buffer; FormatTimespanSmart(buffer.data(), timespan, max_tokens, separator); return buffer; } @@ -104,7 +104,7 @@ FormatTimespanSmart(std::chrono::seconds timespan, unsigned max_tokens = 1, [[gnu::const]] static inline auto FormatTimespanSmart(FloatDuration timespan, unsigned max_tokens = 1, - const TCHAR *separator = _T(" ")) noexcept + const char *separator = _T(" ")) noexcept { return FormatTimespanSmart(std::chrono::duration_cast(timespan), max_tokens, separator); diff --git a/src/Formatter/Units.cpp b/src/Formatter/Units.cpp index 4569ef86e2f..0c5246051eb 100644 --- a/src/Formatter/Units.cpp +++ b/src/Formatter/Units.cpp @@ -9,7 +9,7 @@ #include "util/StringFormat.hpp" static void -FormatInteger(TCHAR *buffer, +FormatInteger(char *buffer, const double value, const Unit unit, bool include_unit, bool include_sign) { @@ -24,14 +24,14 @@ FormatInteger(TCHAR *buffer, } void -FormatMass(TCHAR *buffer, double value, Unit unit, +FormatMass(char *buffer, double value, Unit unit, bool include_unit) { FormatInteger(buffer, value, unit, include_unit, false); } void -FormatWingLoading(TCHAR *buffer, double value, Unit unit, +FormatWingLoading(char *buffer, double value, Unit unit, bool include_unit) { const auto uvalue = Units::ToUserUnit(value, unit); @@ -45,21 +45,21 @@ FormatWingLoading(TCHAR *buffer, double value, Unit unit, } void -FormatAltitude(TCHAR *buffer, double value, Unit unit, +FormatAltitude(char *buffer, double value, Unit unit, bool include_unit) { FormatInteger(buffer, value, unit, include_unit, false); } void -FormatRelativeAltitude(TCHAR *buffer, double value, +FormatRelativeAltitude(char *buffer, double value, Unit unit, bool include_unit) { FormatInteger(buffer, value, unit, include_unit, true); } void -FormatDistance(TCHAR *buffer, double value, Unit unit, +FormatDistance(char *buffer, double value, Unit unit, bool include_unit, int precision) { value = Units::ToUserUnit(value, unit); @@ -89,7 +89,7 @@ GetSmallerDistanceUnit(Unit unit) } Unit -FormatSmallDistance(TCHAR *buffer, double value, Unit unit, +FormatSmallDistance(char *buffer, double value, Unit unit, bool include_unit, int precision) { unit = GetSmallerDistanceUnit(unit); @@ -128,7 +128,7 @@ GetBestDistancePrecision(double value, Unit unit, double threshold = 100) } Unit -FormatDistanceSmart(TCHAR *buffer, double value, Unit unit, +FormatDistanceSmart(char *buffer, double value, Unit unit, bool include_unit, double small_unit_threshold, double precision_threshold) { @@ -140,7 +140,7 @@ FormatDistanceSmart(TCHAR *buffer, double value, Unit unit, } void -FormatSpeed(TCHAR *buffer, +FormatSpeed(char *buffer, double value, const Unit unit, bool include_unit, bool precision) { value = Units::ToUserUnit(value, unit); @@ -153,10 +153,10 @@ FormatSpeed(TCHAR *buffer, StringFormatUnsafe(buffer, _T("%.*f"), prec, (double)value); } -const TCHAR* +const char* GetVerticalSpeedFormat(Unit unit, bool include_unit, bool include_sign) { - static const TCHAR *const format[2][2][2]= { + static const char *const format[2][2][2]= { // 0 0 0 0 0 1 0 1 0 0 1 1 { { _T("%.1f"), _T("%+.1f") }, { _T("%.1f %s"), _T("%+.1f %s") } }, // 1 0 0 1 0 1 1 1 0 1 1 1 @@ -182,7 +182,7 @@ GetVerticalSpeedStep(Unit unit) } void -FormatVerticalSpeed(TCHAR *buffer, double value, Unit unit, +FormatVerticalSpeed(char *buffer, double value, Unit unit, bool include_unit, bool include_sign) { value = Units::ToUserUnit(value, unit); @@ -198,7 +198,7 @@ FormatVerticalSpeed(TCHAR *buffer, double value, Unit unit, } void -FormatTemperature(TCHAR *buffer, double value, Unit unit, +FormatTemperature(char *buffer, double value, Unit unit, bool include_unit) { value = Units::ToUserUnit(value, unit); @@ -211,7 +211,7 @@ FormatTemperature(TCHAR *buffer, double value, Unit unit, } void -FormatPressure(TCHAR *buffer, AtmosphericPressure pressure, +FormatPressure(char *buffer, AtmosphericPressure pressure, Unit unit, bool include_unit) { auto _pressure = Units::ToUserUnit(pressure.GetHectoPascal(), unit); @@ -225,7 +225,7 @@ FormatPressure(TCHAR *buffer, AtmosphericPressure pressure, (double)_pressure); } -const TCHAR* +const char* GetPressureFormat(Unit unit, bool include_unit) { if (include_unit) diff --git a/src/Formatter/Units.hpp b/src/Formatter/Units.hpp index bc63dc1231e..c73c0f4dee5 100644 --- a/src/Formatter/Units.hpp +++ b/src/Formatter/Units.hpp @@ -18,7 +18,7 @@ class AtmosphericPressure; * @param include_unit include the unit into the string? */ void -FormatAltitude(TCHAR *buffer, double value, Unit unit, +FormatAltitude(char *buffer, double value, Unit unit, bool include_unit = true); /** @@ -30,7 +30,7 @@ FormatAltitude(TCHAR *buffer, double value, Unit unit, * @param include_unit include the unit into the string? */ void -FormatMass(TCHAR *buffer, double value, Unit unit, +FormatMass(char *buffer, double value, Unit unit, bool include_unit = true); /** @@ -42,7 +42,7 @@ FormatMass(TCHAR *buffer, double value, Unit unit, * @param include_unit include the unit into the string? */ void -FormatWingLoading(TCHAR *buffer, double value, Unit unit, +FormatWingLoading(char *buffer, double value, Unit unit, bool include_unit = true); /** @@ -54,7 +54,7 @@ FormatWingLoading(TCHAR *buffer, double value, Unit unit, * @param include_unit include the unit into the string? */ void -FormatRelativeAltitude(TCHAR *buffer, double value, Unit unit, +FormatRelativeAltitude(char *buffer, double value, Unit unit, bool include_unit = true); /** @@ -67,7 +67,7 @@ FormatRelativeAltitude(TCHAR *buffer, double value, Unit unit, * @param precision the number of decimal places */ void -FormatDistance(TCHAR *buffer, double value, const Unit unit, +FormatDistance(char *buffer, double value, const Unit unit, bool include_unit = true, int precision = 0); /** @@ -82,7 +82,7 @@ FormatDistance(TCHAR *buffer, double value, const Unit unit, * @return the unit used for output formatting */ Unit -FormatSmallDistance(TCHAR *buffer, double value, Unit unit, +FormatSmallDistance(char *buffer, double value, Unit unit, bool include_unit = true, int precision = 0); /** @@ -96,7 +96,7 @@ FormatSmallDistance(TCHAR *buffer, double value, Unit unit, * @return the unit used for output formatting */ Unit -FormatDistanceSmart(TCHAR *buffer, double value, Unit unit, +FormatDistanceSmart(char *buffer, double value, Unit unit, bool include_unit = true, double small_unit_threshold = 0, double precision_threshold = 100); @@ -111,7 +111,7 @@ FormatDistanceSmart(TCHAR *buffer, double value, Unit unit, * @param precision if true shows one decimal place if the speed is low */ void -FormatSpeed(TCHAR *buffer, double value, const Unit unit, +FormatSpeed(char *buffer, double value, const Unit unit, bool include_unit = true, bool precision = false); /** @@ -121,7 +121,7 @@ FormatSpeed(TCHAR *buffer, double value, const Unit unit, * @param include_sign include the sign into the string? * @return the format */ -const TCHAR* GetVerticalSpeedFormat(Unit unit, bool include_unit = false, +const char* GetVerticalSpeedFormat(Unit unit, bool include_unit = false, bool include_sign = true); /** @@ -142,7 +142,7 @@ GetVerticalSpeedStep(Unit unit); * @param include_sign include the sign into the string? */ void -FormatVerticalSpeed(TCHAR *buffer, double value, Unit unit, +FormatVerticalSpeed(char *buffer, double value, Unit unit, bool include_unit = true, bool include_sign = true); /** @@ -154,7 +154,7 @@ FormatVerticalSpeed(TCHAR *buffer, double value, Unit unit, * @param include_unit include the unit into the string? */ void -FormatTemperature(TCHAR *buffer, double value, Unit unit, +FormatTemperature(char *buffer, double value, Unit unit, bool include_unit = true); /** @@ -165,7 +165,7 @@ FormatTemperature(TCHAR *buffer, double value, Unit unit, * @param unit the pressure unit (e.g. meters, feet, ...) * @param include_unit include the unit into the string? */ -void FormatPressure(TCHAR *buffer, AtmosphericPressure value, Unit unit, +void FormatPressure(char *buffer, AtmosphericPressure value, Unit unit, bool include_unit = true); /** @@ -173,7 +173,7 @@ void FormatPressure(TCHAR *buffer, AtmosphericPressure value, Unit unit, * @param unit the pressure unit * @return the format */ -const TCHAR* GetPressureFormat(Unit unit, bool include_unit = false); +const char* GetPressureFormat(Unit unit, bool include_unit = false); /** * Give the basic step size for pressure editing diff --git a/src/Formatter/UserGeoPointFormatter.cpp b/src/Formatter/UserGeoPointFormatter.cpp index 9045ce6ab9e..ea2e255efa1 100644 --- a/src/Formatter/UserGeoPointFormatter.cpp +++ b/src/Formatter/UserGeoPointFormatter.cpp @@ -20,20 +20,20 @@ SetUserCoordinateFormat(CoordinateFormat _fmt) } bool -FormatLongitude(Angle longitude, TCHAR *buffer, size_t size) +FormatLongitude(Angle longitude, char *buffer, size_t size) { return FormatLongitude(longitude, buffer, size, user_coordinate_format); } bool -FormatLatitude(Angle latitude, TCHAR *buffer, size_t size) +FormatLatitude(Angle latitude, char *buffer, size_t size) { return FormatLatitude(latitude, buffer, size, user_coordinate_format); } -TCHAR * -FormatGeoPoint(const GeoPoint &location, TCHAR *buffer, size_t size, - TCHAR separator) +char * +FormatGeoPoint(const GeoPoint &location, char *buffer, size_t size, + char separator) { return FormatGeoPoint(location, buffer, size, user_coordinate_format, separator); diff --git a/src/Formatter/UserGeoPointFormatter.hpp b/src/Formatter/UserGeoPointFormatter.hpp index ce4d6dd79b5..b92b2468ed4 100644 --- a/src/Formatter/UserGeoPointFormatter.hpp +++ b/src/Formatter/UserGeoPointFormatter.hpp @@ -21,7 +21,7 @@ SetUserCoordinateFormat(CoordinateFormat _fmt); * @param buffer buffer string to write to (pointer) * @param size Size of the buffer */ -bool FormatLongitude(Angle longitude, TCHAR *buffer, size_t size); +bool FormatLongitude(Angle longitude, char *buffer, size_t size); /** * Converts a double-based Latitude into a formatted string @@ -29,19 +29,19 @@ bool FormatLongitude(Angle longitude, TCHAR *buffer, size_t size); * @param buffer buffer string to write to (pointer) * @param size Size of the buffer */ -bool FormatLatitude(Angle latitude, TCHAR *buffer, size_t size); +bool FormatLatitude(Angle latitude, char *buffer, size_t size); /** * Convert a GeoPoint into a formatted string. */ -TCHAR *FormatGeoPoint(const GeoPoint &location, TCHAR *buffer, size_t size, - TCHAR separator = _T(' ')); +char *FormatGeoPoint(const GeoPoint &location, char *buffer, size_t size, + char separator = _T(' ')); [[gnu::pure]] -static inline BasicStringBuffer -FormatGeoPoint(const GeoPoint &location, TCHAR separator = _T(' ')) +static inline BasicStringBuffer +FormatGeoPoint(const GeoPoint &location, char separator = _T(' ')) { - BasicStringBuffer buffer; + BasicStringBuffer buffer; auto result = FormatGeoPoint(location, buffer.data(), buffer.capacity(), separator); if (result == nullptr) diff --git a/src/Formatter/UserUnits.cpp b/src/Formatter/UserUnits.cpp index f8203fa0626..65e43aa23d8 100644 --- a/src/Formatter/UserUnits.cpp +++ b/src/Formatter/UserUnits.cpp @@ -9,20 +9,20 @@ #include void -FormatUserWingLoading(double value, TCHAR *buffer, bool include_unit) noexcept +FormatUserWingLoading(double value, char *buffer, bool include_unit) noexcept { FormatWingLoading(buffer, value, Units::GetUserWingLoadingUnit(), include_unit); } void -FormatUserMass(double value, TCHAR *buffer, bool include_unit) noexcept +FormatUserMass(double value, char *buffer, bool include_unit) noexcept { FormatMass(buffer, value, Units::GetUserMassUnit(), include_unit); } void -FormatUserAltitude(double value, TCHAR *buffer, bool include_unit) noexcept +FormatUserAltitude(double value, char *buffer, bool include_unit) noexcept { FormatAltitude(buffer, value, Units::GetUserAltitudeUnit(), include_unit); } @@ -43,7 +43,7 @@ GetAlternateAltitudeUnit(Unit unit) noexcept } void -FormatAlternateUserAltitude(double value, TCHAR *buffer, bool include_unit) noexcept +FormatAlternateUserAltitude(double value, char *buffer, bool include_unit) noexcept { FormatAltitude(buffer, value, GetAlternateAltitudeUnit(Units::GetUserAltitudeUnit()), @@ -51,21 +51,21 @@ FormatAlternateUserAltitude(double value, TCHAR *buffer, bool include_unit) noex } void -FormatRelativeUserAltitude(double value, TCHAR *buffer, bool include_unit) noexcept +FormatRelativeUserAltitude(double value, char *buffer, bool include_unit) noexcept { FormatRelativeAltitude(buffer, value, Units::GetUserAltitudeUnit(), include_unit); } void -FormatUserDistance(double value, TCHAR *buffer, bool include_unit, int precision) noexcept +FormatUserDistance(double value, char *buffer, bool include_unit, int precision) noexcept { FormatDistance(buffer, value, Units::GetUserDistanceUnit(), include_unit, precision); } Unit -FormatSmallUserDistance(TCHAR *buffer, double value, bool include_unit, +FormatSmallUserDistance(char *buffer, double value, bool include_unit, int precision) noexcept { return FormatSmallDistance(buffer, value, Units::GetUserDistanceUnit(), @@ -73,7 +73,7 @@ FormatSmallUserDistance(TCHAR *buffer, double value, bool include_unit, } Unit -FormatUserDistanceSmart(double value, TCHAR *buffer, bool include_unit, +FormatUserDistanceSmart(double value, char *buffer, bool include_unit, double small_unit_threshold, double precision_threshold) noexcept { return FormatDistanceSmart(buffer, value, Units::GetUserDistanceUnit(), @@ -82,21 +82,21 @@ FormatUserDistanceSmart(double value, TCHAR *buffer, bool include_unit, } Unit -FormatUserMapScale(double value, TCHAR *buffer, bool include_unit) noexcept +FormatUserMapScale(double value, char *buffer, bool include_unit) noexcept { return FormatDistanceSmart(buffer, value, Units::GetUserDistanceUnit(), include_unit, 1000, 9.999); } void -FormatUserSpeed(double value, TCHAR *buffer, bool include_unit, bool precision) noexcept +FormatUserSpeed(double value, char *buffer, bool include_unit, bool precision) noexcept { FormatSpeed(buffer, value, Units::GetUserSpeedUnit(), include_unit, precision); } void -FormatUserWindSpeed(double value, TCHAR *buffer, bool include_unit, +FormatUserWindSpeed(double value, char *buffer, bool include_unit, bool precision) noexcept { FormatSpeed(buffer, value, Units::GetUserWindSpeedUnit(), include_unit, @@ -104,14 +104,14 @@ FormatUserWindSpeed(double value, TCHAR *buffer, bool include_unit, } void -FormatUserTaskSpeed(double value, TCHAR *buffer, bool include_unit, +FormatUserTaskSpeed(double value, char *buffer, bool include_unit, bool precision) noexcept { FormatSpeed(buffer, value, Units::GetUserTaskSpeedUnit(), include_unit, precision); } -const TCHAR * +const char * GetUserVerticalSpeedFormat(bool include_unit, bool include_sign) noexcept { return GetVerticalSpeedFormat(Units::GetUserVerticalSpeedUnit(), include_unit, @@ -125,7 +125,7 @@ GetUserVerticalSpeedStep() noexcept } void -FormatUserVerticalSpeed(double value, TCHAR *buffer, bool include_unit, +FormatUserVerticalSpeed(double value, char *buffer, bool include_unit, bool include_sign) noexcept { FormatVerticalSpeed(buffer, value, Units::GetUserVerticalSpeedUnit(), @@ -133,20 +133,20 @@ FormatUserVerticalSpeed(double value, TCHAR *buffer, bool include_unit, } void -FormatUserTemperature(double value, TCHAR *buffer, bool include_unit) noexcept +FormatUserTemperature(double value, char *buffer, bool include_unit) noexcept { FormatTemperature(buffer, value, Units::GetUserTemperatureUnit(), include_unit); } void -FormatUserPressure(AtmosphericPressure pressure, TCHAR *buffer, +FormatUserPressure(AtmosphericPressure pressure, char *buffer, bool include_unit) noexcept { FormatPressure(buffer, pressure, Units::GetUserPressureUnit(), include_unit); } -const TCHAR * +const char * GetUserPressureFormat(bool include_unit) noexcept { return GetPressureFormat(Units::GetUserPressureUnit(), include_unit); diff --git a/src/Formatter/UserUnits.hpp b/src/Formatter/UserUnits.hpp index d5258ad36df..c96c7d424d4 100644 --- a/src/Formatter/UserUnits.hpp +++ b/src/Formatter/UserUnits.hpp @@ -18,7 +18,7 @@ class AtmosphericPressure; * @param size Size of the buffer */ void -FormatUserWingLoading(double value, TCHAR *buffer, +FormatUserWingLoading(double value, char *buffer, bool include_unit = true) noexcept; /** @@ -28,7 +28,7 @@ FormatUserWingLoading(double value, TCHAR *buffer, * @param size Size of the buffer */ void -FormatUserMass(double value, TCHAR *buffer, +FormatUserMass(double value, char *buffer, bool include_unit = true) noexcept; /** @@ -38,14 +38,14 @@ FormatUserMass(double value, TCHAR *buffer, * @param size Size of the buffer */ void -FormatUserAltitude(double value, TCHAR *buffer, +FormatUserAltitude(double value, char *buffer, bool include_unit = true) noexcept; [[gnu::const]] static inline auto FormatUserAltitude(double value) noexcept { - BasicStringBuffer buffer; + BasicStringBuffer buffer; FormatUserAltitude(value, buffer.data()); return buffer; } @@ -58,7 +58,7 @@ FormatUserAltitude(double value) noexcept * @param size Size of the buffer */ void -FormatAlternateUserAltitude(double value, TCHAR *buffer, +FormatAlternateUserAltitude(double value, char *buffer, bool include_unit = true) noexcept; /** @@ -68,7 +68,7 @@ FormatAlternateUserAltitude(double value, TCHAR *buffer, * @param size Size of the buffer */ void -FormatRelativeUserAltitude(double value, TCHAR *buffer, +FormatRelativeUserAltitude(double value, char *buffer, bool include_unit = true) noexcept; /** @@ -79,7 +79,7 @@ FormatRelativeUserAltitude(double value, TCHAR *buffer, * @param precision the number of decimal places */ void -FormatUserDistance(double value, TCHAR *buffer, +FormatUserDistance(double value, char *buffer, bool include_unit = true, int precision = 0) noexcept; [[gnu::const]] @@ -87,7 +87,7 @@ static inline auto FormatUserDistance(double value, bool include_unit = true, int precision = 0) noexcept { - BasicStringBuffer buffer; + BasicStringBuffer buffer; FormatUserDistance(value, buffer.data(), include_unit, precision); return buffer; } @@ -103,7 +103,7 @@ FormatUserDistance(double value, * @return the unit used for output formatting */ Unit -FormatSmallUserDistance(TCHAR *buffer, double value, +FormatSmallUserDistance(char *buffer, double value, bool include_unit = true, int precision = 0) noexcept; /** @@ -113,7 +113,7 @@ FormatSmallUserDistance(TCHAR *buffer, double value, * @param size Size of the buffer */ Unit -FormatUserDistanceSmart(double value, TCHAR *buffer, +FormatUserDistanceSmart(double value, char *buffer, bool include_unit = true, double small_unit_threshold = 0, double precision_threshold = 100) noexcept; @@ -124,14 +124,14 @@ FormatUserDistanceSmart(double value, bool include_unit = true, double small_unit_threshold = 0, double precision_threshold = 100) noexcept { - BasicStringBuffer buffer; + BasicStringBuffer buffer; FormatUserDistanceSmart(value, buffer.data(), include_unit, small_unit_threshold, precision_threshold); return buffer; } Unit -FormatUserMapScale(double value, TCHAR *buffer, +FormatUserMapScale(double value, char *buffer, bool include_unit = true) noexcept; /** @@ -142,14 +142,14 @@ FormatUserMapScale(double value, TCHAR *buffer, * @return True if buffer long enough, False otherwise */ void -FormatUserSpeed(double value, TCHAR *buffer, +FormatUserSpeed(double value, char *buffer, bool include_unit = true, bool Precision = true) noexcept; [[gnu::const]] static inline auto FormatUserSpeed(double value, bool precision=true) noexcept { - BasicStringBuffer buffer; + BasicStringBuffer buffer; FormatUserSpeed(value, buffer.data(), true, precision); return buffer; } @@ -162,14 +162,14 @@ FormatUserSpeed(double value, bool precision=true) noexcept * @return True if buffer long enough, False otherwise */ void -FormatUserWindSpeed(double value, TCHAR *buffer, +FormatUserWindSpeed(double value, char *buffer, bool include_unit = true, bool Precision = true) noexcept; [[gnu::const]] static inline auto FormatUserWindSpeed(double value, bool include_unit = true, bool precision=true) noexcept { - BasicStringBuffer buffer; + BasicStringBuffer buffer; FormatUserWindSpeed(value, buffer.data(), include_unit, precision); return buffer; } @@ -181,14 +181,14 @@ FormatUserWindSpeed(double value, bool include_unit = true, bool precision=true) * @param value the speed value [m/s] */ void -FormatUserTaskSpeed(double value, TCHAR *buffer, +FormatUserTaskSpeed(double value, char *buffer, bool include_unit=true, bool precision=true) noexcept; [[gnu::const]] static inline auto FormatUserTaskSpeed(double value, bool precision=true) noexcept { - BasicStringBuffer buffer; + BasicStringBuffer buffer; FormatUserTaskSpeed(value, buffer.data(), true, precision); return buffer; } @@ -199,7 +199,7 @@ FormatUserTaskSpeed(double value, bool precision=true) noexcept * @param include_sign include the sign into the string? * @return the format */ -const TCHAR * +const char * GetUserVerticalSpeedFormat(bool include_unit = false, bool include_sign = true) noexcept; @@ -219,14 +219,14 @@ GetUserVerticalSpeedStep() noexcept; * @return True if buffer long enough, False otherwise */ void -FormatUserVerticalSpeed(double value, TCHAR *buffer, +FormatUserVerticalSpeed(double value, char *buffer, bool include_unit = true, bool include_sign = true) noexcept; [[gnu::const]] static inline auto FormatUserVerticalSpeed(double value, bool include_unit = true, bool include_sign = true) noexcept { - BasicStringBuffer buffer; + BasicStringBuffer buffer; FormatUserVerticalSpeed(value, buffer.data(), include_unit, include_sign); return buffer; } @@ -238,7 +238,7 @@ FormatUserVerticalSpeed(double value, bool include_unit = true, bool include_sig * @param size Size of the buffer */ void -FormatUserTemperature(double value, TCHAR *buffer, +FormatUserTemperature(double value, char *buffer, bool include_unit = true) noexcept; /** @@ -247,7 +247,7 @@ FormatUserTemperature(double value, TCHAR *buffer, * @param buffer buffer string to write to (pointer) * @param size Size of the buffer */ -void FormatUserPressure(AtmosphericPressure value, TCHAR *buffer, +void FormatUserPressure(AtmosphericPressure value, char *buffer, bool include_unit = true) noexcept; /** @@ -256,7 +256,7 @@ void FormatUserPressure(AtmosphericPressure value, TCHAR *buffer, * @param size Size of the buffer * @return True if buffer long enough, False otherwise */ -const TCHAR * +const char * GetUserPressureFormat(bool include_unit = false) noexcept; /** diff --git a/src/Gauge/BigThermalAssistantWindow.cpp b/src/Gauge/BigThermalAssistantWindow.cpp index 16551cc49fe..1167096062f 100644 --- a/src/Gauge/BigThermalAssistantWindow.cpp +++ b/src/Gauge/BigThermalAssistantWindow.cpp @@ -31,7 +31,7 @@ BigThermalAssistantWindow::OnMouseUp([[maybe_unused]] PixelPoint p) noexcept if (dragging) { StopDragging(); - const TCHAR *gesture = gestures.Finish(); + const char *gesture = gestures.Finish(); if (gesture && InputEvents::processGesture(gesture)) return true; } diff --git a/src/Gauge/BigTrafficWidget.cpp b/src/Gauge/BigTrafficWidget.cpp index 29e292ccc78..679e50da93f 100644 --- a/src/Gauge/BigTrafficWidget.cpp +++ b/src/Gauge/BigTrafficWidget.cpp @@ -108,7 +108,7 @@ class FlarmTrafficControl : public FlarmTrafficWindow { } protected: - bool OnMouseGesture(const TCHAR* gesture); + bool OnMouseGesture(const char* gesture); /* virtual methods from class Window */ void OnCreate() noexcept override; @@ -325,7 +325,7 @@ FlarmTrafficControl::PaintDistance(Canvas &canvas, PixelRect rc, double distance) const { // Format distance - TCHAR buffer[20]; + char buffer[20]; Unit unit = FormatUserDistanceSmart(distance, buffer, false, 1000); // Calculate unit size @@ -368,7 +368,7 @@ FlarmTrafficControl::PaintRelativeAltitude(Canvas &canvas, PixelRect rc, double relative_altitude) const { // Format relative altitude - TCHAR buffer[20]; + char buffer[20]; Unit unit = Units::GetUserAltitudeUnit(); FormatRelativeUserAltitude(relative_altitude, buffer, false); @@ -413,7 +413,7 @@ void FlarmTrafficControl::PaintID(Canvas &canvas, PixelRect rc, const FlarmTraffic &traffic) const { - TCHAR buffer[20]; + char buffer[20]; unsigned font_size; if (traffic.HasName()) { @@ -546,7 +546,7 @@ FlarmTrafficControl::OpenDetails() static Button MakeSymbolButton(ContainerWindow &parent, const ButtonLook &look, - const TCHAR *caption, + const char *caption, const PixelRect &rc, Button::Callback callback) noexcept { @@ -789,7 +789,7 @@ FlarmTrafficControl::OnMouseUp(PixelPoint p) noexcept if (dragging) { StopDragging(); - const TCHAR *gesture = gestures.Finish(); + const char *gesture = gestures.Finish(); if (gesture && OnMouseGesture(gesture)) return true; } @@ -809,7 +809,7 @@ FlarmTrafficControl::OnMouseDouble([[maybe_unused]] PixelPoint p) noexcept } bool -FlarmTrafficControl::OnMouseGesture(const TCHAR* gesture) +FlarmTrafficControl::OnMouseGesture(const char* gesture) { if (StringIsEqual(gesture, _T("U"))) { ZoomIn(); diff --git a/src/Gauge/FlarmTrafficWindow.cpp b/src/Gauge/FlarmTrafficWindow.cpp index c0dcb65defd..0f1b9188b65 100644 --- a/src/Gauge/FlarmTrafficWindow.cpp +++ b/src/Gauge/FlarmTrafficWindow.cpp @@ -206,7 +206,7 @@ FlarmTrafficWindow::PaintRadarNoTraffic(Canvas &canvas) const noexcept if (small) return; - const TCHAR* str = _("No Traffic"); + const char* str = _("No Traffic"); canvas.Select(look.no_traffic_font); PixelSize ts = canvas.CalcTextSize(str); canvas.SetTextColor(look.default_color); @@ -409,7 +409,7 @@ FlarmTrafficWindow::PaintRadarTarget(Canvas &canvas, canvas.Select(look.side_info_font); // Format string - TCHAR tmp[10]; + char tmp[10]; if (side_display_type == SideInfoType::VARIO) FormatUserVerticalSpeed(traffic.climb_rate_avg30s, tmp, false); diff --git a/src/Gauge/GaugeVario.cpp b/src/Gauge/GaugeVario.cpp index 281e7bfdce4..16b2e9ba4f2 100644 --- a/src/Gauge/GaugeVario.cpp +++ b/src/Gauge/GaugeVario.cpp @@ -231,7 +231,7 @@ GaugeVario::RenderBackground(Canvas &canvas, const PixelRect &rc) noexcept TransformRotatedPoint(r.Rotate(tick_end), geometry.offset)); - TCHAR label[16]; + char label[16]; StringFormatUnsafe(label, _T("%d"), i * tick_value_step); const auto label_size = canvas.CalcTextSize(label); @@ -484,7 +484,7 @@ GaugeVario::RenderNeedle(Canvas &canvas, int i, bool average, void GaugeVario::RenderValue(Canvas &canvas, const LabelValueGeometry &g, LabelValueDrawInfo &di, - double value, const TCHAR *label) noexcept + double value, const char *label) noexcept { value = (double)iround(value * 10) / 10; // prevent the -0.0 case @@ -514,7 +514,7 @@ GaugeVario::RenderValue(Canvas &canvas, const LabelValueGeometry &g, } if (!IsPersistent() || (dirty && di.value.last_value != value)) { - TCHAR buffer[18]; + char buffer[18]; canvas.SetBackgroundColor(look.background_color); canvas.SetTextColor(look.text_color); _stprintf(buffer, _T("%.1f"), (double)value); @@ -703,7 +703,7 @@ GaugeVario::RenderBallast(Canvas &canvas) noexcept // new ballast 0, hide value if (ballast > 0) { - TCHAR buffer[18]; + char buffer[18]; _stprintf(buffer, _T("%u%%"), ballast); canvas.SetTextColor(look.text_color); @@ -746,7 +746,7 @@ GaugeVario::RenderBugs(Canvas &canvas) noexcept } if (bugs > 0) { - TCHAR buffer[18]; + char buffer[18]; _stprintf(buffer, _T("%d%%"), bugs); canvas.SetTextColor(look.text_color); if (IsPersistent()) diff --git a/src/Gauge/GaugeVario.hpp b/src/Gauge/GaugeVario.hpp index 651b454d42a..3c56635b39c 100644 --- a/src/Gauge/GaugeVario.hpp +++ b/src/Gauge/GaugeVario.hpp @@ -68,7 +68,7 @@ class GaugeVario : public AntiFlickerWindow struct DrawInfo { unsigned last_width; double last_value; - TCHAR last_text[32]; + char last_text[32]; Unit last_unit; void Reset() noexcept { @@ -152,7 +152,7 @@ class GaugeVario : public AntiFlickerWindow void RenderZero(Canvas &canvas) noexcept; void RenderValue(Canvas &canvas, const LabelValueGeometry &g, LabelValueDrawInfo &di, - double Value, const TCHAR *Label) noexcept; + double Value, const char *Label) noexcept; void RenderSpeedToFly(Canvas &canvas, int x, int y) noexcept; void RenderBallast(Canvas &canvas) noexcept; void RenderBugs(Canvas &canvas) noexcept; diff --git a/src/Gauge/ThermalAssistantRenderer.cpp b/src/Gauge/ThermalAssistantRenderer.cpp index 32bc6b1d836..8c8a46acf9a 100644 --- a/src/Gauge/ThermalAssistantRenderer.cpp +++ b/src/Gauge/ThermalAssistantRenderer.cpp @@ -92,7 +92,7 @@ DrawCircleLabel(Canvas &canvas, PixelPoint p, static void DrawCircleLabelVSpeed(Canvas &canvas, PixelPoint p, double value) noexcept { - TCHAR buffer[10]; + char buffer[10]; FormatUserVerticalSpeed(value, buffer); DrawCircleLabel(canvas, p, buffer); } @@ -177,7 +177,7 @@ ThermalAssistantRenderer::PaintNotCircling(Canvas &canvas) const if (small) return; - const TCHAR* str = _("Not Circling"); + const char* str = _("Not Circling"); canvas.Select(look.overlay_font); canvas.SetTextColor(look.text_color); diff --git a/src/HorizonWidget.cpp b/src/HorizonWidget.cpp index 20e16d3cc3f..327aa2b145b 100644 --- a/src/HorizonWidget.cpp +++ b/src/HorizonWidget.cpp @@ -98,7 +98,7 @@ HorizonWindow::OnMouseUp([[maybe_unused]] PixelPoint p) noexcept if (dragging) { StopDragging(); - const TCHAR *gesture = gestures.Finish(); + const char *gesture = gestures.Finish(); if (gesture && InputEvents::processGesture(gesture)) return true; } diff --git a/src/IGC/Generator.cpp b/src/IGC/Generator.cpp index c98a1ad6c29..15c35346e8a 100644 --- a/src/IGC/Generator.cpp +++ b/src/IGC/Generator.cpp @@ -48,7 +48,7 @@ FormatIGCLocation(char *buffer, const GeoPoint &location) noexcept void FormatIGCTaskTurnPoint(std::span dest, const GeoPoint &location, - const TCHAR *name) noexcept + const char *name) noexcept { char *p = dest.data(); char *const end = p + dest.size(); diff --git a/src/IGC/Generator.hpp b/src/IGC/Generator.hpp index d26a1b69f8c..0ca51e52546 100644 --- a/src/IGC/Generator.hpp +++ b/src/IGC/Generator.hpp @@ -41,4 +41,4 @@ FormatIGCLocation(char *buffer, const GeoPoint &location) noexcept; void FormatIGCTaskTurnPoint(std::span dest, const GeoPoint &location, - const TCHAR *name) noexcept; + const char *name) noexcept; diff --git a/src/IGC/IGCWriter.cpp b/src/IGC/IGCWriter.cpp index 1c314f0efc8..d3e218f4b3b 100644 --- a/src/IGC/IGCWriter.cpp +++ b/src/IGC/IGCWriter.cpp @@ -47,7 +47,7 @@ IGCWriter::WriteLine(const char *line) } void -IGCWriter::WriteLine(const char *a, const TCHAR *b) +IGCWriter::WriteLine(const char *a, const char *b) { size_t a_length = strlen(a); assert(a_length < buffer.size()); @@ -63,12 +63,12 @@ IGCWriter::WriteLine(const char *a, const TCHAR *b) void IGCWriter::WriteHeader(const BrokenDateTime &date_time, - const TCHAR *pilot_name, - const TCHAR *copilot_name, - const TCHAR *aircraft_model, - const TCHAR *aircraft_registration, - const TCHAR *competition_id, - const char *logger_id, const TCHAR *driver_name, + const char *pilot_name, + const char *copilot_name, + const char *aircraft_model, + const char *aircraft_registration, + const char *competition_id, + const char *logger_id, const char *driver_name, bool simulator) { /* @@ -139,7 +139,7 @@ IGCWriter::EndDeclaration() } void -IGCWriter::AddDeclaration(const GeoPoint &location, const TCHAR *id) +IGCWriter::AddDeclaration(const GeoPoint &location, const char *id) { char c_record[64]; FormatIGCTaskTurnPoint(c_record, location, id); @@ -147,7 +147,7 @@ IGCWriter::AddDeclaration(const GeoPoint &location, const TCHAR *id) } void -IGCWriter::LoggerNote(const TCHAR *text) +IGCWriter::LoggerNote(const char *text) { WriteLine("LPLT", text); } diff --git a/src/IGC/IGCWriter.hpp b/src/IGC/IGCWriter.hpp index 74ade5c4ed9..bad5c75bf88 100644 --- a/src/IGC/IGCWriter.hpp +++ b/src/IGC/IGCWriter.hpp @@ -48,7 +48,7 @@ class IGCWriter { void CommitLine(std::string_view line); void WriteLine(const char *line); - void WriteLine(const char *a, const TCHAR *b); + void WriteLine(const char *a, const char *b); static const char *GetHFFXARecord(); static const char *GetIRecord(); @@ -62,20 +62,20 @@ class IGCWriter { * alphanumeric characters (plain ASCII) */ void WriteHeader(const BrokenDateTime &date_time, - const TCHAR *pilot_name, - const TCHAR *copilot_name, - const TCHAR *aircraft_model, - const TCHAR *aircraft_registration, - const TCHAR *competition_id, - const char *logger_id, const TCHAR *driver_name, + const char *pilot_name, + const char *copilot_name, + const char *aircraft_model, + const char *aircraft_registration, + const char *competition_id, + const char *logger_id, const char *driver_name, bool simulator); - void AddDeclaration(const GeoPoint &location, const TCHAR *ID); + void AddDeclaration(const GeoPoint &location, const char *ID); void StartDeclaration(const BrokenDateTime &date_time, const int number_of_turnpoints); void EndDeclaration(); - void LoggerNote(const TCHAR *text); + void LoggerNote(const char *text); void LogPoint(const IGCFix &fix, int epe, int satellites); void LogPoint(const NMEAInfo &gps_info); diff --git a/src/InfoBoxes/Content/Factory.cpp b/src/InfoBoxes/Content/Factory.cpp index 4781de23ac4..2f1952f7c06 100644 --- a/src/InfoBoxes/Content/Factory.cpp +++ b/src/InfoBoxes/Content/Factory.cpp @@ -70,9 +70,9 @@ struct IBFHelperInt { using namespace InfoBoxFactory; struct MetaData { - const TCHAR *name; - const TCHAR *caption; - const TCHAR *description; + const char *name; + const char *caption; + const char *description; InfoBoxContent *(*create)() noexcept; void (*update)(InfoBoxData &data) noexcept; const InfoBoxPanel *panels; @@ -84,23 +84,23 @@ struct MetaData { */ MetaData() = delete; - constexpr MetaData(const TCHAR *_name, - const TCHAR *_caption, - const TCHAR *_description, + constexpr MetaData(const char *_name, + const char *_caption, + const char *_description, InfoBoxContent *(*_create)() noexcept) noexcept :name(_name), caption(_caption), description(_description), create(_create), update(nullptr), panels(nullptr) {} - constexpr MetaData(const TCHAR *_name, - const TCHAR *_caption, - const TCHAR *_description, + constexpr MetaData(const char *_name, + const char *_caption, + const char *_description, void (*_update)(InfoBoxData &data) noexcept) noexcept :name(_name), caption(_caption), description(_description), create(nullptr), update(_update), panels(nullptr) {} - constexpr MetaData(const TCHAR *_name, - const TCHAR *_caption, - const TCHAR *_description, + constexpr MetaData(const char *_name, + const char *_caption, + const char *_description, void (*_update)(InfoBoxData &data) noexcept, const InfoBoxPanel _panels[]) noexcept :name(_name), caption(_caption), description(_description), @@ -1219,7 +1219,7 @@ static constexpr MetaData meta_data_2nd[] = { // static_assert(ARRAY_SIZE(meta_data_2nd) == NUM_TYPES_2nd - e_NUM_AREA_2nd, "Wrong InfoBox factory size"); -const TCHAR * +const char * InfoBoxFactory::GetName(Type type) noexcept { assert(TypeIsValid(type)); @@ -1227,7 +1227,7 @@ InfoBoxFactory::GetName(Type type) noexcept : meta_data_2nd[type - e_NUM_AREA_2nd].name; } -const TCHAR * +const char * InfoBoxFactory::GetCaption(Type type) noexcept { assert(TypeIsValid(type)); @@ -1239,7 +1239,7 @@ InfoBoxFactory::GetCaption(Type type) noexcept /** * Returns the long description (help text) of the info box type. */ -const TCHAR * +const char * InfoBoxFactory::GetDescription(Type type) noexcept { assert(TypeIsValid(type)); diff --git a/src/InfoBoxes/Content/Factory.hpp b/src/InfoBoxes/Content/Factory.hpp index f44de526432..f2e7cac78ff 100644 --- a/src/InfoBoxes/Content/Factory.hpp +++ b/src/InfoBoxes/Content/Factory.hpp @@ -16,7 +16,7 @@ namespace InfoBoxFactory * Returns the human-readable name of the info box type. */ [[gnu::const]] - const TCHAR * + const char * GetName(Type type) noexcept; /** @@ -25,14 +25,14 @@ namespace InfoBoxFactory * fit in the small #InfoBoxWindow. */ [[gnu::const]] - const TCHAR * + const char * GetCaption(Type type) noexcept; /** * Returns the long description (help text) of the info box type. */ [[gnu::const]] - const TCHAR * + const char * GetDescription(Type type) noexcept; std::unique_ptr Create(Type infobox_type) noexcept; diff --git a/src/InfoBoxes/Content/MacCready.cpp b/src/InfoBoxes/Content/MacCready.cpp index 4f5fcd63ede..9da4e5c0cac 100644 --- a/src/InfoBoxes/Content/MacCready.cpp +++ b/src/InfoBoxes/Content/MacCready.cpp @@ -16,7 +16,7 @@ static void SetVSpeed(InfoBoxData &data, double value) noexcept { - TCHAR buffer[32]; + char buffer[32]; FormatUserVerticalSpeed(value, buffer, false); data.SetValue(buffer[0] == _T('+') ? buffer + 1 : buffer); data.SetValueUnit(Units::current.vertical_speed_unit); diff --git a/src/InfoBoxes/Content/Other.cpp b/src/InfoBoxes/Content/Other.cpp index 62b85db14dd..32d2360b307 100644 --- a/src/InfoBoxes/Content/Other.cpp +++ b/src/InfoBoxes/Content/Other.cpp @@ -162,7 +162,7 @@ InfoBoxContentHorizon::Update(InfoBoxData &data) noexcept // TODO: merge with original copy from Dialogs/StatusPanels/SystemStatusPanel.cpp [[gnu::pure]] -static const TCHAR * +static const char * GetGPSStatus(const NMEAInfo &basic) noexcept { if (!basic.alive) diff --git a/src/InfoBoxes/Content/Radio.cpp b/src/InfoBoxes/Content/Radio.cpp index 9d99b38aa96..b55d9bbacf7 100644 --- a/src/InfoBoxes/Content/Radio.cpp +++ b/src/InfoBoxes/Content/Radio.cpp @@ -14,7 +14,7 @@ static void UpdateInfoBoxFrequency(InfoBoxData &data, const RadioFrequency freq, - const TCHAR *freq_name) noexcept + const char *freq_name) noexcept { if(freq.IsDefined()) { freq.Format(data.value.data(), data.value.capacity()); diff --git a/src/InfoBoxes/Content/Thermal.cpp b/src/InfoBoxes/Content/Thermal.cpp index 35897330237..9766233bf76 100644 --- a/src/InfoBoxes/Content/Thermal.cpp +++ b/src/InfoBoxes/Content/Thermal.cpp @@ -16,7 +16,7 @@ static void SetVSpeed(InfoBoxData &data, double value) noexcept { - TCHAR buffer[32]; + char buffer[32]; FormatUserVerticalSpeed(value, buffer, false); data.SetValue(buffer[0] == _T('+') ? buffer + 1 : buffer); data.SetValueUnit(Units::current.vertical_speed_unit); @@ -210,7 +210,7 @@ UpdateInfoBoxCircleDiameter(InfoBoxData &data) noexcept return; } - TCHAR buffer[32]; + char buffer[32]; Unit unit = FormatSmallUserDistance(buffer, circle_diameter, false, 0); data.SetValue (buffer); data.SetValueUnit(unit); diff --git a/src/InfoBoxes/Content/Trace.cpp b/src/InfoBoxes/Content/Trace.cpp index 59f51d7fec0..1f509d600eb 100644 --- a/src/InfoBoxes/Content/Trace.cpp +++ b/src/InfoBoxes/Content/Trace.cpp @@ -114,7 +114,7 @@ void InfoBoxContentBarogram::Update(InfoBoxData &data) noexcept { const MoreData &basic = CommonInterface::Basic(); - TCHAR sTmp[32]; + char sTmp[32]; if (basic.NavAltitudeAvailable()) { FormatUserAltitude(basic.nav_altitude, sTmp); diff --git a/src/InfoBoxes/Content/Weather.cpp b/src/InfoBoxes/Content/Weather.cpp index 80cd9f7ecb2..a2395ff3401 100644 --- a/src/InfoBoxes/Content/Weather.cpp +++ b/src/InfoBoxes/Content/Weather.cpp @@ -124,7 +124,7 @@ UpdateInfoBoxWindBearing(InfoBoxData &data) noexcept data.SetValue(info.wind.bearing); - TCHAR buffer[16]; + char buffer[16]; FormatUserWindSpeed(info.wind.norm, buffer, true, false); data.SetComment(buffer); } @@ -157,7 +157,7 @@ void UpdateInfoBoxInstWindBearing(InfoBoxData &data) noexcept data.SetValue(info.external_instantaneous_wind.bearing); - TCHAR buffer[16]; + char buffer[16]; FormatUserWindSpeed(info.external_instantaneous_wind.norm, buffer, true, false); data.SetComment(buffer); @@ -210,7 +210,7 @@ InfoBoxContentWindArrow::Update(InfoBoxData &data) noexcept data.SetCustom(info.wind_available.ToInteger() + basic.attitude.heading_available.ToInteger()); - TCHAR speed_buffer[16]; + char speed_buffer[16]; FormatUserWindSpeed(info.wind.norm, speed_buffer, true, false); StaticString<36> buffer; diff --git a/src/InfoBoxes/Data.cpp b/src/InfoBoxes/Data.cpp index 2f93bf88606..395b4adc2d2 100644 --- a/src/InfoBoxes/Data.cpp +++ b/src/InfoBoxes/Data.cpp @@ -29,20 +29,20 @@ InfoBoxData::SetValueInvalid() noexcept } void -InfoBoxData::SetTitle(const TCHAR *_title) noexcept +InfoBoxData::SetTitle(const char *_title) noexcept { title = _title; title.CropIncompleteUTF8(); } void -InfoBoxData::SetValue(const TCHAR *_value) noexcept +InfoBoxData::SetValue(const char *_value) noexcept { value = _value; } void -InfoBoxData::SetComment(const TCHAR *_comment) noexcept +InfoBoxData::SetComment(const char *_comment) noexcept { comment = _comment; comment.CropIncompleteUTF8(); diff --git a/src/InfoBoxes/Data.hpp b/src/InfoBoxes/Data.hpp index 03aa114a2c4..14905531333 100644 --- a/src/InfoBoxes/Data.hpp +++ b/src/InfoBoxes/Data.hpp @@ -77,9 +77,9 @@ struct InfoBoxData { * * @param title New value of the InfoBox title */ - void SetTitle(const TCHAR *title) noexcept; + void SetTitle(const char *title) noexcept; - const TCHAR *GetTitle() const { + const char *GetTitle() const { return title; }; @@ -105,7 +105,7 @@ struct InfoBoxData { * Sets the InfoBox value to the given Value * @param Value New value of the InfoBox value */ - void SetValue(const TCHAR *value) noexcept; + void SetValue(const char *value) noexcept; void VFmtValue(fmt_tstring_view format_str, fmt_tformat_args args) noexcept { auto [p, _] = fmt::vformat_to_n(value.begin(), value.capacity() - 1, @@ -128,7 +128,7 @@ struct InfoBoxData { /** * Sets the InfoBox value to the given angle. */ - void SetValue(Angle value, const TCHAR *suffix=_T("")) noexcept; + void SetValue(Angle value, const char *suffix=_T("")) noexcept; void SetValueFromBearingDifference(Angle delta) noexcept; @@ -176,7 +176,7 @@ struct InfoBoxData { * Sets the InfoBox comment to the given Value * @param Value New value of the InfoBox comment */ - void SetComment(const TCHAR *comment) noexcept; + void SetComment(const char *comment) noexcept; void VFmtComment(fmt_tstring_view format_str, fmt_tformat_args args) noexcept { auto [p, _] = fmt::vformat_to_n(comment.begin(), comment.capacity() - 1, @@ -199,7 +199,7 @@ struct InfoBoxData { /** * Sets the InfoBox comment to the given angle. */ - void SetComment(Angle comment, const TCHAR *suffix=_T("")) noexcept; + void SetComment(Angle comment, const char *suffix=_T("")) noexcept; void SetCommentFromDistance(double value) noexcept; diff --git a/src/InfoBoxes/Format.cpp b/src/InfoBoxes/Format.cpp index 5294418a585..076de9a9a38 100644 --- a/src/InfoBoxes/Format.cpp +++ b/src/InfoBoxes/Format.cpp @@ -8,7 +8,7 @@ #include "Math/Angle.hpp" void -InfoBoxData::SetValue(Angle _value, const TCHAR *suffix) noexcept +InfoBoxData::SetValue(Angle _value, const char *suffix) noexcept { assert(suffix != NULL); @@ -29,7 +29,7 @@ InfoBoxData::SetValueFromGlideRatio(double gr) noexcept } void -InfoBoxData::SetComment(Angle _value, const TCHAR *suffix) noexcept +InfoBoxData::SetComment(Angle _value, const char *suffix) noexcept { assert(suffix != NULL); diff --git a/src/InfoBoxes/InfoBoxManager.cpp b/src/InfoBoxes/InfoBoxManager.cpp index 07c2fd6a58f..56cdae0ba0e 100644 --- a/src/InfoBoxes/InfoBoxManager.cpp +++ b/src/InfoBoxes/InfoBoxManager.cpp @@ -186,7 +186,7 @@ InfoBoxManager::ShowInfoBoxPicker(const int i) noexcept ComboList list; for (unsigned j = InfoBoxFactory::MIN_TYPE_VAL; j < InfoBoxFactory::NUM_TYPES; j++) { - const TCHAR *desc = InfoBoxFactory::GetDescription((InfoBoxFactory::Type)j); + const char *desc = InfoBoxFactory::GetDescription((InfoBoxFactory::Type)j); list.Append(j, gettext(InfoBoxFactory::GetName((InfoBoxFactory::Type)j)), gettext(InfoBoxFactory::GetName((InfoBoxFactory::Type)j)), desc != NULL ? gettext(desc) : NULL); @@ -194,7 +194,7 @@ InfoBoxManager::ShowInfoBoxPicker(const int i) noexcept for (unsigned j = InfoBoxFactory::e_NUM_AREA_2nd; j < InfoBoxFactory::NUM_TYPES_2nd; j++) { const InfoBoxFactory::Type type = (InfoBoxFactory::Type)(j); - const TCHAR *desc = InfoBoxFactory::GetDescription(type); + const char *desc = InfoBoxFactory::GetDescription(type); list.Append(j, gettext(InfoBoxFactory::GetName(type)), gettext(InfoBoxFactory::GetName(type)), desc != NULL ? gettext(desc) : NULL); diff --git a/src/InfoBoxes/InfoBoxWindow.cpp b/src/InfoBoxes/InfoBoxWindow.cpp index ffc5bd51b0b..8f478b80ced 100644 --- a/src/InfoBoxes/InfoBoxWindow.cpp +++ b/src/InfoBoxes/InfoBoxWindow.cpp @@ -35,7 +35,7 @@ InfoBoxWindow::InfoBoxWindow(ContainerWindow &parent, PixelRect rc, } void -InfoBoxWindow::SetTitle(const TCHAR *_title) +InfoBoxWindow::SetTitle(const char *_title) { data.SetTitle(_title); Invalidate(title_rect); diff --git a/src/InfoBoxes/InfoBoxWindow.hpp b/src/InfoBoxes/InfoBoxWindow.hpp index 13b14c9ad43..c91d3c1986c 100644 --- a/src/InfoBoxes/InfoBoxWindow.hpp +++ b/src/InfoBoxes/InfoBoxWindow.hpp @@ -91,9 +91,9 @@ class InfoBoxWindow : public LazyPaintWindow * Sets the InfoBox title to the given Value * @param Value New value of the InfoBox title */ - void SetTitle(const TCHAR *title); + void SetTitle(const char *title); - const TCHAR* GetTitle() { + const char* GetTitle() { return data.title; }; diff --git a/src/InfoBoxes/Panel/ATCReference.cpp b/src/InfoBoxes/Panel/ATCReference.cpp index 0dda554dc21..c27db49b34b 100644 --- a/src/InfoBoxes/Panel/ATCReference.cpp +++ b/src/InfoBoxes/Panel/ATCReference.cpp @@ -43,8 +43,8 @@ ATCReferencePanel::UpdateValues() noexcept SetText(WAYPOINT, waypoint != nullptr ? waypoint->name.c_str() : _T("---")); - const TCHAR *location_string; - TCHAR buffer[64]; + const char *location_string; + char buffer[64]; if (location.IsValid()) { FormatGeoPoint(location, buffer, ARRAY_SIZE(buffer), CommonInterface::GetUISettings().format.coordinate_format); diff --git a/src/InfoBoxes/Panel/Panel.hpp b/src/InfoBoxes/Panel/Panel.hpp index c12244bfe13..dc9af6a199e 100644 --- a/src/InfoBoxes/Panel/Panel.hpp +++ b/src/InfoBoxes/Panel/Panel.hpp @@ -10,9 +10,9 @@ class Widget; struct InfoBoxPanel { constexpr - InfoBoxPanel(const TCHAR *_name, std::unique_ptr (*_load)(unsigned id)) + InfoBoxPanel(const char *_name, std::unique_ptr (*_load)(unsigned id)) :name(_name), load(_load) {}; - const TCHAR *name; + const char *name; std::unique_ptr (*load)(unsigned id); }; diff --git a/src/Input/InputConfig.hpp b/src/Input/InputConfig.hpp index 339a6c7656e..f7f93cb90be 100644 --- a/src/Input/InputConfig.hpp +++ b/src/Input/InputConfig.hpp @@ -30,14 +30,14 @@ struct InputConfig { #endif static constexpr std::size_t MAX_EVENTS = 2048; - typedef void (*pt2Event)(const TCHAR *); + typedef void (*pt2Event)(const char *); // Events - What do you want to DO struct Event { // Which function to call (can be any, but should be here) pt2Event event; // Parameters - const TCHAR *misc; + const char *misc; // Next in event list - eg: Macros unsigned next; }; @@ -102,7 +102,7 @@ struct InputConfig { return mode; } - std::size_t AppendEvent(pt2Event handler, const TCHAR *misc, + std::size_t AppendEvent(pt2Event handler, const char *misc, unsigned next) noexcept { if (events.full()) return 0; @@ -115,7 +115,7 @@ struct InputConfig { return events.size() - 1; } - void AppendMenu(std::size_t mode_id, const TCHAR *label, + void AppendMenu(std::size_t mode_id, const char *label, unsigned location, unsigned event_id) noexcept { assert(mode_id < MAX_MODE); diff --git a/src/Input/InputDefaults.cpp b/src/Input/InputDefaults.cpp index 97a54e199f4..656d7616c29 100644 --- a/src/Input/InputDefaults.cpp +++ b/src/Input/InputDefaults.cpp @@ -44,13 +44,13 @@ struct flat_event_map { struct flat_label { unsigned char mode, location; unsigned short event; - const TCHAR *label; + const char *label; }; struct flat_gesture_map { unsigned char mode; unsigned short event; - const TCHAR *data; + const char *data; }; // Make a new label (add to the end each time) @@ -58,7 +58,7 @@ struct flat_gesture_map { // without taking up more data - but when loading from file must copy string static void makeLabel(InputConfig &input_config, - InputEvents::Mode mode_id, const TCHAR* label, + InputEvents::Mode mode_id, const char* label, unsigned location, unsigned event_id) { input_config.AppendMenu(mode_id, label, location, event_id); @@ -66,7 +66,7 @@ makeLabel(InputConfig &input_config, static void apply_defaults(InputConfig &input_config, - const TCHAR *const* default_modes, + const char *const* default_modes, const InputConfig::Event *default_events, unsigned num_default_events, const flat_gesture_map *default_gesture2event, diff --git a/src/Input/InputEvents.cpp b/src/Input/InputEvents.cpp index 9d22a3bd1f8..5a516e08f83 100644 --- a/src/Input/InputEvents.cpp +++ b/src/Input/InputEvents.cpp @@ -54,7 +54,7 @@ doc/html/advanced/input/ALL http://xcsoar.sourceforge.net/advanced/input/ namespace InputEvents { -static const TCHAR *flavour; +static const char *flavour; static Mode current_mode = InputEvents::MODE_DEFAULT; @@ -81,7 +81,7 @@ UpdateOverlayMode() noexcept; [[gnu::pure]] static unsigned -gesture_to_event(const TCHAR *data) noexcept; +gesture_to_event(const char *data) noexcept; /** * @param full if false, update only the dynamic labels @@ -131,7 +131,7 @@ InputEvents::setMode(Mode mode) noexcept } void -InputEvents::setMode(const TCHAR *mode) noexcept +InputEvents::setMode(const char *mode) noexcept { int m = input_config.LookupMode(mode); if (m >= 0) @@ -145,7 +145,7 @@ InputEvents::UpdatePan() noexcept } void -InputEvents::SetFlavour(const TCHAR *_flavour) noexcept +InputEvents::SetFlavour(const char *_flavour) noexcept { if (flavour == NULL && _flavour == NULL) /* optimised default case */ @@ -162,7 +162,7 @@ InputEvents::SetFlavour(const TCHAR *_flavour) noexcept } bool -InputEvents::IsFlavour(const TCHAR *_flavour) noexcept +InputEvents::IsFlavour(const char *_flavour) noexcept { if (flavour == NULL) return _flavour == NULL; @@ -357,19 +357,19 @@ InputEvents::processKey(unsigned key_code) noexcept } unsigned -InputEvents::gesture_to_event(const TCHAR *data) noexcept +InputEvents::gesture_to_event(const char *data) noexcept { return input_config.Gesture2Event.Get(data, 0); } bool -InputEvents::IsGesture(const TCHAR *data) noexcept +InputEvents::IsGesture(const char *data) noexcept { return (Lua::IsGesture(data)) || (gesture_to_event(data) != 0); } bool -InputEvents::processGesture(const TCHAR *data) noexcept +InputEvents::processGesture(const char *data) noexcept { // start with lua event if available! if (Lua::FireGesture(data)) @@ -386,7 +386,7 @@ InputEvents::processGesture(const TCHAR *data) noexcept } /* - InputEvent::processNmea(TCHAR *data) + InputEvent::processNmea(char *data) Take hard coded inputs from NMEA processor. Return = TRUE if we have a valid key match */ @@ -468,7 +468,7 @@ InputEvents::ShowMenu() noexcept } Menu * -InputEvents::GetMenu(const TCHAR *mode) noexcept +InputEvents::GetMenu(const char *mode) noexcept { int m = input_config.LookupMode(mode); if (m >= 0) @@ -501,7 +501,7 @@ InputEvents::ProcessTimer() noexcept } void -InputEvents::eventLockScreen([[maybe_unused]] const TCHAR *mode) +InputEvents::eventLockScreen([[maybe_unused]] const char *mode) { ShowLockBox(); } diff --git a/src/Input/InputEvents.hpp b/src/Input/InputEvents.hpp index 557e72ae79e..b0688d4d971 100644 --- a/src/Input/InputEvents.hpp +++ b/src/Input/InputEvents.hpp @@ -10,7 +10,7 @@ struct InputConfig; class Menu; -typedef void (*pt2Event)(const TCHAR *); +typedef void (*pt2Event)(const char *); namespace InputEvents { @@ -31,7 +31,7 @@ void HideMenu() noexcept; Menu * -GetMenu(const TCHAR *mode) noexcept; +GetMenu(const char *mode) noexcept; /** * Load the default input file (Data/Input/default.xci). @@ -47,7 +47,7 @@ void setMode(Mode mode) noexcept; void -setMode(const TCHAR *mode) noexcept; +setMode(const char *mode) noexcept; /** * Update the menu after pan mode has been enabled or disabled. @@ -64,7 +64,7 @@ UpdatePan() noexcept; * @param flavour the new flavour name; may be NULL */ void -SetFlavour(const TCHAR *flavour) noexcept; +SetFlavour(const char *flavour) noexcept; /** * Is the specified flavour currently active? @@ -73,7 +73,7 @@ SetFlavour(const TCHAR *flavour) noexcept; */ [[gnu::pure]] bool -IsFlavour(const TCHAR *flavour) noexcept; +IsFlavour(const char *flavour) noexcept; /** * @return: true if current mode is MODE_DEFAULT @@ -98,10 +98,10 @@ bool processKey(unsigned key) noexcept; bool -processGesture(const TCHAR *data) noexcept; +processGesture(const char *data) noexcept; bool -IsGesture(const TCHAR *data) noexcept; +IsGesture(const char *data) noexcept; bool processNmea_real(unsigned key) noexcept; @@ -120,83 +120,83 @@ void sub_SetZoom(double value); // ------- -void eventAbortTask(const TCHAR *misc); -void eventAdjustForecastTemperature(const TCHAR *misc); -void eventAdjustVarioFilter(const TCHAR *misc); -void eventAdjustWaypoint(const TCHAR *misc); -void eventAnalysis(const TCHAR *misc); -void eventArmAdvance(const TCHAR *misc); -void eventAudioDeadband(const TCHAR *misc); -void eventBallast(const TCHAR *misc); -void eventBugs(const TCHAR *misc); -void eventCalculator(const TCHAR *misc); -void eventChecklist(const TCHAR *misc); -void eventClearAirspaceWarnings(const TCHAR *misc); -void eventClearStatusMessages(const TCHAR *misc); -void eventLogger(const TCHAR *misc); -void eventMacCready(const TCHAR *misc); -void eventMainMenu(const TCHAR *misc); -void eventMarkLocation(const TCHAR *misc); -void eventPilotEvent(const TCHAR *misc); -void eventMode(const TCHAR *misc); -void eventNearestAirspaceDetails(const TCHAR *misc); -void eventNearestWaypointDetails(const TCHAR *misc); -void eventNearestMapItems(const TCHAR *misc); -void eventNull(const TCHAR *misc); -void eventPage(const TCHAR *misc); -void eventPan(const TCHAR *misc); -void eventPlaySound(const TCHAR *misc); -void eventProfileLoad(const TCHAR *misc); -void eventProfileSave(const TCHAR *misc); -void eventRepeatStatusMessage(const TCHAR *misc); -void eventRun(const TCHAR *misc); -void eventScreenModes(const TCHAR *misc); -void eventDevice(const TCHAR *misc); -void eventSendNMEA(const TCHAR *misc); -void eventSendNMEAPort1(const TCHAR *misc); -void eventSendNMEAPort2(const TCHAR *misc); -void eventSetup(const TCHAR *misc); -void eventSnailTrail(const TCHAR *misc); -void eventAirSpace(const TCHAR *misc); // VENTA3 -void eventSounds(const TCHAR *misc); -void eventStatus(const TCHAR *misc); -void eventStatusMessage(const TCHAR *misc); -void eventTaskLoad(const TCHAR *misc); -void eventTaskSave(const TCHAR *misc); -void eventTaskTransition(const TCHAR *misc); -void eventTerrainTopography(const TCHAR *misc); -void eventTerrainTopology(const TCHAR *misc); -void eventWaypointDetails(const TCHAR *misc); -void eventWaypointEditor(const TCHAR *misc); -void eventZoom(const TCHAR *misc); -void eventBrightness(const TCHAR *misc); -void eventDeclutterLabels(const TCHAR *misc); -void eventExit(const TCHAR *misc); -void eventFLARMRadar(const TCHAR *misc); -void eventThermalAssistant(const TCHAR *misc); -void eventBeep(const TCHAR *misc); -void eventUserDisplayModeForce(const TCHAR *misc); -void eventAirspaceDisplayMode(const TCHAR *misc); -void eventAutoLogger(const TCHAR *misc); -void eventGotoLookup(const TCHAR *misc); -void eventAddWaypoint(const TCHAR *misc); -void eventOrientation(const TCHAR *misc); -void eventTraffic(const TCHAR *misc); -void eventFlarmTraffic(const TCHAR *misc); -void eventFlarmDetails(const TCHAR *misc); -void eventCredits(const TCHAR *misc); -void eventWeather(const TCHAR *misc); -void eventQuickMenu(const TCHAR *misc); -void eventFileManager(const TCHAR *misc); -void eventRunLuaFile(const TCHAR *misc); -void eventResetTask(const TCHAR *misc); -void eventLockScreen(const TCHAR *misc); -void eventExchangeFrequencies(const TCHAR *misc); +void eventAbortTask(const char *misc); +void eventAdjustForecastTemperature(const char *misc); +void eventAdjustVarioFilter(const char *misc); +void eventAdjustWaypoint(const char *misc); +void eventAnalysis(const char *misc); +void eventArmAdvance(const char *misc); +void eventAudioDeadband(const char *misc); +void eventBallast(const char *misc); +void eventBugs(const char *misc); +void eventCalculator(const char *misc); +void eventChecklist(const char *misc); +void eventClearAirspaceWarnings(const char *misc); +void eventClearStatusMessages(const char *misc); +void eventLogger(const char *misc); +void eventMacCready(const char *misc); +void eventMainMenu(const char *misc); +void eventMarkLocation(const char *misc); +void eventPilotEvent(const char *misc); +void eventMode(const char *misc); +void eventNearestAirspaceDetails(const char *misc); +void eventNearestWaypointDetails(const char *misc); +void eventNearestMapItems(const char *misc); +void eventNull(const char *misc); +void eventPage(const char *misc); +void eventPan(const char *misc); +void eventPlaySound(const char *misc); +void eventProfileLoad(const char *misc); +void eventProfileSave(const char *misc); +void eventRepeatStatusMessage(const char *misc); +void eventRun(const char *misc); +void eventScreenModes(const char *misc); +void eventDevice(const char *misc); +void eventSendNMEA(const char *misc); +void eventSendNMEAPort1(const char *misc); +void eventSendNMEAPort2(const char *misc); +void eventSetup(const char *misc); +void eventSnailTrail(const char *misc); +void eventAirSpace(const char *misc); // VENTA3 +void eventSounds(const char *misc); +void eventStatus(const char *misc); +void eventStatusMessage(const char *misc); +void eventTaskLoad(const char *misc); +void eventTaskSave(const char *misc); +void eventTaskTransition(const char *misc); +void eventTerrainTopography(const char *misc); +void eventTerrainTopology(const char *misc); +void eventWaypointDetails(const char *misc); +void eventWaypointEditor(const char *misc); +void eventZoom(const char *misc); +void eventBrightness(const char *misc); +void eventDeclutterLabels(const char *misc); +void eventExit(const char *misc); +void eventFLARMRadar(const char *misc); +void eventThermalAssistant(const char *misc); +void eventBeep(const char *misc); +void eventUserDisplayModeForce(const char *misc); +void eventAirspaceDisplayMode(const char *misc); +void eventAutoLogger(const char *misc); +void eventGotoLookup(const char *misc); +void eventAddWaypoint(const char *misc); +void eventOrientation(const char *misc); +void eventTraffic(const char *misc); +void eventFlarmTraffic(const char *misc); +void eventFlarmDetails(const char *misc); +void eventCredits(const char *misc); +void eventWeather(const char *misc); +void eventQuickMenu(const char *misc); +void eventFileManager(const char *misc); +void eventRunLuaFile(const char *misc); +void eventResetTask(const char *misc); +void eventLockScreen(const char *misc); +void eventExchangeFrequencies(const char *misc); #if 1 // def IS_OPENVARIO -void eventShutdown(const TCHAR *misc); +void eventShutdown(const char *misc); #endif -void eventUploadIGCFile(const TCHAR *misc); -void eventKeyPressed(const TCHAR *misc); +void eventUploadIGCFile(const char *misc); +void eventKeyPressed(const char *misc); // ------- } // namespace InputEvents diff --git a/src/Input/InputEventsActions.cpp b/src/Input/InputEventsActions.cpp index 0ae903c2340..4f3d9b83238 100644 --- a/src/Input/InputEventsActions.cpp +++ b/src/Input/InputEventsActions.cpp @@ -148,7 +148,7 @@ SuspendAppendSaveWaypoint(Waypoint &&wp) // TODO code: Keep marker text for use in log file etc. void -InputEvents::eventMarkLocation(const TCHAR *misc) +InputEvents::eventMarkLocation(const char *misc) { const NMEAInfo &basic = CommonInterface::Basic(); @@ -167,7 +167,7 @@ InputEvents::eventMarkLocation(const TCHAR *misc) Waypoint wp = factory.Create(location); factory.FallbackElevation(wp); - TCHAR name[64] = _T("Marker"); + char name[64] = _T("Marker"); if (basic.date_time_utc.IsPlausible()) { auto *p = name + StringLength(name); *p++ = _T(' ' ); @@ -187,7 +187,7 @@ InputEvents::eventMarkLocation(const TCHAR *misc) } void -InputEvents::eventPilotEvent([[maybe_unused]] const TCHAR *misc) +InputEvents::eventPilotEvent([[maybe_unused]] const char *misc) try { // Configure start window const OrderedTaskSettings &ots = @@ -228,7 +228,7 @@ try { } void -InputEvents::eventScreenModes(const TCHAR *misc) +InputEvents::eventScreenModes(const char *misc) { // toggle switches like this: // -- normal infobox @@ -269,7 +269,7 @@ InputEvents::eventScreenModes(const TCHAR *misc) // ClearStatusMessages // Do Clear Event Warnings void -InputEvents::eventClearStatusMessages([[maybe_unused]] const TCHAR *misc) +InputEvents::eventClearStatusMessages([[maybe_unused]] const char *misc) { // TODO enhancement: allow selection of specific messages (here we are acknowledging all) if (CommonInterface::main_window->popup != nullptr) @@ -281,7 +281,7 @@ InputEvents::eventClearStatusMessages([[maybe_unused]] const TCHAR *misc) // The argument is the label of the mode to activate. // This is used to activate menus/submenus of buttons void -InputEvents::eventMode(const TCHAR *misc) +InputEvents::eventMode(const char *misc) { assert(misc != NULL); @@ -292,7 +292,7 @@ InputEvents::eventMode(const TCHAR *misc) // Don't think we need this. void -InputEvents::eventMainMenu([[maybe_unused]] const TCHAR *misc) +InputEvents::eventMainMenu([[maybe_unused]] const char *misc) { // todo: popup main menu } @@ -301,7 +301,7 @@ InputEvents::eventMainMenu([[maybe_unused]] const TCHAR *misc) // Displays the checklist dialog // See the checklist dialog section of the reference manual for more info. void -InputEvents::eventChecklist([[maybe_unused]] const TCHAR *misc) +InputEvents::eventChecklist([[maybe_unused]] const char *misc) { dlgChecklistShowModal(); } @@ -314,7 +314,7 @@ InputEvents::eventChecklist([[maybe_unused]] const TCHAR *misc) // See the status dialog section of the reference manual for more info // on these. void -InputEvents::eventStatus(const TCHAR *misc) +InputEvents::eventStatus(const char *misc) { if (StringIsEqual(misc, _T("system"))) { dlgStatusShowModal(1); @@ -332,7 +332,7 @@ InputEvents::eventStatus(const TCHAR *misc) // See the analysis dialog section of the reference manual // for more info. void -InputEvents::eventAnalysis([[maybe_unused]] const TCHAR *misc) +InputEvents::eventAnalysis([[maybe_unused]] const char *misc) { dlgAnalysisShowModal(*CommonInterface::main_window, CommonInterface::main_window->GetLook(), @@ -350,7 +350,7 @@ InputEvents::eventAnalysis([[maybe_unused]] const TCHAR *misc) // See the waypoint dialog section of the reference manual // for more info. void -InputEvents::eventWaypointDetails(const TCHAR *misc) +InputEvents::eventWaypointDetails(const char *misc) { const NMEAInfo &basic = CommonInterface::Basic(); WaypointPtr wp; @@ -384,7 +384,7 @@ InputEvents::eventWaypointDetails(const TCHAR *misc) } void -InputEvents::eventWaypointEditor([[maybe_unused]] const TCHAR *misc) +InputEvents::eventWaypointEditor([[maybe_unused]] const char *misc) { dlgConfigWaypointsShowModal(*data_components->waypoints); } @@ -394,7 +394,7 @@ InputEvents::eventWaypointEditor([[maybe_unused]] const TCHAR *misc) // The argument is the text to be displayed. // No punctuation characters are allowed. void -InputEvents::eventStatusMessage(const TCHAR *misc) +InputEvents::eventStatusMessage(const char *misc) { if (misc != NULL) Message::AddMessage(gettext(misc)); @@ -402,13 +402,13 @@ InputEvents::eventStatusMessage(const TCHAR *misc) // Plays a sound from the filename void -InputEvents::eventPlaySound(const TCHAR *misc) +InputEvents::eventPlaySound(const char *misc) { PlayResource(misc); } void -InputEvents::eventAutoLogger(const TCHAR *misc) +InputEvents::eventAutoLogger(const char *misc) { if (is_simulator()) return; @@ -438,7 +438,7 @@ InputEvents::eventAutoLogger(const TCHAR *misc) // nmea: turns on and off NMEA logging // note: the text following the 'note' characters is added to the log file void -InputEvents::eventLogger(const TCHAR *misc) +InputEvents::eventLogger(const char *misc) try { auto *logger = backend_components->igc_logger.get(); if (logger == nullptr) @@ -493,7 +493,7 @@ try { // Repeats the last status message. If pressed repeatedly, will // repeat previous status messages void -InputEvents::eventRepeatStatusMessage([[maybe_unused]] const TCHAR *misc) +InputEvents::eventRepeatStatusMessage([[maybe_unused]] const char *misc) { // new interface // TODO enhancement: display only by type specified in misc field @@ -504,7 +504,7 @@ InputEvents::eventRepeatStatusMessage([[maybe_unused]] const TCHAR *misc) // NearestWaypointDetails // Displays the waypoint details dialog void -InputEvents::eventNearestWaypointDetails([[maybe_unused]] const TCHAR *misc) +InputEvents::eventNearestWaypointDetails([[maybe_unused]] const char *misc) { const auto location = GetVisibleLocation(); if (!location.IsValid()) @@ -517,7 +517,7 @@ InputEvents::eventNearestWaypointDetails([[maybe_unused]] const TCHAR *misc) // NearestMapItems // Displays the map item list dialog void -InputEvents::eventNearestMapItems([[maybe_unused]] const TCHAR *misc) +InputEvents::eventNearestMapItems([[maybe_unused]] const char *misc) { const auto location = GetVisibleLocation(); if (!location.IsValid()) @@ -530,13 +530,13 @@ InputEvents::eventNearestMapItems([[maybe_unused]] const TCHAR *misc) // The null event does nothing. This can be used to override // default functionality void -InputEvents::eventNull([[maybe_unused]] const TCHAR *misc) +InputEvents::eventNull([[maybe_unused]] const char *misc) { // do nothing } void -InputEvents::eventBeep([[maybe_unused]] const TCHAR *misc) +InputEvents::eventBeep([[maybe_unused]] const char *misc) { #ifdef _WIN32 MessageBeep(MB_ICONEXCLAMATION); @@ -553,7 +553,7 @@ InputEvents::eventBeep([[maybe_unused]] const TCHAR *misc) // Airspace: Airspace filter settings // Replay: IGC replay dialog void -InputEvents::eventSetup(const TCHAR *misc) +InputEvents::eventSetup(const char *misc) { if (StringIsEqual(misc, _T("Basic"))) dlgBasicSettingsShowModal(); @@ -587,7 +587,7 @@ InputEvents::eventSetup(const TCHAR *misc) } void -InputEvents::eventCredits([[maybe_unused]] const TCHAR *misc) +InputEvents::eventCredits([[maybe_unused]] const char *misc) { dlgCreditsShowModal(*CommonInterface::main_window); } @@ -596,7 +596,7 @@ InputEvents::eventCredits([[maybe_unused]] const TCHAR *misc) // Runs an external program of the specified filename. // Note that XCSoar will wait until this program exits. void -InputEvents::eventRun(const TCHAR *misc) +InputEvents::eventRun(const char *misc) { #ifdef _WIN32 PROCESS_INFORMATION pi; @@ -617,14 +617,14 @@ InputEvents::eventRun(const TCHAR *misc) } void -InputEvents::eventBrightness([[maybe_unused]] const TCHAR *misc) +InputEvents::eventBrightness([[maybe_unused]] const char *misc) { // not implemented (was only implemented on Altair) } // Exits for general systems void -InputEvents::eventExit([[maybe_unused]] const TCHAR *misc) +InputEvents::eventExit([[maybe_unused]] const char *misc) { bool force = false; if (StringIsEqual(misc, _T("system"))) { @@ -645,7 +645,7 @@ InputEvents::eventExit([[maybe_unused]] const TCHAR *misc) #if 1 // defined(IS_OPENVARIO) // Exits with real Shutdown only in systems where this is possible void -InputEvents::eventShutdown([[maybe_unused]] const TCHAR *misc) +InputEvents::eventShutdown([[maybe_unused]] const char *misc) { #if defined(IS_OPENVARIO) if (StringIsEqual(misc, _T("reboot"))) { @@ -661,42 +661,42 @@ InputEvents::eventShutdown([[maybe_unused]] const TCHAR *misc) #include "ui/event/KeyCode.hpp" void -InputEvents::eventKeyPressed(const TCHAR *misc) +InputEvents::eventKeyPressed(const char *misc) { // std::map keys; for (auto *p = misc; *p != 0; p++) { if (*p != ' ') { - TCHAR c[2] = {*p, 0}; + char c[2] = {*p, 0}; if (!strncmp(p, "LEFT", strlen("LEFT"))) { - c[0] = (TCHAR) KEY_LEFT; + c[0] = (char) KEY_LEFT; p += strlen("LEFT") ; } else if (!strncmp(p, "RIGHT", strlen("RIGHT"))) { - c[0] = (TCHAR) KEY_RIGHT; + c[0] = (char) KEY_RIGHT; p += strlen("RIGHT") ; } else if (!strncmp(p, "UP", strlen("UP"))) { - c[0] = (TCHAR) KEY_UP; + c[0] = (char) KEY_UP; p += strlen("UP") ; } else if (!strncmp(p, "DOWN", strlen("DOWN"))) { - c[0] = (TCHAR) KEY_DOWN; + c[0] = (char) KEY_DOWN; p += strlen("DOWN") ; } else if (!strncmp(p, "ESCAPE", strlen("ESCAPE"))) { - c[0] = (TCHAR) KEY_ESCAPE; + c[0] = (char) KEY_ESCAPE; p += strlen("ESCAPE") ; } else if (!strncmp(p, "ENTER", strlen("ENTER"))) { - c[0] = (TCHAR) KEY_RETURN; + c[0] = (char) KEY_RETURN; p += strlen("ENTER") ; } else if (!strncmp(p, "RETURN", strlen("RETURN"))) { - c[0] = (TCHAR) KEY_RETURN; + c[0] = (char) KEY_RETURN; p += strlen("RETURN") ; } - ProcessKey(MODE_MENU, ParseKeyCode((const TCHAR *)c)); + ProcessKey(MODE_MENU, ParseKeyCode((const char *)c)); } } } #endif void -InputEvents::eventUserDisplayModeForce(const TCHAR *misc) +InputEvents::eventUserDisplayModeForce(const char *misc) { UIState &ui_state = CommonInterface::SetUIState(); @@ -714,7 +714,7 @@ InputEvents::eventUserDisplayModeForce(const TCHAR *misc) } void -InputEvents::eventAddWaypoint(const TCHAR *misc) +InputEvents::eventAddWaypoint(const char *misc) { const NMEAInfo &basic = CommonInterface::Basic(); const DerivedInfo &calculated = CommonInterface::Calculated(); @@ -784,31 +784,31 @@ mph/kts/... // helpers void -InputEvents::eventWeather(const TCHAR *misc) +InputEvents::eventWeather(const char *misc) { ShowWeatherDialog(misc); } void -InputEvents::eventQuickMenu(const TCHAR *misc) +InputEvents::eventQuickMenu(const char *misc) { dlgQuickMenuShowModal(*CommonInterface::main_window, misc); } void -InputEvents::eventFileManager([[maybe_unused]] const TCHAR *misc) +InputEvents::eventFileManager([[maybe_unused]] const char *misc) { ShowFileManager(); } void -InputEvents::eventExchangeFrequencies([[maybe_unused]] const TCHAR *misc) +InputEvents::eventExchangeFrequencies([[maybe_unused]] const char *misc) { XCSoarInterface::ExchangeRadioFrequencies(true); } void -InputEvents::eventUploadIGCFile([[maybe_unused]] const TCHAR *misc) { +InputEvents::eventUploadIGCFile([[maybe_unused]] const char *misc) { FileDataField df; df.ScanMultiplePatterns(_T("*.igc\0")); df.SetFileType(FileType::IGC); diff --git a/src/Input/InputEventsAirspace.cpp b/src/Input/InputEventsAirspace.cpp index 8f58da5d69d..4f192659032 100644 --- a/src/Input/InputEventsAirspace.cpp +++ b/src/Input/InputEventsAirspace.cpp @@ -29,7 +29,7 @@ * but 0 should mean OFF all the way. */ void -InputEvents::eventAirSpace(const TCHAR *misc) +InputEvents::eventAirSpace(const char *misc) { AirspaceRendererSettings &settings = CommonInterface::SetMapSettings().airspace; @@ -58,7 +58,7 @@ InputEvents::eventAirSpace(const TCHAR *misc) // ClearAirspaceWarnings // Clears airspace warnings for the selected airspace void -InputEvents::eventClearAirspaceWarnings([[maybe_unused]] const TCHAR *misc) +InputEvents::eventClearAirspaceWarnings([[maybe_unused]] const char *misc) { if (auto *airspace_warnings = backend_components->GetAirspaceWarnings()) airspace_warnings->AcknowledgeAll(); @@ -72,7 +72,7 @@ InputEvents::eventClearAirspaceWarnings([[maybe_unused]] const TCHAR *misc) // to the nearest exit to the airspace. void -InputEvents::eventNearestAirspaceDetails([[maybe_unused]] const TCHAR *misc) +InputEvents::eventNearestAirspaceDetails([[maybe_unused]] const char *misc) { const MoreData &basic = CommonInterface::Basic(); const DerivedInfo &calculated = CommonInterface::Calculated(); diff --git a/src/Input/InputEventsDevice.cpp b/src/Input/InputEventsDevice.cpp index fa0e5cd5da9..b2e2c324476 100644 --- a/src/Input/InputEventsDevice.cpp +++ b/src/Input/InputEventsDevice.cpp @@ -18,7 +18,7 @@ // to provide the text in between the '$' and '*'. // void -InputEvents::eventSendNMEA(const TCHAR *misc) +InputEvents::eventSendNMEA(const char *misc) { if (misc != NULL && backend_components->devices != nullptr) { PopupOperationEnvironment env; @@ -27,7 +27,7 @@ InputEvents::eventSendNMEA(const TCHAR *misc) } void -InputEvents::eventSendNMEAPort1(const TCHAR *misc) +InputEvents::eventSendNMEAPort1(const char *misc) { const unsigned i = 0; @@ -38,7 +38,7 @@ InputEvents::eventSendNMEAPort1(const TCHAR *misc) } void -InputEvents::eventSendNMEAPort2(const TCHAR *misc) +InputEvents::eventSendNMEAPort2(const char *misc) { const unsigned i = 1; @@ -49,7 +49,7 @@ InputEvents::eventSendNMEAPort2(const TCHAR *misc) } void -InputEvents::eventDevice(const TCHAR *misc) +InputEvents::eventDevice(const char *misc) { assert(misc != NULL); diff --git a/src/Input/InputEventsLua.cpp b/src/Input/InputEventsLua.cpp index 85a9dbe43aa..122d0afb067 100644 --- a/src/Input/InputEventsLua.cpp +++ b/src/Input/InputEventsLua.cpp @@ -28,7 +28,7 @@ class LuaFileVisitor final : public File::Visitor { }; static AllocatedPath -SelectLuaFile(const TCHAR *path) +SelectLuaFile(const char *path) { if (StringIsEmpty(path)) { /* no parameter: let user select a *.lua file */ @@ -60,7 +60,7 @@ SelectLuaFile(const TCHAR *path) } void -InputEvents::eventRunLuaFile(const TCHAR *misc) +InputEvents::eventRunLuaFile(const char *misc) { const auto path = SelectLuaFile(misc); if (path == nullptr) @@ -69,7 +69,7 @@ InputEvents::eventRunLuaFile(const TCHAR *misc) try { Lua::StartFile(path); } catch (...) { - TCHAR buffer[MAX_PATH]; + char buffer[MAX_PATH]; StringFormat(buffer, MAX_PATH, _T("RunLuaFile %s"), misc); ShowError(std::current_exception(), buffer); } diff --git a/src/Input/InputEventsMap.cpp b/src/Input/InputEventsMap.cpp index 76ec71635c8..8a7bd3a8a1c 100644 --- a/src/Input/InputEventsMap.cpp +++ b/src/Input/InputEventsMap.cpp @@ -32,7 +32,7 @@ // n.n - Zoom to a set scale // show - Show current zoom scale void -InputEvents::eventZoom(const TCHAR* misc) +InputEvents::eventZoom(const char* misc) { // JMW pass through to handler in MapWindow // here: @@ -81,7 +81,7 @@ InputEvents::eventZoom(const TCHAR* misc) else Message::AddMessage(_("Circling zoom off")); } else { - TCHAR *endptr; + char *endptr; double zoom = strtod(misc, &endptr); if (endptr == misc) return; @@ -107,7 +107,7 @@ InputEvents::eventZoom(const TCHAR* misc) * @todo feature: ??? Go to waypoint (eg: next, named) */ void -InputEvents::eventPan(const TCHAR *misc) +InputEvents::eventPan(const char *misc) { if (StringIsEqual(misc, _T("toggle"))) TogglePan(); diff --git a/src/Input/InputEventsPage.cpp b/src/Input/InputEventsPage.cpp index 040a220cd04..dd4f413eb56 100644 --- a/src/Input/InputEventsPage.cpp +++ b/src/Input/InputEventsPage.cpp @@ -6,7 +6,7 @@ #include "util/StringAPI.hxx" void -InputEvents::eventPage(const TCHAR *misc) +InputEvents::eventPage(const char *misc) { if (StringIsEqual(misc, _T("restore"))) PageActions::Restore(); diff --git a/src/Input/InputEventsSettings.cpp b/src/Input/InputEventsSettings.cpp index 9389b291d47..c22382f9596 100644 --- a/src/Input/InputEventsSettings.cpp +++ b/src/Input/InputEventsSettings.cpp @@ -24,7 +24,7 @@ #include "BackendComponents.hpp" void -InputEvents::eventSounds(const TCHAR *misc) +InputEvents::eventSounds(const char *misc) { SoundSettings &settings = CommonInterface::SetUISettings().sound; // bool OldEnableSoundVario = EnableSoundVario; @@ -62,7 +62,7 @@ InputEvents::eventSounds(const TCHAR *misc) } void -InputEvents::eventSnailTrail(const TCHAR *misc) +InputEvents::eventSnailTrail(const char *misc) { MapSettings &settings_map = CommonInterface::SetMapSettings(); @@ -102,14 +102,14 @@ InputEvents::eventSnailTrail(const TCHAR *misc) } void -InputEvents::eventTerrainTopology(const TCHAR *misc) +InputEvents::eventTerrainTopology(const char *misc) { eventTerrainTopography(misc); } // Do JUST Terrain/Topography (toggle any, on/off any, show) void -InputEvents::eventTerrainTopography(const TCHAR *misc) +InputEvents::eventTerrainTopography(const char *misc) { if (StringIsEqual(misc, _T("terrain toggle"))) sub_TerrainTopography(-2); @@ -141,7 +141,7 @@ InputEvents::eventTerrainTopography(const TCHAR *misc) // +: increases deadband // -: decreases deadband void -InputEvents::eventAudioDeadband(const TCHAR *misc) +InputEvents::eventAudioDeadband(const char *misc) { SoundSettings &settings = CommonInterface::SetUISettings().sound; @@ -171,7 +171,7 @@ InputEvents::eventAudioDeadband(const TCHAR *misc) // min: selects the worst performance (50%) // show: shows the current bug degradation void -InputEvents::eventBugs(const TCHAR *misc) +InputEvents::eventBugs(const char *misc) { if (!backend_components->protected_task_manager) return; @@ -193,7 +193,7 @@ InputEvents::eventBugs(const TCHAR *misc) else if (StringIsEqual(misc, _T("min"))) BUGS = 0.5; else if (StringIsEqual(misc, _T("show"))) { - TCHAR Temp[100]; + char Temp[100]; _stprintf(Temp, _T("%d"), (int)(BUGS * 100)); Message::AddMessage(_("Bugs performance"), Temp); } @@ -212,7 +212,7 @@ InputEvents::eventBugs(const TCHAR *misc) // min: selects 0% ballast // show: displays a status message indicating the ballast percentage void -InputEvents::eventBallast(const TCHAR *misc) +InputEvents::eventBallast(const char *misc) { if (!backend_components->protected_task_manager) return; @@ -235,7 +235,7 @@ InputEvents::eventBallast(const TCHAR *misc) else if (StringIsEqual(misc, _T("min"))) BALLAST = 0; else if (StringIsEqual(misc, _T("show"))) { - TCHAR Temp[100]; + char Temp[100]; _stprintf(Temp, _T("%d"), (int)(BALLAST * 100)); /* xgettext:no-c-format */ Message::AddMessage(_("Ballast %"), Temp); @@ -250,7 +250,7 @@ InputEvents::eventBallast(const TCHAR *misc) // ProfileLoad // Loads the profile of the specified filename void -InputEvents::eventProfileLoad(const TCHAR *misc) +InputEvents::eventProfileLoad(const char *misc) { if (!StringIsEmpty(misc)) { Profile::LoadFile(Path(misc)); @@ -268,7 +268,7 @@ InputEvents::eventProfileLoad(const TCHAR *misc) // ProfileSave // Saves the profile to the specified filename void -InputEvents::eventProfileSave(const TCHAR *misc) +InputEvents::eventProfileSave(const char *misc) { if (!StringIsEmpty(misc)) { try { @@ -286,7 +286,7 @@ InputEvents::eventProfileSave(const TCHAR *misc) // -: decreases temperature by one degree celsius // show: Shows a status message with the current forecast temperature void -InputEvents::eventAdjustForecastTemperature(const TCHAR *misc) +InputEvents::eventAdjustForecastTemperature(const char *misc) { if (StringIsEqual(misc, _T("+"))) CommonInterface::SetComputerSettings().forecast_temperature += Temperature::FromKelvin(1); @@ -295,16 +295,16 @@ InputEvents::eventAdjustForecastTemperature(const TCHAR *misc) else if (StringIsEqual(misc, _T("show"))) { auto temperature = CommonInterface::GetComputerSettings().forecast_temperature; - TCHAR Temp[100]; + char Temp[100]; _stprintf(Temp, _T("%f"), temperature.ToUser()); Message::AddMessage(_("Forecast temperature"), Temp); } } void -InputEvents::eventDeclutterLabels(const TCHAR *misc) +InputEvents::eventDeclutterLabels(const char *misc) { - static const TCHAR *const msg[] = { + static const char *const msg[] = { N_("All"), N_("Task & Landables"), N_("Task"), @@ -313,7 +313,7 @@ InputEvents::eventDeclutterLabels(const TCHAR *misc) }; static constexpr unsigned int n = ARRAY_SIZE(msg); - static const TCHAR *const actions[n] = { + static const char *const actions[n] = { _T("all"), _T("task+landables"), _T("task"), @@ -327,7 +327,7 @@ InputEvents::eventDeclutterLabels(const TCHAR *misc) wls = WaypointRendererSettings::LabelSelection(((unsigned)wls + 1) % n); Profile::Set(ProfileKeys::WaypointLabelSelection, (int)wls); } else if (StringIsEqual(misc, _T("show"))) { - TCHAR tbuf[64]; + char tbuf[64]; _stprintf(tbuf, _T("%s: %s"), _("Waypoint labels"), gettext(msg[(unsigned)wls])); Message::AddMessage(tbuf); @@ -346,7 +346,7 @@ InputEvents::eventDeclutterLabels(const TCHAR *misc) } void -InputEvents::eventAirspaceDisplayMode(const TCHAR *misc) +InputEvents::eventAirspaceDisplayMode(const char *misc) { AirspaceRendererSettings &settings = CommonInterface::SetMapSettings().airspace; @@ -366,7 +366,7 @@ InputEvents::eventAirspaceDisplayMode(const TCHAR *misc) } void -InputEvents::eventOrientation(const TCHAR *misc) +InputEvents::eventOrientation(const char *misc) { MapSettings &settings_map = CommonInterface::SetMapSettings(); @@ -445,7 +445,7 @@ InputEvents::sub_TerrainTopography(int vswitch) else if (vswitch == 0) { // Show terrain/topography // ARH Let user know what's happening - TCHAR buf[128]; + char buf[128]; if (settings_map.topography_enabled) _stprintf(buf, _T("\r\n%s / "), _("On")); diff --git a/src/Input/InputEventsTask.cpp b/src/Input/InputEventsTask.cpp index 288db13f7f6..3281f99568b 100644 --- a/src/Input/InputEventsTask.cpp +++ b/src/Input/InputEventsTask.cpp @@ -42,7 +42,7 @@ trigger_redraw() // toggle: Toggles between armed and disarmed. // show: Shows current armed state void -InputEvents::eventArmAdvance(const TCHAR *misc) +InputEvents::eventArmAdvance(const char *misc) { if (!backend_components->protected_task_manager) return; @@ -86,7 +86,7 @@ InputEvents::eventArmAdvance(const TCHAR *misc) } void -InputEvents::eventCalculator([[maybe_unused]] const TCHAR *misc) +InputEvents::eventCalculator([[maybe_unused]] const char *misc) { dlgTaskManagerShowModal(); @@ -94,7 +94,7 @@ InputEvents::eventCalculator([[maybe_unused]] const TCHAR *misc) } void -InputEvents::eventGotoLookup([[maybe_unused]] const TCHAR *misc) +InputEvents::eventGotoLookup([[maybe_unused]] const char *misc) { const NMEAInfo &basic = CommonInterface::Basic(); @@ -112,7 +112,7 @@ InputEvents::eventGotoLookup([[maybe_unused]] const TCHAR *misc) // Adjusts MacCready settings // up, down, auto on, auto off, auto toggle, auto show void -InputEvents::eventMacCready(const TCHAR *misc) +InputEvents::eventMacCready(const char *misc) { if (!backend_components->protected_task_manager) return; @@ -156,7 +156,7 @@ InputEvents::eventMacCready(const TCHAR *misc) // nextwrap: selects the next waypoint, wrapping back to start after final // previouswrap: selects the previous waypoint, wrapping to final after start void -InputEvents::eventAdjustWaypoint(const TCHAR *misc) +InputEvents::eventAdjustWaypoint(const char *misc) { auto *protected_task_manager = backend_components->protected_task_manager.get(); if (protected_task_manager == NULL) @@ -193,7 +193,7 @@ InputEvents::eventAdjustWaypoint(const TCHAR *misc) // toggle: toggles between abort and resume // show: displays a status message showing the task abort status void -InputEvents::eventAbortTask(const TCHAR *misc) +InputEvents::eventAbortTask(const char *misc) { if (!backend_components->protected_task_manager) return; @@ -249,7 +249,7 @@ InputEvents::eventAbortTask(const TCHAR *misc) // TaskLoad // Loads the task of the specified filename void -InputEvents::eventTaskLoad(const TCHAR *misc) +InputEvents::eventTaskLoad(const char *misc) { if (!backend_components->protected_task_manager) return; @@ -277,7 +277,7 @@ InputEvents::eventTaskLoad(const TCHAR *misc) // TaskSave // Saves the task to the specified filename void -InputEvents::eventTaskSave(const TCHAR *misc) +InputEvents::eventTaskSave(const char *misc) { if (!backend_components->protected_task_manager) return; @@ -288,7 +288,7 @@ InputEvents::eventTaskSave(const TCHAR *misc) } void -InputEvents::eventTaskTransition(const TCHAR *misc) +InputEvents::eventTaskTransition(const char *misc) { if (!backend_components->protected_task_manager) return; @@ -299,7 +299,7 @@ InputEvents::eventTaskTransition(const TCHAR *misc) if (!start_stats.HasStarted()) return; - TCHAR TempAll[120]; + char TempAll[120]; _stprintf(TempAll, _T("\r\n%s: %s\r\n%s:%s\r\n%s: %s"), _("Altitude"), FormatUserAltitude(start_stats.altitude).c_str(), @@ -317,7 +317,7 @@ InputEvents::eventTaskTransition(const TCHAR *misc) } void -InputEvents::eventResetTask([[maybe_unused]] const TCHAR *misc) +InputEvents::eventResetTask([[maybe_unused]] const char *misc) { if (backend_components->protected_task_manager) backend_components->protected_task_manager->ResetTask(); diff --git a/src/Input/InputEventsThermalAssistant.cpp b/src/Input/InputEventsThermalAssistant.cpp index 31fdc001837..af19779923d 100644 --- a/src/Input/InputEventsThermalAssistant.cpp +++ b/src/Input/InputEventsThermalAssistant.cpp @@ -5,7 +5,7 @@ #include "PageActions.hpp" void -InputEvents::eventThermalAssistant([[maybe_unused]] const TCHAR *misc) +InputEvents::eventThermalAssistant([[maybe_unused]] const char *misc) { PageActions::ShowThermalAssistant(); } diff --git a/src/Input/InputEventsTraffic.cpp b/src/Input/InputEventsTraffic.cpp index c318363a375..97bb88dd3d2 100644 --- a/src/Input/InputEventsTraffic.cpp +++ b/src/Input/InputEventsTraffic.cpp @@ -10,7 +10,7 @@ #include "Dialogs/Traffic/TrafficDialogs.hpp" void -InputEvents::eventFLARMRadar([[maybe_unused]] const TCHAR *misc) +InputEvents::eventFLARMRadar([[maybe_unused]] const char *misc) { if (StringIsEqual(misc, _T("ForceToggle"))) { CommonInterface::main_window->ToggleForceFLARMRadar(); @@ -21,13 +21,13 @@ InputEvents::eventFLARMRadar([[maybe_unused]] const TCHAR *misc) // FLARM Traffic // Displays the FLARM traffic dialog void -InputEvents::eventFlarmTraffic([[maybe_unused]] const TCHAR *misc) +InputEvents::eventFlarmTraffic([[maybe_unused]] const char *misc) { PageActions::ShowTrafficRadar(); } void -InputEvents::eventTraffic(const TCHAR *misc) +InputEvents::eventTraffic(const char *misc) { LoadFlarmDatabases(); @@ -57,7 +57,7 @@ InputEvents::eventTraffic(const TCHAR *misc) } void -InputEvents::eventFlarmDetails([[maybe_unused]] const TCHAR *misc) +InputEvents::eventFlarmDetails([[maybe_unused]] const char *misc) { LoadFlarmDatabases(); TrafficListDialog(); diff --git a/src/Input/InputEventsVega.cpp b/src/Input/InputEventsVega.cpp index d5b96dbf4ec..aa4267d23eb 100644 --- a/src/Input/InputEventsVega.cpp +++ b/src/Input/InputEventsVega.cpp @@ -61,7 +61,7 @@ AllVegasRequestSetting(const char *name) // zero: Zero's the airspeed indicator's offset // void -InputEvents::eventAdjustVarioFilter(const TCHAR *misc) +InputEvents::eventAdjustVarioFilter(const char *misc) { static int naccel = 0; if (StringIsEqual(misc, _T("slow"))) diff --git a/src/Input/InputKeys.cpp b/src/Input/InputKeys.cpp index ecfbfbd59ad..807d1ecf50a 100644 --- a/src/Input/InputKeys.cpp +++ b/src/Input/InputKeys.cpp @@ -7,7 +7,7 @@ #include "util/StringAPI.hxx" struct string_to_key { - const TCHAR *name; + const char *name; unsigned key; }; @@ -74,7 +74,7 @@ static constexpr struct string_to_key string_to_key[] = { }; unsigned -ParseKeyCode(const TCHAR *data) +ParseKeyCode(const char *data) { for (const struct string_to_key *p = &string_to_key[0]; p->name != NULL; ++p) if (StringIsEqual(data, p->name)) diff --git a/src/Input/InputKeys.hpp b/src/Input/InputKeys.hpp index 74e3484f4ae..789986dca3c 100644 --- a/src/Input/InputKeys.hpp +++ b/src/Input/InputKeys.hpp @@ -7,4 +7,4 @@ [[gnu::pure]] unsigned -ParseKeyCode(const TCHAR *data); +ParseKeyCode(const char *data); diff --git a/src/Input/InputLookup.cpp b/src/Input/InputLookup.cpp index 755e8bfb60b..206f32a5dcf 100644 --- a/src/Input/InputLookup.cpp +++ b/src/Input/InputLookup.cpp @@ -8,7 +8,7 @@ // Mapping text names of events to the real thing struct Text2EventSTRUCT { - const TCHAR *text; + const char *text; pt2Event event; }; @@ -18,13 +18,13 @@ static constexpr Text2EventSTRUCT Text2Event[] = { }; // Mapping text names of events to the real thing -static const TCHAR *const Text2GCE[] = { +static const char *const Text2GCE[] = { #include "InputEvents_Text2GCE.cpp" nullptr }; // Mapping text names of events to the real thing -static const TCHAR *const Text2NE[] = { +static const char *const Text2NE[] = { #include "InputEvents_Text2NE.cpp" nullptr }; @@ -40,7 +40,7 @@ InputEvents::findEvent(tstring_view name) noexcept } int -InputEvents::findGCE(const TCHAR *data) +InputEvents::findGCE(const char *data) { int i; for (i = 0; i < GCE_COUNT; i++) { @@ -52,7 +52,7 @@ InputEvents::findGCE(const TCHAR *data) } int -InputEvents::findNE(const TCHAR *data) +InputEvents::findNE(const char *data) { int i; for (i = 0; i < NE_COUNT; i++) { diff --git a/src/Input/InputLookup.hpp b/src/Input/InputLookup.hpp index 8eba86c7144..2aeafdd9c74 100644 --- a/src/Input/InputLookup.hpp +++ b/src/Input/InputLookup.hpp @@ -7,15 +7,15 @@ #include -typedef void (*pt2Event)(const TCHAR *); +typedef void (*pt2Event)(const char *); namespace InputEvents { [[gnu::pure]] -int findGCE(const TCHAR *data); +int findGCE(const char *data); [[gnu::pure]] -int findNE(const TCHAR *data); +int findNE(const char *data); [[gnu::pure]] pt2Event diff --git a/src/Input/InputParser.cpp b/src/Input/InputParser.cpp index a6205479135..699f479c209 100644 --- a/src/Input/InputParser.cpp +++ b/src/Input/InputParser.cpp @@ -59,7 +59,7 @@ struct EventBuilder { // General errors - these should be true assert(location < 1024); - const TCHAR *new_label = NULL; + const char *new_label = NULL; // For each mode for (const auto token : TIterableSplitString(mode.c_str(), ' ')) { @@ -110,7 +110,7 @@ struct EventBuilder { } else if (type.equals(_T("gesture"))) { // Check data for invalid characters: bool valid = true; - for (const TCHAR* c = data; *c; c++) + for (const char* c = data; *c; c++) if (*c != _T('U') && *c != _T('D') && *c != _T('R') && @@ -206,7 +206,7 @@ ParseInputFile(InputConfig &config, BufferedReader &reader) continue; } - TCHAR *allocated = UnescapeBackslash(string_converter.Convert(d_misc)); + char *allocated = UnescapeBackslash(string_converter.Convert(d_misc)); current.event_id = config.AppendEvent(event, allocated, current.event_id); diff --git a/src/Input/InputQueue.hpp b/src/Input/InputQueue.hpp index 9a15f306b88..8439de0216d 100644 --- a/src/Input/InputQueue.hpp +++ b/src/Input/InputQueue.hpp @@ -5,7 +5,7 @@ #include -typedef void (*pt2Event)(const TCHAR *); +typedef void (*pt2Event)(const char *); namespace InputEvents { diff --git a/src/Kobo/FakeSymbols.cpp b/src/Kobo/FakeSymbols.cpp index 306bc7f9ac8..fb2b892af17 100644 --- a/src/Kobo/FakeSymbols.cpp +++ b/src/Kobo/FakeSymbols.cpp @@ -5,8 +5,8 @@ #include "Dialogs/DataField.hpp" bool -EditDataFieldDialog([[maybe_unused]] const TCHAR *caption, [[maybe_unused]] DataField &df, - [[maybe_unused]] const TCHAR *help_text) +EditDataFieldDialog([[maybe_unused]] const char *caption, [[maybe_unused]] DataField &df, + [[maybe_unused]] const char *help_text) { return false; } diff --git a/src/Kobo/NetworkDialog.cpp b/src/Kobo/NetworkDialog.cpp index 556787ab94d..c985ed4e3e5 100644 --- a/src/Kobo/NetworkDialog.cpp +++ b/src/Kobo/NetworkDialog.cpp @@ -12,7 +12,7 @@ #include "System.hpp" [[gnu::pure]] -static const TCHAR * +static const char * GetWifiToggleCaption() { return IsKoboWifiOn() ? _T("Wifi OFF") : _T("Wifi ON"); diff --git a/src/Kobo/PowerOff.cpp b/src/Kobo/PowerOff.cpp index 1cfbdc3326d..666bea0c8c0 100644 --- a/src/Kobo/PowerOff.cpp +++ b/src/Kobo/PowerOff.cpp @@ -54,23 +54,23 @@ DrawBanner(Canvas &canvas, PixelRect &rc) const int name_y = rc.top + (banner_height - large_font.GetHeight()) / 2; - const TCHAR *const name1 = _T("XC"); + const char *const name1 = _T("XC"); canvas.DrawText({x, name_y}, name1); x += canvas.CalcTextWidth(name1); - const TCHAR *const name2 = _T("Soar"); + const char *const name2 = _T("Soar"); canvas.SetTextColor(COLOR_GRAY); canvas.DrawText({x, name_y}, name2); canvas.SetTextColor(COLOR_BLACK); x += canvas.CalcTextWidth(name2) + 30; /* some more text */ - const TCHAR *const website = _T("www.xcsoar.org"); + const char *const website = _T("www.xcsoar.org"); canvas.Select(normal_font); canvas.DrawText({x, rc.top + int(banner_height - normal_font.GetHeight()) / 2}, website); - TCHAR comment[30] = _T("powered off"); + char comment[30] = _T("powered off"); const auto power_info = Power::GetInfo(); if (power_info.battery.remaining_percent) { snprintf ( comment+strlen(comment), 30-strlen(comment), _T(" - battery %d%%"), *power_info.battery.remaining_percent); diff --git a/src/Kobo/ToolsDialog.cpp b/src/Kobo/ToolsDialog.cpp index 9e12d2f1983..a3db7d6fdee 100644 --- a/src/Kobo/ToolsDialog.cpp +++ b/src/Kobo/ToolsDialog.cpp @@ -18,7 +18,7 @@ struct ListItem StaticString<32> name; AllocatedPath path; - ListItem(const TCHAR *_name, Path _path) + ListItem(const char *_name, Path _path) :name(_name), path(_path) {} bool operator<(const ListItem &i2) const { diff --git a/src/Kobo/WifiDialog.cpp b/src/Kobo/WifiDialog.cpp index 04f1da20a1c..5fdc45b3cf2 100644 --- a/src/Kobo/WifiDialog.cpp +++ b/src/Kobo/WifiDialog.cpp @@ -175,7 +175,7 @@ WifiListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, row_renderer.DrawFirstRow(canvas, rc, info.ssid); row_renderer.DrawSecondRow(canvas, rc, info.bssid); - const TCHAR *state = nullptr; + const char *state = nullptr; StaticString<40> state_buffer; /* found the currently connected wifi network? */ diff --git a/src/Language/Language.cpp b/src/Language/Language.cpp index 08cf2fc9978..69f1cb1ff71 100644 --- a/src/Language/Language.cpp +++ b/src/Language/Language.cpp @@ -52,8 +52,8 @@ DisallowLanguage() * @param text The text to search for * @return The translation if found, otherwise the text itself */ -const TCHAR* -gettext(const TCHAR* text) +const char* +gettext(const char* text) { assert(language_allowed); assert(text != NULL); diff --git a/src/Language/Language.hpp b/src/Language/Language.hpp index 62747265a74..07fb51a9398 100644 --- a/src/Language/Language.hpp +++ b/src/Language/Language.hpp @@ -36,7 +36,7 @@ void DisallowLanguage(); #endif [[gnu::const]] -const TCHAR* gettext(const TCHAR* text); +const char* gettext(const char* text); /** * For source compatibility with GNU gettext. diff --git a/src/Language/LanguageGlue.cpp b/src/Language/LanguageGlue.cpp index f0cb39fedc5..7333d2b6019 100644 --- a/src/Language/LanguageGlue.cpp +++ b/src/Language/LanguageGlue.cpp @@ -64,7 +64,7 @@ FindLanguage(WORD language) noexcept [[gnu::pure]] static const BuiltinLanguage * -FindLanguage(const TCHAR *resource) noexcept +FindLanguage(const char *resource) noexcept { assert(resource != nullptr); @@ -217,7 +217,7 @@ ReadBuiltinLanguage(const BuiltinLanguage &language) noexcept } static bool -ReadResourceLanguageFile(const TCHAR *resource) noexcept +ReadResourceLanguageFile(const char *resource) noexcept { auto language = FindLanguage(resource); return language != nullptr && ReadBuiltinLanguage(*language); diff --git a/src/Language/Table.hpp b/src/Language/Table.hpp index 865758d9e0a..32814d4512e 100644 --- a/src/Language/Table.hpp +++ b/src/Language/Table.hpp @@ -24,8 +24,8 @@ struct BuiltinLanguage { const std::byte *begin; size_t size; #endif - const TCHAR *resource; - const TCHAR *name; + const char *resource; + const char *name; }; extern const BuiltinLanguage language_table[]; diff --git a/src/LocalPath.cpp b/src/LocalPath.cpp index d1ebe277c7c..d758de533e0 100644 --- a/src/LocalPath.cpp +++ b/src/LocalPath.cpp @@ -102,13 +102,13 @@ LocalPath(Path file) noexcept } AllocatedPath -LocalPath(const TCHAR *file) noexcept +LocalPath(const char *file) noexcept { return LocalPath(Path(file)); } AllocatedPath -MakeLocalPath(const TCHAR *name) +MakeLocalPath(const char *name) { auto path = LocalPath(name); Directory::Create(path); @@ -121,11 +121,11 @@ RelativePath(Path path) noexcept return path.RelativeTo(GetPrimaryDataPath()); } -static constexpr TCHAR local_path_code[] = _T("%LOCAL_PATH%\\"); +static constexpr char local_path_code[] = _T("%LOCAL_PATH%\\"); [[gnu::pure]] -static const TCHAR * -AfterLocalPathCode(const TCHAR *p) noexcept +static const char * +AfterLocalPathCode(const char *p) noexcept { p = StringAfterPrefix(p, local_path_code); if (p == nullptr) @@ -144,7 +144,7 @@ AllocatedPath ExpandLocalPath(Path src) noexcept { // Get the relative file name and location (ptr) - const TCHAR *ptr = AfterLocalPathCode(src.c_str()); + const char *ptr = AfterLocalPathCode(src.c_str()); if (ptr == nullptr) return src; @@ -180,7 +180,7 @@ ContractLocalPath(Path src) noexcept static AllocatedPath FindDataPathAtModule(HMODULE hModule) noexcept { - TCHAR buffer[MAX_PATH]; + char buffer[MAX_PATH]; if (GetModuleFileName(hModule, buffer, MAX_PATH) <= 0) return nullptr; @@ -245,7 +245,7 @@ FindDataPaths() noexcept /* Windows: use "My Documents\OpenSoarData" */ { - TCHAR buffer[MAX_PATH]; + char buffer[MAX_PATH]; if (SHGetSpecialFolderPath(nullptr, buffer, CSIDL_PERSONAL, result.empty())) result.emplace_back(AllocatedPath::Build(buffer, _T(OPENSOAR_DATADIR))); @@ -285,7 +285,7 @@ FindDataPaths() noexcept } void -VisitDataFiles(const TCHAR* filter, File::Visitor &visitor) +VisitDataFiles(const char* filter, File::Visitor &visitor) { for (const auto &i : data_paths) Directory::VisitSpecificFiles(i, filter, visitor, true); @@ -298,7 +298,7 @@ GetCachePath() noexcept } AllocatedPath -MakeCacheDirectory(const TCHAR *name) noexcept +MakeCacheDirectory(const char *name) noexcept { Directory::Create(cache_path); auto path = AllocatedPath::Build(cache_path, Path(name)); diff --git a/src/LocalPath.hpp b/src/LocalPath.hpp index 1daf82c40c0..f97eca715b1 100644 --- a/src/LocalPath.hpp +++ b/src/LocalPath.hpp @@ -63,13 +63,13 @@ AllocatedPath LocalPath(Path file) noexcept; AllocatedPath -LocalPath(const TCHAR *file) noexcept; +LocalPath(const char *file) noexcept; /** * Create a subdirectory of XCSoarData and return its absolute path. */ AllocatedPath -MakeLocalPath(const TCHAR *name); +MakeLocalPath(const char *name); /** * Return the portion of the specified path that is relative to the @@ -99,7 +99,7 @@ ExpandLocalPath(Path src) noexcept; AllocatedPath ContractLocalPath(Path src) noexcept; -void VisitDataFiles(const TCHAR* filter, File::Visitor &visitor); +void VisitDataFiles(const char* filter, File::Visitor &visitor); [[gnu::pure]] Path @@ -107,4 +107,4 @@ GetCachePath() noexcept; [[gnu::pure]] AllocatedPath -MakeCacheDirectory(const TCHAR *name) noexcept; +MakeCacheDirectory(const char *name) noexcept; diff --git a/src/Logger/ExternalLogger.cpp b/src/Logger/ExternalLogger.cpp index 415c5b5fbaa..de8e762a39e 100644 --- a/src/Logger/ExternalLogger.cpp +++ b/src/Logger/ExternalLogger.cpp @@ -73,7 +73,7 @@ try { MessageOperationEnvironment env; const ScopeReturnDevice return_device{dev, env}; - const TCHAR *caption = dev.GetDisplayName(); + const char *caption = dev.GetDisplayName(); if (caption == nullptr) caption = _("Declare task"); @@ -316,7 +316,7 @@ ExternalLogger::DownloadFlightFrom(DeviceDescriptor &device) if (header.flight == 0) header.flight = GetFlightNumber(flight_list, *flight); - TCHAR name[64]; + char name[64]; FormatIGCFilenameLong(name, date, header.manufacturer, header.id, header.flight); diff --git a/src/Logger/Logger.cpp b/src/Logger/Logger.cpp index d20d45a63ef..6ae9e1d0d5b 100644 --- a/src/Logger/Logger.cpp +++ b/src/Logger/Logger.cpp @@ -68,7 +68,7 @@ Logger::GUIStartLogger(const NMEAInfo& gps_info, if (task) { if (!noAsk) { - TCHAR TaskMessage[1024]; + char TaskMessage[1024]; strcpy(TaskMessage, _T("Start Logger With Declaration\r\n")); if (decl.Size()) { @@ -117,7 +117,7 @@ Logger::GUIStopLogger(const NMEAInfo &gps_info, } void -Logger::LoggerNote(const TCHAR *text) +Logger::LoggerNote(const char *text) { const std::lock_guard protect{lock}; logger.LoggerNote(text); diff --git a/src/Logger/Logger.hpp b/src/Logger/Logger.hpp index c6268f651b4..95d84b8cf0b 100644 --- a/src/Logger/Logger.hpp +++ b/src/Logger/Logger.hpp @@ -38,6 +38,6 @@ class Logger { bool noAsk = false); void GUIStopLogger(const NMEAInfo &gps_info, bool noAsk = false); - void LoggerNote(const TCHAR *text); + void LoggerNote(const char *text); void ClearBuffer() noexcept; }; diff --git a/src/Logger/LoggerImpl.cpp b/src/Logger/LoggerImpl.cpp index 02a287107b2..44dba072e51 100644 --- a/src/Logger/LoggerImpl.cpp +++ b/src/Logger/LoggerImpl.cpp @@ -231,14 +231,14 @@ LoggerImpl::StartLogger(const NMEAInfo &gps_info, } void -LoggerImpl::LoggerNote(const TCHAR *text) +LoggerImpl::LoggerNote(const char *text) { if (writer != nullptr) writer->LoggerNote(text); } [[gnu::pure]] -static const TCHAR * +static const char * GetGPSDeviceName() noexcept { if (is_simulator()) @@ -258,7 +258,7 @@ GetGPSDeviceName() noexcept void LoggerImpl::StartLogger(const NMEAInfo &gps_info, const LoggerSettings &settings, - const TCHAR *asset_number, const Declaration &decl) + const char *asset_number, const Declaration &decl) { if (!settings.logger_id.empty()) asset_number = settings.logger_id.c_str(); diff --git a/src/Logger/LoggerImpl.hpp b/src/Logger/LoggerImpl.hpp index 75bc2f01a47..67772f00811 100644 --- a/src/Logger/LoggerImpl.hpp +++ b/src/Logger/LoggerImpl.hpp @@ -100,14 +100,14 @@ class LoggerImpl } void StartLogger(const NMEAInfo &gps_info, const LoggerSettings &settings, - const TCHAR *asset_number, const Declaration &decl); + const char *asset_number, const Declaration &decl); /** * Stops the logger * @param gps_info NMEA_INFO struct holding the current date */ void StopLogger(const NMEAInfo &gps_info); - void LoggerNote(const TCHAR *text); + void LoggerNote(const char *text); void ClearBuffer() noexcept; private: diff --git a/src/Look/AutoFont.cpp b/src/Look/AutoFont.cpp index 6f745cb7370..15c7c40153a 100644 --- a/src/Look/AutoFont.cpp +++ b/src/Look/AutoFont.cpp @@ -8,7 +8,7 @@ #include void -AutoSizeFont(FontDescription &d, unsigned width, const TCHAR *text) +AutoSizeFont(FontDescription &d, unsigned width, const char *text) { // JMW algorithm to auto-size info window font. // this is still required in case title font property doesn't exist. diff --git a/src/Look/AutoFont.hpp b/src/Look/AutoFont.hpp index 6173073214d..f76d50eb324 100644 --- a/src/Look/AutoFont.hpp +++ b/src/Look/AutoFont.hpp @@ -13,4 +13,4 @@ class FontDescription; * Throws on error. */ void -AutoSizeFont(FontDescription &d, unsigned width, const TCHAR *text); +AutoSizeFont(FontDescription &d, unsigned width, const char *text); diff --git a/src/Look/FontDescription.cpp b/src/Look/FontDescription.cpp index 4d55b42737b..76ed45762d2 100644 --- a/src/Look/FontDescription.cpp +++ b/src/Look/FontDescription.cpp @@ -16,7 +16,7 @@ FontDescription::FontDescription(unsigned height, } void -FontDescription::Init(const TCHAR *face, +FontDescription::Init(const char *face, int height, bool bold, bool italic, bool monospace) diff --git a/src/Look/FontDescription.hpp b/src/Look/FontDescription.hpp index 71bf4c87e8b..7423bfd1c28 100644 --- a/src/Look/FontDescription.hpp +++ b/src/Look/FontDescription.hpp @@ -50,7 +50,7 @@ class FontDescription { } private: - void Init(const TCHAR *face, + void Init(const char *face, int height, bool bold, bool italic, bool monospace); diff --git a/src/Look/StandardFonts.hpp b/src/Look/StandardFonts.hpp index bcc025ca765..b3a4dc1225e 100644 --- a/src/Look/StandardFonts.hpp +++ b/src/Look/StandardFonts.hpp @@ -6,14 +6,14 @@ #include [[gnu::const]] -static inline const TCHAR * +static inline const char * GetStandardMonospaceFontFace() noexcept { return _T("Consolas"); } [[gnu::const]] -static inline const TCHAR * +static inline const char * GetStandardFontFace() noexcept { return _T("Segeo UI"); diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 19f03eed590..5993af9a9ed 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -626,7 +626,7 @@ MainWindow::OnMouseUp(PixelPoint p) noexcept if (dragging) { StopDragging(); - const TCHAR *gesture = gestures.Finish(); + const char *gesture = gestures.Finish(); if (gesture && InputEvents::processGesture(gesture)) return true; } @@ -1056,7 +1056,7 @@ MainWindow::SetWidget(Widget *_widget) noexcept } Widget * -MainWindow::GetFlavourWidget(const TCHAR *flavour) noexcept +MainWindow::GetFlavourWidget(const char *flavour) noexcept { return InputEvents::IsFlavour(flavour) ? widget diff --git a/src/MainWindow.hpp b/src/MainWindow.hpp index b6d8a993a45..940a9578838 100644 --- a/src/MainWindow.hpp +++ b/src/MainWindow.hpp @@ -37,7 +37,7 @@ namespace InfoBoxLayout { struct Layout; } * The XCSoar main window. */ class MainWindow : public UI::SingleWindow { - static constexpr const TCHAR *title = _T("OpenSoar"); + static constexpr const char *title = _T("OpenSoar"); Look *look = nullptr; @@ -357,7 +357,7 @@ class MainWindow : public UI::SingleWindow { * @see InputEvents::IsFlavour(), InputEvents::SetFlavour() */ [[gnu::pure]] - Widget *GetFlavourWidget(const TCHAR *flavour) noexcept; + Widget *GetFlavourWidget(const char *flavour) noexcept; void ShowMenu(const Menu &menu, const Menu *overlay=nullptr, bool full=true) noexcept; diff --git a/src/MapWindow/GlueMapWindow.hpp b/src/MapWindow/GlueMapWindow.hpp index 07e6a29facd..0612babc144 100644 --- a/src/MapWindow/GlueMapWindow.hpp +++ b/src/MapWindow/GlueMapWindow.hpp @@ -236,7 +236,7 @@ class GlueMapWindow : public MapWindow { * @return True if the gesture was handled by the * event handler, False otherwise */ - bool OnMouseGesture(const TCHAR* gesture) noexcept; + bool OnMouseGesture(const char* gesture) noexcept; private: void DrawGesture(Canvas &canvas) const noexcept; diff --git a/src/MapWindow/GlueMapWindowEvents.cpp b/src/MapWindow/GlueMapWindowEvents.cpp index 03f48d689e0..55a7808ea87 100644 --- a/src/MapWindow/GlueMapWindowEvents.cpp +++ b/src/MapWindow/GlueMapWindowEvents.cpp @@ -266,7 +266,7 @@ GlueMapWindow::OnMouseUp(PixelPoint p) noexcept break; case DRAG_GESTURE: - const TCHAR* gesture = gestures.Finish(); + const char* gesture = gestures.Finish(); if (gesture && OnMouseGesture(gesture)) return true; @@ -328,7 +328,7 @@ GlueMapWindow::OnMultiTouchDown() noexcept #endif /* HAVE_MULTI_TOUCH */ bool -GlueMapWindow::OnMouseGesture(const TCHAR *gesture) noexcept +GlueMapWindow::OnMouseGesture(const char *gesture) noexcept { return InputEvents::processGesture(gesture); } diff --git a/src/MapWindow/GlueMapWindowOverlays.cpp b/src/MapWindow/GlueMapWindowOverlays.cpp index 10f50f68ece..f0ae0997f2c 100644 --- a/src/MapWindow/GlueMapWindowOverlays.cpp +++ b/src/MapWindow/GlueMapWindowOverlays.cpp @@ -30,7 +30,7 @@ GlueMapWindow::DrawGesture(Canvas &canvas) const noexcept if (!gestures.HasPoints()) return; - const TCHAR *gesture = gestures.GetGesture(); + const char *gesture = gestures.GetGesture(); if (gesture != nullptr && !InputEvents::IsGesture(gesture)) canvas.Select(gesture_look.invalid_pen); else @@ -120,10 +120,10 @@ GlueMapWindow::DrawPanInfo(Canvas &canvas) const noexcept } } - TCHAR buffer[256]; + char buffer[256]; FormatGeoPoint(location, buffer, ARRAY_SIZE(buffer), _T('\n')); - TCHAR *start = buffer; + char *start = buffer; while (true) { auto *newline = StringFind(start, _T('\n')); if (newline != nullptr) @@ -144,7 +144,7 @@ void GlueMapWindow::DrawGPSStatus(Canvas &canvas, const PixelRect &rc, const NMEAInfo &info) const noexcept { - const TCHAR *txt; + const char *txt; const MaskedIcon *icon; if (!info.alive) { @@ -340,7 +340,7 @@ GlueMapWindow::DrawMapScale(Canvas &canvas, const PixelRect &rc, (int)GetComputerSettings().polar.glide_polar_task.GetBallastLitres()); if (rasp_renderer != nullptr) { - const TCHAR *label = rasp_renderer->GetLabel(); + const char *label = rasp_renderer->GetLabel(); if (label != nullptr) buffer += gettext(label); } diff --git a/src/MapWindow/Items/MapItem.hpp b/src/MapWindow/Items/MapItem.hpp index b644c3682e8..cba043758cc 100644 --- a/src/MapWindow/Items/MapItem.hpp +++ b/src/MapWindow/Items/MapItem.hpp @@ -198,7 +198,7 @@ struct SkyLinesTrafficMapItem : public MapItem SkyLinesTrafficMapItem(uint32_t _id, Time _time_of_day_ms, int _altitude, - const TCHAR *_name) + const char *_name) :MapItem(Type::SKYLINES_TRAFFIC), id(_id), time_of_day(_time_of_day_ms), altitude(_altitude), name(_name) {} diff --git a/src/MapWindow/Items/RaspMapItem.hpp b/src/MapWindow/Items/RaspMapItem.hpp index 4897cfad151..cac9a112593 100644 --- a/src/MapWindow/Items/RaspMapItem.hpp +++ b/src/MapWindow/Items/RaspMapItem.hpp @@ -14,6 +14,6 @@ struct RaspMapItem : public MapItem { const StaticString<64> label; - explicit RaspMapItem(const TCHAR *_label) + explicit RaspMapItem(const char *_label) :MapItem(Type::RASP), label(_label) {} }; diff --git a/src/MapWindow/Items/TrafficBuilder.cpp b/src/MapWindow/Items/TrafficBuilder.cpp index 9d939f64638..00fa89a0d93 100644 --- a/src/MapWindow/Items/TrafficBuilder.cpp +++ b/src/MapWindow/Items/TrafficBuilder.cpp @@ -45,7 +45,7 @@ MapItemListBuilder::AddSkyLinesTraffic() location.DistanceS(i.second.location) < range) { const uint32_t id = i.first; auto name_i = data.user_names.find(id); - const TCHAR *name; + const char *name; if (name_i == data.user_names.end()) { /* no name found */ buffer.UnsafeFormat(_T("SkyLines %u"), (unsigned)id); diff --git a/src/MapWindow/MapWindowTask.cpp b/src/MapWindow/MapWindowTask.cpp index 845bd85fc9f..05663bfc221 100644 --- a/src/MapWindow/MapWindowTask.cpp +++ b/src/MapWindow/MapWindowTask.cpp @@ -129,7 +129,7 @@ MapWindow::DrawTaskOffTrackIndicator(Canvas &canvas) noexcept int idist = iround((distance - 1) * 100); if ((idist != ilast) && (idist > 0) && (idist < 1000)) { - TCHAR Buffer[5]; + char Buffer[5]; _stprintf(Buffer, _T("%d"), idist); auto sc = render_projection.GeoToScreen(dloc); PixelSize tsize = canvas.CalcTextSize(Buffer); diff --git a/src/MapWindow/MapWindowTraffic.cpp b/src/MapWindow/MapWindowTraffic.cpp index 05393bf2c0d..7505ba3fb87 100644 --- a/src/MapWindow/MapWindowTraffic.cpp +++ b/src/MapWindow/MapWindowTraffic.cpp @@ -184,7 +184,7 @@ MapWindow::DrawGLinkTraffic([[maybe_unused]] Canvas &canvas) const noexcept if(basic.gps_altitude_available && traf.altitude_received && fabs(double(traf.altitude) - basic.gps_altitude) >= 100.0) { // If average climb data available draw it to the canvas - TCHAR label_alt[100]; + char label_alt[100]; double alt = (double(traf.altitude) - basic.gps_altitude) / 100.0; FormatRelativeUserAltitude(alt, label_alt, false); @@ -235,7 +235,7 @@ MapWindow::DrawSkyLinesTraffic(Canvas &canvas) const noexcept traffic_look.teammate_icon.Draw(canvas, *p); if (DisplaySkyLinesTrafficMapMode::SYMBOL_NAME == GetMapSettings().skylines_traffic_map_mode) { const auto name_i = skylines_data->user_names.find(i.first); - const TCHAR *name = name_i != skylines_data->user_names.end() + const char *name = name_i != skylines_data->user_names.end() ? name_i->second.c_str() : _T(""); diff --git a/src/MapWindow/Overlay.hpp b/src/MapWindow/Overlay.hpp index d97004d92fa..fd97b54479c 100644 --- a/src/MapWindow/Overlay.hpp +++ b/src/MapWindow/Overlay.hpp @@ -24,7 +24,7 @@ class MapOverlay { * Returns a human-readable name for this overlay. */ [[gnu::pure]] - virtual const TCHAR *GetLabel() const noexcept = 0; + virtual const char *GetLabel() const noexcept = 0; /** * Check whether the given location is inside the overlay. diff --git a/src/MapWindow/OverlayBitmap.hpp b/src/MapWindow/OverlayBitmap.hpp index 4bebf0e48c8..4461f667d3e 100644 --- a/src/MapWindow/OverlayBitmap.hpp +++ b/src/MapWindow/OverlayBitmap.hpp @@ -75,7 +75,7 @@ class MapOverlayBitmap final : public MapOverlay { } /* virtual methods from class MapOverlay */ - const TCHAR *GetLabel() const noexcept override { + const char *GetLabel() const noexcept override { return label.c_str(); } diff --git a/src/Menu/ButtonLabel.cpp b/src/Menu/ButtonLabel.cpp index 033d992d15b..01b83d8616f 100644 --- a/src/Menu/ButtonLabel.cpp +++ b/src/Menu/ButtonLabel.cpp @@ -16,7 +16,7 @@ * @return false if there is at least one ASCII letter in the string */ static constexpr bool -LacksAlphaASCII(const TCHAR *s) noexcept +LacksAlphaASCII(const char *s) noexcept { for (; *s != 0; ++s) if (IsAlphaASCII(*s)) @@ -31,9 +31,9 @@ LacksAlphaASCII(const TCHAR *s) noexcept * @return the translated string or nullptr if the buffer is too small */ [[gnu::pure]] -static const TCHAR * -GetTextN(const TCHAR *src, const TCHAR *src_end, - TCHAR *buffer, size_t buffer_size) noexcept +static const char * +GetTextN(const char *src, const char *src_end, + char *buffer, size_t buffer_size) noexcept { if (src == src_end) /* gettext("") returns the PO header, and thus we need to exclude @@ -53,10 +53,10 @@ GetTextN(const TCHAR *src, const TCHAR *src_end, } ButtonLabel::Expanded -ButtonLabel::Expand(const TCHAR *text, std::span buffer) noexcept +ButtonLabel::Expand(const char *text, std::span buffer) noexcept { Expanded expanded; - const TCHAR *dollar; + const char *dollar; if (text == nullptr || *text == _T('\0') || *text == _T(' ')) { expanded.visible = false; @@ -65,15 +65,15 @@ ButtonLabel::Expand(const TCHAR *text, std::span buffer) noexcept /* no macro, we can just translate the text */ expanded.visible = true; expanded.enabled = true; - const TCHAR *nl = StringFind(text, '\n'); + const char *nl = StringFind(text, '\n'); if (nl != nullptr && LacksAlphaASCII(nl + 1)) { /* Quick hack for skipping the translation for second line of a two line label with only digits and punctuation in the second line, e.g. for menu labels like "Config\n2/3" */ /* copy the text up to the '\n' to a new buffer and translate it */ - TCHAR translatable[256]; - const TCHAR *translated = GetTextN(text, nl, translatable, + char translatable[256]; + const char *translated = GetTextN(text, nl, translatable, ARRAY_SIZE(translatable)); if (translated == nullptr) { /* buffer too small: keep it untranslated */ @@ -84,20 +84,20 @@ ButtonLabel::Expand(const TCHAR *text, std::span buffer) noexcept /* concatenate the translated text and the part starting with '\n' */ try { expanded.text = BuildString(buffer, translated, nl); - } catch (BasicStringBuilder::Overflow) { + } catch (BasicStringBuilder::Overflow) { expanded.text = gettext(text); } } else expanded.text = gettext(text); return expanded; } else { - const TCHAR *macros = dollar; + const char *macros = dollar; /* backtrack until the first non-whitespace character, because we don't want to translate whitespace between the text and the macro */ macros = StripRight(text, macros); - TCHAR s[100]; + char s[100]; expanded.enabled = !ExpandMacros(text, std::span{s}); if (s[0] == _T('\0') || s[0] == _T(' ')) { expanded.visible = false; @@ -106,8 +106,8 @@ ButtonLabel::Expand(const TCHAR *text, std::span buffer) noexcept /* copy the text (without trailing whitespace) to a new buffer and translate it */ - TCHAR translatable[256]; - const TCHAR *translated = GetTextN(text, macros, translatable, + char translatable[256]; + const char *translated = GetTextN(text, macros, translatable, ARRAY_SIZE(translatable)); if (translated == nullptr) { /* buffer too small: fail */ diff --git a/src/Menu/ButtonLabel.hpp b/src/Menu/ButtonLabel.hpp index 9b300c17044..e1b1871486f 100644 --- a/src/Menu/ButtonLabel.hpp +++ b/src/Menu/ButtonLabel.hpp @@ -15,14 +15,14 @@ namespace ButtonLabel { struct Expanded { bool visible, enabled; - const TCHAR *text; + const char *text; }; [[gnu::pure]] Expanded -Expand(const TCHAR *text, std::span buffer) noexcept; +Expand(const char *text, std::span buffer) noexcept; bool -ExpandMacros(const TCHAR *In, std::span dest) noexcept; +ExpandMacros(const char *In, std::span dest) noexcept; } // namespace ButtonLabel diff --git a/src/Menu/ExpandMacros.cpp b/src/Menu/ExpandMacros.cpp index f65d504dce7..38f1ed0b77a 100644 --- a/src/Menu/ExpandMacros.cpp +++ b/src/Menu/ExpandMacros.cpp @@ -28,7 +28,7 @@ #include -static const TCHAR * +static const char * ExpandTaskMacros(tstring_view name, bool &invalid, const DerivedInfo &calculated, @@ -197,7 +197,7 @@ ExpandTaskMacros(tstring_view name, } [[gnu::pure]] -static const TCHAR * +static const char * ExpandTrafficMacros(tstring_view name) noexcept { TrafficWidget *widget = (TrafficWidget *) @@ -243,7 +243,7 @@ GetUIState() noexcept return CommonInterface::GetUIState(); } -static const TCHAR * +static const char * LookupMacro(tstring_view name, bool &invalid) noexcept { if (name ==_T("CheckAirspace")) { @@ -251,7 +251,7 @@ LookupMacro(tstring_view name, bool &invalid) noexcept return nullptr; } - const TCHAR *value = ExpandTaskMacros(name, invalid, + const char *value = ExpandTaskMacros(name, invalid, Calculated(), GetComputerSettings()); if (value != nullptr) return value; @@ -362,7 +362,7 @@ LookupMacro(tstring_view name, bool &invalid) noexcept } else if (name == _T("AirspaceToggleActionName")) { return GetMapSettings().airspace.enable ? _("Hide") : _("Show"); } else if (name == _T("MapLabelsToggleActionName")) { - static const TCHAR *const labels[] = { + static const char *const labels[] = { N_("All"), N_("Task & Landables"), N_("Task"), @@ -426,7 +426,7 @@ LookupMacro(tstring_view name, bool &invalid) noexcept } else if (name == _T("ZoomAutoToggleActionName")) { return GetMapSettings().auto_zoom_enabled ? _("Manual") : _("Auto"); } else if (name == _T("NextPageName")) { - static TCHAR label[64]; // TODO: oh no, a static string buffer! + static char label[64]; // TODO: oh no, a static string buffer! const PageLayout &page = CommonInterface::GetUISettings().pages.pages[PageActions::NextIndex()]; return page.MakeTitle(CommonInterface::GetUISettings().info_boxes, @@ -436,7 +436,7 @@ LookupMacro(tstring_view name, bool &invalid) noexcept } bool -ButtonLabel::ExpandMacros(const TCHAR *In, std::span dest) noexcept +ButtonLabel::ExpandMacros(const char *In, std::span dest) noexcept { bool invalid = false; diff --git a/src/Menu/Glue.cpp b/src/Menu/Glue.cpp index b0de665c3fc..4d0f9d7bb3d 100644 --- a/src/Menu/Glue.cpp +++ b/src/Menu/Glue.cpp @@ -10,9 +10,9 @@ namespace MenuGlue { void SetLabelText(MenuBar &bar, unsigned index, - const TCHAR *text, unsigned event) noexcept + const char *text, unsigned event) noexcept { - TCHAR buffer[100]; + char buffer[100]; const auto expanded = ButtonLabel::Expand(text, std::span{buffer}); if (expanded.visible) bar.ShowButton(index, expanded.enabled, expanded.text, event); diff --git a/src/Menu/Glue.hpp b/src/Menu/Glue.hpp index 4a0cf48dc62..cd9d5ae2bb0 100644 --- a/src/Menu/Glue.hpp +++ b/src/Menu/Glue.hpp @@ -12,7 +12,7 @@ namespace MenuGlue { void SetLabelText(MenuBar &bar, unsigned i, - const TCHAR *text, unsigned event) noexcept; + const char *text, unsigned event) noexcept; /** * Show the specified menu. diff --git a/src/Menu/MenuBar.cpp b/src/Menu/MenuBar.cpp index 7a2cf200168..73f6cf4acb8 100644 --- a/src/Menu/MenuBar.cpp +++ b/src/Menu/MenuBar.cpp @@ -81,7 +81,7 @@ MenuBar::MenuBar(ContainerWindow &parent, const ButtonLook &look) } void -MenuBar::ShowButton(unsigned i, bool enabled, const TCHAR *text, +MenuBar::ShowButton(unsigned i, bool enabled, const char *text, unsigned event) { assert(i < MAX_BUTTONS); diff --git a/src/Menu/MenuBar.hpp b/src/Menu/MenuBar.hpp index 9639bfcd4b2..3b91124dff0 100644 --- a/src/Menu/MenuBar.hpp +++ b/src/Menu/MenuBar.hpp @@ -39,7 +39,7 @@ class MenuBar { MenuBar(ContainerWindow &parent, const ButtonLook &look); public: - void ShowButton(unsigned i, bool enabled, const TCHAR *text, + void ShowButton(unsigned i, bool enabled, const char *text, unsigned event); void HideButton(unsigned i); diff --git a/src/Menu/MenuData.cpp b/src/Menu/MenuData.cpp index f30b9fd2263..490a553a7ff 100644 --- a/src/Menu/MenuData.cpp +++ b/src/Menu/MenuData.cpp @@ -11,7 +11,7 @@ Menu::Clear() noexcept } void -Menu::Add(const TCHAR *label, unsigned location, unsigned event_id) noexcept +Menu::Add(const char *label, unsigned location, unsigned event_id) noexcept { if (location >= items.size()) return; diff --git a/src/Menu/MenuData.hpp b/src/Menu/MenuData.hpp index 945290967ad..59fb1658ac5 100644 --- a/src/Menu/MenuData.hpp +++ b/src/Menu/MenuData.hpp @@ -13,7 +13,7 @@ */ class MenuItem { public: - const TCHAR *label; + const char *label; unsigned event; void Clear() noexcept { @@ -53,7 +53,7 @@ class Menu { return items[i]; } - void Add(const TCHAR *label, unsigned location, unsigned event_id) noexcept; + void Add(const char *label, unsigned location, unsigned event_id) noexcept; [[gnu::pure]] int FindByEvent(unsigned event) const noexcept; diff --git a/src/Message.cpp b/src/Message.cpp index 4d398af1509..b04f843c0f0 100644 --- a/src/Message.cpp +++ b/src/Message.cpp @@ -7,7 +7,7 @@ #include "Interface.hpp" void -Message::AddMessage(const TCHAR *text, const TCHAR *data) noexcept +Message::AddMessage(const char *text, const char *data) noexcept { if (CommonInterface::main_window->popup != nullptr) CommonInterface::main_window->popup->AddMessage(text, data); diff --git a/src/Message.hpp b/src/Message.hpp index d642ee57232..81e440e0e48 100644 --- a/src/Message.hpp +++ b/src/Message.hpp @@ -8,6 +8,6 @@ namespace Message { void -AddMessage(const TCHAR *text, const TCHAR *data=nullptr) noexcept; +AddMessage(const char *text, const char *data=nullptr) noexcept; } // namespace Message diff --git a/src/Monitor/AirspaceWarningMonitor.cpp b/src/Monitor/AirspaceWarningMonitor.cpp index cc75465698c..9bb1c1032c6 100644 --- a/src/Monitor/AirspaceWarningMonitor.cpp +++ b/src/Monitor/AirspaceWarningMonitor.cpp @@ -30,7 +30,7 @@ class AirspaceWarningWidget final StaticString<256> buffer; [[gnu::pure]] - const TCHAR *MakeMessage(const AbstractAirspace &airspace, + const char *MakeMessage(const AbstractAirspace &airspace, AirspaceWarning::State state, const AirspaceInterceptSolution &solution) noexcept { if (state == AirspaceWarning::WARNING_INSIDE) diff --git a/src/Monitor/MatTaskMonitor.cpp b/src/Monitor/MatTaskMonitor.cpp index ade12963a38..a8d8f2d7297 100644 --- a/src/Monitor/MatTaskMonitor.cpp +++ b/src/Monitor/MatTaskMonitor.cpp @@ -28,7 +28,7 @@ class MatTaskAddWidget final StaticString<256> buffer; [[gnu::pure]] - const TCHAR *MakeMessage(const Waypoint &wp) { + const char *MakeMessage(const Waypoint &wp) { buffer.Format(_T("%s\n%s"), wp.name.c_str(), _("Add this turn point?")); return buffer; } diff --git a/src/OpenVario/ExtraWidget.cpp b/src/OpenVario/ExtraWidget.cpp index 6078f682139..1101acde79c 100644 --- a/src/OpenVario/ExtraWidget.cpp +++ b/src/OpenVario/ExtraWidget.cpp @@ -26,9 +26,9 @@ #include #include -constexpr const TCHAR *opensoar = _T("OpenSoar"); -constexpr const TCHAR *xcsoar = _T("XCSoar"); -constexpr const TCHAR *main_app = opensoar; +constexpr const char *opensoar = _T("OpenSoar"); +constexpr const char *xcsoar = _T("XCSoar"); +constexpr const char *main_app = opensoar; constexpr const char *_main_app = "OpenSoar"; // only temporarily class ExtraWidget final : public RowFormWidget { diff --git a/src/OpenVario/FileMenuWidget.cpp b/src/OpenVario/FileMenuWidget.cpp index 340aba119f4..b981e7f4b54 100644 --- a/src/OpenVario/FileMenuWidget.cpp +++ b/src/OpenVario/FileMenuWidget.cpp @@ -20,9 +20,9 @@ #include #include -constexpr const TCHAR *opensoar = _T("OpenSoar"); -constexpr const TCHAR *xcsoar = _T("XCSoar"); -constexpr const TCHAR *main_app = opensoar; +constexpr const char *opensoar = _T("OpenSoar"); +constexpr const char *xcsoar = _T("XCSoar"); +constexpr const char *main_app = opensoar; constexpr const char *_main_app = "OpenSoar"; // only temporarily class FileMenuWidget final : public RowFormWidget { diff --git a/src/OpenVario/System/WifiDialogOV.cpp b/src/OpenVario/System/WifiDialogOV.cpp index 6482b2223de..8dc161a99af 100644 --- a/src/OpenVario/System/WifiDialogOV.cpp +++ b/src/OpenVario/System/WifiDialogOV.cpp @@ -251,7 +251,7 @@ WifiListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, row_renderer.DrawFirstRow(canvas, rc, _W(info.ssid)); row_renderer.DrawSecondRow(canvas, rc,_W(info.bssid)); - const TCHAR *state = nullptr; + const char *state = nullptr; StaticString<40> state_buffer; /* found the currently connected wifi network? */ diff --git a/src/Operation/ConsoleOperationEnvironment.cpp b/src/Operation/ConsoleOperationEnvironment.cpp index f130ad38bc7..2d08672a377 100644 --- a/src/Operation/ConsoleOperationEnvironment.cpp +++ b/src/Operation/ConsoleOperationEnvironment.cpp @@ -6,13 +6,13 @@ #include void -ConsoleOperationEnvironment::SetErrorMessage(const TCHAR *text) noexcept +ConsoleOperationEnvironment::SetErrorMessage(const char *text) noexcept { _ftprintf(stderr, _T("ERROR: %s\n"), text); } void -ConsoleOperationEnvironment::SetText(const TCHAR *text) noexcept +ConsoleOperationEnvironment::SetText(const char *text) noexcept { _tprintf(_T("%s\n"), text); } diff --git a/src/Operation/ConsoleOperationEnvironment.hpp b/src/Operation/ConsoleOperationEnvironment.hpp index 77d22d72997..d8a66cfbef0 100644 --- a/src/Operation/ConsoleOperationEnvironment.hpp +++ b/src/Operation/ConsoleOperationEnvironment.hpp @@ -10,8 +10,8 @@ class ConsoleOperationEnvironment : public QuietOperationEnvironment { public: /* virtual methods from class OperationEnvironment */ - void SetErrorMessage(const TCHAR *text) noexcept override; - void SetText(const TCHAR *text) noexcept override; + void SetErrorMessage(const char *text) noexcept override; + void SetText(const char *text) noexcept override; void SetProgressRange(unsigned range) noexcept override; void SetProgressPosition(unsigned position) noexcept override; }; diff --git a/src/Operation/MessageOperationEnvironment.cpp b/src/Operation/MessageOperationEnvironment.cpp index be24766b708..2145f0876d9 100644 --- a/src/Operation/MessageOperationEnvironment.cpp +++ b/src/Operation/MessageOperationEnvironment.cpp @@ -5,7 +5,7 @@ #include "Dialogs/Message.hpp" void -MessageOperationEnvironment::SetErrorMessage(const TCHAR *text) noexcept +MessageOperationEnvironment::SetErrorMessage(const char *text) noexcept { ShowMessageBox(text, _T(""), MB_OK|MB_ICONERROR); } diff --git a/src/Operation/MessageOperationEnvironment.hpp b/src/Operation/MessageOperationEnvironment.hpp index 88de3576bce..43502934bc0 100644 --- a/src/Operation/MessageOperationEnvironment.hpp +++ b/src/Operation/MessageOperationEnvironment.hpp @@ -12,5 +12,5 @@ class MessageOperationEnvironment : public QuietOperationEnvironment { public: /* virtual methods from class OperationEnvironment */ - void SetErrorMessage(const TCHAR *text) noexcept override; + void SetErrorMessage(const char *text) noexcept override; }; diff --git a/src/Operation/Operation.cpp b/src/Operation/Operation.cpp index 37fecda0ee9..4a682198226 100644 --- a/src/Operation/Operation.cpp +++ b/src/Operation/Operation.cpp @@ -30,12 +30,12 @@ NullOperationEnvironment::Sleep(std::chrono::steady_clock::duration) noexcept } void -NullOperationEnvironment::SetErrorMessage([[maybe_unused]] const TCHAR *text) noexcept +NullOperationEnvironment::SetErrorMessage([[maybe_unused]] const char *text) noexcept { } void -NullOperationEnvironment::SetText([[maybe_unused]] const TCHAR *text) noexcept +NullOperationEnvironment::SetText([[maybe_unused]] const char *text) noexcept { } diff --git a/src/Operation/Operation.hpp b/src/Operation/Operation.hpp index 337a54dd152..11e621fea9f 100644 --- a/src/Operation/Operation.hpp +++ b/src/Operation/Operation.hpp @@ -44,13 +44,13 @@ class OperationEnvironment : private NonCopyable, public ProgressListener { * Show a human-readable (localized) short text describing the * error condition. */ - virtual void SetErrorMessage(const TCHAR *text) noexcept = 0; + virtual void SetErrorMessage(const char *text) noexcept = 0; /** * Show a human-readable (localized) short text describing the * current state of the operation. */ - virtual void SetText(const TCHAR *text) noexcept = 0; + virtual void SetText(const char *text) noexcept = 0; }; class NullOperationEnvironment : public OperationEnvironment { @@ -59,8 +59,8 @@ class NullOperationEnvironment : public OperationEnvironment { bool IsCancelled() const noexcept override; void SetCancelHandler(std::function handler) noexcept override; void Sleep(std::chrono::steady_clock::duration duration) noexcept override; - void SetErrorMessage(const TCHAR *text) noexcept override; - void SetText(const TCHAR *text) noexcept override; + void SetErrorMessage(const char *text) noexcept override; + void SetText(const char *text) noexcept override; void SetProgressRange(unsigned range) noexcept override; void SetProgressPosition(unsigned position) noexcept override; }; diff --git a/src/Operation/PluggableOperationEnvironment.cpp b/src/Operation/PluggableOperationEnvironment.cpp index 8a639bbfbdd..579c3ecb6ff 100644 --- a/src/Operation/PluggableOperationEnvironment.cpp +++ b/src/Operation/PluggableOperationEnvironment.cpp @@ -27,14 +27,14 @@ PluggableOperationEnvironment::Sleep(std::chrono::steady_clock::duration duratio } void -PluggableOperationEnvironment::SetErrorMessage(const TCHAR *text) noexcept +PluggableOperationEnvironment::SetErrorMessage(const char *text) noexcept { if (other != nullptr) other->SetErrorMessage(text); } void -PluggableOperationEnvironment::SetText(const TCHAR *text) noexcept +PluggableOperationEnvironment::SetText(const char *text) noexcept { if (other != nullptr) other->SetText(text); diff --git a/src/Operation/PluggableOperationEnvironment.hpp b/src/Operation/PluggableOperationEnvironment.hpp index fdd1670cfe8..8e69529a29b 100644 --- a/src/Operation/PluggableOperationEnvironment.hpp +++ b/src/Operation/PluggableOperationEnvironment.hpp @@ -27,8 +27,8 @@ class PluggableOperationEnvironment final : public OperationEnvironment { bool IsCancelled() const noexcept override; void SetCancelHandler(std::function handler) noexcept override; void Sleep(std::chrono::steady_clock::duration duration) noexcept override; - void SetErrorMessage(const TCHAR *text) noexcept override; - void SetText(const TCHAR *text) noexcept override; + void SetErrorMessage(const char *text) noexcept override; + void SetText(const char *text) noexcept override; void SetProgressRange(unsigned range) noexcept override; void SetProgressPosition(unsigned position) noexcept override; }; diff --git a/src/Operation/PopupOperationEnvironment.cpp b/src/Operation/PopupOperationEnvironment.cpp index ab729bfcd9f..1f080ecb14d 100644 --- a/src/Operation/PopupOperationEnvironment.cpp +++ b/src/Operation/PopupOperationEnvironment.cpp @@ -5,7 +5,7 @@ #include "Message.hpp" void -PopupOperationEnvironment::SetErrorMessage(const TCHAR *text) noexcept +PopupOperationEnvironment::SetErrorMessage(const char *text) noexcept { Message::AddMessage(text); } diff --git a/src/Operation/PopupOperationEnvironment.hpp b/src/Operation/PopupOperationEnvironment.hpp index b3b4ec9c54d..fbfc6674823 100644 --- a/src/Operation/PopupOperationEnvironment.hpp +++ b/src/Operation/PopupOperationEnvironment.hpp @@ -11,5 +11,5 @@ class PopupOperationEnvironment : public QuietOperationEnvironment { public: /* virtual methods from class OperationEnvironment */ - void SetErrorMessage(const TCHAR *text) noexcept override; + void SetErrorMessage(const char *text) noexcept override; }; diff --git a/src/Operation/ProxyOperationEnvironment.cpp b/src/Operation/ProxyOperationEnvironment.cpp index ff589f0d88d..8f4f290a4c8 100644 --- a/src/Operation/ProxyOperationEnvironment.cpp +++ b/src/Operation/ProxyOperationEnvironment.cpp @@ -22,13 +22,13 @@ ProxyOperationEnvironment::Sleep(std::chrono::steady_clock::duration duration) n } void -ProxyOperationEnvironment::SetErrorMessage(const TCHAR *text) noexcept +ProxyOperationEnvironment::SetErrorMessage(const char *text) noexcept { other.SetErrorMessage(text); } void -ProxyOperationEnvironment::SetText(const TCHAR *text) noexcept +ProxyOperationEnvironment::SetText(const char *text) noexcept { other.SetText(text); } diff --git a/src/Operation/ProxyOperationEnvironment.hpp b/src/Operation/ProxyOperationEnvironment.hpp index 5847b2442cd..93c2cb50af7 100644 --- a/src/Operation/ProxyOperationEnvironment.hpp +++ b/src/Operation/ProxyOperationEnvironment.hpp @@ -21,8 +21,8 @@ class ProxyOperationEnvironment : public OperationEnvironment { bool IsCancelled() const noexcept override; void SetCancelHandler(std::function handler) noexcept override; void Sleep(std::chrono::steady_clock::duration duration) noexcept override; - void SetErrorMessage(const TCHAR *text) noexcept override; - void SetText(const TCHAR *text) noexcept override; + void SetErrorMessage(const char *text) noexcept override; + void SetText(const char *text) noexcept override; void SetProgressRange(unsigned range) noexcept override; void SetProgressPosition(unsigned position) noexcept override; }; diff --git a/src/Operation/ThreadedOperationEnvironment.cpp b/src/Operation/ThreadedOperationEnvironment.cpp index 61403d79dfa..852034e8ffd 100644 --- a/src/Operation/ThreadedOperationEnvironment.cpp +++ b/src/Operation/ThreadedOperationEnvironment.cpp @@ -48,7 +48,7 @@ ThreadedOperationEnvironment::Sleep(std::chrono::steady_clock::duration duration } void -ThreadedOperationEnvironment::SetErrorMessage(const TCHAR *_error) noexcept +ThreadedOperationEnvironment::SetErrorMessage(const char *_error) noexcept { { const std::lock_guard lock{mutex}; @@ -59,7 +59,7 @@ ThreadedOperationEnvironment::SetErrorMessage(const TCHAR *_error) noexcept } void -ThreadedOperationEnvironment::SetText(const TCHAR *_text) noexcept +ThreadedOperationEnvironment::SetText(const char *_text) noexcept { { const std::lock_guard lock{mutex}; diff --git a/src/Operation/ThreadedOperationEnvironment.hpp b/src/Operation/ThreadedOperationEnvironment.hpp index c2564d5c501..a949f917147 100644 --- a/src/Operation/ThreadedOperationEnvironment.hpp +++ b/src/Operation/ThreadedOperationEnvironment.hpp @@ -32,12 +32,12 @@ class ThreadedOperationEnvironment update_error(false), update_text(false), update_progress_range(false), update_progress_position(false) {} - void SetErrorMessage(const TCHAR *_error) noexcept { + void SetErrorMessage(const char *_error) noexcept { error = _error; update_error = true; } - void SetText(const TCHAR *_text) noexcept { + void SetText(const char *_text) noexcept { text = _text; update_text = true; } @@ -114,8 +114,8 @@ class ThreadedOperationEnvironment bool IsCancelled() const noexcept override; void SetCancelHandler(std::function handler) noexcept override; void Sleep(std::chrono::steady_clock::duration duration) noexcept override; - void SetErrorMessage(const TCHAR *error) noexcept override; - void SetText(const TCHAR *text) noexcept override; + void SetErrorMessage(const char *error) noexcept override; + void SetText(const char *text) noexcept override; void SetProgressRange(unsigned range) noexcept override; void SetProgressPosition(unsigned position) noexcept override; diff --git a/src/Operation/VerboseOperationEnvironment.cpp b/src/Operation/VerboseOperationEnvironment.cpp index 408129256cc..333cc1b1ac1 100644 --- a/src/Operation/VerboseOperationEnvironment.cpp +++ b/src/Operation/VerboseOperationEnvironment.cpp @@ -5,7 +5,7 @@ #include "ProgressGlue.hpp" void -VerboseOperationEnvironment::SetText(const TCHAR *text) noexcept +VerboseOperationEnvironment::SetText(const char *text) noexcept { ProgressGlue::Create(text); } diff --git a/src/Operation/VerboseOperationEnvironment.hpp b/src/Operation/VerboseOperationEnvironment.hpp index fc24e03d33a..7321dedd440 100644 --- a/src/Operation/VerboseOperationEnvironment.hpp +++ b/src/Operation/VerboseOperationEnvironment.hpp @@ -15,7 +15,7 @@ class VerboseOperationEnvironment : public MessageOperationEnvironment { void Hide() noexcept; /* virtual methods from class OperationEnvironment */ - void SetText(const TCHAR *text) noexcept override; + void SetText(const char *text) noexcept override; void SetProgressRange(unsigned range) noexcept override; void SetProgressPosition(unsigned position) noexcept override; }; diff --git a/src/PageSettings.cpp b/src/PageSettings.cpp index c538807a362..68ebc7e9a60 100644 --- a/src/PageSettings.cpp +++ b/src/PageSettings.cpp @@ -8,9 +8,9 @@ #include -const TCHAR * +const char * PageLayout::MakeTitle(const InfoBoxSettings &info_box_settings, - std::span buffer, + std::span buffer, const bool concise) const noexcept { if (!valid) @@ -33,7 +33,7 @@ PageLayout::MakeTitle(const InfoBoxSettings &info_box_settings, gcc_unreachable(); } - BasicStringBuilder builder{buffer}; + BasicStringBuilder builder{buffer}; try { if (infobox_config.enabled) { @@ -74,7 +74,7 @@ PageLayout::MakeTitle(const InfoBoxSettings &info_box_settings, case Bottom::MAX: gcc_unreachable(); } - } catch (BasicStringBuilder::Overflow) { + } catch (BasicStringBuilder::Overflow) { } return buffer.data(); diff --git a/src/PageSettings.hpp b/src/PageSettings.hpp index 3f5b3516655..c6a56bd6614 100644 --- a/src/PageSettings.hpp +++ b/src/PageSettings.hpp @@ -134,8 +134,8 @@ struct PageLayout } [[nodiscard]] - const TCHAR *MakeTitle(const InfoBoxSettings &info_box_settings, - std::span buffer, + const char *MakeTitle(const InfoBoxSettings &info_box_settings, + std::span buffer, const bool concise=false) const noexcept; constexpr bool operator==(const PageLayout &other) const noexcept = default; diff --git a/src/Polar/PolarStore.hpp b/src/Polar/PolarStore.hpp index 254daa44382..ea9e5fc4ec7 100644 --- a/src/Polar/PolarStore.hpp +++ b/src/Polar/PolarStore.hpp @@ -14,7 +14,7 @@ namespace PolarStore { struct Item { /**< Name of the glider type */ - const TCHAR *name; + const char *name; // Using doubles here to simplify the code in PolarStore.cpp diff --git a/src/PopupMessage.cpp b/src/PopupMessage.cpp index cbeb6119cbb..62749d4f38f 100644 --- a/src/PopupMessage.cpp +++ b/src/PopupMessage.cpp @@ -19,7 +19,7 @@ using std::max; void PopupMessage::Message::Set(Type _type, std::chrono::steady_clock::duration _tshow, - const TCHAR *_text, + const char *_text, std::chrono::steady_clock::time_point now) noexcept { type = _type; @@ -240,7 +240,7 @@ PopupMessage::GetEmptySlot() noexcept void PopupMessage::AddMessage(std::chrono::steady_clock::duration tshow, Type type, - const TCHAR *Text) noexcept + const char *Text) noexcept { const auto now = std::chrono::steady_clock::now(); @@ -306,7 +306,7 @@ PopupMessage::Acknowledge(Type type) noexcept // TODO code: (need to discuss) Consider moving almost all this functionality into AddMessage ? void -PopupMessage::AddMessage(const TCHAR* text, const TCHAR *data) noexcept +PopupMessage::AddMessage(const char* text, const char *data) noexcept { const std::lock_guard lock{mutex}; @@ -317,7 +317,7 @@ PopupMessage::AddMessage(const TCHAR* text, const TCHAR *data) noexcept // TODO code: consider what is a sensible size? if (msg.visible) { - TCHAR msgcache[1024]; + char msgcache[1024]; strcpy(msgcache, text); if (data != nullptr) { strcat(msgcache, _T(" ")); diff --git a/src/PopupMessage.hpp b/src/PopupMessage.hpp index 9d8dd0305de..0a84945956e 100644 --- a/src/PopupMessage.hpp +++ b/src/PopupMessage.hpp @@ -71,7 +71,7 @@ class PopupMessage : public PaintWindow } void Set(Type type, std::chrono::steady_clock::duration tshow, - const TCHAR *text, + const char *text, std::chrono::steady_clock::time_point now) noexcept; /** @@ -117,10 +117,10 @@ class PopupMessage : public PaintWindow protected: /** Caller must hold the lock. */ void AddMessage(std::chrono::steady_clock::duration tshow, Type type, - const TCHAR *Text) noexcept; + const char *Text) noexcept; public: - void AddMessage(const TCHAR* text, const TCHAR *data=nullptr) noexcept; + void AddMessage(const char* text, const char *data=nullptr) noexcept; /** * Repeats last non-visible message of specified type diff --git a/src/Profile/DeviceConfig.cpp b/src/Profile/DeviceConfig.cpp index eab528e3912..ce0448dab69 100644 --- a/src/Profile/DeviceConfig.cpp +++ b/src/Profile/DeviceConfig.cpp @@ -89,7 +89,7 @@ LoadPath(const ProfileMap &map, DeviceConfig &config, unsigned n) bool retvalue = map.Get(buffer, config.path); // the usual windows port names has no colon at the end if (retvalue && !config.path.empty()) { - if ((config.path.back() == TCHAR(':')) && + if ((config.path.back() == char(':')) && /* In Windows the value itself should be only have the short */ config.path.StartsWith(_T("COM"))) { /* old-style raw names has a trailing colon (for backwards diff --git a/src/Profile/Map.hpp b/src/Profile/Map.hpp index 00640a6117f..b458bcf1e4d 100644 --- a/src/Profile/Map.hpp +++ b/src/Profile/Map.hpp @@ -87,7 +87,7 @@ class ProfileMap { void Set(std::string_view key, const char *value) noexcept; - // TCHAR string values + // char string values /** * Reads a value from the profile map @@ -95,11 +95,11 @@ class ProfileMap { * @param key name of the value that should be read * @param value Pointer to the output buffer */ - bool Get(std::string_view key, std::span value) const noexcept; + bool Get(std::string_view key, std::span value) const noexcept; template bool Get(std::string_view key, - BasicStringBuffer &value) const noexcept { + BasicStringBuffer &value) const noexcept { return Get(key, std::span{value.data(), value.capacity()}); } @@ -174,7 +174,7 @@ class ProfileMap { * Gets a path from the profile and return its base name only. */ [[gnu::pure]] - StringPointer GetPathBase(std::string_view key) const noexcept; + StringPointer GetPathBase(std::string_view key) const noexcept; void SetPath(std::string_view key, Path value) noexcept; diff --git a/src/Profile/PathValue.cpp b/src/Profile/PathValue.cpp index 3daaa3aaf4a..ae093024d91 100644 --- a/src/Profile/PathValue.cpp +++ b/src/Profile/PathValue.cpp @@ -14,7 +14,7 @@ AllocatedPath ProfileMap::GetPath(std::string_view key) const noexcept { - TCHAR buffer[MAX_PATH]; + char buffer[MAX_PATH]; if (!Get(key, std::span{buffer})) return nullptr; @@ -36,7 +36,7 @@ ProfileMap::GetPathIsEqual(std::string_view key, Path value) const noexcept [[gnu::pure]] static Path -BackslashBaseName(const TCHAR *p) noexcept +BackslashBaseName(const char *p) noexcept { if (DIR_SEPARATOR != '\\') { const auto *backslash = StringFindLast(p, _T('\\')); @@ -47,7 +47,7 @@ BackslashBaseName(const TCHAR *p) noexcept return Path(p).GetBase(); } -StringPointer +StringPointer ProfileMap::GetPathBase(std::string_view key) const noexcept { const auto *path = Get(key); diff --git a/src/Profile/ProfileMap.cpp b/src/Profile/ProfileMap.cpp index 5562b545a5e..e49f4077e99 100644 --- a/src/Profile/ProfileMap.cpp +++ b/src/Profile/ProfileMap.cpp @@ -24,7 +24,7 @@ Profile::Get(std::string_view key, const char *default_value) noexcept } bool -Profile::Get(std::string_view key, std::span value) noexcept +Profile::Get(std::string_view key, std::span value) noexcept { return map.Get(key, value); } diff --git a/src/Profile/ProfileMap.hpp b/src/Profile/ProfileMap.hpp index ed009ff9510..0ec6114f804 100644 --- a/src/Profile/ProfileMap.hpp +++ b/src/Profile/ProfileMap.hpp @@ -49,7 +49,7 @@ Get(std::string_view key, const char *default_value=nullptr) noexcept; * @param max_size Maximum size of the output buffer */ bool -Get(std::string_view key, std::span value) noexcept; +Get(std::string_view key, std::span value) noexcept; /** * Writes a value to the profile map @@ -125,7 +125,7 @@ SetEnum(std::string_view key, T value) noexcept template static inline bool -Get(std::string_view key, BasicStringBuffer &value) noexcept +Get(std::string_view key, BasicStringBuffer &value) noexcept { return Get(key, std::span{value.data(), value.capacity()}); } diff --git a/src/Profile/StringValue.cpp b/src/Profile/StringValue.cpp index 37c57b7043b..355282c790c 100644 --- a/src/Profile/StringValue.cpp +++ b/src/Profile/StringValue.cpp @@ -7,7 +7,7 @@ #include "util/Macros.hpp" bool -ProfileMap::Get(std::string_view key, std::span value) const noexcept +ProfileMap::Get(std::string_view key, std::span value) const noexcept { const char *src = Get(key); if (src == nullptr) { diff --git a/src/ProgressGlue.cpp b/src/ProgressGlue.cpp index c413e709da0..73216ef8b2b 100644 --- a/src/ProgressGlue.cpp +++ b/src/ProgressGlue.cpp @@ -15,7 +15,7 @@ static ProgressWindow *global_progress_window; static PeriodClock throttle_clock; void -ProgressGlue::Create(const TCHAR *text) noexcept +ProgressGlue::Create(const char *text) noexcept { UIGlobals::GetMainWindow().RefreshSize(); diff --git a/src/ProgressGlue.hpp b/src/ProgressGlue.hpp index debaf15953d..1c293e655dd 100644 --- a/src/ProgressGlue.hpp +++ b/src/ProgressGlue.hpp @@ -13,7 +13,7 @@ namespace ProgressGlue { * Creates or updates the ProgressWindow * @param text the text inside the progress bar */ -void Create(const TCHAR *text) noexcept; +void Create(const char *text) noexcept; void Move(const PixelRect &rc) noexcept; diff --git a/src/ProgressWindow.cpp b/src/ProgressWindow.cpp index e5bca666ff9..91b27929076 100644 --- a/src/ProgressWindow.cpp +++ b/src/ProgressWindow.cpp @@ -76,7 +76,7 @@ ProgressWindow::UpdateLayout(PixelRect rc) noexcept } void -ProgressWindow::SetMessage(const TCHAR *text) noexcept +ProgressWindow::SetMessage(const char *text) noexcept { AssertThread(); diff --git a/src/ProgressWindow.hpp b/src/ProgressWindow.hpp index 0588adccbd6..6fc30da1b5f 100644 --- a/src/ProgressWindow.hpp +++ b/src/ProgressWindow.hpp @@ -36,7 +36,7 @@ class ProgressWindow : public ContainerWindow { public: explicit ProgressWindow(ContainerWindow &parent) noexcept; - void SetMessage(const TCHAR *text) noexcept; + void SetMessage(const char *text) noexcept; void SetRange(unsigned min_value, unsigned max_value) noexcept; void SetStep(unsigned size) noexcept; diff --git a/src/RadioFrequency.cpp b/src/RadioFrequency.cpp index 2c7536a3384..aff4c9312df 100644 --- a/src/RadioFrequency.cpp +++ b/src/RadioFrequency.cpp @@ -10,8 +10,8 @@ using std::string_view_literals::operator""sv; -TCHAR * -RadioFrequency::Format(TCHAR *buffer, size_t max_size) const noexcept +char * +RadioFrequency::Format(char *buffer, size_t max_size) const noexcept { if (!IsDefined()) return nullptr; diff --git a/src/RadioFrequency.hpp b/src/RadioFrequency.hpp index 141b833829e..8f7f470db63 100644 --- a/src/RadioFrequency.hpp +++ b/src/RadioFrequency.hpp @@ -104,7 +104,7 @@ class RadioFrequency { SetKiloHertz(new_khz); } - TCHAR *Format(TCHAR *buffer, size_t max_size) const noexcept; + char *Format(char *buffer, size_t max_size) const noexcept; [[gnu::pure]] static RadioFrequency Parse(std::string_view src) noexcept; diff --git a/src/Renderer/AirspaceLabelRenderer.cpp b/src/Renderer/AirspaceLabelRenderer.cpp index 8380a4d5c79..2b738bcf439 100644 --- a/src/Renderer/AirspaceLabelRenderer.cpp +++ b/src/Renderer/AirspaceLabelRenderer.cpp @@ -93,11 +93,11 @@ AirspaceLabelRenderer::DrawLabel(Canvas &canvas, const WindowProjection &projection, const AirspaceLabelList::Label &label) noexcept { - TCHAR topText[NAME_SIZE + 1]; + char topText[NAME_SIZE + 1]; AirspaceFormatter::FormatAltitudeShort(topText, label.top, false); const PixelSize topSize = canvas.CalcTextSize(topText); - TCHAR baseText[NAME_SIZE + 1]; + char baseText[NAME_SIZE + 1]; AirspaceFormatter::FormatAltitudeShort(baseText, label.base, false); const PixelSize baseSize = canvas.CalcTextSize(baseText); diff --git a/src/Renderer/AirspaceListRenderer.cpp b/src/Renderer/AirspaceListRenderer.cpp index 3a116d935a7..aabd9667a65 100644 --- a/src/Renderer/AirspaceListRenderer.cpp +++ b/src/Renderer/AirspaceListRenderer.cpp @@ -16,7 +16,7 @@ static void Draw(Canvas &canvas, PixelRect rc, const AbstractAirspace &airspace, - const TCHAR *comment, + const char *comment, const TwoTextRowsRenderer &row_renderer, const AirspaceLook &look, const AirspaceRendererSettings &renderer_settings) @@ -33,7 +33,7 @@ Draw(Canvas &canvas, PixelRect rc, rc.left += line_height + padding; // Draw upper airspace altitude limit - TCHAR buffer[40]; + char buffer[40]; AirspaceFormatter::FormatAltitudeShort(buffer, airspace.GetTop()); const int top_x = row_renderer.DrawRightFirstRow(canvas, rc, buffer); diff --git a/src/Renderer/BarographRenderer.cpp b/src/Renderer/BarographRenderer.cpp index e8e0c52474b..12e36a7068b 100644 --- a/src/Renderer/BarographRenderer.cpp +++ b/src/Renderer/BarographRenderer.cpp @@ -17,7 +17,7 @@ #include "GradientRenderer.hpp" void -BarographCaption(TCHAR *sTmp, const FlightStatistics &fs) +BarographCaption(char *sTmp, const FlightStatistics &fs) { const std::lock_guard lock{fs.mutex}; if (!fs.altitude_ceiling.HasResult() || fs.altitude_base.IsEmpty()) { diff --git a/src/Renderer/BarographRenderer.hpp b/src/Renderer/BarographRenderer.hpp index a2d85f1c06f..5deed9d7e48 100644 --- a/src/Renderer/BarographRenderer.hpp +++ b/src/Renderer/BarographRenderer.hpp @@ -16,7 +16,7 @@ class ProtectedTaskManager; class TaskManager; void -BarographCaption(TCHAR *buffer, const FlightStatistics &fs); +BarographCaption(char *buffer, const FlightStatistics &fs); void RenderBarographSpark(Canvas &canvas, const PixelRect rc, diff --git a/src/Renderer/ChartRenderer.cpp b/src/Renderer/ChartRenderer.cpp index 3416b2378a0..fd330cfbb26 100644 --- a/src/Renderer/ChartRenderer.cpp +++ b/src/Renderer/ChartRenderer.cpp @@ -29,27 +29,27 @@ ChartRenderer::ChartRenderer(const ChartLook &_look, Canvas &the_canvas, } void -ChartRenderer::SetXLabel(const TCHAR *text) noexcept +ChartRenderer::SetXLabel(const char *text) noexcept { CopyTruncateString(x_label.data(), x_label.capacity(), text); } void -ChartRenderer::SetXLabel(const TCHAR *text, const TCHAR *unit) noexcept +ChartRenderer::SetXLabel(const char *text, const char *unit) noexcept { StringFormat(x_label.data(), x_label.capacity(), _T("%s [%s]"), text, unit); } void -ChartRenderer::SetYLabel(const TCHAR *text, const TCHAR *unit) noexcept +ChartRenderer::SetYLabel(const char *text, const char *unit) noexcept { StringFormat(y_label.data(), y_label.capacity(), _T("%s [%s]"), text, unit); } void -ChartRenderer::SetYLabel(const TCHAR *text) noexcept +ChartRenderer::SetYLabel(const char *text) noexcept { CopyTruncateString(y_label.data(), y_label.capacity(), text); } @@ -193,7 +193,7 @@ ChartRenderer::ScaleXFromValue(const double value) noexcept } void -ChartRenderer::DrawLabel(DoublePoint2D v, const TCHAR *text) noexcept +ChartRenderer::DrawLabel(DoublePoint2D v, const char *text) noexcept { canvas.Select(look.label_font); canvas.SetBackgroundTransparent(); @@ -214,7 +214,7 @@ ChartRenderer::DrawLabel(DoublePoint2D v, const TCHAR *text) noexcept } void -ChartRenderer::DrawNoData(const TCHAR *text) noexcept +ChartRenderer::DrawNoData(const char *text) noexcept { canvas.Select(look.label_font); canvas.SetBackgroundTransparent(); @@ -437,11 +437,11 @@ ChartRenderer::DrawLineGraph(const XYDataStore &lsdata, DrawLineGraph(lsdata, look.GetPen(style), swap); } -BasicStringBuffer +BasicStringBuffer ChartRenderer::FormatTicText(const double val, const double step, UnitFormat units) noexcept { - BasicStringBuffer buffer; + BasicStringBuffer buffer; if (units == UnitFormat::TIME) { const unsigned total_minutes(val * 60); diff --git a/src/Renderer/ChartRenderer.hpp b/src/Renderer/ChartRenderer.hpp index 19a988566c6..614934b93f2 100644 --- a/src/Renderer/ChartRenderer.hpp +++ b/src/Renderer/ChartRenderer.hpp @@ -33,7 +33,7 @@ class ChartRenderer PixelRect rc; PixelRect rc_chart; - BasicStringBuffer x_label, y_label; + BasicStringBuffer x_label, y_label; ReusableArray point_buffer; @@ -62,11 +62,11 @@ class ChartRenderer const PixelRect &the_rc, const bool has_padding=true) noexcept; - void SetXLabel(const TCHAR *text) noexcept; - void SetXLabel(const TCHAR *text, const TCHAR *unit) noexcept; + void SetXLabel(const char *text) noexcept; + void SetXLabel(const char *text, const char *unit) noexcept; - void SetYLabel(const TCHAR *text) noexcept; - void SetYLabel(const TCHAR *text, const TCHAR *unit) noexcept; + void SetYLabel(const char *text) noexcept; + void SetYLabel(const char *text, const char *unit) noexcept; /** * Prepare for drawing; this method calculates the layout. Call @@ -117,7 +117,7 @@ class ChartRenderer void ScaleXFromValue(double val) noexcept; [[gnu::pure]] - static BasicStringBuffer FormatTicText(double val, double step, + static BasicStringBuffer FormatTicText(double val, double step, UnitFormat units) noexcept; void DrawXGrid(double tic_step, double unit_step, @@ -125,8 +125,8 @@ class ChartRenderer void DrawYGrid(double tic_step, double unit_step, UnitFormat units = UnitFormat::NONE) noexcept; - void DrawLabel(DoublePoint2D v, const TCHAR *text) noexcept; - void DrawNoData(const TCHAR *text) noexcept; + void DrawLabel(DoublePoint2D v, const char *text) noexcept; + void DrawNoData(const char *text) noexcept; void DrawNoData() noexcept; void DrawBlankRectangle(DoublePoint2D min, DoublePoint2D max) noexcept; diff --git a/src/Renderer/ClimbChartRenderer.cpp b/src/Renderer/ClimbChartRenderer.cpp index 666797d701c..05a0f1958d3 100644 --- a/src/Renderer/ClimbChartRenderer.cpp +++ b/src/Renderer/ClimbChartRenderer.cpp @@ -16,7 +16,7 @@ #include "GradientRenderer.hpp" void -ClimbChartCaption(TCHAR *sTmp, +ClimbChartCaption(char *sTmp, const FlightStatistics &fs) { const std::lock_guard lock{fs.mutex}; diff --git a/src/Renderer/ClimbChartRenderer.hpp b/src/Renderer/ClimbChartRenderer.hpp index 3a1d10a9dad..e542fe2926e 100644 --- a/src/Renderer/ClimbChartRenderer.hpp +++ b/src/Renderer/ClimbChartRenderer.hpp @@ -15,7 +15,7 @@ struct DerivedInfo; class TaskManager; void -ClimbChartCaption(TCHAR *buffer, +ClimbChartCaption(char *buffer, const FlightStatistics &fs); void diff --git a/src/Renderer/CuRenderer.cpp b/src/Renderer/CuRenderer.cpp index 0a317ac346b..ad921aaaf69 100644 --- a/src/Renderer/CuRenderer.cpp +++ b/src/Renderer/CuRenderer.cpp @@ -121,7 +121,7 @@ RenderTemperatureChart(Canvas &canvas, const PixelRect rc, } void -TemperatureChartCaption(TCHAR *sTmp, const CuSonde &cu_sonde) +TemperatureChartCaption(char *sTmp, const CuSonde &cu_sonde) { StringFormatUnsafe(sTmp, _T("%s:\r\n %5.0f %s\r\n\r\n%s:\r\n %5.0f %s\r\n"), _("Thermal height"), diff --git a/src/Renderer/CuRenderer.hpp b/src/Renderer/CuRenderer.hpp index 066410447a9..a9c7213f4ee 100644 --- a/src/Renderer/CuRenderer.hpp +++ b/src/Renderer/CuRenderer.hpp @@ -16,4 +16,4 @@ RenderTemperatureChart(Canvas &canvas, const PixelRect rc, const CuSonde &cu_sonde); void -TemperatureChartCaption(TCHAR *buffer, const CuSonde &cu_sonde); +TemperatureChartCaption(char *buffer, const CuSonde &cu_sonde); diff --git a/src/Renderer/FinalGlideBarRenderer.cpp b/src/Renderer/FinalGlideBarRenderer.cpp index 47fd1954b21..5693fc34e20 100644 --- a/src/Renderer/FinalGlideBarRenderer.cpp +++ b/src/Renderer/FinalGlideBarRenderer.cpp @@ -37,7 +37,7 @@ FinalGlideBarRenderer::Draw(Canvas &canvas, const PixelRect &rc, { 0, 0 }, { 9, 9 }, { 9, 15 }, { 0, 6 } }; - TCHAR Value[10]; + char Value[10]; const TaskStats &task_stats = calculated.task_stats; const ElementStat &total = task_stats.total; diff --git a/src/Renderer/FlightListRenderer.cpp b/src/Renderer/FlightListRenderer.cpp index 3a8a7ff0486..9a3304a96cf 100644 --- a/src/Renderer/FlightListRenderer.cpp +++ b/src/Renderer/FlightListRenderer.cpp @@ -21,7 +21,7 @@ FlightListRenderer::Draw(Canvas &canvas, PixelRect rc) if (flights.empty()) { auto center = rc.GetCenter(); - const TCHAR *text = _T("No flights"); + const char *text = _T("No flights"); PixelSize size = canvas.CalcTextSize(text); canvas.DrawText(center - size / 2u, text); return; diff --git a/src/Renderer/FlightStatisticsRenderer.cpp b/src/Renderer/FlightStatisticsRenderer.cpp index 43b1cda8b2e..bc70d6102b4 100644 --- a/src/Renderer/FlightStatisticsRenderer.cpp +++ b/src/Renderer/FlightStatisticsRenderer.cpp @@ -187,7 +187,7 @@ FlightStatisticsRenderer::RenderContest(Canvas &canvas, const PixelRect rc, } void -FlightStatisticsRenderer::CaptionContest(TCHAR *sTmp, +FlightStatisticsRenderer::CaptionContest(char *sTmp, const ContestSettings &settings, const DerivedInfo &derived) noexcept { @@ -336,7 +336,7 @@ FlightStatisticsRenderer::RenderTask(Canvas &canvas, const PixelRect rc, } void -FlightStatisticsRenderer::CaptionTask(TCHAR *sTmp, const DerivedInfo &derived) noexcept +FlightStatisticsRenderer::CaptionTask(char *sTmp, const DerivedInfo &derived) noexcept { const TaskStats &task_stats = derived.ordered_task_stats; const CommonStats &common = derived.common_stats; diff --git a/src/Renderer/FlightStatisticsRenderer.hpp b/src/Renderer/FlightStatisticsRenderer.hpp index ca7a67f20a5..79e7f4caa4c 100644 --- a/src/Renderer/FlightStatisticsRenderer.hpp +++ b/src/Renderer/FlightStatisticsRenderer.hpp @@ -62,8 +62,8 @@ class FlightStatisticsRenderer { const ProtectedTaskManager &task, const TraceComputer *trace_computer) noexcept; - static void CaptionTask(TCHAR *sTmp, const DerivedInfo &derived) noexcept; - static void CaptionContest(TCHAR *sTmp, const ContestSettings &settings, + static void CaptionTask(char *sTmp, const DerivedInfo &derived) noexcept; + static void CaptionContest(char *sTmp, const ContestSettings &settings, const DerivedInfo &derived) noexcept; private: diff --git a/src/Renderer/GlidePolarRenderer.cpp b/src/Renderer/GlidePolarRenderer.cpp index e2dabc38251..3d3fad7e89b 100644 --- a/src/Renderer/GlidePolarRenderer.cpp +++ b/src/Renderer/GlidePolarRenderer.cpp @@ -16,7 +16,7 @@ #include void -GlidePolarCaption(TCHAR *sTmp, const GlidePolar &glide_polar) +GlidePolarCaption(char *sTmp, const GlidePolar &glide_polar) { if (!glide_polar.IsValid()) { *sTmp = _T('\0'); diff --git a/src/Renderer/GlidePolarRenderer.hpp b/src/Renderer/GlidePolarRenderer.hpp index 8ae3188640d..5978700b2bb 100644 --- a/src/Renderer/GlidePolarRenderer.hpp +++ b/src/Renderer/GlidePolarRenderer.hpp @@ -12,7 +12,7 @@ class ClimbHistory; class GlidePolar; void -GlidePolarCaption(TCHAR *buffer, const GlidePolar &glide_polar); +GlidePolarCaption(char *buffer, const GlidePolar &glide_polar); void RenderGlidePolar(Canvas &canvas, const PixelRect rc, diff --git a/src/Renderer/MacCreadyRenderer.cpp b/src/Renderer/MacCreadyRenderer.cpp index 2257e94db88..d00a052c9a8 100644 --- a/src/Renderer/MacCreadyRenderer.cpp +++ b/src/Renderer/MacCreadyRenderer.cpp @@ -16,7 +16,7 @@ static constexpr double MAX_MACCREADY = 5.2; static constexpr unsigned STEPS_MACCREADY = 25; void -MacCreadyCaption(TCHAR *sTmp, const GlidePolar &glide_polar) +MacCreadyCaption(char *sTmp, const GlidePolar &glide_polar) { if (!glide_polar.IsValid()) { *sTmp = _T('\0'); diff --git a/src/Renderer/MacCreadyRenderer.hpp b/src/Renderer/MacCreadyRenderer.hpp index f24f5ffe8ef..162cd50bc3c 100644 --- a/src/Renderer/MacCreadyRenderer.hpp +++ b/src/Renderer/MacCreadyRenderer.hpp @@ -11,7 +11,7 @@ struct ChartLook; class GlidePolar; void -MacCreadyCaption(TCHAR *sTmp, const GlidePolar &glide_polar); +MacCreadyCaption(char *sTmp, const GlidePolar &glide_polar); void RenderMacCready(Canvas &canvas, const PixelRect rc, diff --git a/src/Renderer/MapItemListRenderer.cpp b/src/Renderer/MapItemListRenderer.cpp index 4e10f26c142..f2934dcf714 100644 --- a/src/Renderer/MapItemListRenderer.cpp +++ b/src/Renderer/MapItemListRenderer.cpp @@ -53,7 +53,7 @@ Draw(Canvas &canvas, const PixelRect rc, const LocationMapItem &item, const TwoTextRowsRenderer &row_renderer) { - TCHAR info_buffer[256]; + char info_buffer[256]; if (item.vector.IsValid()) StringFormatUnsafe(info_buffer, _T("%s: %s, %s: %s"), _("Distance"), @@ -120,7 +120,7 @@ Draw(Canvas &canvas, PixelRect rc, // Format title row - TCHAR altitude_buffer[32]; + char altitude_buffer[32]; StaticString<256> buffer; buffer.clear(); @@ -283,7 +283,7 @@ Draw(Canvas &canvas, PixelRect rc, rc.left += line_height + text_padding; - TCHAR buffer[256]; + char buffer[256]; // Draw details line OrderedTaskPointRadiusLabel(*item.oz, buffer); @@ -330,7 +330,7 @@ Draw(Canvas &canvas, PixelRect rc, title_string = _("FLARM Traffic"); // Append name to the title, if it exists - const TCHAR *callsign = FlarmDetails::LookupCallsign(item.id); + const char *callsign = FlarmDetails::LookupCallsign(item.id); if (callsign != nullptr && !StringIsEmpty(callsign)) { title_string.append(_T(", ")); title_string.append(callsign); diff --git a/src/Renderer/NOAAListRenderer.cpp b/src/Renderer/NOAAListRenderer.cpp index efc53e44667..48541378096 100644 --- a/src/Renderer/NOAAListRenderer.cpp +++ b/src/Renderer/NOAAListRenderer.cpp @@ -21,7 +21,7 @@ NOAAListRenderer::Draw(Canvas &canvas, const PixelRect rc, row_renderer.DrawFirstRow(canvas, rc, title); - const TCHAR *tmp; + const char *tmp; if (!station.metar_available) tmp = _("No METAR available"); else diff --git a/src/Renderer/TabRenderer.cpp b/src/Renderer/TabRenderer.cpp index d0d4c992a2e..0171e481c6b 100644 --- a/src/Renderer/TabRenderer.cpp +++ b/src/Renderer/TabRenderer.cpp @@ -9,7 +9,7 @@ void TabRenderer::Draw(Canvas &canvas, const PixelRect &rc, const DialogLook &look, - const TCHAR *caption, const MaskedIcon *icon, + const char *caption, const MaskedIcon *icon, bool focused, bool pressed, bool selected) const noexcept { canvas.DrawFilledRectangle(rc, diff --git a/src/Renderer/TabRenderer.hpp b/src/Renderer/TabRenderer.hpp index 26c04aed64f..a3a66d1dc2b 100644 --- a/src/Renderer/TabRenderer.hpp +++ b/src/Renderer/TabRenderer.hpp @@ -31,6 +31,6 @@ class TabRenderer { void Draw(Canvas &canvas, const PixelRect &rc, const DialogLook &look, - const TCHAR *caption, const MaskedIcon *icon, + const char *caption, const MaskedIcon *icon, bool focused, bool pressed, bool selected) const noexcept; }; diff --git a/src/Renderer/TaskLegRenderer.cpp b/src/Renderer/TaskLegRenderer.cpp index 1fb300e2510..dee87b99612 100644 --- a/src/Renderer/TaskLegRenderer.cpp +++ b/src/Renderer/TaskLegRenderer.cpp @@ -43,7 +43,7 @@ RenderTaskLegs(ChartRenderer &chart, if (!task_stats.start.HasStarted()) return; - TCHAR sTmp[5]; + char sTmp[5]; const OrderedTask &task = task_manager.GetOrderedTask(); for (unsigned i = 0, n = task.TaskSize(); i < n; ++i) { diff --git a/src/Renderer/TaskSpeedRenderer.cpp b/src/Renderer/TaskSpeedRenderer.cpp index df7a3d4d0fc..0a267e6aa85 100644 --- a/src/Renderer/TaskSpeedRenderer.cpp +++ b/src/Renderer/TaskSpeedRenderer.cpp @@ -15,7 +15,7 @@ #include "Engine/GlideSolvers/GlidePolar.hpp" void -TaskSpeedCaption(TCHAR *sTmp, +TaskSpeedCaption(char *sTmp, const FlightStatistics &fs, const GlidePolar &glide_polar) { diff --git a/src/Renderer/TaskSpeedRenderer.hpp b/src/Renderer/TaskSpeedRenderer.hpp index 57e915c5e60..19cc704778d 100644 --- a/src/Renderer/TaskSpeedRenderer.hpp +++ b/src/Renderer/TaskSpeedRenderer.hpp @@ -15,7 +15,7 @@ class GlidePolar; #include void -TaskSpeedCaption(TCHAR *sTmp, +TaskSpeedCaption(char *sTmp, const FlightStatistics &fs, const GlidePolar &glide_polar); diff --git a/src/Renderer/TextInBox.cpp b/src/Renderer/TextInBox.cpp index d42c1325bde..6eb4878ed16 100644 --- a/src/Renderer/TextInBox.cpp +++ b/src/Renderer/TextInBox.cpp @@ -52,7 +52,7 @@ TextInBoxMoveInView(PixelRect &rc, const PixelRect &map_rc) noexcept } static void -RenderShadowedText(Canvas &canvas, const TCHAR *text, +RenderShadowedText(Canvas &canvas, const char *text, PixelPoint p, bool inverted) noexcept { @@ -71,7 +71,7 @@ RenderShadowedText(Canvas &canvas, const TCHAR *text, // returns true if really wrote something bool -TextInBox(Canvas &canvas, const TCHAR *text, PixelPoint p, +TextInBox(Canvas &canvas, const char *text, PixelPoint p, TextInBoxMode mode, const PixelRect &map_rc, LabelBlock *label_block) noexcept { @@ -144,7 +144,7 @@ TextInBox(Canvas &canvas, const TCHAR *text, PixelPoint p, } bool -TextInBox(Canvas &canvas, const TCHAR *text, PixelPoint p, +TextInBox(Canvas &canvas, const char *text, PixelPoint p, TextInBoxMode mode, PixelSize screen_size, LabelBlock *label_block) noexcept diff --git a/src/Renderer/TextInBox.hpp b/src/Renderer/TextInBox.hpp index 111df0c1e86..18c05f1a11d 100644 --- a/src/Renderer/TextInBox.hpp +++ b/src/Renderer/TextInBox.hpp @@ -33,12 +33,12 @@ struct TextInBoxMode { }; bool -TextInBox(Canvas &canvas, const TCHAR *value, PixelPoint p, +TextInBox(Canvas &canvas, const char *value, PixelPoint p, TextInBoxMode mode, const PixelRect &map_rc, LabelBlock *label_block=nullptr) noexcept; bool -TextInBox(Canvas &canvas, const TCHAR *value, PixelPoint p, +TextInBox(Canvas &canvas, const char *value, PixelPoint p, TextInBoxMode mode, PixelSize screen_size, LabelBlock *label_block=nullptr) noexcept; diff --git a/src/Renderer/TextRowRenderer.cpp b/src/Renderer/TextRowRenderer.cpp index babb57839dc..1a9081e48d5 100644 --- a/src/Renderer/TextRowRenderer.cpp +++ b/src/Renderer/TextRowRenderer.cpp @@ -24,7 +24,7 @@ TextRowRenderer::CalculateLayout(const Font &font) noexcept void TextRowRenderer::DrawTextRow(Canvas &canvas, const PixelRect &rc, - const TCHAR *text) const noexcept + const char *text) const noexcept { canvas.DrawClippedText(rc.GetTopLeft() + PixelSize{left_padding, top_padding}, rc, text); @@ -32,7 +32,7 @@ TextRowRenderer::DrawTextRow(Canvas &canvas, const PixelRect &rc, int TextRowRenderer::NextColumn(Canvas &canvas, const PixelRect &rc, - const TCHAR *text) const noexcept + const char *text) const noexcept { return std::min(rc.left + int(2 * left_padding + canvas.CalcTextWidth(text)), rc.right); @@ -40,7 +40,7 @@ TextRowRenderer::NextColumn(Canvas &canvas, const PixelRect &rc, int TextRowRenderer::DrawColumn(Canvas &canvas, const PixelRect &rc, - const TCHAR *text) const noexcept + const char *text) const noexcept { DrawTextRow(canvas, rc, text); return NextColumn(canvas, rc, text); @@ -48,7 +48,7 @@ TextRowRenderer::DrawColumn(Canvas &canvas, const PixelRect &rc, int TextRowRenderer::PreviousRightColumn(Canvas &canvas, const PixelRect &rc, - const TCHAR *text) const noexcept + const char *text) const noexcept { int text_width = canvas.CalcTextWidth(text); int x = rc.right - int(left_padding + text_width); @@ -62,7 +62,7 @@ TextRowRenderer::PreviousRightColumn(Canvas &canvas, const PixelRect &rc, int TextRowRenderer::DrawRightColumn(Canvas &canvas, const PixelRect &rc, - const TCHAR *text) const noexcept + const char *text) const noexcept { int text_width = canvas.CalcTextWidth(text); int x = rc.right - int(left_padding + text_width); diff --git a/src/Renderer/TextRowRenderer.hpp b/src/Renderer/TextRowRenderer.hpp index 0f54590d6b1..b034cc1ad7e 100644 --- a/src/Renderer/TextRowRenderer.hpp +++ b/src/Renderer/TextRowRenderer.hpp @@ -22,7 +22,7 @@ class TextRowRenderer { unsigned CalculateLayout(const Font &font) noexcept; void DrawTextRow(Canvas &canvas, const PixelRect &rc, - const TCHAR *text) const noexcept; + const char *text) const noexcept; /** * Returns the minimum X coordinate of the column after the given @@ -30,13 +30,13 @@ class TextRowRenderer { */ [[gnu::pure]] int NextColumn(Canvas &canvas, const PixelRect &rc, - const TCHAR *text) const noexcept; + const char *text) const noexcept; /** * Combine DrawTextRow() and NextColumn(). */ int DrawColumn(Canvas &canvas, const PixelRect &rc, - const TCHAR *text) const noexcept; + const char *text) const noexcept; /** * Returns the maximum X coordinate of the column before the given @@ -44,12 +44,12 @@ class TextRowRenderer { */ [[gnu::pure]] int PreviousRightColumn(Canvas &canvas, const PixelRect &rc, - const TCHAR *text) const noexcept; + const char *text) const noexcept; /** * Draws a right-aligned column and returns the new "right" * coordinate. */ int DrawRightColumn(Canvas &canvas, const PixelRect &rc, - const TCHAR *text) const noexcept; + const char *text) const noexcept; }; diff --git a/src/Renderer/TwoTextRowsRenderer.cpp b/src/Renderer/TwoTextRowsRenderer.cpp index 9f134eb887e..5ab5d21f3c6 100644 --- a/src/Renderer/TwoTextRowsRenderer.cpp +++ b/src/Renderer/TwoTextRowsRenderer.cpp @@ -33,7 +33,7 @@ TwoTextRowsRenderer::CalculateLayout(const Font &_first_font, void TwoTextRowsRenderer::DrawFirstRow(Canvas &canvas, const PixelRect &rc, - const TCHAR *text) const noexcept + const char *text) const noexcept { canvas.Select(*first_font); canvas.DrawClippedText({rc.left + x, rc.top + first_y}, rc, text); @@ -41,7 +41,7 @@ TwoTextRowsRenderer::DrawFirstRow(Canvas &canvas, const PixelRect &rc, void TwoTextRowsRenderer::DrawSecondRow(Canvas &canvas, const PixelRect &rc, - const TCHAR *text) const noexcept + const char *text) const noexcept { canvas.Select(*second_font); canvas.DrawClippedText({rc.left + x, rc.top + second_y}, rc, text); @@ -49,7 +49,7 @@ TwoTextRowsRenderer::DrawSecondRow(Canvas &canvas, const PixelRect &rc, int TwoTextRowsRenderer::DrawRightFirstRow(Canvas &canvas, const PixelRect &rc, - const TCHAR *text) const noexcept + const char *text) const noexcept { canvas.Select(*second_font); int text_width = canvas.CalcTextWidth(text); @@ -65,7 +65,7 @@ TwoTextRowsRenderer::DrawRightFirstRow(Canvas &canvas, const PixelRect &rc, int TwoTextRowsRenderer::DrawRightSecondRow(Canvas &canvas, const PixelRect &rc, - const TCHAR *text) const noexcept + const char *text) const noexcept { canvas.Select(*second_font); int text_width = canvas.CalcTextWidth(text); diff --git a/src/Renderer/TwoTextRowsRenderer.hpp b/src/Renderer/TwoTextRowsRenderer.hpp index ada8a4346cc..b914462510f 100644 --- a/src/Renderer/TwoTextRowsRenderer.hpp +++ b/src/Renderer/TwoTextRowsRenderer.hpp @@ -45,10 +45,10 @@ class TwoTextRowsRenderer { } void DrawFirstRow(Canvas &canvas, const PixelRect &rc, - const TCHAR *text) const noexcept; + const char *text) const noexcept; void DrawSecondRow(Canvas &canvas, const PixelRect &rc, - const TCHAR *text) const noexcept; + const char *text) const noexcept; /** * Draws a right-aligned column in the first row (but with the @@ -56,12 +56,12 @@ class TwoTextRowsRenderer { * coordinate. */ int DrawRightFirstRow(Canvas &canvas, const PixelRect &rc, - const TCHAR *text) const noexcept; + const char *text) const noexcept; /** * Draws a right-aligned column in the second row and returns the * new "right" coordinate. */ int DrawRightSecondRow(Canvas &canvas, const PixelRect &rc, - const TCHAR *text) const noexcept; + const char *text) const noexcept; }; diff --git a/src/Renderer/UnitSymbolRenderer.cpp b/src/Renderer/UnitSymbolRenderer.cpp index cb5f43a415e..0f2be5edcc4 100644 --- a/src/Renderer/UnitSymbolRenderer.cpp +++ b/src/Renderer/UnitSymbolRenderer.cpp @@ -11,8 +11,8 @@ #include struct UnitSymbolStrings { - const TCHAR *line1; - const TCHAR *line2; + const char *line1; + const char *line2; bool is_fraction; }; diff --git a/src/Renderer/VarioBarRenderer.cpp b/src/Renderer/VarioBarRenderer.cpp index 8c829282f80..ee1a8ca414a 100644 --- a/src/Renderer/VarioBarRenderer.cpp +++ b/src/Renderer/VarioBarRenderer.cpp @@ -41,7 +41,7 @@ VarioBarRenderer::Draw(Canvas &canvas, const PixelRect &rc, { 0, 0 }, { 9, -9 }, { 18, 0 }, { 18, -2 }, { 9, -11 }, { 0, -2 } }; - TCHAR Value[10]; + char Value[10]; const int y0 = (rc.bottom + rc.top) / 2; diff --git a/src/Renderer/WaypointLabelList.cpp b/src/Renderer/WaypointLabelList.cpp index 43c50227028..a0929dccb68 100644 --- a/src/Renderer/WaypointLabelList.cpp +++ b/src/Renderer/WaypointLabelList.cpp @@ -46,7 +46,7 @@ MapWaypointLabelListCompare(const WaypointLabelList::Label &e1, } void -WaypointLabelList::Add(const TCHAR *Name, PixelPoint p, +WaypointLabelList::Add(const char *Name, PixelPoint p, TextInBoxMode Mode, bool bold, int AltArivalAGL, bool inTask, bool isLandable, bool isAirport, diff --git a/src/Renderer/WaypointLabelList.hpp b/src/Renderer/WaypointLabelList.hpp index f66f56b4b90..2c840931e4d 100644 --- a/src/Renderer/WaypointLabelList.hpp +++ b/src/Renderer/WaypointLabelList.hpp @@ -17,7 +17,7 @@ class WaypointLabelList : private NonCopyable { public: struct Label{ - TCHAR Name[NAME_SIZE+1]; + char Name[NAME_SIZE+1]; PixelPoint Pos; TextInBoxMode Mode; int AltArivalAGL; @@ -41,7 +41,7 @@ class WaypointLabelList : private NonCopyable { clip_rect.right += WPCIRCLESIZE * 2; } - void Add(const TCHAR *name, PixelPoint p, + void Add(const char *name, PixelPoint p, TextInBoxMode Mode, bool bold, int AltArivalAGL, bool inTask, bool isLandable, bool isAirport, diff --git a/src/Renderer/WaypointListRenderer.cpp b/src/Renderer/WaypointListRenderer.cpp index ee4ebc61073..7b57f1f0b4e 100644 --- a/src/Renderer/WaypointListRenderer.cpp +++ b/src/Renderer/WaypointListRenderer.cpp @@ -26,7 +26,7 @@ FormatWaypointDetails(Buffer &buffer, const Waypoint &waypoint) buffer.Format(_T("%s: %s"), _("Elevation"), _T("?")); if (waypoint.radio_frequency.IsDefined()) { - TCHAR radio[16]; + char radio[16]; waypoint.radio_frequency.Format(radio, 16); buffer.AppendFormat(_T(" - %s MHz"), radio); } @@ -128,7 +128,7 @@ WaypointListRenderer::Draw(Canvas &canvas, PixelRect rc, // Draw distance and arrival altitude StaticString<256> buffer; - TCHAR alt[20], radio[20]; + char alt[20], radio[20]; FormatRelativeUserAltitude(arrival_altitude, alt, true); buffer.Format(_T("%s: %s - %s: %s"), _("Distance"), diff --git a/src/Renderer/WaypointRenderer.cpp b/src/Renderer/WaypointRenderer.cpp index 4ae7a388299..b7d4e39bd28 100644 --- a/src/Renderer/WaypointRenderer.cpp +++ b/src/Renderer/WaypointRenderer.cpp @@ -134,7 +134,7 @@ class WaypointVisitorMap final const TaskBehaviour &task_behaviour; const MoreData &basic; - TCHAR altitude_unit[4]; + char altitude_unit[4]; bool task_valid; /** @@ -173,7 +173,7 @@ class WaypointVisitorMap final protected: - void FormatTitle(TCHAR *buffer, size_t buffer_size, + void FormatTitle(char *buffer, size_t buffer_size, const Waypoint &way_point) const noexcept { buffer[0] = _T('\0'); @@ -196,7 +196,7 @@ class WaypointVisitorMap final case WaypointRendererSettings::DisplayTextType::FIRST_WORD: CopyTruncateString(buffer, buffer_size, way_point.name.c_str()); - TCHAR *tmp; + char *tmp; tmp = strstr(buffer, _T(" ")); if (tmp != nullptr) tmp[0] = '\0'; @@ -216,7 +216,7 @@ class WaypointVisitorMap final } } - void FormatLabel(TCHAR *buffer, size_t buffer_size, + void FormatLabel(char *buffer, size_t buffer_size, const Waypoint &way_point, WaypointReachability reachable, const ReachResult &reach) const noexcept { @@ -342,7 +342,7 @@ class WaypointVisitorMap final text_mode.move_in_view = true; } - TCHAR buffer[NAME_SIZE+1]; + char buffer[NAME_SIZE+1]; FormatLabel(buffer, ARRAY_SIZE(buffer), way_point, vwp.reachable, vwp.reach); diff --git a/src/ResourceLoader.cpp b/src/ResourceLoader.cpp index 4b14545b442..78b107e32de 100644 --- a/src/ResourceLoader.cpp +++ b/src/ResourceLoader.cpp @@ -34,7 +34,7 @@ void ResourceLoader::Init(HINSTANCE hInstance) #endif /* !WIN32 */ ResourceLoader::Data -ResourceLoader::Load(const TCHAR *name, [[maybe_unused]] const TCHAR *type) +ResourceLoader::Load(const char *name, [[maybe_unused]] const char *type) { #ifdef USE_WIN32_RESOURCES assert(ResourceLoaderInstance != nullptr); diff --git a/src/ResourceLoader.hpp b/src/ResourceLoader.hpp index f1183b99e6a..bb3f9d613d6 100644 --- a/src/ResourceLoader.hpp +++ b/src/ResourceLoader.hpp @@ -25,7 +25,7 @@ Init(HINSTANCE hInstance); using Data = std::span; Data -Load(const TCHAR *name, const TCHAR *type); +Load(const char *name, const char *type); #ifndef ANDROID Data diff --git a/src/StatusMessage.cpp b/src/StatusMessage.cpp index ee2ea57fab4..1dc4f4333d2 100644 --- a/src/StatusMessage.cpp +++ b/src/StatusMessage.cpp @@ -13,7 +13,7 @@ static constexpr StatusMessage default_status_messages[] = { [[gnu::pure]] const StatusMessage & -FindStatusMessage(const TCHAR *key) +FindStatusMessage(const char *key) { assert(ARRAY_SIZE(default_status_messages) > 0); diff --git a/src/StatusMessage.hpp b/src/StatusMessage.hpp index baf55b485f4..6e8d961a6db 100644 --- a/src/StatusMessage.hpp +++ b/src/StatusMessage.hpp @@ -11,10 +11,10 @@ */ struct StatusMessage { /** English key */ - const TCHAR *key; + const char *key; /** What sound entry to play */ - const TCHAR *sound; + const char *sound; bool visible; @@ -24,4 +24,4 @@ struct StatusMessage { [[gnu::pure]] const StatusMessage & -FindStatusMessage(const TCHAR *key); +FindStatusMessage(const char *key); diff --git a/src/Task/Serialiser.cpp b/src/Task/Serialiser.cpp index 56df3111474..0ffcb30575a 100644 --- a/src/Task/Serialiser.cpp +++ b/src/Task/Serialiser.cpp @@ -18,7 +18,7 @@ #include [[gnu::const]] -static const TCHAR * +static const char * GetName(TaskPointType type, bool mode_optional_start) { switch (type) { @@ -42,7 +42,7 @@ GetName(TaskPointType type, bool mode_optional_start) } [[gnu::pure]] -static const TCHAR * +static const char * GetName(const OrderedTaskPoint &tp, bool mode_optional_start) { return GetName(tp.GetType(), mode_optional_start); @@ -166,7 +166,7 @@ Serialise(WritableDataNode &node, const ObservationZonePoint &data) static void Serialise(WritableDataNode &node, const OrderedTaskPoint &data, - const TCHAR *name) + const char *name) { // do nothing auto child = node.AppendChild("Point"); @@ -187,7 +187,7 @@ static void Serialise(WritableDataNode &node, const OrderedTaskPoint &tp, bool mode_optional_start) { - const TCHAR *name = GetName(tp, mode_optional_start); + const char *name = GetName(tp, mode_optional_start); assert(name != nullptr); Serialise(node, tp, name); } @@ -210,7 +210,7 @@ GetHeightRef(AltitudeReference height_ref) } [[gnu::const]] -static const TCHAR * +static const char * GetTaskFactoryType(TaskFactoryType type) { switch(type) { diff --git a/src/Task/TaskFileIGC.cpp b/src/Task/TaskFileIGC.cpp index 42899812915..98a56c1b81d 100644 --- a/src/Task/TaskFileIGC.cpp +++ b/src/Task/TaskFileIGC.cpp @@ -49,7 +49,7 @@ try { } static WaypointPtr -MakeWaypoint(GeoPoint location, const TCHAR *name) +MakeWaypoint(GeoPoint location, const char *name) { Waypoint *wp = new Waypoint(location); wp->name = name; diff --git a/src/Task/TaskStore.cpp b/src/Task/TaskStore.cpp index ff7dfe20190..552596c47ad 100644 --- a/src/Task/TaskStore.cpp +++ b/src/Task/TaskStore.cpp @@ -102,7 +102,7 @@ TaskStore::Item::GetTask(const TaskBehaviour &task_behaviour, return task.get(); } -const TCHAR * +const char * TaskStore::GetName(unsigned index) const { return store[index].GetName(); diff --git a/src/Task/TypeStrings.cpp b/src/Task/TypeStrings.cpp index df2b488330d..2e1785d523d 100644 --- a/src/Task/TypeStrings.cpp +++ b/src/Task/TypeStrings.cpp @@ -7,7 +7,7 @@ #include "Language/Language.hpp" #include "util/Macros.hpp" -static const TCHAR *const task_factory_names[] = { +static const char *const task_factory_names[] = { N_("FAI badges/records"), N_("FAI triangle"), N_("FAI out and return"), @@ -22,13 +22,13 @@ static const TCHAR *const task_factory_names[] = { static_assert(ARRAY_SIZE(task_factory_names) == unsigned(TaskFactoryType::COUNT), "Wrong array size"); -const TCHAR* +const char* OrderedTaskFactoryName(TaskFactoryType type) { return gettext(task_factory_names[unsigned(type)]); } -static const TCHAR *const task_factory_descriptions[] = { +static const char *const task_factory_descriptions[] = { N_("FAI rules, allows only FAI start, finish and turn point types, for badges and " "records. Enables FAI finish height for final glide calculation."), N_("FAI rules, path from a start to two turn points and return."), @@ -46,13 +46,13 @@ static const TCHAR *const task_factory_descriptions[] = { static_assert(ARRAY_SIZE(task_factory_descriptions) == unsigned(TaskFactoryType::COUNT), "Wrong array size"); -const TCHAR* +const char* OrderedTaskFactoryDescription(TaskFactoryType type) { return gettext(task_factory_descriptions[unsigned(type)]); } -static const TCHAR *const tp_factory_descriptions[] = { +static const char *const tp_factory_descriptions[] = { N_("A 90 degree sector with 1km radius. Cross corner edge from inside area to start."), N_("A straight line start gate. Cross start gate from inside area to start."), N_("A cylinder. Exit area to start."), @@ -83,13 +83,13 @@ static const TCHAR *const tp_factory_descriptions[] = { static_assert(ARRAY_SIZE(tp_factory_descriptions) == unsigned(TaskPointFactoryType::COUNT), "Wrong array size"); -const TCHAR* +const char* OrderedTaskPointDescription(TaskPointFactoryType type) { return tp_factory_descriptions[unsigned(type)]; } -static const TCHAR *const tp_factory_names[] = { +static const char *const tp_factory_names[] = { N_("FAI start quadrant"), N_("Start line"), N_("Start cylinder"), @@ -114,7 +114,7 @@ static const TCHAR *const tp_factory_names[] = { static_assert(ARRAY_SIZE(tp_factory_names) == unsigned(TaskPointFactoryType::COUNT), "Wrong array size"); -const TCHAR* +const char* OrderedTaskPointName(TaskPointFactoryType type) { return tp_factory_names[unsigned(type)]; diff --git a/src/Task/TypeStrings.hpp b/src/Task/TypeStrings.hpp index 216010ade60..8baab7af9c5 100644 --- a/src/Task/TypeStrings.hpp +++ b/src/Task/TypeStrings.hpp @@ -11,17 +11,17 @@ enum class TaskFactoryType : uint8_t; enum class TaskPointFactoryType : uint8_t; [[gnu::const]] -const TCHAR * +const char * OrderedTaskFactoryDescription(TaskFactoryType type); [[gnu::const]] -const TCHAR * +const char * OrderedTaskFactoryName(TaskFactoryType type); [[gnu::const]] -const TCHAR * +const char * OrderedTaskPointDescription(TaskPointFactoryType type); [[gnu::const]] -const TCHAR * +const char * OrderedTaskPointName(TaskPointFactoryType type); diff --git a/src/Task/ValidationErrorStrings.cpp b/src/Task/ValidationErrorStrings.cpp index 75a97c7d181..5fec7b58cf2 100644 --- a/src/Task/ValidationErrorStrings.cpp +++ b/src/Task/ValidationErrorStrings.cpp @@ -8,7 +8,7 @@ #include // for MAX_PATH #include -static const TCHAR *const validation_error_strings[] = { +static const char *const validation_error_strings[] = { N_("No valid start"), N_("No valid finish"), N_("Task not closed"), @@ -26,10 +26,10 @@ static const TCHAR *const validation_error_strings[] = { static_assert(ARRAY_SIZE(validation_error_strings) == unsigned(TaskValidationErrorType::COUNT), "Wrong array size"); -const TCHAR* +const char* getTaskValidationErrors(const TaskValidationErrorSet v) { - static TCHAR err[MAX_PATH]; + static char err[MAX_PATH]; err[0] = '\0'; for (unsigned i = 0; i < v.N; i++) { @@ -37,7 +37,7 @@ getTaskValidationErrors(const TaskValidationErrorSet v) if (!v.Contains(error)) continue; - const TCHAR *current = gettext(validation_error_strings[i]); + const char *current = gettext(validation_error_strings[i]); if (strlen(err) + strlen(current) + 1 < MAX_PATH) { strcat(err, current); strcat(err, _T("\n")); diff --git a/src/Task/ValidationErrorStrings.hpp b/src/Task/ValidationErrorStrings.hpp index ef3f4c479c0..17519c3a566 100644 --- a/src/Task/ValidationErrorStrings.hpp +++ b/src/Task/ValidationErrorStrings.hpp @@ -8,5 +8,5 @@ #include [[gnu::const]] -const TCHAR * +const char * getTaskValidationErrors(const TaskValidationErrorSet v); diff --git a/src/Task/XCTrackTaskDecoder.cpp b/src/Task/XCTrackTaskDecoder.cpp index 50717acef73..ceeb4d816c5 100644 --- a/src/Task/XCTrackTaskDecoder.cpp +++ b/src/Task/XCTrackTaskDecoder.cpp @@ -50,7 +50,7 @@ DecodeXCTrackZ(std::string_view src) } static WaypointPtr -MakeWaypoint(GeoPoint location, const TCHAR *name) +MakeWaypoint(GeoPoint location, const char *name) { Waypoint *wp = new Waypoint(location); wp->name = name; diff --git a/src/TeamActions.cpp b/src/TeamActions.cpp index ad9820c320d..071af504b4c 100644 --- a/src/TeamActions.cpp +++ b/src/TeamActions.cpp @@ -8,7 +8,7 @@ #include "FLARM/Global.hpp" void -TeamActions::TrackFlarm(FlarmId id, const TCHAR *callsign) noexcept +TeamActions::TrackFlarm(FlarmId id, const char *callsign) noexcept { TeamCodeSettings &settings = CommonInterface::SetComputerSettings().team_code; diff --git a/src/TeamActions.hpp b/src/TeamActions.hpp index 1e39f2d02c8..547a49347ed 100644 --- a/src/TeamActions.hpp +++ b/src/TeamActions.hpp @@ -13,6 +13,6 @@ namespace TeamActions { * Track the specified FLARM peer. */ void -TrackFlarm(FlarmId id, const TCHAR *callsign=nullptr) noexcept; +TrackFlarm(FlarmId id, const char *callsign=nullptr) noexcept; }; diff --git a/src/TeamCode/Settings.cpp b/src/TeamCode/Settings.cpp index 1e84814bd2b..5cf66d26ae2 100644 --- a/src/TeamCode/Settings.cpp +++ b/src/TeamCode/Settings.cpp @@ -12,7 +12,7 @@ TeamCodeSettings::SetDefaults() } void -TeamCodeSettings::TrackFlarm(FlarmId id, const TCHAR *name) +TeamCodeSettings::TrackFlarm(FlarmId id, const char *name) { // Start tracking team_flarm_id = id; diff --git a/src/TeamCode/Settings.hpp b/src/TeamCode/Settings.hpp index 935ab0c8dfa..09ff8f9342d 100644 --- a/src/TeamCode/Settings.hpp +++ b/src/TeamCode/Settings.hpp @@ -38,7 +38,7 @@ struct TeamCodeSettings { * Don't use this method directory, use TeamActions::TrackFlarm() * instead. */ - void TrackFlarm(FlarmId id, const TCHAR *callsign); + void TrackFlarm(FlarmId id, const char *callsign); }; static_assert(std::is_trivial::value, "type is not trivial"); diff --git a/src/TeamCode/TeamCode.cpp b/src/TeamCode/TeamCode.cpp index a5929accd9a..9753b7a3cba 100644 --- a/src/TeamCode/TeamCode.cpp +++ b/src/TeamCode/TeamCode.cpp @@ -20,7 +20,7 @@ static constexpr Angle ANGLE_FACTOR = * @return The decoded value */ static unsigned -GetValueFromTeamCode(const TCHAR *code, unsigned length) +GetValueFromTeamCode(const char *code, unsigned length) { unsigned val = 0; unsigned position = 0; @@ -63,12 +63,12 @@ CountDigits(unsigned value) * @param n_digits Number of chars for the teamcode */ static void -NumberToTeamCode(unsigned value, TCHAR *code, unsigned n_digits) +NumberToTeamCode(unsigned value, char *code, unsigned n_digits) { if (n_digits == 0) n_digits = CountDigits(value); - TCHAR *p = code + n_digits; + char *p = code + n_digits; *p-- = _T('\0'); do { @@ -76,8 +76,8 @@ NumberToTeamCode(unsigned value, TCHAR *code, unsigned n_digits) value /= BASE; *p = digit_value < 10 - ? TCHAR('0' + digit_value) - : TCHAR('A' + digit_value - 10); + ? char('0' + digit_value) + : char('A' + digit_value - 10); } while (--p >= code); } @@ -87,7 +87,7 @@ NumberToTeamCode(unsigned value, TCHAR *code, unsigned n_digits) * @param code The teamcode (pointer) */ static void -ConvertBearingToTeamCode(const Angle bearing, TCHAR *code) +ConvertBearingToTeamCode(const Angle bearing, char *code) { const unsigned value = uround(bearing.AsBearing().Native() / ANGLE_FACTOR.Native()); @@ -122,7 +122,7 @@ TeamCode::Update(Angle bearing, double range) } void -TeamCode::Update(const TCHAR* _code) +TeamCode::Update(const char* _code) { code = _code; } diff --git a/src/TeamCode/TeamCode.hpp b/src/TeamCode/TeamCode.hpp index bfaaf30363d..7115cfa3f4e 100644 --- a/src/TeamCode/TeamCode.hpp +++ b/src/TeamCode/TeamCode.hpp @@ -30,7 +30,7 @@ class TeamCode * Returns the current team code * @return Current team code */ - const TCHAR *GetCode() const { + const char *GetCode() const { return code; } @@ -66,7 +66,7 @@ class TeamCode * Updates the team code to the given code * @param _code The new team code */ - void Update(const TCHAR* _code); + void Update(const char* _code); }; static_assert(std::is_trivial::value, "type is not trivial"); diff --git a/src/Terrain/RasterTerrain.cpp b/src/Terrain/RasterTerrain.cpp index 08ed7dde7b6..07a3cdacd43 100644 --- a/src/Terrain/RasterTerrain.cpp +++ b/src/Terrain/RasterTerrain.cpp @@ -15,7 +15,7 @@ #include "util/ConvertString.hpp" #include "LogFile.hpp" -static const TCHAR *const terrain_cache_name = _T("terrain"); +static const char *const terrain_cache_name = _T("terrain"); inline bool RasterTerrain::LoadCache(FileCache &cache, Path path) diff --git a/src/Topography/TopographyFileRenderer.cpp b/src/Topography/TopographyFileRenderer.cpp index 97d1000603b..d93161bd139 100644 --- a/src/Topography/TopographyFileRenderer.cpp +++ b/src/Topography/TopographyFileRenderer.cpp @@ -377,7 +377,7 @@ TopographyFileRenderer::PaintLabels(Canvas &canvas, const XShape &shape = *shape_p; // Skip shapes without a label - const TCHAR *label = shape.GetLabel(); + const char *label = shape.GetLabel(); assert(label != nullptr); const auto lines = shape.GetLines(); diff --git a/src/Topography/XShape.cpp b/src/Topography/XShape.cpp index c74852cbfd9..9446de616f2 100644 --- a/src/Topography/XShape.cpp +++ b/src/Topography/XShape.cpp @@ -19,7 +19,7 @@ #include -static BasicAllocatedString +static BasicAllocatedString ImportLabel(const char *src) noexcept { if (src == nullptr) @@ -34,7 +34,7 @@ ImportLabel(const char *src) noexcept if (!ValidateUTF8(src)) return nullptr; - return BasicAllocatedString(src); + return BasicAllocatedString(src); } /** diff --git a/src/Topography/XShape.hpp b/src/Topography/XShape.hpp index 1a3a9a937cf..be6467f647d 100644 --- a/src/Topography/XShape.hpp +++ b/src/Topography/XShape.hpp @@ -75,7 +75,7 @@ class XShape { mutable unsigned offset; #endif - BasicAllocatedString label; + BasicAllocatedString label; public: /** @@ -129,7 +129,7 @@ class XShape { return points.get(); } - const TCHAR *GetLabel() const noexcept { + const char *GetLabel() const noexcept { return label.c_str(); } }; diff --git a/src/Tracking/LiveTrack24/Client.cpp b/src/Tracking/LiveTrack24/Client.cpp index 98e0ee11c52..afb6a9c8bb4 100644 --- a/src/Tracking/LiveTrack24/Client.cpp +++ b/src/Tracking/LiveTrack24/Client.cpp @@ -22,7 +22,7 @@ using std::string_view_literals::operator""sv; namespace LiveTrack24 { Co::Task -Client::GetUserID(const TCHAR *username, const TCHAR *password) +Client::GetUserID(const char *username, const char *password) { // http://www.livetrack24.com/client.php?op=login&user=&pass= @@ -63,9 +63,9 @@ Client::GetUserID(const TCHAR *username, const TCHAR *password) } Co::Task -Client::StartTracking(SessionID session, const TCHAR *username, - const TCHAR *password, [[maybe_unused]] unsigned tracking_interval, - VehicleType vtype, const TCHAR *vname) +Client::StartTracking(SessionID session, const char *username, + const char *password, [[maybe_unused]] unsigned tracking_interval, + VehicleType vtype, const char *vname) { // http://www.livetrack24.com/track.php?leolive=2&sid=42664778&pid=1& // client=YourProgramName&v=1&user=yourusername&pass=yourpass& @@ -134,7 +134,7 @@ Client::EndTracking(SessionID session, unsigned packet_id) } void -Client::SetServer(const TCHAR * _server) noexcept +Client::SetServer(const char * _server) noexcept { server.SetASCII(_server); } diff --git a/src/Tracking/LiveTrack24/Client.hpp b/src/Tracking/LiveTrack24/Client.hpp index f66baddadc6..2fc76f3196b 100644 --- a/src/Tracking/LiveTrack24/Client.hpp +++ b/src/Tracking/LiveTrack24/Client.hpp @@ -54,12 +54,12 @@ class Client final { * @param password Case-insensitive password * @return 0 if userdata are incorrect, or else the userID of the user */ - Co::Task GetUserID(const TCHAR *username, const TCHAR *password); + Co::Task GetUserID(const char *username, const char *password); /** Sends the "start of track" packet to the tracking server */ - Co::Task StartTracking(SessionID session, const TCHAR *username, - const TCHAR *password, unsigned tracking_interval, - VehicleType vtype, const TCHAR *vname); + Co::Task StartTracking(SessionID session, const char *username, + const char *password, unsigned tracking_interval, + VehicleType vtype, const char *vname); /** * Sends a "gps point" packet to the tracking server @@ -79,7 +79,7 @@ class Client final { * Set the tracking server * @param server e.g. www.livetrack24.com (without http:// prefix) */ - void SetServer(const TCHAR *server) noexcept; + void SetServer(const char *server) noexcept; private: const char *GetServer() const noexcept { diff --git a/src/Tracking/SkyLines/Handler.hpp b/src/Tracking/SkyLines/Handler.hpp index b17ca576507..0384af110a4 100644 --- a/src/Tracking/SkyLines/Handler.hpp +++ b/src/Tracking/SkyLines/Handler.hpp @@ -27,7 +27,7 @@ class Handler { virtual void OnAck([[maybe_unused]] unsigned id) {} virtual void OnTraffic([[maybe_unused]] uint32_t pilot_id, [[maybe_unused]] unsigned time_of_day_ms, [[maybe_unused]] const ::GeoPoint &location, [[maybe_unused]] int altitude) {} - virtual void OnUserName([[maybe_unused]] uint32_t user_id, [[maybe_unused]] const TCHAR *name) {} + virtual void OnUserName([[maybe_unused]] uint32_t user_id, [[maybe_unused]] const char *name) {} virtual void OnWave([[maybe_unused]] unsigned time_of_day_ms, [[maybe_unused]] const ::GeoPoint &a, [[maybe_unused]] const ::GeoPoint &b) {} virtual void OnThermal([[maybe_unused]] unsigned time_of_day_ms, diff --git a/src/Tracking/TrackingGlue.cpp b/src/Tracking/TrackingGlue.cpp index 12daed40e2f..351d2bbb824 100644 --- a/src/Tracking/TrackingGlue.cpp +++ b/src/Tracking/TrackingGlue.cpp @@ -54,7 +54,7 @@ TrackingGlue::OnTraffic(uint32_t pilot_id, unsigned time_of_day_ms, } void -TrackingGlue::OnUserName(uint32_t user_id, const TCHAR *name) +TrackingGlue::OnUserName(uint32_t user_id, const char *name) { const std::lock_guard lock{skylines_data.mutex}; skylines_data.user_names[user_id] = name; diff --git a/src/Tracking/TrackingGlue.hpp b/src/Tracking/TrackingGlue.hpp index 9c7245177ae..9edb51ec361 100644 --- a/src/Tracking/TrackingGlue.hpp +++ b/src/Tracking/TrackingGlue.hpp @@ -37,7 +37,7 @@ class TrackingGlue final /* virtual methods from SkyLinesTracking::Handler */ virtual void OnTraffic(uint32_t pilot_id, unsigned time_of_day_ms, const GeoPoint &location, int altitude) override; - virtual void OnUserName(uint32_t user_id, const TCHAR *name) override; + virtual void OnUserName(uint32_t user_id, const char *name) override; void OnWave(unsigned time_of_day_ms, const GeoPoint &a, const GeoPoint &b) override; void OnThermal(unsigned time_of_day_ms, diff --git a/src/TransponderCode.cpp b/src/TransponderCode.cpp index a8e7aabdff4..96d5abdce67 100644 --- a/src/TransponderCode.cpp +++ b/src/TransponderCode.cpp @@ -6,8 +6,8 @@ #include "util/NumberParser.hpp" #include "util/StringFormat.hpp" -TCHAR * -TransponderCode::Format(TCHAR *buffer, std::size_t max_size) const noexcept +char * +TransponderCode::Format(char *buffer, std::size_t max_size) const noexcept { if (!IsDefined()) return nullptr; @@ -17,9 +17,9 @@ TransponderCode::Format(TCHAR *buffer, std::size_t max_size) const noexcept } TransponderCode -TransponderCode::Parse(const TCHAR *s) noexcept +TransponderCode::Parse(const char *s) noexcept { - TCHAR *endptr; + char *endptr; const auto value = ParseUnsigned(s, &endptr, 8); auto result = Null(); diff --git a/src/TransponderCode.hpp b/src/TransponderCode.hpp index 17f7f7e9d35..fdb78c18d46 100644 --- a/src/TransponderCode.hpp +++ b/src/TransponderCode.hpp @@ -55,8 +55,8 @@ class TransponderCode { *this = Null(); } - TCHAR *Format(TCHAR *buffer, std::size_t max_size) const noexcept; + char *Format(char *buffer, std::size_t max_size) const noexcept; [[gnu::pure]] - static TransponderCode Parse(const TCHAR *s) noexcept; + static TransponderCode Parse(const char *s) noexcept; }; diff --git a/src/UIGlobals.cpp b/src/UIGlobals.cpp index 67b6244a689..14cce194cc5 100644 --- a/src/UIGlobals.cpp +++ b/src/UIGlobals.cpp @@ -77,4 +77,4 @@ UIGlobals::GetMapLook() } -const TCHAR *UIGlobals::CommandLine = nullptr; +const char *UIGlobals::CommandLine = nullptr; diff --git a/src/UIGlobals.hpp b/src/UIGlobals.hpp index 2bcea69055a..200c2174410 100644 --- a/src/UIGlobals.hpp +++ b/src/UIGlobals.hpp @@ -53,6 +53,6 @@ namespace UIGlobals { [[gnu::const]] const MapLook &GetMapLook(); - extern const TCHAR *CommandLine; + extern const char *CommandLine; }; diff --git a/src/UIUtil/GestureManager.cpp b/src/UIUtil/GestureManager.cpp index 41d8dd819f2..77da6b81bab 100644 --- a/src/UIUtil/GestureManager.cpp +++ b/src/UIUtil/GestureManager.cpp @@ -5,7 +5,7 @@ #include "Math/FastMath.hpp" #include "util/Compiler.h" -[[gnu::const]] static TCHAR +[[gnu::const]] static char getDirection(int dx, int dy) { if (dy < 0 && -dy >= abs(dx) * 2) @@ -34,7 +34,7 @@ GestureManager::Update(PixelPoint p) drag_last = p; // Get current dragging direction - TCHAR direction = getDirection(d.x, d.y); + char direction = getDirection(d.x, d.y); // Return if we are in an unclear direction if (direction == '\0') @@ -60,13 +60,13 @@ GestureManager::Start(PixelPoint p, int _threshold) threshold = _threshold; } -const TCHAR* +const char* GestureManager::Finish() { return GetGesture(); } -const TCHAR* +const char* GestureManager::GetGesture() const { return gesture.empty() diff --git a/src/UIUtil/GestureManager.hpp b/src/UIUtil/GestureManager.hpp index 1ee22251a7c..2f8bfaf21ec 100644 --- a/src/UIUtil/GestureManager.hpp +++ b/src/UIUtil/GestureManager.hpp @@ -34,13 +34,13 @@ class GestureManager * Returns the recognized gesture * @return NULL or recognized gesture string */ - const TCHAR* GetGesture() const; + const char* GetGesture() const; /** * Stops the GestureManager and returns the recognized gesture * @return NULL or recognized gesture string */ - const TCHAR* Finish(); + const char* Finish(); /** * Starts the GestureManager at the given coordinates diff --git a/src/UIUtil/TrackingGestureManager.cpp b/src/UIUtil/TrackingGestureManager.cpp index 2162a4d455c..c27274b29c6 100644 --- a/src/UIUtil/TrackingGestureManager.cpp +++ b/src/UIUtil/TrackingGestureManager.cpp @@ -31,7 +31,7 @@ TrackingGestureManager::Start(PixelPoint p, int threshold) GestureManager::Start(p, threshold); } -const TCHAR* +const char* TrackingGestureManager::Finish() { points.clear(); diff --git a/src/UIUtil/TrackingGestureManager.hpp b/src/UIUtil/TrackingGestureManager.hpp index d3b94268633..34f693a04f9 100644 --- a/src/UIUtil/TrackingGestureManager.hpp +++ b/src/UIUtil/TrackingGestureManager.hpp @@ -26,7 +26,7 @@ class TrackingGestureManager: public GestureManager * Stops the GestureManager and returns the recognized gesture * @return NULL or recognized gesture string */ - const TCHAR* Finish(); + const char* Finish(); /** * Starts the GestureManager at the given coordinates diff --git a/src/Units/Descriptor.cpp b/src/Units/Descriptor.cpp index bc8f0f055f2..2112f825e10 100644 --- a/src/Units/Descriptor.cpp +++ b/src/Units/Descriptor.cpp @@ -45,7 +45,7 @@ const UnitDescriptor Units::unit_descriptors[] = { static_assert(ARRAY_SIZE(Units::unit_descriptors) == (size_t)Unit::COUNT, "number of unit descriptions does not match number of units"); -const TCHAR * +const char * Units::GetUnitName(Unit unit) noexcept { const unsigned i = (unsigned)unit; diff --git a/src/Units/Descriptor.hpp b/src/Units/Descriptor.hpp index e628f280a5a..1c380930120 100644 --- a/src/Units/Descriptor.hpp +++ b/src/Units/Descriptor.hpp @@ -9,7 +9,7 @@ struct UnitDescriptor { - const TCHAR *name; + const char *name; double factor_to_user; double offset_to_user; }; @@ -28,7 +28,7 @@ extern const UnitDescriptor unit_descriptors[]; * @return The name of the given Unit (e.g. "km" or "ft") */ [[gnu::const]] -const TCHAR * +const char * GetUnitName(Unit unit) noexcept; }; diff --git a/src/Units/Units.cpp b/src/Units/Units.cpp index 846bdfe4d0d..0ffed256272 100644 --- a/src/Units/Units.cpp +++ b/src/Units/Units.cpp @@ -90,49 +90,49 @@ Units::GetUserUnitByGroup(UnitGroup group) return current.GetByGroup(group); } -const TCHAR * +const char * Units::GetSpeedName() { return GetUnitName(GetUserSpeedUnit()); } -const TCHAR * +const char * Units::GetVerticalSpeedName() { return GetUnitName(GetUserVerticalSpeedUnit()); } -const TCHAR * +const char * Units::GetWindSpeedName() { return GetUnitName(GetUserWindSpeedUnit()); } -const TCHAR * +const char * Units::GetDistanceName() { return GetUnitName(GetUserDistanceUnit()); } -const TCHAR * +const char * Units::GetAltitudeName() { return GetUnitName(GetUserAltitudeUnit()); } -const TCHAR * +const char * Units::GetTemperatureName() { return GetUnitName(GetUserTemperatureUnit()); } -const TCHAR * +const char * Units::GetTaskSpeedName() { return GetUnitName(GetUserTaskSpeedUnit()); } -const TCHAR * +const char * Units::GetPressureName() { return GetUnitName(GetUserPressureUnit()); diff --git a/src/Units/Units.hpp b/src/Units/Units.hpp index d39e4b68cba..c9d108465e4 100644 --- a/src/Units/Units.hpp +++ b/src/Units/Units.hpp @@ -108,35 +108,35 @@ Unit GetUserUnitByGroup(UnitGroup group); [[gnu::pure]] -const TCHAR * +const char * GetSpeedName(); [[gnu::pure]] -const TCHAR * +const char * GetVerticalSpeedName(); [[gnu::pure]] -const TCHAR * +const char * GetWindSpeedName(); [[gnu::pure]] -const TCHAR * +const char * GetDistanceName(); [[gnu::pure]] -const TCHAR * +const char * GetAltitudeName(); [[gnu::pure]] -const TCHAR * +const char * GetTemperatureName(); [[gnu::pure]] -const TCHAR * +const char * GetTaskSpeedName(); [[gnu::pure]] -const TCHAR * +const char * GetPressureName(); static inline double diff --git a/src/Units/UnitsGlue.cpp b/src/Units/UnitsGlue.cpp index 91f758ba864..a1897a5e8c9 100644 --- a/src/Units/UnitsGlue.cpp +++ b/src/Units/UnitsGlue.cpp @@ -22,7 +22,7 @@ struct language_unit_map { unsigned region_id; - const TCHAR* region_code; + const char* region_code; unsigned store_index; }; @@ -69,7 +69,7 @@ FindLanguage(LANGID lang) } #elif defined(ANDROID) static unsigned -FindLanguage(const TCHAR* lang) +FindLanguage(const char* lang) { // Search for supported languages matching the language code for (unsigned i = 0; language_table[i].region_code != nullptr; ++i) diff --git a/src/Units/UnitsStore.cpp b/src/Units/UnitsStore.cpp index 038ebafb8a0..cb90b835d3d 100644 --- a/src/Units/UnitsStore.cpp +++ b/src/Units/UnitsStore.cpp @@ -10,7 +10,7 @@ struct UnitStoreItem { - const TCHAR* Name; + const char* Name; UnitSetting Units; }; @@ -70,7 +70,7 @@ static constexpr UnitStoreItem Presets[] = } } }; -const TCHAR * +const char * Units::Store::GetName(unsigned i) noexcept { assert(i < Count()); diff --git a/src/Units/UnitsStore.hpp b/src/Units/UnitsStore.hpp index 7dc0dde1a48..fd43063400d 100644 --- a/src/Units/UnitsStore.hpp +++ b/src/Units/UnitsStore.hpp @@ -13,7 +13,7 @@ struct UnitSetting; namespace Units::Store { [[gnu::const]] -const TCHAR * +const char * GetName(unsigned i) noexcept; [[gnu::const]] diff --git a/src/Version.cpp b/src/Version.cpp index 85c6d53cc30..7ca77bc1707 100644 --- a/src/Version.cpp +++ b/src/Version.cpp @@ -39,8 +39,8 @@ # define GIT_SUFFIX #endif -const TCHAR OpenSoar_Version[] = _T(VERSION); -const TCHAR OpenSoar_VersionLong[] = _T(VERSION VERSION_SUFFIX); -const TCHAR OpenSoar_VersionString[] = _T(VERSION VERSION_SUFFIX "-" TARGET); -const TCHAR OpenSoar_VersionStringOld[] = _T(TARGET " " VERSION VERSION_SUFFIX); -const TCHAR OpenSoar_ProductToken[] = _T("OpenSoar v" VERSION VERSION_SUFFIX "-" TARGET GIT_SUFFIX); +const char OpenSoar_Version[] = _T(VERSION); +const char OpenSoar_VersionLong[] = _T(VERSION VERSION_SUFFIX); +const char OpenSoar_VersionString[] = _T(VERSION VERSION_SUFFIX "-" TARGET); +const char OpenSoar_VersionStringOld[] = _T(TARGET " " VERSION VERSION_SUFFIX); +const char OpenSoar_ProductToken[] = _T("OpenSoar v" VERSION VERSION_SUFFIX "-" TARGET GIT_SUFFIX); diff --git a/src/Version.hpp b/src/Version.hpp index 822234e4f9a..38543c1b33b 100644 --- a/src/Version.hpp +++ b/src/Version.hpp @@ -6,12 +6,12 @@ #include /** 5.2.5 */ -extern const TCHAR OpenSoar_Version[]; +extern const char OpenSoar_Version[]; /** 5.2.5F */ -extern const TCHAR OpenSoar_VersionLong[]; +extern const char OpenSoar_VersionLong[]; /** 5.2.5F-PC */ -extern const TCHAR OpenSoar_VersionString[]; +extern const char OpenSoar_VersionString[]; /** PC 5.2.5F 7. Oct 09 */ -extern const TCHAR OpenSoar_VersionStringOld[]; +extern const char OpenSoar_VersionStringOld[]; /** XCSoar v5.2.5F-PC */ -extern const TCHAR OpenSoar_ProductToken[]; +extern const char OpenSoar_ProductToken[]; diff --git a/src/Waypoint/WaypointDetailsReader.cpp b/src/Waypoint/WaypointDetailsReader.cpp index dae96c229d5..288ca0b1cd2 100644 --- a/src/Waypoint/WaypointDetailsReader.cpp +++ b/src/Waypoint/WaypointDetailsReader.cpp @@ -18,13 +18,13 @@ namespace WaypointDetails { static WaypointPtr -FindWaypoint(Waypoints &way_points, const TCHAR *name) +FindWaypoint(Waypoints &way_points, const char *name) { return way_points.LookupName(name); } struct WaypointDetailsBuilder { - TCHAR name[201]; + char name[201]; tstring details; #ifdef HAVE_RUN_FILE std::forward_list files_external; diff --git a/src/Waypoint/WaypointFilter.cpp b/src/Waypoint/WaypointFilter.cpp index 99e3dcb05f2..67cd44de813 100644 --- a/src/Waypoint/WaypointFilter.cpp +++ b/src/Waypoint/WaypointFilter.cpp @@ -83,7 +83,7 @@ WaypointFilter::CompareDirection(const Waypoint &waypoint, } inline bool -WaypointFilter::CompareName(const Waypoint &waypoint, const TCHAR *name) +WaypointFilter::CompareName(const Waypoint &waypoint, const char *name) { return StringIsEqualIgnoreCase(waypoint.name.c_str(), name, strlen(name)); } diff --git a/src/Waypoint/WaypointFilter.hpp b/src/Waypoint/WaypointFilter.hpp index 759d56ce1e3..9824a864f7f 100644 --- a/src/Waypoint/WaypointFilter.hpp +++ b/src/Waypoint/WaypointFilter.hpp @@ -62,7 +62,7 @@ struct WaypointFilter bool CompareDirection(const Waypoint &waypoint, GeoPoint location) const; - static bool CompareName(const Waypoint &waypoint, const TCHAR *name); + static bool CompareName(const Waypoint &waypoint, const char *name); bool CompareName(const Waypoint &waypoint) const; }; diff --git a/src/Waypoint/WaypointReaderZander.cpp b/src/Waypoint/WaypointReaderZander.cpp index d9c3b5ed566..f7ee4bde6ab 100644 --- a/src/Waypoint/WaypointReaderZander.cpp +++ b/src/Waypoint/WaypointReaderZander.cpp @@ -51,7 +51,7 @@ ParseAngle(const char *src, Angle &dest, const bool lat) noexcept auto value = deg + min / 60. + sec / 3600.; - TCHAR sign = *endptr; + char sign = *endptr; if (sign == 'W' || sign == 'w' || sign == 'S' || sign == 's') value = -value; diff --git a/src/Weather/METARParser.cpp b/src/Weather/METARParser.cpp index 98b4e4a7f88..401849e2914 100644 --- a/src/Weather/METARParser.cpp +++ b/src/Weather/METARParser.cpp @@ -25,11 +25,11 @@ ParseDecoded(const METAR::ContentString &decoded, ParsedMETAR &parsed); class METARLine { protected: - TCHAR *start, *data, *end; + char *start, *data, *end; public: /** Constructor. Duplicates the const input to be able to tokenize it. */ - METARLine(const TCHAR *line) + METARLine(const char *line) :start(strdup(line)), data(start), end(start + strlen(line)) { // Trim possible = character at the end (End-of-METAR character) @@ -45,11 +45,11 @@ class METARLine { } /** Returns the next token or NULL if no token is left. (Seperator is ' ') */ - const TCHAR *Next() { + const char *Next() { if (data >= end) return NULL; - const TCHAR *start = data; + const char *start = data; auto *seperator = StringFind(data, _T(' ')); if (seperator != NULL && seperator < end) { @@ -65,7 +65,7 @@ class METARLine { /** Detects a token with exactly 4 letters */ static bool -DetectICAOCodeToken(const TCHAR *token) +DetectICAOCodeToken(const char *token) { if (strlen(token) != 4) return false; @@ -83,7 +83,7 @@ DetectICAOCodeToken(const TCHAR *token) /** Detects a token with exactly 6 digits and a Z (Zulu = UTC) at the end */ static bool -DetectTimeCodeToken(const TCHAR *token) +DetectTimeCodeToken(const char *token) { if (strlen(token) != 7) return false; @@ -92,11 +92,11 @@ DetectTimeCodeToken(const TCHAR *token) } static bool -ParseTimeCode(const TCHAR *token, ParsedMETAR &parsed) +ParseTimeCode(const char *token, ParsedMETAR &parsed) { assert(DetectTimeCodeToken(token)); - TCHAR *endptr; + char *endptr; unsigned time_code = strtod(token, &endptr); if (endptr == NULL || endptr == token) return false; @@ -115,7 +115,7 @@ ParseTimeCode(const TCHAR *token, ParsedMETAR &parsed) * If the wind direction varies VRB is also valid. */ static bool -DetectWindToken(const TCHAR *token) +DetectWindToken(const char *token) { unsigned length = strlen(token); @@ -136,7 +136,7 @@ DetectWindToken(const TCHAR *token) } static bool -ParseWind(const TCHAR *token, ParsedMETAR &parsed) +ParseWind(const char *token, ParsedMETAR &parsed) { assert(DetectWindToken(token)); @@ -145,7 +145,7 @@ ParseWind(const TCHAR *token, ParsedMETAR &parsed) // parsing okay but don't provide wind return true; - TCHAR *endptr; + char *endptr; unsigned wind_code = strtod(token, &endptr); if (endptr == NULL || endptr == token) return false; @@ -167,14 +167,14 @@ ParseWind(const TCHAR *token, ParsedMETAR &parsed) /** Detects a CAVOK token */ static bool -DetectCAVOK(const TCHAR *token) +DetectCAVOK(const char *token) { return (strlen(token) == 5 && StringIsEqualIgnoreCase(token, _T("CAVOK"))); } /** Detects a token with exactly 5 digits */ static bool -DetectVisibilityToken(const TCHAR *token) +DetectVisibilityToken(const char *token) { if (strlen(token) != 4) return false; @@ -187,11 +187,11 @@ DetectVisibilityToken(const TCHAR *token) } static bool -ParseVisibility(const TCHAR *token, ParsedMETAR &parsed) +ParseVisibility(const char *token, ParsedMETAR &parsed) { assert(DetectVisibilityToken(token)); - TCHAR *endptr; + char *endptr; parsed.visibility = strtol(token, &endptr, 10); if (endptr == NULL || endptr == token) return false; @@ -205,7 +205,7 @@ ParseVisibility(const TCHAR *token, ParsedMETAR &parsed) * If the temperatures are negative a 'M' is a valid prefix. */ static bool -DetectTemperaturesToken(const TCHAR *token) +DetectTemperaturesToken(const char *token) { unsigned length = strlen(token); @@ -231,14 +231,14 @@ DetectTemperaturesToken(const TCHAR *token) return divider_found; } -static const TCHAR * -ParseTemperature(const TCHAR *token, double &temperature) +static const char * +ParseTemperature(const char *token, double &temperature) { bool negative = (token[0] == _T('M') || token[0] == _T('m')); if (negative) token++; - TCHAR *endptr; + char *endptr; int _temperature = strtod(token, &endptr); if (endptr == NULL || endptr == token) return NULL; @@ -251,7 +251,7 @@ ParseTemperature(const TCHAR *token, double &temperature) } static bool -ParseTemperatures(const TCHAR *token, ParsedMETAR &parsed) +ParseTemperatures(const char *token, ParsedMETAR &parsed) { assert(DetectTemperaturesToken(token)); @@ -272,7 +272,7 @@ ParseTemperatures(const TCHAR *token, ParsedMETAR &parsed) /** Detects a token beginning with a 'T' and followed by 8 digits */ static bool -DetectAdditionalTemperaturesToken(const TCHAR *token) +DetectAdditionalTemperaturesToken(const char *token) { if (strlen(token) != 9) return false; @@ -289,14 +289,14 @@ DetectAdditionalTemperaturesToken(const TCHAR *token) } static bool -ParseAdditionalTemperatures(const TCHAR *token, ParsedMETAR &parsed) +ParseAdditionalTemperatures(const char *token, ParsedMETAR &parsed) { assert(DetectAdditionalTemperaturesToken(token)); // Skip 'T' token++; - TCHAR *endptr; + char *endptr; long temperature_code = strtol(token, &endptr, 10); if (endptr == NULL || endptr == token) return false; @@ -318,7 +318,7 @@ ParseAdditionalTemperatures(const TCHAR *token, ParsedMETAR &parsed) /** Detects a token beginning with either 'Q' or 'A' and followed by 4 digits */ static bool -DetectQNHToken(const TCHAR *token) +DetectQNHToken(const char *token) { unsigned length = strlen(token); @@ -334,7 +334,7 @@ DetectQNHToken(const TCHAR *token) } static bool -ParseQNH(const TCHAR *token, ParsedMETAR &parsed) +ParseQNH(const char *token, ParsedMETAR &parsed) { assert(DetectQNHToken(token)); @@ -342,7 +342,7 @@ ParseQNH(const TCHAR *token, ParsedMETAR &parsed) if (token[0] == _T('Q') || token[0] == _T('q')) { token++; - TCHAR *endptr; + char *endptr; unsigned hpa = strtod(token, &endptr); if (endptr == NULL || endptr == token) return false; @@ -356,7 +356,7 @@ ParseQNH(const TCHAR *token, ParsedMETAR &parsed) if (token[0] == _T('A') || token[0] == _T('a')) { token++; - TCHAR *endptr; + char *endptr; unsigned inch_hg = strtod(token, &endptr); if (endptr == NULL || endptr == token) return false; @@ -379,7 +379,7 @@ METARParser::ParseLine(const METAR::ContentString &content, ParsedMETAR &parsed) // METAR KTTN 051853Z 04011KT 1/2SM VCTS SN FZFG BKN003 OVC010 M02/M02 A3006 RMK AO2 TSB40 SLP176 P0002 T10171017= METARLine line(content.c_str()); - const TCHAR *token; + const char *token; // Parse four-letter ICAO code while ((token = line.Next()) != NULL) { @@ -452,10 +452,10 @@ METARParser::ParseLine(const METAR::ContentString &content, ParsedMETAR &parsed) } static bool -ParseLocation(const TCHAR *buffer, ParsedMETAR &parsed) +ParseLocation(const char *buffer, ParsedMETAR &parsed) { // 51-18N 006-46E - TCHAR *end; + char *end; unsigned lat_deg = ParseUnsigned(buffer, &end, 10); if (*end != '-') @@ -528,8 +528,8 @@ METARParser::ParseDecoded(const METAR::ContentString &decoded, // Duesseldorf, Germany (EDDL) 51-18N 006-46E 41M // Nov 04, 2011 - 07:50 PM EDT / 2011.11.04 2350 UTC - const TCHAR *start = decoded.c_str(); - const TCHAR *end = start + strlen(start); + const char *start = decoded.c_str(); + const char *end = start + strlen(start); const auto *opening_brace = StringFind(start, _T('(')); const auto *closing_brace = StringFind(start, _T(')')); const auto *line_break = StringFind(start, _T('\n')); diff --git a/src/Weather/NOAAFormatter.cpp b/src/Weather/NOAAFormatter.cpp index c9b560a9f0b..dd9de873c43 100644 --- a/src/Weather/NOAAFormatter.cpp +++ b/src/Weather/NOAAFormatter.cpp @@ -12,12 +12,12 @@ class NOAALineSplitter { - const TCHAR *start; + const char *start; public: - typedef std::pair Range; + typedef std::pair Range; - NOAALineSplitter(const TCHAR *_start):start(_start) {} + NOAALineSplitter(const char *_start):start(_start) {} bool HasNext() const { return start != NULL && start[0] != _T('\0'); @@ -26,7 +26,7 @@ class NOAALineSplitter Range Next() { assert(HasNext()); - const TCHAR *line_start = start; + const char *line_start = start; // Search for next line break const auto *line_break = StringFind(line_start, _T('\n')); @@ -43,7 +43,7 @@ class NOAALineSplitter }; static bool -CheckTitle(const TCHAR *title, size_t title_length, const TCHAR *check) +CheckTitle(const char *title, size_t title_length, const char *check) { if (strlen(check) != title_length) return false; @@ -52,12 +52,12 @@ CheckTitle(const TCHAR *title, size_t title_length, const TCHAR *check) } static bool -FormatDecodedMETARLine(const TCHAR *line, unsigned length, +FormatDecodedMETARLine(const char *line, unsigned length, const ParsedMETAR &parsed, tstring &output) { - const TCHAR *end = line + length; + const char *end = line + length; - const TCHAR *colon = (const TCHAR *)memchr(line, _T(':'), length); + const char *colon = (const char *)memchr(line, _T(':'), length); if (!colon) return false; @@ -65,7 +65,7 @@ FormatDecodedMETARLine(const TCHAR *line, unsigned length, if (title_length == 0) return false; - const TCHAR *value = colon + 1; + const char *value = colon + 1; while (*value == _T(' ')) value++; @@ -94,7 +94,7 @@ FormatDecodedMETARLine(const TCHAR *line, unsigned length, buffer.Format(_T("%s: "), _("Temperature")); buffer.append({value, value_length}); } else { - TCHAR temperature_buffer[16]; + char temperature_buffer[16]; FormatUserTemperature(parsed.temperature, temperature_buffer); buffer.Format(_T("%s: %s"), _("Temperature"), temperature_buffer); @@ -111,7 +111,7 @@ FormatDecodedMETARLine(const TCHAR *line, unsigned length, buffer.Format(_T("%s: "), _("Dew Point")); buffer.append({value, value_length}); } else { - TCHAR temperature_buffer[16]; + char temperature_buffer[16]; FormatUserTemperature(parsed.dew_point, temperature_buffer); buffer.Format(_T("%s: %s"), _("Dew Point"), temperature_buffer); @@ -128,7 +128,7 @@ FormatDecodedMETARLine(const TCHAR *line, unsigned length, buffer.Format(_T("%s: "), _("Pressure")); buffer.append({value, value_length}); } else { - TCHAR qnh_buffer[16]; + char qnh_buffer[16]; FormatUserPressure(parsed.qnh, qnh_buffer); buffer.Format(_T("%s: %s"), _("Pressure"), qnh_buffer); diff --git a/src/Weather/NOAAStore.hpp b/src/Weather/NOAAStore.hpp index e6deea99f27..cb528197871 100644 --- a/src/Weather/NOAAStore.hpp +++ b/src/Weather/NOAAStore.hpp @@ -25,7 +25,7 @@ class NOAAStore TAF taf; /** - * Returns the four letter code as a TCHAR string. This may + * Returns the four letter code as a char string. This may * return a pointer to a static buffer, and consecutive calls * (even with different objects) may Invalidate the previous * return value. May be called only from the main thread. diff --git a/src/Weather/PCMet/Images.hpp b/src/Weather/PCMet/Images.hpp index e67545526bf..a46bca572de 100644 --- a/src/Weather/PCMet/Images.hpp +++ b/src/Weather/PCMet/Images.hpp @@ -15,12 +15,12 @@ namespace PCMet { struct ImageArea { const char *name; - const TCHAR *display_name; + const char *display_name; }; struct ImageType { const char *uri; - const TCHAR *display_name; + const char *display_name; const ImageArea *areas; }; diff --git a/src/Weather/PCMet/Overlays.cpp b/src/Weather/PCMet/Overlays.cpp index 2b1e7ea6d45..00a3098716a 100644 --- a/src/Weather/PCMet/Overlays.cpp +++ b/src/Weather/PCMet/Overlays.cpp @@ -24,7 +24,7 @@ static constexpr const char *type_names[] = { "nb_cosde_ome", }; -static constexpr const TCHAR *type_labels[] = { +static constexpr const char *type_labels[] = { _T("Vertikal"), }; @@ -39,7 +39,7 @@ static constexpr const char *area_names[] = { "sued", }; -static constexpr const TCHAR *area_labels[] = { +static constexpr const char *area_labels[] = { _T("Nord"), _T("Süd"), }; diff --git a/src/Weather/Rasp/RaspCache.cpp b/src/Weather/Rasp/RaspCache.cpp index c2fe959033c..2d9553cd9e1 100644 --- a/src/Weather/Rasp/RaspCache.cpp +++ b/src/Weather/Rasp/RaspCache.cpp @@ -24,13 +24,13 @@ ToQuarterHours(BrokenTime t) return t.hour * 4u + t.minute / 15; } -const TCHAR * +const char * RaspCache::GetMapName() const { return store.GetItemInfo(parameter).name; } -const TCHAR * +const char * RaspCache::GetMapLabel() const { const auto &info = store.GetItemInfo(parameter); diff --git a/src/Weather/Rasp/RaspCache.hpp b/src/Weather/Rasp/RaspCache.hpp index 3d1bdfe53e5..ca62561c519 100644 --- a/src/Weather/Rasp/RaspCache.hpp +++ b/src/Weather/Rasp/RaspCache.hpp @@ -44,14 +44,14 @@ class RaspCache { * Returns the current map's name. */ [[gnu::pure]] - const TCHAR *GetMapName() const; + const char *GetMapName() const; /** * Returns the human-readable name for the current RASP map, or * nullptr if no RASP map is enabled. */ [[gnu::pure]] - const TCHAR *GetMapLabel() const; + const char *GetMapLabel() const; /** * Returns the index of the weather map being displayed. diff --git a/src/Weather/Rasp/RaspRenderer.cpp b/src/Weather/Rasp/RaspRenderer.cpp index 3da43e6c85d..5cd2123d733 100644 --- a/src/Weather/Rasp/RaspRenderer.cpp +++ b/src/Weather/Rasp/RaspRenderer.cpp @@ -12,7 +12,7 @@ [[gnu::pure]] static const RaspStyle & -LookupWeatherTerrainStyle(const TCHAR *name) +LookupWeatherTerrainStyle(const char *name) { const auto *i = rasp_styles; while (i->name != nullptr && !StringIsEqual(i->name, name)) diff --git a/src/Weather/Rasp/RaspRenderer.hpp b/src/Weather/Rasp/RaspRenderer.hpp index b7d864775c7..e425862ad04 100644 --- a/src/Weather/Rasp/RaspRenderer.hpp +++ b/src/Weather/Rasp/RaspRenderer.hpp @@ -48,7 +48,7 @@ class RaspRenderer { * nullptr if no RASP map is enabled. */ [[gnu::pure]] - const TCHAR *GetLabel() const { + const char *GetLabel() const { return cache.GetMapLabel(); } diff --git a/src/Weather/Rasp/RaspStore.cpp b/src/Weather/Rasp/RaspStore.cpp index f5a203cfe49..7b572654207 100644 --- a/src/Weather/Rasp/RaspStore.cpp +++ b/src/Weather/Rasp/RaspStore.cpp @@ -75,7 +75,7 @@ static constexpr RaspStore::MapInfo WeatherDescriptors[] = { }, }; -RaspStore::MapItem::MapItem(const TCHAR *_name) +RaspStore::MapItem::MapItem(const char *_name) :name(_name) { std::fill_n(times, ARRAY_SIZE(times), false); diff --git a/src/Weather/Rasp/RaspStore.hpp b/src/Weather/Rasp/RaspStore.hpp index 2afa7a1e908..1382af40072 100644 --- a/src/Weather/Rasp/RaspStore.hpp +++ b/src/Weather/Rasp/RaspStore.hpp @@ -30,18 +30,18 @@ class RaspStore { static constexpr unsigned MAX_WEATHER_TIMES = 96; /**< Max time segments of each item */ struct MapInfo { - const TCHAR *name; + const char *name; /** * Human-readable label. Call gettext() for internationalization. */ - const TCHAR *label; + const char *label; /** * Human-readable help text. Call gettext() for * internationalization. */ - const TCHAR *help; + const char *help; }; struct MapItem { @@ -50,18 +50,18 @@ class RaspStore { /** * Human-readable label. Call gettext() for internationalization. */ - const TCHAR *label; + const char *label; /** * Human-readable help text. Call gettext() for * internationalization. */ - const TCHAR *help; + const char *help; bool times[MAX_WEATHER_TIMES]; MapItem() = default; - explicit MapItem(const TCHAR *_name); + explicit MapItem(const char *_name); }; typedef StaticArray MapList; diff --git a/src/Weather/Rasp/RaspStyle.hpp b/src/Weather/Rasp/RaspStyle.hpp index 52cf8f10a02..7b20e2436c7 100644 --- a/src/Weather/Rasp/RaspStyle.hpp +++ b/src/Weather/Rasp/RaspStyle.hpp @@ -8,7 +8,7 @@ struct ColorRamp; struct RaspStyle { - const TCHAR *name; + const char *name; const ColorRamp *color_ramp; unsigned height_scale; bool do_water; diff --git a/src/Widget/ButtonWidget.cpp b/src/Widget/ButtonWidget.cpp index 3bd783bb7fd..143dcd0d92a 100644 --- a/src/Widget/ButtonWidget.cpp +++ b/src/Widget/ButtonWidget.cpp @@ -12,7 +12,7 @@ ButtonWidget::ButtonWidget(std::unique_ptr _renderer, :renderer(std::move(_renderer)), callback(std::move(_callback)) {} -ButtonWidget::ButtonWidget(const ButtonLook &look, const TCHAR *caption, +ButtonWidget::ButtonWidget(const ButtonLook &look, const char *caption, std::function _callback) noexcept :renderer(std::make_unique(look, caption)), callback(std::move(_callback)) {} diff --git a/src/Widget/ButtonWidget.hpp b/src/Widget/ButtonWidget.hpp index 6e485e03573..ec9bd8aab6a 100644 --- a/src/Widget/ButtonWidget.hpp +++ b/src/Widget/ButtonWidget.hpp @@ -25,7 +25,7 @@ class ButtonWidget : public WindowWidget { ButtonWidget(std::unique_ptr _renderer, std::function _callback) noexcept; - ButtonWidget(const ButtonLook &look, const TCHAR *caption, + ButtonWidget(const ButtonLook &look, const char *caption, std::function _callback) noexcept; ~ButtonWidget() noexcept override; diff --git a/src/Widget/EditRowFormWidget.cpp b/src/Widget/EditRowFormWidget.cpp index 1ba48bc937d..433f8186cd9 100644 --- a/src/Widget/EditRowFormWidget.cpp +++ b/src/Widget/EditRowFormWidget.cpp @@ -24,7 +24,7 @@ #include std::unique_ptr -RowFormWidget::CreateEdit(const TCHAR *label, const TCHAR *help, +RowFormWidget::CreateEdit(const char *label, const char *help, bool read_only) noexcept { assert(IsDefined()); @@ -50,7 +50,7 @@ RowFormWidget::CreateEdit(const TCHAR *label, const TCHAR *help, } WndProperty * -RowFormWidget::Add(const TCHAR *label, const TCHAR *help, +RowFormWidget::Add(const char *label, const char *help, bool read_only) noexcept { return (WndProperty *)&Add(Row::Type::EDIT, @@ -58,8 +58,8 @@ RowFormWidget::Add(const TCHAR *label, const TCHAR *help, } void -RowFormWidget::AddReadOnly(const TCHAR *label, const TCHAR *help, - const TCHAR *text) noexcept +RowFormWidget::AddReadOnly(const char *label, const char *help, + const char *text) noexcept { WndProperty *control = Add(label, help, true); if (text != nullptr) @@ -67,8 +67,8 @@ RowFormWidget::AddReadOnly(const TCHAR *label, const TCHAR *help, } void -RowFormWidget::AddReadOnly(const TCHAR *label, const TCHAR *help, - const TCHAR *display_format, +RowFormWidget::AddReadOnly(const char *label, const char *help, + const char *display_format, double value) noexcept { WndProperty *edit = Add(label, help, true); @@ -78,7 +78,7 @@ RowFormWidget::AddReadOnly(const TCHAR *label, const TCHAR *help, } void -RowFormWidget::AddReadOnly(const TCHAR *label, const TCHAR *help, +RowFormWidget::AddReadOnly(const char *label, const char *help, bool value) noexcept { WndProperty *edit = Add(label, help, true); @@ -87,7 +87,7 @@ RowFormWidget::AddReadOnly(const TCHAR *label, const TCHAR *help, } WndProperty * -RowFormWidget::Add(const TCHAR *label, const TCHAR *help, +RowFormWidget::Add(const char *label, const char *help, DataField *df) noexcept { WndProperty *edit = Add(label, help); @@ -96,7 +96,7 @@ RowFormWidget::Add(const TCHAR *label, const TCHAR *help, } WndProperty * -RowFormWidget::AddBoolean(const TCHAR *label, const TCHAR *help, +RowFormWidget::AddBoolean(const char *label, const char *help, bool value, DataFieldListener *listener) noexcept { @@ -108,9 +108,9 @@ RowFormWidget::AddBoolean(const TCHAR *label, const TCHAR *help, } WndProperty * -RowFormWidget::AddInteger(const TCHAR *label, const TCHAR *help, - const TCHAR *display_format, - const TCHAR *edit_format, +RowFormWidget::AddInteger(const char *label, const char *help, + const char *display_format, + const char *edit_format, int min_value, int max_value, int step, int value, DataFieldListener *listener) noexcept { @@ -123,9 +123,9 @@ RowFormWidget::AddInteger(const TCHAR *label, const TCHAR *help, } WndProperty * -RowFormWidget::AddFloat(const TCHAR *label, const TCHAR *help, - const TCHAR *display_format, - const TCHAR *edit_format, +RowFormWidget::AddFloat(const char *label, const char *help, + const char *display_format, + const char *edit_format, double min_value, double max_value, double step, bool fine, double value, @@ -140,7 +140,7 @@ RowFormWidget::AddFloat(const TCHAR *label, const TCHAR *help, } WndProperty * -RowFormWidget::AddAngle(const TCHAR *label, const TCHAR *help, +RowFormWidget::AddAngle(const char *label, const char *help, Angle value, unsigned step, bool fine, DataFieldListener *listener) noexcept { @@ -151,7 +151,7 @@ RowFormWidget::AddAngle(const TCHAR *label, const TCHAR *help, } WndProperty * -RowFormWidget::AddEnum(const TCHAR *label, const TCHAR *help, +RowFormWidget::AddEnum(const char *label, const char *help, const StaticEnumChoice *list, unsigned value, DataFieldListener *listener) noexcept { @@ -171,7 +171,7 @@ RowFormWidget::AddEnum(const TCHAR *label, const TCHAR *help, } WndProperty * -RowFormWidget::AddEnum(const TCHAR *label, const TCHAR *help, +RowFormWidget::AddEnum(const char *label, const char *help, DataFieldListener *listener) noexcept { WndProperty *edit = Add(label, help); @@ -182,8 +182,8 @@ RowFormWidget::AddEnum(const TCHAR *label, const TCHAR *help, } WndProperty * -RowFormWidget::AddText(const TCHAR *label, const TCHAR *help, - const TCHAR *content, +RowFormWidget::AddText(const char *label, const char *help, + const char *content, DataFieldListener *listener) noexcept { WndProperty *edit = Add(label, help); @@ -194,8 +194,8 @@ RowFormWidget::AddText(const TCHAR *label, const TCHAR *help, } WndProperty * -RowFormWidget::AddPassword(const TCHAR *label, const TCHAR *help, - const TCHAR *content) noexcept +RowFormWidget::AddPassword(const char *label, const char *help, + const char *content) noexcept { WndProperty *edit = Add(label, help); PasswordDataField *df = new PasswordDataField(content); @@ -205,7 +205,7 @@ RowFormWidget::AddPassword(const TCHAR *label, const TCHAR *help, } WndProperty * -RowFormWidget::AddDuration(const TCHAR *label, const TCHAR *help, +RowFormWidget::AddDuration(const char *label, const char *help, std::chrono::seconds min_value, std::chrono::seconds max_value, std::chrono::seconds step, @@ -222,7 +222,7 @@ RowFormWidget::AddDuration(const TCHAR *label, const TCHAR *help, } WndProperty * -RowFormWidget::AddDate(const TCHAR *label, const TCHAR *help, +RowFormWidget::AddDate(const char *label, const char *help, BrokenDate date, DataFieldListener *listener) noexcept { @@ -233,7 +233,7 @@ RowFormWidget::AddDate(const TCHAR *label, const TCHAR *help, } WndProperty * -RowFormWidget::AddRoughTime(const TCHAR *label, const TCHAR *help, +RowFormWidget::AddRoughTime(const char *label, const char *help, RoughTime value, RoughTimeDelta time_zone, DataFieldListener *listener) noexcept { @@ -264,7 +264,7 @@ RowFormWidget::LoadValue(unsigned i, bool value) noexcept } void -RowFormWidget::LoadValueEnum(unsigned i, const TCHAR *text) noexcept +RowFormWidget::LoadValueEnum(unsigned i, const char *text) noexcept { WndProperty &control = GetControl(i); DataFieldEnum &df = *(DataFieldEnum *)control.GetDataField(); @@ -294,7 +294,7 @@ RowFormWidget::LoadValue(unsigned i, double value) noexcept } void -RowFormWidget::LoadValue(unsigned i, const TCHAR *value) noexcept +RowFormWidget::LoadValue(unsigned i, const char *value) noexcept { WndProperty &control = GetControl(i); DataFieldString &df = *(DataFieldString *)control.GetDataField(); @@ -463,9 +463,9 @@ RowFormWidget::SaveValue(unsigned i, RoughTime &value_r) const noexcept bool RowFormWidget::SaveValue(unsigned i, - TCHAR *string, size_t max_size) const noexcept + char *string, size_t max_size) const noexcept { - const TCHAR *new_value = GetDataField(i).GetAsString(); + const char *new_value = GetDataField(i).GetAsString(); assert(new_value != nullptr); if (StringIsEqual(string, new_value)) diff --git a/src/Widget/KeyboardWidget.cpp b/src/Widget/KeyboardWidget.cpp index 555dd7c785f..74c354042fd 100644 --- a/src/Widget/KeyboardWidget.cpp +++ b/src/Widget/KeyboardWidget.cpp @@ -11,7 +11,7 @@ #include #include -static constexpr TCHAR keyboard_letters[] = +static constexpr char keyboard_letters[] = _T("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"); void @@ -19,9 +19,9 @@ KeyboardWidget::Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept { PrepareSize(rc); - TCHAR caption[] = _T(" "); + char caption[] = _T(" "); - for (const TCHAR *i = keyboard_letters; !StringIsEmpty(i); ++i) { + for (const char *i = keyboard_letters; !StringIsEmpty(i); ++i) { caption[0] = *i; AddButton(parent, caption, *i); } @@ -70,7 +70,7 @@ KeyboardWidget::Move(const PixelRect &rc) noexcept } void -KeyboardWidget::SetAllowedCharacters(const TCHAR *allowed) +KeyboardWidget::SetAllowedCharacters(const char *allowed) { for (unsigned i = 0; i < num_buttons; ++i) buttons[i].SetVisible(allowed == nullptr || @@ -133,7 +133,7 @@ KeyboardWidget::ResizeButtons() void KeyboardWidget::MoveButtonsToRow(const PixelRect &rc, - const TCHAR *buttons, unsigned row, + const char *buttons, unsigned row, int offset) { if (StringIsEmpty(buttons)) @@ -191,7 +191,7 @@ KeyboardWidget::OnResize(const PixelRect &rc) void KeyboardWidget::AddButton(ContainerWindow &parent, - const TCHAR *caption, unsigned ch) + const char *caption, unsigned ch) { assert(num_buttons < MAX_BUTTONS); diff --git a/src/Widget/KeyboardWidget.hpp b/src/Widget/KeyboardWidget.hpp index 9c153b0c8ab..413b64ba4cf 100644 --- a/src/Widget/KeyboardWidget.hpp +++ b/src/Widget/KeyboardWidget.hpp @@ -45,7 +45,7 @@ class KeyboardWidget : public NullWidget { /** * Show only the buttons representing the specified character list. */ - void SetAllowedCharacters(const TCHAR *allowed); + void SetAllowedCharacters(const char *allowed); private: void PrepareSize(const PixelRect &rc); @@ -59,7 +59,7 @@ class KeyboardWidget : public NullWidget { void ResizeButtons(); void SetButtonsSize(); void MoveButtonsToRow(const PixelRect &rc, - const TCHAR *buttons, unsigned row, + const char *buttons, unsigned row, int offset_left = 0); void MoveButtons(const PixelRect &rc); @@ -71,7 +71,7 @@ class KeyboardWidget : public NullWidget { /* updates UI based on value of shift_state property */ void UpdateShiftState(); - void AddButton(ContainerWindow &parent, const TCHAR *caption, unsigned ch); + void AddButton(ContainerWindow &parent, const char *caption, unsigned ch); public: /* virtual methods from class Widget */ diff --git a/src/Widget/LargeTextWidget.cpp b/src/Widget/LargeTextWidget.cpp index b3f85878806..e626b64dd07 100644 --- a/src/Widget/LargeTextWidget.cpp +++ b/src/Widget/LargeTextWidget.cpp @@ -6,7 +6,7 @@ #include "Look/DialogLook.hpp" void -LargeTextWidget::SetText(const TCHAR *text) noexcept +LargeTextWidget::SetText(const char *text) noexcept { LargeTextWindow &w = (LargeTextWindow &)GetWindow(); w.SetText(text); diff --git a/src/Widget/LargeTextWidget.hpp b/src/Widget/LargeTextWidget.hpp index 3404483eb4a..7ce88a4fa8e 100644 --- a/src/Widget/LargeTextWidget.hpp +++ b/src/Widget/LargeTextWidget.hpp @@ -14,14 +14,14 @@ struct DialogLook; */ class LargeTextWidget : public WindowWidget { const DialogLook &look; - const TCHAR *text; + const char *text; public: explicit LargeTextWidget(const DialogLook &_look, - const TCHAR *_text=nullptr) noexcept + const char *_text=nullptr) noexcept :look(_look), text(_text) {} - void SetText(const TCHAR *text) noexcept; + void SetText(const char *text) noexcept; /* virtual methods from class Widget */ void Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept override; bool SetFocus() noexcept override; diff --git a/src/Widget/OffsetButtonsWidget.cpp b/src/Widget/OffsetButtonsWidget.cpp index bc0d385f883..ba94b4f3043 100644 --- a/src/Widget/OffsetButtonsWidget.cpp +++ b/src/Widget/OffsetButtonsWidget.cpp @@ -41,7 +41,7 @@ inline Button OffsetButtonsWidget::MakeButton(ContainerWindow &parent, const PixelRect &r, unsigned i) noexcept { - TCHAR caption[16]; + char caption[16]; _stprintf(caption, format, offsets[i]); WindowStyle style; diff --git a/src/Widget/OffsetButtonsWidget.hpp b/src/Widget/OffsetButtonsWidget.hpp index 9df5f5f2e89..ae9be2e8b42 100644 --- a/src/Widget/OffsetButtonsWidget.hpp +++ b/src/Widget/OffsetButtonsWidget.hpp @@ -21,12 +21,12 @@ class Button; */ class OffsetButtonsWidget : public NullWidget { const ButtonLook &look; - const TCHAR *const format; + const char *const format; const double offsets[4]; std::unique_ptr> buttons; public: - OffsetButtonsWidget(const ButtonLook &_look, const TCHAR *_format, + OffsetButtonsWidget(const ButtonLook &_look, const char *_format, double small_offset, double large_offset) noexcept :look(_look), format(_format), offsets{-large_offset, -small_offset, small_offset, large_offset} {} diff --git a/src/Widget/ProfileRowFormWidget.cpp b/src/Widget/ProfileRowFormWidget.cpp index 87410bfb589..0d3c8bf7bc3 100644 --- a/src/Widget/ProfileRowFormWidget.cpp +++ b/src/Widget/ProfileRowFormWidget.cpp @@ -11,8 +11,8 @@ #include "Formatter/TimeFormatter.hpp" WndProperty * -RowFormWidget::AddFile(const TCHAR *label, const TCHAR *help, - std::string_view profile_key, const TCHAR *filters, +RowFormWidget::AddFile(const char *label, const char *help, + std::string_view profile_key, const char *filters, FileType file_type, bool nullable) noexcept { @@ -45,7 +45,7 @@ RowFormWidget::SetProfile(std::string_view profile_key, unsigned value) noexcept bool RowFormWidget::SaveValue(unsigned i, std::string_view profile_key, - TCHAR *string, size_t max_size) const noexcept + char *string, size_t max_size) const noexcept { if (!SaveValue(i, string, max_size)) return false; @@ -113,7 +113,7 @@ RowFormWidget::SaveValue(unsigned i, if (new_value == value) return false; - TCHAR buffer[0x10]; + char buffer[0x10]; FormatISO8601(buffer, new_value); Profile::Set(profile_key, buffer); value = new_value; diff --git a/src/Widget/ProgressWidget.cpp b/src/Widget/ProgressWidget.cpp index 92221cdc06d..1ca38c0e21c 100644 --- a/src/Widget/ProgressWidget.cpp +++ b/src/Widget/ProgressWidget.cpp @@ -32,7 +32,7 @@ class ProgressWidget::ProgressBar final : public PaintWindow { Invalidate(); } - void SetText(const TCHAR *_text) noexcept { + void SetText(const char *_text) noexcept { text = _text; Invalidate(); } @@ -97,7 +97,7 @@ ProgressWidget::Unprepare() noexcept } void -ProgressWidget::SetText(const TCHAR *_text) noexcept +ProgressWidget::SetText(const char *_text) noexcept { if (IsDefined()) { auto &pb = (ProgressBar &)GetWindow(); diff --git a/src/Widget/ProgressWidget.hpp b/src/Widget/ProgressWidget.hpp index f374bdbea73..c3ca20bd19f 100644 --- a/src/Widget/ProgressWidget.hpp +++ b/src/Widget/ProgressWidget.hpp @@ -21,7 +21,7 @@ class ProgressWidget final : public WindowWidget, MessageOperationEnvironment { public: explicit ProgressWidget(PluggableOperationEnvironment &_env, - const TCHAR *_text) noexcept + const char *_text) noexcept :env(_env), text(_text) {} /* virtual methods from class Widget */ @@ -32,7 +32,7 @@ class ProgressWidget final : public WindowWidget, MessageOperationEnvironment { private: /* virtual methods from class OperationEnvironment */ - void SetText(const TCHAR *text) noexcept override; + void SetText(const char *text) noexcept override; void SetProgressRange(unsigned range) noexcept override; void SetProgressPosition(unsigned position) noexcept override; }; diff --git a/src/Widget/QuestionWidget.cpp b/src/Widget/QuestionWidget.cpp index ab4b68a0f74..e02416e9213 100644 --- a/src/Widget/QuestionWidget.cpp +++ b/src/Widget/QuestionWidget.cpp @@ -6,13 +6,13 @@ #include "TextWidget.hpp" #include "Form/ButtonPanel.hpp" -QuestionWidget::QuestionWidget(const TCHAR *_message) noexcept +QuestionWidget::QuestionWidget(const char *_message) noexcept :SolidWidget(std::make_unique(std::make_unique(), ButtonPanelWidget::Alignment::BOTTOM)), message(_message) {} void -QuestionWidget::SetMessage(const TCHAR *_message) noexcept +QuestionWidget::SetMessage(const char *_message) noexcept { auto &bpw = (ButtonPanelWidget &)GetWidget(); auto &tw = (TextWidget &)bpw.GetWidget(); diff --git a/src/Widget/QuestionWidget.hpp b/src/Widget/QuestionWidget.hpp index f19d4ab6ee1..c7ac4deba55 100644 --- a/src/Widget/QuestionWidget.hpp +++ b/src/Widget/QuestionWidget.hpp @@ -17,20 +17,20 @@ */ class QuestionWidget : public SolidWidget { struct Button { - const TCHAR *caption; + const char *caption; std::function callback; }; - const TCHAR *const message; + const char *const message; StaticArray buttons; public: - explicit QuestionWidget(const TCHAR *_message) noexcept; + explicit QuestionWidget(const char *_message) noexcept; - void SetMessage(const TCHAR *_message) noexcept; + void SetMessage(const char *_message) noexcept; - void AddButton(const TCHAR *caption, + void AddButton(const char *caption, std::function callback) noexcept { buttons.append({caption, std::move(callback)}); } diff --git a/src/Widget/RowFormWidget.cpp b/src/Widget/RowFormWidget.cpp index 767494a3590..fe634fceee1 100644 --- a/src/Widget/RowFormWidget.cpp +++ b/src/Widget/RowFormWidget.cpp @@ -267,7 +267,7 @@ RowFormWidget::AddSpacer() noexcept } void -RowFormWidget::AddLabel(const TCHAR *text, unsigned lines) noexcept +RowFormWidget::AddLabel(const char *text, unsigned lines) noexcept { ContainerWindow &panel = (ContainerWindow &)GetWindow(); if (lines == 0) lines = 1; @@ -280,7 +280,7 @@ RowFormWidget::AddLabel(const TCHAR *text, unsigned lines) noexcept } void -RowFormWidget::AddMultiLine(const TCHAR *text) noexcept +RowFormWidget::AddMultiLine(const char *text) noexcept { assert(IsDefined()); @@ -302,7 +302,7 @@ RowFormWidget::AddMultiLine(const TCHAR *text) noexcept } Button * -RowFormWidget::AddButton(const TCHAR *label, +RowFormWidget::AddButton(const char *label, std::function callback) noexcept { assert(IsDefined()); @@ -322,7 +322,7 @@ RowFormWidget::AddButton(const TCHAR *label, } void -RowFormWidget::SetMultiLineText(unsigned i, const TCHAR *text) noexcept +RowFormWidget::SetMultiLineText(unsigned i, const char *text) noexcept { assert(text != nullptr); assert(rows[i].type == Row::Type::MULTI_LINE); diff --git a/src/Widget/RowFormWidget.hpp b/src/Widget/RowFormWidget.hpp index 6fe56c70e9d..a8bb54f8bc1 100644 --- a/src/Widget/RowFormWidget.hpp +++ b/src/Widget/RowFormWidget.hpp @@ -279,8 +279,8 @@ class RowFormWidget : public WindowWidget { Window &Add(Row::Type type, std::unique_ptr window) noexcept; - std::unique_ptr CreateEdit(const TCHAR *label, - const TCHAR *help=nullptr, + std::unique_ptr CreateEdit(const char *label, + const char *help=nullptr, bool read_only=false) noexcept; public: @@ -314,91 +314,91 @@ class RowFormWidget : public WindowWidget { Add(Row::Type::REMAINING, std::move(window)); } - WndProperty *Add(const TCHAR *label, const TCHAR *help=nullptr, + WndProperty *Add(const char *label, const char *help=nullptr, bool read_only=false) noexcept; /** * Add a read-only control. You can use SetText() to update its * text. */ - void AddReadOnly(const TCHAR *label, const TCHAR *help=nullptr, - const TCHAR *text=nullptr) noexcept; + void AddReadOnly(const char *label, const char *help=nullptr, + const char *text=nullptr) noexcept; /** * Add a read-only control displaying a floating-point value. Use * LoadValue() to update the displayed value. */ - void AddReadOnly(const TCHAR *label, const TCHAR *help, - const TCHAR *display_format, + void AddReadOnly(const char *label, const char *help, + const char *display_format, double value) noexcept; /** * Add a read-only control displaying a floating-point value. Use * LoadValue() to update the displayed value. */ - void AddReadOnly(const TCHAR *label, const TCHAR *help, - const TCHAR *display_format, + void AddReadOnly(const char *label, const char *help, + const char *display_format, UnitGroup unit_group, double value) noexcept; /** * Add a read-only control displaying a boolean value. Use * LoadValue() to update the displayed value. */ - void AddReadOnly(const TCHAR *label, const TCHAR *help, + void AddReadOnly(const char *label, const char *help, bool value) noexcept; - WndProperty *Add(const TCHAR *label, const TCHAR *help, + WndProperty *Add(const char *label, const char *help, DataField *df) noexcept; - WndProperty *AddBoolean(const TCHAR *label, const TCHAR *help, + WndProperty *AddBoolean(const char *label, const char *help, bool value=false, DataFieldListener *listener=nullptr) noexcept; - WndProperty *AddInteger(const TCHAR *label, const TCHAR *help, - const TCHAR *display_format, - const TCHAR *edit_format, + WndProperty *AddInteger(const char *label, const char *help, + const char *display_format, + const char *edit_format, int min_value, int max_value, int step, int value, DataFieldListener *listener=nullptr) noexcept; - WndProperty *AddFloat(const TCHAR *label, const TCHAR *help, - const TCHAR *display_format, - const TCHAR *edit_format, + WndProperty *AddFloat(const char *label, const char *help, + const char *display_format, + const char *edit_format, double min_value, double max_value, double step, bool fine, double value, DataFieldListener *listener=nullptr) noexcept; - WndProperty *AddFloat(const TCHAR *label, const TCHAR *help, - const TCHAR *display_format, - const TCHAR *edit_format, + WndProperty *AddFloat(const char *label, const char *help, + const char *display_format, + const char *edit_format, double min_value, double max_value, double step, bool fine, UnitGroup unit_group, double value, DataFieldListener *listener=nullptr) noexcept; - WndProperty *AddAngle(const TCHAR *label, const TCHAR *help, + WndProperty *AddAngle(const char *label, const char *help, Angle value, unsigned step, bool fine, DataFieldListener *listener=nullptr) noexcept; - WndProperty *AddEnum(const TCHAR *label, const TCHAR *help, + WndProperty *AddEnum(const char *label, const char *help, const StaticEnumChoice *list, unsigned value=0, DataFieldListener *listener=nullptr) noexcept; - WndProperty *AddEnum(const TCHAR *label, const TCHAR *help, + WndProperty *AddEnum(const char *label, const char *help, DataFieldListener *listener=nullptr) noexcept; - WndProperty *AddText(const TCHAR *label, const TCHAR *help, - const TCHAR *content, + WndProperty *AddText(const char *label, const char *help, + const char *content, DataFieldListener *listener=nullptr) noexcept; /** * Add a password edit control. The password is obfuscated while * not editing. */ - WndProperty *AddPassword(const TCHAR *label, const TCHAR *help, - const TCHAR *content) noexcept; + WndProperty *AddPassword(const char *label, const char *help, + const char *content) noexcept; - WndProperty *AddDuration(const TCHAR *label, const TCHAR *help, + WndProperty *AddDuration(const char *label, const char *help, std::chrono::seconds min_value, std::chrono::seconds max_value, std::chrono::seconds step, @@ -407,7 +407,7 @@ class RowFormWidget : public WindowWidget { DataFieldListener *listener=nullptr) noexcept; template - WndProperty *AddDuration(const TCHAR *label, const TCHAR *help, + WndProperty *AddDuration(const char *label, const char *help, std::chrono::seconds min_value, std::chrono::seconds max_value, std::chrono::seconds step, @@ -419,23 +419,23 @@ class RowFormWidget : public WindowWidget { max_tokens, listener); } - WndProperty *AddDate(const TCHAR *label, const TCHAR *help, + WndProperty *AddDate(const char *label, const char *help, BrokenDate date, DataFieldListener *listener=nullptr) noexcept; - WndProperty *AddRoughTime(const TCHAR *label, const TCHAR *help, + WndProperty *AddRoughTime(const char *label, const char *help, RoughTime value, RoughTimeDelta time_zone, DataFieldListener *listener=nullptr) noexcept; void AddSpacer() noexcept; - WndProperty *AddFile(const TCHAR *label, const TCHAR *help, - std::string_view profile_key, const TCHAR *filters, + WndProperty *AddFile(const char *label, const char *help, + std::string_view profile_key, const char *filters, FileType file_type, bool nullable = true) noexcept; - WndProperty *AddFile(const TCHAR *label, const TCHAR *help, - std::string_view profile_key, const TCHAR *filters, + WndProperty *AddFile(const char *label, const char *help, + std::string_view profile_key, const char *filters, bool nullable = true) noexcept { return AddFile(label, help, profile_key, filters, FileType::UNKNOWN, nullable); @@ -446,15 +446,15 @@ class RowFormWidget : public WindowWidget { * descriptions or messages. You can use SetText() to update its text. * the parameter lines controls the height if this panel! */ - void AddLabel(const TCHAR *label, unsigned lines = 1) noexcept; + void AddLabel(const char *label, unsigned lines = 1) noexcept; /** * Add a read-only multi-line control. You can use * SetMultiLineText() to update its text. */ - void AddMultiLine(const TCHAR *text=nullptr) noexcept; + void AddMultiLine(const char *text=nullptr) noexcept; - Button *AddButton(const TCHAR *label, std::function callback) noexcept; + Button *AddButton(const char *label, std::function callback) noexcept; [[gnu::pure]] Widget &GetRowWidget(unsigned i) noexcept { @@ -519,7 +519,7 @@ class RowFormWidget : public WindowWidget { /** * Update the text of a multi line control. */ - void SetText(unsigned i, const TCHAR *text) noexcept { + void SetText(unsigned i, const char *text) noexcept { assert(text != nullptr); WndProperty &control = GetControl(i); @@ -534,7 +534,7 @@ class RowFormWidget : public WindowWidget { /** * Update the text of a multi line control. */ - void SetMultiLineText(unsigned i, const TCHAR *text) noexcept; + void SetMultiLineText(unsigned i, const char *text) noexcept; [[gnu::pure]] DataField &GetDataField(unsigned i) noexcept { @@ -572,7 +572,7 @@ class RowFormWidget : public WindowWidget { } void LoadValue(unsigned i, bool value) noexcept; - void LoadValueEnum(unsigned i, const TCHAR *text) noexcept; + void LoadValueEnum(unsigned i, const char *text) noexcept; void LoadValueEnum(unsigned i, unsigned value) noexcept; template @@ -581,7 +581,7 @@ class RowFormWidget : public WindowWidget { LoadValueEnum(i, unsigned(value)); } - void LoadValue(unsigned i, const TCHAR *value) noexcept; + void LoadValue(unsigned i, const char *value) noexcept; void LoadValue(unsigned i, double value) noexcept; void LoadValue(unsigned i, Angle value) noexcept; @@ -600,7 +600,7 @@ class RowFormWidget : public WindowWidget { * Return the raw text of the #WndProperty, bypassing the * #DataField. */ - const TCHAR *GetText(unsigned i) const noexcept { + const char *GetText(unsigned i) const noexcept { return GetControl(i).GetText(); } @@ -641,7 +641,7 @@ class RowFormWidget : public WindowWidget { Path GetValueFile(unsigned i) const noexcept; [[gnu::pure]] - const TCHAR *GetValueString(unsigned i) const noexcept { + const char *GetValueString(unsigned i) const noexcept { return GetDataField(i).GetAsString(); } @@ -679,19 +679,19 @@ class RowFormWidget : public WindowWidget { } bool SaveValue(unsigned i, RoughTime &value_r) const noexcept; - bool SaveValue(unsigned i, TCHAR *string, size_t max_size) const noexcept; + bool SaveValue(unsigned i, char *string, size_t max_size) const noexcept; template - bool SaveValue(unsigned i, BasicStringBuffer &value) const noexcept { + bool SaveValue(unsigned i, BasicStringBuffer &value) const noexcept { return SaveValue(i, value.data(), value.capacity()); } bool SaveValue(unsigned i, std::string_view profile_key, - TCHAR *string, size_t max_size) const noexcept; + char *string, size_t max_size) const noexcept; template bool SaveValue(unsigned i, std::string_view profile_key, - BasicStringBuffer &value) const noexcept { + BasicStringBuffer &value) const noexcept { return SaveValue(i, profile_key, value.data(), value.capacity()); } diff --git a/src/Widget/TabWidget.cpp b/src/Widget/TabWidget.cpp index 70ac0d4c5ab..8f905ac0aa1 100644 --- a/src/Widget/TabWidget.cpp +++ b/src/Widget/TabWidget.cpp @@ -83,14 +83,14 @@ TabWidget::RestoreExtra() noexcept } void -TabWidget::AddTab(std::unique_ptr widget, const TCHAR *caption, +TabWidget::AddTab(std::unique_ptr widget, const char *caption, const MaskedIcon *icon) noexcept { tab_display->Add(caption, icon); PagerWidget::Add(std::move(widget)); } -const TCHAR * +const char * TabWidget::GetButtonCaption(unsigned i) const noexcept { return tab_display->GetCaption(i); diff --git a/src/Widget/TabWidget.hpp b/src/Widget/TabWidget.hpp index 08a7da1ed26..722beed928c 100644 --- a/src/Widget/TabWidget.hpp +++ b/src/Widget/TabWidget.hpp @@ -114,11 +114,11 @@ class TabWidget : public PagerWidget, TabHandler { LargeExtra(); } - void AddTab(std::unique_ptr widget, const TCHAR *caption, + void AddTab(std::unique_ptr widget, const char *caption, const MaskedIcon *icon=nullptr) noexcept; [[gnu::pure]] - const TCHAR *GetButtonCaption(unsigned i) const noexcept; + const char *GetButtonCaption(unsigned i) const noexcept; public: /* virtual methods from class Widget */ diff --git a/src/Widget/TextListWidget.hpp b/src/Widget/TextListWidget.hpp index 462a709ad93..ef21a84b5c5 100644 --- a/src/Widget/TextListWidget.hpp +++ b/src/Widget/TextListWidget.hpp @@ -14,7 +14,7 @@ class TextListWidget : public ListWidget { TextRowRenderer row_renderer; [[gnu::pure]] - virtual const TCHAR *GetRowText(unsigned i) const noexcept = 0; + virtual const char *GetRowText(unsigned i) const noexcept = 0; public: /* virtual methods from class Widget */ diff --git a/src/Widget/TextWidget.cpp b/src/Widget/TextWidget.cpp index eec54a167f7..0f220d5632d 100644 --- a/src/Widget/TextWidget.cpp +++ b/src/Widget/TextWidget.cpp @@ -9,7 +9,7 @@ #include "Look/DialogLook.hpp" void -TextWidget::SetText(const TCHAR *text) noexcept +TextWidget::SetText(const char *text) noexcept { WndFrame &w = (WndFrame &)GetWindow(); w.SetText(text); diff --git a/src/Widget/TextWidget.hpp b/src/Widget/TextWidget.hpp index acbca12cd05..ed6225e38db 100644 --- a/src/Widget/TextWidget.hpp +++ b/src/Widget/TextWidget.hpp @@ -14,7 +14,7 @@ class Color; */ class TextWidget : public WindowWidget { public: - void SetText(const TCHAR *text) noexcept; + void SetText(const char *text) noexcept; void SetColor(Color _color) noexcept; /* virtual methods from class Widget */ diff --git a/src/Widget/UnitRowFormWidget.cpp b/src/Widget/UnitRowFormWidget.cpp index bc685174224..6a8b54e2e5e 100644 --- a/src/Widget/UnitRowFormWidget.cpp +++ b/src/Widget/UnitRowFormWidget.cpp @@ -11,8 +11,8 @@ #include void -RowFormWidget::AddReadOnly(const TCHAR *label, const TCHAR *help, - const TCHAR *display_format, +RowFormWidget::AddReadOnly(const char *label, const char *help, + const char *display_format, UnitGroup unit_group, double value) noexcept { WndProperty *edit = Add(label, help, true); @@ -26,9 +26,9 @@ RowFormWidget::AddReadOnly(const TCHAR *label, const TCHAR *help, } WndProperty * -RowFormWidget::AddFloat(const TCHAR *label, const TCHAR *help, - const TCHAR *display_format, - const TCHAR *edit_format, +RowFormWidget::AddFloat(const char *label, const char *help, + const char *display_format, + const char *edit_format, double min_value, double max_value, double step, bool fine, UnitGroup unit_group, double value, diff --git a/src/XML/DataNode.hpp b/src/XML/DataNode.hpp index ccb779ec882..6aed51ebefa 100644 --- a/src/XML/DataNode.hpp +++ b/src/XML/DataNode.hpp @@ -198,6 +198,6 @@ class WritableDataNode { void SetAttribute(const char *name, RoughTime value) noexcept; /* just here to prevent implicit pointer-to-bool casts - (e.g. TCHAR/wchar_t strings) */ + (e.g. char/wchar_t strings) */ void SetAttribute(const char *name, const auto *value) noexcept = delete; }; diff --git a/src/io/DataFile.cpp b/src/io/DataFile.cpp index 41f3ee18081..aa8cd215837 100644 --- a/src/io/DataFile.cpp +++ b/src/io/DataFile.cpp @@ -10,7 +10,7 @@ #include std::unique_ptr -OpenDataFile(const TCHAR *name) +OpenDataFile(const char *name) { assert(name != nullptr); assert(!StringIsEmpty(name)); diff --git a/src/io/DataFile.hpp b/src/io/DataFile.hpp index a7328c4f624..3ce1f268442 100644 --- a/src/io/DataFile.hpp +++ b/src/io/DataFile.hpp @@ -17,4 +17,4 @@ class Reader; * @param name the file name relative to the data directory */ std::unique_ptr -OpenDataFile(const TCHAR *name); +OpenDataFile(const char *name); diff --git a/src/io/FileCache.cpp b/src/io/FileCache.cpp index d4ee7a69621..2d596722f2e 100644 --- a/src/io/FileCache.cpp +++ b/src/io/FileCache.cpp @@ -75,13 +75,13 @@ FileCache::FileCache(AllocatedPath &&_cache_path) :cache_path(std::move(_cache_path)) {} void -FileCache::Flush(const TCHAR *name) +FileCache::Flush(const char *name) { File::Delete(MakeCachePath(name)); } std::unique_ptr -FileCache::Load(const TCHAR *name, Path original_path) noexcept +FileCache::Load(const char *name, Path original_path) noexcept { FileInfo original_info; if (!GetRegularFileInfo(original_path, original_info)) @@ -121,7 +121,7 @@ FileCache::Load(const TCHAR *name, Path original_path) noexcept } std::unique_ptr -FileCache::Save(const TCHAR *name, Path original_path) +FileCache::Save(const char *name, Path original_path) { FileInfo original_info; if (!GetRegularFileInfo(original_path, original_info)) diff --git a/src/io/FileCache.hpp b/src/io/FileCache.hpp index 62e3acb14ee..087e26fecc8 100644 --- a/src/io/FileCache.hpp +++ b/src/io/FileCache.hpp @@ -20,20 +20,20 @@ class FileCache { protected: [[gnu::pure]] - AllocatedPath MakeCachePath(const TCHAR *name) const { + AllocatedPath MakeCachePath(const char *name) const { return AllocatedPath::Build(cache_path, name); } public: - void Flush(const TCHAR *name); + void Flush(const char *name); /** * Returns nullptr on error. */ - std::unique_ptr Load(const TCHAR *name, Path original_path) noexcept; + std::unique_ptr Load(const char *name, Path original_path) noexcept; /** * Throws on error. */ - std::unique_ptr Save(const TCHAR *name, Path original_path); + std::unique_ptr Save(const char *name, Path original_path); }; diff --git a/src/io/StringConverter.cpp b/src/io/StringConverter.cpp index fa24ab83be7..6fff87ccc20 100644 --- a/src/io/StringConverter.cpp +++ b/src/io/StringConverter.cpp @@ -52,7 +52,7 @@ StringConverter::DetectStrip(std::string_view src) noexcept return src; } -TCHAR * +char * StringConverter::Convert(char *narrow) { narrow = DetectStrip(narrow); diff --git a/src/io/StringConverter.hpp b/src/io/StringConverter.hpp index a00f7580b40..d64fe7865dc 100644 --- a/src/io/StringConverter.hpp +++ b/src/io/StringConverter.hpp @@ -10,12 +10,12 @@ #include /** - * Helper which imports strings from a file to `TCHAR*`. + * Helper which imports strings from a file to `char*`. */ class StringConverter { Charset charset; - ReusableArray tbuffer; + ReusableArray tbuffer; public: explicit StringConverter(Charset cs=Charset::AUTO) noexcept @@ -47,7 +47,7 @@ class StringConverter { * * Throws on error. */ - TCHAR *Convert(char *src); + char *Convert(char *src); tstring_view Convert(std::string_view src); }; diff --git a/src/lua/InputEvent.cpp b/src/lua/InputEvent.cpp index a90b689817d..b72ae28efd1 100644 --- a/src/lua/InputEvent.cpp +++ b/src/lua/InputEvent.cpp @@ -96,7 +96,7 @@ class LuaInputEvent final { } } - void AttachGesture(const TCHAR* gesture) { + void AttachGesture(const char* gesture) { if (event_store_gesture.Insert(gesture, this)) { Lua::AddPersistent(L, this); } @@ -347,11 +347,11 @@ bool Lua::FireNMEAEvent(unsigned event) { return event_store_enum.Fire(event + GCE_COUNT); } -bool Lua::FireGesture(const TCHAR* gesture) { +bool Lua::FireGesture(const char* gesture) { return event_store_gesture.Fire(gesture); } -bool Lua::IsGesture(const TCHAR* gesture) { +bool Lua::IsGesture(const char* gesture) { return event_store_gesture.HasHandler(gesture); } diff --git a/src/lua/InputEvent.hpp b/src/lua/InputEvent.hpp index a204c606240..739132ba0b4 100644 --- a/src/lua/InputEvent.hpp +++ b/src/lua/InputEvent.hpp @@ -23,12 +23,12 @@ bool FireNMEAEvent(unsigned event); bool -FireGesture(const TCHAR *gesture); +FireGesture(const char *gesture); bool FireKey(unsigned key); bool -IsGesture(const TCHAR *gesture); +IsGesture(const char *gesture); } diff --git a/src/system/Args.hpp b/src/system/Args.hpp index d33b3c59560..068e119ddb2 100644 --- a/src/system/Args.hpp +++ b/src/system/Args.hpp @@ -53,7 +53,7 @@ class Args { } #ifdef _WIN32 - Args(const TCHAR *_cmdline, const char *_usage) + Args(const char *_cmdline, const char *_usage) :usage(_usage) { ParseCommandLine(_cmdline); } diff --git a/src/system/FileUtil.cpp b/src/system/FileUtil.cpp index afca409b235..4722766766f 100644 --- a/src/system/FileUtil.cpp +++ b/src/system/FileUtil.cpp @@ -62,7 +62,7 @@ Directory::Exists(Path path) noexcept */ #ifndef HAVE_POSIX static bool -IsDots(const TCHAR *str) noexcept +IsDots(const char *str) noexcept { return StringIsEqual(str, _T(".")) || StringIsEqual(str, _T("..")); } @@ -72,7 +72,7 @@ IsDots(const TCHAR *str) noexcept [[gnu::pure]] static bool -checkFilter(const TCHAR *filename, const TCHAR *filter) noexcept +checkFilter(const char *filename, const char *filter) noexcept { // filter = e.g. "*.igc" or "config/*.prf" // todo: make filters like "config/*.prf" work @@ -87,10 +87,10 @@ checkFilter(const TCHAR *filename, const TCHAR *filter) noexcept static bool ScanFiles(File::Visitor &visitor, Path sPath, - const TCHAR* filter = _T("*")) + const char* filter = _T("*")) { - TCHAR DirPath[MAX_PATH]; - TCHAR FileName[MAX_PATH]; + char DirPath[MAX_PATH]; + char FileName[MAX_PATH]; if (sPath != nullptr) // e.g. "/test/data/something" @@ -149,14 +149,14 @@ ScanFiles(File::Visitor &visitor, Path sPath, static bool ScanDirectories(File::Visitor &visitor, bool recursive, - Path sPath, const TCHAR* filter = _T("*")) + Path sPath, const char* filter = _T("*")) { #ifdef HAVE_POSIX DIR *dir = opendir(sPath.c_str()); if (dir == nullptr) return false; - TCHAR FileName[MAX_PATH]; + char FileName[MAX_PATH]; strcpy(FileName, sPath.c_str()); size_t FileNameLength = strlen(FileName); FileName[FileNameLength++] = '/'; @@ -187,8 +187,8 @@ ScanDirectories(File::Visitor &visitor, bool recursive, closedir(dir); #else /* !HAVE_POSIX */ - TCHAR DirPath[MAX_PATH]; - TCHAR FileName[MAX_PATH]; + char DirPath[MAX_PATH]; + char FileName[MAX_PATH]; if (sPath != nullptr) { // e.g. "/test/data/something" @@ -260,7 +260,7 @@ Directory::VisitFiles(Path path, File::Visitor &visitor, bool recursive) } void -Directory::VisitSpecificFiles(Path path, const TCHAR* filter, +Directory::VisitSpecificFiles(Path path, const char* filter, File::Visitor &visitor, bool recursive) { ScanDirectories(visitor, recursive, path, filter); diff --git a/src/system/FileUtil.hpp b/src/system/FileUtil.hpp index 33d7a45b815..6cff7876941 100644 --- a/src/system/FileUtil.hpp +++ b/src/system/FileUtil.hpp @@ -73,7 +73,7 @@ VisitFiles(Path path, File::Visitor &visitor, * @param recursive If true all subfolders will be visited too */ void -VisitSpecificFiles(Path path, const TCHAR *filter, +VisitSpecificFiles(Path path, const char *filter, File::Visitor &visitor, bool recursive = false); } // namespace Directory diff --git a/src/system/PathName.cpp b/src/system/PathName.cpp index 3ad4a53d33b..0abb6d32331 100644 --- a/src/system/PathName.cpp +++ b/src/system/PathName.cpp @@ -5,8 +5,8 @@ #include "util/StringAPI.hxx" [[gnu::pure]] -static const TCHAR * -LastSeparator(const TCHAR *path) +static const char * +LastSeparator(const char *path) { const auto *p = StringFindLast(path, _T('/')); #ifdef _WIN32 @@ -18,16 +18,16 @@ LastSeparator(const TCHAR *path) } [[gnu::pure]] -static TCHAR * -LastSeparator(TCHAR *path) +static char * +LastSeparator(char *path) { - return const_cast(LastSeparator((const TCHAR *)path)); + return const_cast(LastSeparator((const char *)path)); } void -ReplaceBaseName(TCHAR *path, const TCHAR *new_base) +ReplaceBaseName(char *path, const char *new_base) { - TCHAR *q = LastSeparator(path); + char *q = LastSeparator(path); if (q != nullptr) ++q; else diff --git a/src/system/PathName.hpp b/src/system/PathName.hpp index 0ad1df235cc..7441f860ac6 100644 --- a/src/system/PathName.hpp +++ b/src/system/PathName.hpp @@ -16,4 +16,4 @@ * @param new_base the new base name to be copied to #path */ void -ReplaceBaseName(TCHAR *path, const TCHAR *new_base); +ReplaceBaseName(char *path, const char *new_base); diff --git a/src/system/RunFile.cpp b/src/system/RunFile.cpp index a8d47c0dcf5..95b945e3286 100644 --- a/src/system/RunFile.cpp +++ b/src/system/RunFile.cpp @@ -10,7 +10,7 @@ #include "Process.hpp" bool -RunFile(const TCHAR *path) noexcept +RunFile(const char *path) noexcept { #if defined(__APPLE__) return Start("/usr/bin/open", path); diff --git a/src/system/RunFile.hpp b/src/system/RunFile.hpp index 94b2f4cc907..1da3957b86d 100644 --- a/src/system/RunFile.hpp +++ b/src/system/RunFile.hpp @@ -13,6 +13,6 @@ * Opens a file in the user's preferred application. */ bool -RunFile(const TCHAR *path) noexcept; +RunFile(const char *path) noexcept; #endif diff --git a/src/system/WindowsRegistry.hpp b/src/system/WindowsRegistry.hpp index e079dc661e1..fbe3e5e33cd 100644 --- a/src/system/WindowsRegistry.hpp +++ b/src/system/WindowsRegistry.hpp @@ -22,7 +22,7 @@ class RegistryKey { public: RegistryKey() noexcept = default; - RegistryKey(HKEY parent, const TCHAR *key) { + RegistryKey(HKEY parent, const char *key) { const auto result = RegOpenKeyEx(parent, key, 0, KEY_READ, &h); if (result != ERROR_SUCCESS) throw MakeLastError("RegOpenKeyEx() failed"); @@ -46,7 +46,7 @@ class RegistryKey { return h; } - bool GetValue(const TCHAR *name, LPDWORD type_r, + bool GetValue(const char *name, LPDWORD type_r, LPBYTE data, LPDWORD length_r) const noexcept { return RegQueryValueEx(h, name, nullptr, type_r, data, length_r) == ERROR_SUCCESS; @@ -58,19 +58,19 @@ class RegistryKey { * * @return true on success */ - bool GetValue(const TCHAR *name, std::span value) const noexcept { + bool GetValue(const char *name, std::span value) const noexcept { const auto s = std::as_writable_bytes(value); DWORD type, length = s.size(); return GetValue(name, &type, (LPBYTE)s.data(), &length) && type == REG_SZ; } - bool EnumKey(DWORD idx, std::span name) const noexcept { + bool EnumKey(DWORD idx, std::span name) const noexcept { DWORD name_max_size = (DWORD)name.size(); return RegEnumKeyEx(h, idx, name.data(), &name_max_size, nullptr, nullptr, nullptr, nullptr) == ERROR_SUCCESS; } - bool EnumValue(DWORD idx, std::span name, LPDWORD type, + bool EnumValue(DWORD idx, std::span name, LPDWORD type, std::span value) const noexcept { DWORD name_max_size = (DWORD)name.size(); DWORD value_max_size = (DWORD)name.size(); diff --git a/src/ui/canvas/custom/MoreCanvas.cpp b/src/ui/canvas/custom/MoreCanvas.cpp index 0c93d26327f..64ed06f1bdc 100644 --- a/src/ui/canvas/custom/MoreCanvas.cpp +++ b/src/ui/canvas/custom/MoreCanvas.cpp @@ -49,9 +49,9 @@ Canvas::DrawFormattedText(const PixelRect r, const tstring_view text, ? UINT_MAX : (r.GetHeight() + skip - 1) / skip; - TCHAR *const duplicated = new TCHAR[text.size() + 1], *p = duplicated; + char *const duplicated = new char[text.size() + 1], *p = duplicated; unsigned lines = 1; - for (TCHAR ch : text) { + for (char ch : text) { if (ch == _T('\n')) { /* explicit line break */ @@ -76,7 +76,7 @@ Canvas::DrawFormattedText(const PixelRect r, const tstring_view text, // no grouping of multiple spaces for (size_t i = 0; i < len; i += strlen(duplicated + i) + 1) { PixelSize sz = CalcTextSize(duplicated + i); - TCHAR *prev_p = nullptr; + char *prev_p = nullptr; // remove words from behind till line fits or no more space is found while (sz.width > r.GetWidth() && diff --git a/src/ui/canvas/gdi/GdiPlusBitmap.cpp b/src/ui/canvas/gdi/GdiPlusBitmap.cpp index d48daf8ff24..31ddb2119cc 100644 --- a/src/ui/canvas/gdi/GdiPlusBitmap.cpp +++ b/src/ui/canvas/gdi/GdiPlusBitmap.cpp @@ -36,7 +36,7 @@ GdiShutdown() //---------------------------------------------------------------------------- // can load: BMP, GIF, JPEG, PNG, TIFF, Exif, WMF, and EMF HBITMAP -GdiLoadImage(const TCHAR* filename) +GdiLoadImage(const char* filename) { HBITMAP result = nullptr; Gdiplus::Bitmap bitmap(UTF8ToWide(filename).c_str(), false); diff --git a/src/ui/canvas/gdi/GdiPlusBitmap.hpp b/src/ui/canvas/gdi/GdiPlusBitmap.hpp index a7d284cc5f5..6b83bbbb3b5 100644 --- a/src/ui/canvas/gdi/GdiPlusBitmap.hpp +++ b/src/ui/canvas/gdi/GdiPlusBitmap.hpp @@ -8,7 +8,7 @@ #include #include -HBITMAP GdiLoadImage(const TCHAR* filename); +HBITMAP GdiLoadImage(const char* filename); void GdiStartup(); void GdiShutdown(); #endif // _WIN32 && USE_GDI diff --git a/src/ui/control/LargeTextWindow.hpp b/src/ui/control/LargeTextWindow.hpp index 52ff28922aa..7477b97e6d2 100644 --- a/src/ui/control/LargeTextWindow.hpp +++ b/src/ui/control/LargeTextWindow.hpp @@ -77,7 +77,7 @@ class LargeTextWindow : public NativeWindow { } #endif - void SetText(const TCHAR *text); + void SetText(const char *text); /** * Scroll the contents of a multi-line control by the specified diff --git a/src/ui/control/TerminalWindow.hpp b/src/ui/control/TerminalWindow.hpp index 2bdae608bda..395033ead3f 100644 --- a/src/ui/control/TerminalWindow.hpp +++ b/src/ui/control/TerminalWindow.hpp @@ -17,7 +17,7 @@ class TerminalWindow : public PaintWindow { unsigned cursor_x, cursor_y; PixelSize cell_size; - AllocatedGrid data; + AllocatedGrid data; public: TerminalWindow(const TerminalLook &_look):look(_look) {} diff --git a/src/ui/control/custom/LargeTextWindow.cpp b/src/ui/control/custom/LargeTextWindow.cpp index 923b5056367..78073615bf0 100644 --- a/src/ui/control/custom/LargeTextWindow.cpp +++ b/src/ui/control/custom/LargeTextWindow.cpp @@ -25,7 +25,7 @@ LargeTextWindow::GetVisibleRows() const unsigned LargeTextWindow::GetRowCount() const { - const TCHAR *str = value.c_str(); + const char *str = value.c_str(); unsigned row_count = 1; while ((str = StringFind(str, _T('\n'))) != nullptr) { str++; @@ -179,7 +179,7 @@ LargeTextWindow::OnMouseDown([[maybe_unused]] PixelPoint p) noexcept } void -LargeTextWindow::SetText(const TCHAR *text) +LargeTextWindow::SetText(const char *text) { if (text != nullptr) value = text; diff --git a/src/ui/control/gdi/LargeTextWindow.cpp b/src/ui/control/gdi/LargeTextWindow.cpp index 8196c171b4c..4e4a0057fc4 100644 --- a/src/ui/control/gdi/LargeTextWindow.cpp +++ b/src/ui/control/gdi/LargeTextWindow.cpp @@ -17,16 +17,16 @@ LargeTextWindow::Create(ContainerWindow &parent, PixelRect rc, } void -LargeTextWindow::SetText(const TCHAR *text) +LargeTextWindow::SetText(const char *text) { // Replace \n by \r\r\n to enable usage of line-breaks in edit control unsigned size = strlen(text); - const std::unique_ptr allocation(new TCHAR[size * 3 + 1]); - TCHAR *buffer = allocation.get(); + const std::unique_ptr allocation(new char[size * 3 + 1]); + char *buffer = allocation.get(); - const TCHAR* p2 = text; - TCHAR* p3 = buffer; + const char* p2 = text; + char* p3 = buffer; for (; *p2 != _T('\0'); p2++) { if (*p2 == _T('\n')) { *p3 = _T('\r'); diff --git a/src/ui/window/PaintWindow.hpp b/src/ui/window/PaintWindow.hpp index 476d9feacfe..cb028f42ec5 100644 --- a/src/ui/window/PaintWindow.hpp +++ b/src/ui/window/PaintWindow.hpp @@ -29,12 +29,12 @@ class PaintWindow : public Window { Create(&parent, rc, style); } #else /* USE_WINUSER */ - void Create(ContainerWindow *parent, const TCHAR *cls, PixelRect rc, + void Create(ContainerWindow *parent, const char *cls, PixelRect rc, const WindowStyle style=WindowStyle()) noexcept { Window::Create(parent, cls, nullptr, rc, style); } - void Create(ContainerWindow &parent, const TCHAR *cls, PixelRect rc, + void Create(ContainerWindow &parent, const char *cls, PixelRect rc, const WindowStyle style=WindowStyle()) noexcept { Create(&parent, cls, rc, style); } diff --git a/src/ui/window/SingleWindow.hpp b/src/ui/window/SingleWindow.hpp index 26a68a4f850..2293cd71b80 100644 --- a/src/ui/window/SingleWindow.hpp +++ b/src/ui/window/SingleWindow.hpp @@ -20,7 +20,7 @@ struct Event; */ class SingleWindow : public TopWindow { #ifdef USE_WINUSER - static constexpr const TCHAR *class_name = _T("XCSoarMain"); + static constexpr const char *class_name = _T("XCSoarMain"); #endif std::forward_list dialogs; @@ -38,7 +38,7 @@ class SingleWindow : public TopWindow { /** * Throws on error. */ - void Create(const TCHAR *text, PixelSize size, + void Create(const char *text, PixelSize size, TopWindowStyle style=TopWindowStyle()) { #ifdef USE_WINUSER TopWindow::Create(class_name, text, size, style); diff --git a/src/ui/window/TopWindow.hpp b/src/ui/window/TopWindow.hpp index 212c7a460df..0ee348ffd57 100644 --- a/src/ui/window/TopWindow.hpp +++ b/src/ui/window/TopWindow.hpp @@ -232,10 +232,10 @@ class TopWindow : public ContainerWindow { * Throws on error. */ #ifdef USE_WINUSER - void Create(const TCHAR *cls, const TCHAR *text, PixelSize size, + void Create(const char *cls, const char *text, PixelSize size, TopWindowStyle style=TopWindowStyle()); #else - void Create(const TCHAR *text, PixelSize size, + void Create(const char *text, PixelSize size, TopWindowStyle style=TopWindowStyle()); #endif @@ -244,7 +244,7 @@ class TopWindow : public ContainerWindow { /** * Throws on error. */ - void CreateNative(const TCHAR *text, PixelSize size, + void CreateNative(const char *text, PixelSize size, TopWindowStyle style); public: @@ -261,9 +261,9 @@ class TopWindow : public ContainerWindow { #if !defined(USE_WINUSER) && !defined(ENABLE_SDL) #if defined(ANDROID) || defined(USE_FB) || defined(USE_EGL) || defined(USE_GLX) || defined(USE_VFB) - void SetCaption(const TCHAR *) noexcept {} + void SetCaption(const char *) noexcept {} #else - void SetCaption(const TCHAR *caption) noexcept; + void SetCaption(const char *caption) noexcept; #endif #endif diff --git a/src/ui/window/Window.hpp b/src/ui/window/Window.hpp index 9ca5e6595f2..644c241c471 100644 --- a/src/ui/window/Window.hpp +++ b/src/ui/window/Window.hpp @@ -237,7 +237,7 @@ class Window { void Create(ContainerWindow *parent, const PixelRect rc, const WindowStyle window_style=WindowStyle()) noexcept; #else - void Create(ContainerWindow *parent, const TCHAR *cls, const TCHAR *text, + void Create(ContainerWindow *parent, const char *cls, const char *text, const PixelRect rc, const WindowStyle window_style=WindowStyle()) noexcept; diff --git a/src/ui/window/custom/TopWindow.cpp b/src/ui/window/custom/TopWindow.cpp index c9ac943b2ef..51c8b7c8030 100644 --- a/src/ui/window/custom/TopWindow.cpp +++ b/src/ui/window/custom/TopWindow.cpp @@ -44,7 +44,7 @@ TopWindow::~TopWindow() noexcept } void -TopWindow::Create([[maybe_unused]] const TCHAR *text, PixelSize size, +TopWindow::Create([[maybe_unused]] const char *text, PixelSize size, TopWindowStyle style) { invalidated = true; diff --git a/src/ui/window/gdi/TopWindow.cpp b/src/ui/window/gdi/TopWindow.cpp index 3a95c7db627..f551436b662 100644 --- a/src/ui/window/gdi/TopWindow.cpp +++ b/src/ui/window/gdi/TopWindow.cpp @@ -10,7 +10,7 @@ namespace UI { void -TopWindow::Create(const TCHAR *cls, const TCHAR *text, PixelSize size, +TopWindow::Create(const char *cls, const char *text, PixelSize size, TopWindowStyle style) { hSavedFocus = nullptr; diff --git a/src/ui/window/gdi/Window.cpp b/src/ui/window/gdi/Window.cpp index eef6b6ff2ff..42ea5284675 100644 --- a/src/ui/window/gdi/Window.cpp +++ b/src/ui/window/gdi/Window.cpp @@ -12,7 +12,7 @@ #include void -Window::Create(ContainerWindow *parent, const TCHAR *cls, const TCHAR *text, +Window::Create(ContainerWindow *parent, const char *cls, const char *text, PixelRect rc, const WindowStyle window_style) noexcept { assert(IsScreenInitialized()); @@ -233,7 +233,7 @@ Window::OnMessage([[maybe_unused]] HWND _hWnd, UINT message, break; case WM_CHAR: - if (OnCharacter((TCHAR)wParam)) + if (OnCharacter((char)wParam)) /* true returned: message was handled */ return 0; diff --git a/src/ui/window/sdl/TopWindow.cpp b/src/ui/window/sdl/TopWindow.cpp index 1fc4e5543e3..561cc22476d 100644 --- a/src/ui/window/sdl/TopWindow.cpp +++ b/src/ui/window/sdl/TopWindow.cpp @@ -50,7 +50,7 @@ MakeSDLFlags([[maybe_unused]] bool full_screen, bool resizable) noexcept } void -TopWindow::CreateNative(const TCHAR *_text, PixelSize new_size, +TopWindow::CreateNative(const char *_text, PixelSize new_size, TopWindowStyle style) { const char *text = _text; diff --git a/src/ui/window/wayland/TopWindow.cpp b/src/ui/window/wayland/TopWindow.cpp index ecd6977f977..e392e72acf5 100644 --- a/src/ui/window/wayland/TopWindow.cpp +++ b/src/ui/window/wayland/TopWindow.cpp @@ -87,7 +87,7 @@ static const struct xdg_toplevel_listener toplevel_listener = { }; void -TopWindow::CreateNative(const TCHAR *text, PixelSize size, +TopWindow::CreateNative(const char *text, PixelSize size, TopWindowStyle) { auto compositor = event_queue->GetCompositor(); diff --git a/src/ui/window/x11/TopWindow.cpp b/src/ui/window/x11/TopWindow.cpp index 735c983d337..bac2b06aba1 100644 --- a/src/ui/window/x11/TopWindow.cpp +++ b/src/ui/window/x11/TopWindow.cpp @@ -21,7 +21,7 @@ namespace UI { void -TopWindow::CreateNative(const TCHAR *text, PixelSize size, +TopWindow::CreateNative(const char *text, PixelSize size, TopWindowStyle style) { const auto x_display = display.GetXDisplay(); diff --git a/src/unix/tchar.h b/src/unix/tchar.h index 9267c31f376..2475a4a0500 100644 --- a/src/unix/tchar.h +++ b/src/unix/tchar.h @@ -10,7 +10,6 @@ #include #endif -typedef char TCHAR; #define _stprintf sprintf #define _vstprintf vsprintf #define _vsntprintf vsnprintf diff --git a/src/util/ConvertString.hpp b/src/util/ConvertString.hpp index a049359124d..3f8b920167c 100644 --- a/src/util/ConvertString.hpp +++ b/src/util/ConvertString.hpp @@ -13,7 +13,7 @@ #include /** - * Convert a UTF-8 string to a TCHAR string. The source buffer passed + * Convert a UTF-8 string to a char string. The source buffer passed * to the constructor must be valid as long as this object is being * used. */ @@ -54,7 +54,7 @@ class UTF8ToWideConverter { }; /** - * Convert a TCHAR string to UTF-8. The source buffer passed to the + * Convert a char string to UTF-8. The source buffer passed to the * constructor must be valid as long as this object is being used. */ class WideToUTF8Converter { @@ -94,7 +94,7 @@ class WideToUTF8Converter { }; /** - * Convert a TCHAR string to ACP (Windows ANSI code page). The source + * Convert a char string to ACP (Windows ANSI code page). The source * buffer passed to the constructor must be valid as long as this * object is being used. */ diff --git a/src/util/DollarExpand.hpp b/src/util/DollarExpand.hpp index b74a4c9c87d..8c51dd3f03c 100644 --- a/src/util/DollarExpand.hpp +++ b/src/util/DollarExpand.hpp @@ -18,7 +18,7 @@ * buffer is too small, then the output is truncated silently. */ void -DollarExpand(const TCHAR *src, std::span dest, +DollarExpand(const char *src, std::span dest, std::invocable auto lookup_function) noexcept { while (true) { @@ -46,7 +46,7 @@ DollarExpand(const TCHAR *src, std::span dest, /* look up the name and copy the result to the destination buffer */ - const TCHAR *const expansion = lookup_function(name); + const char *const expansion = lookup_function(name); if (expansion != nullptr) { const tstring_view ex{expansion}; if (ex.size() >= dest.size()) diff --git a/src/util/EscapeBackslash.cpp b/src/util/EscapeBackslash.cpp index 738d3107376..54abaa16cb0 100644 --- a/src/util/EscapeBackslash.cpp +++ b/src/util/EscapeBackslash.cpp @@ -9,7 +9,7 @@ tstring_view::pointer UnescapeBackslash(tstring_view old_string) noexcept { - TCHAR buffer[2048]; // Note - max size of any string we cope with here ! + char buffer[2048]; // Note - max size of any string we cope with here ! tstring_view::size_type used = 0; diff --git a/src/util/RadixTree.hpp b/src/util/RadixTree.hpp index dadb81304e6..8686005fdef 100644 --- a/src/util/RadixTree.hpp +++ b/src/util/RadixTree.hpp @@ -16,7 +16,7 @@ #endif /** - * An associative container which maps TCHAR strings to arbitrary + * An associative container which maps char strings to arbitrary * objects. Each "key" may have multiple values. * * This class provides a sorted iterator, which is optimized for @@ -29,10 +29,10 @@ class RadixTree { template struct KeyVisitorAdapter { V &visitor; - const TCHAR *key; + const char *key; constexpr KeyVisitorAdapter(V &_visitor, - const TCHAR *_key) noexcept + const char *_key) noexcept :visitor(_visitor), key(_key) {} void operator()(const T &value) const { @@ -164,7 +164,7 @@ class RadixTree { Node *next_sibling = nullptr, *children = nullptr; LeafList leaves; - constexpr Node(const TCHAR *_label) noexcept + constexpr Node(const char *_label) noexcept :label(_label) {} Node(const Node &) = delete; @@ -180,7 +180,7 @@ class RadixTree { * StaticString, multiple chained Node objects are * created. */ - Node *CreateLeaf(const TCHAR *label, const T &value) const { + Node *CreateLeaf(const char *label, const T &value) const { Node *top = new Node(label), *bottom = top; while (strlen(label) >= Node::label.capacity()) { /* label too long for the Node's @@ -209,8 +209,8 @@ class RadixTree { * match (even if the node's label is longer). */ [[gnu::pure]] - const TCHAR *MatchKey(const TCHAR *key) const noexcept { - const TCHAR *l = label.c_str(); + const char *MatchKey(const char *key) const noexcept { + const char *l = label.c_str(); while (!StringIsEmpty(key) && *key == *l) { ++key; @@ -231,8 +231,8 @@ class RadixTree { * Returns nullptr if there is a mismatch. */ [[gnu::pure]] - const TCHAR *MatchPrefix(const TCHAR *prefix) const noexcept { - const TCHAR *l = label.c_str(); + const char *MatchPrefix(const char *prefix) const noexcept { + const char *l = label.c_str(); while (!StringIsEmpty(prefix) && !StringIsEmpty(l)) { if (*l != *prefix) @@ -246,7 +246,7 @@ class RadixTree { } [[gnu::pure]] - T *Get(const TCHAR *key) noexcept { + T *Get(const char *key) noexcept { if (StringIsEmpty(key)) /* found */ return leaves.GetFirstPointer(); @@ -258,7 +258,7 @@ class RadixTree { } [[gnu::pure]] - const T *Get(const TCHAR *key) const noexcept { + const T *Get(const char *key) const noexcept { if (StringIsEmpty(key)) /* found */ return leaves.GetFirstPointer(); @@ -271,7 +271,7 @@ class RadixTree { template [[gnu::pure]] - T *GetIf(const TCHAR *key, const P &predicate) noexcept { + T *GetIf(const char *key, const P &predicate) noexcept { if (StringIsEmpty(key)) /* found */ return leaves.GetIf(predicate); @@ -284,7 +284,7 @@ class RadixTree { template [[gnu::pure]] - const T *GetIf(const TCHAR *key, + const T *GetIf(const char *key, const P &predicate) const noexcept { if (StringIsEmpty(key)) /* found */ @@ -297,12 +297,12 @@ class RadixTree { } [[gnu::pure]] - TCHAR *Suggest(const TCHAR *prefix, TCHAR *dest, + char *Suggest(const char *prefix, char *dest, size_t max_length) const noexcept { if (StringIsEmpty(prefix)) { /* exact match - return the first character of all child nodes */ - TCHAR *retval = dest, *end = dest + max_length - 1; + char *retval = dest, *end = dest + max_length - 1; for (const Node *node = children; node != nullptr && dest < end; node = node->next_sibling) @@ -373,7 +373,7 @@ class RadixTree { /** * Remove all values with the specified key. */ - void RemoveValues(const TCHAR *key) noexcept { + void RemoveValues(const char *key) noexcept { assert(key != nullptr); if (StringIsEmpty(key)) { @@ -392,7 +392,7 @@ class RadixTree { * * @return true if a value was found and removed */ - bool RemoveValue(const TCHAR *key, const T &value) noexcept { + bool RemoveValue(const char *key, const T &value) noexcept { assert(key != nullptr); if (StringIsEmpty(key)) { @@ -426,7 +426,7 @@ class RadixTree { * This overload is used by VisitAllPairs(). */ template - void VisitValues(const TCHAR *prefix, V &visitor) const { + void VisitValues(const char *prefix, V &visitor) const { tstring key(prefix); key.append(label); @@ -464,7 +464,7 @@ class RadixTree { * alphabetic order. This overload is used by VisitAllPairs(). */ template - void VisitAllChildren(const TCHAR *prefix, V &visitor) const { + void VisitAllChildren(const char *prefix, V &visitor) const { tstring key(prefix); key.append(label); @@ -481,7 +481,7 @@ class RadixTree { * is only matched on children's labels. */ template - void VisitChildren(const TCHAR *key, V &visitor) { + void VisitChildren(const char *key, V &visitor) { VisitSiblings(children, key, visitor); } @@ -491,7 +491,7 @@ class RadixTree { * children's labels. */ template - void VisitChildren(const TCHAR *key, V &visitor) const { + void VisitChildren(const char *key, V &visitor) const { VisitSiblings(const_cast(children), key, visitor); } @@ -500,8 +500,8 @@ class RadixTree { * key is matched on this node's label first. */ template - void Visit(const TCHAR *key, V &visitor) { - const TCHAR *match = MatchPrefix(key); + void Visit(const char *key, V &visitor) { + const char *match = MatchPrefix(key); if (match == nullptr) return; @@ -516,8 +516,8 @@ class RadixTree { * key is matched on this node's label first. */ template - void Visit(const TCHAR *key, V &visitor) const { - const TCHAR *match = MatchPrefix(key); + void Visit(const char *key, V &visitor) const { + const char *match = MatchPrefix(key); if (match == nullptr) return; @@ -533,7 +533,7 @@ class RadixTree { * is only matched on children's labels. */ template - void VisitPrefixChildren(const TCHAR *prefix, V &visitor) { + void VisitPrefixChildren(const char *prefix, V &visitor) { if (StringIsEmpty(prefix)) VisitAllChildren(visitor); else @@ -547,7 +547,7 @@ class RadixTree { * is only matched on children's labels. */ template - void VisitPrefixChildren(const TCHAR *prefix, V &visitor) const { + void VisitPrefixChildren(const char *prefix, V &visitor) const { if (StringIsEmpty(prefix)) VisitAllChildren(visitor); else @@ -562,8 +562,8 @@ class RadixTree { * prefix is matched on this node's label first. */ template - void VisitPrefix(const TCHAR *prefix, V &visitor) { - const TCHAR *match = MatchPrefix(prefix); + void VisitPrefix(const char *prefix, V &visitor) { + const char *match = MatchPrefix(prefix); if (match == nullptr) return; @@ -581,8 +581,8 @@ class RadixTree { * prefix is matched on this node's label first. */ template - void VisitPrefix(const TCHAR *prefix, V &visitor) const { - const TCHAR *match = MatchPrefix(prefix); + void VisitPrefix(const char *prefix, V &visitor) const { + const char *match = MatchPrefix(prefix); if (match == nullptr) return; @@ -596,14 +596,14 @@ class RadixTree { struct Match { Node *node; - const TCHAR *key; + const char *key; constexpr Match(Node *_node, - const TCHAR *_key) noexcept + const char *_key) noexcept :node(_node), key(_key) {} [[gnu::pure]] - bool IsFullMatch(const TCHAR *key) const noexcept { + bool IsFullMatch(const char *key) const noexcept { return this->key != key && this->key >= key + node->label.length(); } }; @@ -615,10 +615,10 @@ class RadixTree { * of the key which was not used yet. */ [[gnu::pure]] - struct Match FindChild(const TCHAR *key) const noexcept { + struct Match FindChild(const char *key) const noexcept { Node *node = children, *prev = nullptr; while (node != nullptr) { - const TCHAR *label = node->label.c_str(); + const char *label = node->label.c_str(); if (key[0u] < label[0u]) return Match(prev, key); else if (key[0u] == label[0u]) @@ -635,7 +635,7 @@ class RadixTree { * Adds a new value relative to this node, possibly creating a * new node and/or splitting an existing node. */ - void Add(const TCHAR *key, const T &value) { + void Add(const char *key, const T &value) { assert(key != nullptr); if (StringIsEmpty(key)) { @@ -716,7 +716,7 @@ class RadixTree { * multiple values, any one is returned. */ [[gnu::pure]] - T &Get(const TCHAR *key, T &default_value) noexcept { + T &Get(const char *key, T &default_value) noexcept { T *value = root.get(key); return value != nullptr ? *value @@ -729,7 +729,7 @@ class RadixTree { * multiple values, any one is returned. */ [[gnu::pure]] - const T &Get(const TCHAR *key, const T &default_value) const noexcept { + const T &Get(const char *key, const T &default_value) const noexcept { const T *value = root.Get(key); return value != nullptr ? *value @@ -738,7 +738,7 @@ class RadixTree { template [[gnu::pure]] - T &GetIf(const TCHAR *key, T &default_value, const P &predicate) noexcept { + T &GetIf(const char *key, T &default_value, const P &predicate) noexcept { const T *value = root.GetIf(key, predicate); return value != nullptr ? *value @@ -747,7 +747,7 @@ class RadixTree { template [[gnu::pure]] - const T &GetIf(const TCHAR *key, const T &default_value, + const T &GetIf(const char *key, const T &default_value, const P &predicate) const noexcept { const T *value = root.GetIf(key, predicate); return value != nullptr @@ -769,7 +769,7 @@ class RadixTree { * occur in the tree */ [[gnu::pure]] - TCHAR *Suggest(const TCHAR *prefix, TCHAR *dest, + char *Suggest(const char *prefix, char *dest, size_t max_length) const noexcept { return root.Suggest(prefix, dest, max_length); } @@ -782,14 +782,14 @@ class RadixTree { * Add a new value with the specified key. Multiple values can * exist for one key. */ - void Add(const TCHAR *key, const T &value) { + void Add(const char *key, const T &value) { root.Add(key, value); } /** * Remove all values with the specified key. */ - void Remove(const TCHAR *key) noexcept { + void Remove(const char *key) noexcept { assert(key != nullptr); root.RemoveValues(key); @@ -800,7 +800,7 @@ class RadixTree { * * @return true if a value was found and removed */ - bool Remove(const TCHAR *key, const T &value) noexcept { + bool Remove(const char *key, const T &value) noexcept { assert(key != nullptr); return root.RemoveValue(key, value); @@ -837,7 +837,7 @@ class RadixTree { * Visit all values with the specified key. */ template - void Visit(const TCHAR *key, V &visitor) { + void Visit(const char *key, V &visitor) { root.Visit(key, visitor); } @@ -845,7 +845,7 @@ class RadixTree { * Visit all values with the specified key. */ template - void Visit(const TCHAR *key, V &visitor) const { + void Visit(const char *key, V &visitor) const { root.Visit(key, visitor); } @@ -854,7 +854,7 @@ class RadixTree { * order. */ template - void VisitPrefix(const TCHAR *prefix, V &visitor) { + void VisitPrefix(const char *prefix, V &visitor) { root.VisitPrefix(prefix, visitor); } @@ -863,7 +863,7 @@ class RadixTree { * order. */ template - void VisitPrefix(const TCHAR *prefix, V &visitor) const { + void VisitPrefix(const char *prefix, V &visitor) const { root.VisitPrefix(prefix, visitor); } diff --git a/src/util/TruncateString.cpp b/src/util/TruncateString.cpp index 20641f908ef..e57b167784a 100644 --- a/src/util/TruncateString.cpp +++ b/src/util/TruncateString.cpp @@ -24,9 +24,9 @@ CopyTruncateString(char *dest, size_t dest_size, const char *src) return CropIncompleteUTF8(dest); } -TCHAR * -CopyTruncateString(TCHAR *dest, size_t dest_size, - const TCHAR *src, size_t truncate) +char * +CopyTruncateString(char *dest, size_t dest_size, + const char *src, size_t truncate) { assert(dest != nullptr); assert(dest_size > 0); diff --git a/src/util/TruncateString.hpp b/src/util/TruncateString.hpp index 3393dfcd2c5..d0bf527d333 100644 --- a/src/util/TruncateString.hpp +++ b/src/util/TruncateString.hpp @@ -27,6 +27,6 @@ CopyTruncateString(char *dest, size_t dest_size, const char *src); * copy * @return a pointer to the end of the destination string */ -TCHAR * -CopyTruncateString(TCHAR *dest, size_t dest_size, - const TCHAR *src, size_t truncate); +char * +CopyTruncateString(char *dest, size_t dest_size, + const char *src, size_t truncate); diff --git a/test/src/FakeDialogs.cpp b/test/src/FakeDialogs.cpp index 7057545ad88..3c174c1b4cd 100644 --- a/test/src/FakeDialogs.cpp +++ b/test/src/FakeDialogs.cpp @@ -5,17 +5,17 @@ #include "Dialogs/DataField.hpp" int -ShowMessageBox([[maybe_unused]] const TCHAR *lpText, - [[maybe_unused]] const TCHAR *lpCaption, +ShowMessageBox([[maybe_unused]] const char *lpText, + [[maybe_unused]] const char *lpCaption, [[maybe_unused]] unsigned uType) noexcept { return -1; } bool -EditDataFieldDialog([[maybe_unused]] const TCHAR *caption, +EditDataFieldDialog([[maybe_unused]] const char *caption, [[maybe_unused]] DataField &df, - [[maybe_unused]] const TCHAR *help_text) + [[maybe_unused]] const char *help_text) { return false; } diff --git a/test/src/FakeHelpDialog.cpp b/test/src/FakeHelpDialog.cpp index 6a34d34ae2b..ac6a369dcfb 100644 --- a/test/src/FakeHelpDialog.cpp +++ b/test/src/FakeHelpDialog.cpp @@ -4,6 +4,6 @@ #include "Dialogs/HelpDialog.hpp" void -HelpDialog([[maybe_unused]] const TCHAR *caption, [[maybe_unused]] const TCHAR *text) +HelpDialog([[maybe_unused]] const char *caption, [[maybe_unused]] const char *text) { } diff --git a/test/src/FakeLanguage.cpp b/test/src/FakeLanguage.cpp index a653ad454cf..85752e6c825 100644 --- a/test/src/FakeLanguage.cpp +++ b/test/src/FakeLanguage.cpp @@ -5,8 +5,8 @@ #ifndef USE_LIBINTL -const TCHAR * -gettext(const TCHAR *text) +const char * +gettext(const char *text) { return text; } diff --git a/test/src/FakeListPicker.cpp b/test/src/FakeListPicker.cpp index fb32ef7c818..f92c84c26f8 100644 --- a/test/src/FakeListPicker.cpp +++ b/test/src/FakeListPicker.cpp @@ -4,9 +4,9 @@ #include "Dialogs/ComboPicker.hpp" bool -ComboPicker([[maybe_unused]] const TCHAR *caption, +ComboPicker([[maybe_unused]] const char *caption, [[maybe_unused]] DataField &df, - [[maybe_unused]] const TCHAR *help_text) + [[maybe_unused]] const char *help_text) { return false; } diff --git a/test/src/FakeMessage.cpp b/test/src/FakeMessage.cpp index a6487e3c30c..51b6d941720 100644 --- a/test/src/FakeMessage.cpp +++ b/test/src/FakeMessage.cpp @@ -6,8 +6,8 @@ #include void -Message::AddMessage(const TCHAR *text, - [[maybe_unused]] const TCHAR *data) noexcept +Message::AddMessage(const char *text, + [[maybe_unused]] const char *data) noexcept { _ftprintf(stderr, _T("%s\n"), text); } diff --git a/test/src/FakeProfile.cpp b/test/src/FakeProfile.cpp index 511ab77e9bd..95fb25c4d33 100644 --- a/test/src/FakeProfile.cpp +++ b/test/src/FakeProfile.cpp @@ -24,7 +24,7 @@ Profile::Get([[maybe_unused]] std::string_view key, bool Profile::Get([[maybe_unused]] std::string_view key, - std::span value) noexcept + std::span value) noexcept { value[0] = _T('\0'); return false; diff --git a/test/src/FlightTable.cpp b/test/src/FlightTable.cpp index 3f622f441b1..4fca9efdd76 100644 --- a/test/src/FlightTable.cpp +++ b/test/src/FlightTable.cpp @@ -23,7 +23,7 @@ class FlightCheck { unsigned slow_count, fast_count; public: - FlightCheck(const TCHAR *_name) + FlightCheck(const char *_name) :name(_name), year(0), month(0), day(0), previous_valid(false), takeoff_valid(false), diff --git a/test/src/KeyCodeDumper.cpp b/test/src/KeyCodeDumper.cpp index ba3692f5c45..b6930f3cd81 100644 --- a/test/src/KeyCodeDumper.cpp +++ b/test/src/KeyCodeDumper.cpp @@ -86,7 +86,7 @@ class KeyCodeDumper : public PaintWindow { unsigned text_height = canvas.CalcTextSize(_T("W")).height; for (int i = num_events - 1, y = 4; i >= 0; --i, y += text_height) { const struct key_event &event = events[i]; - TCHAR buffer[64]; + char buffer[64]; _stprintf(buffer, _T("key %s = 0x%x"), event.down ? _T("down") : _T("up"), event.code); canvas.DrawText({4, y}, buffer); diff --git a/test/src/LoadImage.cpp b/test/src/LoadImage.cpp index 91137a29cda..efb9d5db794 100644 --- a/test/src/LoadImage.cpp +++ b/test/src/LoadImage.cpp @@ -28,7 +28,7 @@ ParseCommandLine(Args &args) path = args.ExpectNextPath(); #ifdef USE_GDI - TCHAR *endptr; + char *endptr; unsigned _id = ParseUnsigned(path.c_str(), &endptr); if (StringIsEmpty(endptr)) id = ResourceId(_id); diff --git a/test/src/RunAirspaceWarningDialog.cpp b/test/src/RunAirspaceWarningDialog.cpp index 440b7fc2c26..7385660dd2e 100644 --- a/test/src/RunAirspaceWarningDialog.cpp +++ b/test/src/RunAirspaceWarningDialog.cpp @@ -27,7 +27,7 @@ #include #include -void VisitDataFiles([[maybe_unused]] const TCHAR* filter, +void VisitDataFiles([[maybe_unused]] const char* filter, [[maybe_unused]] File::Visitor &visitor) {} InterfaceBlackboard CommonInterface::Private::blackboard; @@ -42,7 +42,7 @@ dlgAirspaceDetails([[maybe_unused]] ConstAirspacePtr the_airspace, void ActionInterface::SetActiveFrequency([[maybe_unused]] const RadioFrequency freq, - [[maybe_unused]] const TCHAR * freq_name, + [[maybe_unused]] const char * freq_name, [[maybe_unused]] bool to_devices) noexcept { } diff --git a/test/src/RunCanvas.cpp b/test/src/RunCanvas.cpp index eda60b497e0..f9fae24a6d2 100644 --- a/test/src/RunCanvas.cpp +++ b/test/src/RunCanvas.cpp @@ -98,7 +98,7 @@ class TestWindow final : public UI::SingleWindow { { width * 5, 3000 }, }; - const TCHAR *label; + const char *label; switch (page) { case 0: canvas.DrawSegment(center, diff --git a/test/src/RunChartRenderer.cpp b/test/src/RunChartRenderer.cpp index 315afede39a..5b3002ce201 100644 --- a/test/src/RunChartRenderer.cpp +++ b/test/src/RunChartRenderer.cpp @@ -12,7 +12,7 @@ #include "util/Macros.hpp" #include "Renderer/ChartRenderer.hpp" -static const TCHAR *const chart_names[] = { +static const char *const chart_names[] = { _T("Line"), _T("Line2"), }; diff --git a/test/src/RunCirclingWind.cpp b/test/src/RunCirclingWind.cpp index 76f4e931bf2..455f162f854 100644 --- a/test/src/RunCirclingWind.cpp +++ b/test/src/RunCirclingWind.cpp @@ -43,7 +43,7 @@ int main(int argc, char **argv) CirclingWind::Result result = circling_wind.NewSample(replay->Basic(), replay->Calculated()); if (result.quality > 0) { - TCHAR time_buffer[32]; + char time_buffer[32]; FormatTime(time_buffer, replay->Basic().time); _tprintf(_T("%s %d %d %g\n"), diff --git a/test/src/RunDeclare.cpp b/test/src/RunDeclare.cpp index 793fa91696f..da850a41aa3 100644 --- a/test/src/RunDeclare.cpp +++ b/test/src/RunDeclare.cpp @@ -71,7 +71,7 @@ NMEAParser::TimeHasAdvanced([[maybe_unused]] TimeStamp this_time, } static Waypoint -MakeWaypoint(const TCHAR *name, int altitude, +MakeWaypoint(const char *name, int altitude, double longitude, double latitude) { Waypoint wp(GeoPoint(Angle::Degrees(longitude), @@ -87,7 +87,7 @@ try { Args args(argc, argv, "[--through DRIVER0] DRIVER PORT BAUD"); tstring _through_name; - const TCHAR *through_name = NULL; + const char *through_name = NULL; const char *a; while ((a = args.PeekNext()) != NULL && *a == '-') { @@ -100,7 +100,7 @@ try { } tstring _driver_name = args.ExpectNextT(); - const TCHAR *driver_name = _driver_name.c_str(); + const char *driver_name = _driver_name.c_str(); DebugPort debug_port(args); args.ExpectEnd(); diff --git a/test/src/RunEnableNMEA.cpp b/test/src/RunEnableNMEA.cpp index fe011b2b986..c1c6686d9e2 100644 --- a/test/src/RunEnableNMEA.cpp +++ b/test/src/RunEnableNMEA.cpp @@ -64,7 +64,7 @@ try { Args args(argc, argv, "DRIVER PORT BAUD"); tstring _driver_name = args.ExpectNextT(); - const TCHAR *driver_name = _driver_name.c_str(); + const char *driver_name = _driver_name.c_str(); DebugPort debug_port(args); args.ExpectEnd(); diff --git a/test/src/RunExternalWind.cpp b/test/src/RunExternalWind.cpp index 062c56dbf9a..34867d7eb8e 100644 --- a/test/src/RunExternalWind.cpp +++ b/test/src/RunExternalWind.cpp @@ -27,7 +27,7 @@ int main(int argc, char **argv) if (basic.external_wind_available.Modified(last_available)) { last_available = basic.external_wind_available; - TCHAR time_buffer[32]; + char time_buffer[32]; FormatTime(time_buffer, basic.time); _tprintf(_T("%s %d %g\n"), diff --git a/test/src/RunFlarmUtils.cpp b/test/src/RunFlarmUtils.cpp index 105abacf69c..b27b8846738 100644 --- a/test/src/RunFlarmUtils.cpp +++ b/test/src/RunFlarmUtils.cpp @@ -24,7 +24,7 @@ static void ChangePilot(FlarmDevice &flarm, OperationEnvironment &env) { while (true) { - TCHAR old_pilot_name[64]; + char old_pilot_name[64]; if (flarm.GetPilot(old_pilot_name, 64, env)) _tprintf(_T("Old pilot name: \"%s\"\n"), old_pilot_name); @@ -54,7 +54,7 @@ static void ChangeCoPilot(FlarmDevice &flarm, OperationEnvironment &env) { while (true) { - TCHAR old_copilot_name[64]; + char old_copilot_name[64]; if (flarm.GetCoPilot(old_copilot_name, 64, env)) _tprintf(_T("Old copilot name: \"%s\"\n"), old_copilot_name); @@ -84,7 +84,7 @@ static void ChangePlaneType(FlarmDevice &flarm, OperationEnvironment &env) { while (true) { - TCHAR old_plane_type[64]; + char old_plane_type[64]; if (flarm.GetPlaneType(old_plane_type, 64, env)) _tprintf(_T("Old plane type: \"%s\"\n"), old_plane_type); @@ -114,7 +114,7 @@ static void ChangeRegistration(FlarmDevice &flarm, OperationEnvironment &env) { while (true) { - TCHAR old_registration[64]; + char old_registration[64]; if (flarm.GetPlaneRegistration(old_registration, 64, env)) _tprintf(_T("Old plane registratio: \"%s\"\n"), old_registration); @@ -144,7 +144,7 @@ static void ChangeCompetitionId(FlarmDevice &flarm, OperationEnvironment &env) { while (true) { - TCHAR old_id[64]; + char old_id[64]; if (flarm.GetCompetitionId(old_id, 64, env)) _tprintf(_T("Old competition id: \"%s\"\n"), old_id); @@ -174,7 +174,7 @@ static void ChangeCompetitionClass(FlarmDevice &flarm, OperationEnvironment &env) { while (true) { - TCHAR old_comp_class[64]; + char old_comp_class[64]; if (flarm.GetCompetitionClass(old_comp_class, 64, env)) _tprintf(_T("Old competition class: \"%s\"\n"), old_comp_class); diff --git a/test/src/RunFlyingComputer.cpp b/test/src/RunFlyingComputer.cpp index fd856dd5156..33ddc98f75f 100644 --- a/test/src/RunFlyingComputer.cpp +++ b/test/src/RunFlyingComputer.cpp @@ -10,9 +10,9 @@ #include static void -LogEvent(const TCHAR *event, TimeStamp time, const GeoPoint &location) noexcept +LogEvent(const char *event, TimeStamp time, const GeoPoint &location) noexcept { - TCHAR time_buffer[32]; + char time_buffer[32]; FormatTime(time_buffer, time); _tprintf(_T("%s %s %s\n"), time_buffer, diff --git a/test/src/RunIGCWriter.cpp b/test/src/RunIGCWriter.cpp index 0e9d06a34fd..77f491edac9 100644 --- a/test/src/RunIGCWriter.cpp +++ b/test/src/RunIGCWriter.cpp @@ -23,7 +23,7 @@ int main(int argc, char **argv) if (!replay->Next()) return 0; - const TCHAR *driver_name = _T("Unknown"); + const char *driver_name = _T("Unknown"); IGCWriter writer(output_file); writer.WriteHeader(replay->Basic().date_time_utc, _T("Manfred Mustermann"), _T("Manuela Mustermann"), diff --git a/test/src/RunInputParser.cpp b/test/src/RunInputParser.cpp index b69dc9bd8f9..f507f705c82 100644 --- a/test/src/RunInputParser.cpp +++ b/test/src/RunInputParser.cpp @@ -16,7 +16,7 @@ pt2Event InputEvents::findEvent(tstring_view name) noexcept { union { - const TCHAR *in; + const char *in; pt2Event out; } u; @@ -25,13 +25,13 @@ InputEvents::findEvent(tstring_view name) noexcept } int -InputEvents::findGCE([[maybe_unused]] const TCHAR *data) +InputEvents::findGCE([[maybe_unused]] const char *data) { return -1; } int -InputEvents::findNE([[maybe_unused]] const TCHAR *data) +InputEvents::findNE([[maybe_unused]] const char *data) { return -1; } @@ -40,7 +40,7 @@ static void Dump(InputConfig::Event &event, unsigned id) { _tprintf(_T(" Event[%u]: '%s' misc='%s'\n"), id, - (const TCHAR *)event.event, event.misc); + (const char *)event.event, event.misc); } int main(int argc, char **argv) diff --git a/test/src/RunListControl.cpp b/test/src/RunListControl.cpp index 0dfc63bd335..5946b7adfe6 100644 --- a/test/src/RunListControl.cpp +++ b/test/src/RunListControl.cpp @@ -12,7 +12,7 @@ static void PaintItemCallback(Canvas &canvas, const PixelRect rc, unsigned idx) { - TCHAR text[32]; + char text[32]; _stprintf(text, _T("%u"), idx); canvas.DrawText(rc.WithPadding(2).GetTopLeft(), text); } diff --git a/test/src/RunNOAADownloader.cpp b/test/src/RunNOAADownloader.cpp index ccfa90eb272..76b706f1df6 100644 --- a/test/src/RunNOAADownloader.cpp +++ b/test/src/RunNOAADownloader.cpp @@ -47,20 +47,20 @@ DisplayParsedMETAR(const NOAAStore::Item &station) FormatGeoPoint(parsed.location, CoordinateFormat::DDMMSS).c_str()); if (parsed.qnh_available) { - TCHAR buffer[256]; + char buffer[256]; FormatUserPressure(parsed.qnh, buffer); _tprintf(_T("QNH: %s\n"), buffer); } if (parsed.wind_available) { - TCHAR buffer[256]; + char buffer[256]; FormatUserWindSpeed(parsed.wind.norm, buffer); _tprintf(_T("Wind: %.0f" DEG " %s\n"), (double)parsed.wind.bearing.Degrees(), buffer); } if (parsed.temperatures_available) { - TCHAR buffer[256]; + char buffer[256]; FormatUserTemperature(parsed.temperature, buffer); _tprintf(_T("Temperature: %s\n"), buffer); FormatUserTemperature(parsed.dew_point, buffer); @@ -68,7 +68,7 @@ DisplayParsedMETAR(const NOAAStore::Item &station) } if (parsed.visibility_available) { - TCHAR buffer[256]; + char buffer[256]; if (parsed.visibility >= 9999) strcpy(buffer, _T("unlimited")); else { diff --git a/test/src/RunProfileListDialog.cpp b/test/src/RunProfileListDialog.cpp index 5fb16b7b135..3c88cd09120 100644 --- a/test/src/RunProfileListDialog.cpp +++ b/test/src/RunProfileListDialog.cpp @@ -10,9 +10,9 @@ #include "Dialogs/DataField.hpp" bool -EditDataFieldDialog([[maybe_unused]] const TCHAR *caption, +EditDataFieldDialog([[maybe_unused]] const char *caption, [[maybe_unused]] DataField &df, - [[maybe_unused]] const TCHAR *help_text) + [[maybe_unused]] const char *help_text) { return false; } diff --git a/test/src/RunRenderOZ.cpp b/test/src/RunRenderOZ.cpp index c81d06c7bf6..cc45a9fa931 100644 --- a/test/src/RunRenderOZ.cpp +++ b/test/src/RunRenderOZ.cpp @@ -29,7 +29,7 @@ enum { NUM_OZ_TYPES = 12, }; -static const TCHAR *const oz_type_names[NUM_OZ_TYPES] = { +static const char *const oz_type_names[NUM_OZ_TYPES] = { _T("Line"), _T("Cylinder"), _T("MAT Cylinder"), diff --git a/test/src/RunTaskEditorDialog.cpp b/test/src/RunTaskEditorDialog.cpp index e01901c555e..54f499302c3 100644 --- a/test/src/RunTaskEditorDialog.cpp +++ b/test/src/RunTaskEditorDialog.cpp @@ -65,7 +65,7 @@ LoadFiles() static void CreateDefaultTask(TaskManager &task_manager, const Waypoints &way_points) { - const TCHAR start_name[] = _T("Bergneustadt"); + const char start_name[] = _T("Bergneustadt"); task_manager.set_factory(OrderedTask::FactoryType::MIXED); AbstractTaskFactory &factory = task_manager.GetFactory(); diff --git a/test/src/RunTextEntry.cpp b/test/src/RunTextEntry.cpp index 8aa8ae59dd7..edf48ce7080 100644 --- a/test/src/RunTextEntry.cpp +++ b/test/src/RunTextEntry.cpp @@ -13,6 +13,6 @@ static void Main([[maybe_unused]] TestMainWindow &main_window) { - TCHAR text[64] = _T(""); + char text[64] = _T(""); TextEntryDialog(text, ARRAY_SIZE(text), _T("The caption")); } diff --git a/test/src/RunWaveComputer.cpp b/test/src/RunWaveComputer.cpp index 9d993ad2b13..0ed640d5292 100644 --- a/test/src/RunWaveComputer.cpp +++ b/test/src/RunWaveComputer.cpp @@ -39,7 +39,7 @@ int main(int argc, char **argv) delete replay; for (const auto &w : result.waves) { - TCHAR time_buffer[32]; + char time_buffer[32]; if (w.time.IsDefined()) FormatTime(time_buffer, w.time); else diff --git a/test/src/RunWindComputer.cpp b/test/src/RunWindComputer.cpp index 01d6fa33361..69ab77c042c 100644 --- a/test/src/RunWindComputer.cpp +++ b/test/src/RunWindComputer.cpp @@ -52,7 +52,7 @@ int main(int argc, char **argv) replay->SetCalculated()); if (calculated.estimated_wind_available.Modified(last)) { - TCHAR time_buffer[32]; + char time_buffer[32]; FormatTime(time_buffer, replay->Basic().time); _tprintf(_T("%s %d %g\n"), diff --git a/test/src/RunWindEKF.cpp b/test/src/RunWindEKF.cpp index e05a6e65995..20e36b99997 100644 --- a/test/src/RunWindEKF.cpp +++ b/test/src/RunWindEKF.cpp @@ -40,7 +40,7 @@ int main(int argc, char **argv) WindEKFGlue::Result result = wind_ekf.Update(data, replay->Calculated()); if (result.quality > 0) { - TCHAR time_buffer[32]; + char time_buffer[32]; FormatTime(time_buffer, data.time); _tprintf(_T("%s %d %g %g %g %d\n"), time_buffer, diff --git a/test/src/TestAirspaceParser.cpp b/test/src/TestAirspaceParser.cpp index 0de66a3d1c1..932c0a95d66 100644 --- a/test/src/TestAirspaceParser.cpp +++ b/test/src/TestAirspaceParser.cpp @@ -18,7 +18,7 @@ struct AirspaceClassTestCouple { - const TCHAR* name; + const char* name; AirspaceClass asclass; }; diff --git a/test/src/TestByteSizeFormatter.cpp b/test/src/TestByteSizeFormatter.cpp index dad3f2cfa89..c848087b3b1 100644 --- a/test/src/TestByteSizeFormatter.cpp +++ b/test/src/TestByteSizeFormatter.cpp @@ -10,7 +10,7 @@ int main() { plan_tests(31); - TCHAR buffer[256]; + char buffer[256]; FormatByteSize(buffer, ARRAY_SIZE(buffer), 0); ok1(StringIsEqual(buffer, _T("0 B"))); diff --git a/test/src/TestGRecord.cpp b/test/src/TestGRecord.cpp index 8b0f5a44e62..35f9a5a13a1 100644 --- a/test/src/TestGRecord.cpp +++ b/test/src/TestGRecord.cpp @@ -10,7 +10,7 @@ #include static void -CheckGRecord(const TCHAR *path) +CheckGRecord(const char *path) { GRecord grecord; grecord.Initialize(); diff --git a/test/src/TestGeoPointFormatter.cpp b/test/src/TestGeoPointFormatter.cpp index 8760dfbe5cf..0277cbf5740 100644 --- a/test/src/TestGeoPointFormatter.cpp +++ b/test/src/TestGeoPointFormatter.cpp @@ -7,8 +7,8 @@ #include "TestUtil.hpp" static bool -StringIsEqualWildcard(const TCHAR *string1, const TCHAR *string2, - TCHAR wildcard = _T('*')) +StringIsEqualWildcard(const char *string1, const char *string2, + char wildcard = _T('*')) { while (*string1 == *string2 || *string1 == wildcard || @@ -26,7 +26,7 @@ int main() { plan_tests(14); - TCHAR buffer[256]; + char buffer[256]; GeoPoint location1(Angle::Degrees(8.466322), Angle::Degrees(49.487153)); diff --git a/test/src/TestIGCFilenameFormatter.cpp b/test/src/TestIGCFilenameFormatter.cpp index 6422a607a5b..6a4a53d419a 100644 --- a/test/src/TestIGCFilenameFormatter.cpp +++ b/test/src/TestIGCFilenameFormatter.cpp @@ -9,7 +9,7 @@ static void TestShort() { - TCHAR buffer[256]; + char buffer[256]; FormatIGCFilename(buffer, BrokenDate(2012, 2, 10), _T('T'), _T("ABC"), 1); ok1(StringIsEqual(buffer, _T("22ATABC1.igc"))); @@ -24,7 +24,7 @@ TestShort() static void TestLong() { - TCHAR buffer[256]; + char buffer[256]; FormatIGCFilenameLong(buffer, BrokenDate(2012, 2, 10), _T("XYZ"), _T("ABC"), 1); @@ -42,7 +42,7 @@ TestLong() static void TestChar() { - TCHAR buffer[256]; + char buffer[256]; FormatIGCFilename(buffer, BrokenDate(2012, 2, 10), 'T', "ABC", 1); ok1(StringIsEqual(buffer, _T("22ATABC1.igc"))); diff --git a/test/src/TestPolars.cpp b/test/src/TestPolars.cpp index c42e2995cca..27c50a938b7 100644 --- a/test/src/TestPolars.cpp +++ b/test/src/TestPolars.cpp @@ -83,7 +83,7 @@ TestBuiltInPolars() } struct PerformanceItem { - const TCHAR* name; + const char* name; bool check_best_LD; double best_LD; bool check_best_LD_speed; @@ -125,7 +125,7 @@ ValuePlausible(double ref, double used, double threshold = 0.05) [[gnu::pure]] static auto -GetPolarByName(const TCHAR *name) noexcept +GetPolarByName(const char *name) noexcept { for (const auto &i : PolarStore::GetAll()) if (StringIsEqual(i.name, name)) @@ -138,7 +138,7 @@ static void TestBuiltInPolarsPlausibility() { for(unsigned i = 0; i < ARRAY_SIZE(performanceData); i++) { - const TCHAR *si = performanceData[i].name; + const char *si = performanceData[i].name; WideToUTF8Converter polarName(si); const auto polar = GetPolarByName(si); PolarCoefficients pc = polar.CalculateCoefficients(); diff --git a/test/src/TestRadixTree.cpp b/test/src/TestRadixTree.cpp index 373efed278d..e06da1025c8 100644 --- a/test/src/TestRadixTree.cpp +++ b/test/src/TestRadixTree.cpp @@ -28,7 +28,7 @@ all_sum(const RadixTree &rt) } static int -prefix_sum(const RadixTree &rt, const TCHAR *prefix) +prefix_sum(const RadixTree &rt, const char *prefix) { Sum sum; rt.VisitPrefix(prefix, sum); @@ -39,7 +39,7 @@ template struct AscendingKeyVisitor { tstring last; - void operator()(const TCHAR *key, [[maybe_unused]] const T &value) { + void operator()(const char *key, [[maybe_unused]] const T &value) { ok1(last.compare(key) <= 0); last = key; } @@ -57,7 +57,7 @@ int main() { plan_tests(86); - TCHAR buffer[64], *suggest; + char buffer[64], *suggest; RadixTree irt; irt.Add(_T("foo"), 42); diff --git a/test/src/TestTimeFormatter.cpp b/test/src/TestTimeFormatter.cpp index 035ba3bb021..bea7c91680a 100644 --- a/test/src/TestTimeFormatter.cpp +++ b/test/src/TestTimeFormatter.cpp @@ -9,7 +9,7 @@ static void TestFormat() { - TCHAR buffer[256]; + char buffer[256]; FormatTime(buffer, FloatDuration{}); ok1(StringIsEqual(buffer, _T("00:00:00"))); @@ -48,7 +48,7 @@ TestFormat() static void TestFormatLong() { - TCHAR buffer[256]; + char buffer[256]; FormatTimeLong(buffer, {}); ok1(StringIsEqual(buffer, _T("00:00:00.000"))); @@ -87,7 +87,7 @@ TestFormatLong() static void TestHHMM() { - TCHAR buffer[256]; + char buffer[256]; FormatSignedTimeHHMM(buffer, {}); ok1(StringIsEqual(buffer, _T("00:00"))); @@ -128,7 +128,7 @@ TestHHMM() static void TestTwoLines() { - TCHAR buffer[256], buffer2[256]; + char buffer[256], buffer2[256]; FormatTimeTwoLines(buffer, buffer2, {}); ok1(StringIsEqual(buffer, _T("00'00"))); @@ -176,11 +176,11 @@ TestTwoLines() } static void -TestSmart(int _time, const TCHAR *expected_output1, - const TCHAR *expected_output2, const TCHAR *expected_output3, - const TCHAR *expected_output4, const TCHAR *separator = _T(" ")) +TestSmart(int _time, const char *expected_output1, + const char *expected_output2, const char *expected_output3, + const char *expected_output4, const char *separator = _T(" ")) { - TCHAR buffer[256]; + char buffer[256]; const auto time = std::chrono::seconds{_time}; diff --git a/test/src/TestTransponderCode.cpp b/test/src/TestTransponderCode.cpp index 8a3f8db5014..85dfebc6061 100644 --- a/test/src/TestTransponderCode.cpp +++ b/test/src/TestTransponderCode.cpp @@ -26,7 +26,7 @@ int main() TransponderCode code{04567}; ok1(code.IsDefined()); - TCHAR buf[12]; + char buf[12]; ok1(StringIsEqual(code.Format(buf, std::size(buf)), _T("4567"))); diff --git a/test/src/TestUnitsFormatter.cpp b/test/src/TestUnitsFormatter.cpp index 1b4a93ee826..a6b91be91df 100644 --- a/test/src/TestUnitsFormatter.cpp +++ b/test/src/TestUnitsFormatter.cpp @@ -12,7 +12,7 @@ static void TestAltitude() { - TCHAR buffer[256]; + char buffer[256]; // Test FormatAltitude() FormatAltitude(buffer, 1234, Unit::METER); @@ -37,7 +37,7 @@ TestAltitude() static void TestRelativeAltitude() { - TCHAR buffer[256]; + char buffer[256]; // Test FormatRelativeAltitude() FormatRelativeAltitude(buffer, 1234, Unit::METER); @@ -64,7 +64,7 @@ TestRelativeAltitude() static void TestDistance() { - TCHAR buffer[256]; + char buffer[256]; // Test FormatDistance() FormatDistance(buffer, 123.4, Unit::METER); @@ -137,7 +137,7 @@ TestDistance() static void TestSmallDistance() { - TCHAR buffer[256]; + char buffer[256]; // Test FormatSmallDistance() FormatSmallDistance(buffer, 123.4, Unit::METER); @@ -205,12 +205,12 @@ TestSmallDistance() static void TestDistanceSmart(double value, Unit unit, Unit expected_unit, - const TCHAR *expected_output_with_unit, - const TCHAR *expected_output_without_unit, + const char *expected_output_with_unit, + const char *expected_output_without_unit, double small_unit_threshold = 2500, double precision_threshold = 100) { - TCHAR buffer[256]; + char buffer[256]; ok1(FormatDistanceSmart(buffer, value, unit, true, small_unit_threshold, precision_threshold) == expected_unit); @@ -341,7 +341,7 @@ TestDistanceSmart() static void TestSpeed() { - TCHAR buffer[256]; + char buffer[256]; // Test FormatSpeed() FormatSpeed(buffer, 23.46, Unit::METER_PER_SECOND); @@ -399,7 +399,7 @@ TestSpeed() static void TestVerticalSpeed() { - TCHAR buffer[256]; + char buffer[256]; // Test FormatVerticalSpeed() FormatVerticalSpeed(buffer, 1.42, Unit::METER_PER_SECOND); @@ -430,7 +430,7 @@ TestVerticalSpeed() static void TestTemperature() { - TCHAR buffer[256]; + char buffer[256]; // Test FormatTemperature() FormatTemperature(buffer, 293.93, Unit::KELVIN); @@ -463,7 +463,7 @@ TestTemperature() static void TestPressure() { - TCHAR buffer[256]; + char buffer[256]; // Test FormatPressure() FormatPressure(buffer, AtmosphericPressure::HectoPascal(1013.25), diff --git a/test/src/TestWaypoints.cpp b/test/src/TestWaypoints.cpp index c8d15da5e5d..9cfe52d6866 100644 --- a/test/src/TestWaypoints.cpp +++ b/test/src/TestWaypoints.cpp @@ -107,10 +107,10 @@ TestLookups(const Waypoints &waypoints, const GeoPoint ¢er) class BeginsWith { - const TCHAR *prefix; + const char *prefix; public: - BeginsWith(const TCHAR *_prefix):prefix(_prefix) {} + BeginsWith(const char *_prefix):prefix(_prefix) {} bool operator()(const Waypoint &waypoint) { return StringStartsWith(waypoint.name.c_str(), prefix); @@ -118,7 +118,7 @@ class BeginsWith }; static void -TestNamePrefixVisitor(const Waypoints &waypoints, const TCHAR *prefix, +TestNamePrefixVisitor(const Waypoints &waypoints, const char *prefix, unsigned expected_results) { WaypointPredicateCounter::Predicate predicate = BeginsWith(prefix); diff --git a/tools/GenerateResources.pl b/tools/GenerateResources.pl index a0db6a405b5..f213067c5d2 100755 --- a/tools/GenerateResources.pl +++ b/tools/GenerateResources.pl @@ -29,10 +29,8 @@ ($) } } -print "#include \n"; - print "static constexpr struct {\n"; -print " const TCHAR *name;\n"; +print " const char *name;\n"; print " std::span data;\n"; print "} named_resources[] = {"; foreach my $i (@named) { diff --git a/tools/xci2cpp.pl b/tools/xci2cpp.pl index dcc5bf89c1f..6a18fd263a4 100755 --- a/tools/xci2cpp.pl +++ b/tools/xci2cpp.pl @@ -170,7 +170,7 @@ ($) return qq|_T("$value")|; } -print "static const TCHAR *const default_modes[] = {\n"; +print "static const char *const default_modes[] = {\n"; splice @modes, 0, 4; foreach my $m (@modes) { $m = c_string($m); From bc095ddfb131d3547d9d406143783558746704a8 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 22 Apr 2024 17:43:27 +0200 Subject: [PATCH 379/403] [UTF8] replace tstring and tstring_view with std::string.. ~115 (97+18) replacments in src ~112 (110+2) replacments in test --- src/Airspace/AirspaceParser.cpp | 4 ++-- src/Device/Descriptor.hpp | 6 +++--- src/Dialogs/Device/DeviceListDialog.cpp | 2 +- src/Dialogs/Device/PortDataField.cpp | 23 +++++++++++------------ src/Dialogs/Device/PortPicker.cpp | 2 +- src/Dialogs/Plane/PlaneListDialog.cpp | 6 +++--- src/Dialogs/Traffic/TrafficList.cpp | 8 ++++---- src/Dialogs/Weather/NOAADetails.cpp | 2 +- src/Dialogs/dlgChecklist.cpp | 4 ++-- src/Engine/Airspace/AbstractAirspace.hpp | 10 +++++----- src/Engine/Waypoint/Waypoint.hpp | 14 +++++++------- src/Engine/Waypoint/Waypoints.cpp | 10 +++++----- src/Engine/Waypoint/Waypoints.hpp | 14 +++++++------- src/Form/CheckBox.cpp | 4 ++-- src/Form/CheckBox.hpp | 8 ++++---- src/Form/DataField/ComboList.hpp | 8 ++++---- src/Form/Edit.hpp | 4 ++-- src/Form/Form.hpp | 4 ++-- src/Form/Frame.hpp | 4 ++-- src/Gauge/FlarmTrafficWindow.cpp | 2 +- src/Gauge/ThermalAssistantRenderer.cpp | 2 +- src/Input/InputConfig.hpp | 8 ++++---- src/Input/InputLookup.cpp | 2 +- src/Input/InputLookup.hpp | 4 ++-- src/LocalPath.cpp | 4 ++-- src/MapWindow/OverlayBitmap.hpp | 6 +++--- src/Menu/ExpandMacros.cpp | 8 ++++---- src/OpenVario/System/OpenVarioDevice.cpp | 2 -- src/Profile/Profile.cpp | 4 ++-- src/Renderer/TextButtonRenderer.cpp | 2 +- src/Renderer/TextButtonRenderer.hpp | 2 +- src/Renderer/TextRenderer.cpp | 8 ++++---- src/Renderer/TextRenderer.hpp | 10 +++++----- src/Task/TaskFile.hpp | 4 ++-- src/Task/TaskFileIGC.cpp | 4 ++-- src/Task/TaskFileIGC.hpp | 2 +- src/Task/TaskFileSeeYou.cpp | 4 ++-- src/Task/TaskFileSeeYou.hpp | 2 +- src/Task/TaskFileXCSoar.hpp | 2 +- src/Task/TaskStore.hpp | 10 +++++----- src/Task/XCTrackTaskFile.hpp | 2 +- src/Topography/TopographyFileRenderer.cpp | 4 ++-- src/Tracking/SkyLines/Data.hpp | 4 ++-- src/Waypoint/WaypointDetailsReader.cpp | 6 +++--- src/Waypoint/WaypointReaderFS.cpp | 4 ++-- src/Waypoint/WaypointReaderOzi.cpp | 4 ++-- src/Waypoint/WaypointReaderWinPilot.cpp | 4 ++-- src/Waypoint/WaypointReaderZander.cpp | 2 +- src/Weather/NOAAFormatter.cpp | 6 +++--- src/Weather/NOAAFormatter.hpp | 4 ++-- src/Weather/PCMet/Overlays.hpp | 4 ++-- src/Weather/Rasp/RaspStore.cpp | 4 ++-- src/Widget/ProgressWidget.cpp | 8 ++++---- src/Widget/ProgressWidget.hpp | 4 ++-- src/io/StringConverter.cpp | 2 +- src/io/StringConverter.hpp | 4 ++-- src/lua/InputEvent.cpp | 6 +++--- src/system/Args.hpp | 6 +++--- src/ui/canvas/Font.hpp | 8 ++++---- src/ui/canvas/android/Font.cpp | 4 ++-- src/ui/canvas/apple/Font.cpp | 4 ++-- src/ui/canvas/custom/Cache.cpp | 2 +- src/ui/canvas/custom/MoreCanvas.cpp | 4 ++-- src/ui/canvas/freetype/Font.cpp | 8 ++++---- src/ui/canvas/gdi/Canvas.cpp | 16 ++++++++-------- src/ui/canvas/gdi/Canvas.hpp | 18 +++++++++--------- src/ui/canvas/gdi/Font.cpp | 2 +- src/ui/canvas/memory/Canvas.cpp | 12 ++++++------ src/ui/canvas/memory/Canvas.hpp | 20 ++++++++++---------- src/ui/canvas/opengl/Canvas.cpp | 12 ++++++------ src/ui/canvas/opengl/Canvas.hpp | 20 ++++++++++---------- src/ui/control/LargeTextWindow.hpp | 4 ++-- src/util/DollarExpand.hpp | 8 ++++---- src/util/EscapeBackslash.cpp | 8 ++++---- src/util/EscapeBackslash.hpp | 6 +++--- src/util/RadixTree.hpp | 6 +++--- src/util/tstring.hpp | 2 +- src/util/tstring_view.hxx | 2 +- test/src/DebugReplayNMEA.cpp | 2 +- test/src/DebugReplayNMEA.hpp | 2 +- test/src/RunDeclare.cpp | 4 ++-- test/src/RunDeviceDriver.cpp | 2 +- test/src/RunDownloadFlight.cpp | 2 +- test/src/RunEnableNMEA.cpp | 2 +- test/src/RunFlightList.cpp | 2 +- test/src/RunInputParser.cpp | 2 +- test/src/RunLiveTrack24.cpp | 2 +- test/src/TestRadixTree.cpp | 2 +- test/src/TestTaskSave.cpp | 4 ++-- test/src/TestWaypointReader.cpp | 12 ++++++------ test/src/TestWaypoints.cpp | 2 +- 91 files changed, 255 insertions(+), 258 deletions(-) diff --git a/src/Airspace/AirspaceParser.cpp b/src/Airspace/AirspaceParser.cpp index 707b630ecd4..a93ed6e5ca4 100644 --- a/src/Airspace/AirspaceParser.cpp +++ b/src/Airspace/AirspaceParser.cpp @@ -121,10 +121,10 @@ struct TempAirspace } // General - tstring name; + std::string name; RadioFrequency radio_frequency; AirspaceClass asclass; - tstring astype; + std::string astype; std::optional base; std::optional top; AirspaceActivity days_of_operation; diff --git a/src/Device/Descriptor.hpp b/src/Device/Descriptor.hpp index a5620fd88f9..ee4f9a244d1 100644 --- a/src/Device/Descriptor.hpp +++ b/src/Device/Descriptor.hpp @@ -18,7 +18,7 @@ #include "thread/Mutex.hxx" #include "thread/Debug.hpp" #include "time/FloatDuration.hxx" -#include "util/tstring.hpp" +#include #include "util/StaticFifoBuffer.hxx" #ifdef HAVE_INTERNAL_GPS @@ -231,7 +231,7 @@ class DeviceDescriptor final * If this device has failed, then this attribute may contain an * error message. */ - tstring error_message; + std::string error_message; /** * Number of port failures since the device was last reset. @@ -292,7 +292,7 @@ class DeviceDescriptor final [[gnu::pure]] PortState GetState() const noexcept; - tstring GetErrorMessage() const noexcept { + std::string GetErrorMessage() const noexcept { const std::lock_guard lock{mutex}; return error_message; } diff --git a/src/Dialogs/Device/DeviceListDialog.cpp b/src/Dialogs/Device/DeviceListDialog.cpp index f8d19c506db..d19c7663e2b 100644 --- a/src/Dialogs/Device/DeviceListDialog.cpp +++ b/src/Dialogs/Device/DeviceListDialog.cpp @@ -167,7 +167,7 @@ class DeviceListWidget final static_assert(sizeof(Item) == 4, "wrong size"); Item items[NUMDEV]; - tstring error_messages[NUMDEV]; + std::string error_messages[NUMDEV]; Button *disable_button; Button *reconnect_button, *flight_button; diff --git a/src/Dialogs/Device/PortDataField.cpp b/src/Dialogs/Device/PortDataField.cpp index 57231e4407f..aa181ef665e 100644 --- a/src/Dialogs/Device/PortDataField.cpp +++ b/src/Dialogs/Device/PortDataField.cpp @@ -16,7 +16,6 @@ # include "util/StringFormat.hpp" # include # include - typedef std::string tstring; #endif #ifdef ANDROID @@ -109,7 +108,7 @@ try { //------------------------------- RegistryKey bthenums{HKEY_LOCAL_MACHINE, _T("SYSTEM\\CurrentControlSet\\" "Enum\\BthEnum")}; - std::map bthmap; + std::map bthmap; for (unsigned k = 0;; ++k) { char dev_name[128]; char name[128]; @@ -117,7 +116,7 @@ try { if (!bthenums.EnumKey(k, std::span{dev_name})) break; - tstring map_name(dev_name); + std::string map_name(dev_name); if (!map_name.starts_with(_T("Dev_"))) continue; RegistryKey bthenum_dev{bthenums, dev_name}; @@ -128,14 +127,14 @@ try { if (!bthenum_key.GetValue(_T("FriendlyName"), friendly_name)) break; map_name = map_name.substr(4); - for (tstring::iterator it = map_name.begin(); it != map_name.end(); + for (std::string::iterator it = map_name.begin(); it != map_name.end(); ++it) *it = towlower(*it); bthmap[map_name] = friendly_name; // Left "Dev_" } RegistryKey bthle{HKEY_LOCAL_MACHINE, _T("SYSTEM\\CurrentControlSet\\" "Enum\\BthLE")}; - std::map blemap; + std::map blemap; for (unsigned k = 0;; ++k) { char dev_name[128]; char name[128]; @@ -143,7 +142,7 @@ try { if (!bthle.EnumKey(k, std::span{dev_name})) break; - tstring map_name(dev_name); + std::string map_name(dev_name); if (!map_name.starts_with(_T("Dev_"))) continue; RegistryKey bthle_dev{bthle, dev_name}; @@ -154,7 +153,7 @@ try { if (!bthle_key.GetValue(_T("FriendlyName"), friendly_name)) break; map_name = map_name.substr(4); - for (tstring::iterator it = map_name.begin(); it != map_name.end(); + for (std::string::iterator it = map_name.begin(); it != map_name.end(); ++it) *it = towlower(*it); blemap[map_name] = friendly_name; // Left "Dev_" @@ -188,10 +187,10 @@ try { // BlueTooth: "\\?\bthenum#" // USB: "\\?\usb#" // Normal: "\\?\acpi#" - an Kupschis Rechner! - tstring dev = name1; + std::string dev = name1; if (dev.starts_with(_T("\\\\?\\usb#"))) { - std::vector strs; - tstring port_name; + std::vector strs; + std::string port_name; boost::split(strs, name, boost::is_any_of("\\")); port_name = value; port_name += _T(" ("); @@ -200,8 +199,8 @@ try { AddPort(df, DeviceConfig::PortType::USB_SERIAL, value, port_name.c_str()); } else if (dev.starts_with(_T("\\\\?\\bthenum#"))) { - std::vector strs; - tstring port_name; + std::vector strs; + std::string port_name; boost::split(strs, name1, boost::is_any_of("#")); boost::split(strs, strs[2], boost::is_any_of("_")); if (strs[1] == _T("c00000000")) { diff --git a/src/Dialogs/Device/PortPicker.cpp b/src/Dialogs/Device/PortPicker.cpp index f1d0c28b677..3a5fe887af0 100644 --- a/src/Dialogs/Device/PortPicker.cpp +++ b/src/Dialogs/Device/PortPicker.cpp @@ -84,7 +84,7 @@ class PortPickerWidget struct DetectedPort { DeviceConfig::PortType type; - tstring address, name; + std::string address, name; }; Mutex detected_mutex; diff --git a/src/Dialogs/Plane/PlaneListDialog.cpp b/src/Dialogs/Plane/PlaneListDialog.cpp index 9f7464c3d7a..0fbcaa96498 100644 --- a/src/Dialogs/Plane/PlaneListDialog.cpp +++ b/src/Dialogs/Plane/PlaneListDialog.cpp @@ -40,7 +40,7 @@ class PlaneListWidget final StaticString<32> name; AllocatedPath path; - ListItem(tstring_view _name, Path _path) noexcept + ListItem(std::string_view _name, Path _path) noexcept :name(_name), path(_path) {} bool operator<(const ListItem &i2) const noexcept { @@ -56,8 +56,8 @@ class PlaneListWidget final PlaneFileVisitor(std::vector &_list) noexcept:list(_list) {} void Visit(Path path, Path filename) override { - tstring_view name{filename.c_str()}; - RemoveSuffix(name, tstring_view{_T(".xcp")}); + std::string_view name{filename.c_str()}; + RemoveSuffix(name, std::string_view{_T(".xcp")}); list.emplace_back(name, path); } diff --git a/src/Dialogs/Traffic/TrafficList.cpp b/src/Dialogs/Traffic/TrafficList.cpp index df63bf446ef..84c600e048f 100644 --- a/src/Dialogs/Traffic/TrafficList.cpp +++ b/src/Dialogs/Traffic/TrafficList.cpp @@ -94,7 +94,7 @@ class TrafficListWidget : public ListWidget, public DataFieldListener, /** * The display name of the SkyLines account. */ - tstring name; + std::string name; #ifdef HAVE_SKYLINES_TRACKING StaticString<20> near_name; @@ -116,7 +116,7 @@ class TrafficListWidget : public ListWidget, public DataFieldListener, #ifdef HAVE_SKYLINES_TRACKING explicit Item(uint32_t _id, SkyLinesTracking::Data::Time _time_of_day, const GeoPoint &_location, int _altitude, - tstring &&_name) + std::string &&_name) :id(FlarmId::Undefined()), skylines_id(_id), time_of_day(_time_of_day), color(FlarmColor::COUNT), @@ -392,9 +392,9 @@ TrafficListWidget::UpdateList() const std::lock_guard lock{data.mutex}; for (const auto &i : data.traffic) { const auto name_i = data.user_names.find(i.first); - tstring name = name_i != data.user_names.end() + std::string name = name_i != data.user_names.end() ? name_i->second - : tstring(); + : std::string(); items.emplace_back(i.first, i.second.time_of_day, i.second.location, i.second.altitude, diff --git a/src/Dialogs/Weather/NOAADetails.cpp b/src/Dialogs/Weather/NOAADetails.cpp index 01c9e8b39da..49bdd476dbd 100644 --- a/src/Dialogs/Weather/NOAADetails.cpp +++ b/src/Dialogs/Weather/NOAADetails.cpp @@ -54,7 +54,7 @@ NOAADetailsWidget::CreateButtons(WidgetDialog &buttons) void NOAADetailsWidget::Update() { - tstring metar_taf = _T(""); + std::string metar_taf = _T(""); NOAAFormatter::Format(*station_iterator, metar_taf); diff --git a/src/Dialogs/dlgChecklist.cpp b/src/Dialogs/dlgChecklist.cpp index d36dafdeb2a..410925641ce 100644 --- a/src/Dialogs/dlgChecklist.cpp +++ b/src/Dialogs/dlgChecklist.cpp @@ -10,7 +10,7 @@ #include "util/StaticString.hxx" #include "util/StringSplit.hxx" #include "util/StringCompare.hxx" -#include "util/tstring.hpp" +#include #include "io/DataFile.hpp" #include "io/Reader.hxx" #include "io/BufferedReader.hxx" @@ -23,7 +23,7 @@ #define XCSCHKLIST "xcsoar-checklist.txt" struct ChecklistPage { - tstring title, text; + std::string title, text; bool empty() const noexcept { return title.empty() && text.empty(); diff --git a/src/Engine/Airspace/AbstractAirspace.hpp b/src/Engine/Airspace/AbstractAirspace.hpp index 418af46ed87..44612cb1189 100644 --- a/src/Engine/Airspace/AbstractAirspace.hpp +++ b/src/Engine/Airspace/AbstractAirspace.hpp @@ -4,7 +4,7 @@ #pragma once #include "util/TriState.hpp" -#include "util/tstring.hpp" +#include #include "AirspaceAltitude.hpp" #include "AirspaceClass.hpp" #include "AirspaceActivity.hpp" @@ -52,10 +52,10 @@ class AbstractAirspace { AirspaceAltitude altitude_top; /** Airspace name (identifier) */ - tstring name; + std::string name; /** Airspace type */ - tstring astype; + std::string astype; /** Radio frequency (optional) */ RadioFrequency radio_frequency = RadioFrequency::Null(); @@ -197,8 +197,8 @@ class AbstractAirspace { * @param _base Lower limit * @param _top Upper limit */ - void SetProperties(tstring &&_name, const AirspaceClass _class, - tstring &&_type, + void SetProperties(std::string &&_name, const AirspaceClass _class, + std::string &&_type, const AirspaceAltitude &_base, const AirspaceAltitude &_top) noexcept { name = std::move(_name); diff --git a/src/Engine/Waypoint/Waypoint.hpp b/src/Engine/Waypoint/Waypoint.hpp index 63e0c752cfe..a016f31cb23 100644 --- a/src/Engine/Waypoint/Waypoint.hpp +++ b/src/Engine/Waypoint/Waypoint.hpp @@ -4,7 +4,7 @@ #pragma once #include "Origin.hpp" -#include "util/tstring.hpp" +#include #include "Geo/GeoPoint.hpp" #include "Geo/Flat/FlatGeoPoint.hpp" #include "RadioFrequency.hpp" @@ -80,19 +80,19 @@ struct Waypoint { double elevation; /** Short name (code) label of waypoint */ - tstring shortname; + std::string shortname; /** Name of waypoint */ - tstring name; + std::string name; /** Additional comment text for waypoint */ - tstring comment; + std::string comment; /** Airfield or additional (long) details */ - tstring details; + std::string details; /** Additional files to be displayed in the WayointDetails dialog */ - std::forward_list files_embed; + std::forward_list files_embed; #ifdef HAVE_RUN_FILE /** Additional files to be opened by external programs */ - std::forward_list files_external; + std::forward_list files_external; #endif /** Unique id */ diff --git a/src/Engine/Waypoint/Waypoints.cpp b/src/Engine/Waypoint/Waypoints.cpp index 200a01c4eef..c705dc47547 100644 --- a/src/Engine/Waypoint/Waypoints.cpp +++ b/src/Engine/Waypoint/Waypoints.cpp @@ -8,7 +8,7 @@ static constexpr std::size_t NORMALIZE_BUFFER_SIZE = 4096; inline WaypointPtr -Waypoints::WaypointNameTree::Get(tstring_view name) const noexcept +Waypoints::WaypointNameTree::Get(std::string_view name) const noexcept { if (name.size() >= NORMALIZE_BUFFER_SIZE) return {}; @@ -19,7 +19,7 @@ Waypoints::WaypointNameTree::Get(tstring_view name) const noexcept } inline void -Waypoints::WaypointNameTree::VisitNormalisedPrefix(tstring_view prefix, +Waypoints::WaypointNameTree::VisitNormalisedPrefix(std::string_view prefix, const WaypointVisitor &visitor) const { if (prefix.size() >= NORMALIZE_BUFFER_SIZE) @@ -31,7 +31,7 @@ Waypoints::WaypointNameTree::VisitNormalisedPrefix(tstring_view prefix, } char * -Waypoints::WaypointNameTree::SuggestNormalisedPrefix(tstring_view prefix, +Waypoints::WaypointNameTree::SuggestNormalisedPrefix(std::string_view prefix, char *dest, size_t max_length) const noexcept { @@ -166,7 +166,7 @@ Waypoints::GetNearestIf(const GeoPoint &loc, double range, } WaypointPtr -Waypoints::LookupName(tstring_view name) const noexcept +Waypoints::LookupName(std::string_view name) const noexcept { return name_tree.Get(name); } @@ -237,7 +237,7 @@ Waypoints::VisitWithinRange(const GeoPoint &loc, const double range, } void -Waypoints::VisitNamePrefix(tstring_view prefix, +Waypoints::VisitNamePrefix(std::string_view prefix, WaypointVisitor visitor) const { name_tree.VisitNormalisedPrefix(prefix, visitor); diff --git a/src/Engine/Waypoint/Waypoints.hpp b/src/Engine/Waypoint/Waypoints.hpp index 70f9cb12d7c..fb4eaec2995 100644 --- a/src/Engine/Waypoint/Waypoints.hpp +++ b/src/Engine/Waypoint/Waypoints.hpp @@ -9,7 +9,7 @@ #include "util/RadixTree.hpp" #include "util/QuadTree.hxx" #include "util/Serial.hpp" -#include "util/tstring_view.hxx" +#include #include @@ -44,10 +44,10 @@ class Waypoints { class WaypointNameTree : public RadixTree { public: [[gnu::pure]] - WaypointPtr Get(tstring_view name) const noexcept; + WaypointPtr Get(std::string_view name) const noexcept; - void VisitNormalisedPrefix(tstring_view prefix, const WaypointVisitor &visitor) const; - char *SuggestNormalisedPrefix(tstring_view prefix, + void VisitNormalisedPrefix(std::string_view prefix, const WaypointVisitor &visitor) const; + char *SuggestNormalisedPrefix(std::string_view prefix, char *dest, size_t max_length) const noexcept; void Add(WaypointPtr wp) noexcept; void Remove(const WaypointPtr &wp) noexcept; @@ -254,7 +254,7 @@ class Waypoints { * @return Pointer to waypoint if found (or nullptr if not) */ [[gnu::pure]] - WaypointPtr LookupName(tstring_view name) const noexcept; + WaypointPtr LookupName(std::string_view name) const noexcept; /** * Check if a waypoint with same name and approximate location @@ -282,14 +282,14 @@ class Waypoints { * Call visitor function on waypoints with the specified name * prefix. */ - void VisitNamePrefix(tstring_view prefix, WaypointVisitor visitor) const; + void VisitNamePrefix(std::string_view prefix, WaypointVisitor visitor) const; /** * Returns a set of possible characters following the specified * prefix. */ [[gnu::pure]] - char *SuggestNamePrefix(tstring_view prefix, + char *SuggestNamePrefix(std::string_view prefix, char *dest, size_t max_length) const noexcept { return name_tree.SuggestNormalisedPrefix(prefix, dest, max_length); } diff --git a/src/Form/CheckBox.cpp b/src/Form/CheckBox.cpp index 51896aa3558..1f42c158e43 100644 --- a/src/Form/CheckBox.cpp +++ b/src/Form/CheckBox.cpp @@ -11,7 +11,7 @@ void CheckBoxControl::Create(ContainerWindow &parent, const DialogLook &_look, - tstring::const_pointer _caption, + std::string::const_pointer _caption, const PixelRect &rc, const WindowStyle style, Callback _callback) noexcept @@ -27,7 +27,7 @@ CheckBoxControl::Create(ContainerWindow &parent, const DialogLook &_look, unsigned CheckBoxControl::GetMinimumWidth(const DialogLook &look, unsigned height, - tstring::const_pointer caption) noexcept + std::string::const_pointer caption) noexcept { const unsigned padding = Layout::GetTextPadding(); return 3 * padding + height + look.check_box.font->TextSize(caption).width; diff --git a/src/Form/CheckBox.hpp b/src/Form/CheckBox.hpp index b54a0e97568..dc9f217572e 100644 --- a/src/Form/CheckBox.hpp +++ b/src/Form/CheckBox.hpp @@ -4,7 +4,7 @@ #pragma once #include "ui/window/PaintWindow.hpp" -#include "util/tstring.hpp" +#include #include #include @@ -19,21 +19,21 @@ class CheckBoxControl : public PaintWindow { bool checked, dragging, pressed; const DialogLook *look; - tstring caption; + std::string caption; using Callback = std::function; Callback callback; public: void Create(ContainerWindow &parent, const DialogLook &look, - tstring::const_pointer caption, + std::string::const_pointer caption, const PixelRect &rc, const WindowStyle style, Callback _callback) noexcept; [[gnu::pure]] static unsigned GetMinimumWidth(const DialogLook &look, unsigned height, - tstring::const_pointer caption) noexcept; + std::string::const_pointer caption) noexcept; /** * Set the function that will receive click events. diff --git a/src/Form/DataField/ComboList.hpp b/src/Form/DataField/ComboList.hpp index 28b4145bbc7..26ee7f12be0 100644 --- a/src/Form/DataField/ComboList.hpp +++ b/src/Form/DataField/ComboList.hpp @@ -3,10 +3,10 @@ #pragma once -#include "util/tstring.hpp" #include #include +#include class ComboList { public: @@ -16,9 +16,9 @@ class ComboList { static constexpr int DOWNLOAD = -800003; int int_value; - tstring string_value; - tstring display_string; - tstring help_text; + std::string string_value; + std::string display_string; + std::string help_text; Item(int _int_value, const char *_string_value, const char *_display_string, diff --git a/src/Form/Edit.hpp b/src/Form/Edit.hpp index de75053dc4b..a7edc09de05 100644 --- a/src/Form/Edit.hpp +++ b/src/Form/Edit.hpp @@ -5,7 +5,7 @@ #include "Form/Control.hpp" #include "ui/dim/Rect.hpp" -#include "util/tstring.hpp" +#include struct DialogLook; class DataField; @@ -27,7 +27,7 @@ class WndProperty : public WindowControl { /** Width reserved for the caption of the Control */ int caption_width; - tstring value; + std::string value; DataField *data_field = nullptr; diff --git a/src/Form/Form.hpp b/src/Form/Form.hpp index c0670c0c30a..47864cae128 100644 --- a/src/Form/Form.hpp +++ b/src/Form/Form.hpp @@ -5,7 +5,7 @@ #include "ui/window/ContainerWindow.hpp" #include "ui/window/SolidContainerWindow.hpp" -#include "util/tstring.hpp" +#include #include "Form/Button.hpp" #include @@ -65,7 +65,7 @@ class WndForm : public ContainerWindow void OnPaint(Canvas &canvas) noexcept override; - tstring caption; + std::string caption; public: WndForm(const DialogLook &_look); diff --git a/src/Form/Frame.hpp b/src/Form/Frame.hpp index 99b0579bab8..2c00518a4a5 100644 --- a/src/Form/Frame.hpp +++ b/src/Form/Frame.hpp @@ -6,7 +6,7 @@ #include "ui/window/PaintWindow.hpp" #include "ui/canvas/Color.hpp" #include "Renderer/TextRenderer.hpp" -#include "util/tstring.hpp" +#include #include @@ -19,7 +19,7 @@ class WndFrame : public PaintWindow { TextRenderer text_renderer; - tstring text; + std::string text; public: explicit WndFrame(const DialogLook &look) noexcept; diff --git a/src/Gauge/FlarmTrafficWindow.cpp b/src/Gauge/FlarmTrafficWindow.cpp index 0f1b9188b65..2f61b2b49cf 100644 --- a/src/Gauge/FlarmTrafficWindow.cpp +++ b/src/Gauge/FlarmTrafficWindow.cpp @@ -618,7 +618,7 @@ FlarmTrafficWindow::PaintNorth(Canvas &canvas) const noexcept static void DrawCircleLabel(Canvas &canvas, PixelPoint p, - tstring_view text) noexcept + std::string_view text) noexcept { const auto size = canvas.CalcTextSize(text); p.x -= size.width / 2; diff --git a/src/Gauge/ThermalAssistantRenderer.cpp b/src/Gauge/ThermalAssistantRenderer.cpp index 8c8a46acf9a..51f308bb9e4 100644 --- a/src/Gauge/ThermalAssistantRenderer.cpp +++ b/src/Gauge/ThermalAssistantRenderer.cpp @@ -80,7 +80,7 @@ ThermalAssistantRenderer::NormalizeLift(double lift, double max_lift) noexcept static void DrawCircleLabel(Canvas &canvas, PixelPoint p, - tstring_view text) noexcept + std::string_view text) noexcept { const auto size = canvas.CalcTextSize(text); p.x -= size.width / 2; diff --git a/src/Input/InputConfig.hpp b/src/Input/InputConfig.hpp index f7f93cb90be..b1826cacd2a 100644 --- a/src/Input/InputConfig.hpp +++ b/src/Input/InputConfig.hpp @@ -8,7 +8,7 @@ #include "util/RadixTree.hpp" #include "util/StaticString.hxx" #include "util/TrivialArray.hxx" -#include "util/tstring_view.hxx" +#include #include #include @@ -77,7 +77,7 @@ struct InputConfig { void SetDefaults() noexcept; [[gnu::pure]] - int LookupMode(tstring_view name) const noexcept { + int LookupMode(std::string_view name) const noexcept { for (std::size_t i = 0, size = modes.size(); i < size; ++i) if (name == modes[i].c_str()) return i; @@ -85,7 +85,7 @@ struct InputConfig { return -1; } - int AppendMode(tstring_view name) noexcept { + int AppendMode(std::string_view name) noexcept { if (modes.full()) return -1; @@ -94,7 +94,7 @@ struct InputConfig { } [[gnu::pure]] - int MakeMode(tstring_view name) noexcept { + int MakeMode(std::string_view name) noexcept { int mode = LookupMode(name); if (mode < 0) mode = AppendMode(name); diff --git a/src/Input/InputLookup.cpp b/src/Input/InputLookup.cpp index 206f32a5dcf..1a51f7006ff 100644 --- a/src/Input/InputLookup.cpp +++ b/src/Input/InputLookup.cpp @@ -30,7 +30,7 @@ static const char *const Text2NE[] = { }; pt2Event -InputEvents::findEvent(tstring_view name) noexcept +InputEvents::findEvent(std::string_view name) noexcept { for (unsigned i = 0; Text2Event[i].text != nullptr; ++i) if (name == Text2Event[i].text) diff --git a/src/Input/InputLookup.hpp b/src/Input/InputLookup.hpp index 2aeafdd9c74..87b5dd98c1b 100644 --- a/src/Input/InputLookup.hpp +++ b/src/Input/InputLookup.hpp @@ -3,7 +3,7 @@ #pragma once -#include "util/tstring_view.hxx" +#include #include @@ -19,6 +19,6 @@ int findNE(const char *data); [[gnu::pure]] pt2Event -findEvent(tstring_view name) noexcept; +findEvent(std::string_view name) noexcept; } // namespace InputEvents diff --git a/src/LocalPath.cpp b/src/LocalPath.cpp index d758de533e0..d162a6f3f00 100644 --- a/src/LocalPath.cpp +++ b/src/LocalPath.cpp @@ -20,7 +20,7 @@ #ifdef _WIN32 #include "system/PathName.hpp" #else -#include "util/tstring.hpp" +#include #endif #include @@ -150,7 +150,7 @@ ExpandLocalPath(Path src) noexcept #ifndef _WIN32 // Convert backslashes to slashes on platforms where it matters - tstring src2(ptr); + std::string src2(ptr); std::replace(src2.begin(), src2.end(), '\\', '/'); ptr = src2.c_str(); #endif diff --git a/src/MapWindow/OverlayBitmap.hpp b/src/MapWindow/OverlayBitmap.hpp index 4461f667d3e..fba5b5463f6 100644 --- a/src/MapWindow/OverlayBitmap.hpp +++ b/src/MapWindow/OverlayBitmap.hpp @@ -7,7 +7,7 @@ #include "ui/canvas/Bitmap.hpp" #include "Geo/Quadrilateral.hpp" #include "Geo/GeoBounds.hpp" -#include "util/tstring.hpp" +#include class Canvas; class WindowProjection; @@ -35,7 +35,7 @@ class MapOverlayBitmap final : public MapOverlay { float alpha = 1; - tstring label; + std::string label; public: /** @@ -49,7 +49,7 @@ class MapOverlayBitmap final : public MapOverlay { * Move an existing #Bitmap with a geo reference. */ MapOverlayBitmap(Bitmap &&_bitmap, GeoQuadrilateral _bounds, - tstring::const_pointer _label) noexcept + std::string::const_pointer _label) noexcept :bitmap(std::move(_bitmap)), bounds(_bounds), simple_bounds(bounds.GetBounds()), label(_label) {} diff --git a/src/Menu/ExpandMacros.cpp b/src/Menu/ExpandMacros.cpp index 38f1ed0b77a..26592863759 100644 --- a/src/Menu/ExpandMacros.cpp +++ b/src/Menu/ExpandMacros.cpp @@ -29,7 +29,7 @@ #include static const char * -ExpandTaskMacros(tstring_view name, +ExpandTaskMacros(std::string_view name, bool &invalid, const DerivedInfo &calculated, const ComputerSettings &settings_computer) noexcept @@ -198,7 +198,7 @@ ExpandTaskMacros(tstring_view name, [[gnu::pure]] static const char * -ExpandTrafficMacros(tstring_view name) noexcept +ExpandTrafficMacros(std::string_view name) noexcept { TrafficWidget *widget = (TrafficWidget *) CommonInterface::main_window->GetFlavourWidget(_T("Traffic")); @@ -244,7 +244,7 @@ GetUIState() noexcept } static const char * -LookupMacro(tstring_view name, bool &invalid) noexcept +LookupMacro(std::string_view name, bool &invalid) noexcept { if (name ==_T("CheckAirspace")) { invalid |= data_components->airspaces->IsEmpty(); @@ -441,7 +441,7 @@ ButtonLabel::ExpandMacros(const char *In, std::span dest) noexcept bool invalid = false; DollarExpand(In, dest, - [&invalid](tstring_view name){ + [&invalid](std::string_view name){ return LookupMacro(name, invalid); }); diff --git a/src/OpenVario/System/OpenVarioDevice.cpp b/src/OpenVario/System/OpenVarioDevice.cpp index 0e89b562778..7368c022abb 100644 --- a/src/OpenVario/System/OpenVarioDevice.cpp +++ b/src/OpenVario/System/OpenVarioDevice.cpp @@ -27,8 +27,6 @@ #include "LogFile.hpp" #include "LocalPath.hpp" -#include - #ifndef _WIN32 #include #include diff --git a/src/Profile/Profile.cpp b/src/Profile/Profile.cpp index faf041a1ef2..d5fbb82ea58 100644 --- a/src/Profile/Profile.cpp +++ b/src/Profile/Profile.cpp @@ -11,7 +11,7 @@ #include "util/StringUtil.hpp" #include "util/StringCompare.hxx" #include "util/StringAPI.hxx" -#include "util/tstring.hpp" +#include #include "system/FileUtil.hpp" #include "system/Path.hpp" @@ -90,7 +90,7 @@ Profile::SetFiles(Path override_path) noexcept if (StringFind(override_path.c_str(), '.') != nullptr) startProfileFile = LocalPath(override_path); else { - tstring t(override_path.c_str()); + std::string t(override_path.c_str()); t += _T(".prf"); startProfileFile = LocalPath(t.c_str()); } diff --git a/src/Renderer/TextButtonRenderer.cpp b/src/Renderer/TextButtonRenderer.cpp index 5e6c712ba33..f46f43990d7 100644 --- a/src/Renderer/TextButtonRenderer.cpp +++ b/src/Renderer/TextButtonRenderer.cpp @@ -8,7 +8,7 @@ unsigned TextButtonRenderer::GetMinimumButtonWidth(const ButtonLook &look, - tstring_view caption) noexcept + std::string_view caption) noexcept { return 2 * (ButtonFrameRenderer::GetMargin() + Layout::GetTextPadding()) + look.font->TextSize(caption).width; diff --git a/src/Renderer/TextButtonRenderer.hpp b/src/Renderer/TextButtonRenderer.hpp index b17d91d11db..f9ab4c43b3f 100644 --- a/src/Renderer/TextButtonRenderer.hpp +++ b/src/Renderer/TextButtonRenderer.hpp @@ -36,7 +36,7 @@ class TextButtonRenderer : public ButtonRenderer { [[gnu::pure]] static unsigned GetMinimumButtonWidth(const ButtonLook &look, - tstring_view caption) noexcept; + std::string_view caption) noexcept; const ButtonLook &GetLook() const noexcept { return frame_renderer.GetLook(); diff --git a/src/Renderer/TextRenderer.cpp b/src/Renderer/TextRenderer.cpp index 18ca85415dd..c69cad66ee8 100644 --- a/src/Renderer/TextRenderer.cpp +++ b/src/Renderer/TextRenderer.cpp @@ -10,21 +10,21 @@ unsigned TextRenderer::GetHeight(Canvas &canvas, PixelRect rc, - tstring_view text) const noexcept + std::string_view text) const noexcept { return canvas.DrawFormattedText(rc, text, DT_CALCRECT); } unsigned TextRenderer::GetHeight(Canvas &canvas, unsigned width, - tstring_view text) const noexcept + std::string_view text) const noexcept { return GetHeight(canvas, PixelRect(0, 0, width, 0), text); } unsigned TextRenderer::GetHeight(const Font &font, unsigned width, - tstring_view text) const noexcept + std::string_view text) const noexcept { AnyCanvas canvas; canvas.Select(font); @@ -33,7 +33,7 @@ TextRenderer::GetHeight(const Font &font, unsigned width, void TextRenderer::Draw(Canvas &canvas, PixelRect rc, - tstring_view text) const noexcept + std::string_view text) const noexcept { unsigned format = (center ? DT_CENTER : DT_LEFT); diff --git a/src/Renderer/TextRenderer.hpp b/src/Renderer/TextRenderer.hpp index 7e5670367dc..a1b43048c36 100644 --- a/src/Renderer/TextRenderer.hpp +++ b/src/Renderer/TextRenderer.hpp @@ -3,7 +3,7 @@ #pragma once -#include "util/tstring_view.hxx" +#include struct PixelRect; class Canvas; @@ -38,15 +38,15 @@ class TextRenderer { [[gnu::pure]] unsigned GetHeight(Canvas &canvas, PixelRect rc, - tstring_view text) const noexcept; + std::string_view text) const noexcept; [[gnu::pure]] unsigned GetHeight(Canvas &canvas, unsigned width, - tstring_view text) const noexcept; + std::string_view text) const noexcept; [[gnu::pure]] unsigned GetHeight(const Font &font, unsigned width, - tstring_view text) const noexcept; + std::string_view text) const noexcept; - void Draw(Canvas &canvas, PixelRect rc, tstring_view text) const noexcept; + void Draw(Canvas &canvas, PixelRect rc, std::string_view text) const noexcept; }; diff --git a/src/Task/TaskFile.hpp b/src/Task/TaskFile.hpp index 25aee2cc252..4c871c97198 100644 --- a/src/Task/TaskFile.hpp +++ b/src/Task/TaskFile.hpp @@ -4,7 +4,7 @@ #pragma once #include "system/Path.hpp" -#include "util/tstring.hpp" +#include #include #include @@ -41,7 +41,7 @@ class TaskFile /** * Throws on error. */ - virtual std::vector GetList() const = 0; + virtual std::vector GetList() const = 0; virtual std::unique_ptr GetTask(const TaskBehaviour &task_behaviour, const Waypoints *waypoints, diff --git a/src/Task/TaskFileIGC.cpp b/src/Task/TaskFileIGC.cpp index 98a56c1b81d..ebb1286ea97 100644 --- a/src/Task/TaskFileIGC.cpp +++ b/src/Task/TaskFileIGC.cpp @@ -118,7 +118,7 @@ TaskFileIGC::GetTask(const TaskBehaviour &task_behaviour, return task; } -std::vector +std::vector TaskFileIGC::GetList() const { // Open the IGC file @@ -136,7 +136,7 @@ TaskFileIGC::GetList() const header.num_turnpoints == 0) return {}; - std::vector result; + std::vector result; if (!header.task_name.empty() && !StringIsEqual(header.task_name, "Task")) { diff --git a/src/Task/TaskFileIGC.hpp b/src/Task/TaskFileIGC.hpp index 301af424c67..fe97ffa601d 100644 --- a/src/Task/TaskFileIGC.hpp +++ b/src/Task/TaskFileIGC.hpp @@ -10,7 +10,7 @@ class TaskFileIGC: public TaskFile public: using TaskFile::TaskFile; - std::vector GetList() const override; + std::vector GetList() const override; std::unique_ptr GetTask(const TaskBehaviour &task_behaviour, const Waypoints *waypoints, diff --git a/src/Task/TaskFileSeeYou.cpp b/src/Task/TaskFileSeeYou.cpp index d495d99fd82..3431811a180 100644 --- a/src/Task/TaskFileSeeYou.cpp +++ b/src/Task/TaskFileSeeYou.cpp @@ -553,10 +553,10 @@ try { return nullptr; } -std::vector +std::vector TaskFileSeeYou::GetList() const { - std::vector result; + std::vector result; // Open the CUP file FileReader file_reader{path}; diff --git a/src/Task/TaskFileSeeYou.hpp b/src/Task/TaskFileSeeYou.hpp index 35723970977..93825cfdf7b 100644 --- a/src/Task/TaskFileSeeYou.hpp +++ b/src/Task/TaskFileSeeYou.hpp @@ -15,7 +15,7 @@ class TaskFileSeeYou: public TaskFile public: using TaskFile::TaskFile; - std::vector GetList() const override; + std::vector GetList() const override; std::unique_ptr GetTask(const TaskBehaviour &task_behaviour, const Waypoints *waypoints, unsigned index) const override; diff --git a/src/Task/TaskFileXCSoar.hpp b/src/Task/TaskFileXCSoar.hpp index 1bf9487ae08..cedde6ec8b8 100644 --- a/src/Task/TaskFileXCSoar.hpp +++ b/src/Task/TaskFileXCSoar.hpp @@ -10,7 +10,7 @@ class TaskFileXCSoar: public TaskFile public: using TaskFile::TaskFile; - std::vector GetList() const override { + std::vector GetList() const override { return {{}}; } diff --git a/src/Task/TaskStore.hpp b/src/Task/TaskStore.hpp index 30689b22d7b..9a8ff4353d6 100644 --- a/src/Task/TaskStore.hpp +++ b/src/Task/TaskStore.hpp @@ -4,7 +4,7 @@ #pragma once #include "system/Path.hpp" -#include "util/tstring.hpp" +#include #include #include @@ -21,14 +21,14 @@ class TaskStore public: struct Item { - tstring task_name; + std::string task_name; AllocatedPath filename; unsigned task_index; std::unique_ptr task; bool valid; Item(Path the_filename, - tstring::const_pointer _task_name, + std::string::const_pointer _task_name, unsigned _task_index = 0) :task_name(_task_name), filename(the_filename), @@ -41,7 +41,7 @@ class TaskStore Item &operator=(Item &&) = default; [[gnu::pure]] - tstring::const_pointer GetName() const { + std::string::const_pointer GetName() const { return task_name.c_str(); } @@ -97,7 +97,7 @@ class TaskStore * @return Filename of the task defined by the given index */ [[gnu::pure]] - tstring::const_pointer GetName(unsigned index) const; + std::string::const_pointer GetName(unsigned index) const; /** * Return the pathname of the task defined by the given index diff --git a/src/Task/XCTrackTaskFile.hpp b/src/Task/XCTrackTaskFile.hpp index 00d88fd8024..8de76ccbe13 100644 --- a/src/Task/XCTrackTaskFile.hpp +++ b/src/Task/XCTrackTaskFile.hpp @@ -9,7 +9,7 @@ class XCTrackTaskFile final : public TaskFile { public: using TaskFile::TaskFile; - std::vector GetList() const override { + std::vector GetList() const override { return {{}}; } diff --git a/src/Topography/TopographyFileRenderer.cpp b/src/Topography/TopographyFileRenderer.cpp index d93161bd139..40e2e0a32f6 100644 --- a/src/Topography/TopographyFileRenderer.cpp +++ b/src/Topography/TopographyFileRenderer.cpp @@ -12,7 +12,7 @@ #include "Screen/Layout.hpp" #include "shapelib/mapserver.h" #include "util/AllocatedArray.hxx" -#include "util/tstring.hpp" +#include #include "Geo/GeoClip.hpp" #include "Geo/FAISphere.hpp" @@ -370,7 +370,7 @@ TopographyFileRenderer::PaintLabels(Canvas &canvas, int iskip = file.GetSkipSteps(map_scale); - std::set drawn_labels; + std::set drawn_labels; // Iterate over all shapes in the file for (const XShape *shape_p : visible_labels) { diff --git a/src/Tracking/SkyLines/Data.hpp b/src/Tracking/SkyLines/Data.hpp index ec713bfda24..e724e1b99f3 100644 --- a/src/Tracking/SkyLines/Data.hpp +++ b/src/Tracking/SkyLines/Data.hpp @@ -5,7 +5,7 @@ #include "Geo/GeoPoint.hpp" #include "thread/Mutex.hxx" -#include "util/tstring.hpp" +#include #include #include @@ -76,7 +76,7 @@ struct Data { * A database of user-id to display-name. An empty string means * the server has failed/refused to supply a name. */ - std::map user_names; + std::map user_names; std::list waves; diff --git a/src/Waypoint/WaypointDetailsReader.cpp b/src/Waypoint/WaypointDetailsReader.cpp index 288ca0b1cd2..e58d453cb8c 100644 --- a/src/Waypoint/WaypointDetailsReader.cpp +++ b/src/Waypoint/WaypointDetailsReader.cpp @@ -25,11 +25,11 @@ FindWaypoint(Waypoints &way_points, const char *name) struct WaypointDetailsBuilder { char name[201]; - tstring details; + std::string details; #ifdef HAVE_RUN_FILE - std::forward_list files_external; + std::forward_list files_external; #endif - std::forward_list files_embed; + std::forward_list files_embed; void Reset() noexcept { details.clear(); diff --git a/src/Waypoint/WaypointReaderFS.cpp b/src/Waypoint/WaypointReaderFS.cpp index cc6c905bb89..045e6870f87 100644 --- a/src/Waypoint/WaypointReaderFS.cpp +++ b/src/Waypoint/WaypointReaderFS.cpp @@ -149,7 +149,7 @@ WaypointReaderFS::ParseLine(const char *line, Waypoints &way_points) Waypoint new_waypoint = factory.Create(location); - new_waypoint.name = tstring{string_converter.Convert({line, 8})}; + new_waypoint.name = std::string{string_converter.Convert({line, 8})}; if (ParseAltitude(line + (is_utm ? 32 : 41), new_waypoint.elevation)) new_waypoint.has_elevation = true; @@ -158,7 +158,7 @@ WaypointReaderFS::ParseLine(const char *line, Waypoints &way_points) // Description (Characters 35-44) if (len > (is_utm ? 38 : 47)) - new_waypoint.comment = tstring{string_converter.Convert(line + (is_utm ? 38 : 47))}; + new_waypoint.comment = std::string{string_converter.Convert(line + (is_utm ? 38 : 47))}; way_points.Append(std::move(new_waypoint)); return true; diff --git a/src/Waypoint/WaypointReaderOzi.cpp b/src/Waypoint/WaypointReaderOzi.cpp index 4f117f7a93f..8f7d867c7f4 100644 --- a/src/Waypoint/WaypointReaderOzi.cpp +++ b/src/Waypoint/WaypointReaderOzi.cpp @@ -49,7 +49,7 @@ WaypointReaderOzi::ParseLine(const char *line, Waypoints &way_points) ParseIntegerTo(NextColumn(rest), number); // Field 2 : Name - tstring name{string_converter.Convert(NextColumn(rest))}; + std::string name{string_converter.Convert(NextColumn(rest))}; GeoPoint location; // Latitude (e.g. 5115.900N) @@ -70,7 +70,7 @@ WaypointReaderOzi::ParseLine(const char *line, Waypoints &way_points) NextColumn(rest); // Field 10 : Background Color // Field 11 : Description - tstring comment{string_converter.Convert(NextColumn(rest))}; + std::string comment{string_converter.Convert(NextColumn(rest))}; NextColumn(rest); // Field 12 : Pointer Direction NextColumn(rest); // Field 13 : Garmin Display Format diff --git a/src/Waypoint/WaypointReaderWinPilot.cpp b/src/Waypoint/WaypointReaderWinPilot.cpp index b2b6d6ec6c1..7382d896934 100644 --- a/src/Waypoint/WaypointReaderWinPilot.cpp +++ b/src/Waypoint/WaypointReaderWinPilot.cpp @@ -244,13 +244,13 @@ WaypointReaderWinPilot::ParseLine(const char *line, Waypoints &waypoints) ParseFlags(NextColumn(rest), new_waypoint); // Name (e.g. KAMPLI) - new_waypoint.name = tstring{string_converter.Convert(NextColumn(rest))}; + new_waypoint.name = std::string{string_converter.Convert(NextColumn(rest))}; if (new_waypoint.name.empty()) return false; // Description (e.g. 119.750 Airport) const auto comment = NextColumn(rest); - new_waypoint.comment = tstring{string_converter.Convert(comment)}; + new_waypoint.comment = std::string{string_converter.Convert(comment)}; ParseRunwayDirection(comment, new_waypoint.runway); waypoints.Append(std::move(new_waypoint)); diff --git a/src/Waypoint/WaypointReaderZander.cpp b/src/Waypoint/WaypointReaderZander.cpp index f7ee4bde6ab..67e05a260d6 100644 --- a/src/Waypoint/WaypointReaderZander.cpp +++ b/src/Waypoint/WaypointReaderZander.cpp @@ -9,7 +9,7 @@ static bool ParseString(StringConverter &string_converter, - std::string_view src, tstring &dest, std::size_t len) noexcept + std::string_view src, std::string &dest, std::size_t len) noexcept { if (src.empty()) return false; diff --git a/src/Weather/NOAAFormatter.cpp b/src/Weather/NOAAFormatter.cpp index dd9de873c43..0a3fc44a433 100644 --- a/src/Weather/NOAAFormatter.cpp +++ b/src/Weather/NOAAFormatter.cpp @@ -53,7 +53,7 @@ CheckTitle(const char *title, size_t title_length, const char *check) static bool FormatDecodedMETARLine(const char *line, unsigned length, - const ParsedMETAR &parsed, tstring &output) + const ParsedMETAR &parsed, std::string &output) { const char *end = line + length; @@ -199,7 +199,7 @@ FormatDecodedMETARLine(const char *line, unsigned length, static void FormatDecodedMETAR(const METAR &metar, const ParsedMETAR &parsed, - tstring &output) + std::string &output) { /* 00 ## Hamburg-Fuhlsbuettel, Germany (EDDH) 53-38N 010-00E 15M ## @@ -242,7 +242,7 @@ FormatDecodedMETAR(const METAR &metar, const ParsedMETAR &parsed, } void -NOAAFormatter::Format(const NOAAStore::Item &station, tstring &output) +NOAAFormatter::Format(const NOAAStore::Item &station, std::string &output) { output.reserve(2048); diff --git a/src/Weather/NOAAFormatter.hpp b/src/Weather/NOAAFormatter.hpp index 16303b43404..6e53c67a62f 100644 --- a/src/Weather/NOAAFormatter.hpp +++ b/src/Weather/NOAAFormatter.hpp @@ -4,11 +4,11 @@ #pragma once #include "NOAAStore.hpp" -#include "util/tstring.hpp" +#include namespace NOAAFormatter { void -Format(const NOAAStore::Item &station, tstring &output); +Format(const NOAAStore::Item &station, std::string &output); } // namespace NOAAFormatter diff --git a/src/Weather/PCMet/Overlays.hpp b/src/Weather/PCMet/Overlays.hpp index 80b01dee5b9..de70aac6084 100644 --- a/src/Weather/PCMet/Overlays.hpp +++ b/src/Weather/PCMet/Overlays.hpp @@ -5,7 +5,7 @@ #include "system/Path.hpp" #include "time/BrokenDateTime.hpp" -#include "util/tstring.hpp" +#include #include @@ -35,7 +35,7 @@ struct OverlayInfo { unsigned level; unsigned step; - tstring label; + std::string label; AllocatedPath path; }; diff --git a/src/Weather/Rasp/RaspStore.cpp b/src/Weather/Rasp/RaspStore.cpp index 7b572654207..9fdd45bab59 100644 --- a/src/Weather/Rasp/RaspStore.cpp +++ b/src/Weather/Rasp/RaspStore.cpp @@ -9,7 +9,7 @@ #include "io/ZipArchive.hpp" #include "util/StringCompare.hxx" #include "util/Macros.hpp" -#include "util/tstring.hpp" +#include #include "zzip/zzip.h" #include "LogFile.hpp" @@ -158,7 +158,7 @@ try { maps.clear(); - std::set names; + std::set names; for (const auto &i : WeatherDescriptors) { if (maps.full()) diff --git a/src/Widget/ProgressWidget.cpp b/src/Widget/ProgressWidget.cpp index 1ca38c0e21c..c24f5f9b1dd 100644 --- a/src/Widget/ProgressWidget.cpp +++ b/src/Widget/ProgressWidget.cpp @@ -8,16 +8,16 @@ #include "Renderer/ProgressBarRenderer.hpp" #include "Screen/Layout.hpp" #include "Look/DialogLook.hpp" -#include "util/tstring_view.hxx" +#include #include "UIGlobals.hpp" class ProgressWidget::ProgressBar final : public PaintWindow { unsigned range = 0, position = 0; - tstring text; + std::string text; public: - explicit ProgressBar(tstring &&_text) noexcept + explicit ProgressBar(std::string &&_text) noexcept :text(std::move(_text)) {} void SetRange(unsigned _range) noexcept { @@ -52,7 +52,7 @@ class ProgressWidget::ProgressBar final : public PaintWindow { canvas.SetTextColor(COLOR_BLACK); canvas.SetBackgroundTransparent(); - const tstring_view _text{text}; + const std::string_view _text{text}; canvas.DrawText({padding, padding}, _text); } } diff --git a/src/Widget/ProgressWidget.hpp b/src/Widget/ProgressWidget.hpp index c3ca20bd19f..de6d12dbc57 100644 --- a/src/Widget/ProgressWidget.hpp +++ b/src/Widget/ProgressWidget.hpp @@ -5,7 +5,7 @@ #include "WindowWidget.hpp" #include "Operation/MessageOperationEnvironment.hpp" -#include "util/tstring.hpp" +#include class PluggableOperationEnvironment; @@ -17,7 +17,7 @@ class ProgressWidget final : public WindowWidget, MessageOperationEnvironment { PluggableOperationEnvironment &env; - tstring text; + std::string text; public: explicit ProgressWidget(PluggableOperationEnvironment &_env, diff --git a/src/io/StringConverter.cpp b/src/io/StringConverter.cpp index 6fff87ccc20..d62651158c4 100644 --- a/src/io/StringConverter.cpp +++ b/src/io/StringConverter.cpp @@ -84,7 +84,7 @@ StringConverter::Convert(char *narrow) gcc_unreachable(); } -tstring_view +std::string_view StringConverter::Convert(std::string_view src) { src = DetectStrip(src); diff --git a/src/io/StringConverter.hpp b/src/io/StringConverter.hpp index d64fe7865dc..14ae6666c9f 100644 --- a/src/io/StringConverter.hpp +++ b/src/io/StringConverter.hpp @@ -5,7 +5,7 @@ #include "Charset.hpp" #include "util/ReusableArray.hpp" -#include "util/tstring_view.hxx" +#include #include @@ -49,5 +49,5 @@ class StringConverter { */ char *Convert(char *src); - tstring_view Convert(std::string_view src); + std::string_view Convert(std::string_view src); }; diff --git a/src/lua/InputEvent.cpp b/src/lua/InputEvent.cpp index b72ae28efd1..8a40a5a1a40 100644 --- a/src/lua/InputEvent.cpp +++ b/src/lua/InputEvent.cpp @@ -17,7 +17,7 @@ #include "Interface.hpp" #include -#include "util/tstring.hpp" +#include extern "C" { #include @@ -56,7 +56,7 @@ class LuaEventRegistry { }; static LuaEventRegistry event_store_enum; -static LuaEventRegistry event_store_gesture; +static LuaEventRegistry event_store_gesture; static LuaEventRegistry event_store_key; static constexpr const char* event_enum_names[] = { @@ -225,7 +225,7 @@ class LuaInputEvent final { else if (StringIsEqual(name, "gesture_", 8)) { const UTF8ToWideConverter gesture(name+8); if (gesture.IsValid()) { - event_store_gesture.Clear(tstring(gesture)); + event_store_gesture.Clear(std::string(gesture)); return 1; } } else if (StringIsEqual(name, "key_", 4)) { diff --git a/src/system/Args.hpp b/src/system/Args.hpp index 068e119ddb2..2df85f297ac 100644 --- a/src/system/Args.hpp +++ b/src/system/Args.hpp @@ -4,7 +4,7 @@ #pragma once #include "util/Compiler.h" -#include "util/tstring.hpp" +#include #include "util/NumberParser.hpp" #include "system/Path.hpp" @@ -162,11 +162,11 @@ class Args { return result; } - tstring ExpectNextT() { + std::string ExpectNextT() { const char *p = ExpectNext(); assert(p != nullptr); - return tstring(p); + return std::string(p); } Path ExpectNextPath() { diff --git a/src/ui/canvas/Font.hpp b/src/ui/canvas/Font.hpp index 83e7802fa37..294b8e64d41 100644 --- a/src/ui/canvas/Font.hpp +++ b/src/ui/canvas/Font.hpp @@ -4,7 +4,7 @@ #pragma once #include "ui/dim/Size.hpp" -#include "util/tstring_view.hxx" +#include #if defined(USE_APPKIT) || defined(USE_UIKIT) #import @@ -104,17 +104,17 @@ class Font { #endif [[gnu::pure]] - PixelSize TextSize(tstring_view text) const noexcept; + PixelSize TextSize(std::string_view text) const noexcept; #if defined(USE_FREETYPE) || defined(USE_APPKIT) || defined(USE_UIKIT) static constexpr std::size_t BufferSize(const PixelSize size) noexcept { return std::size_t(size.width) * std::size_t(size.height); } - void Render(tstring_view text, const PixelSize size, + void Render(std::string_view text, const PixelSize size, void *buffer) const noexcept; #elif defined(ANDROID) - std::unique_ptr TextTextureGL(tstring_view text) const noexcept; + std::unique_ptr TextTextureGL(std::string_view text) const noexcept; #elif defined(USE_GDI) HFONT Native() const noexcept { return font; diff --git a/src/ui/canvas/android/Font.cpp b/src/ui/canvas/android/Font.cpp index cf55d5d05c3..026cf169624 100644 --- a/src/ui/canvas/android/Font.cpp +++ b/src/ui/canvas/android/Font.cpp @@ -37,7 +37,7 @@ Font::Destroy() noexcept } PixelSize -Font::TextSize(tstring_view text) const noexcept +Font::TextSize(std::string_view text) const noexcept { if (text_util_object == nullptr || text.empty()) return {0, 0}; @@ -46,7 +46,7 @@ Font::TextSize(tstring_view text) const noexcept } std::unique_ptr -Font::TextTextureGL(tstring_view text) const noexcept +Font::TextTextureGL(std::string_view text) const noexcept { if (!text_util_object) return {}; diff --git a/src/ui/canvas/apple/Font.cpp b/src/ui/canvas/apple/Font.cpp index 5f68d6da994..af13b815b23 100644 --- a/src/ui/canvas/apple/Font.cpp +++ b/src/ui/canvas/apple/Font.cpp @@ -88,7 +88,7 @@ Font::Load(const FontDescription &d) } PixelSize -Font::TextSize(const tstring_view text) const noexcept +Font::TextSize(const std::string_view text) const noexcept { assert(nil != draw_attributes); @@ -106,7 +106,7 @@ Font::TextSize(const tstring_view text) const noexcept } void -Font::Render(tstring_view text, const PixelSize size, +Font::Render(std::string_view text, const PixelSize size, void *buffer) const noexcept { assert(nil != draw_attributes); diff --git a/src/ui/canvas/custom/Cache.cpp b/src/ui/canvas/custom/Cache.cpp index 10ffc58e51b..b0c43e2944a 100644 --- a/src/ui/canvas/custom/Cache.cpp +++ b/src/ui/canvas/custom/Cache.cpp @@ -6,7 +6,7 @@ #include "util/StaticCache.hxx" #include "util/StringCompare.hxx" #include "util/StringAPI.hxx" -#include "util/tstring_view.hxx" +#include #ifdef ENABLE_OPENGL #include "ui/canvas/opengl/Texture.hpp" diff --git a/src/ui/canvas/custom/MoreCanvas.cpp b/src/ui/canvas/custom/MoreCanvas.cpp index 64ed06f1bdc..12809615018 100644 --- a/src/ui/canvas/custom/MoreCanvas.cpp +++ b/src/ui/canvas/custom/MoreCanvas.cpp @@ -37,7 +37,7 @@ Canvas::DrawRaisedEdge(PixelRect &rc) noexcept } unsigned -Canvas::DrawFormattedText(const PixelRect r, const tstring_view text, +Canvas::DrawFormattedText(const PixelRect r, const std::string_view text, const unsigned format) noexcept { assert(ValidateUTF8(text)); @@ -132,7 +132,7 @@ Canvas::DrawFormattedText(const PixelRect r, const tstring_view text, void Canvas::DrawOpaqueText(PixelPoint p, const PixelRect &rc, - tstring_view text) noexcept + std::string_view text) noexcept { DrawFilledRectangle(rc, background_color); DrawTransparentText(p, text); diff --git a/src/ui/canvas/freetype/Font.cpp b/src/ui/canvas/freetype/Font.cpp index 6a1a278b0aa..4c85e84cfae 100644 --- a/src/ui/canvas/freetype/Font.cpp +++ b/src/ui/canvas/freetype/Font.cpp @@ -75,7 +75,7 @@ FT_CEIL(FT_Long x) noexcept [[gnu::pure]] static unsigned -NextChar(tstring_view &s) noexcept +NextChar(std::string_view &s) noexcept { assert(!s.empty()); @@ -203,7 +203,7 @@ Font::Destroy() noexcept } static void -ForEachChar(tstring_view text, std::invocable auto f) +ForEachChar(std::string_view text, std::invocable auto f) { assert(ValidateUTF8(text)); @@ -261,7 +261,7 @@ ForEachGlyph(const FT_Face face, unsigned ascent_height, T &&text, } PixelSize -Font::TextSize(tstring_view text) const noexcept +Font::TextSize(std::string_view text) const noexcept { int maxx = 0; @@ -370,7 +370,7 @@ RenderGlyph(uint8_t *buffer, size_t width, size_t height, } void -Font::Render(tstring_view text, const PixelSize size, +Font::Render(std::string_view text, const PixelSize size, void *_buffer) const noexcept { uint8_t *buffer = (uint8_t *)_buffer; diff --git a/src/ui/canvas/gdi/Canvas.cpp b/src/ui/canvas/gdi/Canvas.cpp index 3b88942fddf..f81ecf0cf4a 100644 --- a/src/ui/canvas/gdi/Canvas.cpp +++ b/src/ui/canvas/gdi/Canvas.cpp @@ -13,7 +13,7 @@ #include "util/UTF8Win.hpp" static bool UTF8TextOut(HDC hdc, const PixelPoint &p, unsigned options, const RECT *r, - tstring_view _text, const int *lpDx) { + std::string_view _text, const int *lpDx) { auto text = UTF8ToWide(_text); #if 1 return ::ExtTextOutW(hdc, p.x, p.y, options, r, text.c_str(), text.size(), @@ -110,11 +110,11 @@ Canvas::DrawArc(PixelPoint center, unsigned radius, } const PixelSize -Canvas::CalcTextSize(tstring_view _text) const noexcept +Canvas::CalcTextSize(std::string_view _text) const noexcept { assert(IsDefined()); - // tstring_view text = UTF8ToWide(_text.data()); + // std::string_view text = UTF8ToWide(_text.data()); auto text = UTF8ToWide(_text); // std::wstring text = UTF8ToWide(_text.data()); @@ -134,7 +134,7 @@ Canvas::GetFontHeight() const } void -Canvas::DrawText(PixelPoint p, tstring_view text) noexcept +Canvas::DrawText(PixelPoint p, std::string_view text) noexcept { assert(IsDefined()); @@ -143,7 +143,7 @@ Canvas::DrawText(PixelPoint p, tstring_view text) noexcept void Canvas::DrawOpaqueText(PixelPoint p, const PixelRect &_rc, - tstring_view text) noexcept + std::string_view text) noexcept { assert(IsDefined()); @@ -153,7 +153,7 @@ Canvas::DrawOpaqueText(PixelPoint p, const PixelRect &_rc, void Canvas::DrawClippedText(PixelPoint p, const PixelRect &_rc, - tstring_view text) noexcept + std::string_view text) noexcept { assert(IsDefined()); @@ -163,7 +163,7 @@ Canvas::DrawClippedText(PixelPoint p, const PixelRect &_rc, void Canvas::DrawClippedText(PixelPoint p, unsigned width, - tstring_view text) noexcept + std::string_view text) noexcept { const PixelSize size = CalcTextSize(text); @@ -350,7 +350,7 @@ Canvas::AlphaBlend(PixelPoint dest_position, PixelSize dest_size, #endif unsigned -Canvas::DrawFormattedText(RECT rc, tstring_view _text, unsigned format) { +Canvas::DrawFormattedText(RECT rc, std::string_view _text, unsigned format) { format |= DT_NOPREFIX | DT_WORDBREAK; auto text = UTF8ToWide(_text); diff --git a/src/ui/canvas/gdi/Canvas.hpp b/src/ui/canvas/gdi/Canvas.hpp index ddc575d3d15..f9a2fb7c242 100644 --- a/src/ui/canvas/gdi/Canvas.hpp +++ b/src/ui/canvas/gdi/Canvas.hpp @@ -9,7 +9,7 @@ #include "ui/canvas/Pen.hpp" #include "ui/dim/Rect.hpp" #include "ui/dim/BulkPoint.hpp" -#include "util/tstring_view.hxx" +#include #include @@ -359,33 +359,33 @@ class Canvas { } [[gnu::pure]] - const PixelSize CalcTextSize(tstring_view text) const noexcept; + const PixelSize CalcTextSize(std::string_view text) const noexcept; [[gnu::pure]] - unsigned CalcTextWidth(tstring_view text) const { + unsigned CalcTextWidth(std::string_view text) const { return CalcTextSize(text).width; } [[gnu::pure]] unsigned GetFontHeight() const; - void DrawText(PixelPoint p, tstring_view text) noexcept; + void DrawText(PixelPoint p, std::string_view text) noexcept; void DrawOpaqueText(PixelPoint p, const PixelRect &rc, - tstring_view text) noexcept; + std::string_view text) noexcept; void DrawClippedText(PixelPoint p, const PixelRect &rc, - tstring_view text) noexcept; + std::string_view text) noexcept; void DrawClippedText(PixelPoint p, unsigned width, - tstring_view text) noexcept; + std::string_view text) noexcept; /** * Render text, clip it within the bounds of this Canvas. */ - void TextAutoClipped(PixelPoint p, tstring_view text) noexcept { + void TextAutoClipped(PixelPoint p, std::string_view text) noexcept { DrawText(p, text); } - unsigned DrawFormattedText(RECT rc, tstring_view _text, unsigned format); + unsigned DrawFormattedText(RECT rc, std::string_view _text, unsigned format); void Copy(PixelPoint dest_position, PixelSize dest_size, HDC src, PixelPoint src_position, diff --git a/src/ui/canvas/gdi/Font.cpp b/src/ui/canvas/gdi/Font.cpp index f271e45153c..9ae6e499d09 100644 --- a/src/ui/canvas/gdi/Font.cpp +++ b/src/ui/canvas/gdi/Font.cpp @@ -31,7 +31,7 @@ Font::Load(const FontDescription &d) } PixelSize -Font::TextSize(tstring_view text) const noexcept +Font::TextSize(std::string_view text) const noexcept { AnyCanvas canvas; canvas.Select(*this); diff --git a/src/ui/canvas/memory/Canvas.cpp b/src/ui/canvas/memory/Canvas.cpp index b3816477310..34e0f71d562 100644 --- a/src/ui/canvas/memory/Canvas.cpp +++ b/src/ui/canvas/memory/Canvas.cpp @@ -196,7 +196,7 @@ Canvas::DrawArc(PixelPoint center, unsigned radius, } const PixelSize -Canvas::CalcTextSize(tstring_view text) const noexcept +Canvas::CalcTextSize(std::string_view text) const noexcept { const std::string_view text2 = text; assert(ValidateUTF8(text)); @@ -215,7 +215,7 @@ Canvas::CalcTextSize(tstring_view text) const noexcept } static TextCache::Result -RenderText(const Font *font, tstring_view text) noexcept +RenderText(const Font *font, std::string_view text) noexcept { if (font == nullptr) return nullptr; @@ -256,7 +256,7 @@ CopyTextRectangle(SDLRasterCanvas &canvas, int x, int y, } void -Canvas::DrawText(PixelPoint p, tstring_view text) noexcept +Canvas::DrawText(PixelPoint p, std::string_view text) noexcept { assert(ValidateUTF8(text)); auto s = RenderText(font, text); @@ -270,7 +270,7 @@ Canvas::DrawText(PixelPoint p, tstring_view text) noexcept } void -Canvas::DrawTransparentText(PixelPoint p, tstring_view text) noexcept +Canvas::DrawTransparentText(PixelPoint p, std::string_view text) noexcept { assert(ValidateUTF8(text)); @@ -286,7 +286,7 @@ Canvas::DrawTransparentText(PixelPoint p, tstring_view text) noexcept void Canvas::DrawClippedText(PixelPoint p, const PixelRect &rc, - tstring_view text) noexcept + std::string_view text) noexcept { // TODO: implement full clipping if (rc.right > p.x) @@ -295,7 +295,7 @@ Canvas::DrawClippedText(PixelPoint p, const PixelRect &rc, void Canvas::DrawClippedText(PixelPoint p, unsigned width, - tstring_view text) noexcept + std::string_view text) noexcept { assert(ValidateUTF8(text)); diff --git a/src/ui/canvas/memory/Canvas.hpp b/src/ui/canvas/memory/Canvas.hpp index 1398d192a1b..07d761018ff 100644 --- a/src/ui/canvas/memory/Canvas.hpp +++ b/src/ui/canvas/memory/Canvas.hpp @@ -12,7 +12,7 @@ #include "PixelTraits.hpp" #include "Buffer.hpp" #include "ActivePixelTraits.hpp" -#include "util/tstring_view.hxx" +#include #include @@ -250,10 +250,10 @@ class Canvas { } [[gnu::pure]] - const PixelSize CalcTextSize(tstring_view text) const noexcept; + const PixelSize CalcTextSize(std::string_view text) const noexcept; [[gnu::pure]] - unsigned CalcTextWidth(tstring_view text) const noexcept { + unsigned CalcTextWidth(std::string_view text) const noexcept { return CalcTextSize(text).width; } @@ -262,22 +262,22 @@ class Canvas { return font != nullptr ? font->GetHeight() : 0; } - void DrawText(PixelPoint p, tstring_view text) noexcept; + void DrawText(PixelPoint p, std::string_view text) noexcept; - void DrawTransparentText(PixelPoint p, tstring_view text) noexcept; + void DrawTransparentText(PixelPoint p, std::string_view text) noexcept; void DrawOpaqueText(PixelPoint p, const PixelRect &rc, - tstring_view text) noexcept; + std::string_view text) noexcept; void DrawClippedText(PixelPoint p, const PixelRect &rc, - tstring_view text) noexcept; + std::string_view text) noexcept; void DrawClippedText(PixelPoint p, unsigned width, - tstring_view text) noexcept; + std::string_view text) noexcept; /** * Render text, clip it within the bounds of this Canvas. */ - void TextAutoClipped(PixelPoint p, tstring_view t) noexcept { + void TextAutoClipped(PixelPoint p, std::string_view t) noexcept { DrawText(p, t); } @@ -286,7 +286,7 @@ class Canvas { * * @return the resulting text height */ - unsigned DrawFormattedText(PixelRect r, tstring_view text, + unsigned DrawFormattedText(PixelRect r, std::string_view text, unsigned format) noexcept; void Copy(PixelPoint dest_position, PixelSize dest_size, diff --git a/src/ui/canvas/opengl/Canvas.cpp b/src/ui/canvas/opengl/Canvas.cpp index 5aa15615228..22dca69ce18 100644 --- a/src/ui/canvas/opengl/Canvas.cpp +++ b/src/ui/canvas/opengl/Canvas.cpp @@ -73,8 +73,8 @@ Canvas::InvertRectangle(PixelRect r) noexcept glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); } -static tstring_view -ClipText(const Font &font, tstring_view text, +static std::string_view +ClipText(const Font &font, std::string_view text, int x, unsigned canvas_width) noexcept { if (text.empty() || x >= int(canvas_width)) @@ -535,7 +535,7 @@ Canvas::DrawFocusRectangle(PixelRect rc) noexcept } const PixelSize -Canvas::CalcTextSize(tstring_view text) const noexcept +Canvas::CalcTextSize(std::string_view text) const noexcept { const std::string_view text2 = text; assert(ValidateUTF8(text)); @@ -564,7 +564,7 @@ PrepareColoredAlphaTexture(Color color) noexcept } void -Canvas::DrawText(PixelPoint p, tstring_view text) noexcept +Canvas::DrawText(PixelPoint p, std::string_view text) noexcept { const std::string_view text2 = text; assert(ValidateUTF8(text)); @@ -594,7 +594,7 @@ Canvas::DrawText(PixelPoint p, tstring_view text) noexcept } void -Canvas::DrawTransparentText(PixelPoint p, tstring_view text) noexcept +Canvas::DrawTransparentText(PixelPoint p, std::string_view text) noexcept { const std::string_view text2 = text; assert(ValidateUTF8(text)); @@ -622,7 +622,7 @@ Canvas::DrawTransparentText(PixelPoint p, tstring_view text) noexcept void Canvas::DrawClippedText(PixelPoint p, PixelSize size, - tstring_view text) noexcept + std::string_view text) noexcept { const std::string_view text2 = text; assert(ValidateUTF8(text)); diff --git a/src/ui/canvas/opengl/Canvas.hpp b/src/ui/canvas/opengl/Canvas.hpp index 5e4357000d8..c092073d297 100644 --- a/src/ui/canvas/opengl/Canvas.hpp +++ b/src/ui/canvas/opengl/Canvas.hpp @@ -274,10 +274,10 @@ class Canvas { void DrawFocusRectangle(PixelRect rc) noexcept; [[gnu::pure]] - const PixelSize CalcTextSize(tstring_view text) const noexcept; + const PixelSize CalcTextSize(std::string_view text) const noexcept; [[gnu::pure]] - unsigned CalcTextWidth(tstring_view text) const noexcept { + unsigned CalcTextWidth(std::string_view text) const noexcept { return CalcTextSize(text).width; } @@ -286,15 +286,15 @@ class Canvas { return font != nullptr ? font->GetHeight() : 0; } - void DrawText(PixelPoint p, tstring_view text) noexcept; + void DrawText(PixelPoint p, std::string_view text) noexcept; - void DrawTransparentText(PixelPoint p, tstring_view text) noexcept; + void DrawTransparentText(PixelPoint p, std::string_view text) noexcept; void DrawOpaqueText(PixelPoint p, const PixelRect &rc, - tstring_view text) noexcept; + std::string_view text) noexcept; void DrawClippedText(PixelPoint p, const PixelRect &rc, - tstring_view text) noexcept { + std::string_view text) noexcept { // XXX if (p.x < rc.right) @@ -302,17 +302,17 @@ class Canvas { } void DrawClippedText(PixelPoint p, PixelSize size, - tstring_view text) noexcept; + std::string_view text) noexcept; void DrawClippedText(PixelPoint p, unsigned width, - tstring_view text) noexcept { + std::string_view text) noexcept { DrawClippedText(p, {width, 16384u}, text); } /** * Render text, clip it within the bounds of this Canvas. */ - void TextAutoClipped(PixelPoint p, tstring_view t) noexcept { + void TextAutoClipped(PixelPoint p, std::string_view t) noexcept { if (p.x < (int)GetWidth() && p.y < (int)GetHeight()) DrawClippedText(p, {GetWidth() - p.x, GetHeight() - p.y}, t); } @@ -322,7 +322,7 @@ class Canvas { * * @return the resulting text height */ - unsigned DrawFormattedText(PixelRect r, tstring_view text, + unsigned DrawFormattedText(PixelRect r, std::string_view text, unsigned format) noexcept; /** diff --git a/src/ui/control/LargeTextWindow.hpp b/src/ui/control/LargeTextWindow.hpp index 7477b97e6d2..d0d275f2512 100644 --- a/src/ui/control/LargeTextWindow.hpp +++ b/src/ui/control/LargeTextWindow.hpp @@ -7,7 +7,7 @@ #ifndef USE_WINUSER #include "Renderer/TextRenderer.hpp" -#include "util/tstring.hpp" +#include #endif #include @@ -36,7 +36,7 @@ class LargeTextWindow : public NativeWindow { #ifndef USE_WINUSER const Font *font = nullptr; - tstring value; + std::string value; /** * The first visible line. diff --git a/src/util/DollarExpand.hpp b/src/util/DollarExpand.hpp index 8c51dd3f03c..db93b94901f 100644 --- a/src/util/DollarExpand.hpp +++ b/src/util/DollarExpand.hpp @@ -5,7 +5,7 @@ #include "StringAPI.hxx" #include "TruncateString.hpp" -#include "tstring_view.hxx" +#include #include #include @@ -19,7 +19,7 @@ */ void DollarExpand(const char *src, std::span dest, - std::invocable auto lookup_function) noexcept + std::invocable auto lookup_function) noexcept { while (true) { auto dollar = StringFind(src, _T("$(")); @@ -31,7 +31,7 @@ DollarExpand(const char *src, std::span dest, if (closing == nullptr) break; - const tstring_view name(name_start, closing - name_start); + const std::string_view name(name_start, closing - name_start); const std::size_t prefix_size = dollar - src; if (prefix_size >= dest.size()) @@ -48,7 +48,7 @@ DollarExpand(const char *src, std::span dest, const char *const expansion = lookup_function(name); if (expansion != nullptr) { - const tstring_view ex{expansion}; + const std::string_view ex{expansion}; if (ex.size() >= dest.size()) break; diff --git a/src/util/EscapeBackslash.cpp b/src/util/EscapeBackslash.cpp index 54abaa16cb0..78f5232860e 100644 --- a/src/util/EscapeBackslash.cpp +++ b/src/util/EscapeBackslash.cpp @@ -6,14 +6,14 @@ #include #include -tstring_view::pointer -UnescapeBackslash(tstring_view old_string) noexcept +std::string_view::pointer +UnescapeBackslash(std::string_view old_string) noexcept { char buffer[2048]; // Note - max size of any string we cope with here ! - tstring_view::size_type used = 0; + std::string_view::size_type used = 0; - for (tstring_view::size_type i = 0; i < old_string.size(); i++) { + for (std::string_view::size_type i = 0; i < old_string.size(); i++) { if (used < 2045) { if (old_string[i] == '\\') { if (old_string[i + 1] == 'r') { diff --git a/src/util/EscapeBackslash.hpp b/src/util/EscapeBackslash.hpp index d9ee99bb6ee..7ed0310bdc1 100644 --- a/src/util/EscapeBackslash.hpp +++ b/src/util/EscapeBackslash.hpp @@ -3,7 +3,7 @@ #pragma once -#include "util/tstring_view.hxx" +#include /** * Parses the special characters (cr, lf, back slash) in the old_string and @@ -11,5 +11,5 @@ * @param old_string The old string with (or without) special characters * @return The new parsed string */ -tstring_view::pointer -UnescapeBackslash(tstring_view old_string) noexcept; +std::string_view::pointer +UnescapeBackslash(std::string_view old_string) noexcept; diff --git a/src/util/RadixTree.hpp b/src/util/RadixTree.hpp index 8686005fdef..05ad0df2f6c 100644 --- a/src/util/RadixTree.hpp +++ b/src/util/RadixTree.hpp @@ -5,7 +5,7 @@ #include "StaticString.hxx" #include "StringCompare.hxx" -#include "tstring.hpp" +#include #include #include @@ -427,7 +427,7 @@ class RadixTree { */ template void VisitValues(const char *prefix, V &visitor) const { - tstring key(prefix); + std::string key(prefix); key.append(label); const KeyVisitorAdapter adapter(visitor, key.c_str()); @@ -465,7 +465,7 @@ class RadixTree { */ template void VisitAllChildren(const char *prefix, V &visitor) const { - tstring key(prefix); + std::string key(prefix); key.append(label); for (const Node *node = children; node != nullptr; diff --git a/src/util/tstring.hpp b/src/util/tstring.hpp index 4901fbda465..2288c69ff20 100644 --- a/src/util/tstring.hpp +++ b/src/util/tstring.hpp @@ -5,4 +5,4 @@ #include -using tstring = std::string; +using std::string = std::string; diff --git a/src/util/tstring_view.hxx b/src/util/tstring_view.hxx index 65f44557eba..0a822c4155b 100644 --- a/src/util/tstring_view.hxx +++ b/src/util/tstring_view.hxx @@ -5,4 +5,4 @@ #include -using tstring_view = std::string_view; +using std::string_view = std::string_view; diff --git a/test/src/DebugReplayNMEA.cpp b/test/src/DebugReplayNMEA.cpp index 4d330369f0c..c316c1e99bd 100644 --- a/test/src/DebugReplayNMEA.cpp +++ b/test/src/DebugReplayNMEA.cpp @@ -23,7 +23,7 @@ DebugReplayNMEA::DebugReplayNMEA(FileLineReaderA *_reader, } DebugReplay* -DebugReplayNMEA::Create(Path input_file, const tstring &driver_name) +DebugReplayNMEA::Create(Path input_file, const std::string &driver_name) { const struct DeviceRegister *driver = FindDriverByName(driver_name.c_str()); if (driver == NULL) { diff --git a/test/src/DebugReplayNMEA.hpp b/test/src/DebugReplayNMEA.hpp index 7790835b6df..7e4eb7ae9a3 100644 --- a/test/src/DebugReplayNMEA.hpp +++ b/test/src/DebugReplayNMEA.hpp @@ -27,5 +27,5 @@ class DebugReplayNMEA : public DebugReplayFile { public: virtual bool Next(); - static DebugReplay *Create(Path input_file, const tstring &driver_name); + static DebugReplay *Create(Path input_file, const std::string &driver_name); }; diff --git a/test/src/RunDeclare.cpp b/test/src/RunDeclare.cpp index da850a41aa3..fafcf6f5d41 100644 --- a/test/src/RunDeclare.cpp +++ b/test/src/RunDeclare.cpp @@ -86,7 +86,7 @@ int main(int argc, char **argv) try { Args args(argc, argv, "[--through DRIVER0] DRIVER PORT BAUD"); - tstring _through_name; + std::string _through_name; const char *through_name = NULL; const char *a; @@ -99,7 +99,7 @@ try { args.UsageError(); } - tstring _driver_name = args.ExpectNextT(); + std::string _driver_name = args.ExpectNextT(); const char *driver_name = _driver_name.c_str(); DebugPort debug_port(args); args.ExpectEnd(); diff --git a/test/src/RunDeviceDriver.cpp b/test/src/RunDeviceDriver.cpp index 289aa1d4b17..33a7b8452a5 100644 --- a/test/src/RunDeviceDriver.cpp +++ b/test/src/RunDeviceDriver.cpp @@ -172,7 +172,7 @@ int main(int argc, char **argv) } Args args(argc, argv, usage); - tstring driver_name = args.ExpectNextT(); + std::string driver_name = args.ExpectNextT(); args.ExpectEnd(); driver = FindDriverByName(driver_name.c_str()); diff --git a/test/src/RunDownloadFlight.cpp b/test/src/RunDownloadFlight.cpp index c1b7792a96f..5ff98ef97aa 100644 --- a/test/src/RunDownloadFlight.cpp +++ b/test/src/RunDownloadFlight.cpp @@ -77,7 +77,7 @@ try { } Args args(argc, argv, usage); - tstring driver_name = args.ExpectNextT(); + std::string driver_name = args.ExpectNextT(); DebugPort debug_port(args); const auto path = args.ExpectNextPath(); diff --git a/test/src/RunEnableNMEA.cpp b/test/src/RunEnableNMEA.cpp index c1c6686d9e2..86d28ad575e 100644 --- a/test/src/RunEnableNMEA.cpp +++ b/test/src/RunEnableNMEA.cpp @@ -63,7 +63,7 @@ int main(int argc, char **argv) try { Args args(argc, argv, "DRIVER PORT BAUD"); - tstring _driver_name = args.ExpectNextT(); + std::string _driver_name = args.ExpectNextT(); const char *driver_name = _driver_name.c_str(); DebugPort debug_port(args); args.ExpectEnd(); diff --git a/test/src/RunFlightList.cpp b/test/src/RunFlightList.cpp index 0e6ef7fb959..7b28b73da49 100644 --- a/test/src/RunFlightList.cpp +++ b/test/src/RunFlightList.cpp @@ -71,7 +71,7 @@ try { } Args args(argc, argv, usage); - tstring driver_name = args.ExpectNextT(); + std::string driver_name = args.ExpectNextT(); DebugPort debug_port(args); args.ExpectEnd(); diff --git a/test/src/RunInputParser.cpp b/test/src/RunInputParser.cpp index f507f705c82..b099104a2fe 100644 --- a/test/src/RunInputParser.cpp +++ b/test/src/RunInputParser.cpp @@ -13,7 +13,7 @@ #include pt2Event -InputEvents::findEvent(tstring_view name) noexcept +InputEvents::findEvent(std::string_view name) noexcept { union { const char *in; diff --git a/test/src/RunLiveTrack24.cpp b/test/src/RunLiveTrack24.cpp index fc51bccd9ef..6a5fec2ebd4 100644 --- a/test/src/RunLiveTrack24.cpp +++ b/test/src/RunLiveTrack24.cpp @@ -30,7 +30,7 @@ TestTracking(int argc, char *argv[], LiveTrack24::Client &client) bool has_user_id; UserID user_id; - tstring username, password; + std::string username, password; if (args.IsEmpty()) { username = _T(""); password = _T(""); diff --git a/test/src/TestRadixTree.cpp b/test/src/TestRadixTree.cpp index e06da1025c8..b33a3e2770d 100644 --- a/test/src/TestRadixTree.cpp +++ b/test/src/TestRadixTree.cpp @@ -37,7 +37,7 @@ prefix_sum(const RadixTree &rt, const char *prefix) template struct AscendingKeyVisitor { - tstring last; + std::string last; void operator()(const char *key, [[maybe_unused]] const T &value) { ok1(last.compare(key) <= 0); diff --git a/test/src/TestTaskSave.cpp b/test/src/TestTaskSave.cpp index 7fff071746a..257a18790f4 100644 --- a/test/src/TestTaskSave.cpp +++ b/test/src/TestTaskSave.cpp @@ -24,7 +24,7 @@ MakeGeoPoint(double longitude, double latitude) noexcept } static Waypoint -MakeWaypoint(Waypoint wp, double altitude, tstring name, unsigned id) noexcept +MakeWaypoint(Waypoint wp, double altitude, std::string name, unsigned id) noexcept { wp.name = name; wp.id = id; @@ -34,7 +34,7 @@ MakeWaypoint(Waypoint wp, double altitude, tstring name, unsigned id) noexcept } static Waypoint -MakeWaypoint(double longitude, double latitude, double altitude, tstring name, unsigned id) noexcept +MakeWaypoint(double longitude, double latitude, double altitude, std::string name, unsigned id) noexcept { return MakeWaypoint(Waypoint(MakeGeoPoint(longitude, latitude)), altitude, name, id); } diff --git a/test/src/TestWaypointReader.cpp b/test/src/TestWaypointReader.cpp index 9f7d46f8576..e66a56b232e 100644 --- a/test/src/TestWaypointReader.cpp +++ b/test/src/TestWaypointReader.cpp @@ -11,7 +11,7 @@ #include "system/Path.hpp" #include "io/BufferedOutputStream.hxx" #include "io/StringOutputStream.hxx" -#include "util/tstring.hpp" +#include #include "util/StringAPI.hxx" #include "util/StringStrip.hxx" #include "Operation/Operation.hpp" @@ -179,9 +179,9 @@ TestZanderWaypoint(const Waypoint org_wp, const Waypoint *wp) } static void -TruncateStrip(tstring &s, std::size_t max_length) noexcept +TruncateStrip(std::string &s, std::size_t max_length) noexcept { - tstring_view v = s; + std::string_view v = s; if (v.size() > max_length) v = v.substr(0, max_length); v = Strip(v); @@ -248,7 +248,7 @@ TestOzi(const wp_vector &org_wp) } for (auto i : org_wp) { - i.name = tstring{Strip(i.name)}; + i.name = std::string{Strip(i.name)}; GetWaypoint(i, way_points); } } @@ -265,7 +265,7 @@ TestCompeGPS(const wp_vector &org_wp) for (auto i : org_wp) { size_t pos; - while ((pos = i.name.find_first_of(_T(' '))) != tstring::npos) + while ((pos = i.name.find_first_of(_T(' '))) != std::string::npos) i.name.erase(pos, 1); TruncateStrip(i.name, 6); @@ -286,7 +286,7 @@ TestCompeGPS_UTM(const wp_vector &org_wp) for (auto i : org_wp) { size_t pos; - while ((pos = i.name.find_first_of(_T(' '))) != tstring::npos) + while ((pos = i.name.find_first_of(_T(' '))) != std::string::npos) i.name.erase(pos, 1); TruncateStrip(i.name, 6); diff --git a/test/src/TestWaypoints.cpp b/test/src/TestWaypoints.cpp index 9cfe52d6866..91c2e7afd85 100644 --- a/test/src/TestWaypoints.cpp +++ b/test/src/TestWaypoints.cpp @@ -268,7 +268,7 @@ TestReplace(Waypoints& waypoints, unsigned id) if (wp == NULL) return false; - tstring oldName = wp->name; + std::string oldName = wp->name; Waypoint copy = *wp; copy.name = _T("Fred"); From 2c4370f68d2fa03e7b1c2db1042de38e4c815420 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 23 Apr 2024 16:26:10 +0200 Subject: [PATCH 380/403] [UTF8] io/FileDescriptor removing wchar_t (used in Windows) --- src/io/FileDescriptor.cxx | 11 ----------- src/io/FileDescriptor.hxx | 10 +--------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/src/io/FileDescriptor.cxx b/src/io/FileDescriptor.cxx index 45c740ee222..84d329f1286 100644 --- a/src/io/FileDescriptor.cxx +++ b/src/io/FileDescriptor.cxx @@ -73,17 +73,6 @@ FileDescriptor::Open(const char *pathname, int flags, mode_t mode) noexcept return IsDefined(); } -#ifdef _WIN32 - -bool -FileDescriptor::Open(const wchar_t *pathname, int flags, mode_t mode) noexcept -{ - fd = ::_wopen(pathname, flags | O_NOCTTY | O_CLOEXEC, mode); - return IsDefined(); -} - -#endif - bool FileDescriptor::OpenReadOnly(const char *pathname) noexcept { diff --git a/src/io/FileDescriptor.hxx b/src/io/FileDescriptor.hxx index 9ffca93dffd..1f84f80539f 100644 --- a/src/io/FileDescriptor.hxx +++ b/src/io/FileDescriptor.hxx @@ -17,11 +17,8 @@ #else # include #endif -#include -#ifdef _WIN32 -#include -#endif +#include class UniqueFileDescriptor; @@ -115,11 +112,6 @@ public: [[nodiscard]] bool Open(const char *pathname, int flags, mode_t mode=0666) noexcept; -#ifdef _WIN32 - [[nodiscard]] - bool Open(const wchar_t *pathname, int flags, mode_t mode=0666) noexcept; -#endif - [[nodiscard]] bool OpenReadOnly(const char *pathname) noexcept; From 8717b5619e13e11902ba4fa8516e2493e154ba54 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 23 Apr 2024 16:32:46 +0200 Subject: [PATCH 381/403] [UTF8] Windows - use only char* strings for resource, not WideChar.. --- tools/python/create_resource.py | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/tools/python/create_resource.py b/tools/python/create_resource.py index ec1d1914477..7f4c65bd6c5 100644 --- a/tools/python/create_resource.py +++ b/tools/python/create_resource.py @@ -13,20 +13,14 @@ # def write_resource(outfile, line, macro, type, extension): def create_line(name, res_name, path, file, ext): line = '{:30s}'.format(name) + ' ' + '{:12s}'.format(res_name) - line = line + 'DISCARDABLE L"' + path + '/' + line = line + 'DISCARDABLE "' + path + '/' line = line + file + '.' + ext + '"' - # line = '{:30s}'.format(params[1]) + ' ' + '{:12s}'.format(resource[2]) - # line = line + 'DISCARDABLE L"' + resource[3] + '/' - # line = line + params[2].strip(' \n').replace('"','') + resource[4] + '"' outfile.write(line + '\n') # Copy of read line (with replaced field) if debug: print(line) ## return line def write_resource(outfile, line, resource): - # line = line.replace(resource[0]+'(','') - # line = line.replace(')','') - # params = line.split(',') params = line.split(' ') # if debug: if len(params) >= 2: @@ -76,15 +70,7 @@ def write_line(outfile, line): src_location1 = sys.argv[3] src_location2 = sys.argv[4] - -### res_array.append(['BITMAP_ICON', 'BITMAP', src_location2 + '/icons', '.bmp']) -### res_array.append(['BITMAP_BITMAP', 'BITMAP', src_location1 + '/bitmaps', '.bmp']) -### res_array.append(['BITMAP_GRAPHIC','BITMAP', src_location2 + '/graphics', '.bmp']) -### res_array.append(['HATCH_BITMAP', 'BITMAP', src_location1 + '/bitmaps', '.bmp']) -### res_array.append(['SOUND', 'WAVE', src_location1 + '/sound', '.wav']) -### res_array.append(['ICON_ICON', 'ICON', src_location1 + '/bitmaps', '.ico']) - -# res_array.append(['bitmap_icon ', 'BITMAP', src_location2 + '/icons', '.bmp']) + res_array.append(['bitmap_icon_scaled ', 'BITMAP_ICON', 'BITMAP', src_location2 + '/icons', 'bmp']) res_array.append(['bitmap_bitmap ', 'BITMAP_BITMAP', 'BITMAP', src_location1 + '/bitmaps', 'bmp']) res_array.append(['bitmap_graphic ', 'BITMAP_GRAPHIC','BITMAP', src_location2 + '/graphics', 'bmp']) From 380e39e58bd794f0b58b3bee15073cc92ca7ee93 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 22 Apr 2024 18:35:25 +0200 Subject: [PATCH 382/403] [UTF8] remove all WString files from system (util/*) --- build/libutil.mk | 8 +- src/util/CMakeSource.cmake | 6 -- src/util/WASCII.cxx | 84 ---------------- src/util/WASCII.hxx | 37 -------- src/util/WCharUtil.hxx | 120 ----------------------- src/util/WStringAPI.hxx | 184 ------------------------------------ src/util/WStringCompare.cxx | 43 --------- src/util/WStringCompare.hxx | 94 ------------------ src/util/WStringFormat.hpp | 49 ---------- src/util/WStringStrip.cxx | 88 ----------------- src/util/WStringStrip.hxx | 86 ----------------- src/util/WStringUtil.cpp | 35 ------- src/util/WStringUtil.hpp | 24 ----- src/util/tstring.hpp | 8 -- src/util/tstring_view.hxx | 8 -- 15 files changed, 2 insertions(+), 872 deletions(-) delete mode 100644 src/util/WASCII.cxx delete mode 100644 src/util/WASCII.hxx delete mode 100644 src/util/WCharUtil.hxx delete mode 100644 src/util/WStringAPI.hxx delete mode 100644 src/util/WStringCompare.cxx delete mode 100644 src/util/WStringCompare.hxx delete mode 100644 src/util/WStringFormat.hpp delete mode 100644 src/util/WStringStrip.cxx delete mode 100644 src/util/WStringStrip.hxx delete mode 100644 src/util/WStringUtil.cpp delete mode 100644 src/util/WStringUtil.hpp delete mode 100644 src/util/tstring.hpp delete mode 100644 src/util/tstring_view.hxx diff --git a/build/libutil.mk b/build/libutil.mk index ac0dd04782b..5e47891d289 100644 --- a/build/libutil.mk +++ b/build/libutil.mk @@ -19,13 +19,9 @@ UTIL_SOURCES = \ $(UTIL_SRC_DIR)/StringUtil.cpp ifeq ($(HAVE_MSVCRT),y) +# move this code in UTF8.cpp! UTIL_SOURCES += \ - $(UTIL_SRC_DIR)/UTF8Win.cpp \ - \ - $(UTIL_SRC_DIR)/WASCII.cxx \ - $(UTIL_SRC_DIR)/WStringCompare.cpp \ - $(UTIL_SRC_DIR)/WStringStrip.cxx \ - $(UTIL_SRC_DIR)/WStringUtil.cpp + $(UTIL_SRC_DIR)/UTF8Win.cpp endif $(eval $(call link-library,util,UTIL)) diff --git a/src/util/CMakeSource.cmake b/src/util/CMakeSource.cmake index 7c034b0c91d..1b7caab6e5c 100644 --- a/src/util/CMakeSource.cmake +++ b/src/util/CMakeSource.cmake @@ -11,18 +11,12 @@ set(_SOURCES util/StringStrip.cxx util/StringUtil.cpp util/TruncateString.cpp - # removed 7.36: util/tstring.cpp util/UTF8.cpp util/MD5.cpp # new with 6.8.14 util/DecimalParser.cxx # new with 7.40 ) if(WIN32) list(APPEND _SOURCES - util/WASCII.cxx - util/WStringCompare.cxx - util/WStringStrip.cxx - util/WStringUtil.cpp - util/UTF8Win.cpp ) endif() diff --git a/src/util/WASCII.cxx b/src/util/WASCII.cxx deleted file mode 100644 index 05ae8db8288..00000000000 --- a/src/util/WASCII.cxx +++ /dev/null @@ -1,84 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -// author: Max Kellermann - -#include "WASCII.hxx" -#include "WCharUtil.hxx" - -#include - -template -static D * -TemplateCopyASCII(D *dest, std::size_t dest_size, - std::basic_string_view src) noexcept -{ - const auto dest_end = dest + dest_size; - for (const auto ch : src) { - if (!IsASCII(ch)) - continue; - - if (dest == dest_end) - break; - - *dest++ = ch; - } - - return dest; -} - -void -CopyASCII(wchar_t *dest, const wchar_t *src) noexcept -{ - do { - if (IsASCII(*src)) - *dest++ = *src; - } while (*src++ != L'\0'); -} - -wchar_t * -CopyASCII(wchar_t *dest, std::size_t dest_size, - std::wstring_view src) noexcept -{ - return TemplateCopyASCII(dest, dest_size, src); -} - -void -CopyASCII(wchar_t *dest, const char *src) noexcept -{ - do { - if (IsASCII(*src)) - *dest++ = (wchar_t)*src; - } while (*src++ != '\0'); -} - -wchar_t * -CopyASCII(wchar_t *dest, std::size_t dest_size, - std::string_view src) noexcept -{ - return TemplateCopyASCII(dest, dest_size, src); -} - -char * -CopyASCII(char *dest, std::size_t dest_size, - std::wstring_view src) noexcept -{ - return TemplateCopyASCII(dest, dest_size, src); -} - -char * -CopyASCIIUpper(char *dest, std::size_t dest_size, - std::wstring_view src) noexcept -{ - const auto dest_end = dest + dest_size; - for (auto t : src) { - if (!IsASCII(t)) - continue; - - if (dest == dest_end) - break; - - char ch = (char)t; - *dest++ = ToUpperASCII(ch); - } - - return dest; -} diff --git a/src/util/WASCII.hxx b/src/util/WASCII.hxx deleted file mode 100644 index 9d93cceba93..00000000000 --- a/src/util/WASCII.hxx +++ /dev/null @@ -1,37 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -// author: Max Kellermann - -#pragma once - -#include -#include - -#include - -[[gnu::nonnull]] -void -CopyASCII(wchar_t *dest, const wchar_t *src) noexcept; - -[[gnu::nonnull]] -wchar_t * -CopyASCII(wchar_t *dest, std::size_t dest_size, - std::wstring_view src) noexcept; - -[[gnu::nonnull]] -void -CopyASCII(wchar_t *dest, const char *src) noexcept; - -[[gnu::nonnull]] -wchar_t * -CopyASCII(wchar_t *dest, std::size_t dest_size, - std::string_view src) noexcept; - -[[gnu::nonnull]] -char * -CopyASCII(char *dest, std::size_t dest_size, - std::wstring_view src) noexcept; - -[[gnu::nonnull]] -char * -CopyASCIIUpper(char *dest, std::size_t dest_size, - std::wstring_view src) noexcept; diff --git a/src/util/WCharUtil.hxx b/src/util/WCharUtil.hxx deleted file mode 100644 index 4117be8626a..00000000000 --- a/src/util/WCharUtil.hxx +++ /dev/null @@ -1,120 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -// author: Max Kellermann - -#pragma once - -#include - -constexpr bool -IsASCII(const wchar_t ch) noexcept -{ - return (ch & ~0x7f) == 0; -} - -constexpr bool -IsWhitespaceOrNull(const wchar_t ch) noexcept -{ - return (unsigned)ch <= 0x20; -} - -constexpr bool -IsWhitespaceNotNull(const wchar_t ch) noexcept -{ - return ch > 0 && ch <= 0x20; -} - -/** - * Is the given character whitespace? This calls the faster one of - * IsWhitespaceOrNull() or IsWhitespaceNotNull(). Use this if you - * want the fastest implementation, and you don't care if a null byte - * matches. - */ -constexpr bool -IsWhitespaceFast(const wchar_t ch) noexcept -{ - return IsWhitespaceOrNull(ch); -} - -/** - * Is this a non-printable ASCII character? Returns false for - * non-ASCII characters. - * - * Note that this is not the opposide of IsNonPrintableASCII(). - */ -constexpr bool -IsPrintableASCII(wchar_t ch) noexcept -{ - return IsASCII(ch) && ch >= 0x20; -} - -/** - * Is this a non-printable character? Returns false for non-ASCII - * characters. - * - * Note that this is not the opposide of IsPrintableASCII() - */ -constexpr bool -IsNonPrintableASCII(wchar_t ch) noexcept -{ - return (unsigned)ch < 0x20; -} - -constexpr bool -IsDigitASCII(wchar_t ch) noexcept -{ - return ch >= '0' && ch <= '9'; -} - -constexpr bool -IsUpperAlphaASCII(wchar_t ch) noexcept -{ - return ch >= 'A' && ch <= 'Z'; -} - -constexpr bool -IsLowerAlphaASCII(wchar_t ch) noexcept -{ - return ch >= 'a' && ch <= 'z'; -} - -constexpr bool -IsAlphaASCII(wchar_t ch) noexcept -{ - return IsUpperAlphaASCII(ch) || IsLowerAlphaASCII(ch); -} - -constexpr bool -IsAlphaNumericASCII(wchar_t ch) noexcept -{ - return IsAlphaASCII(ch) || IsDigitASCII(ch); -} - -constexpr bool -IsLowerAlphaNumericASCII(wchar_t ch) noexcept -{ - return IsLowerAlphaASCII(ch) || IsDigitASCII(ch); -} - -/** - * Convert the specified ASCII character (0x00..0x7f) to upper case. - * Unlike toupper(), it ignores the system locale. - */ -constexpr wchar_t -ToUpperASCII(wchar_t ch) noexcept -{ - return ch >= 'a' && ch <= 'z' - ? (ch - ('a' - 'A')) - : ch; -} - -/** - * Convert the specified ASCII character (0x00..0x7f) to lower case. - * Unlike tolower(), it ignores the system locale. - */ -constexpr wchar_t -ToLowerASCII(wchar_t ch) noexcept -{ - return ch >= 'A' && ch <= 'Z' - ? (ch + ('a' - 'A')) - : ch; -} diff --git a/src/util/WStringAPI.hxx b/src/util/WStringAPI.hxx deleted file mode 100644 index ec79d014321..00000000000 --- a/src/util/WStringAPI.hxx +++ /dev/null @@ -1,184 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -// author: Max Kellermann - -#pragma once - -#include - -[[gnu::pure]] [[gnu::nonnull]] -static inline size_t -StringLength(const wchar_t *p) noexcept -{ - return wcslen(p); -} - -[[gnu::pure]] [[gnu::nonnull]] -static inline const wchar_t * -StringFind(const wchar_t *haystack, const wchar_t *needle) noexcept -{ - return wcsstr(haystack, needle); -} - -[[gnu::pure]] [[gnu::nonnull]] -static inline const wchar_t * -StringFind(const wchar_t *haystack, wchar_t needle, size_t size) noexcept -{ - return std::wmemchr(haystack, needle, size); -} - -[[gnu::pure]] [[gnu::nonnull]] -static inline wchar_t * -StringFind(wchar_t *haystack, wchar_t needle, size_t size) noexcept -{ - return std::wmemchr(haystack, needle, size); -} - -[[gnu::pure]] [[gnu::nonnull]] -static inline const wchar_t * -StringFind(const wchar_t *haystack, wchar_t needle) noexcept -{ - return wcschr(haystack, needle); -} - -[[gnu::pure]] [[gnu::nonnull]] -static inline wchar_t * -StringFind(wchar_t *haystack, wchar_t needle) noexcept -{ - return wcschr(haystack, needle); -} - -[[gnu::pure]] [[gnu::nonnull]] -static inline const wchar_t * -StringFindLast(const wchar_t *haystack, wchar_t needle) noexcept -{ - return wcsrchr(haystack, needle); -} - -[[gnu::pure]] [[gnu::nonnull]] -static inline wchar_t * -StringFindLast(wchar_t *haystack, wchar_t needle) noexcept -{ - return wcsrchr(haystack, needle); -} - -[[gnu::pure]] [[gnu::nonnull]] -static inline const wchar_t * -StringFindLast(const wchar_t *haystack, wchar_t needle, size_t size) noexcept -{ - /* there's no wmemrchr() unfortunately */ - const auto *p = haystack + size; - while (p > haystack) { - --p; - if (*p == needle) - return p; - } - - return nullptr; -} - -[[gnu::pure]] [[gnu::nonnull]] -static inline const wchar_t * -StringFindAny(const wchar_t *haystack, const wchar_t *accept) noexcept -{ - return wcspbrk(haystack, accept); -} - -[[gnu::nonnull]] -static inline void -UnsafeCopyString(wchar_t *dest, const wchar_t *src) noexcept -{ - wcscpy(dest, src); -} - -[[gnu::returns_nonnull]] [[gnu::nonnull]] -static inline wchar_t * -UnsafeCopyStringP(wchar_t *dest, const wchar_t *src) noexcept -{ -#if defined(_WIN32) || defined(__OpenBSD__) || defined(__NetBSD__) - /* emulate wcpcpy() */ - UnsafeCopyString(dest, src); - return dest + StringLength(dest); -#elif defined(__sun) && defined (__SVR4) - return std::wcpcpy(dest, src); -#else - return wcpcpy(dest, src); -#endif -} - -[[gnu::pure]] [[gnu::nonnull]] -static inline int -StringCompare(const wchar_t *a, const wchar_t *b) noexcept -{ - return wcscmp(a, b); -} - -[[gnu::pure]] [[gnu::nonnull]] -static inline int -StringCompare(const wchar_t *a, const wchar_t *b, size_t n) noexcept -{ - return wcsncmp(a, b, n); -} - -/** - * Checks whether str1 and str2 are equal. - * @param str1 String 1 - * @param str2 String 2 - * @return True if equal, False otherwise - */ -[[gnu::pure]] [[gnu::nonnull]] -static inline bool -StringIsEqual(const wchar_t *str1, const wchar_t *str2) noexcept -{ - return StringCompare(str1, str2) == 0; -} - -/** - * Checks whether #a and #b are equal. - */ -[[gnu::pure]] [[gnu::nonnull]] -static inline bool -StringIsEqual(const wchar_t *a, const wchar_t *b, size_t length) noexcept -{ - return wcsncmp(a, b, length) == 0; -} - -[[gnu::pure]] [[gnu::nonnull]] -static inline bool -StringIsEqualIgnoreCase(const wchar_t *a, const wchar_t *b) noexcept -{ -#ifdef _WIN32 - return _wcsicmp(a, b) == 0; -#else - return wcscasecmp(a, b) == 0; -#endif -} - -[[gnu::pure]] [[gnu::nonnull]] -static inline bool -StringIsEqualIgnoreCase(const wchar_t *a, const wchar_t *b, - size_t size) noexcept -{ -#ifdef _WIN32 - return _wcsnicmp(a, b, size) == 0; -#else - return wcsncasecmp(a, b, size) == 0; -#endif -} - -[[gnu::pure]] [[gnu::nonnull]] -static inline int -StringCollate(const wchar_t *a, const wchar_t *b) noexcept -{ - return wcscoll(a, b); -} - -[[gnu::malloc]] [[gnu::returns_nonnull]] [[gnu::nonnull]] -static inline wchar_t * -DuplicateString(const wchar_t *p) noexcept -{ -#if defined(__sun) && defined (__SVR4) - return std::wcsdup(p); -#else - return wcsdup(p); -#endif -} diff --git a/src/util/WStringCompare.cxx b/src/util/WStringCompare.cxx deleted file mode 100644 index 4d715d8100a..00000000000 --- a/src/util/WStringCompare.cxx +++ /dev/null @@ -1,43 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -// author: Max Kellermann - -#include "WStringCompare.hxx" - -#include - -bool -StringEndsWith(const wchar_t *haystack, const wchar_t *needle) noexcept -{ - const size_t haystack_length = StringLength(haystack); - const size_t needle_length = StringLength(needle); - - return haystack_length >= needle_length && - StringIsEqual(haystack + haystack_length - needle_length, needle); -} - -bool -StringEndsWithIgnoreCase(const wchar_t *haystack, - const wchar_t *needle) noexcept -{ - const size_t haystack_length = StringLength(haystack); - const size_t needle_length = StringLength(needle); - - return haystack_length >= needle_length && - StringIsEqualIgnoreCase(haystack + haystack_length - needle_length, - needle); -} - -const wchar_t * -FindStringSuffix(const wchar_t *p, const wchar_t *suffix) noexcept -{ - const size_t p_length = StringLength(p); - const size_t suffix_length = StringLength(suffix); - - if (p_length < suffix_length) - return nullptr; - - const auto *q = p + p_length - suffix_length; - return memcmp(q, suffix, suffix_length * sizeof(*suffix)) == 0 - ? q - : nullptr; -} diff --git a/src/util/WStringCompare.hxx b/src/util/WStringCompare.hxx deleted file mode 100644 index cbc32e64859..00000000000 --- a/src/util/WStringCompare.hxx +++ /dev/null @@ -1,94 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -// author: Max Kellermann - -#pragma once - -#include "WStringAPI.hxx" - -#include -#include - -[[gnu::pure]] [[gnu::nonnull]] -static inline bool -StringIsEmpty(const wchar_t *string) noexcept -{ - return *string == 0; -} - -[[gnu::pure]] -static inline bool -StringIsEqual(std::wstring_view a, std::wstring_view b) noexcept -{ - return a.size() == b.size() && - StringIsEqual(a.data(), b.data(), b.size()); -} - -[[gnu::pure]] -static inline bool -StringIsEqualIgnoreCase(std::wstring_view a, std::wstring_view b) noexcept -{ - return a.size() == b.size() && - StringIsEqualIgnoreCase(a.data(), b.data(), b.size()); -} - -[[gnu::pure]] [[gnu::nonnull]] -static inline bool -StringStartsWith(const wchar_t *haystack, std::wstring_view needle) noexcept -{ - return StringIsEqual(haystack, needle.data(), needle.size()); -} - -[[gnu::pure]] [[gnu::nonnull]] -bool -StringEndsWith(const wchar_t *haystack, const wchar_t *needle) noexcept; - -[[gnu::pure]] [[gnu::nonnull]] -bool -StringEndsWithIgnoreCase(const wchar_t *haystack, - const wchar_t *needle) noexcept; - -/** - * Returns the portion of the string after a prefix. If the string - * does not begin with the specified prefix, this function returns - * nullptr. - */ -[[gnu::pure]] [[gnu::nonnull]] -static inline const wchar_t * -StringAfterPrefix(const wchar_t *haystack, std::wstring_view needle) noexcept -{ - return StringStartsWith(haystack, needle) - ? haystack + needle.size() - : nullptr; -} - -[[gnu::pure]] [[gnu::nonnull]] -static inline bool -StringStartsWithIgnoreCase(const wchar_t *haystack, - std::wstring_view needle) noexcept -{ - return StringIsEqualIgnoreCase(haystack, needle.data(), needle.size()); -} - -/** - * Returns the portion of the string after a prefix. If the string - * does not begin with the specified prefix, this function returns - * nullptr. - * This function is case-independent. - */ -[[gnu::pure]] [[gnu::nonnull]] -static inline const wchar_t * -StringAfterPrefixIgnoreCase(const wchar_t *haystack, - std::wstring_view needle) noexcept -{ - return StringStartsWithIgnoreCase(haystack, needle) - ? haystack + needle.size() - : nullptr; -} - -/** - * Check if the given string ends with the specified suffix. If yes, - * returns the position of the suffix, and nullptr otherwise. - */ -[[gnu::pure]] [[gnu::nonnull]] -const wchar_t * -FindStringSuffix(const wchar_t *p, const wchar_t *suffix) noexcept; diff --git a/src/util/WStringFormat.hpp b/src/util/WStringFormat.hpp deleted file mode 100644 index 673ce9e6b82..00000000000 --- a/src/util/WStringFormat.hpp +++ /dev/null @@ -1,49 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -// author: Max Kellermann - -#pragma once - -#include - -#ifdef _WIN32 -#include -#endif - -template -static inline int -StringFormat(wchar_t *buffer, size_t size, const wchar_t *fmt, - Args&&... args) noexcept -{ - /* unlike snprintf(), _sntprintf() does not guarantee that the - destination buffer is terminated */ - -#ifdef _WIN32 - /* usually, it would be enough to clear the last byte in the output - buffer after the _sntprintf() call, but unfortunately WINE 1.4.1 - has a bug that applies the wrong limit in the overflow branch - (confuses number of characters with number of bytes), therefore - we must clear the whole buffer and pass an even number of - characters; this terminates the string at half the buffer size, - but is better than exposing undefined bytes */ - size &= ~decltype(size)(sizeof(wchar_t) - 1); - memset(buffer, 0, size * sizeof(wchar_t)); - --size; -#endif - - return _snwprintf(buffer, size, fmt, args...); -} - -template -static inline int -StringFormatUnsafe(wchar_t *buffer, const wchar_t *fmt, - Args&&... args) noexcept -{ - /* work around a problem in mingw-w64/libstdc++: libstdc++ defines - __USE_MINGW_ANSI_STDIO=1 and forces mingw to expose the - POSIX-compatible stdio functions instead of the - Microsoft-compatible ones, but those have a major problem for us: - "%s" denotes a "narrow" string, not a "wide" string, and we'd - need to use "%ls"; this workaround explicitly selects the - Microsoft-compatible implementation */ - return _swprintf(buffer, fmt, args...); -} diff --git a/src/util/WStringStrip.cxx b/src/util/WStringStrip.cxx deleted file mode 100644 index 63769709eb1..00000000000 --- a/src/util/WStringStrip.cxx +++ /dev/null @@ -1,88 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -// author: Max Kellermann - -#include "WStringStrip.hxx" -#include "WStringAPI.hxx" -#include "WCharUtil.hxx" - -#include -#include - -const wchar_t * -StripLeft(const wchar_t *p) noexcept -{ - while (IsWhitespaceNotNull(*p)) - ++p; - - return p; -} - -const wchar_t * -StripLeft(const wchar_t *p, const wchar_t *end) noexcept -{ - while (p < end && IsWhitespaceOrNull(*p)) - ++p; - - return p; -} - -std::wstring_view -StripLeft(const std::wstring_view s) noexcept -{ - auto i = std::find_if_not(s.begin(), s.end(), - [](auto ch){ return IsWhitespaceOrNull(ch); }); - - return { - i, - s.end(), - }; -} - -const wchar_t * -StripRight(const wchar_t *p, const wchar_t *end) noexcept -{ - while (end > p && IsWhitespaceOrNull(end[-1])) - --end; - - return end; -} - -size_t -StripRight(const wchar_t *p, size_t length) noexcept -{ - while (length > 0 && IsWhitespaceOrNull(p[length - 1])) - --length; - - return length; -} - -void -StripRight(wchar_t *p) noexcept -{ - size_t old_length = StringLength(p); - size_t new_length = StripRight(p, old_length); - p[new_length] = 0; -} - -std::wstring_view -StripRight(std::wstring_view s) noexcept -{ - auto i = std::find_if_not(s.rbegin(), s.rend(), - [](auto ch){ return IsWhitespaceOrNull(ch); }); - - return s.substr(0, std::distance(i, s.rend())); -} - -wchar_t * -Strip(wchar_t *p) noexcept -{ - p = StripLeft(p); - StripRight(p); - return p; -} - -std::wstring_view -Strip(std::wstring_view s) noexcept -{ - return StripRight(StripLeft(s)); -} diff --git a/src/util/WStringStrip.hxx b/src/util/WStringStrip.hxx deleted file mode 100644 index c0216e82d55..00000000000 --- a/src/util/WStringStrip.hxx +++ /dev/null @@ -1,86 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -// author: Max Kellermann - -#pragma once - -#include - -#include - -/** - * Skips whitespace at the beginning of the string, and returns the - * first non-whitespace character. If the string has no - * non-whitespace characters, then a pointer to the NULL terminator is - * returned. - */ -[[gnu::pure]] [[gnu::returns_nonnull]] [[gnu::nonnull]] -const wchar_t * -StripLeft(const wchar_t *p) noexcept; - -[[gnu::pure]] [[gnu::returns_nonnull]] [[gnu::nonnull]] -static inline wchar_t * -StripLeft(wchar_t *p) noexcept -{ - return const_cast(StripLeft((const wchar_t *)p)); -} - -/** - * Skips whitespace at the beginning of the string, and returns the - * first non-whitespace character or the end pointer. - */ -[[gnu::pure]] [[gnu::returns_nonnull]] [[gnu::nonnull]] -const wchar_t * -StripLeft(const wchar_t *p, const wchar_t *end) noexcept; - -[[gnu::pure]] -std::wstring_view -StripLeft(std::wstring_view s) noexcept; - -/** - * Determine the string's end as if it was stripped on the right side. - */ -[[gnu::pure]] [[gnu::returns_nonnull]] [[gnu::nonnull]] -const wchar_t * -StripRight(const wchar_t *p, const wchar_t *end) noexcept; - -/** - * Determine the string's end as if it was stripped on the right side. - */ -[[gnu::pure]] [[gnu::returns_nonnull]] [[gnu::nonnull]] -static inline wchar_t * -StripRight(wchar_t *p, wchar_t *end) noexcept -{ - return const_cast(StripRight((const wchar_t *)p, - (const wchar_t *)end)); -} - -/** - * Determine the string's length as if it was stripped on the right - * side. - */ -[[gnu::pure]] [[gnu::nonnull]] -size_t -StripRight(const wchar_t *p, size_t length) noexcept; - -/** - * Strip trailing whitespace by null-terminating the string. - */ -[[gnu::nonnull]] -void -StripRight(wchar_t *p) noexcept; - -[[gnu::pure]] -std::wstring_view -StripRight(std::wstring_view s) noexcept; - -/** - * Skip whitespace at the beginning and terminate the string after the - * last non-whitespace character. - */ -[[gnu::returns_nonnull]] [[gnu::nonnull]] -wchar_t * -Strip(wchar_t *p) noexcept; - -[[gnu::pure]] -std::wstring_view -Strip(std::wstring_view s) noexcept; diff --git a/src/util/WStringUtil.cpp b/src/util/WStringUtil.cpp deleted file mode 100644 index 61809c11a54..00000000000 --- a/src/util/WStringUtil.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -// Copyright The XCSoar Project - -#include "WStringUtil.hpp" -#include "WCharUtil.hxx" -#include "Compiler.h" - -#include - -wchar_t * -CopyString(wchar_t *gcc_restrict dest, size_t dest_size, - std::wstring_view src) noexcept -{ - if (src.size() >= dest_size) - src = src.substr(0, dest_size -1); - - wchar_t *p = std::copy(src.begin(), src.end(), dest); - *p = L'\0'; - return p; -} - -wchar_t * -NormalizeSearchString(wchar_t *gcc_restrict dest, - std::wstring_view src) noexcept -{ - wchar_t *retval = dest; - - for (const auto ch : src) - if (IsAlphaNumericASCII(ch)) - *dest++ = ToUpperASCII(ch); - - *dest = L'\0'; - - return retval; -} diff --git a/src/util/WStringUtil.hpp b/src/util/WStringUtil.hpp deleted file mode 100644 index 39bf43fc591..00000000000 --- a/src/util/WStringUtil.hpp +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -// Copyright The XCSoar Project - -#pragma once - -#include - -#include - -/** - * Copy a string. If the buffer is too small, then the string is - * truncated. This is a safer version of strncpy(). - * - * @param dest_size the size of the destination buffer (including the - * null terminator) - * @return a pointer to the null terminator - */ -[[gnu::nonnull]] -wchar_t * -CopyString(wchar_t *dest, size_t dest_size, std::wstring_view src) noexcept; - -[[gnu::nonnull]] -wchar_t * -NormalizeSearchString(wchar_t *dest, std::wstring_view src) noexcept; diff --git a/src/util/tstring.hpp b/src/util/tstring.hpp deleted file mode 100644 index 2288c69ff20..00000000000 --- a/src/util/tstring.hpp +++ /dev/null @@ -1,8 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -// Copyright The XCSoar Project - -#pragma once - -#include - -using std::string = std::string; diff --git a/src/util/tstring_view.hxx b/src/util/tstring_view.hxx deleted file mode 100644 index 0a822c4155b..00000000000 --- a/src/util/tstring_view.hxx +++ /dev/null @@ -1,8 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -// author: Max Kellermann - -#pragma once - -#include - -using std::string_view = std::string_view; From 39d040c9ff242b5376eb8dc0a41b3ac9efec4ca7 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 22 Apr 2024 23:05:54 +0200 Subject: [PATCH 383/403] [UTF8] remove UTF8Win, move the code in UTF8.* --- build/libutil.mk | 6 ------ src/ui/canvas/gdi/Canvas.cpp | 3 +-- src/ui/canvas/gdi/GdiPlusBitmap.cpp | 3 +-- src/util/CMakeSource.cmake | 5 ----- src/util/UTF8.cpp | 15 +++++++++++++++ src/util/UTF8.hpp | 12 +++++++++++- src/util/UTF8Win.cpp | 19 ------------------- src/util/UTF8Win.hpp | 15 --------------- 8 files changed, 28 insertions(+), 50 deletions(-) delete mode 100644 src/util/UTF8Win.cpp delete mode 100644 src/util/UTF8Win.hpp diff --git a/build/libutil.mk b/build/libutil.mk index 5e47891d289..f7078db0c72 100644 --- a/build/libutil.mk +++ b/build/libutil.mk @@ -18,10 +18,4 @@ UTIL_SOURCES = \ $(UTIL_SRC_DIR)/StringStrip.cxx \ $(UTIL_SRC_DIR)/StringUtil.cpp -ifeq ($(HAVE_MSVCRT),y) -# move this code in UTF8.cpp! -UTIL_SOURCES += \ - $(UTIL_SRC_DIR)/UTF8Win.cpp -endif - $(eval $(call link-library,util,UTIL)) diff --git a/src/ui/canvas/gdi/Canvas.cpp b/src/ui/canvas/gdi/Canvas.cpp index f81ecf0cf4a..53831f8f124 100644 --- a/src/ui/canvas/gdi/Canvas.cpp +++ b/src/ui/canvas/gdi/Canvas.cpp @@ -7,11 +7,10 @@ #include "Asset.hpp" /* for needclipping */ #include "AlphaBlend.hpp" #include "Math/Angle.hpp" +#include "util/UTF8.hpp" #include -#include "util/UTF8Win.hpp" - static bool UTF8TextOut(HDC hdc, const PixelPoint &p, unsigned options, const RECT *r, std::string_view _text, const int *lpDx) { auto text = UTF8ToWide(_text); diff --git a/src/ui/canvas/gdi/GdiPlusBitmap.cpp b/src/ui/canvas/gdi/GdiPlusBitmap.cpp index 31ddb2119cc..90d6d826f83 100644 --- a/src/ui/canvas/gdi/GdiPlusBitmap.cpp +++ b/src/ui/canvas/gdi/GdiPlusBitmap.cpp @@ -2,6 +2,7 @@ // Copyright The XCSoar Project #include "GdiPlusBitmap.hpp" +#include "util/UTF8.hpp" #if defined(_MSC_VER) # include @@ -9,8 +10,6 @@ using std::min; // to avoid the missing 'min' in the gdiplush headers using std::max; // to avoid the missing 'max' in the gdiplush headers #endif // _MSC_VER -// #include "util/UTF8.hpp" -#include "util/UTF8Win.hpp" #include #include diff --git a/src/util/CMakeSource.cmake b/src/util/CMakeSource.cmake index 1b7caab6e5c..e241220628c 100644 --- a/src/util/CMakeSource.cmake +++ b/src/util/CMakeSource.cmake @@ -15,11 +15,6 @@ set(_SOURCES util/MD5.cpp # new with 6.8.14 util/DecimalParser.cxx # new with 7.40 ) -if(WIN32) - list(APPEND _SOURCES - util/UTF8Win.cpp - ) -endif() set(SCRIPT_FILES CMakeSource.cmake diff --git a/src/util/UTF8.cpp b/src/util/UTF8.cpp index 00ab25a1de2..a05c13322d3 100644 --- a/src/util/UTF8.cpp +++ b/src/util/UTF8.cpp @@ -4,6 +4,7 @@ #include "UTF8.hpp" #include "CharUtil.hxx" #include "Compiler.h" +#include "LogFile.hpp" #include @@ -658,3 +659,17 @@ NextUTF8(const char *p) noexcept gcc_unreachable(); } } + +#ifdef _WIN32 +#include + +std::wstring +UTF8ToWide(const std::string_view s) +{ + int length = MultiByteToWideChar(CP_UTF8, 0, s.data(), s.size() + 1, nullptr, 0); + std::wstring w(length + 1, L'\0'); + MultiByteToWideChar(CP_UTF8, 0, s.data(), s.size() + 1, w.data(), length); + return w; +} + +#endif diff --git a/src/util/UTF8.hpp b/src/util/UTF8.hpp index b3fba5c01f4..4525ec1418f 100644 --- a/src/util/UTF8.hpp +++ b/src/util/UTF8.hpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include constexpr std::string_view utf8_byte_order_mark{"\xef\xbb\xbf"}; @@ -146,3 +146,13 @@ CopyTruncateStringUTF8(std::span dest, [[gnu::pure]] [[gnu::nonnull]] std::pair NextUTF8(const char *p) noexcept; + +#ifdef _WIN32 +// #include +#include +#include + +std::wstring +UTF8ToWide(const std::string_view s); + +#endif diff --git a/src/util/UTF8Win.cpp b/src/util/UTF8Win.cpp deleted file mode 100644 index 55ffd4d35fe..00000000000 --- a/src/util/UTF8Win.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -// Copyright The XCSoar Project - -#include "UTF8Win.hpp" -#include "LogFile.hpp" - -#ifdef _WIN32 -#include - -std::wstring -UTF8ToWide(const std::string_view s) -{ - int length = MultiByteToWideChar(CP_UTF8, 0, s.data(), s.size() + 1, nullptr, 0); - std::wstring w(length + 1, L'\0'); - MultiByteToWideChar(CP_UTF8, 0, s.data(), s.size() + 1, w.data(), length); - return w; -} - -#endif diff --git a/src/util/UTF8Win.hpp b/src/util/UTF8Win.hpp deleted file mode 100644 index 51e97c9d3ea..00000000000 --- a/src/util/UTF8Win.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -// Copyright The XCSoar Project - -#pragma once - - -#ifdef _WIN32 -// #include -#include -#include - -std::wstring -UTF8ToWide(const std::string_view s); - -#endif \ No newline at end of file From 4db98cdb39ae4b24a50aebabf58773224dca89e3 Mon Sep 17 00:00:00 2001 From: August2111 Date: Mon, 22 Apr 2024 23:50:29 +0200 Subject: [PATCH 384/403] [UTF8] Remove all _T() from code 2635 replacements in src 807 replacements in test 10 replacements in tools --- src/Android/Main.cpp | 2 +- src/Android/SoundUtil.cpp | 2 +- src/Audio/PCMMixer.cpp | 8 +- src/Audio/PCMResourcePlayer.cpp | 4 +- src/Audio/Sound.cpp | 4 +- src/Compatibility/path.h | 4 +- src/CrossSection/CrossSectionRenderer.cpp | 4 +- src/Device/Config.cpp | 30 +- src/Device/Config.hpp | 2 +- src/Device/Descriptor.cpp | 30 +- src/Device/Descriptor.hpp | 4 +- src/Device/Driver/AR62xx.cpp | 4 +- src/Device/Driver/ATR833/Register.cpp | 4 +- src/Device/Driver/AirControlDisplay.cpp | 6 +- src/Device/Driver/AltairPro.cpp | 6 +- src/Device/Driver/Anemoi.cpp | 4 +- src/Device/Driver/BlueFly/Register.cpp | 4 +- src/Device/Driver/BorgeltB50.cpp | 4 +- src/Device/Driver/CAI302/Manage.cpp | 2 +- src/Device/Driver/CAI302/Register.cpp | 4 +- src/Device/Driver/CProbe.cpp | 4 +- src/Device/Driver/CaiGpsNav.cpp | 4 +- src/Device/Driver/CaiLNav.cpp | 4 +- src/Device/Driver/Condor.cpp | 4 +- src/Device/Driver/EW.cpp | 4 +- src/Device/Driver/EWMicroRecorder.cpp | 16 +- src/Device/Driver/Eye.cpp | 4 +- src/Device/Driver/FLARM/Register.cpp | 2 +- src/Device/Driver/FlyNet.cpp | 4 +- src/Device/Driver/FlymasterF1.cpp | 4 +- src/Device/Driver/Flytec/Register.cpp | 2 +- src/Device/Driver/FreeVario.cpp | 20 +- src/Device/Driver/Generic.cpp | 4 +- src/Device/Driver/ILEC.cpp | 4 +- src/Device/Driver/IMI/Internal.cpp | 2 +- src/Device/Driver/IMI/Protocol/Protocol.cpp | 2 +- src/Device/Driver/IMI/Register.cpp | 4 +- src/Device/Driver/KRT2.cpp | 6 +- src/Device/Driver/LX/Declare.cpp | 6 +- src/Device/Driver/LX/Register.cpp | 4 +- src/Device/Driver/Larus.cpp | 4 +- src/Device/Driver/Leonardo.cpp | 4 +- src/Device/Driver/LevilAHRS_G.cpp | 6 +- src/Device/Driver/NmeaOut.cpp | 4 +- src/Device/Driver/OpenVario.cpp | 4 +- src/Device/Driver/PosiGraph.cpp | 4 +- src/Device/Driver/ThermalExpress/Driver.cpp | 4 +- src/Device/Driver/Vaulter.cpp | 4 +- src/Device/Driver/Vega/Parser.cpp | 2 +- src/Device/Driver/Vega/Register.cpp | 4 +- src/Device/Driver/Volkslogger/Logger.cpp | 2 +- src/Device/Driver/Volkslogger/Register.cpp | 4 +- src/Device/Driver/Westerboer.cpp | 4 +- src/Device/Driver/XCOM760.cpp | 4 +- src/Device/Driver/XCTracer/Register.cpp | 4 +- src/Device/Driver/XCVario.cpp | 4 +- src/Device/Driver/Zander.cpp | 4 +- src/Device/Port/AndroidIOIOUartPort.hpp | 10 +- src/Device/Port/ConfiguredPort.cpp | 6 +- .../AirspaceCRendererSettingsPanel.cpp | 2 +- src/Dialogs/Airspace/AirspaceList.cpp | 44 +-- src/Dialogs/Airspace/dlgAirspaceDetails.cpp | 2 +- src/Dialogs/Airspace/dlgAirspaceWarnings.cpp | 20 +- .../BlueFly/BlueFlyConfigurationDialog.cpp | 16 +- src/Dialogs/Device/CAI302/UnitsEditor.cpp | 32 +- src/Dialogs/Device/DeviceEditWidget.cpp | 70 ++-- src/Dialogs/Device/DeviceListDialog.cpp | 42 +-- src/Dialogs/Device/FLARM/ConfigWidget.cpp | 18 +- .../Device/LX/LXNAVVarioConfigWidget.cpp | 24 +- src/Dialogs/Device/LX/ManageLX16xxDialog.cpp | 2 +- .../Device/LX/ManageLXNAVVarioDialog.cpp | 6 +- src/Dialogs/Device/LX/ManageNanoDialog.cpp | 4 +- src/Dialogs/Device/LX/NanoConfigWidget.cpp | 18 +- src/Dialogs/Device/ManageCAI302Dialog.cpp | 4 +- src/Dialogs/Device/ManageFlarmDialog.cpp | 4 +- src/Dialogs/Device/ManageI2CPitotDialog.cpp | 6 +- src/Dialogs/Device/PortDataField.cpp | 50 +-- src/Dialogs/Device/PortMonitor.cpp | 2 +- src/Dialogs/Device/PortPicker.cpp | 2 +- src/Dialogs/Device/Vega/AlertParameters.hpp | 14 +- .../Device/Vega/AudioDeadbandParameters.hpp | 8 +- .../Device/Vega/AudioModeParameters.hpp | 46 +-- src/Dialogs/Device/Vega/AudioParameters.hpp | 62 ++-- .../Device/Vega/CalibrationParameters.hpp | 8 +- src/Dialogs/Device/Vega/DisplayParameters.hpp | 8 +- .../Device/Vega/FlarmAlertParameters.hpp | 12 +- .../Vega/FlarmIdentificationParameters.hpp | 30 +- .../Device/Vega/FlarmRepeatParameters.hpp | 6 +- .../Device/Vega/HardwareParameters.hpp | 14 +- src/Dialogs/Device/Vega/LimitParameters.hpp | 12 +- src/Dialogs/Device/Vega/LoggerParameters.hpp | 4 +- src/Dialogs/Device/Vega/MixerParameters.hpp | 10 +- .../Device/Vega/VegaConfigurationDialog.cpp | 48 +-- src/Dialogs/Device/Vega/VegaDemoDialog.cpp | 12 +- src/Dialogs/DownloadFilePicker.cpp | 6 +- src/Dialogs/Error.cpp | 2 +- src/Dialogs/FileManager.cpp | 6 +- src/Dialogs/HelpDialog.cpp | 2 +- src/Dialogs/KnobTextEntry.cpp | 10 +- src/Dialogs/LockScreen.cpp | 2 +- src/Dialogs/MapItemListDialog.cpp | 4 +- src/Dialogs/Plane/PlaneDetailsDialog.cpp | 20 +- src/Dialogs/Plane/PlaneListDialog.cpp | 12 +- src/Dialogs/Plane/PlanePolarDialog.cpp | 8 +- src/Dialogs/Plane/PolarShapeEditWidget.cpp | 8 +- src/Dialogs/ProfileListDialog.cpp | 6 +- src/Dialogs/ReplayDialog.cpp | 6 +- .../Settings/Panels/AirspaceConfigPanel.cpp | 4 +- .../Settings/Panels/AudioConfigPanel.cpp | 2 +- .../Settings/Panels/AudioVarioConfigPanel.cpp | 16 +- .../Settings/Panels/CloudConfigPanel.cpp | 4 +- .../Panels/GlideComputerConfigPanel.cpp | 12 +- .../Settings/Panels/InterfaceConfigPanel.cpp | 22 +- .../Settings/Panels/LayoutConfigPanel.cpp | 2 +- .../Settings/Panels/LoggerConfigPanel.cpp | 2 +- .../Settings/Panels/MapDisplayConfigPanel.cpp | 4 +- .../Settings/Panels/PagesConfigPanel.cpp | 12 +- .../Panels/SafetyFactorsConfigPanel.cpp | 10 +- .../Settings/Panels/ScoringConfigPanel.cpp | 6 +- .../Settings/Panels/SiteConfigPanel.cpp | 16 +- .../Panels/TaskDefaultsConfigPanel.cpp | 6 +- .../Settings/Panels/TaskRulesConfigPanel.cpp | 10 +- .../Panels/TerrainDisplayConfigPanel.cpp | 4 +- .../Settings/Panels/TrackingConfigPanel.cpp | 64 ++-- .../Settings/Panels/UnitsConfigPanel.cpp | 54 +-- .../Panels/WaypointDisplayConfigPanel.cpp | 2 +- .../Settings/Panels/WeGlideConfigPanel.cpp | 2 +- .../Settings/Panels/WeatherConfigPanel.cpp | 10 +- src/Dialogs/Settings/WindSettingsPanel.cpp | 2 +- src/Dialogs/Settings/dlgBasicSettings.cpp | 14 +- src/Dialogs/Settings/dlgConfigInfoboxes.cpp | 4 +- src/Dialogs/Settings/dlgConfiguration.cpp | 10 +- src/Dialogs/StartupDialog.cpp | 2 +- .../StatusPanels/FlightStatusPanel.cpp | 6 +- src/Dialogs/StatusPanels/RulesStatusPanel.cpp | 6 +- .../StatusPanels/SystemStatusPanel.cpp | 14 +- src/Dialogs/StatusPanels/TaskStatusPanel.cpp | 12 +- src/Dialogs/StatusPanels/TimesStatusPanel.cpp | 4 +- src/Dialogs/Task/Manager/TaskEditPanel.cpp | 4 +- src/Dialogs/Task/Manager/TaskListPanel.cpp | 22 +- .../Task/Manager/TaskManagerDialog.cpp | 4 +- .../Task/Manager/TaskPropertiesPanel.cpp | 6 +- .../Task/Manager/WeGlideTasksPanel.cpp | 2 +- src/Dialogs/Task/MutateTaskPointDialog.cpp | 2 +- src/Dialogs/Task/OptionalStartsDialog.cpp | 2 +- src/Dialogs/Task/TargetDialog.cpp | 12 +- src/Dialogs/Task/TaskPointDialog.cpp | 16 +- .../Task/Widgets/CylinderZoneEditWidget.cpp | 2 +- .../Task/Widgets/KeyholeZoneEditWidget.cpp | 4 +- .../Task/Widgets/LineSectorZoneEditWidget.cpp | 2 +- .../Task/Widgets/SectorZoneEditWidget.cpp | 4 +- src/Dialogs/Task/dlgTaskHelpers.cpp | 34 +- src/Dialogs/TouchTextEntry.cpp | 4 +- src/Dialogs/Tracking/CloudEnableDialog.cpp | 2 +- src/Dialogs/Traffic/FlarmTrafficDetails.cpp | 28 +- src/Dialogs/Traffic/TeamCodeDialog.cpp | 4 +- src/Dialogs/Traffic/TrafficList.cpp | 20 +- src/Dialogs/Waypoint/WaypointInfoWidget.cpp | 12 +- src/Dialogs/Waypoint/WaypointList.cpp | 28 +- src/Dialogs/Waypoint/dlgWaypointDetails.cpp | 16 +- src/Dialogs/Waypoint/dlgWaypointEdit.cpp | 2 +- src/Dialogs/Weather/MapOverlayWidget.cpp | 28 +- src/Dialogs/Weather/NOAADetails.cpp | 6 +- src/Dialogs/Weather/NOAAList.cpp | 2 +- src/Dialogs/Weather/PCMetDialog.cpp | 6 +- src/Dialogs/Weather/RASPDialog.cpp | 6 +- src/Dialogs/Weather/WeatherDialog.cpp | 16 +- src/Dialogs/dlgAnalysis.cpp | 46 +-- src/Dialogs/dlgChecklist.cpp | 4 +- src/Dialogs/dlgCredits.cpp | 12 +- src/Dialogs/dlgInfoBoxAccess.cpp | 2 +- src/Dialogs/dlgQuickMenu.cpp | 4 +- src/Dialogs/dlgStatus.cpp | 2 +- src/Engine/Contest/Solvers/Contests.cpp | 32 +- src/Engine/Waypoint/Waypoints.cpp | 4 +- src/FLARM/FlarmNetReader.cpp | 4 +- src/FLARM/Glue.cpp | 4 +- src/FLARM/Traffic.cpp | 10 +- src/Form/Control.cpp | 2 +- src/Form/DataField/Angle.cpp | 8 +- src/Form/DataField/ComboList.cpp | 2 +- src/Form/DataField/Enum.cpp | 4 +- src/Form/DataField/File.cpp | 30 +- src/Form/DataField/Float.cpp | 4 +- src/Form/DataField/Float.hpp | 2 +- src/Form/DataField/GeoPoint.cpp | 2 +- src/Form/DataField/Integer.cpp | 4 +- src/Form/DataField/Number.cpp | 2 +- src/Form/DataField/Password.cpp | 2 +- src/Form/DataField/Prefix.cpp | 14 +- src/Form/DataField/Prefix.hpp | 6 +- src/Form/DataField/RoughTime.cpp | 8 +- src/Form/DataField/Time.cpp | 8 +- src/Form/DigitEntry.cpp | 36 +- src/Form/Form.cpp | 2 +- src/Form/TabMenuDisplay.cpp | 2 +- src/Formatter/AirspaceFormatter.cpp | 72 ++-- src/Formatter/AirspaceUserUnitsFormatter.cpp | 16 +- src/Formatter/AngleFormatter.cpp | 14 +- src/Formatter/ByteSizeFormatter.cpp | 10 +- src/Formatter/GeoPointFormatter.cpp | 24 +- src/Formatter/GeoPointFormatter.hpp | 4 +- src/Formatter/GlideRatioFormatter.cpp | 2 +- src/Formatter/IGCFilenameFormatter.cpp | 8 +- src/Formatter/TimeFormatter.cpp | 36 +- src/Formatter/TimeFormatter.hpp | 6 +- src/Formatter/Units.cpp | 32 +- src/Formatter/UserGeoPointFormatter.hpp | 4 +- src/Gauge/BigTrafficWidget.cpp | 18 +- src/Gauge/FlarmTrafficWindow.cpp | 6 +- src/Gauge/GaugeThermalAssistant.cpp | 2 +- src/Gauge/GaugeVario.cpp | 22 +- src/InfoBoxes/Content/Alternate.cpp | 4 +- src/InfoBoxes/Content/Altitude.cpp | 8 +- src/InfoBoxes/Content/Contest.cpp | 4 +- src/InfoBoxes/Content/Engine.cpp | 6 +- src/InfoBoxes/Content/Factory.cpp | 6 +- src/InfoBoxes/Content/Glide.cpp | 4 +- src/InfoBoxes/Content/MacCready.cpp | 2 +- src/InfoBoxes/Content/Other.cpp | 8 +- src/InfoBoxes/Content/Task.cpp | 30 +- src/InfoBoxes/Content/Team.cpp | 6 +- src/InfoBoxes/Content/Thermal.cpp | 4 +- src/InfoBoxes/Content/Time.cpp | 6 +- src/InfoBoxes/Content/Weather.cpp | 16 +- src/InfoBoxes/Data.cpp | 2 +- src/InfoBoxes/Data.hpp | 4 +- src/InfoBoxes/Format.cpp | 6 +- src/InfoBoxes/InfoBoxManager.cpp | 2 +- src/InfoBoxes/InfoBoxSettings.cpp | 2 +- src/InfoBoxes/Panel/ATCReference.cpp | 4 +- src/InfoBoxes/Panel/ATCSetup.cpp | 2 +- src/InfoBoxes/Panel/AltitudeSimulator.cpp | 2 +- src/InfoBoxes/Panel/RadioEdit.cpp | 2 +- src/Input/InputConfig.cpp | 8 +- src/Input/InputEvents.cpp | 2 +- src/Input/InputEventsActions.cpp | 108 +++--- src/Input/InputEventsAirspace.cpp | 10 +- src/Input/InputEventsDevice.cpp | 2 +- src/Input/InputEventsLua.cpp | 14 +- src/Input/InputEventsMap.cpp | 46 +-- src/Input/InputEventsPage.cpp | 2 +- src/Input/InputEventsSettings.cpp | 124 +++---- src/Input/InputEventsTask.cpp | 48 +-- src/Input/InputEventsTraffic.cpp | 18 +- src/Input/InputEventsVega.cpp | 36 +- src/Input/InputKeys.cpp | 98 ++--- src/Input/InputParser.cpp | 32 +- src/Kobo/KoboMenu.cpp | 2 +- src/Kobo/NetworkDialog.cpp | 6 +- src/Kobo/PowerOff.cpp | 10 +- src/Kobo/SystemDialog.cpp | 18 +- src/Kobo/ToolsDialog.cpp | 2 +- src/Kobo/WifiDialog.cpp | 4 +- src/Language/Language.hpp | 4 +- src/Language/LanguageGlue.cpp | 16 +- src/Language/Table.cpp | 6 +- src/LocalPath.cpp | 16 +- src/LogFile.cpp | 8 +- src/Logger/ExternalLogger.cpp | 14 +- src/Logger/Logger.cpp | 8 +- src/Logger/LoggerImpl.cpp | 16 +- src/Logger/NMEALogger.cpp | 4 +- src/Look/InfoBoxLook.cpp | 6 +- src/Look/StandardFonts.hpp | 4 +- src/MainWindow.cpp | 4 +- src/MainWindow.hpp | 2 +- src/MapWindow/GlueMapWindowOverlays.cpp | 18 +- src/MapWindow/Items/TrafficBuilder.cpp | 2 +- src/MapWindow/MapWindowTask.cpp | 2 +- src/MapWindow/MapWindowTraffic.cpp | 4 +- src/Markers/Markers.cpp | 2 +- src/Menu/ButtonLabel.cpp | 8 +- src/Menu/ExpandMacros.cpp | 174 ++++----- src/Menu/MenuBar.cpp | 2 +- src/Menu/MenuData.hpp | 2 +- src/Monitor/AirspaceWarningMonitor.cpp | 8 +- src/Monitor/MatTaskMonitor.cpp | 2 +- src/Monitor/TaskConstraintsMonitor.cpp | 2 +- src/OpenSoar.cpp | 2 +- src/OpenVario/DisplaySettingsWidget.cpp | 16 +- src/OpenVario/ExtraWidget.cpp | 6 +- src/OpenVario/FileMenuWidget.cpp | 6 +- src/OpenVario/OpenVarioBaseMenu.cpp | 32 +- src/OpenVario/System/OpenVarioDevice.cpp | 40 +- src/OpenVario/System/OpenVarioTools.cpp | 14 +- .../System/Setting/RotationWidget.cpp | 12 +- src/OpenVario/System/SystemMenuWidget.cpp | 44 +-- src/OpenVario/System/WifiDialogOV.cpp | 86 ++--- src/OpenVario/SystemSettingsWidget.cpp | 36 +- src/Operation/ConsoleOperationEnvironment.cpp | 4 +- src/Operation/MessageOperationEnvironment.cpp | 2 +- .../ThreadedOperationEnvironment.hpp | 2 +- src/PageSettings.cpp | 6 +- src/Polar/Parser.cpp | 30 +- src/Polar/PolarStore.cpp | 344 +++++++++--------- src/PopupMessage.cpp | 4 +- src/Profile/DeviceConfig.cpp | 4 +- src/Profile/GeoValue.cpp | 4 +- src/Profile/InfoBoxConfig.cpp | 2 +- src/Profile/PathValue.cpp | 4 +- src/Profile/Profile.cpp | 8 +- src/Profile/ProfileMap.hpp | 2 +- src/Profile/StringValue.cpp | 2 +- src/Profile/TrackingProfile.cpp | 6 +- src/ProgressWindow.cpp | 2 +- src/RadioFrequency.cpp | 2 +- src/Renderer/AirspaceListRenderer.cpp | 2 +- src/Renderer/BarographRenderer.cpp | 10 +- src/Renderer/ChartRenderer.cpp | 10 +- src/Renderer/ClimbChartRenderer.cpp | 12 +- src/Renderer/CuRenderer.cpp | 12 +- src/Renderer/FlightListRenderer.cpp | 28 +- src/Renderer/FlightStatisticsRenderer.cpp | 18 +- src/Renderer/GlidePolarInfoRenderer.cpp | 4 +- src/Renderer/GlidePolarRenderer.cpp | 16 +- src/Renderer/MacCreadyRenderer.cpp | 12 +- src/Renderer/MapItemListRenderer.cpp | 30 +- src/Renderer/NOAAListRenderer.cpp | 2 +- src/Renderer/TaskLegRenderer.cpp | 2 +- src/Renderer/TaskSpeedRenderer.cpp | 12 +- src/Renderer/ThermalBandRenderer.cpp | 6 +- src/Renderer/UnitSymbolRenderer.cpp | 54 +-- src/Renderer/VarioHistogramRenderer.cpp | 6 +- src/Renderer/WaypointListRenderer.cpp | 16 +- src/Renderer/WaypointRenderer.cpp | 20 +- src/Renderer/WindArrowRenderer.cpp | 2 +- src/Renderer/WindChartRenderer.cpp | 4 +- src/Replay/Replay.cpp | 2 +- src/Repository/Glue.cpp | 2 +- src/Startup.cpp | 6 +- src/SystemSettings.cpp | 6 +- src/Task/DefaultTask.hpp | 2 +- src/Task/Serialiser.cpp | 26 +- src/Task/TaskFile.cpp | 8 +- src/Task/TaskFileIGC.cpp | 8 +- src/Task/TaskStore.cpp | 10 +- src/Task/ValidationErrorStrings.cpp | 2 +- src/TeamCode/TeamCode.cpp | 2 +- src/Terrain/RasterTerrain.cpp | 2 +- src/Topography/Index.cpp | 16 +- src/Tracking/LiveTrack24/Settings.hpp | 2 +- src/TransponderCode.cpp | 2 +- src/UIActions.cpp | 22 +- src/UIUtil/GestureManager.cpp | 10 +- src/Units/Descriptor.cpp | 54 +-- src/Units/UnitsGlue.cpp | 6 +- src/VALI-XCS.cpp | 2 +- src/Version.cpp | 10 +- src/Waypoint/Patterns.hpp | 2 +- src/Waypoint/SaveGlue.cpp | 6 +- src/Waypoint/WaypointFileType.cpp | 10 +- src/Waypoint/WaypointGlue.cpp | 8 +- src/Waypoint/WaypointReaderFS.cpp | 18 +- src/Waypoint/WaypointReaderWinPilot.cpp | 2 +- src/Weather/METARParser.cpp | 64 ++-- src/Weather/NOAAFormatter.cpp | 50 +-- src/Weather/NOAAGlue.cpp | 6 +- src/Weather/PCMet/Images.cpp | 108 +++--- src/Weather/PCMet/Overlays.cpp | 14 +- src/Weather/Rasp/Configured.cpp | 2 +- src/Weather/Rasp/RaspStore.cpp | 22 +- src/Weather/Rasp/RaspStyle.cpp | 102 +++--- src/Widget/ArrowPagerWidget.cpp | 4 +- src/Widget/KeyboardWidget.cpp | 38 +- src/Widget/RowFormWidget.cpp | 4 +- src/Widget/RowFormWidget.hpp | 4 +- src/XCSoar.cpp | 2 +- src/io/FileOutputStream.cxx | 2 +- src/io/FileTransaction.cpp | 4 +- src/lua/Dialogs.cpp | 4 +- src/lua/Full.cpp | 2 +- src/net/client/WeGlide/UploadIGCFile.cpp | 6 +- src/system/FileUtil.cpp | 14 +- src/system/Path.cpp | 14 +- src/system/PathName.cpp | 4 +- src/system/Process.cpp | 4 +- src/ui/canvas/custom/Bitmap.cpp | 4 +- src/ui/canvas/custom/GeoBitmap.cpp | 4 +- src/ui/canvas/custom/LibJPEG.cpp | 2 +- src/ui/canvas/custom/MoreCanvas.cpp | 18 +- src/ui/canvas/gdi/Canvas.hpp | 2 +- src/ui/control/TerminalWindow.cpp | 2 +- src/ui/control/custom/LargeTextWindow.cpp | 2 +- src/ui/control/gdi/LargeTextWindow.cpp | 14 +- src/ui/window/PaintWindow.hpp | 2 +- src/ui/window/SingleWindow.hpp | 2 +- src/ui/window/gdi/Window.cpp | 2 +- src/unix/tchar.h | 5 +- src/util/DollarExpand.hpp | 4 +- src/util/EscapeBackslash.cpp | 2 +- src/util/RadixTree.hpp | 10 +- src/util/TruncateString.cpp | 2 +- test/src/ContestPrinting.cpp | 2 +- test/src/DebugPort.cpp | 12 +- test/src/DebugReplayNMEA.cpp | 2 +- test/src/DownloadFile.cpp | 2 +- test/src/DumpFlarmNet.cpp | 2 +- test/src/DumpTaskFile.cpp | 2 +- test/src/FakeMessage.cpp | 2 +- test/src/FakeProfile.cpp | 2 +- test/src/FlightTable.cpp | 4 +- test/src/KeyCodeDumper.cpp | 10 +- test/src/Main.hpp | 4 +- test/src/NearestWaypoints.cpp | 2 +- test/src/Printing.cpp | 2 +- test/src/RunAnalysis.cpp | 2 +- test/src/RunAngleEntry.cpp | 2 +- test/src/RunCanvas.cpp | 20 +- test/src/RunChartRenderer.cpp | 14 +- test/src/RunCirclingWind.cpp | 2 +- test/src/RunDateEntry.cpp | 2 +- test/src/RunDeclare.cpp | 30 +- test/src/RunDeviceDriver.cpp | 2 +- test/src/RunEnableNMEA.cpp | 4 +- test/src/RunExternalWind.cpp | 2 +- test/src/RunFlarmUtils.cpp | 12 +- test/src/RunFlightListRenderer.cpp | 4 +- test/src/RunFlyingComputer.cpp | 10 +- test/src/RunGeoPointEntry.cpp | 4 +- test/src/RunIGCWriter.cpp | 8 +- test/src/RunInputParser.cpp | 6 +- test/src/RunJobDialog.cpp | 4 +- test/src/RunListControl.cpp | 4 +- test/src/RunLiveTrack24.cpp | 10 +- test/src/RunNOAADownloader.cpp | 22 +- test/src/RunNumberEntry.cpp | 2 +- test/src/RunProgressWindow.cpp | 2 +- test/src/RunRenderOZ.cpp | 28 +- test/src/RunTaskEditorDialog.cpp | 8 +- test/src/RunTerminal.cpp | 2 +- test/src/RunTextEntry.cpp | 4 +- test/src/RunTimeEntry.cpp | 2 +- test/src/RunWaveComputer.cpp | 4 +- test/src/RunWaypointParser.cpp | 8 +- test/src/RunWindComputer.cpp | 2 +- test/src/RunWindEKF.cpp | 2 +- test/src/TaskInfo.cpp | 2 +- test/src/TaskPrinting.cpp | 2 +- test/src/TestAirspaceParser.cpp | 114 +++--- test/src/TestByteSizeFormatter.cpp | 62 ++-- test/src/TestDriver.cpp | 10 +- test/src/TestFileUtil.cpp | 30 +- test/src/TestFlarmNet.cpp | 24 +- test/src/TestGRecord.cpp | 8 +- test/src/TestGeoPointFormatter.cpp | 40 +- test/src/TestIGCFilenameFormatter.cpp | 28 +- test/src/TestLogger.cpp | 14 +- test/src/TestMETARParser.cpp | 22 +- test/src/TestPlanes.cpp | 24 +- test/src/TestPolars.cpp | 20 +- test/src/TestProfile.cpp | 8 +- test/src/TestRadixTree.cpp | 156 ++++---- test/src/TestStrings.cpp | 48 +-- test/src/TestTaskSave.cpp | 10 +- test/src/TestTaskWaypoint.cpp | 4 +- test/src/TestTeamCode.cpp | 8 +- test/src/TestTimeFormatter.cpp | 160 ++++---- test/src/TestTrace.cpp | 2 +- test/src/TestTransponderCode.cpp | 10 +- test/src/TestUnitsFormatter.cpp | 262 ++++++------- test/src/TestWaypointReader.cpp | 42 +-- test/src/TestWaypoints.cpp | 26 +- test/src/ViewImage.cpp | 2 +- test/src/harness_airspace.cpp | 6 +- test/src/harness_flight.cpp | 2 +- test/src/harness_waypoints.cpp | 6 +- test/src/test_debug.cpp | 4 +- test/src/test_mc.cpp | 2 +- test/src/test_reach.cpp | 2 +- test/src/test_replay_olc.cpp | 4 +- test/src/test_replay_retrospective.cpp | 2 +- test/src/test_replay_task.cpp | 6 +- test/src/test_route.cpp | 2 +- test/src/test_troute.cpp | 2 +- tools/GenerateResources.pl | 2 +- tools/Text2Event.pl | 2 +- tools/Text2GCE.pl | 2 +- tools/Text2NE.pl | 2 +- tools/polar_import.py | 4 +- tools/xci2cpp.pl | 6 +- tools/xcs2cpp.pl | 2 +- 482 files changed, 3283 insertions(+), 3284 deletions(-) diff --git a/src/Android/Main.cpp b/src/Android/Main.cpp index f4aa82ee1ce..b90e100ffbf 100644 --- a/src/Android/Main.cpp +++ b/src/Android/Main.cpp @@ -239,7 +239,7 @@ try { InitialiseDataPath(); AtScopeExit() { DeinitialiseDataPath(); }; - LogFormat(_T("Starting OpenSoar %s"), OpenSoar_ProductToken); + LogFormat("Starting OpenSoar %s", OpenSoar_ProductToken); TextUtil::Initialise(env); AtScopeExit(env) { TextUtil::Deinitialise(env); }; diff --git a/src/Android/SoundUtil.cpp b/src/Android/SoundUtil.cpp index b70e4a78bbb..ce35af2019e 100644 --- a/src/Android/SoundUtil.cpp +++ b/src/Android/SoundUtil.cpp @@ -45,7 +45,7 @@ SoundUtil::Play(JNIEnv *env, jobject context, const char *name) bool SoundUtil::PlayExternal(JNIEnv *env, jobject context, const char *path) { - AllocatedPath absolutePath = LocalPath(_T(path)); + AllocatedPath absolutePath = LocalPath(path); Java::String paramName(env, absolutePath.c_str()); return env->CallStaticBooleanMethod(cls, playExternal_method, context, paramName.Get()); diff --git a/src/Audio/PCMMixer.cpp b/src/Audio/PCMMixer.cpp index b18e4eeac57..cf5de47a909 100644 --- a/src/Audio/PCMMixer.cpp +++ b/src/Audio/PCMMixer.cpp @@ -26,8 +26,8 @@ PCMMixer::Start(PCMDataSource &source) if (src_sample_rate != mixer_sample_rate) { /* Resampling is not supported yet */ - LogFormat(_T("Cannot playback PCM data source with sample rate of %u Hz, ") - _T("because the mixer sample rate is %u Hz"), + LogFormat("Cannot playback PCM data source with sample rate of %u Hz, " + "because the mixer sample rate is %u Hz", src_sample_rate, mixer_sample_rate); return false; @@ -36,8 +36,8 @@ PCMMixer::Start(PCMDataSource &source) const std::lock_guard protect{lock}; if (!mixer_data_source.AddSource(source)) { - LogFormat(_T("Cannot handle PCM data source to mixer, because the mixer ") - _T("capacity is exceeded")); + LogFormat("Cannot handle PCM data source to mixer, because the mixer " + "capacity is exceeded"); return false; } diff --git a/src/Audio/PCMResourcePlayer.cpp b/src/Audio/PCMResourcePlayer.cpp index eafc5c508f7..9413ab634df 100644 --- a/src/Audio/PCMResourcePlayer.cpp +++ b/src/Audio/PCMResourcePlayer.cpp @@ -21,9 +21,9 @@ PCMResourcePlayer::PlayResource(const char *resource_name) { PCMBufferDataSource::PCMData pcm_data = FromBytesStrict( - ResourceLoader::Load(resource_name, _T("WAVE"))); + ResourceLoader::Load(resource_name, "WAVE")); if (pcm_data.data() == nullptr) { - LogFormat(_T("PCM resource \"%s\" not found!"), resource_name); + LogFormat("PCM resource \"%s\" not found!", resource_name); return false; } diff --git a/src/Audio/Sound.cpp b/src/Audio/Sound.cpp index 7f4a1bc7dae..55ee41c90bb 100644 --- a/src/Audio/Sound.cpp +++ b/src/Audio/Sound.cpp @@ -23,7 +23,7 @@ PlayResource(const char *resource_name) { #ifdef ANDROID - if (strstr(resource_name, _T(".wav"))) + if (strstr(resource_name, ".wav")) return SoundUtil::PlayExternal(Java::GetEnv(), context->Get(), resource_name); return SoundUtil::Play(Java::GetEnv(), context->Get(), resource_name); @@ -32,7 +32,7 @@ PlayResource(const char *resource_name) if (strstr(resource_name, TEXT(".wav"))) return sndPlaySound(resource_name, SND_ASYNC | SND_NODEFAULT); - ResourceLoader::Data data = ResourceLoader::Load(resource_name, _T("WAVE")); + ResourceLoader::Data data = ResourceLoader::Load(resource_name, "WAVE"); return data.data() != nullptr && sndPlaySound((LPCTSTR)data.data(), SND_MEMORY | SND_ASYNC | SND_NODEFAULT); diff --git a/src/Compatibility/path.h b/src/Compatibility/path.h index 697a20b229e..5288bf9f897 100644 --- a/src/Compatibility/path.h +++ b/src/Compatibility/path.h @@ -22,8 +22,8 @@ IsDirSeparator(char ch) { #ifdef _WIN32 // at Windows both separators are possible!!! - return ch == _T(DIR_SEPARATOR) || ch == _T('/'); + return ch == DIR_SEPARATOR || ch == '/'; #else - return ch == _T(DIR_SEPARATOR); + return ch == DIR_SEPARATOR; #endif } diff --git a/src/CrossSection/CrossSectionRenderer.cpp b/src/CrossSection/CrossSectionRenderer.cpp index 8188c8f5788..e2dfbaac374 100644 --- a/src/CrossSection/CrossSectionRenderer.cpp +++ b/src/CrossSection/CrossSectionRenderer.cpp @@ -44,8 +44,8 @@ CrossSectionRenderer::Paint(Canvas &canvas, const PixelRect rc) const { ChartRenderer chart(chart_look, canvas, rc); - chart.SetXLabel(_T("D"), Units::GetDistanceName()); - chart.SetYLabel(_T("h"), Units::GetAltitudeName()); + chart.SetXLabel("D", Units::GetDistanceName()); + chart.SetYLabel("h", Units::GetAltitudeName()); chart.Begin(); diff --git a/src/Device/Config.cpp b/src/Device/Config.cpp index 25230bfbac1..162486ddb3f 100644 --- a/src/Device/Config.cpp +++ b/src/Device/Config.cpp @@ -123,7 +123,7 @@ DeviceConfig::MaybeBluetooth(PortType port_type, [[maybe_unused]] const char *pa return true; #ifdef HAVE_POSIX - if (port_type == PortType::SERIAL && strstr(path, _T("/rfcomm")) != nullptr) + if (port_type == PortType::SERIAL && strstr(path, "/rfcomm") != nullptr) return true; #endif @@ -141,7 +141,7 @@ DeviceConfig::MaybeBluetooth() const noexcept return true; #ifdef HAVE_POSIX - if (port_type == PortType::SERIAL && path.Contains(_T("/rfcomm"))) + if (port_type == PortType::SERIAL && path.Contains("/rfcomm")) return true; #endif @@ -215,7 +215,7 @@ DeviceConfig::GetPortName(char *buffer, size_t max_size) const noexcept name = port_name; #endif - StringFormat(buffer, max_size, _T("%s: %s"), + StringFormat(buffer, max_size, "%s: %s", _("BLE sensor"), name); return buffer; } @@ -233,7 +233,7 @@ DeviceConfig::GetPortName(char *buffer, size_t max_size) const noexcept name = port_name; #endif - StringFormat(buffer, max_size, _T("%s: %s"), + StringFormat(buffer, max_size, "%s: %s", _("BLE port"), name); return buffer; } @@ -251,7 +251,7 @@ DeviceConfig::GetPortName(char *buffer, size_t max_size) const noexcept name = port_name; #endif - StringFormat(buffer, max_size, _T("Bluetooth %s"), name); + StringFormat(buffer, max_size, "Bluetooth %s", name); return buffer; } @@ -259,20 +259,20 @@ DeviceConfig::GetPortName(char *buffer, size_t max_size) const noexcept return _("Bluetooth server"); case PortType::IOIOUART: - StringFormat(buffer, max_size, _T("IOIO UART %d"), ioio_uart_id); + StringFormat(buffer, max_size, "IOIO UART %d", ioio_uart_id); return buffer; case PortType::DROIDSOAR_V2: - return _T("DroidSoar V2"); + return "DroidSoar V2"; case PortType::NUNCHUCK: - return _T("Nunchuck"); + return "Nunchuck"; case PortType::I2CPRESSURESENSOR: - return _T("IOIO i2c pressure sensor"); + return "IOIO i2c pressure sensor"; case PortType::IOIOVOLTAGE: - return _T("IOIO voltage sensor"); + return "IOIO voltage sensor"; case PortType::AUTO: return _("GPS Intermediate Driver"); @@ -284,24 +284,24 @@ DeviceConfig::GetPortName(char *buffer, size_t max_size) const noexcept return _("GliderLink traffic receiver"); case PortType::TCP_CLIENT: - StringFormat(buffer, max_size, _T("TCP client %s:%u"), + StringFormat(buffer, max_size, "TCP client %s:%u", ip_address.c_str(), tcp_port); return buffer; case PortType::TCP_LISTENER: - StringFormat(buffer, max_size, _T("TCP port %d"), tcp_port); + StringFormat(buffer, max_size, "TCP port %d", tcp_port); return buffer; case PortType::UDP_LISTENER: - StringFormat(buffer, max_size, _T("UDP port %d"), tcp_port); + StringFormat(buffer, max_size, "UDP port %d", tcp_port); return buffer; case PortType::PTY: - StringFormat(buffer, max_size, _T("Pseudo-terminal %s"), path.c_str()); + StringFormat(buffer, max_size, "Pseudo-terminal %s", path.c_str()); return buffer; case PortType::USB_SERIAL: - StringFormat(buffer, max_size, _T("%s: %s"), + StringFormat(buffer, max_size, "%s: %s", _("USB serial"), port_name.c_str()); return buffer; } diff --git a/src/Device/Config.hpp b/src/Device/Config.hpp index eb8e604b730..c5d11e6a23b 100644 --- a/src/Device/Config.hpp +++ b/src/Device/Config.hpp @@ -416,7 +416,7 @@ struct DeviceConfig { } bool IsVega() const noexcept { - return IsDriver(_T("Vega")); + return IsDriver("Vega"); } constexpr bool IsAndroidInternalGPS() const noexcept { diff --git a/src/Device/Descriptor.cpp b/src/Device/Descriptor.cpp index 65e7c82a328..99b73353500 100644 --- a/src/Device/Descriptor.cpp +++ b/src/Device/Descriptor.cpp @@ -196,8 +196,8 @@ try { port = std::move(_port); parser.Reset(); - parser.SetReal(!StringIsEqual(driver->name, _T("Condor"))); - if (config.IsDriver(_T("Condor"))) + parser.SetReal(!StringIsEqual(driver->name, "Condor")); + if (config.IsDriver("Condor")) parser.DisableGeoid(); if (driver->CreateOnPort != nullptr) { @@ -398,7 +398,7 @@ try { LockSetErrorMessage(what); StaticString<256> msg; - msg.Format(_T("%s: %s (%s)"), _("Unable to open port"), name, + msg.Format("%s: %s (%s)", _("Unable to open port"), name, (const char *)what); env.SetErrorMessage(msg); } @@ -411,7 +411,7 @@ try { const char *name = config.GetPortName(name_buffer, 64); StaticString<256> msg; - msg.Format(_T("%s: %s."), _("Unable to open port"), name); + msg.Format("%s: %s.", _("Unable to open port"), name); env.SetErrorMessage(msg); return false; } @@ -467,7 +467,7 @@ DeviceDescriptor::Open(OperationEnvironment &env) assert(open_job == nullptr); char buffer[64]; - LogFormat(_T("Opening device %s"), config.GetPortName(buffer, 64)); + LogFormat("Opening device %s", config.GetPortName(buffer, 64)); #ifdef ANDROID /* reset the Kalman filter */ @@ -556,7 +556,7 @@ DeviceDescriptor::AutoReopen(OperationEnvironment &env) return; char buffer[64]; - LogFormat(_T("Reconnecting to device %s"), config.GetPortName(buffer, 64)); + LogFormat("Reconnecting to device %s", config.GetPortName(buffer, 64)); InputEvents::processGlideComputer(GCE_COMMPORT_RESTART); Reopen(env); @@ -628,7 +628,7 @@ DeviceDescriptor::IsManageable() const noexcept if (driver->IsManageable()) return true; - if (StringIsEqual(driver->name, _T("LX")) && device != nullptr) { + if (StringIsEqual(driver->name, "LX") && device != nullptr) { const LXDevice &lx = *(const LXDevice *)device; return lx.IsManageable(); } @@ -1051,13 +1051,13 @@ DoDeclare(const struct Declaration &declaration, OperationEnvironment &env) { StaticString<60> text; - text.Format(_T("%s: %s."), _("Sending declaration"), driver.display_name); + text.Format("%s: %s.", _("Sending declaration"), driver.display_name); env.SetText(text); bool result = device != nullptr && device->Declare(declaration, home, env); if (flarm) { - text.Format(_T("%s: FLARM."), _("Sending declaration")); + text.Format("%s: FLARM.", _("Sending declaration")); env.SetText(text); result |= DeclareToFLARM(declaration, port, driver, device, home, env); @@ -1085,7 +1085,7 @@ DeviceDescriptor::Declare(const struct Declaration &declaration, } else { /* enable the "muxed FLARM" hack? */ const bool flarm = blackboard.IsFLARM(index) && - !IsDriver(_T("FLARM")); + !IsDriver("FLARM"); return DoDeclare(declaration, *port, *driver, device, flarm, home, env); @@ -1104,14 +1104,14 @@ DeviceDescriptor::ReadFlightList(RecordedFlightList &flight_list, StaticString<60> text; if (driver->HasPassThrough() && second_device != nullptr) { - text.Format(_T("%s: %s."), _("Reading flight list"), + text.Format("%s: %s.", _("Reading flight list"), second_driver->display_name); env.SetText(text); device->EnablePassThrough(env); return second_device->ReadFlightList(flight_list, env); } else { - text.Format(_T("%s: %s."), _("Reading flight list"), driver->display_name); + text.Format("%s: %s.", _("Reading flight list"), driver->display_name); env.SetText(text); return device->ReadFlightList(flight_list, env); @@ -1135,14 +1135,14 @@ DeviceDescriptor::DownloadFlight(const RecordedFlightInfo &flight, if (driver->HasPassThrough() && (second_device != nullptr)) { - text.Format(_T("%s: %s."), _("Downloading flight log"), + text.Format("%s: %s.", _("Downloading flight log"), second_driver->display_name); env.SetText(text); device->EnablePassThrough(env); return second_device->DownloadFlight(flight, path, env); } else { - text.Format(_T("%s: %s."), _("Downloading flight log"), + text.Format("%s: %s.", _("Downloading flight log"), driver->display_name); env.SetText(text); @@ -1267,7 +1267,7 @@ DeviceDescriptor::PortError(const char *msg) noexcept { { char buffer[64]; - LogFormat(_T("Error on device %s: %s"), + LogFormat("Error on device %s: %s", config.GetPortName(buffer, 64), msg); } diff --git a/src/Device/Descriptor.hpp b/src/Device/Descriptor.hpp index ee4f9a244d1..d88151ce011 100644 --- a/src/Device/Descriptor.hpp +++ b/src/Device/Descriptor.hpp @@ -434,11 +434,11 @@ class DeviceDescriptor final bool IsLogger() const noexcept; bool IsCondor() const noexcept { - return IsDriver(_T("Condor")); + return IsDriver("Condor"); } bool IsVega() const noexcept { - return IsDriver(_T("Vega")); + return IsDriver("Vega"); } bool IsNMEAOut() const noexcept; diff --git a/src/Device/Driver/AR62xx.cpp b/src/Device/Driver/AR62xx.cpp index 1e50177993c..c12c9bf156d 100644 --- a/src/Device/Driver/AR62xx.cpp +++ b/src/Device/Driver/AR62xx.cpp @@ -631,8 +631,8 @@ AR62xxCreateOnPort([[maybe_unused]] const DeviceConfig &config, * same as in KRT2.cpp */ const struct DeviceRegister ar62xx_driver = { - _T("AR62xx"), - _T("Becker AR62xx"), + "AR62xx", + "Becker AR62xx", DeviceRegister::NO_TIMEOUT | DeviceRegister::RAW_GPS_DATA, AR62xxCreateOnPort, }; diff --git a/src/Device/Driver/ATR833/Register.cpp b/src/Device/Driver/ATR833/Register.cpp index 86b29421704..b156a004ff0 100644 --- a/src/Device/Driver/ATR833/Register.cpp +++ b/src/Device/Driver/ATR833/Register.cpp @@ -11,8 +11,8 @@ ATR833CreateOnPort([[maybe_unused]] const DeviceConfig &config, Port &com_port) } const DeviceRegister atr833_driver = { - _T("ATR833"), - _T("ATR833"), + "ATR833", + "ATR833", DeviceRegister::RAW_GPS_DATA, ATR833CreateOnPort, }; diff --git a/src/Device/Driver/AirControlDisplay.cpp b/src/Device/Driver/AirControlDisplay.cpp index dac78143cc5..f7666c51005 100644 --- a/src/Device/Driver/AirControlDisplay.cpp +++ b/src/Device/Driver/AirControlDisplay.cpp @@ -91,7 +91,7 @@ ParsePAAVS(NMEAInputLine &line, NMEAInfo &info) unsigned code_value; if (line.ReadChecked(code_value)) { StaticString<16> buffer; - buffer.Format(_T("%04u"), code_value); + buffer.Format("%04u", code_value); TransponderCode parsed_code = TransponderCode::Parse(buffer); if (!parsed_code.IsDefined()) @@ -222,8 +222,8 @@ AirControlDisplayCreateOnPort([[maybe_unused]] const DeviceConfig &config, Port } const struct DeviceRegister acd_driver = { - _T("ACD"), - _T("Air Control Display"), + "ACD", + "Air Control Display", DeviceRegister::RECEIVE_SETTINGS | DeviceRegister::SEND_SETTINGS, AirControlDisplayCreateOnPort, }; diff --git a/src/Device/Driver/AltairPro.cpp b/src/Device/Driver/AltairPro.cpp index 20c4c7c1ecd..eda5200f783 100644 --- a/src/Device/Driver/AltairPro.cpp +++ b/src/Device/Driver/AltairPro.cpp @@ -56,7 +56,7 @@ ReadAltitude(NMEAInputLine &line, double &value_r) if (!available) return false; - if (unit == _T('f') || unit == _T('F')) + if (unit == 'f' || unit == 'F') value = Units::ToSysUnit(value, Unit::FEET); value_r = value; @@ -287,8 +287,8 @@ AltairProCreateOnPort([[maybe_unused]] const DeviceConfig &config, Port &com_por } const struct DeviceRegister altair_pro_driver = { - _T("Altair RU"), - _T("Altair Recording Unit"), + "Altair RU", + "Altair Recording Unit", DeviceRegister::DECLARE, AltairProCreateOnPort, }; diff --git a/src/Device/Driver/Anemoi.cpp b/src/Device/Driver/Anemoi.cpp index f089bb87820..055a46ccf7a 100644 --- a/src/Device/Driver/Anemoi.cpp +++ b/src/Device/Driver/Anemoi.cpp @@ -478,8 +478,8 @@ AnemoiCreateOnPort([[maybe_unused]] const DeviceConfig &config, Port &com_port) } const struct DeviceRegister anemoi_driver = { - _T("Anemoi"), - _T("Anemoi"), + "Anemoi", + "Anemoi", // DeviceRegister::RECEIVE_SETTINGS | DeviceRegister::SEND_SETTINGS, DeviceRegister::NO_TIMEOUT | DeviceRegister::RAW_GPS_DATA, AnemoiCreateOnPort, diff --git a/src/Device/Driver/BlueFly/Register.cpp b/src/Device/Driver/BlueFly/Register.cpp index 33ea49a12d9..b576a3b1f32 100644 --- a/src/Device/Driver/BlueFly/Register.cpp +++ b/src/Device/Driver/BlueFly/Register.cpp @@ -11,8 +11,8 @@ BlueFlyCreateOnPort([[maybe_unused]] const DeviceConfig &config, Port &com_port) } const struct DeviceRegister bluefly_driver = { - _T("BlueFly"), - _T("BlueFly Vario"), + "BlueFly", + "BlueFly Vario", DeviceRegister::MANAGE, BlueFlyCreateOnPort, }; diff --git a/src/Device/Driver/BorgeltB50.cpp b/src/Device/Driver/BorgeltB50.cpp index eaaefcb4d89..1033c61ec7b 100644 --- a/src/Device/Driver/BorgeltB50.cpp +++ b/src/Device/Driver/BorgeltB50.cpp @@ -152,8 +152,8 @@ B50CreateOnPort([[maybe_unused]] const DeviceConfig &config, Port &com_port) } const struct DeviceRegister b50_driver = { - _T("Borgelt B50"), - _T("Borgelt B50/B800"), + "Borgelt B50", + "Borgelt B50/B800", DeviceRegister::RECEIVE_SETTINGS | DeviceRegister::SEND_SETTINGS, B50CreateOnPort, }; diff --git a/src/Device/Driver/CAI302/Manage.cpp b/src/Device/Driver/CAI302/Manage.cpp index a579efbbb3c..b9cf1112d9e 100644 --- a/src/Device/Driver/CAI302/Manage.cpp +++ b/src/Device/Driver/CAI302/Manage.cpp @@ -205,7 +205,7 @@ static void ToASCII(char *dest, size_t dest_size, const char *src) { char *end = dest + dest_size - 1; - while (*src != _T('\0') && dest < end) + while (*src != '\0' && dest < end) if (IsPrintableASCII(*src)) *dest++ = (char)*src++; diff --git a/src/Device/Driver/CAI302/Register.cpp b/src/Device/Driver/CAI302/Register.cpp index 74ae351fa4f..f5c7dcca274 100644 --- a/src/Device/Driver/CAI302/Register.cpp +++ b/src/Device/Driver/CAI302/Register.cpp @@ -11,8 +11,8 @@ CAI302CreateOnPort(const DeviceConfig &config, Port &port) } const struct DeviceRegister cai302_driver = { - _T("CAI 302"), - _T("Cambridge CAI302"), + "CAI 302", + "Cambridge CAI302", DeviceRegister::BULK_BAUD_RATE | DeviceRegister::DECLARE | DeviceRegister::LOGGER | DeviceRegister::MANAGE | DeviceRegister::RECEIVE_SETTINGS | DeviceRegister::SEND_SETTINGS, diff --git a/src/Device/Driver/CProbe.cpp b/src/Device/Driver/CProbe.cpp index cd418fb49f8..1c14d288d57 100644 --- a/src/Device/Driver/CProbe.cpp +++ b/src/Device/Driver/CProbe.cpp @@ -124,8 +124,8 @@ CProbeCreateOnPort([[maybe_unused]] const DeviceConfig &config, [[maybe_unused]] } const struct DeviceRegister c_probe_driver = { - _T("CProbe"), - _T("Compass C-Probe"), + "CProbe", + "Compass C-Probe", 0, CProbeCreateOnPort, }; diff --git a/src/Device/Driver/CaiGpsNav.cpp b/src/Device/Driver/CaiGpsNav.cpp index f0afb29cfcd..ae3f02f4246 100644 --- a/src/Device/Driver/CaiGpsNav.cpp +++ b/src/Device/Driver/CaiGpsNav.cpp @@ -50,8 +50,8 @@ CaiGpsNavCreateOnPort([[maybe_unused]] const DeviceConfig &config, Port &com_por } const struct DeviceRegister gps_nav_driver = { - _T("CAI GPS-NAV"), - _T("Cambridge CAI GPS-NAV"), + "CAI GPS-NAV", + "Cambridge CAI GPS-NAV", 0, CaiGpsNavCreateOnPort, }; diff --git a/src/Device/Driver/CaiLNav.cpp b/src/Device/Driver/CaiLNav.cpp index d1beb0f894d..ab07e5a1200 100644 --- a/src/Device/Driver/CaiLNav.cpp +++ b/src/Device/Driver/CaiLNav.cpp @@ -139,8 +139,8 @@ CaiLNavCreateOnPort([[maybe_unused]] const DeviceConfig &config, Port &com_port) } const struct DeviceRegister cai_lnav_driver = { - _T("cai_lnav"), - _T("Cambridge L-Nav"), + "cai_lnav", + "Cambridge L-Nav", DeviceRegister::NO_TIMEOUT, CaiLNavCreateOnPort, }; diff --git a/src/Device/Driver/Condor.cpp b/src/Device/Driver/Condor.cpp index dfe1b0d8201..dd993b6d0dd 100644 --- a/src/Device/Driver/Condor.cpp +++ b/src/Device/Driver/Condor.cpp @@ -82,8 +82,8 @@ CondorCreateOnPort([[maybe_unused]] const DeviceConfig &config, [[maybe_unused]] } const struct DeviceRegister condor_driver = { - _T("Condor"), - _T("Condor Soaring Simulator"), + "Condor", + "Condor Soaring Simulator", 0, CondorCreateOnPort, }; diff --git a/src/Device/Driver/EW.cpp b/src/Device/Driver/EW.cpp index 1df43c0ab36..a8724a0fc2f 100644 --- a/src/Device/Driver/EW.cpp +++ b/src/Device/Driver/EW.cpp @@ -265,8 +265,8 @@ EWCreateOnPort([[maybe_unused]] const DeviceConfig &config, Port &com_port) } const struct DeviceRegister ew_driver = { - _T("EW Logger"), - _T("EW Logger"), + "EW Logger", + "EW Logger", DeviceRegister::DECLARE, EWCreateOnPort, }; diff --git a/src/Device/Driver/EWMicroRecorder.cpp b/src/Device/Driver/EWMicroRecorder.cpp index f04951070f7..10ea4955462 100644 --- a/src/Device/Driver/EWMicroRecorder.cpp +++ b/src/Device/Driver/EWMicroRecorder.cpp @@ -58,7 +58,7 @@ ReadAltitude(NMEAInputLine &line, double &value_r) if (!available) return false; - if (unit == _T('f') || unit == _T('F')) + if (unit == 'f' || unit == 'F') value = Units::ToSysUnit(value, Unit::FEET); value_r = value; @@ -219,10 +219,10 @@ WriteGeoPoint(Port &port, const GeoPoint &value, OperationEnvironment &env) // prepare latitude tmp = (double)value.latitude.Degrees(); - NoS = _T('N'); + NoS = 'N'; if (tmp < 0) { - NoS = _T('S'); + NoS = 'S'; tmp = -tmp; } @@ -231,10 +231,10 @@ WriteGeoPoint(Port &port, const GeoPoint &value, OperationEnvironment &env) // prepare long tmp = (double)value.longitude.Degrees(); - EoW = _T('E'); + EoW = 'E'; if (tmp < 0) { - EoW = _T('W'); + EoW = 'W'; tmp = -tmp; } @@ -293,7 +293,7 @@ DeclareInner(Port &port, const Declaration &declaration, port.FullWrite("\r\nFLIGHT DECLARATION\r\n-------------------\r\n\r\n", env, std::chrono::seconds(1)); - WritePair(port, "Description", _T("XCSoar task declaration"), env); + WritePair(port, "Description", "XCSoar task declaration", env); for (unsigned i = 0; i < 11; i++) { if (i+1>= declaration.Size()) { @@ -343,8 +343,8 @@ EWMicroRecorderCreateOnPort([[maybe_unused]] const DeviceConfig &config, Port &c } const struct DeviceRegister ew_microrecorder_driver = { - _T("EW MicroRecorder"), - _T("EW microRecorder"), + "EW MicroRecorder", + "EW microRecorder", DeviceRegister::DECLARE, EWMicroRecorderCreateOnPort, }; diff --git a/src/Device/Driver/Eye.cpp b/src/Device/Driver/Eye.cpp index 5ccc9f7094e..88cbb40c867 100644 --- a/src/Device/Driver/Eye.cpp +++ b/src/Device/Driver/Eye.cpp @@ -159,8 +159,8 @@ EyeCreateOnPort(const DeviceConfig &, Port &) } const struct DeviceRegister eye_driver = { - _T("EYE"), - _T("EYE sensor-box (experimental)"), + "EYE", + "EYE sensor-box (experimental)", 0, EyeCreateOnPort, }; diff --git a/src/Device/Driver/FLARM/Register.cpp b/src/Device/Driver/FLARM/Register.cpp index bfef1807328..5e317faf5e2 100644 --- a/src/Device/Driver/FLARM/Register.cpp +++ b/src/Device/Driver/FLARM/Register.cpp @@ -11,7 +11,7 @@ FlarmCreateOnPort([[maybe_unused]] const DeviceConfig &config, Port &com_port) } const struct DeviceRegister flarm_driver = { - _T("FLARM"), _T("FLARM"), + "FLARM", "FLARM", DeviceRegister::DECLARE | DeviceRegister::LOGGER | DeviceRegister::MANAGE, FlarmCreateOnPort, }; diff --git a/src/Device/Driver/FlyNet.cpp b/src/Device/Driver/FlyNet.cpp index f5c5f9e9824..777fd27f446 100644 --- a/src/Device/Driver/FlyNet.cpp +++ b/src/Device/Driver/FlyNet.cpp @@ -96,8 +96,8 @@ FlyNetCreateOnPort([[maybe_unused]] const DeviceConfig &config, [[maybe_unused]] } const struct DeviceRegister flynet_driver = { - _T("FlyNet"), - _T("FlyNet Vario"), + "FlyNet", + "FlyNet Vario", 0, FlyNetCreateOnPort, }; diff --git a/src/Device/Driver/FlymasterF1.cpp b/src/Device/Driver/FlymasterF1.cpp index 10dafc72f00..fb00ae50baa 100644 --- a/src/Device/Driver/FlymasterF1.cpp +++ b/src/Device/Driver/FlymasterF1.cpp @@ -90,8 +90,8 @@ FlymasterF1CreateOnPort([[maybe_unused]] const DeviceConfig &config, Port &port) } const struct DeviceRegister flymaster_f1_driver = { - _T("FlymasterF1"), - _T("Flymaster F1"), + "FlymasterF1", + "Flymaster F1", 0, FlymasterF1CreateOnPort, }; diff --git a/src/Device/Driver/Flytec/Register.cpp b/src/Device/Driver/Flytec/Register.cpp index 3a808ef4e15..0f275b4f699 100644 --- a/src/Device/Driver/Flytec/Register.cpp +++ b/src/Device/Driver/Flytec/Register.cpp @@ -11,7 +11,7 @@ FlytecCreateOnPort([[maybe_unused]] const DeviceConfig &config, Port &com_port) } const struct DeviceRegister flytec_driver = { - _T("Flytec"), _T("Flytec 5030 / Brauniger"), + "Flytec", "Flytec 5030 / Brauniger", 0 /* DeviceRegister::LOGGER deactivated until current firmware supports this */, FlytecCreateOnPort, }; diff --git a/src/Device/Driver/FreeVario.cpp b/src/Device/Driver/FreeVario.cpp index 7fcaa701ef1..289d6578b36 100755 --- a/src/Device/Driver/FreeVario.cpp +++ b/src/Device/Driver/FreeVario.cpp @@ -97,17 +97,17 @@ FreeVarioDevice::POVParserAndForward(NMEAInputLine &line) // info.switch_state.flight_mode = SwitchState::FlightMode::CIRCLING; StaticString<4> bufferAsString; bufferAsString.SetUTF8(buff); - if ('C' == command && bufferAsString == _T("STF")) { + if ('C' == command && bufferAsString == "STF") { messageValid = true; - InputEvents::eventSendNMEAPort1(_T("POV,C,STF*4B")); - InputEvents::eventSendNMEAPort2(_T("POV,C,STF*4B")); - InputEvents::eventStatusMessage(_T("Speed to Fly Mode")); + InputEvents::eventSendNMEAPort1("POV,C,STF*4B"); + InputEvents::eventSendNMEAPort2("POV,C,STF*4B"); + InputEvents::eventStatusMessage("Speed to Fly Mode"); } - if ('C' == command && bufferAsString == _T("VAR")) { + if ('C' == command && bufferAsString == "VAR") { messageValid = true; - InputEvents::eventSendNMEAPort1(_T("POV,C,VAR*4F")); - InputEvents::eventSendNMEAPort2(_T("POV,C,VAR*4F")); - InputEvents::eventStatusMessage(_T("Vario Mode")); + InputEvents::eventSendNMEAPort1("POV,C,VAR*4F"); + InputEvents::eventSendNMEAPort2("POV,C,VAR*4F"); + InputEvents::eventStatusMessage("Vario Mode"); } #endif } @@ -392,8 +392,8 @@ FreeVarioCreateOnPort([[maybe_unused]] const DeviceConfig &config, } const struct DeviceRegister free_vario_driver = { - _T("FreeVario"), - _T("FreeVario"), + "FreeVario", + "FreeVario", DeviceRegister::SEND_SETTINGS| DeviceRegister::RECEIVE_SETTINGS, FreeVarioCreateOnPort, diff --git a/src/Device/Driver/Generic.cpp b/src/Device/Driver/Generic.cpp index b19a46315d3..56ead1db6c1 100644 --- a/src/Device/Driver/Generic.cpp +++ b/src/Device/Driver/Generic.cpp @@ -14,8 +14,8 @@ GenericCreateOnPort([[maybe_unused]] const DeviceConfig &config, [[maybe_unused] } const struct DeviceRegister generic_driver = { - _T("Generic"), - _T("Generic"), + "Generic", + "Generic", 0, GenericCreateOnPort, }; diff --git a/src/Device/Driver/ILEC.cpp b/src/Device/Driver/ILEC.cpp index 0ad9aeff9b9..702d68b2dfa 100644 --- a/src/Device/Driver/ILEC.cpp +++ b/src/Device/Driver/ILEC.cpp @@ -70,8 +70,8 @@ ILECCreateOnPort([[maybe_unused]] const DeviceConfig &config, [[maybe_unused]] P } const struct DeviceRegister ilec_driver = { - _T("ILEC SN10"), - _T("ILEC SN10"), + "ILEC SN10", + "ILEC SN10", 0, ILECCreateOnPort, }; diff --git a/src/Device/Driver/IMI/Internal.cpp b/src/Device/Driver/IMI/Internal.cpp index 31fa3e658bb..4b976fb781a 100644 --- a/src/Device/Driver/IMI/Internal.cpp +++ b/src/Device/Driver/IMI/Internal.cpp @@ -37,7 +37,7 @@ ReadAltitude(NMEAInputLine &line, double &value_r) if (!available) return false; - if (unit == _T('f') || unit == _T('F')) + if (unit == 'f' || unit == 'F') value = Units::ToSysUnit(value, Unit::FEET); value_r = value; diff --git a/src/Device/Driver/IMI/Protocol/Protocol.cpp b/src/Device/Driver/IMI/Protocol/Protocol.cpp index 448548c6c50..0f650cc0811 100644 --- a/src/Device/Driver/IMI/Protocol/Protocol.cpp +++ b/src/Device/Driver/IMI/Protocol/Protocol.cpp @@ -130,7 +130,7 @@ IMI::DeclarationWrite(Port &port, const Declaration &decl, sizeof(imiDecl.header.gid)); ConvertToChar(decl.competition_id, imiDecl.header.cid, sizeof(imiDecl.header.cid)); - ConvertToChar(_T("XCSOARTASK"), imiDecl.header.tskName, + ConvertToChar("XCSOARTASK", imiDecl.header.tskName, sizeof(imiDecl.header.tskName)); ConvertWaypoint(decl.turnpoints[0].waypoint, imiDecl.wp[0]); diff --git a/src/Device/Driver/IMI/Register.cpp b/src/Device/Driver/IMI/Register.cpp index 5f59e809ca9..6a3c8312a0d 100644 --- a/src/Device/Driver/IMI/Register.cpp +++ b/src/Device/Driver/IMI/Register.cpp @@ -11,8 +11,8 @@ IMICreateOnPort([[maybe_unused]] const DeviceConfig &config, Port &com_port) } const struct DeviceRegister imi_driver = { - _T("IMI ERIXX"), - _T("IMI ERIXX"), + "IMI ERIXX", + "IMI ERIXX", DeviceRegister::DECLARE | DeviceRegister::LOGGER, IMICreateOnPort, }; diff --git a/src/Device/Driver/KRT2.cpp b/src/Device/Driver/KRT2.cpp index ee1b2723b17..e38e6ba0e91 100644 --- a/src/Device/Driver/KRT2.cpp +++ b/src/Device/Driver/KRT2.cpp @@ -254,7 +254,7 @@ inline void KRT2Device::GetStationName(char *station_name, const char *name) { if(name == nullptr) - name = _T(""); + name = ""; size_t s_idx = 0; //!< Source name index size_t d_idx = 0; //!< Destination name index @@ -413,8 +413,8 @@ KRT2CreateOnPort([[maybe_unused]] const DeviceConfig &config, Port &comPort) } const DeviceRegister krt2_driver = { - _T("KRT2"), - _T("KRT2"), + "KRT2", + "KRT2", DeviceRegister::NO_TIMEOUT | DeviceRegister::RAW_GPS_DATA, KRT2CreateOnPort, diff --git a/src/Device/Driver/LX/Declare.cpp b/src/Device/Driver/LX/Declare.cpp index 904d1e7d120..720a23b1189 100644 --- a/src/Device/Driver/LX/Declare.cpp +++ b/src/Device/Driver/LX/Declare.cpp @@ -95,7 +95,7 @@ LoadTask(LX::Declaration &lx_driver_Declaration, const Declaration &declaration) lx_driver_Declaration.tptypes[i] = 3; lx_driver_Declaration.Latitudes[i] = 0; lx_driver_Declaration.Longitudes[i] = 0; - copy_space_padded(lx_driver_Declaration.WaypointNames[i], _T("TAKEOFF"), + copy_space_padded(lx_driver_Declaration.WaypointNames[i], "TAKEOFF", sizeof(lx_driver_Declaration.WaypointNames[i])); @@ -113,7 +113,7 @@ LoadTask(LX::Declaration &lx_driver_Declaration, const Declaration &declaration) lx_driver_Declaration.tptypes[i] = 2; lx_driver_Declaration.Longitudes[i] = 0; lx_driver_Declaration.Latitudes[i] = 0; - copy_space_padded(lx_driver_Declaration.WaypointNames[i], _T("LANDING"), + copy_space_padded(lx_driver_Declaration.WaypointNames[i], "LANDING", sizeof(lx_driver_Declaration.WaypointNames[i])); } else { // unused @@ -131,7 +131,7 @@ static void LoadContestClass(LX::ContestClass &lx_driver_ContestClass, [[maybe_unused]] const Declaration &declaration) { - copy_space_padded(lx_driver_ContestClass.contest_class, _T(""), + copy_space_padded(lx_driver_ContestClass.contest_class, "", sizeof(lx_driver_ContestClass.contest_class)); } diff --git a/src/Device/Driver/LX/Register.cpp b/src/Device/Driver/LX/Register.cpp index 567cfa1fdc6..6e2dd2674a6 100644 --- a/src/Device/Driver/LX/Register.cpp +++ b/src/Device/Driver/LX/Register.cpp @@ -18,8 +18,8 @@ LXCreateOnPort(const DeviceConfig &config, Port &com_port) } const struct DeviceRegister lx_driver = { - _T("LX"), - _T("LXNAV"), + "LX", + "LXNAV", DeviceRegister::DECLARE | DeviceRegister::LOGGER | DeviceRegister::PASS_THROUGH | DeviceRegister::BULK_BAUD_RATE | diff --git a/src/Device/Driver/Larus.cpp b/src/Device/Driver/Larus.cpp index 9678f2dde89..c44e9f1361a 100644 --- a/src/Device/Driver/Larus.cpp +++ b/src/Device/Driver/Larus.cpp @@ -469,8 +469,8 @@ LarusCreateOnPort([[maybe_unused]] const DeviceConfig &config, Port &com_port) //----------------------------------------------------------------------------- const struct DeviceRegister larus_driver = { - _T("Larus"), - _T("Larus"), + "Larus", + "Larus", DeviceRegister::SEND_SETTINGS, LarusCreateOnPort, }; diff --git a/src/Device/Driver/Leonardo.cpp b/src/Device/Driver/Leonardo.cpp index 74139e9c4a3..e3aab49fdbe 100644 --- a/src/Device/Driver/Leonardo.cpp +++ b/src/Device/Driver/Leonardo.cpp @@ -190,8 +190,8 @@ LeonardoCreateOnPort([[maybe_unused]] const DeviceConfig &config, [[maybe_unused } const struct DeviceRegister leonardo_driver = { - _T("Leonardo"), - _T("Digifly Leonardo"), + "Leonardo", + "Digifly Leonardo", 0, LeonardoCreateOnPort, }; diff --git a/src/Device/Driver/LevilAHRS_G.cpp b/src/Device/Driver/LevilAHRS_G.cpp index 6d5066f1383..ec017f49e66 100644 --- a/src/Device/Driver/LevilAHRS_G.cpp +++ b/src/Device/Driver/LevilAHRS_G.cpp @@ -21,7 +21,7 @@ class LevilDevice : public AbstractDevice { static void ErrorMessage([[maybe_unused]] unsigned code) { - Message::AddMessage(_T("Levil AHRS: hardware error !")); + Message::AddMessage("Levil AHRS: hardware error !"); } static bool @@ -140,8 +140,8 @@ LevilCreateOnPort([[maybe_unused]] const DeviceConfig &config, [[maybe_unused]] } const struct DeviceRegister levil_driver = { - _T("Levil AHRS"), - _T("Levil AHRS"), + "Levil AHRS", + "Levil AHRS", 0, LevilCreateOnPort, }; diff --git a/src/Device/Driver/NmeaOut.cpp b/src/Device/Driver/NmeaOut.cpp index 705231ce6e5..57b384ea56b 100644 --- a/src/Device/Driver/NmeaOut.cpp +++ b/src/Device/Driver/NmeaOut.cpp @@ -5,8 +5,8 @@ #include "Device/Driver.hpp" const struct DeviceRegister nmea_out_driver = { - _T("NmeaOut"), - _T("NMEA output"), + "NmeaOut", + "NMEA output", DeviceRegister::NMEA_OUT|DeviceRegister::NO_TIMEOUT, nullptr, }; diff --git a/src/Device/Driver/OpenVario.cpp b/src/Device/Driver/OpenVario.cpp index ce0036e1dfe..d01485e327f 100644 --- a/src/Device/Driver/OpenVario.cpp +++ b/src/Device/Driver/OpenVario.cpp @@ -354,8 +354,8 @@ OpenVarioCreateOnPort([[maybe_unused]] const DeviceConfig &config, Port &com_por } const struct DeviceRegister open_vario_driver = { - _T("OpenVario"), - _T("OpenVario"), + "OpenVario", + "OpenVario", DeviceRegister::SEND_SETTINGS, OpenVarioCreateOnPort, }; diff --git a/src/Device/Driver/PosiGraph.cpp b/src/Device/Driver/PosiGraph.cpp index edbfe20f38a..7cc99d9bc59 100644 --- a/src/Device/Driver/PosiGraph.cpp +++ b/src/Device/Driver/PosiGraph.cpp @@ -62,8 +62,8 @@ PGCreateOnPort(const DeviceConfig &config, Port &com_port) } const struct DeviceRegister posigraph_driver = { - _T("PosiGraph Logger"), - _T("PosiGraph Logger"), + "PosiGraph Logger", + "PosiGraph Logger", DeviceRegister::DECLARE | DeviceRegister::BULK_BAUD_RATE | DeviceRegister::LOGGER, PGCreateOnPort, diff --git a/src/Device/Driver/ThermalExpress/Driver.cpp b/src/Device/Driver/ThermalExpress/Driver.cpp index a2c41a3ae4f..f77559cc8cc 100644 --- a/src/Device/Driver/ThermalExpress/Driver.cpp +++ b/src/Device/Driver/ThermalExpress/Driver.cpp @@ -43,8 +43,8 @@ ThermalExpressCreateOnPort([[maybe_unused]] const DeviceConfig &config, [[maybe_ } const struct DeviceRegister thermalexpress_driver = { - _T("ThermalExpress"), - _T("Thermal Express"), + "ThermalExpress", + "Thermal Express", 0, ThermalExpressCreateOnPort, }; diff --git a/src/Device/Driver/Vaulter.cpp b/src/Device/Driver/Vaulter.cpp index 4deee183f58..aa84ec5a289 100644 --- a/src/Device/Driver/Vaulter.cpp +++ b/src/Device/Driver/Vaulter.cpp @@ -164,8 +164,8 @@ VaulterCreateOnPort([[maybe_unused]] const DeviceConfig &config, Port &com_port) } const struct DeviceRegister vaulter_driver = { - _T("Vaulter"), - _T("WSI Vaulter"), + "Vaulter", + "WSI Vaulter", DeviceRegister::RECEIVE_SETTINGS | DeviceRegister::SEND_SETTINGS, VaulterCreateOnPort, }; diff --git a/src/Device/Driver/Vega/Parser.cpp b/src/Device/Driver/Vega/Parser.cpp index 197ee49b5b9..16d30edfb59 100644 --- a/src/Device/Driver/Vega/Parser.cpp +++ b/src/Device/Driver/Vega/Parser.cpp @@ -185,7 +185,7 @@ PDTSM(NMEAInputLine &line, [[maybe_unused]] NMEAInfo &info) buffer.SetASCII(message); // todo duration handling - Message::AddMessage(_T("VEGA:"), buffer); + Message::AddMessage("VEGA:", buffer); return true; } diff --git a/src/Device/Driver/Vega/Register.cpp b/src/Device/Driver/Vega/Register.cpp index e1a4169a626..81617f2cd51 100644 --- a/src/Device/Driver/Vega/Register.cpp +++ b/src/Device/Driver/Vega/Register.cpp @@ -11,8 +11,8 @@ VegaCreateOnPort([[maybe_unused]] const DeviceConfig &config, Port &com_port) } const struct DeviceRegister vega_driver = { - _T("Vega"), - _T("Vega"), + "Vega", + "Vega", DeviceRegister::MANAGE | DeviceRegister::RECEIVE_SETTINGS | DeviceRegister::SEND_SETTINGS, VegaCreateOnPort, diff --git a/src/Device/Driver/Volkslogger/Logger.cpp b/src/Device/Driver/Volkslogger/Logger.cpp index 2cc6133c1f3..f76834bf907 100644 --- a/src/Device/Driver/Volkslogger/Logger.cpp +++ b/src/Device/Driver/Volkslogger/Logger.cpp @@ -90,7 +90,7 @@ DownloadFlightInner(Port &port, unsigned bulkrate, if (length == 0) return false; - FILE *outfile = _tfopen(path.c_str(), _T("wt")); + FILE *outfile = _tfopen(path.c_str(), "wt"); if (outfile == nullptr) return false; diff --git a/src/Device/Driver/Volkslogger/Register.cpp b/src/Device/Driver/Volkslogger/Register.cpp index a7115630917..d85739b5497 100644 --- a/src/Device/Driver/Volkslogger/Register.cpp +++ b/src/Device/Driver/Volkslogger/Register.cpp @@ -23,8 +23,8 @@ VolksloggerCreateOnPort(const DeviceConfig &config, Port &com_port) } const struct DeviceRegister volkslogger_driver = { - _T("Volkslogger"), - _T("Volkslogger"), + "Volkslogger", + "Volkslogger", DeviceRegister::DECLARE | DeviceRegister::LOGGER | DeviceRegister::BULK_BAUD_RATE, VolksloggerCreateOnPort, diff --git a/src/Device/Driver/Westerboer.cpp b/src/Device/Driver/Westerboer.cpp index d1139bb6f76..323f1792620 100644 --- a/src/Device/Driver/Westerboer.cpp +++ b/src/Device/Driver/Westerboer.cpp @@ -172,8 +172,8 @@ WesterboerCreateOnPort([[maybe_unused]] const DeviceConfig &config, Port &com_po } const struct DeviceRegister westerboer_driver = { - _T("Westerboer VW1150"), - _T("Westerboer VW1150"), + "Westerboer VW1150", + "Westerboer VW1150", DeviceRegister::RECEIVE_SETTINGS | DeviceRegister::SEND_SETTINGS, WesterboerCreateOnPort, }; diff --git a/src/Device/Driver/XCOM760.cpp b/src/Device/Driver/XCOM760.cpp index ac8f92b596d..ead0304e7fd 100644 --- a/src/Device/Driver/XCOM760.cpp +++ b/src/Device/Driver/XCOM760.cpp @@ -67,8 +67,8 @@ XCOM760CreateOnPort([[maybe_unused]] const DeviceConfig &config, Port &com_port) } const struct DeviceRegister xcom760_driver = { - _T("XCOM760"), - _T("XCOM760"), + "XCOM760", + "XCOM760", DeviceRegister::NO_TIMEOUT | DeviceRegister::SEND_SETTINGS, XCOM760CreateOnPort, }; diff --git a/src/Device/Driver/XCTracer/Register.cpp b/src/Device/Driver/XCTracer/Register.cpp index adf0094e0f4..cbeaa490773 100644 --- a/src/Device/Driver/XCTracer/Register.cpp +++ b/src/Device/Driver/XCTracer/Register.cpp @@ -11,8 +11,8 @@ XCTracerCreateOnPort([[maybe_unused]] const DeviceConfig &config, [[maybe_unused } const struct DeviceRegister xctracer_driver = { - _T("XCTracer"), - _T("XC-Tracer Vario"), + "XCTracer", + "XC-Tracer Vario", 0, XCTracerCreateOnPort, }; diff --git a/src/Device/Driver/XCVario.cpp b/src/Device/Driver/XCVario.cpp index b3af31ce5e0..f70f5ae9be7 100644 --- a/src/Device/Driver/XCVario.cpp +++ b/src/Device/Driver/XCVario.cpp @@ -299,8 +299,8 @@ XVCCreateOnPort([[maybe_unused]] const DeviceConfig &config, Port &com_port) } const struct DeviceRegister xcv_driver = { - _T("XCVario"), - _T("XCVario"), + "XCVario", + "XCVario", DeviceRegister::RECEIVE_SETTINGS | DeviceRegister::SEND_SETTINGS, XVCCreateOnPort, }; diff --git a/src/Device/Driver/Zander.cpp b/src/Device/Driver/Zander.cpp index 951edae745e..8dd9a761d69 100644 --- a/src/Device/Driver/Zander.cpp +++ b/src/Device/Driver/Zander.cpp @@ -142,8 +142,8 @@ ZanderCreateOnPort([[maybe_unused]] const DeviceConfig &config, [[maybe_unused]] } const struct DeviceRegister zander_driver = { - _T("Zander"), - _T("Zander / SDI"), + "Zander", + "Zander / SDI", DeviceRegister::RECEIVE_SETTINGS, ZanderCreateOnPort, }; diff --git a/src/Device/Port/AndroidIOIOUartPort.hpp b/src/Device/Port/AndroidIOIOUartPort.hpp index 8137d092d0c..90297ace2f6 100644 --- a/src/Device/Port/AndroidIOIOUartPort.hpp +++ b/src/Device/Port/AndroidIOIOUartPort.hpp @@ -20,15 +20,15 @@ namespace AndroidIOIOUartPort static inline const char *getPortHelp(unsigned UartID) { switch (UartID) { case 0: - return _T("IOIO external board Uart: pin3=out, pin4=in"); + return "IOIO external board Uart: pin3=out, pin4=in"; case 1: - return _T("IOIO external board Uart: pin5=out, pin6=in"); + return "IOIO external board Uart: pin5=out, pin6=in"; case 2: - return _T("IOIO external board Uart: pin10=out, pin11=in"); + return "IOIO external board Uart: pin10=out, pin11=in"; case 3: - return _T("IOIO external board Uart: pin12=out, pin13=in"); + return "IOIO external board Uart: pin12=out, pin13=in"; default: - return _T("Illegal IOIO Uart ID"); + return "Illegal IOIO Uart ID"; } } } diff --git a/src/Device/Port/ConfiguredPort.cpp b/src/Device/Port/ConfiguredPort.cpp index 01b189a26d0..782d7c9e678 100644 --- a/src/Device/Port/ConfiguredPort.cpp +++ b/src/Device/Port/ConfiguredPort.cpp @@ -70,7 +70,7 @@ WindowsPort(char buffer[], const DeviceConfig &config) { throw std::runtime_error("No port path configured"); // the usual windows style of device names: - strcpy(buffer, _T("\\\\.\\")); + strcpy(buffer, "\\\\.\\"); strcat(buffer, config.path.c_str());return buffer; } #endif @@ -168,7 +168,7 @@ OpenPortInternal(EventLoop &event_loop, Cares::Channel &cares, if (!DetectGPS(buffer, sizeof(buffer))) throw std::runtime_error("No GPS detected"); - LogFormat(_T("GPS detected: %s"), buffer); + LogFormat("GPS detected: %s", buffer); path = buffer; break; @@ -240,7 +240,7 @@ OpenPortInternal(EventLoop &event_loop, Cares::Channel &cares, throw std::runtime_error("No port path configured"); // the usual windows style of device names: - strcpy(buffer, _T("\\\\.\\")); + strcpy(buffer, "\\\\.\\"); strcat(buffer, config.path.c_str()); path = buffer; #else diff --git a/src/Dialogs/Airspace/AirspaceCRendererSettingsPanel.cpp b/src/Dialogs/Airspace/AirspaceCRendererSettingsPanel.cpp index 241284335b2..8dd6954a17b 100644 --- a/src/Dialogs/Airspace/AirspaceCRendererSettingsPanel.cpp +++ b/src/Dialogs/Airspace/AirspaceCRendererSettingsPanel.cpp @@ -65,7 +65,7 @@ AirspaceClassRendererSettingsPanel::Prepare(ContainerWindow &parent, AddInteger(_("Border Width"), _("The width of the border drawn around each airspace. " "Set this value to zero to hide the border."), - _T("%d"), _T("%d"), 0, 5, 1, settings.border_width); + "%d", "%d", 0, 5, 1, settings.border_width); static constexpr StaticEnumChoice fill_mode_list[] = { { AirspaceClassRendererSettings::FillMode::ALL, N_("Filled"), }, diff --git a/src/Dialogs/Airspace/AirspaceList.cpp b/src/Dialogs/Airspace/AirspaceList.cpp index fccc68a26f6..7fb79980787 100644 --- a/src/Dialogs/Airspace/AirspaceList.cpp +++ b/src/Dialogs/Airspace/AirspaceList.cpp @@ -148,22 +148,22 @@ static GeoPoint location; static Angle last_heading; static constexpr StaticEnumChoice type_filter_list[] = { - { WILDCARD, _T("*") }, - { OTHER, _T("Other") }, - { RESTRICT, _T("Restricted areas") }, - { PROHIBITED, _T("Prohibited areas") }, - { DANGER, _T("Danger areas") }, - { CLASSA, _T("Class A") }, - { CLASSB, _T("Class B") }, - { CLASSC, _T("Class C") }, - { CLASSD, _T("Class D") }, - { NOGLIDER, _T("No gliders") }, - { CTR, _T("CTR") }, - { WAVE, _T("Wave") }, - { CLASSE, _T("Class E") }, - { CLASSF, _T("Class F") }, - { TMZ, _T("TMZ") }, - { MATZ, _T("MATZ") }, + { WILDCARD, "*" }, + { OTHER, "Other" }, + { RESTRICT, "Restricted areas" }, + { PROHIBITED, "Prohibited areas" }, + { DANGER, "Danger areas" }, + { CLASSA, "Class A" }, + { CLASSB, "Class B" }, + { CLASSC, "Class C" }, + { CLASSD, "Class D" }, + { NOGLIDER, "No gliders" }, + { CTR, "CTR" }, + { WAVE, "Wave" }, + { CLASSE, "Class E" }, + { CLASSF, "Class F" }, + { TMZ, "TMZ" }, + { MATZ, "MATZ" }, nullptr }; @@ -248,7 +248,7 @@ AirspaceListWidget::FilterMode(bool direction) filter_widget.LoadValueEnum(DISTANCE, WILDCARD); filter_widget.LoadValueEnum(DIRECTION, WILDCARD); } else { - filter_widget.LoadValue(NAME, _T("")); + filter_widget.LoadValue(NAME, ""); } } @@ -304,7 +304,7 @@ GetHeadingString(char *buffer) FormatBearing(heading, ARRAY_SIZE(heading), CommonInterface::Basic().attitude.heading); - StringFormatUnsafe(buffer, _T("%s (%s)"), _("Heading"), heading); + StringFormatUnsafe(buffer, "%s (%s)", _("Heading"), heading); return buffer; } @@ -338,7 +338,7 @@ AirspaceFilterWidget::Update() static void FillDistanceEnum(DataFieldEnum &df) { - df.AddChoice(0, _T("*")); + df.AddChoice(0, "*"); static constexpr unsigned distances[] = { 25, 50, 75, 100, 150, 250, 500, 1000 @@ -347,7 +347,7 @@ FillDistanceEnum(DataFieldEnum &df) char buffer[64]; const char *unit = Units::GetDistanceName(); for (unsigned i = 0; i < ARRAY_SIZE(distances); ++i) { - StringFormatUnsafe(buffer, _T("%u %s"), distances[i], unit); + StringFormatUnsafe(buffer, "%u %s", distances[i], unit); df.AddChoice(distances[i], buffer); } @@ -359,7 +359,7 @@ FillDirectionEnum(DataFieldEnum &df) { char buffer[64]; - df.AddChoice(WILDCARD, _T("*")); + df.AddChoice(WILDCARD, "*"); df.AddChoice(0, GetHeadingString(buffer)); static constexpr unsigned directions[] = { @@ -375,7 +375,7 @@ FillDirectionEnum(DataFieldEnum &df) static DataField * CreateNameDataField(DataFieldListener *listener) { - return new PrefixDataField(_T(""), listener); + return new PrefixDataField("", listener); } static DataField * diff --git a/src/Dialogs/Airspace/dlgAirspaceDetails.cpp b/src/Dialogs/Airspace/dlgAirspaceDetails.cpp index e32bc8bb15a..b31b8534d98 100644 --- a/src/Dialogs/Airspace/dlgAirspaceDetails.cpp +++ b/src/Dialogs/Airspace/dlgAirspaceDetails.cpp @@ -50,7 +50,7 @@ AirspaceDetailsWidget::Prepare([[maybe_unused]] ContainerWindow &parent, if (airspace->GetRadioFrequency().Format(buffer.data(), buffer.capacity()) != nullptr) { - buffer += _T(" MHz"); + buffer += " MHz"; AddReadOnly(_("Radio"), nullptr, buffer); AddButton(_("Set Active Frequency"), [this](){ diff --git a/src/Dialogs/Airspace/dlgAirspaceWarnings.cpp b/src/Dialogs/Airspace/dlgAirspaceWarnings.cpp index 90ff357a83f..f102fa2353f 100644 --- a/src/Dialogs/Airspace/dlgAirspaceWarnings.cpp +++ b/src/Dialogs/Airspace/dlgAirspaceWarnings.cpp @@ -290,9 +290,9 @@ AirspaceWarningListWidget::OnPaintItem(Canvas &canvas, // word "inside" is used as the etalon, because it is longer than "near" and // currently (9.4.2011) there is no other possibility for the status text. - const int status_width = canvas.CalcTextWidth(_T("inside")); + const int status_width = canvas.CalcTextWidth("inside"); // "1888" is used in order to have enough space for 4-digit heights with "AGL" - const int altitude_width = canvas.CalcTextWidth(_T("1888 m AGL")); + const int altitude_width = canvas.CalcTextWidth("1888 m AGL"); // Dynamic columns scaling - "name" column is flexible, altitude and state // columns are fixed-width. @@ -306,7 +306,7 @@ AirspaceWarningListWidget::OnPaintItem(Canvas &canvas, canvas.SetTextColor(COLOR_GRAY); { // name, altitude info - StringFormat(buffer, ARRAY_SIZE(buffer), _T("%s %s"), + StringFormat(buffer, ARRAY_SIZE(buffer), "%s %s", airspace.GetName(), AirspaceFormatter::GetClass(airspace)); @@ -322,16 +322,16 @@ AirspaceWarningListWidget::OnPaintItem(Canvas &canvas, if (const auto &solution = warning.GetSolution(); warning.IsWarning() && !warning.IsInside() && solution.IsValid()) { - _stprintf(buffer, _T("%d secs"), + _stprintf(buffer, "%d secs", (int)solution.elapsed_time.count()); if (solution.distance > 0) - _stprintf(buffer + strlen(buffer), _T(" dist %d m"), + _stprintf(buffer + strlen(buffer), " dist %d m", (int)solution.distance); else { /* the airspace is right above or below us - show the vertical distance */ - strcat(buffer, _T(" vertical ")); + strcat(buffer, " vertical "); auto delta = solution.altitude - CommonInterface::Basic().nav_altitude; FormatRelativeUserAltitude(delta, buffer + strlen(buffer), true); @@ -347,17 +347,17 @@ AirspaceWarningListWidget::OnPaintItem(Canvas &canvas, if (warning.IsInside()) { state_color = warning.IsActive() ? inside_color : inside_ack_color; - state_text = _T("inside"); + state_text = "inside"; } else if (warning.IsWarning()) { state_color = warning.IsActive() ? near_color : near_ack_color; - state_text = _T("near"); + state_text = "near"; } else { state_color = COLOR_WHITE; state_text = NULL; } const PixelSize state_text_size = - canvas.CalcTextSize(state_text != NULL ? state_text : _T("W")); + canvas.CalcTextSize(state_text != NULL ? state_text : "W"); if (state_color != COLOR_WHITE) { /* colored background */ @@ -430,7 +430,7 @@ AirspaceWarningListWidget::UpdateList() const unsigned sound_interval = ((tt_closest_airspace * 3 / warning_config.warning_time) + 1) * 2; if (sound_interval_counter >= sound_interval) { - PlayResource(_T("IDR_WAV_BEEPBWEEP")); + PlayResource("IDR_WAV_BEEPBWEEP"); sound_interval_counter = 1; } else ++sound_interval_counter; diff --git a/src/Dialogs/Device/BlueFly/BlueFlyConfigurationDialog.cpp b/src/Dialogs/Device/BlueFly/BlueFlyConfigurationDialog.cpp index 60d90757918..f885db524f4 100644 --- a/src/Dialogs/Device/BlueFly/BlueFlyConfigurationDialog.cpp +++ b/src/Dialogs/Device/BlueFly/BlueFlyConfigurationDialog.cpp @@ -33,15 +33,15 @@ class BlueFlyConfigurationWidget final void Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept override { AddFloat(N_("Volume"), nullptr, - _T("%.2f"), - _T("%.2f"), + "%.2f", + "%.2f", 0, 1.0, 0.1, true, 0); static constexpr StaticEnumChoice modes[] = { - { 0, _T("BlueFlyVario") }, - { 1, _T("LK8EX1") }, - { 2, _T("LX") }, - { 3, _T("FlyNet") }, + { 0, "BlueFlyVario" }, + { 1, "LK8EX1" }, + { 2, "LX" }, + { 3, "FlyNet" }, { 0 } }; @@ -73,7 +73,7 @@ class BlueFlyConfigurationWidget final } catch (OperationCancelled) { return false; } catch (...) { - ShowError(std::current_exception(), _T("BlueFly Vario")); + ShowError(std::current_exception(), "BlueFly Vario"); return false; } @@ -108,7 +108,7 @@ dlgConfigurationBlueFlyVarioShowModal(Device &_device) WidgetDialog dialog(WidgetDialog::Auto{}, UIGlobals::GetMainWindow(), look, - _T("BlueFly Vario")); + "BlueFly Vario"); // unfortunately this internal declaration isn't possible with MSVC! // so I have to set this widget later... // (BlueFlyConfigurationWidget(.., dialog,..) with dialog from paren funktion diff --git a/src/Dialogs/Device/CAI302/UnitsEditor.cpp b/src/Dialogs/Device/CAI302/UnitsEditor.cpp index e06268b6341..94397012c33 100644 --- a/src/Dialogs/Device/CAI302/UnitsEditor.cpp +++ b/src/Dialogs/Device/CAI302/UnitsEditor.cpp @@ -11,58 +11,58 @@ CAI302UnitsEditor::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { static constexpr StaticEnumChoice vario_list[] = { - { 0, _T("m/s"), }, - { 1, _T("kt"), }, + { 0, "m/s", }, + { 1, "kt", }, nullptr }; AddEnum(_("Vario"), NULL, vario_list, data.GetVarioUnit()); static constexpr StaticEnumChoice altitude_list[] = { - { 0, _T("m"), }, - { 1, _T("ft"), }, + { 0, "m", }, + { 1, "ft", }, nullptr }; AddEnum(_("Altitude"), NULL, altitude_list, data.GetAltitudeUnit()); static constexpr StaticEnumChoice temperature_list[] = { - { 0, _T(DEG "C"), }, - { 1, _T(DEG "F"), }, + { 0, DEG "C", }, + { 1, DEG "F", }, nullptr }; AddEnum(_("Temperature"), NULL, temperature_list, data.GetTemperatureUnit()); static constexpr StaticEnumChoice pressure_list[] = { - { 0, _T("hPa"), }, - { 1, _T("inHg"), }, + { 0, "hPa", }, + { 1, "inHg", }, nullptr }; AddEnum(_("Pressure"), NULL, pressure_list, data.GetPressureUnit()); static constexpr StaticEnumChoice distance_list[] = { - { 0, _T("km"), }, - { 1, _T("NM"), }, - { 2, _T("mi"), }, + { 0, "km", }, + { 1, "NM", }, + { 2, "mi", }, nullptr }; AddEnum(_("Distance"), NULL, distance_list, data.GetDistanceUnit()); static constexpr StaticEnumChoice speed_list[] = { - { 0, _T("m/s"), }, - { 1, _T("kt"), }, - { 2, _T("mph"), }, + { 0, "m/s", }, + { 1, "kt", }, + { 2, "mph", }, nullptr }; AddEnum(_("Speed"), NULL, speed_list, data.GetSpeedUnit()); static constexpr StaticEnumChoice sink_tone_list[] = { - { 0, _T("off"), }, - { 1, _T("on"), }, + { 0, "off", }, + { 1, "on", }, nullptr }; AddEnum(_("Sink tone"), NULL, sink_tone_list, diff --git a/src/Dialogs/Device/DeviceEditWidget.cpp b/src/Dialogs/Device/DeviceEditWidget.cpp index 142e6e50a9c..f2a441bf084 100644 --- a/src/Dialogs/Device/DeviceEditWidget.cpp +++ b/src/Dialogs/Device/DeviceEditWidget.cpp @@ -27,55 +27,55 @@ enum ControlIndex { static void FillBaudRates(DataFieldEnum &dfe) noexcept { - dfe.addEnumText(_T("1200"), 1200); - dfe.addEnumText(_T("2400"), 2400); - dfe.addEnumText(_T("4800"), 4800); - dfe.addEnumText(_T("9600"), 9600); - dfe.addEnumText(_T("19200"), 19200); - dfe.addEnumText(_T("38400"), 38400); - dfe.addEnumText(_T("57600"), 57600); - dfe.addEnumText(_T("115200"), 115200); + dfe.addEnumText("1200", 1200); + dfe.addEnumText("2400", 2400); + dfe.addEnumText("4800", 4800); + dfe.addEnumText("9600", 9600); + dfe.addEnumText("19200", 19200); + dfe.addEnumText("38400", 38400); + dfe.addEnumText("57600", 57600); + dfe.addEnumText("115200", 115200); } static void FillTCPPorts(DataFieldEnum &dfe) noexcept { - dfe.addEnumText(_T("4353"), 4353); - dfe.addEnumText(_T("10110"), 10110); - dfe.addEnumText(_T("4352"), 4352); - dfe.addEnumText(_T("2000"), 2000); - dfe.addEnumText(_T("23"), 23); - dfe.addEnumText(_T("8880"), 8880); - dfe.addEnumText(_T("8881"), 8881); - dfe.addEnumText(_T("8882"), 8882); + dfe.addEnumText("4353", 4353); + dfe.addEnumText("10110", 10110); + dfe.addEnumText("4352", 4352); + dfe.addEnumText("2000", 2000); + dfe.addEnumText("23", 23); + dfe.addEnumText("8880", 8880); + dfe.addEnumText("8881", 8881); + dfe.addEnumText("8882", 8882); } static void FillI2CBus(DataFieldEnum &dfe) noexcept { - dfe.addEnumText(_T("0"), 0U); - dfe.addEnumText(_T("1"), 1U); - dfe.addEnumText(_T("2"), 2U); + dfe.addEnumText("0", 0U); + dfe.addEnumText("1", 1U); + dfe.addEnumText("2", 2U); } /* Only lists possible addresses of supported devices */ static void FillI2CAddr(DataFieldEnum &dfe) noexcept { - dfe.addEnumText(_T("0x76 (MS5611)"), 0x76); - dfe.addEnumText(_T("0x77 (BMP085 and MS5611)"), 0x77); -// dfe.addEnumText(_T("0x52 (Nunchuck)"), 0x52); Is implied by device, no choice -// dfe.addEnumText(_T("0x69 (MPU6050)"), 0x69); Is implied by device, no choice -// dfe.addEnumText(_T("0x1e (HMC5883)"), 0x1e); Is implied by device, no choice + dfe.addEnumText("0x76 (MS5611)", 0x76); + dfe.addEnumText("0x77 (BMP085 and MS5611)", 0x77); +// dfe.addEnumText("0x52 (Nunchuck)", 0x52); Is implied by device, no choice +// dfe.addEnumText("0x69 (MPU6050)", 0x69); Is implied by device, no choice +// dfe.addEnumText("0x1e (HMC5883)", 0x1e); Is implied by device, no choice } static void FillPress(DataFieldEnum &dfe) noexcept { - dfe.addEnumText(_T("Static & Vario"), (unsigned)DeviceConfig::PressureUse::STATIC_WITH_VARIO); - dfe.addEnumText(_T("Static"), (unsigned)DeviceConfig::PressureUse::STATIC_ONLY); - dfe.addEnumText(_T("TE probe (compensated vario)"), (unsigned)DeviceConfig::PressureUse::TEK_PRESSURE); - dfe.addEnumText(_T("Pitot (airspeed)"), (unsigned)DeviceConfig::PressureUse::PITOT); + dfe.addEnumText("Static & Vario", (unsigned)DeviceConfig::PressureUse::STATIC_WITH_VARIO); + dfe.addEnumText("Static", (unsigned)DeviceConfig::PressureUse::STATIC_ONLY); + dfe.addEnumText("TE probe (compensated vario)", (unsigned)DeviceConfig::PressureUse::TEK_PRESSURE); + dfe.addEnumText("Pitot (airspeed)", (unsigned)DeviceConfig::PressureUse::PITOT); } /** @@ -88,10 +88,10 @@ FillPress(DataFieldEnum &dfe) noexcept static void FillEngineType(DataFieldEnum &dfe) noexcept { - dfe.addEnumText(_T("None"), static_cast(DeviceConfig::EngineType::NONE)); - dfe.addEnumText(_T("2S1I"), static_cast(DeviceConfig::EngineType::TWO_STROKE_1_IGN)); - dfe.addEnumText(_T("2S2I"), static_cast(DeviceConfig::EngineType::TWO_STROKE_2_IGN)); - dfe.addEnumText(_T("4S1I"), static_cast(DeviceConfig::EngineType::FOUR_STROKE_1_IGN)); + dfe.addEnumText("None", static_cast(DeviceConfig::EngineType::NONE)); + dfe.addEnumText("2S1I", static_cast(DeviceConfig::EngineType::TWO_STROKE_1_IGN)); + dfe.addEnumText("2S2I", static_cast(DeviceConfig::EngineType::TWO_STROKE_2_IGN)); + dfe.addEnumText("4S1I", static_cast(DeviceConfig::EngineType::FOUR_STROKE_1_IGN)); } static bool @@ -257,14 +257,14 @@ DeviceEditWidget::Prepare(ContainerWindow &parent, Add(_("Baud rate"), nullptr, baud_rate_df); DataFieldEnum *bulk_baud_rate_df = new DataFieldEnum(this); - bulk_baud_rate_df->addEnumText(_T("Default"), 0u); + bulk_baud_rate_df->addEnumText("Default", 0u); FillBaudRates(*bulk_baud_rate_df); bulk_baud_rate_df->SetValue(config.bulk_baud_rate); Add(_("Bulk baud rate"), _("The baud rate used for bulk transfers, such as task declaration or flight download."), bulk_baud_rate_df); - DataFieldString *ip_address_df = new DataFieldString(_T(""), this); + DataFieldString *ip_address_df = new DataFieldString("", this); ip_address_df->SetValue(config.ip_address); Add(_("IP address"), nullptr, ip_address_df); @@ -333,7 +333,7 @@ DeviceEditWidget::Prepare(ContainerWindow &parent, config.sync_to_device, this); SetExpertRow(SyncToDevice); - AddBoolean(_T("K6Bt"), + AddBoolean("K6Bt", _("Whether you use a K6Bt to connect the device."), config.k6bt, this); SetExpertRow(K6Bt); diff --git a/src/Dialogs/Device/DeviceListDialog.cpp b/src/Dialogs/Device/DeviceListDialog.cpp index d19c7663e2b..fe8f862a5d1 100644 --- a/src/Dialogs/Device/DeviceListDialog.cpp +++ b/src/Dialogs/Device/DeviceListDialog.cpp @@ -373,7 +373,7 @@ DeviceListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, const char *port_name = config.GetPortName(port_name_buffer, ARRAY_SIZE(port_name_buffer)); - StaticString<256> text(_T("A: ")); + StaticString<256> text("A: "); text[0u] += idx; if (config.UsesDriver()) { @@ -402,54 +402,54 @@ DeviceListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, } if (flags.baro) { - buffer.append(_T("; ")); + buffer.append("; "); buffer.append(_("Baro")); } if (flags.pitot) { - buffer.append(_T("; ")); + buffer.append("; "); buffer.append(_("Pitot")); } if (flags.airspeed) { - buffer.append(_T("; ")); + buffer.append("; "); buffer.append(_("Airspeed")); } if (flags.vario) { - buffer.append(_T("; ")); + buffer.append("; "); buffer.append(_("Vario")); } if (flags.traffic) - buffer.append(_T("; FLARM")); + buffer.append("; FLARM"); if (flags.temperature || flags.humidity) { - buffer.append(_T("; ")); - buffer.append(_T("Environment")); + buffer.append("; "); + buffer.append("Environment"); } if (flags.radio) { - buffer.append(_T("; ")); - buffer.append(_T("Radio")); + buffer.append("; "); + buffer.append("Radio"); } if (flags.transponder) { - buffer.append(_T("; XPDR")); + buffer.append("; XPDR"); } if (flags.engine) - buffer.append(_T("; Engine")); + buffer.append("; Engine"); if (flags.debug) { - buffer.append(_T("; ")); + buffer.append("; "); buffer.append(_("Debug")); } if (flags.battery_percent >= 0) { - buffer.append(_T("; ")); + buffer.append("; "); buffer.append(_("Battery")); - buffer.AppendFormat(_T("=%d%%"), flags.battery_percent); + buffer.AppendFormat("=%d%%", flags.battery_percent); } status = buffer; @@ -461,7 +461,7 @@ DeviceListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, buffer = _("No data"); if (flags.debug) { - buffer.append(_T("; ")); + buffer.append("; "); buffer.append(_("Debug")); } @@ -676,9 +676,9 @@ DeviceListWidget::ManageCurrent() return; } - if (descriptor.IsDriver(_T("CAI 302"))) + if (descriptor.IsDriver("CAI 302")) ManageCAI302Dialog(UIGlobals::GetMainWindow(), look, *device); - else if (descriptor.IsDriver(_T("FLARM"))) { + else if (descriptor.IsDriver("FLARM")) { FlarmVersion version; { @@ -688,7 +688,7 @@ DeviceListWidget::ManageCurrent() } ManageFlarmDialog(*device, version); - } else if (descriptor.IsDriver(_T("LX"))) { + } else if (descriptor.IsDriver("LX")) { DeviceInfo info, secondary_info; { @@ -705,9 +705,9 @@ DeviceListWidget::ManageCurrent() ManageNanoDialog(lx_device, info); else if (lx_device.IsLX16xx()) ManageLX16xxDialog(lx_device, info); - } else if (descriptor.IsDriver(_T("Vega"))) + } else if (descriptor.IsDriver("Vega")) dlgConfigurationVarioShowModal(*device); - else if (descriptor.IsDriver(_T("BlueFly"))) + else if (descriptor.IsDriver("BlueFly")) dlgConfigurationBlueFlyVarioShowModal(*device); } diff --git a/src/Dialogs/Device/FLARM/ConfigWidget.cpp b/src/Dialogs/Device/FLARM/ConfigWidget.cpp index f0a9e509cd4..00d9dfd6a8c 100644 --- a/src/Dialogs/Device/FLARM/ConfigWidget.cpp +++ b/src/Dialogs/Device/FLARM/ConfigWidget.cpp @@ -94,18 +94,18 @@ FLARMConfigWidget::Prepare([[maybe_unused]] ContainerWindow &parent, notrack = GetUnsignedValue(device, "NOTRACK", 0) == 1; static constexpr StaticEnumChoice baud_list[] = { - { 0, _T("4800") }, - { 1, _T("9600") }, - { 2, _T("19200") }, - { 4, _T("38400") }, - { 5, _T("57600") }, + { 0, "4800" }, + { 1, "9600" }, + { 2, "19200" }, + { 4, "38400" }, + { 5, "57600" }, nullptr }; AddEnum(_("Baud rate"), NULL, baud_list, baud); AddBoolean(_("Stealth mode"), NULL, priv); - AddInteger(_("Threshold"), NULL, _T("%d m/s"), _T("%d"), 1, 10, 1, thre); - AddInteger(_("Range"), NULL, _T("%d m"), _T("%d"), 2000, 25500, 250, range); + AddInteger(_("Threshold"), NULL, "%d m/s", "%d", 1, 10, 1, thre); + AddInteger(_("Range"), NULL, "%d m", "%d", 2000, 25500, 250, range); static constexpr StaticEnumChoice acft_list[] = { { FlarmTraffic::AircraftType::UNKNOWN, N_("Unknown") }, @@ -127,7 +127,7 @@ FLARMConfigWidget::Prepare([[maybe_unused]] ContainerWindow &parent, }; AddEnum(_("Type"), NULL, acft_list, acft); - AddInteger(_("Logger interval"), NULL, _T("%d s"), _T("%d"), + AddInteger(_("Logger interval"), NULL, "%d s", "%d", 1, 8, 1, log_int); AddBoolean(_("No tracking mode"), NULL, notrack); @@ -187,6 +187,6 @@ try { } catch (OperationCancelled) { return false; } catch (...) { - ShowError(std::current_exception(), _T("FLARM")); + ShowError(std::current_exception(), "FLARM"); return false; } diff --git a/src/Dialogs/Device/LX/LXNAVVarioConfigWidget.cpp b/src/Dialogs/Device/LX/LXNAVVarioConfigWidget.cpp index eb520f38935..fcde87cdca6 100644 --- a/src/Dialogs/Device/LX/LXNAVVarioConfigWidget.cpp +++ b/src/Dialogs/Device/LX/LXNAVVarioConfigWidget.cpp @@ -52,17 +52,17 @@ LXNAVVarioConfigWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[mayb brpda = WaitUnsignedValue(device, "BRPDA", 5); static constexpr StaticEnumChoice baud_list[] = { - { 0, _T("4800") }, - { 1, _T("9600") }, - { 2, _T("19200") }, - { 3, _T("38400") }, - { 4, _T("57600") }, - { 5, _T("115200") }, - { 6, _T("230400") }, - { 7, _T("256000") }, - { 8, _T("460800") }, - { 9, _T("500k") }, - { 10, _T("1M") }, + { 0, "4800" }, + { 1, "9600" }, + { 2, "19200" }, + { 3, "38400" }, + { 4, "57600" }, + { 5, "115200" }, + { 6, "230400" }, + { 7, "256000" }, + { 8, "460800" }, + { 9, "500k" }, + { 10, "1M" }, { 0 } }; @@ -94,6 +94,6 @@ try { } catch (OperationCancelled) { return false; } catch (...) { - ShowError(std::current_exception(), _T("Vega")); + ShowError(std::current_exception(), "Vega"); return false; } diff --git a/src/Dialogs/Device/LX/ManageLX16xxDialog.cpp b/src/Dialogs/Device/LX/ManageLX16xxDialog.cpp index 67f5275e9ff..fb870cd1dc8 100644 --- a/src/Dialogs/Device/LX/ManageLX16xxDialog.cpp +++ b/src/Dialogs/Device/LX/ManageLX16xxDialog.cpp @@ -54,7 +54,7 @@ void ManageLX16xxDialog(Device &device, const DeviceInfo &info) { StaticString<64> title; - title.Format(_T("LX %s"), info.product.c_str()); + title.Format("LX %s", info.product.c_str()); WidgetDialog dialog(WidgetDialog::Auto{}, UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), diff --git a/src/Dialogs/Device/LX/ManageLXNAVVarioDialog.cpp b/src/Dialogs/Device/LX/ManageLXNAVVarioDialog.cpp index cdc6bbabb0c..567322e2da6 100644 --- a/src/Dialogs/Device/LX/ManageLXNAVVarioDialog.cpp +++ b/src/Dialogs/Device/LX/ManageLXNAVVarioDialog.cpp @@ -61,11 +61,11 @@ ManageLXNAVVarioWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[mayb AddButton(_("Setup"), [this](){ LXNAVVarioConfigWidget widget(GetLook(), device); DefaultWidgetDialog(UIGlobals::GetMainWindow(), GetLook(), - _T("LXNAV Vario"), widget); + "LXNAV Vario", widget); }); if (device.IsNano()) - AddButton(_T("LXNAV Nano"), [this](){ + AddButton("LXNAV Nano", [this](){ MessageOperationEnvironment env; if (device.EnablePassThrough(env)) { ManageNanoDialog(device, secondary_info); @@ -80,7 +80,7 @@ ManageLXNAVVarioDialog(Device &device, const DeviceInfo &info, { WidgetDialog dialog(WidgetDialog::Auto{}, UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T("LXNAV Vario"), + "LXNAV Vario", new ManageLXNAVVarioWidget(UIGlobals::GetDialogLook(), (LXDevice &)device, info, secondary_info)); diff --git a/src/Dialogs/Device/LX/ManageNanoDialog.cpp b/src/Dialogs/Device/LX/ManageNanoDialog.cpp index 62358395c51..ab6e7710a82 100644 --- a/src/Dialogs/Device/LX/ManageNanoDialog.cpp +++ b/src/Dialogs/Device/LX/ManageNanoDialog.cpp @@ -60,7 +60,7 @@ ManageNanoWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unus AddButton(_("Setup"), [this](){ NanoConfigWidget widget(GetLook(), device); DefaultWidgetDialog(UIGlobals::GetMainWindow(), GetLook(), - _T("LXNAV Nano"), widget); + "LXNAV Nano", widget); }); } @@ -69,7 +69,7 @@ ManageNanoDialog(Device &device, const DeviceInfo &info) { WidgetDialog dialog(WidgetDialog::Auto{}, UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T("LXNAV Nano"), + "LXNAV Nano", new ManageNanoWidget(UIGlobals::GetDialogLook(), (LXDevice &)device, info)); dialog.AddButton(_("Close"), mrCancel); diff --git a/src/Dialogs/Device/LX/NanoConfigWidget.cpp b/src/Dialogs/Device/LX/NanoConfigWidget.cpp index 2decb003da6..7abb3e49a49 100644 --- a/src/Dialogs/Device/LX/NanoConfigWidget.cpp +++ b/src/Dialogs/Device/LX/NanoConfigWidget.cpp @@ -64,13 +64,13 @@ NanoConfigWidget::Prepare([[maybe_unused]] ContainerWindow &parent, RequestAllSettings(device); static constexpr StaticEnumChoice baud_list[] = { - { 2400, _T("2400") }, - { 4800, _T("4800") }, - { 9600, _T("9600") }, - { 19200, _T("19200") }, - { 38400, _T("38400") }, - { 57600, _T("57600") }, - { 115200, _T("115200") }, + { 2400, "2400" }, + { 4800, "4800" }, + { 9600, "9600" }, + { 19200, "19200" }, + { 38400, "38400" }, + { 57600, "57600" }, + { 115200, "115200" }, { 0 } }; @@ -90,7 +90,7 @@ NanoConfigWidget::Prepare([[maybe_unused]] ContainerWindow &parent, WaitBoolValue(device, "NMEA", true)); AddInteger(_("Recording interval"), NULL, - _T("%d s"), _T("%d"), 1, 60, 1, + "%d s", "%d", 1, 60, 1, WaitUnsignedValue(device, "RECINT", 1)); } @@ -139,6 +139,6 @@ try { } catch (OperationCancelled) { return false; } catch (...) { - ShowError(std::current_exception(), _T("LXNAV Nano")); + ShowError(std::current_exception(), "LXNAV Nano"); return false; } diff --git a/src/Dialogs/Device/ManageCAI302Dialog.cpp b/src/Dialogs/Device/ManageCAI302Dialog.cpp index 16b4a09d165..4f9c8ab7e44 100644 --- a/src/Dialogs/Device/ManageCAI302Dialog.cpp +++ b/src/Dialogs/Device/ManageCAI302Dialog.cpp @@ -105,7 +105,7 @@ ManageCAI302Widget::Prepare([[maybe_unused]] ContainerWindow &parent, AddButton(_("Delete all flights"), [this](){ if (ShowMessageBox(_("Do you really want to delete all flights from the device?"), - _T("CAI 302"), MB_YESNO) != IDYES) + "CAI 302", MB_YESNO) != IDYES) return; MessageOperationEnvironment env; @@ -134,7 +134,7 @@ ManageCAI302Dialog([[maybe_unused]] SingleWindow &parent, const DialogLook &look { WidgetDialog dialog(WidgetDialog::Auto{}, UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T("CAI 302"), + "CAI 302", new ManageCAI302Widget(look, (CAI302Device &)device)); dialog.AddButton(_("Close"), mrCancel); dialog.ShowModal(); diff --git a/src/Dialogs/Device/ManageFlarmDialog.cpp b/src/Dialogs/Device/ManageFlarmDialog.cpp index a7ca856eff5..15e6e722d86 100644 --- a/src/Dialogs/Device/ManageFlarmDialog.cpp +++ b/src/Dialogs/Device/ManageFlarmDialog.cpp @@ -60,7 +60,7 @@ ManageFLARMWidget::Prepare([[maybe_unused]] ContainerWindow &parent, AddButton(_("Setup"), [this](){ FLARMConfigWidget widget(GetLook(), device); DefaultWidgetDialog(UIGlobals::GetMainWindow(), GetLook(), - _T("FLARM"), widget); + "FLARM", widget); }); AddButton(_("Reboot"), [this](){ @@ -79,7 +79,7 @@ ManageFlarmDialog(Device &device, const FlarmVersion &version) { WidgetDialog dialog(WidgetDialog::Auto{}, UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T("FLARM"), + "FLARM", new ManageFLARMWidget(UIGlobals::GetDialogLook(), (FlarmDevice &)device, version)); dialog.AddButton(_("Close"), mrCancel); diff --git a/src/Dialogs/Device/ManageI2CPitotDialog.cpp b/src/Dialogs/Device/ManageI2CPitotDialog.cpp index 9630dac1f97..272321833ca 100644 --- a/src/Dialogs/Device/ManageI2CPitotDialog.cpp +++ b/src/Dialogs/Device/ManageI2CPitotDialog.cpp @@ -105,9 +105,9 @@ void ManageI2CPitotWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { - AddReadOnly(_("Pitot"), nullptr, _T("%.2f"), UnitGroup::PRESSURE, 0); - AddReadOnly(_("Pressure"), nullptr, _T("%.2f"), UnitGroup::PRESSURE, 0); - AddReadOnly(_("Offset"), nullptr, _T("%.2f"), + AddReadOnly(_("Pitot"), nullptr, "%.2f", UnitGroup::PRESSURE, 0); + AddReadOnly(_("Pressure"), nullptr, "%.2f", UnitGroup::PRESSURE, 0); + AddReadOnly(_("Offset"), nullptr, "%.2f", UnitGroup::PRESSURE, device.GetConfig().sensor_offset); } diff --git a/src/Dialogs/Device/PortDataField.cpp b/src/Dialogs/Device/PortDataField.cpp index aa181ef665e..5e5a4335fb0 100644 --- a/src/Dialogs/Device/PortDataField.cpp +++ b/src/Dialogs/Device/PortDataField.cpp @@ -37,8 +37,8 @@ static constexpr struct { #endif #ifdef ANDROID { DeviceConfig::PortType::RFCOMM_SERVER, N_("Bluetooth server") }, - { DeviceConfig::PortType::DROIDSOAR_V2, _T("DroidSoar V2") }, - { DeviceConfig::PortType::GLIDER_LINK, _T("GliderLink traffic receiver") }, + { DeviceConfig::PortType::DROIDSOAR_V2, "DroidSoar V2" }, + { DeviceConfig::PortType::GLIDER_LINK, "GliderLink traffic receiver" }, #ifndef NDEBUG { DeviceConfig::PortType::NUNCHUCK, N_("IOIO switches and Nunchuk") }, #endif @@ -106,8 +106,8 @@ static void DetectSerialPorts(DataFieldEnum &df) noexcept try { //------------------------------- - RegistryKey bthenums{HKEY_LOCAL_MACHINE, _T("SYSTEM\\CurrentControlSet\\" - "Enum\\BthEnum")}; + RegistryKey bthenums{HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\" + "Enum\\BthEnum"}; std::map bthmap; for (unsigned k = 0;; ++k) { char dev_name[128]; @@ -117,14 +117,14 @@ try { if (!bthenums.EnumKey(k, std::span{dev_name})) break; std::string map_name(dev_name); - if (!map_name.starts_with(_T("Dev_"))) + if (!map_name.starts_with("Dev_")) continue; RegistryKey bthenum_dev{bthenums, dev_name}; // only one is possible... if (!bthenum_dev.EnumKey(0, std::span{name})) break; RegistryKey bthenum_key{bthenum_dev, name}; - if (!bthenum_key.GetValue(_T("FriendlyName"), friendly_name)) + if (!bthenum_key.GetValue("FriendlyName", friendly_name)) break; map_name = map_name.substr(4); for (std::string::iterator it = map_name.begin(); it != map_name.end(); @@ -132,8 +132,8 @@ try { *it = towlower(*it); bthmap[map_name] = friendly_name; // Left "Dev_" } - RegistryKey bthle{HKEY_LOCAL_MACHINE, _T("SYSTEM\\CurrentControlSet\\" - "Enum\\BthLE")}; + RegistryKey bthle{HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\" + "Enum\\BthLE"}; std::map blemap; for (unsigned k = 0;; ++k) { char dev_name[128]; @@ -143,14 +143,14 @@ try { if (!bthle.EnumKey(k, std::span{dev_name})) break; std::string map_name(dev_name); - if (!map_name.starts_with(_T("Dev_"))) + if (!map_name.starts_with("Dev_")) continue; RegistryKey bthle_dev{bthle, dev_name}; // only one is possible... if (!bthle_dev.EnumKey(0, std::span{name})) break; RegistryKey bthle_key{bthle_dev, name}; - if (!bthle_key.GetValue(_T("FriendlyName"), friendly_name)) + if (!bthle_key.GetValue("FriendlyName", friendly_name)) break; map_name = map_name.substr(4); for (std::string::iterator it = map_name.begin(); it != map_name.end(); @@ -161,7 +161,7 @@ try { /* the registry key HKEY_LOCAL_MACHINE/Hardware/DEVICEMAP/SERIALCOMM is the best way to discover serial ports on Windows */ - RegistryKey serialcomm{HKEY_LOCAL_MACHINE, _T("Hardware\\DeviceMap\\SerialComm")}; + RegistryKey serialcomm{HKEY_LOCAL_MACHINE, "Hardware\\DeviceMap\\SerialComm"}; for (unsigned i = 0;; ++i) { char name[128]; @@ -176,8 +176,8 @@ try { // weird continue; - RegistryKey devices {HKEY_LOCAL_MACHINE, _T("SYSTEM\\CurrentControlSet\\" - "Control\\COM Name Arbiter\\Devices")}; + RegistryKey devices {HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\" + "Control\\COM Name Arbiter\\Devices"}; char name1[0x200]; if (!devices.GetValue(value, name1)) @@ -188,27 +188,27 @@ try { // USB: "\\?\usb#" // Normal: "\\?\acpi#" - an Kupschis Rechner! std::string dev = name1; - if (dev.starts_with(_T("\\\\?\\usb#"))) { + if (dev.starts_with("\\\\?\\usb#")) { std::vector strs; std::string port_name; boost::split(strs, name, boost::is_any_of("\\")); port_name = value; - port_name += _T(" ("); + port_name += " ("; port_name += strs[2]; - port_name += _T(")"); + port_name += ")"; AddPort(df, DeviceConfig::PortType::USB_SERIAL, value, port_name.c_str()); - } else if (dev.starts_with(_T("\\\\?\\bthenum#"))) { + } else if (dev.starts_with("\\\\?\\bthenum#")) { std::vector strs; std::string port_name; boost::split(strs, name1, boost::is_any_of("#")); boost::split(strs, strs[2], boost::is_any_of("_")); - if (strs[1] == _T("c00000000")) { + if (strs[1] == "c00000000") { boost::split(strs, strs[0], boost::is_any_of("&")); - if (strs[3] != _T("000000000000")) { + if (strs[3] != "000000000000") { DeviceConfig::PortType port_type = DeviceConfig::PortType::DISABLED; port_name = value; - port_name += _T(" ("); + port_name += " ("; if (blemap.find(strs[3]) != blemap.end()) { port_type = DeviceConfig::PortType::RFCOMM; port_type = DeviceConfig::PortType::BLE_HM10; @@ -219,13 +219,13 @@ try { port_name += bthmap[strs[3]]; } - port_name += _T(")"); + port_name += ")"; if (port_type != DeviceConfig::PortType::DISABLED) AddPort(df, port_type, value, port_name.c_str()); } } - } else // if (dev.starts_with(_T("\\\\?\\acpi#"))) + } else // if (dev.starts_with("\\\\?\\acpi#")) AddPort(df, DeviceConfig::PortType::SERIAL, value, name); } } catch (const std::system_error &) { @@ -322,8 +322,8 @@ FillAndroidIOIOPorts([[maybe_unused]] DataFieldEnum &df, [[maybe_unused]] const char tempID[4]; char tempName[15]; for (unsigned i = 0; i < AndroidIOIOUartPort::getNumberUarts(); i++) { - StringFormatUnsafe(tempID, _T("%u"), i); - StringFormat(tempName, sizeof(tempName), _T("IOIO UART %u"), i); + StringFormatUnsafe(tempID, "%u", i); + StringFormat(tempName, sizeof(tempName), "IOIO UART %u", i); unsigned id = AddPort(df, DeviceConfig::PortType::IOIOUART, tempID, tempName, AndroidIOIOUartPort::getPortHelp(i)); @@ -399,7 +399,7 @@ SetDevicePort(DataFieldEnum &df, const DeviceConfig &config) noexcept case DeviceConfig::PortType::IOIOUART: StaticString<16> buffer; - buffer.UnsafeFormat(_T("%d"), config.ioio_uart_id); + buffer.UnsafeFormat("%d", config.ioio_uart_id); df.SetValue(buffer); return; } diff --git a/src/Dialogs/Device/PortMonitor.cpp b/src/Dialogs/Device/PortMonitor.cpp index a03f7c51431..e0fd75bb0ba 100644 --- a/src/Dialogs/Device/PortMonitor.cpp +++ b/src/Dialogs/Device/PortMonitor.cpp @@ -157,7 +157,7 @@ ShowPortMonitor(DeviceDescriptor &device) std::array buffer; StaticString<128> caption; - caption.Format(_T("%s: %s"), _("Port monitor"), + caption.Format("%s: %s", _("Port monitor"), device.GetConfig().GetPortName(buffer.data(), buffer.size())); TWidgetDialog diff --git a/src/Dialogs/Device/PortPicker.cpp b/src/Dialogs/Device/PortPicker.cpp index 3a5fe887af0..2d35d6c4a26 100644 --- a/src/Dialogs/Device/PortPicker.cpp +++ b/src/Dialogs/Device/PortPicker.cpp @@ -47,7 +47,7 @@ class PortListItemRenderer final { static const char *ToDisplayString(DeviceConfig::PortType type) noexcept { switch (type) { case DeviceConfig::PortType::RFCOMM: - return _T("Bluetooth"); + return "Bluetooth"; case DeviceConfig::PortType::BLE_HM10: return _("BLE port"); diff --git a/src/Dialogs/Device/Vega/AlertParameters.hpp b/src/Dialogs/Device/Vega/AlertParameters.hpp index 6d51c547144..96a34407258 100644 --- a/src/Dialogs/Device/Vega/AlertParameters.hpp +++ b/src/Dialogs/Device/Vega/AlertParameters.hpp @@ -10,25 +10,25 @@ static constexpr VegaParametersWidget::StaticParameter alert_parameters[] = { { DataField::Type::INTEGER, "GearOnDelay", N_("Gear on delay"), NULL, - NULL, 1, 2000, 50, _T("%d ms") }, + NULL, 1, 2000, 50, "%d ms" }, { DataField::Type::INTEGER, "GearOffDelay", N_("Gear off delay"), NULL, - NULL, 1, 2000, 50, _T("%d ms") }, + NULL, 1, 2000, 50, "%d ms" }, { DataField::Type::INTEGER, "GearRepeatTime", N_("Interval; gear"), NULL, - NULL, 1, 100, 1, _T("%d s") }, + NULL, 1, 100, 1, "%d s" }, { DataField::Type::INTEGER, "PlyMaxComDelay", N_("Radio com. max. delay"), NULL, - NULL, 0, 100, 1, _T("%d s") }, + NULL, 0, 100, 1, "%d s" }, { DataField::Type::INTEGER, "BatLowDelay", N_("Battery low delay"), NULL, - NULL, 0, 100, 1, _T("%d s") }, + NULL, 0, 100, 1, "%d s" }, { DataField::Type::INTEGER, "BatEmptyDelay", N_("Battery empty delay"), NULL, - NULL, 0, 100, 1, _T("%d s") }, + NULL, 0, 100, 1, "%d s" }, { DataField::Type::INTEGER, "BatRepeatTime", N_("Interval; battery"), NULL, - NULL, 0, 100, 1, _T("%d s") }, + NULL, 0, 100, 1, "%d s" }, /* sentinel */ { DataField::Type::BOOLEAN } diff --git a/src/Dialogs/Device/Vega/AudioDeadbandParameters.hpp b/src/Dialogs/Device/Vega/AudioDeadbandParameters.hpp index 4fccce3ae09..6627bcdde6c 100644 --- a/src/Dialogs/Device/Vega/AudioDeadbandParameters.hpp +++ b/src/Dialogs/Device/Vega/AudioDeadbandParameters.hpp @@ -23,12 +23,12 @@ VegaParametersWidget::StaticParameter audio_deadband_parameters[] = { { DataField::Type::INTEGER, "ToneDeadbandCirclingHigh", N_("Circling hi cutoff"), N_("High limit of circling dead band"), - NULL, 0, 100, 1, _T("%d %%"), + NULL, 0, 100, 1, "%d %%", }, { DataField::Type::INTEGER, "ToneDeadbandCirclingLow", N_("Circling low cutoff"), N_("Low limit of circling dead band"), - NULL, 0, 100, 1, _T("%d %%"), + NULL, 0, 100, 1, "%d %%", }, { DataField::Type::ENUM, "ToneDeadbandCruiseType", @@ -39,12 +39,12 @@ VegaParametersWidget::StaticParameter audio_deadband_parameters[] = { { DataField::Type::INTEGER, "ToneDeadbandCruiseHigh", N_("Cruise hi cutoff"), N_("High limit of cruise dead band"), - NULL, 0, 100, 1, _T("%d %%"), + NULL, 0, 100, 1, "%d %%", }, { DataField::Type::INTEGER, "ToneDeadbandCruiseLow", N_("Cruise low cutoff"), N_("Low limit of cruise dead band"), - NULL, 0, 100, 1, _T("%d %%"), + NULL, 0, 100, 1, "%d %%", }, /* sentinel */ diff --git a/src/Dialogs/Device/Vega/AudioModeParameters.hpp b/src/Dialogs/Device/Vega/AudioModeParameters.hpp index 07657b8afba..14ca644b291 100644 --- a/src/Dialogs/Device/Vega/AudioModeParameters.hpp +++ b/src/Dialogs/Device/Vega/AudioModeParameters.hpp @@ -10,38 +10,38 @@ static constexpr StaticEnumChoice tone_climb_comparisons[] = { { 0, N_("None") }, - { 1, _T("Gross>MacCready") }, - { 2, _T("Gross>Average") }, + { 1, "Gross>MacCready" }, + { 2, "Gross>Average" }, { 0 } }; static constexpr StaticEnumChoice tone_cruise_lift_detection_types[] = { { 0, N_("Disabled") }, - { 1, _T("Relative>0") }, - { 2, _T("Relative>MacCready/2") }, - { 3, _T("Gross>0") }, - { 4, _T("Net>MacCready/2") }, - { 5, _T("Relative>MacCready") }, - { 6, _T("Net>MacCready") }, + { 1, "Relative>0" }, + { 2, "Relative>MacCready/2" }, + { 3, "Gross>0" }, + { 4, "Net>MacCready/2" }, + { 5, "Relative>MacCready" }, + { 6, "Net>MacCready" }, { 0 } }; static constexpr StaticEnumChoice time_scales[] = { - { 0, _T(" 0.0s") }, - { 1, _T(" 0.8s") }, - { 2, _T(" 1.7s") }, - { 3, _T(" 3.5s") }, - { 4, _T(" 7.5s") }, - { 5, _T("15.0s") }, - { 6, _T("30.0s") }, + { 0, " 0.0s" }, + { 1, " 0.8s" }, + { 2, " 1.7s" }, + { 3, " 3.5s" }, + { 4, " 7.5s" }, + { 5, "15.0s" }, + { 6, "30.0s" }, { 0 } }; static constexpr StaticEnumChoice filter_time[] = { - { 0, _T(" 1.0s") }, - { 1, _T(" 1.3s") }, - { 2, _T(" 1.8s") }, - { 3, _T(" 2.7s") }, + { 0, " 1.0s" }, + { 1, " 1.3s" }, + { 2, " 1.8s" }, + { 3, " 2.7s" }, { 0 } }; @@ -69,17 +69,17 @@ VegaParametersWidget::StaticParameter audio_mode_parameters[] = { { DataField::Type::INTEGER, "ToneMeanVolumeCircling", N_("Circling volume"), N_("Mean volume level in circling modes."), - NULL, 0, 8, 1, _T("%d/8"), + NULL, 0, 8, 1, "%d/8", }, { DataField::Type::INTEGER, "ToneMeanVolumeCruise", N_("Cruise volume"), N_("Mean volume level in cruise modes. If set to zero, scales with airspeed."), - NULL, 0, 8, 1, _T("%d/8"), + NULL, 0, 8, 1, "%d/8", }, { DataField::Type::INTEGER, "ToneBaseFrequencyOffset", N_("Base frequency"), N_("Adjustment to base frequency of tones in all modes."), - NULL, -30, 30, 1, _T("%d"), + NULL, -30, 30, 1, "%d", }, { DataField::Type::ENUM, "VarioTimeConstantCircling", N_("Filter circling"), @@ -94,7 +94,7 @@ VegaParametersWidget::StaticParameter audio_mode_parameters[] = { { DataField::Type::INTEGER, "TonePitchScale", N_("Tone pitch scale"), N_("Adjustment to base pitch scale of tones in all modes."), - NULL, 32, 100, 1, _T("%d"), + NULL, 32, 100, 1, "%d", }, /* sentinel */ diff --git a/src/Dialogs/Device/Vega/AudioParameters.hpp b/src/Dialogs/Device/Vega/AudioParameters.hpp index a9ba1b6f487..6f4aeee585b 100644 --- a/src/Dialogs/Device/Vega/AudioParameters.hpp +++ b/src/Dialogs/Device/Vega/AudioParameters.hpp @@ -12,49 +12,49 @@ #include static constexpr StaticEnumChoice beep_types[] = { - { 0, _T("Silence") }, - { 1, _T("Short") }, - { 2, _T("Medium") }, - { 3, _T("Long") }, - { 4, _T("Continuous") }, - { 5, _T("Short double") }, + { 0, "Silence" }, + { 1, "Short" }, + { 2, "Medium" }, + { 3, "Long" }, + { 4, "Continuous" }, + { 5, "Short double" }, { 0 } }; static constexpr StaticEnumChoice pitch_schemes[] = { - { 0, _T("Constant high") }, - { 1, _T("Constant medium") }, - { 2, _T("Constant low") }, - { 3, _T("Speed percent") }, - { 4, _T("Speed error") }, - { 5, _T("Vario gross") }, - { 6, _T("Vario net") }, - { 7, _T("Vario relative") }, - { 8, _T("Vario gross/relative") }, + { 0, "Constant high" }, + { 1, "Constant medium" }, + { 2, "Constant low" }, + { 3, "Speed percent" }, + { 4, "Speed error" }, + { 5, "Vario gross" }, + { 6, "Vario net" }, + { 7, "Vario relative" }, + { 8, "Vario gross/relative" }, { 0 } }; static constexpr StaticEnumChoice period_schemes[] = { - { 0, _T("Constant high") }, - { 1, _T("Constant medium") }, - { 2, _T("Constant low") }, - { 3, _T("Speed percent") }, - { 4, _T("Speed error") }, - { 5, _T("Vario gross") }, - { 6, _T("Vario net") }, - { 7, _T("Vario relative") }, - { 8, _T("Vario gross/relative") }, - { 9, _T("Intermittent") }, + { 0, "Constant high" }, + { 1, "Constant medium" }, + { 2, "Constant low" }, + { 3, "Speed percent" }, + { 4, "Speed error" }, + { 5, "Vario gross" }, + { 6, "Vario net" }, + { 7, "Vario relative" }, + { 8, "Vario gross/relative" }, + { 9, "Intermittent" }, { 0 } }; static constexpr StaticEnumChoice pitch_and_period_scales[] = { - { 0, _T("+Linear") }, - { 1, _T("+Low end") }, - { 2, _T("+High end") }, - { 3, _T("-Linear") }, - { 4, _T("-Low end") }, - { 5, _T("-High end") }, + { 0, "+Linear" }, + { 1, "+Low end" }, + { 2, "+High end" }, + { 3, "-Linear" }, + { 4, "-Low end" }, + { 5, "-High end" }, { 0 } }; diff --git a/src/Dialogs/Device/Vega/CalibrationParameters.hpp b/src/Dialogs/Device/Vega/CalibrationParameters.hpp index cf4a11f2e91..ca9cd7b2100 100644 --- a/src/Dialogs/Device/Vega/CalibrationParameters.hpp +++ b/src/Dialogs/Device/Vega/CalibrationParameters.hpp @@ -11,22 +11,22 @@ VegaParametersWidget::StaticParameter calibration_parameters[] = { { DataField::Type::INTEGER, "TotalEnergyMixingRatio", N_("TE mixing"), N_("Proportion of TE probe value used in total energy mixing with pitot/static total energy."), - NULL, 0, 8, 1, _T("%d/8"), + NULL, 0, 8, 1, "%d/8", }, { DataField::Type::INTEGER, "CalibrationAirSpeed", N_("ASI cal."), N_("Calibration factor applied to measured airspeed to obtain indicated airspeed."), - NULL, 0, 200, 1, _T("%d %%"), + NULL, 0, 200, 1, "%d %%", }, { DataField::Type::INTEGER, "CalibrationTEStatic", N_("TE static cal."), N_("Calibration factor applied to static pressure used in total energy calculation."), - NULL, 0, 200, 1, _T("%d %%"), + NULL, 0, 200, 1, "%d %%", }, { DataField::Type::INTEGER, "CalibrationTEDynamic", N_("TE dynamic cal."), N_("Calibration factor applied to dynamic pressure used in total energy calculation."), - NULL, 0, 200, 1, _T("%d %%"), + NULL, 0, 200, 1, "%d %%", }, /* sentinel */ diff --git a/src/Dialogs/Device/Vega/DisplayParameters.hpp b/src/Dialogs/Device/Vega/DisplayParameters.hpp index 3f26b98d707..a3d45738c92 100644 --- a/src/Dialogs/Device/Vega/DisplayParameters.hpp +++ b/src/Dialogs/Device/Vega/DisplayParameters.hpp @@ -8,9 +8,9 @@ #include "Language/Language.hpp" static constexpr StaticEnumChoice needle_gauge_types[] = { - { 0, _T("None") }, - { 1, _T("LX") }, - { 2, _T("Analog") }, + { 0, "None" }, + { 1, "LX" }, + { 2, "Analog" }, { 0 }, }; @@ -19,7 +19,7 @@ VegaParametersWidget::StaticParameter display_parameters[] = { { DataField::Type::ENUM, "NeedleGaugeType", N_("Needle gauge type"), NULL, needle_gauge_types }, { DataField::Type::INTEGER, "LedBrightness", N_("LED bright"), NULL, - NULL, 1, 15, 1, _T("%d/15") }, + NULL, 1, 15, 1, "%d/15" }, /* sentinel */ { DataField::Type::BOOLEAN } diff --git a/src/Dialogs/Device/Vega/FlarmAlertParameters.hpp b/src/Dialogs/Device/Vega/FlarmAlertParameters.hpp index 942fde29d52..eac0a63e34d 100644 --- a/src/Dialogs/Device/Vega/FlarmAlertParameters.hpp +++ b/src/Dialogs/Device/Vega/FlarmAlertParameters.hpp @@ -8,19 +8,19 @@ #include "Language/Language.hpp" static constexpr StaticEnumChoice flarm_user_interfaces[] = { - { 0, _T("LED+Buzzer") }, - { 1, _T("None") }, - { 2, _T("Buzzer") }, - { 3, _T("LED") }, + { 0, "LED+Buzzer" }, + { 1, "None" }, + { 2, "Buzzer" }, + { 3, "LED" }, { 0 } }; static constexpr VegaParametersWidget::StaticParameter flarm_alert_parameters[] = { { DataField::Type::INTEGER, "FlarmMaxObjectsReported", - N_("Max. objects reported"), NULL, NULL, 0, 15, 1, _T("%d") }, + N_("Max. objects reported"), NULL, NULL, 0, 15, 1, "%d" }, { DataField::Type::INTEGER, "FlarmMaxObjectsReportedOnCircling", - N_("Max. reported"), NULL, NULL, 0, 4, 1, _T("%d") }, + N_("Max. reported"), NULL, NULL, 0, 4, 1, "%d" }, { DataField::Type::ENUM, "FlarmUserInterface", N_("Flarm interface"), NULL, flarm_user_interfaces }, { DataField::Type::BOOLEAN, "KeepOnStraightFlightMode", diff --git a/src/Dialogs/Device/Vega/FlarmIdentificationParameters.hpp b/src/Dialogs/Device/Vega/FlarmIdentificationParameters.hpp index 8ad4ddf8a7d..74185ca6006 100644 --- a/src/Dialogs/Device/Vega/FlarmIdentificationParameters.hpp +++ b/src/Dialogs/Device/Vega/FlarmIdentificationParameters.hpp @@ -8,21 +8,21 @@ #include "Language/Language.hpp" static constexpr StaticEnumChoice flarm_aircraft_types[] = { - { 0, _T("Undefined") }, - { 1, _T("Glider") }, - { 2, _T("Tow plane") }, - { 3, _T("Helicopter") }, - { 4, _T("Parachute") }, - { 5, _T("Drop plane") }, - { 6, _T("Fixed hangglider") }, - { 7, _T("Soft paraglider") }, - { 8, _T("Powered aircraft") }, - { 9, _T("Jet aircraft") }, - { 10, _T("UFO") }, - { 11, _T("Baloon") }, - { 12, _T("Blimp, Zeppelin") }, - { 13, _T("UAV (Drone)") }, - { 14, _T("Static") }, + { 0, "Undefined" }, + { 1, "Glider" }, + { 2, "Tow plane" }, + { 3, "Helicopter" }, + { 4, "Parachute" }, + { 5, "Drop plane" }, + { 6, "Fixed hangglider" }, + { 7, "Soft paraglider" }, + { 8, "Powered aircraft" }, + { 9, "Jet aircraft" }, + { 10, "UFO" }, + { 11, "Baloon" }, + { 12, "Blimp, Zeppelin" }, + { 13, "UAV (Drone)" }, + { 14, "Static" }, { 0 } }; diff --git a/src/Dialogs/Device/Vega/FlarmRepeatParameters.hpp b/src/Dialogs/Device/Vega/FlarmRepeatParameters.hpp index 7b860f5ec38..6e38ea4f144 100644 --- a/src/Dialogs/Device/Vega/FlarmRepeatParameters.hpp +++ b/src/Dialogs/Device/Vega/FlarmRepeatParameters.hpp @@ -10,13 +10,13 @@ static constexpr VegaParametersWidget::StaticParameter flarm_repeat_parameters[] = { { DataField::Type::INTEGER, "FlarmInfoRepeatTime", N_("Interval; info"), NULL, - NULL, 1, 2000, 100, _T("%d ms") }, + NULL, 1, 2000, 100, "%d ms" }, { DataField::Type::INTEGER, "FlarmCautionRepeatTime", N_("Interval; caution"), NULL, - NULL, 1, 2000, 100, _T("%d ms") }, + NULL, 1, 2000, 100, "%d ms" }, { DataField::Type::INTEGER, "FlarmWarningRepeatTime", N_("Interval; warning"), NULL, - NULL, 1, 2000, 100, _T("%d ms") }, + NULL, 1, 2000, 100, "%d ms" }, /* sentinel */ { DataField::Type::BOOLEAN } diff --git a/src/Dialogs/Device/Vega/HardwareParameters.hpp b/src/Dialogs/Device/Vega/HardwareParameters.hpp index 482caad6fb6..269a298a28e 100644 --- a/src/Dialogs/Device/Vega/HardwareParameters.hpp +++ b/src/Dialogs/Device/Vega/HardwareParameters.hpp @@ -15,13 +15,13 @@ static constexpr StaticEnumChoice tri_state[] = { }; static constexpr StaticEnumChoice baud_rates[] = { - { 0, _T("Auto") }, - { 1, _T("4800") }, - { 2, _T("9600") }, - { 3, _T("19200") }, - { 4, _T("38400") }, - { 5, _T("57600") }, - { 6, _T("115200") }, + { 0, "Auto" }, + { 1, "4800" }, + { 2, "9600" }, + { 3, "19200" }, + { 4, "38400" }, + { 5, "57600" }, + { 6, "115200" }, { 0 }, }; diff --git a/src/Dialogs/Device/Vega/LimitParameters.hpp b/src/Dialogs/Device/Vega/LimitParameters.hpp index a3e4946542f..8d3eb8a76a1 100644 --- a/src/Dialogs/Device/Vega/LimitParameters.hpp +++ b/src/Dialogs/Device/Vega/LimitParameters.hpp @@ -9,17 +9,17 @@ static constexpr VegaParametersWidget::StaticParameter limit_parameters[] = { { DataField::Type::INTEGER, "VelocityNeverExceed", N_("VNE"), NULL, - NULL, 0, 2000, 10, _T("%d (0.1 m/s)") }, + NULL, 0, 2000, 10, "%d (0.1 m/s)" }, { DataField::Type::INTEGER, "VelocitySafeTerrain", N_("V terrain"), NULL, - NULL, 0, 2000, 10, _T("%d (0.1 m/s)") }, + NULL, 0, 2000, 10, "%d (0.1 m/s)" }, { DataField::Type::INTEGER, "VelocitySafeTerrain", N_("Height terrain"), - NULL, NULL, 0, 2000, 10, _T("%d m") }, + NULL, NULL, 0, 2000, 10, "%d m" }, { DataField::Type::INTEGER, "VelocityManoeuvering", N_("V manoeuvering"), - NULL, NULL, 0, 2000, 10, _T("%d (0.1 m/s)") }, + NULL, NULL, 0, 2000, 10, "%d (0.1 m/s)" }, { DataField::Type::INTEGER, "VelocityAirBrake", N_("V airbrake"), - NULL, NULL, 0, 2000, 10, _T("%d (0.1 m/s)") }, + NULL, NULL, 0, 2000, 10, "%d (0.1 m/s)" }, { DataField::Type::INTEGER, "VelocityFlap", N_("V flap"), - NULL, NULL, 0, 2000, 10, _T("%d (0.1 m/s)") }, + NULL, NULL, 0, 2000, 10, "%d (0.1 m/s)" }, /* sentinel */ { DataField::Type::BOOLEAN } diff --git a/src/Dialogs/Device/Vega/LoggerParameters.hpp b/src/Dialogs/Device/Vega/LoggerParameters.hpp index 9783ac87789..231e8ec00e0 100644 --- a/src/Dialogs/Device/Vega/LoggerParameters.hpp +++ b/src/Dialogs/Device/Vega/LoggerParameters.hpp @@ -10,14 +10,14 @@ static constexpr VegaParametersWidget::StaticParameter logger_parameters[] = { { DataField::Type::INTEGER, "UTCOffset", N_("UTC offset"), NULL, - NULL, -13, 13, 1, _T("%d"), + NULL, -13, 13, 1, "%d", }, { DataField::Type::BOOLEAN, "IGCLoging", N_("IGC logging"), }, { DataField::Type::INTEGER, "IGCLoggerInterval", N_("Logger interval"), NULL, - NULL, 1, 12, 1, _T("%d"), + NULL, 1, 12, 1, "%d", }, /* sentinel */ diff --git a/src/Dialogs/Device/Vega/MixerParameters.hpp b/src/Dialogs/Device/Vega/MixerParameters.hpp index af93d6bc045..1a54a2c0dc5 100644 --- a/src/Dialogs/Device/Vega/MixerParameters.hpp +++ b/src/Dialogs/Device/Vega/MixerParameters.hpp @@ -11,15 +11,15 @@ VegaParametersWidget::StaticParameter mixer_parameters[] = { { DataField::Type::BOOLEAN, "MuteVarioOnPlay", N_("Mute vario on voice") }, { DataField::Type::BOOLEAN, "MuteVarioOnCom", N_("Mute vario on radio") }, { DataField::Type::INTEGER, "VarioRelativeMuteVol", N_("Vario muting"), - NULL, NULL, 0, 254, 1, _T("%d/255") }, + NULL, NULL, 0, 254, 1, "%d/255" }, { DataField::Type::INTEGER, "VoiceRelativeMuteVol", N_("Voice muting"), - NULL, NULL, 0, 254, 1, _T("%d/255") }, + NULL, NULL, 0, 254, 1, "%d/255" }, { DataField::Type::INTEGER, "MuteComSpkThreshold", N_("Speaker threshold"), - NULL, NULL, 0, 254, 1, _T("%d/255") }, + NULL, NULL, 0, 254, 1, "%d/255" }, { DataField::Type::INTEGER, "MuteComPhnThreshold", N_("Headset threshold"), - NULL, NULL, 0, 254, 1, _T("%d/255") }, + NULL, NULL, 0, 254, 1, "%d/255" }, { DataField::Type::INTEGER, "MinUrgentVolume", N_("Urgent min. volume"), - NULL, NULL, 0, 254, 1, _T("%d/255") }, + NULL, NULL, 0, 254, 1, "%d/255" }, /* sentinel */ { DataField::Type::BOOLEAN } diff --git a/src/Dialogs/Device/Vega/VegaConfigurationDialog.cpp b/src/Dialogs/Device/Vega/VegaConfigurationDialog.cpp index 9d23650e5ab..db0cf785b8d 100644 --- a/src/Dialogs/Device/Vega/VegaConfigurationDialog.cpp +++ b/src/Dialogs/Device/Vega/VegaConfigurationDialog.cpp @@ -26,25 +26,25 @@ #include "Operation/MessageOperationEnvironment.hpp" static const char *const captions[] = { - _T(" 1 Hardware"), - _T(" 2 Calibration"), - _T(" 3 Audio Modes"), - _T(" 4 Deadband"), - _T(" 5 Tones: Cruise Faster"), - _T(" 6 Tones: Cruise Slower"), - _T(" 7 Tones: Cruise in Lift"), - _T(" 8 Tones: Circling, climbing fast"), - _T(" 9 Tones: Circling, climbing slow"), - _T("10 Tones: Circling, descending"), - _T("11 Vario flight logger"), - _T("12 Audio mixer"), - _T("13 FLARM Alerts"), - _T("14 FLARM Identification"), - _T("15 FLARM Repeats"), - _T("16 Alerts"), - _T("17 Airframe Limits"), - _T("18 Audio Schemes"), - _T("19 Display"), + " 1 Hardware", + " 2 Calibration", + " 3 Audio Modes", + " 4 Deadband", + " 5 Tones: Cruise Faster", + " 6 Tones: Cruise Slower", + " 7 Tones: Cruise in Lift", + " 8 Tones: Circling, climbing fast", + " 9 Tones: Circling, climbing slow", + "10 Tones: Circling, descending", + "11 Vario flight logger", + "12 Audio mixer", + "13 FLARM Alerts", + "14 FLARM Identification", + "15 FLARM Repeats", + "16 Alerts", + "17 Airframe Limits", + "18 Audio Schemes", + "19 Display", }; static const char *const audio_pages[] = { @@ -130,7 +130,7 @@ static void SetParametersScheme(PagerWidget &pager, int schemetype) { if(ShowMessageBox(_("Set new audio scheme? Old values will be lost."), - _T("Vega"), + "Vega", MB_YESNO | MB_ICONQUESTION) != IDYES) return; @@ -201,10 +201,10 @@ class VegaSchemeButtonsPage : public RowFormWidget { void Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept override { RowFormWidget::Prepare(parent, rc); - AddButton(_T("Vega"), MakeSetParametersScheme(pager, 0)); - AddButton(_T("Borgelt"), MakeSetParametersScheme(pager, 1)); - AddButton(_T("Cambridge"), MakeSetParametersScheme(pager, 2)); - AddButton(_T("Zander"), MakeSetParametersScheme(pager, 3)); + AddButton("Vega", MakeSetParametersScheme(pager, 0)); + AddButton("Borgelt", MakeSetParametersScheme(pager, 1)); + AddButton("Cambridge", MakeSetParametersScheme(pager, 2)); + AddButton("Zander", MakeSetParametersScheme(pager, 3)); } }; diff --git a/src/Dialogs/Device/Vega/VegaDemoDialog.cpp b/src/Dialogs/Device/Vega/VegaDemoDialog.cpp index 9a656cb9aed..9b129027489 100644 --- a/src/Dialogs/Device/Vega/VegaDemoDialog.cpp +++ b/src/Dialogs/Device/Vega/VegaDemoDialog.cpp @@ -30,7 +30,7 @@ VegaWriteDemo() return; char dbuf[100]; - _stprintf(dbuf, _T("PDVDD,%d,%d"), + _stprintf(dbuf, "PDVDD,%d,%d", iround(VegaDemoW * 10), iround(VegaDemoV * 10)); @@ -80,14 +80,14 @@ VegaDemoWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused { AddFloat(_("TE vario"), _("This produces a fake TE vario gross vertical velocity. It can be used when in circling mode to demonstrate the lift tones. When not in circling mode, set this to a realistic negative value so speed command tones are produced."), - _T("%.1f %s"), _T("%.1f"), + "%.1f %s", "%.1f", Units::ToUserVSpeed(-20), Units::ToUserVSpeed(20), GetUserVerticalSpeedStep(), false, UnitGroup::VERTICAL_SPEED, VegaDemoW, this); AddFloat(_("Airspeed"), _("This produces a fake airspeed. It can be used when not in circling mode to demonstrate the speed command tones."), - _T("%.0f %s"), _T("%.0f"), 0, 200, 2, + "%.0f %s", "%.0f", 0, 200, 2, false, UnitGroup::HORIZONTAL_SPEED, VegaDemoV, this); AddBoolean(_("Circling"), @@ -99,8 +99,8 @@ void dlgVegaDemoShowModal() { PopupOperationEnvironment env; - backend_components->devices->VegaWriteNMEA(_T("PDVSC,S,DemoMode,0"), env); - backend_components->devices->VegaWriteNMEA(_T("PDVSC,S,DemoMode,3"), env); + backend_components->devices->VegaWriteNMEA("PDVSC,S,DemoMode,0", env); + backend_components->devices->VegaWriteNMEA("PDVSC,S,DemoMode,3", env); const DialogLook &look = UIGlobals::GetDialogLook(); TWidgetDialog @@ -111,5 +111,5 @@ dlgVegaDemoShowModal() dialog.ShowModal(); // deactivate demo. - backend_components->devices->VegaWriteNMEA(_T("PDVSC,S,DemoMode,0"), env); + backend_components->devices->VegaWriteNMEA("PDVSC,S,DemoMode,0", env); } diff --git a/src/Dialogs/DownloadFilePicker.cpp b/src/Dialogs/DownloadFilePicker.cpp index 5460097d886..912ad0f275e 100644 --- a/src/Dialogs/DownloadFilePicker.cpp +++ b/src/Dialogs/DownloadFilePicker.cpp @@ -253,7 +253,7 @@ try { FileRepository repository; - const auto path = LocalPath(_T("repository")); + const auto path = LocalPath("repository"); FileLineReaderA reader(path); ParseFileRepository(repository, reader); @@ -322,7 +322,7 @@ DownloadFilePickerWidget::OnDownloadComplete(Path path_relative) noexcept if (name == nullptr) return; - if (name == Path(_T("repository"))) { + if (name == Path("repository")) { const std::lock_guard lock{mutex}; repository_failed = false; repository_modified = true; @@ -339,7 +339,7 @@ DownloadFilePickerWidget::OnDownloadError(Path path_relative, if (name == nullptr) return; - if (name == Path(_T("repository"))) { + if (name == Path("repository")) { const std::lock_guard lock{mutex}; repository_failed = true; repository_error = std::move(error); diff --git a/src/Dialogs/Error.cpp b/src/Dialogs/Error.cpp index 6cce59fef8f..132048640f9 100644 --- a/src/Dialogs/Error.cpp +++ b/src/Dialogs/Error.cpp @@ -19,7 +19,7 @@ ShowError(const char *msg, std::exception_ptr e, const char *caption) noexcept { StaticString<1024> buffer; - buffer.Format(_T("%s\n%s"), msg, + buffer.Format("%s\n%s", msg, UTF8ToWideConverter(GetFullMessage(e).c_str()).c_str()); buffer.CropIncompleteUTF8(); diff --git a/src/Dialogs/FileManager.cpp b/src/Dialogs/FileManager.cpp index 3da9eca4b61..9179fcdc624 100644 --- a/src/Dialogs/FileManager.cpp +++ b/src/Dialogs/FileManager.cpp @@ -325,7 +325,7 @@ try { repository.Clear(); - const auto path = LocalPath(_T("repository")); + const auto path = LocalPath("repository"); FileLineReaderA reader(path); ParseFileRepository(repository, reader); } catch (const std::runtime_error & /* e */) { @@ -425,13 +425,13 @@ ManagedFileListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, if (file.download_status.position < 0) { text = _("Queued"); } else if (file.download_status.size > 0) { - text.Format(_T("%s (%u%%)"), _("Downloading"), + text.Format("%s (%u%%)", _("Downloading"), unsigned(file.download_status.position * 100 / file.download_status.size)); } else { char size[32]; FormatByteSize(size, ARRAY_SIZE(size), file.download_status.position); - text.Format(_T("%s (%s)"), _("Downloading"), size); + text.Format("%s (%s)", _("Downloading"), size); } row_renderer.DrawRightFirstRow(canvas, rc, text); diff --git a/src/Dialogs/HelpDialog.cpp b/src/Dialogs/HelpDialog.cpp index cd65430d9c6..875bc85cf79 100644 --- a/src/Dialogs/HelpDialog.cpp +++ b/src/Dialogs/HelpDialog.cpp @@ -19,7 +19,7 @@ HelpDialog(const char *Caption, const char *HelpText) StaticString<100> full_caption; if (Caption != nullptr) { - full_caption.Format(_T("%s: %s"), prefix, Caption); + full_caption.Format("%s: %s", prefix, Caption); Caption = full_caption.c_str(); } else Caption = prefix; diff --git a/src/Dialogs/KnobTextEntry.cpp b/src/Dialogs/KnobTextEntry.cpp index 80ac0ec8a6f..2df0cb7acee 100644 --- a/src/Dialogs/KnobTextEntry.cpp +++ b/src/Dialogs/KnobTextEntry.cpp @@ -28,7 +28,7 @@ enum Buttons { static constexpr size_t MAX_TEXTENTRY = 40; static constexpr char EntryLetters[] = - _T(" ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.-"); + " ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.-"; static constexpr unsigned MAXENTRYLETTERS = ARRAY_SIZE(EntryLetters) - 1; @@ -198,16 +198,16 @@ class KnobTextEntryWidget final : public WindowWidget { inline void KnobTextEntryWidget::CreateButtons(WidgetDialog &dialog) { - dialog.AddButton(_T("A+"), [this](){ GetWindow().IncrementLetter(); }); + dialog.AddButton("A+", [this](){ GetWindow().IncrementLetter(); }); dialog.AddButtonKey(KEY_UP); - dialog.AddButton(_T("A-"), [this](){ GetWindow().DecrementLetter(); }); + dialog.AddButton("A-", [this](){ GetWindow().DecrementLetter(); }); dialog.AddButtonKey(KEY_DOWN); - dialog.AddSymbolButton(_T("<"), [this](){ GetWindow().MoveCursorLeft(); }); + dialog.AddSymbolButton("<", [this](){ GetWindow().MoveCursorLeft(); }); dialog.AddButtonKey(KEY_LEFT); - dialog.AddSymbolButton(_T(">"), [this](){ GetWindow().MoveCursorRight(); }); + dialog.AddSymbolButton(">", [this](){ GetWindow().MoveCursorRight(); }); dialog.AddButtonKey(KEY_RIGHT); } diff --git a/src/Dialogs/LockScreen.cpp b/src/Dialogs/LockScreen.cpp index 4b2182ab4b6..0db0ec87907 100644 --- a/src/Dialogs/LockScreen.cpp +++ b/src/Dialogs/LockScreen.cpp @@ -44,7 +44,7 @@ ShowLockBox() WindowStyle button_style; - const Button button(client_area, dialog_look.button, _T("U"), button_rc, button_style, + const Button button(client_area, dialog_look.button, "U", button_rc, button_style, [&wf](){ wf.SetModalResult(mrCancel); }); wf.ShowModal(); diff --git a/src/Dialogs/MapItemListDialog.cpp b/src/Dialogs/MapItemListDialog.cpp index 706bcc829c9..9ac0c359728 100644 --- a/src/Dialogs/MapItemListDialog.cpp +++ b/src/Dialogs/MapItemListDialog.cpp @@ -284,11 +284,11 @@ ShowMapItemDialog(const MapItem &item, #endif case MapItem::Type::OVERLAY: - ShowWeatherDialog(_T("overlay")); + ShowWeatherDialog("overlay"); break; case MapItem::Type::RASP: - ShowWeatherDialog(_T("rasp")); + ShowWeatherDialog("rasp"); break; } } diff --git a/src/Dialogs/Plane/PlaneDetailsDialog.cpp b/src/Dialogs/Plane/PlaneDetailsDialog.cpp index 37ef1b7e249..75ea64c2258 100644 --- a/src/Dialogs/Plane/PlaneDetailsDialog.cpp +++ b/src/Dialogs/Plane/PlaneDetailsDialog.cpp @@ -61,7 +61,7 @@ PlaneEditWidget::UpdateCaption() noexcept return; StaticString<128> tmp; - tmp.Format(_T("%s: %s"), _("Plane Details"), GetValueString(REGISTRATION)); + tmp.Format("%s: %s", _("Plane Details"), GetValueString(REGISTRATION)); dialog->SetCaption(tmp); } @@ -71,7 +71,7 @@ PlaneEditWidget::UpdatePolarButton() noexcept const char *caption = _("Polar"); StaticString<64> buffer; if (!plane.polar_name.empty()) { - buffer.Format(_T("%s: %s"), caption, plane.polar_name.c_str()); + buffer.Format("%s: %s", caption, plane.polar_name.c_str()); caption = buffer; } @@ -94,33 +94,33 @@ PlaneEditWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unuse AddButton(_("Polar"), [this](){ PolarButtonClicked(); }); AddText(_("Type"), nullptr, plane.type); AddInteger(_("Handicap"), nullptr, - _T("%u %%"), _T("%u"), + "%u %%", "%u", 50, 150, 1, plane.handicap); AddFloat(_("Wing Area"), nullptr, - _T("%.1f m²"), _T("%.1f"), + "%.1f m²", "%.1f", 0, 40, 0.1, false, plane.wing_area); AddFloat(_("Empty Mass"), _("Net mass of the rigged plane."), - _T("%.0f %s"), _T("%.0f"), + "%.0f %s", "%.0f", 0, 1000, 5, false, UnitGroup::MASS, plane.empty_mass); AddFloat(_("Max. Ballast"), nullptr, - _T("%.0f l"), _T("%.0f"), + "%.0f l", "%.0f", 0, 500, 5, false, plane.max_ballast); AddInteger(_("Dump Time"), nullptr, - _T("%u s"), _T("%u"), + "%u s", "%u", 10, 300, 5, plane.dump_time); AddFloat(_("Max. Cruise Speed"), nullptr, - _T("%.0f %s"), _T("%.0f"), 0, 300, 5, + "%.0f %s", "%.0f", 0, 300, 5, false, UnitGroup::HORIZONTAL_SPEED, plane.max_speed); /* TODO: this should be a select list from https://api.weglide.org/v1/aircraft */ if (CommonInterface::GetComputerSettings().weglide.enabled) - AddInteger(_("WeGlide Type"), nullptr, _T("%d"), _T("%d"), 1, 999, + AddInteger(_("WeGlide Type"), nullptr, "%d", "%d", 1, 999, 1, plane.weglide_glider_type); else AddDummy(); @@ -161,7 +161,7 @@ PlaneEditWidget::PolarButtonClicked() noexcept dlgPlanePolarShowModal(plane); UpdatePolarButton(); - if (plane.polar_name != _T("Custom")) + if (plane.polar_name != "Custom") LoadValue(TYPE, plane.polar_name.c_str()); /* reload attributes that may have been modified */ diff --git a/src/Dialogs/Plane/PlaneListDialog.cpp b/src/Dialogs/Plane/PlaneListDialog.cpp index 0fbcaa96498..7720d61311e 100644 --- a/src/Dialogs/Plane/PlaneListDialog.cpp +++ b/src/Dialogs/Plane/PlaneListDialog.cpp @@ -57,7 +57,7 @@ class PlaneListWidget final void Visit(Path path, Path filename) override { std::string_view name{filename.c_str()}; - RemoveSuffix(name, std::string_view{_T(".xcp")}); + RemoveSuffix(name, std::string_view{".xcp"}); list.emplace_back(name, path); } @@ -106,7 +106,7 @@ PlaneListWidget::UpdateList() noexcept list.clear(); PlaneFileVisitor pfv(list); - VisitDataFiles(_T("*.xcp"), pfv); + VisitDataFiles("*.xcp", pfv); unsigned len = list.size(); @@ -154,7 +154,7 @@ PlaneListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, if (Profile::GetPathIsEqual("PlanePath", list[i].path)) { StaticString<256> buffer; - buffer.Format(_T("%s - %s"), list[i].name.c_str(), _("Active")); + buffer.Format("%s - %s", list[i].name.c_str(), _("Active")); row_renderer.DrawFirstRow(canvas, rc, buffer); } else row_renderer.DrawFirstRow(canvas, rc, list[i].name); @@ -225,7 +225,7 @@ PlaneListWidget::NewClicked() noexcept } StaticString<42> filename(plane.registration); - filename += _T(".xcp"); + filename += ".xcp"; const auto path = LocalPath(filename); @@ -270,7 +270,7 @@ PlaneListWidget::EditClicked(bool copy) noexcept } StaticString<42> filename(plane.registration); - filename += _T(".xcp"); + filename += ".xcp"; if (copy || filename != old_filename) { const auto path = AllocatedPath::Build(old_path.GetParent(), @@ -345,7 +345,7 @@ PlaneListWidget::OnActivateItem(unsigned i) noexcept tmp.Format(_("Activate plane \"%s\"?"), list[i].name.c_str()); - if (ShowMessageBox(tmp, _T(" "), MB_YESNO) == IDYES) + if (ShowMessageBox(tmp, " ", MB_YESNO) == IDYES) LoadWithDialog(i); } diff --git a/src/Dialogs/Plane/PlanePolarDialog.cpp b/src/Dialogs/Plane/PlanePolarDialog.cpp index 5e0a20d2a65..834fdfe7931 100644 --- a/src/Dialogs/Plane/PlanePolarDialog.cpp +++ b/src/Dialogs/Plane/PlanePolarDialog.cpp @@ -112,7 +112,7 @@ PlanePolarWidget::Prepare([[maybe_unused]] ContainerWindow &parent, Add(std::make_unique(plane.polar_shape, listener)); AddFloat(_("Reference Mass"), _("Reference mass of the polar."), - _T("%.0f %s"), _T("%.0f"), + "%.0f %s", "%.0f", 0, 1000, 5, false, UnitGroup::MASS, plane.polar_shape.reference_mass); } @@ -180,7 +180,7 @@ inline void PlanePolarWidget::ImportClicked() noexcept { // let the user select - const auto path = FilePicker(_("Load Polar From File"), _T("*.plr\0")); + const auto path = FilePicker(_("Load Polar From File"), "*.plr\0"); if (path == nullptr) return; @@ -210,7 +210,7 @@ PlanePolarWidget::ImportClicked() noexcept void PlanePolarWidget::OnModified([[maybe_unused]] DataField &df) noexcept { - plane.polar_name = _T("Custom"); + plane.polar_name = "Custom"; UpdatePolarLabel(); UpdateInvalidLabel(); } @@ -219,7 +219,7 @@ bool dlgPlanePolarShowModal(Plane &_plane) noexcept { StaticString<128> caption; - caption.Format(_T("%s: %s"), _("Plane Polar"), _plane.registration.c_str()); + caption.Format("%s: %s", _("Plane Polar"), _plane.registration.c_str()); const DialogLook &look = UIGlobals::GetDialogLook(); TWidgetDialog diff --git a/src/Dialogs/Plane/PolarShapeEditWidget.cpp b/src/Dialogs/Plane/PolarShapeEditWidget.cpp index a5acd5c9c3f..4e59987537b 100644 --- a/src/Dialogs/Plane/PolarShapeEditWidget.cpp +++ b/src/Dialogs/Plane/PolarShapeEditWidget.cpp @@ -130,9 +130,9 @@ PolarShapeEditWidget::Prepare(ContainerWindow &parent, rc.bottom = row_height; for (unsigned i = 0; i < ARRAY_SIZE(points); ++i, rc.left += edit_width, rc.right += edit_width) { - points[i].v = std::make_unique(panel, look, _T(""), + points[i].v = std::make_unique(panel, look, "", rc, 0, style); - DataFieldFloat *df = new DataFieldFloat(_T("%.0f"), _T("%.0f %s"), + DataFieldFloat *df = new DataFieldFloat("%.0f", "%.0f %s", 0, 300, 0, 1, false, listener); points[i].v->SetDataField(df); @@ -166,9 +166,9 @@ PolarShapeEditWidget::Prepare(ContainerWindow &parent, for (unsigned i = 0; i < ARRAY_SIZE(points); ++i, rc.left += edit_width, rc.right += edit_width) { - points[i].w = std::make_unique(panel, look, _T(""), + points[i].w = std::make_unique(panel, look, "", rc, 0, style); - DataFieldFloat *df = new DataFieldFloat(_T("%.2f"), _T("%.2f %s"), + DataFieldFloat *df = new DataFieldFloat("%.2f", "%.2f %s", min, 0, 0, step, false, listener); diff --git a/src/Dialogs/ProfileListDialog.cpp b/src/Dialogs/ProfileListDialog.cpp index 895392dc2b2..d2443041875 100644 --- a/src/Dialogs/ProfileListDialog.cpp +++ b/src/Dialogs/ProfileListDialog.cpp @@ -109,7 +109,7 @@ ProfileListWidget::UpdateList() list.clear(); ProfileFileVisitor pfv(list); - VisitDataFiles(_T("*.prf"), pfv); + VisitDataFiles("*.prf", pfv); unsigned len = list.size(); @@ -173,7 +173,7 @@ ProfileListWidget::NewClicked() StaticString<80> filename; filename = name; - filename += _T(".prf"); + filename += ".prf"; const auto path = LocalPath(filename); if (!File::CreateExclusive(path)) { @@ -240,7 +240,7 @@ ProfileListWidget::CopyClicked() StaticString<80> new_filename; new_filename = new_name; - new_filename += _T(".prf"); + new_filename += ".prf"; const auto new_path = LocalPath(new_filename); diff --git a/src/Dialogs/ReplayDialog.cpp b/src/Dialogs/ReplayDialog.cpp index 5f0d4c0184d..f9cd8f98aae 100644 --- a/src/Dialogs/ReplayDialog.cpp +++ b/src/Dialogs/ReplayDialog.cpp @@ -28,7 +28,7 @@ class ReplayControlWidget final void CreateButtons(WidgetDialog &dialog) noexcept { dialog.AddButton(_("Start"), [this](){ OnStartClicked(); }); dialog.AddButton(_("Stop"), [this](){ OnStopClicked(); }); - dialog.AddButton(_T("+10'"), [this](){ OnFastForwardClicked(); }); + dialog.AddButton("+10'", [this](){ OnFastForwardClicked(); }); } private: @@ -49,13 +49,13 @@ ReplayControlWidget::Prepare([[maybe_unused]] ContainerWindow &parent, AddFile(_("File"), _("Name of file to replay. Can be an IGC file (.igc), a raw NMEA log file (.nmea), or if blank, runs the demo."), {}, - _T("*.nmea\0*.igc\0"), + "*.nmea\0*.igc\0", true); LoadValue(FILE, replay.GetFilename()); AddFloat(_("Rate"), _("Time acceleration of replay. Set to 0 for pause, 1 for normal real-time replay."), - _T("%.0f x"), _T("%.0f"), + "%.0f x", "%.0f", 0, 10, 1, false, replay.GetTimeScale()); GetDataField(RATE).SetOnModified([this]{ replay.SetTimeScale(GetValueFloat(RATE)); diff --git a/src/Dialogs/Settings/Panels/AirspaceConfigPanel.cpp b/src/Dialogs/Settings/Panels/AirspaceConfigPanel.cpp index 1bf60462435..a3c7b6efa3f 100644 --- a/src/Dialogs/Settings/Panels/AirspaceConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/AirspaceConfigPanel.cpp @@ -166,12 +166,12 @@ AirspaceConfigPanel::Prepare(ContainerWindow &parent, AddFloat(_("Clip altitude"), _("For clip airspace mode, this is the altitude below which airspace is displayed."), - _T("%.0f %s"), _T("%.0f"), 0, 20000, 100, false, + "%.0f %s", "%.0f", 0, 20000, 100, false, UnitGroup::ALTITUDE, renderer.clip_altitude); AddFloat(_("Margin"), _("For auto and all below airspace mode, this is the altitude above/below which airspace is included."), - _T("%.0f %s"), _T("%.0f"), 0, 10000, 100, false, + "%.0f %s", "%.0f", 0, 10000, 100, false, UnitGroup::ALTITUDE, computer.warnings.altitude_warning_margin); AddBoolean(_("Warnings"), _("Enable/disable all airspace warnings."), diff --git a/src/Dialogs/Settings/Panels/AudioConfigPanel.cpp b/src/Dialogs/Settings/Panels/AudioConfigPanel.cpp index 9e87ab33893..39b26a32a81 100644 --- a/src/Dialogs/Settings/Panels/AudioConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/AudioConfigPanel.cpp @@ -37,7 +37,7 @@ AudioConfigPanel::Prepare(ContainerWindow &parent, const auto &settings = CommonInterface::GetUISettings().sound; - AddInteger(_("Master Volume"), nullptr, _T("%d %%"), _T("%d"), + AddInteger(_("Master Volume"), nullptr, "%d %%", "%d", 0, VolumeController::GetMaxValue(), 1, settings.master_volume); } diff --git a/src/Dialogs/Settings/Panels/AudioVarioConfigPanel.cpp b/src/Dialogs/Settings/Panels/AudioVarioConfigPanel.cpp index 08aecd6f0e2..5fb5ae5d0a4 100644 --- a/src/Dialogs/Settings/Panels/AudioVarioConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/AudioVarioConfigPanel.cpp @@ -50,8 +50,8 @@ AudioVarioConfigPanel::OnModified([[maybe_unused]] DataField &df) noexcept if (IsDataField(ENABLED, df)) { bool enabled = ((const DataFieldBoolean &)df).GetValue(); // SetEnabled(((const DataFieldBoolean &)df).GetValue()); - ShowMessageBox(enabled ? _T("Audio enabled") : _T("disabled"), - _T("Audio-Enable"), 0); //MB_OK); + ShowMessageBox(enabled ? "Audio enabled" : "disabled", + "Audio-Enable", 0); //MB_OK); } } @@ -70,7 +70,7 @@ AudioVarioConfigPanel::Prepare(ContainerWindow &parent, _("Emulate the sound of an electronic vario."), settings.enabled, this); - AddInteger(_("Volume"), nullptr, _T("%u %%"), _T("%u"), + AddInteger(_("Volume"), nullptr, "%u %%", "%u", 0, 100, 1, settings.volume); AddBoolean(_("Enable Deadband"), @@ -82,19 +82,19 @@ AudioVarioConfigPanel::Prepare(ContainerWindow &parent, AddInteger(_("Min. Frequency"), _("The tone frequency that is played at maximum sink rate."), - _T("%u Hz"), _T("%u"), + "%u Hz", "%u", 50, 3000, 50, settings.min_frequency); SetExpertRow(MIN_FREQUENCY); AddInteger(_("Zero Frequency"), _("The tone frequency that is played at zero climb rate."), - _T("%u Hz"), _T("%u"), + "%u Hz", "%u", 50, 3000, 50, settings.zero_frequency); SetExpertRow(ZERO_FREQUENCY); AddInteger(_("Max. Frequency"), _("The tone frequency that is played at maximum climb rate."), - _T("%u Hz"), _T("%u"), + "%u Hz", "%u", 50, 3000, 50, settings.max_frequency); SetExpertRow(MAX_FREQUENCY); @@ -103,7 +103,7 @@ AudioVarioConfigPanel::Prepare(ContainerWindow &parent, AddFloat(_("Deadband min. lift"), _("Below this lift threshold the vario will start to play sounds if the 'Deadband' feature is enabled."), - _T("%.1f %s"), _T("%.1f"), + "%.1f %s", "%.1f", Units::ToUserVSpeed(-5), 0, GetUserVerticalSpeedStep(), false, UnitGroup::VERTICAL_SPEED, settings.min_dead); @@ -113,7 +113,7 @@ AudioVarioConfigPanel::Prepare(ContainerWindow &parent, AddFloat(_("Deadband max. lift"), _("Above this lift threshold the vario will start to play sounds if the 'Deadband' feature is enabled."), - _T("%.1f %s"), _T("%.1f"), + "%.1f %s", "%.1f", 0, Units::ToUserVSpeed(2), GetUserVerticalSpeedStep(), false, UnitGroup::VERTICAL_SPEED, settings.max_dead); diff --git a/src/Dialogs/Settings/Panels/CloudConfigPanel.cpp b/src/Dialogs/Settings/Panels/CloudConfigPanel.cpp index 3e7d086b861..7039f6a3abd 100644 --- a/src/Dialogs/Settings/Panels/CloudConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/CloudConfigPanel.cpp @@ -60,12 +60,12 @@ CloudConfigPanel::Prepare(ContainerWindow &parent, const auto &settings = CommonInterface::GetComputerSettings().tracking.skylines.cloud; - AddBoolean(_T("XCSoar Cloud"), + AddBoolean("XCSoar Cloud", _("Participate in the XCSoar Cloud field test? This transmits your location, thermal/wave locations and other weather data to our test server."), settings.enabled == TriState::TRUE, this); - AddBoolean(_T("Show thermals"), + AddBoolean("Show thermals", _("Obtain and show thermal locations reported by others."), settings.show_thermals); diff --git a/src/Dialogs/Settings/Panels/GlideComputerConfigPanel.cpp b/src/Dialogs/Settings/Panels/GlideComputerConfigPanel.cpp index 4d8b94d58c5..267f0083ca4 100644 --- a/src/Dialogs/Settings/Panels/GlideComputerConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/GlideComputerConfigPanel.cpp @@ -79,12 +79,12 @@ GlideComputerConfigPanel::Prepare(ContainerWindow &parent, SetExpertRow(EnableExternalTriggerCruise); static constexpr StaticEnumChoice aver_eff_list[] = { - { AverageEffTime::ae15seconds, _T("15 s"), N_("Preferred period for paragliders.") }, - { AverageEffTime::ae30seconds, _T("30 s") }, - { AverageEffTime::ae60seconds, _T("60 s") }, - { AverageEffTime::ae90seconds, _T("90 s"), N_("Preferred period for gliders.") }, - { AverageEffTime::ae2minutes, _T("2 min") }, - { AverageEffTime::ae3minutes, _T("3 min") }, + { AverageEffTime::ae15seconds, "15 s", N_("Preferred period for paragliders.") }, + { AverageEffTime::ae30seconds, "30 s" }, + { AverageEffTime::ae60seconds, "60 s" }, + { AverageEffTime::ae90seconds, "90 s", N_("Preferred period for gliders.") }, + { AverageEffTime::ae2minutes, "2 min" }, + { AverageEffTime::ae3minutes, "3 min" }, nullptr }; diff --git a/src/Dialogs/Settings/Panels/InterfaceConfigPanel.cpp b/src/Dialogs/Settings/Panels/InterfaceConfigPanel.cpp index 08b16af41c2..e0ff4316ae4 100644 --- a/src/Dialogs/Settings/Panels/InterfaceConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/InterfaceConfigPanel.cpp @@ -70,7 +70,7 @@ InterfaceConfigPanel::Prepare(ContainerWindow &parent, AddInteger(_("Text size"), nullptr, - _T("%d %%"), _T("%d"), 75, 200, 5, + "%d %%", "%d", 75, 200, 5, settings.scale); WndProperty *wp_dpi = AddEnum(_("Display Resolution"), @@ -98,7 +98,7 @@ InterfaceConfigPanel::Prepare(ContainerWindow &parent, AddFile(_("Events"), _("The Input Events file defines the menu system and how XCSoar responds to " "button presses and events from external devices."), - ProfileKeys::InputFile, _T("*.xci\0"), FileType::XCI); + ProfileKeys::InputFile, "*.xci\0", FileType::XCI); SetExpertRow(InputFile); #ifdef HAVE_NLS @@ -110,18 +110,18 @@ InterfaceConfigPanel::Prepare(ContainerWindow &parent, if (wp != nullptr) { DataFieldEnum &df = *(DataFieldEnum *)wp->GetDataField(); df.addEnumText(_("Automatic")); - df.addEnumText(_T("English")); + df.addEnumText("English"); for (const BuiltinLanguage *l = language_table; l->resource != nullptr; ++l) { StaticString<100> display_string; - display_string.Format(_T("%s (%s)"), l->name, l->resource); + display_string.Format("%s (%s)", l->name, l->resource); df.addEnumText(l->resource, display_string); } #ifdef HAVE_BUILTIN_LANGUAGES LanguageFileVisitor lfv(df); - VisitDataFiles(_T("*.mo"), lfv); + VisitDataFiles("*.mo", lfv); #endif df.Sort(2); @@ -129,11 +129,11 @@ InterfaceConfigPanel::Prepare(ContainerWindow &parent, auto value_buffer = Profile::GetPath(ProfileKeys::LanguageFile); Path value = value_buffer; if (value == nullptr) - value = Path(_T("")); + value = Path(""); - if (value == Path(_T("none"))) + if (value == Path("none")) df.SetValue(1); - else if (!value.empty() && value != Path(_T("auto"))) { + else if (!value.empty() && value != Path("auto")) { const Path base = value.GetBase(); if (base != nullptr) df.SetValue(base.c_str()); @@ -206,7 +206,7 @@ InterfaceConfigPanel::Save(bool &_changed) noexcept const auto old_value_buffer = Profile::GetPath(ProfileKeys::LanguageFile); Path old_value = old_value_buffer; if (old_value == nullptr) - old_value = Path(_T("")); + old_value = Path(""); auto old_base = old_value.GetBase(); if (old_base == nullptr) @@ -217,11 +217,11 @@ InterfaceConfigPanel::Save(bool &_changed) noexcept switch (df.GetValue()) { case 0: - new_value = new_base = _T("auto"); + new_value = new_base = "auto"; break; case 1: - new_value = new_base = _T("none"); + new_value = new_base = "none"; break; default: diff --git a/src/Dialogs/Settings/Panels/LayoutConfigPanel.cpp b/src/Dialogs/Settings/Panels/LayoutConfigPanel.cpp index d7d02fb3837..10eb67f9961 100644 --- a/src/Dialogs/Settings/Panels/LayoutConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/LayoutConfigPanel.cpp @@ -251,7 +251,7 @@ LayoutConfigPanel::Prepare(ContainerWindow &parent, #endif #ifdef DRAW_MOUSE_CURSOR - AddInteger(_("Cursor zoom"), _("Cursor zoom factor"), _T("%d x"), _T("%d x"), 1, 10, 1, + AddInteger(_("Cursor zoom"), _("Cursor zoom factor"), "%d x", "%d x", 1, 10, 1, (unsigned)ui_settings.display.cursor_size); AddBoolean(_("Invert cursor color"), _("Enable black cursor"), ui_settings.display.invert_cursor_colors); diff --git a/src/Dialogs/Settings/Panels/LoggerConfigPanel.cpp b/src/Dialogs/Settings/Panels/LoggerConfigPanel.cpp index 1c965ec5e97..c7a004c5ec8 100644 --- a/src/Dialogs/Settings/Panels/LoggerConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/LoggerConfigPanel.cpp @@ -60,7 +60,7 @@ LoggerConfigPanel::Prepare(ContainerWindow &parent, AddFloat(_("Crew weight default"), _("Default for all weight loaded to the glider beyond the empty weight and besides " "the water ballast."), - _T("%.0f %s"), _T("%.0f"), + "%.0f %s", "%.0f", 0, 300, 5, false, UnitGroup::MASS, logger.crew_mass_template); diff --git a/src/Dialogs/Settings/Panels/MapDisplayConfigPanel.cpp b/src/Dialogs/Settings/Panels/MapDisplayConfigPanel.cpp index e33994d0c50..b881cdfe3db 100644 --- a/src/Dialogs/Settings/Panels/MapDisplayConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/MapDisplayConfigPanel.cpp @@ -114,13 +114,13 @@ MapDisplayConfigPanel::Prepare(ContainerWindow &parent, AddInteger(_("Glider position offset"), _("Defines the location of the glider drawn on the screen in percent from the screen edge."), - _T("%d %%"), _T("%d"), 10, 50, 5, + "%d %%", "%d", 10, 50, 5, settings_map.glider_screen_position); SetExpertRow(GliderScreenPosition); AddFloat(_("Max. auto zoom distance"), _("The upper limit for auto zoom distance."), - _T("%.0f %s"), _T("%.0f"), 20, 250, 10, false, + "%.0f %s", "%.0f", 20, 250, 10, false, UnitGroup::DISTANCE, settings_map.max_auto_zoom_distance); SetExpertRow(MaxAutoZoomDistance); diff --git a/src/Dialogs/Settings/Panels/PagesConfigPanel.cpp b/src/Dialogs/Settings/Panels/PagesConfigPanel.cpp index 753a3486468..dc89f0a9573 100644 --- a/src/Dialogs/Settings/Panels/PagesConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/PagesConfigPanel.cpp @@ -115,7 +115,7 @@ class PageListWidget } }); - move_up_button = buttons.AddSymbol(_T("^"), [this](){ + move_up_button = buttons.AddSymbol("^", [this](){ const unsigned cursor = GetList().GetCursorIndex(); if (cursor > 0) { std::swap(settings.pages[cursor], settings.pages[cursor - 1]); @@ -123,7 +123,7 @@ class PageListWidget } }); - move_down_button = buttons.AddSymbol(_T("v"), [this](){ + move_down_button = buttons.AddSymbol("v", [this](){ const unsigned n = GetList().GetLength(); const unsigned cursor = GetList().GetCursorIndex(); if (cursor + 1 < n) { @@ -364,14 +364,14 @@ PageListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, } if (value.infobox_config.enabled) { - buffer.AppendFormat(_T(", %s"), _("InfoBoxes")); + buffer.AppendFormat(", %s", _("InfoBoxes")); if (!value.infobox_config.auto_switch && value.infobox_config.panel < InfoBoxSettings::MAX_PANELS) - buffer.AppendFormat(_T(" (%s)"), + buffer.AppendFormat(" (%s)", gettext(info_box_settings.panels[value.infobox_config.panel].name)); else - buffer.AppendFormat(_T(" (%s)"), _("Auto")); + buffer.AppendFormat(" (%s)", _("Auto")); } switch (value.bottom) { @@ -380,7 +380,7 @@ PageListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, break; case PageLayout::Bottom::CROSS_SECTION: - buffer.AppendFormat(_T(", %s"), _("Cross section")); + buffer.AppendFormat(", %s", _("Cross section")); break; case PageLayout::Bottom::MAX: diff --git a/src/Dialogs/Settings/Panels/SafetyFactorsConfigPanel.cpp b/src/Dialogs/Settings/Panels/SafetyFactorsConfigPanel.cpp index 25eb85aabf6..53eb5c20c7b 100644 --- a/src/Dialogs/Settings/Panels/SafetyFactorsConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/SafetyFactorsConfigPanel.cpp @@ -46,13 +46,13 @@ SafetyFactorsConfigPanel::Prepare(ContainerWindow &parent, AddFloat(_("Arrival height"), _("The height above terrain that the glider should arrive at for a safe landing."), - _T("%.0f %s"), _T("%.0f"), + "%.0f %s", "%.0f", 0, 2000, 10, false, UnitGroup::ALTITUDE, task_behaviour.safety_height_arrival); AddFloat(_("Terrain height"), _("The height above terrain that the glider must clear during final glide."), - _T("%.0f %s"), _T("%.0f"), + "%.0f %s", "%.0f", 0, 1000, 10, false, UnitGroup::ALTITUDE, task_behaviour.route_planner.safety_height_terrain); @@ -74,7 +74,7 @@ SafetyFactorsConfigPanel::Prepare(ContainerWindow &parent, _("A permanent polar degradation. " "0% means no degradation, " "50% indicates the glider's sink rate is doubled."), - _T("%.0f %%"), _T("%.0f"), + "%.0f %%", "%.0f", 0, 50, 1, false, (1 - settings_computer.polar.degradation_factor) * 100); SetExpertRow(PolarDegradation); @@ -86,7 +86,7 @@ SafetyFactorsConfigPanel::Prepare(ContainerWindow &parent, AddFloat(_("Safety MC"), _("The MacCready setting used, when safety MC is enabled for reach calculations, in task abort mode and for determining arrival altitude at airfields."), - _T("%.1f %s"), _T("%.1f"), + "%.1f %s", "%.1f", 0, Units::ToUserVSpeed(10), GetUserVerticalSpeedStep(), false, UnitGroup::VERTICAL_SPEED, task_behaviour.safety_mc); SetExpertRow(SafetyMC); @@ -95,7 +95,7 @@ SafetyFactorsConfigPanel::Prepare(ContainerWindow &parent, AddFloat(_("STF risk factor"), _("The STF risk factor reduces the MacCready setting used to calculate speed to fly as the glider gets low, in order to compensate for risk. Set to 0.0 for no compensation, 1.0 scales MC linearly with current height (with reference to height of the maximum climb). If considered, 0.3 is recommended."), - _T("%.1f %s"), _T("%.1f"), + "%.1f %s", "%.1f", 0, 1, 0.1, false, task_behaviour.risk_gamma); SetExpertRow(RiskFactor); diff --git a/src/Dialogs/Settings/Panels/ScoringConfigPanel.cpp b/src/Dialogs/Settings/Panels/ScoringConfigPanel.cpp index 8b9b0b7c207..cf8e6117b6d 100644 --- a/src/Dialogs/Settings/Panels/ScoringConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/ScoringConfigPanel.cpp @@ -55,8 +55,8 @@ ScoringConfigPanel::ShowFAITriangleControls(bool show) } static constexpr StaticEnumChoice fai_triangle_threshold_list[] = { - { FAITriangleSettings::Threshold::FAI, _T("750km (FAI)") }, - { FAITriangleSettings::Threshold::KM500, _T("500km (OLC, DMSt)") }, + { FAITriangleSettings::Threshold::FAI, "750km (FAI)" }, + { FAITriangleSettings::Threshold::KM500, "500km (OLC, DMSt)" }, nullptr }; @@ -83,7 +83,7 @@ ScoringConfigPanel::Prepare([[maybe_unused]] ContainerWindow &parent, N_("A combination of Classic and FAI rules. 30% of the FAI score are added to the Classic score.") }, { Contest::DMST, ContestToString(Contest::DMST), /* German competition, no translation */ - _T("Deutsche Meisterschaft im Streckensegelflug.") }, + "Deutsche Meisterschaft im Streckensegelflug." }, { Contest::XCONTEST, ContestToString(Contest::XCONTEST), N_("PG online contest with different track values: Free flight - 1 km = 1.0 point; " "flat trianlge - 1 km = 1.2 p; FAI triangle - 1 km = 1.4 p.") }, diff --git a/src/Dialogs/Settings/Panels/SiteConfigPanel.cpp b/src/Dialogs/Settings/Panels/SiteConfigPanel.cpp index 602dd17ae11..212c9405f09 100644 --- a/src/Dialogs/Settings/Panels/SiteConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/SiteConfigPanel.cpp @@ -42,14 +42,14 @@ class SiteConfigPanel final : public RowFormWidget { void SiteConfigPanel::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { - WndProperty *wp = Add(_T(""), 0, true); + WndProperty *wp = Add("", 0, true); wp->SetText(GetPrimaryDataPath().c_str()); wp->SetEnabled(false); AddFile(_("Map database"), _("The name of the file (.xcm) containing terrain, topography, and optionally " "waypoints, their details and airspaces."), - ProfileKeys::MapFile, _T("*.xcm\0*.lkm\0"), FileType::MAP); + ProfileKeys::MapFile, "*.xcm\0*.lkm\0", FileType::MAP); AddFile(_("Waypoints"), _("Primary waypoints file. Supported file types are Cambridge/WinPilot files (.dat), " @@ -72,28 +72,28 @@ SiteConfigPanel::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unuse SetExpertRow(WatchedWaypointFile); AddFile(_("Airspaces"), _("The file name of the primary airspace file."), - ProfileKeys::AirspaceFile, _T("*.txt\0*.air\0*.sua\0"), + ProfileKeys::AirspaceFile, "*.txt\0*.air\0*.sua\0", FileType::AIRSPACE); AddFile(_("More airspaces"), _("The file name of the secondary airspace file."), - ProfileKeys::AdditionalAirspaceFile, _T("*.txt\0*.air\0*.sua\0"), + ProfileKeys::AdditionalAirspaceFile, "*.txt\0*.air\0*.sua\0", FileType::AIRSPACE); SetExpertRow(AdditionalAirspaceFile); AddFile(_("Waypoint details"), _("The file may contain extracts from enroute supplements or other contributed " "information about individual waypoints and airfields."), - ProfileKeys::AirfieldFile, _T("*.txt\0"), + ProfileKeys::AirfieldFile, "*.txt\0", FileType::WAYPOINTDETAILS); SetExpertRow(AirfieldFile); AddFile(_("FLARM Device Database"), _("The name of the file containing information about registered FLARM devices."), - ProfileKeys::FlarmFile, _T("*.fln\0"), + ProfileKeys::FlarmFile, "*.fln\0", FileType::FLARMNET); - AddFile(_T("RASP"), nullptr, - ProfileKeys::RaspFile, _T("*-rasp*.dat\0"), + AddFile("RASP", nullptr, + ProfileKeys::RaspFile, "*-rasp*.dat\0", FileType::RASP); } diff --git a/src/Dialogs/Settings/Panels/TaskDefaultsConfigPanel.cpp b/src/Dialogs/Settings/Panels/TaskDefaultsConfigPanel.cpp index a63e59f6d27..0d3c77b1005 100644 --- a/src/Dialogs/Settings/Panels/TaskDefaultsConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/TaskDefaultsConfigPanel.cpp @@ -130,7 +130,7 @@ TaskDefaultsConfigPanel::Prepare(ContainerWindow &parent, task_behaviour.sector_defaults.start_type); AddFloat(Caption_GateWidth, _("Default radius or gate width of the start zone for new tasks."), - _T("%.1f %s"), _T("%.1f"), 0.1, 100, 1.0, true, UnitGroup::DISTANCE, + "%.1f %s", "%.1f", 0.1, 100, 1.0, true, UnitGroup::DISTANCE, task_behaviour.sector_defaults.start_radius); AddSpacer(); @@ -142,7 +142,7 @@ TaskDefaultsConfigPanel::Prepare(ContainerWindow &parent, task_behaviour.sector_defaults.finish_type); AddFloat(Caption_GateWidth, _("Default radius or gate width of the finish zone in new tasks."), - _T("%.1f %s"), _T("%.1f"), 0.1, 100, 1.0, true, UnitGroup::DISTANCE, + "%.1f %s", "%.1f", 0.1, 100, 1.0, true, UnitGroup::DISTANCE, task_behaviour.sector_defaults.finish_radius); AddSpacer(); @@ -152,7 +152,7 @@ TaskDefaultsConfigPanel::Prepare(ContainerWindow &parent, task_behaviour.sector_defaults.turnpoint_type); AddFloat(Caption_Radius, _("Default radius of turnpoint cylinders and sectors in new tasks."), - _T("%.1f %s"), _T("%.1f"), 0.1, 100, 1.0, true, UnitGroup::DISTANCE, + "%.1f %s", "%.1f", 0.1, 100, 1.0, true, UnitGroup::DISTANCE, task_behaviour.sector_defaults.turnpoint_radius); AddSpacer(); diff --git a/src/Dialogs/Settings/Panels/TaskRulesConfigPanel.cpp b/src/Dialogs/Settings/Panels/TaskRulesConfigPanel.cpp index c1617d26246..f99f8f87340 100644 --- a/src/Dialogs/Settings/Panels/TaskRulesConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/TaskRulesConfigPanel.cpp @@ -46,13 +46,13 @@ TaskRulesConfigPanel::Prepare(ContainerWindow &parent, RowFormWidget::Prepare(parent, rc); AddFloat(_("Start max. speed"), _("Maximum speed allowed in start observation zone. Set to 0 for no limit."), - _T("%.0f %s"), _T("%.0f"), 0, 300, 5, false, UnitGroup::HORIZONTAL_SPEED, + "%.0f %s", "%.0f", 0, 300, 5, false, UnitGroup::HORIZONTAL_SPEED, task_behaviour.ordered_defaults.start_constraints.max_speed); SetExpertRow(StartMaxSpeed); AddFloat(_("Start max. speed margin"), _("Maximum speed above maximum start speed to tolerate. Set to 0 for no tolerance."), - _T("%.0f %s"), _T("%.0f"), 0, 300, 5, false, UnitGroup::HORIZONTAL_SPEED, + "%.0f %s", "%.0f", 0, 300, 5, false, UnitGroup::HORIZONTAL_SPEED, task_behaviour.start_margins.max_speed_margin); SetExpertRow(StartMaxSpeedMargin); @@ -62,13 +62,13 @@ TaskRulesConfigPanel::Prepare(ContainerWindow &parent, AddFloat(_("Start max. height"), _("Maximum height based on start height reference (AGL or MSL) while starting the task. " "Set to 0 for no limit."), - _T("%.0f %s"), _T("%.0f"), 0, 10000, 50, false, UnitGroup::ALTITUDE, + "%.0f %s", "%.0f", 0, 10000, 50, false, UnitGroup::ALTITUDE, task_behaviour.ordered_defaults.start_constraints.max_height); SetExpertRow(StartMaxHeight); AddFloat(_("Start max. height margin"), _("Maximum height above maximum start height to tolerate. Set to 0 for no tolerance."), - _T("%.0f %s"), _T("%.0f"), 0, 10000, 50, false, UnitGroup::ALTITUDE, + "%.0f %s", "%.0f", 0, 10000, 50, false, UnitGroup::ALTITUDE, task_behaviour.start_margins.max_height_margin); SetExpertRow(StartMaxHeightMargin); @@ -92,7 +92,7 @@ TaskRulesConfigPanel::Prepare(ContainerWindow &parent, AddFloat(_("Finish min. height"), _("Minimum height based on finish height reference (AGL or MSL) while finishing the task. " "Set to 0 for no limit."), - _T("%.0f %s"), _T("%.0f"), 0, 10000, 50, false, UnitGroup::ALTITUDE, + "%.0f %s", "%.0f", 0, 10000, 50, false, UnitGroup::ALTITUDE, task_behaviour.ordered_defaults.finish_constraints.min_height); SetExpertRow(FinishMinHeight); diff --git a/src/Dialogs/Settings/Panels/TerrainDisplayConfigPanel.cpp b/src/Dialogs/Settings/Panels/TerrainDisplayConfigPanel.cpp index 79c45df67b0..a31139fcbc5 100644 --- a/src/Dialogs/Settings/Panels/TerrainDisplayConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/TerrainDisplayConfigPanel.cpp @@ -227,14 +227,14 @@ TerrainDisplayConfigPanel::Prepare(ContainerWindow &parent, AddInteger(_("Terrain contrast"), _("Defines the amount of Phong shading in the terrain rendering. Use large values to emphasise terrain slope, smaller values if flying in steep mountains."), - _T("%d %%"), _T("%d %%"), 0, 100, 5, + "%d %%", "%d %%", 0, 100, 5, ByteToPercent(terrain.contrast)); GetDataField(TerrainContrast).SetListener(this); SetExpertRow(TerrainContrast); AddInteger(_("Terrain brightness"), _("Defines the brightness (whiteness) of the terrain rendering. This controls the average illumination of the terrain."), - _T("%d %%"), _T("%d %%"), 0, 100, 5, + "%d %%", "%d %%", 0, 100, 5, ByteToPercent(terrain.brightness)); GetDataField(TerrainBrightness).SetListener(this); SetExpertRow(TerrainBrightness); diff --git a/src/Dialogs/Settings/Panels/TrackingConfigPanel.cpp b/src/Dialogs/Settings/Panels/TrackingConfigPanel.cpp index 85caa2d119e..81e322e22a6 100644 --- a/src/Dialogs/Settings/Panels/TrackingConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/TrackingConfigPanel.cpp @@ -130,26 +130,26 @@ TrackingConfigPanel::OnModified(DataField &df) noexcept #if (defined HAVE_SKYLINES_TRACKING || defined HAVE_LIVETRACK24) static constexpr StaticEnumChoice tracking_intervals[] = { - { 1, _T("1 sec") }, - { 2, _T("2 sec") }, - { 3, _T("3 sec") }, - { 5, _T("5 sec") }, - { 10, _T("10 sec") }, - { 15, _T("15 sec") }, - { 20, _T("20 sec") }, - { 30, _T("30 sec") }, - { 45, _T("45 sec") }, - { 60, _T("1 min") }, - { 120, _T("2 min") }, - { 180, _T("3 min") }, - { 300, _T("5 min") }, - { 600, _T("10 min") }, - { 900, _T("15 min") }, - { 1200, _T("20 min") }, - { 1800, _T("30 min") }, - { 2400, _T("40 min") }, - { 3000, _T("50 min") }, - { 3600, _T("60 min") }, + { 1, "1 sec" }, + { 2, "2 sec" }, + { 3, "3 sec" }, + { 5, "5 sec" }, + { 10, "10 sec" }, + { 15, "15 sec" }, + { 20, "20 sec" }, + { 30, "30 sec" }, + { 45, "45 sec" }, + { 60, "1 min" }, + { 120, "2 min" }, + { 180, "3 min" }, + { 300, "5 min" }, + { 600, "10 min" }, + { 900, "15 min" }, + { 1200, "20 min" }, + { 1800, "30 min" }, + { 2400, "40 min" }, + { 3000, "50 min" }, + { 3600, "60 min" }, nullptr, }; @@ -158,9 +158,9 @@ static constexpr StaticEnumChoice tracking_intervals[] = { #ifdef HAVE_LIVETRACK24 static constexpr StaticEnumChoice server_list[] = { - { 0, _T("www.livetrack24.com") }, - { 1, _T("test.livetrack24.com") }, - { 2, _T("livexc.dhv.de") }, + { 0, "www.livetrack24.com" }, + { 1, "test.livetrack24.com" }, + { 2, "livexc.dhv.de" }, nullptr, }; @@ -185,9 +185,9 @@ TrackingConfigPanel::Prepare(ContainerWindow &parent, const PixelRect &rc) noexc RowFormWidget::Prepare(parent, rc); #ifdef HAVE_SKYLINES_TRACKING - AddBoolean(_T("SkyLines"), nullptr, settings.skylines.enabled, this); + AddBoolean("SkyLines", nullptr, settings.skylines.enabled, this); #ifdef HAVE_NET_STATE_ROAMING - AddBoolean(_T("Roaming"), nullptr, settings.skylines.roaming, this); + AddBoolean("Roaming", nullptr, settings.skylines.roaming, this); #endif AddEnum(_("Tracking Interval"), nullptr, tracking_intervals, FindClosestTrackingInterval(settings.skylines.interval)); @@ -202,10 +202,10 @@ TrackingConfigPanel::Prepare(ContainerWindow &parent, const PixelRect &rc) noexc StaticString<64> buffer; if (settings.skylines.key != 0) - buffer.UnsafeFormat(_T("%llX"), (unsigned long long)settings.skylines.key); + buffer.UnsafeFormat("%llX", (unsigned long long)settings.skylines.key); else buffer.clear(); - AddText(_T("Key"), nullptr, buffer); + AddText("Key", nullptr, buffer); #endif #if defined(HAVE_SKYLINES_TRACKING) && defined(HAVE_LIVETRACK24) @@ -213,22 +213,22 @@ TrackingConfigPanel::Prepare(ContainerWindow &parent, const PixelRect &rc) noexc #endif #ifdef HAVE_LIVETRACK24 - AddBoolean(_T("LiveTrack24"), _T(""), settings.livetrack24.enabled, this); + AddBoolean("LiveTrack24", "", settings.livetrack24.enabled, this); AddEnum(_("Tracking Interval"), nullptr, tracking_intervals, FindClosestTrackingInterval(settings.livetrack24.interval)); AddEnum(_("Vehicle Type"), _("Type of vehicle used."), vehicle_type_list, (unsigned) settings.livetrack24.vehicleType); - AddText(_("Vehicle Name"), _T("Name of vehicle used."), + AddText(_("Vehicle Name"), "Name of vehicle used.", settings.livetrack24.vehicle_name); - WndProperty *edit = AddEnum(_("Server"), _T(""), server_list, 0); + WndProperty *edit = AddEnum(_("Server"), "", server_list, 0); ((DataFieldEnum *)edit->GetDataField())->SetValue(settings.livetrack24.server); edit->RefreshDisplay(); - AddText(_("Username"), _T(""), settings.livetrack24.username); - AddPassword(_("Password"), _T(""), settings.livetrack24.password); + AddText(_("Username"), "", settings.livetrack24.username); + AddPassword(_("Password"), "", settings.livetrack24.password); #endif #ifdef HAVE_SKYLINES_TRACKING diff --git a/src/Dialogs/Settings/Panels/UnitsConfigPanel.cpp b/src/Dialogs/Settings/Panels/UnitsConfigPanel.cpp index 722f562edeb..f2aae72d978 100644 --- a/src/Dialogs/Settings/Panels/UnitsConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/UnitsConfigPanel.cpp @@ -121,10 +121,10 @@ UnitsConfigPanel::Prepare(ContainerWindow &parent, SetExpertRow(spacer_1); static constexpr StaticEnumChoice units_speed_list[] = { - { Unit::STATUTE_MILES_PER_HOUR, _T("mph") }, + { Unit::STATUTE_MILES_PER_HOUR, "mph" }, { Unit::KNOTS, N_("knots") }, - { Unit::KILOMETER_PER_HOUR, _T("km/h") }, - { Unit::METER_PER_SECOND, _T("m/s") }, + { Unit::KILOMETER_PER_HOUR, "km/h" }, + { Unit::METER_PER_SECOND, "m/s" }, nullptr }; AddEnum(_("Aircraft/Wind speed"), @@ -135,9 +135,9 @@ UnitsConfigPanel::Prepare(ContainerWindow &parent, SetExpertRow(UnitsSpeed); static constexpr StaticEnumChoice units_distance_list[] = { - { Unit::STATUTE_MILES, _T("sm") }, - { Unit::NAUTICAL_MILES, _T("nm") }, - { Unit::KILOMETER, _T("km") }, + { Unit::STATUTE_MILES, "sm" }, + { Unit::NAUTICAL_MILES, "nm" }, + { Unit::KILOMETER, "km" }, nullptr }; AddEnum(_("Distance"), @@ -149,8 +149,8 @@ UnitsConfigPanel::Prepare(ContainerWindow &parent, static constexpr StaticEnumChoice units_lift_list[] = { { Unit::KNOTS, N_("knots") }, - { Unit::METER_PER_SECOND, _T("m/s") }, - { Unit::FEET_PER_MINUTE, _T("ft/min") }, + { Unit::METER_PER_SECOND, "m/s" }, + { Unit::FEET_PER_MINUTE, "ft/min" }, nullptr }; AddEnum(_("Lift"), _("Units used for vertical speeds (variometer)."), @@ -169,8 +169,8 @@ UnitsConfigPanel::Prepare(ContainerWindow &parent, SetExpertRow(UnitsAltitude); static constexpr StaticEnumChoice units_temperature_list[] = { - { Unit::DEGREES_CELCIUS, _T(DEG "C") }, - { Unit::DEGREES_FAHRENHEIT, _T(DEG "F") }, + { Unit::DEGREES_CELCIUS, DEG "C" }, + { Unit::DEGREES_FAHRENHEIT, DEG "F" }, nullptr }; AddEnum(_("Temperature"), _("Units used for temperature."), @@ -179,10 +179,10 @@ UnitsConfigPanel::Prepare(ContainerWindow &parent, SetExpertRow(UnitsTemperature); static constexpr StaticEnumChoice units_taskspeed_list[] = { - { Unit::STATUTE_MILES_PER_HOUR, _T("mph") }, + { Unit::STATUTE_MILES_PER_HOUR, "mph" }, { Unit::KNOTS, N_("knots") }, - { Unit::KILOMETER_PER_HOUR, _T("km/h") }, - { Unit::METER_PER_SECOND, _T("m/s") }, + { Unit::KILOMETER_PER_HOUR, "km/h" }, + { Unit::METER_PER_SECOND, "m/s" }, nullptr }; AddEnum(_("Task speed"), _("Units used for task speeds."), @@ -191,9 +191,9 @@ UnitsConfigPanel::Prepare(ContainerWindow &parent, SetExpertRow(UnitsTaskSpeed); static constexpr StaticEnumChoice pressure_labels_list[] = { - { Unit::HECTOPASCAL, _T("hPa") }, - { Unit::MILLIBAR, _T("mb") }, - { Unit::INCH_MERCURY, _T("inHg") }, + { Unit::HECTOPASCAL, "hPa" }, + { Unit::MILLIBAR, "mb" }, + { Unit::INCH_MERCURY, "inHg" }, nullptr }; AddEnum(_("Pressure"), _("Units used for pressures."), @@ -202,8 +202,8 @@ UnitsConfigPanel::Prepare(ContainerWindow &parent, SetExpertRow(UnitsPressure); static constexpr StaticEnumChoice mass_labels_list[] = { - { Unit::KG, _T("kg") }, - { Unit::LB, _T("lb") }, + { Unit::KG, "kg" }, + { Unit::LB, "lb" }, nullptr }; AddEnum(_("Mass"), _("Units used for mass."), @@ -212,8 +212,8 @@ UnitsConfigPanel::Prepare(ContainerWindow &parent, SetExpertRow(UnitsMass); static constexpr StaticEnumChoice wing_loading_labels_list[] = { - { Unit::KG_PER_M2, _T("kg/m²") }, - { Unit::LB_PER_FT2, _T("lb/ft²") }, + { Unit::KG_PER_M2, "kg/m²" }, + { Unit::LB_PER_FT2, "lb/ft²" }, nullptr }; AddEnum(_("Wing loading"), _("Units used for wing loading."), @@ -225,11 +225,11 @@ UnitsConfigPanel::Prepare(ContainerWindow &parent, SetExpertRow(spacer_2); static constexpr StaticEnumChoice units_lat_lon_list[] = { - { CoordinateFormat::DDMMSS, _T("DDMMSS") }, - { CoordinateFormat::DDMMSS_S, _T("DDMMSS.s") }, - { CoordinateFormat::DDMM_MMM, _T("DDMM.mmm") }, - { CoordinateFormat::DD_DDDDD, _T("DD.ddddd") }, - { CoordinateFormat::UTM, _T("UTM") }, + { CoordinateFormat::DDMMSS, "DDMMSS" }, + { CoordinateFormat::DDMMSS_S, "DDMMSS.s" }, + { CoordinateFormat::DDMM_MMM, "DDMM.mmm" }, + { CoordinateFormat::DD_DDDDD, "DD.ddddd" }, + { CoordinateFormat::UTM, "UTM" }, nullptr }; AddEnum(_("Lat./Lon."), _("Units used for latitude and longitude."), @@ -238,8 +238,8 @@ UnitsConfigPanel::Prepare(ContainerWindow &parent, SetExpertRow(UnitsLatLon); static constexpr StaticEnumChoice rotation_labels_list[] = { - { Unit::HZ, _T("Hz") }, - { Unit::RPM, _T("rpm") }, + { Unit::HZ, "Hz" }, + { Unit::RPM, "rpm" }, nullptr }; AddEnum(_("Rotation"), _("Unit used for rotation."), diff --git a/src/Dialogs/Settings/Panels/WaypointDisplayConfigPanel.cpp b/src/Dialogs/Settings/Panels/WaypointDisplayConfigPanel.cpp index 8c39f1aefa8..622db6a8faf 100644 --- a/src/Dialogs/Settings/Panels/WaypointDisplayConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/WaypointDisplayConfigPanel.cpp @@ -176,7 +176,7 @@ WaypointDisplayConfigPanel::Prepare(ContainerWindow &parent, AddInteger(_("Landable size"), _("A percentage to select the size landables are displayed on the map."), - _T("%u %%"), _T("%u"), 50, 200, 10, settings.landable_rendering_scale); + "%u %%", "%u", 50, 200, 10, settings.landable_rendering_scale); SetExpertRow(AppLandableRenderingScale); AddBoolean(_("Scale runway length"), diff --git a/src/Dialogs/Settings/Panels/WeGlideConfigPanel.cpp b/src/Dialogs/Settings/Panels/WeGlideConfigPanel.cpp index 32ab738b37c..05c5bcb69eb 100644 --- a/src/Dialogs/Settings/Panels/WeGlideConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/WeGlideConfigPanel.cpp @@ -77,7 +77,7 @@ WeGlideConfigPanel::Prepare(ContainerWindow &parent, AddInteger(_("Pilot"), _("Take this from your WeGlide Profile. Or set to 0 if not used."), - _T("%d"), _T("%d"), 1, 99999, 1, weglide.pilot_id); + "%d", "%d", 1, 99999, 1, weglide.pilot_id); AddDate(_("Pilot date of birth"), nullptr, weglide.pilot_birthdate); diff --git a/src/Dialogs/Settings/Panels/WeatherConfigPanel.cpp b/src/Dialogs/Settings/Panels/WeatherConfigPanel.cpp index f3431914ff2..3bc22f63dac 100644 --- a/src/Dialogs/Settings/Panels/WeatherConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/WeatherConfigPanel.cpp @@ -48,22 +48,22 @@ WeatherConfigPanel::Prepare(ContainerWindow &parent, RowFormWidget::Prepare(parent, rc); #ifdef HAVE_PCMET - AddText(_T("pc_met Username"), _T(""), + AddText("pc_met Username", "", settings.pcmet.www_credentials.username); - AddPassword(_T("pc_met Password"), _T(""), + AddPassword("pc_met Password", "", settings.pcmet.www_credentials.password); #if 0 // code disabled because DWD has terminated our access */ - AddText(_T("pc_met FTP Username"), _T(""), + AddText("pc_met FTP Username", "", settings.pcmet.ftp_credentials.username); - AddPassword(_T("pc_met FTP Password"), _T(""), + AddPassword("pc_met FTP Password", "", settings.pcmet.ftp_credentials.password); #endif #endif #ifdef HAVE_HTTP - AddBoolean(_T("Thermal Information Map"), + AddBoolean("Thermal Information Map", _("Show thermal locations downloaded from Thermal Information Map (thermalmap.info)."), settings.enable_tim); #endif diff --git a/src/Dialogs/Settings/WindSettingsPanel.cpp b/src/Dialogs/Settings/WindSettingsPanel.cpp index 332d1d44f97..a40de94f1aa 100644 --- a/src/Dialogs/Settings/WindSettingsPanel.cpp +++ b/src/Dialogs/Settings/WindSettingsPanel.cpp @@ -65,7 +65,7 @@ WindSettingsPanel::Prepare(ContainerWindow &parent, WndProperty *wp = AddFloat(_("Speed"), _("Manual adjustment of wind speed."), - _T("%.0f %s"), _T("%.0f"), + "%.0f %s", "%.0f", 0, Units::ToUserWindSpeed(Units::ToSysUnit(200, Unit::KILOMETER_PER_HOUR)), diff --git a/src/Dialogs/Settings/dlgBasicSettings.cpp b/src/Dialogs/Settings/dlgBasicSettings.cpp index 05311877060..5e3a5f100c9 100644 --- a/src/Dialogs/Settings/dlgBasicSettings.cpp +++ b/src/Dialogs/Settings/dlgBasicSettings.cpp @@ -264,7 +264,7 @@ FlightSetupPanel::Prepare(ContainerWindow &parent, AddFloat(_("Crew"), _("All masses loaded to the glider beyond the empty weight including pilot and copilot, but not water ballast."), - _T("%.0f %s"), _T("%.0f"), + "%.0f %s", "%.0f", 0, 300, 5, false, UnitGroup::MASS, polar_settings.glide_polar_task.GetCrewMass(), this); @@ -272,12 +272,12 @@ FlightSetupPanel::Prepare(ContainerWindow &parent, const double db = 5; AddFloat(_("Ballast"), _("Ballast of the glider. Press \"Dump/Stop\" to toggle count-down of the ballast volume according to the dump rate specified in the configuration settings."), - _T("%.0f l"), _T("%.0f"), + "%.0f l", "%.0f", 0, db*ceil(plane.max_ballast/db), db, false, 0, this); WndProperty *wing_loading = AddFloat(_("Wing loading"), nullptr, - _T("%.1f %s"), _T("%.0f"), 0, + "%.1f %s", "%.0f", 0, 300, 5, false, UnitGroup::WING_LOADING, 0); @@ -286,7 +286,7 @@ FlightSetupPanel::Prepare(ContainerWindow &parent, AddFloat(_("Bugs"), /* xgettext:no-c-format */ _("How clean the glider is. Set to 0% for clean, larger numbers as the wings " "pick up bugs or gets wet. 50% indicates the glider's sink rate is doubled."), - _T("%.0f %%"), _T("%.0f"), + "%.0f %%", "%.0f", 0, 50, 1, false, (1 - polar_settings.bugs) * 100, this); @@ -305,12 +305,12 @@ FlightSetupPanel::Prepare(ContainerWindow &parent, wp->RefreshDisplay(); } - AddReadOnly(_("Altitude"), NULL, _T("%.0f %s"), + AddReadOnly(_("Altitude"), NULL, "%.0f %s", UnitGroup::ALTITUDE, 0); wp = AddFloat(_("Max. temp."), _("Set to forecast ground temperature. Used by convection estimator (temperature trace page of Analysis dialog)"), - _T("%.0f %s"), _T("%.0f"), + "%.0f %s", "%.0f", Temperature::FromCelsius(-50).ToUser(), Temperature::FromCelsius(60).ToUser(), 1, false, @@ -343,7 +343,7 @@ dlgBasicSettingsShowModal() const Plane &plane = CommonInterface::GetComputerSettings().plane; StaticString<128> caption(_("Flight Setup")); - caption.append(_T(" - ")); + caption.append(" - "); caption.append(plane.polar_name); WidgetDialog dialog(WidgetDialog::Auto{}, UIGlobals::GetMainWindow(), diff --git a/src/Dialogs/Settings/dlgConfigInfoboxes.cpp b/src/Dialogs/Settings/dlgConfigInfoboxes.cpp index 483b18280df..1b60028c630 100644 --- a/src/Dialogs/Settings/dlgConfigInfoboxes.cpp +++ b/src/Dialogs/Settings/dlgConfigInfoboxes.cpp @@ -220,7 +220,7 @@ InfoBoxesConfigWidget::Prepare(ContainerWindow &parent, DataFieldEnum *dfe = new DataFieldEnum(this); for (unsigned i = 0; i < layout.info_boxes.count; ++i) { char label[32]; - _stprintf(label, _T("%u"), i + 1); + _stprintf(label, "%u", i + 1); dfe->addEnumText(label, i); } @@ -300,7 +300,7 @@ InfoBoxesConfigWidget::RefreshEditContentDescription() { DataFieldEnum &df = (DataFieldEnum &)GetDataField(CONTENT); WndFrame &description = (WndFrame &)GetRow(DESCRIPTION); - description.SetText(df.GetHelp() != nullptr ? df.GetHelp() : _T("")); + description.SetText(df.GetHelp() != nullptr ? df.GetHelp() : ""); } void diff --git a/src/Dialogs/Settings/dlgConfiguration.cpp b/src/Dialogs/Settings/dlgConfiguration.cpp index 5a07aeeac15..ed0e3a77569 100644 --- a/src/Dialogs/Settings/dlgConfiguration.cpp +++ b/src/Dialogs/Settings/dlgConfiguration.cpp @@ -148,11 +148,11 @@ static constexpr TabMenuPage setup_pages[] = { #ifdef HAVE_TRACKING { N_("Tracking"), CreateTrackingConfigPanel }, #endif - { _T("XCSoar Cloud"), CreateCloudConfigPanel }, + { "XCSoar Cloud", CreateCloudConfigPanel }, #if defined(HAVE_PCMET) || defined(HAVE_HTTP) { N_("Weather"), CreateWeatherConfigPanel }, #endif - { _T("WeGlide"), CreateWeGlideConfigPanel }, + { "WeGlide", CreateWeGlideConfigPanel }, #ifdef HAVE_VOLUME_CONTROLLER { N_("Audio"), CreateAudioConfigPanel }, #endif @@ -285,8 +285,8 @@ class ConfigurationExtraButtons final layout.xcsoar_style, style, [](bool value){ OnXCSoarStyle(value); }); #endif - button2.Create(parent, look.button, _T(""), layout.button2, style); - button1.Create(parent, look.button, _T(""), layout.button1, style); + button2.Create(parent, look.button, "", layout.button2, style); + button1.Create(parent, look.button, "", layout.button1, style); } void Show(const PixelRect &rc) noexcept override { @@ -483,7 +483,7 @@ void dlgConfigurationShowModal() if (ShowMessageBox( _("Changes to configuration saved. Restart OpenSoar " "is needed to apply changes. Do you want restart immediately?"), - _T(""), MB_YESNO | MB_ICONQUESTION) == IDYES) { + "", MB_YESNO | MB_ICONQUESTION) == IDYES) { if (UI::TopWindow::GetExitValue() == 0) UI::TopWindow::SetExitValue(EXIT_RESTART); UIActions::SignalShutdown(true); diff --git a/src/Dialogs/StartupDialog.cpp b/src/Dialogs/StartupDialog.cpp index 9082cb36f46..d91168602ee 100644 --- a/src/Dialogs/StartupDialog.cpp +++ b/src/Dialogs/StartupDialog.cpp @@ -182,7 +182,7 @@ dlgStartupShowModal() noexcept /* scan all profile files */ auto *dff = new FileDataField(); - dff->ScanDirectoryTop(_T("*.prf")); + dff->ScanDirectoryTop("*.prf"); if (dff->GetNumFiles() == 1) { /* skip this dialog if there is only one */ diff --git a/src/Dialogs/StatusPanels/FlightStatusPanel.cpp b/src/Dialogs/StatusPanels/FlightStatusPanel.cpp index 9eeb0ddad81..24e284ac2de 100644 --- a/src/Dialogs/StatusPanels/FlightStatusPanel.cpp +++ b/src/Dialogs/StatusPanels/FlightStatusPanel.cpp @@ -57,9 +57,9 @@ FlightStatusPanel::Refresh() noexcept SetText(Distance, FormatUserDistanceSmart(vec.distance)); } else { - SetText(Near, _T("-")); - SetText(Bearing, _T("-")); - SetText(Distance, _T("-")); + SetText(Near, "-"); + SetText(Bearing, "-"); + SetText(Distance, "-"); } } diff --git a/src/Dialogs/StatusPanels/RulesStatusPanel.cpp b/src/Dialogs/StatusPanels/RulesStatusPanel.cpp index bf6bedfc96d..f651a9a6e96 100644 --- a/src/Dialogs/StatusPanels/RulesStatusPanel.cpp +++ b/src/Dialogs/StatusPanels/RulesStatusPanel.cpp @@ -37,10 +37,10 @@ RulesStatusPanel::Refresh() noexcept /// @todo proper task validity check SetText(ValidStart, start_stats.HasStarted() - ? _("Yes") : _T("No")); + ? _("Yes") : "No"); SetText(ValidFinish, task_stats.task_finished - ? _("Yes") : _T("No")); + ? _("Yes") : "No"); if (start_stats.HasStarted()) { SetText(StartTime, @@ -56,7 +56,7 @@ RulesStatusPanel::Refresh() noexcept ClearValue(StartHeight); } - Temp[0] = _T('\0'); + Temp[0] = '\0'; double finish_height(0); if (backend_components->protected_task_manager) { diff --git a/src/Dialogs/StatusPanels/SystemStatusPanel.cpp b/src/Dialogs/StatusPanels/SystemStatusPanel.cpp index f08254a7a79..01d69d951f7 100644 --- a/src/Dialogs/StatusPanels/SystemStatusPanel.cpp +++ b/src/Dialogs/StatusPanels/SystemStatusPanel.cpp @@ -66,7 +66,7 @@ SystemStatusPanel::Refresh() noexcept ClearText(NumSat); else if (gps.satellites_used_available) { // known number of sats - Temp.Format(_T("%u"), gps.satellites_used); + Temp.Format("%u", gps.satellites_used); SetText(NumSat, Temp); } else // valid but unknown number of sats @@ -82,9 +82,9 @@ SystemStatusPanel::Refresh() noexcept if (basic.flarm.version.available && !basic.flarm.version.software_version.empty()) { /* append FLARM firmware version */ - Temp.append(_T(" (fw ")); + Temp.append(" (fw "); Temp.UnsafeAppendASCII(basic.flarm.version.software_version.c_str()); - Temp.push_back(_T(')')); + Temp.push_back(')'); } SetText(FLARM, Temp); @@ -98,13 +98,13 @@ SystemStatusPanel::Refresh() noexcept #ifdef HAVE_BATTERY const auto &battery = Power::global_info.battery; if (battery.remaining_percent) { - Temp.Format(_T("%u %% "), *battery.remaining_percent); + Temp.Format("%u %% ", *battery.remaining_percent); } #endif if (basic.voltage_available) - Temp.AppendFormat(_T("%.1f V"), (double)basic.voltage); + Temp.AppendFormat("%.1f V", (double)basic.voltage); else if (basic.battery_level_available) - Temp.AppendFormat(_T("%.0f%%"), (double)basic.battery_level); + Temp.AppendFormat("%.0f%%", (double)basic.battery_level); SetText(Battery, Temp); @@ -118,7 +118,7 @@ SystemStatusPanel::Prepare([[maybe_unused]] ContainerWindow &parent, AddReadOnly(_("GPS lock")); AddReadOnly(_("Satellites in view")); AddReadOnly(_("Variometer")); - AddReadOnly(_T("FLARM")); + AddReadOnly("FLARM"); AddReadOnly(_("Logger")); AddReadOnly(_("Supply voltage")); AddReadOnly(_("Network")); diff --git a/src/Dialogs/StatusPanels/TaskStatusPanel.cpp b/src/Dialogs/StatusPanels/TaskStatusPanel.cpp index b159bfd208c..c43918f5501 100644 --- a/src/Dialogs/StatusPanels/TaskStatusPanel.cpp +++ b/src/Dialogs/StatusPanels/TaskStatusPanel.cpp @@ -130,7 +130,7 @@ TaskStatusPanel::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unuse _("Adjusts MC value used in the calculator. " "Use this to determine the effect on estimated task time due to changes in conditions. " "This value will not affect the main computer's setting if the dialog is exited with the Cancel button."), - _T("%.1f %s"), _T("%.1f"), + "%.1f %s", "%.1f", 0, Units::ToUserVSpeed(5), GetUserVerticalSpeedStep(), false, 0, this); @@ -140,21 +140,21 @@ TaskStatusPanel::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unuse AddReadOnly(_("AAT range"), /* xgettext:no-c-format */ _("For AAT tasks, this value tells you how far based on the targets of your task you will fly relative to the minimum and maximum possible tasks. -100% indicates the minimum AAT distance. 0% is the nominal AAT distance. +100% is maximum AAT distance."), - _T("%.0f %%"), 0); + "%.0f %%", 0); - AddReadOnly(_("Speed remaining"), nullptr, _T("%.0f %s"), + AddReadOnly(_("Speed remaining"), nullptr, "%.0f %s", UnitGroup::TASK_SPEED, 0); - AddReadOnly(_("Achieved MacCready"), nullptr, _T("%.1f %s"), + AddReadOnly(_("Achieved MacCready"), nullptr, "%.1f %s", UnitGroup::VERTICAL_SPEED, 0); DataFieldFloat &emc_df = (DataFieldFloat &)GetDataField(EFFECTIVE_MC); emc_df.SetFormat(GetUserVerticalSpeedFormat(false, false)); - AddReadOnly(_("Achieved speed"), nullptr, _T("%.0f %s"), + AddReadOnly(_("Achieved speed"), nullptr, "%.0f %s", UnitGroup::TASK_SPEED, 0); AddReadOnly(_("Cruise efficiency"), _("Efficiency of cruise. 100 indicates perfect MacCready performance, greater than 100 indicates better than MacCready performance is achieved through flying in streets. Less than 100 is appropriate if you fly considerably off-track. This value estimates your cruise efficiency according to the current flight history with the set MC value. Calculation begins after task is started."), - _T("%.0f %%"), + "%.0f %%", 0); } diff --git a/src/Dialogs/StatusPanels/TimesStatusPanel.cpp b/src/Dialogs/StatusPanels/TimesStatusPanel.cpp index deca43d0915..14925d202b5 100644 --- a/src/Dialogs/StatusPanels/TimesStatusPanel.cpp +++ b/src/Dialogs/StatusPanels/TimesStatusPanel.cpp @@ -37,7 +37,7 @@ TimesStatusPanel::Refresh() noexcept const unsigned sunsethours = (int)sun.time_of_sunset; const unsigned sunsetmins = (int)((sun.time_of_sunset - double(sunsethours)) * 60); - temp.Format(_T("%02u:%02u - %02u:%02u"), sunrisehours, sunrisemins, sunsethours, sunsetmins); + temp.Format("%02u:%02u - %02u:%02u", sunrisehours, sunrisemins, sunsethours, sunsetmins); SetText(Daylight, temp); } else { ClearText(Daylight); @@ -53,7 +53,7 @@ TimesStatusPanel::Refresh() noexcept } if (basic.date_time_utc.IsDatePlausible()) { - temp.Format(_T("%04d-%02d-%02d"), basic.date_time_utc.year, + temp.Format("%04d-%02d-%02d", basic.date_time_utc.year, basic.date_time_utc.month, basic.date_time_utc.day); SetText(UTCDate, temp); } else { diff --git a/src/Dialogs/Task/Manager/TaskEditPanel.cpp b/src/Dialogs/Task/Manager/TaskEditPanel.cpp index 884bcc2be0e..dc6f6f32153 100644 --- a/src/Dialogs/Task/Manager/TaskEditPanel.cpp +++ b/src/Dialogs/Task/Manager/TaskEditPanel.cpp @@ -112,9 +112,9 @@ TaskEditPanel::CreateButtons(ButtonPanel &buttons) noexcept [this](){ OnEditTurnpointClicked(); }); mutate_button = buttons.Add(_("Make Finish"), [this](){ OnMakeFinish(); }); - down_button = buttons.Add(std::make_unique(buttons.GetLook(), _T("v")), + down_button = buttons.Add(std::make_unique(buttons.GetLook(), "v"), [this](){ MoveDown(); }); - up_button = buttons.Add(std::make_unique(buttons.GetLook(), _T("^")), + up_button = buttons.Add(std::make_unique(buttons.GetLook(), "^"), [this](){ MoveUp(); }); reverse_button = buttons.Add(_("Reverse"), [this](){ ReverseTask(); }); diff --git a/src/Dialogs/Task/Manager/TaskListPanel.cpp b/src/Dialogs/Task/Manager/TaskListPanel.cpp index e155a1455fc..511a5616074 100644 --- a/src/Dialogs/Task/Manager/TaskListPanel.cpp +++ b/src/Dialogs/Task/Manager/TaskListPanel.cpp @@ -146,7 +146,7 @@ TaskListPanel::get_cursor_name() { const unsigned cursor_index = GetList().GetCursorIndex(); if (cursor_index >= task_store.Size()) - return _T(""); + return ""; return task_store.GetName(cursor_index); } @@ -171,7 +171,7 @@ TaskListPanel::RefreshView() dialog.ShowTaskView(ordered_task); if (ordered_task == nullptr) { - summary.SetText(_T("")); + summary.SetText(""); } else { char text[300]; OrderedTaskSummary(ordered_task, text, false); @@ -190,11 +190,11 @@ TaskListPanel::LoadTask() return; StaticString<1024> text; - text.Format(_T("%s\n(%s)"), _("Load the selected task?"), + text.Format("%s\n(%s)", _("Load the selected task?"), get_cursor_name()); if (const auto errors = orig->CheckTask(); !errors.IsEmpty()) { - text.append(_T("\n")); + text.append("\n"); text.append(getTaskValidationErrors(errors)); } @@ -222,7 +222,7 @@ TaskListPanel::DeleteTask() return; const auto path = task_store.GetPath(cursor_index); - if (StringEndsWithIgnoreCase(path.c_str(), _T(".cup"))) { + if (StringEndsWithIgnoreCase(path.c_str(), ".cup")) { ShowMessageBox(_("Can't delete .CUP files"), _("Error"), MB_OK | MB_ICONEXCLAMATION); return; @@ -231,7 +231,7 @@ TaskListPanel::DeleteTask() const char *fname = task_store.GetName(cursor_index); StaticString<1024> text; - text.Format(_T("%s\n(%s)"), _("Delete the selected task?"), fname); + text.Format("%s\n(%s)", _("Delete the selected task?"), fname); if (ShowMessageBox(text.c_str(), _("Task Browser"), MB_YESNO | MB_ICONQUESTION) != IDYES) return; @@ -254,7 +254,7 @@ ClearSuffix(char *p, const char *suffix) if (!StringIsEqualIgnoreCase(q, suffix)) return false; - *q = _T('\0'); + *q = '\0'; return true; } @@ -268,20 +268,20 @@ TaskListPanel::RenameTask() const char *oldname = task_store.GetName(cursor_index); StaticString<40> newname(oldname); - if (ClearSuffix(newname.buffer(), _T(".cup"))) { + if (ClearSuffix(newname.buffer(), ".cup")) { ShowMessageBox(_("Can't rename .CUP files"), _("Rename Error"), MB_ICONEXCLAMATION); return; } - ClearSuffix(newname.buffer(), _T(".tsk")); + ClearSuffix(newname.buffer(), ".tsk"); if (!TextEntryDialog(newname)) return; - newname.append(_T(".tsk")); + newname.append(".tsk"); - const auto tasks_path = MakeLocalPath(_T("tasks")); + const auto tasks_path = MakeLocalPath("tasks"); File::Rename(task_store.GetPath(cursor_index), AllocatedPath::Build(tasks_path, newname)); diff --git a/src/Dialogs/Task/Manager/TaskManagerDialog.cpp b/src/Dialogs/Task/Manager/TaskManagerDialog.cpp index 0c58997be2f..19c76620d68 100644 --- a/src/Dialogs/Task/Manager/TaskManagerDialog.cpp +++ b/src/Dialogs/Task/Manager/TaskManagerDialog.cpp @@ -131,10 +131,10 @@ TaskManagerDialog::UpdateCaption() { StaticString<128> title; if (task->GetName().empty()) - title.Format(_T("%s: %s"), _("Task Manager"), + title.Format("%s: %s", _("Task Manager"), GetButtonCaption(GetCurrentIndex())); else - title.Format(_T("%s: %s - %s"), _("Task Manager"), + title.Format("%s: %s - %s", _("Task Manager"), task->GetName().c_str(), GetButtonCaption(GetCurrentIndex())); dialog.SetCaption(title); diff --git a/src/Dialogs/Task/Manager/TaskPropertiesPanel.cpp b/src/Dialogs/Task/Manager/TaskPropertiesPanel.cpp index cd4180459e2..4bb8035c236 100644 --- a/src/Dialogs/Task/Manager/TaskPropertiesPanel.cpp +++ b/src/Dialogs/Task/Manager/TaskPropertiesPanel.cpp @@ -228,12 +228,12 @@ TaskPropertiesPanel::Prepare([[maybe_unused]] ContainerWindow &parent, AddFloat(_("Start max. speed"), _("Maximum speed allowed in start observation zone. Set to 0 for no limit."), - _T("%.0f %s"), _T("%.0f"), + "%.0f %s", "%.0f", 0, 300, 5, false, 0); AddFloat(_("Start max. height"), _("Maximum height based on start height reference (AGL or MSL) while starting the task. Set to 0 for no limit."), - _T("%.0f %s"), _T("%.0f"), + "%.0f %s", "%.0f", 0, 10000, 25, false, 0); static constexpr StaticEnumChoice altitude_reference_list[] = { @@ -250,7 +250,7 @@ TaskPropertiesPanel::Prepare([[maybe_unused]] ContainerWindow &parent, AddFloat(_("Finish min. height"), _("Minimum height based on finish height reference (AGL or MSL) while finishing the task. Set to 0 for no limit."), - _T("%.0f %s"), _T("%.0f"), + "%.0f %s", "%.0f", 0, 10000, 25, false, 0); AddEnum(_("Finish height ref."), diff --git a/src/Dialogs/Task/Manager/WeGlideTasksPanel.cpp b/src/Dialogs/Task/Manager/WeGlideTasksPanel.cpp index 4dd576a00a2..3a5c5f54471 100644 --- a/src/Dialogs/Task/Manager/WeGlideTasksPanel.cpp +++ b/src/Dialogs/Task/Manager/WeGlideTasksPanel.cpp @@ -167,7 +167,7 @@ WeGlideTasksPanel::ReloadList() noexcept UpdateButtons(); }, [](std::exception_ptr error){ - ShowError(error, _T("Error")); + ShowError(error, "Error"); }); } diff --git a/src/Dialogs/Task/MutateTaskPointDialog.cpp b/src/Dialogs/Task/MutateTaskPointDialog.cpp index 77905b789e1..5bebcb0abbc 100644 --- a/src/Dialogs/Task/MutateTaskPointDialog.cpp +++ b/src/Dialogs/Task/MutateTaskPointDialog.cpp @@ -48,7 +48,7 @@ MutateTaskPointRenderer::OnPaintItem(Canvas &canvas, PixelRect rc, assert(DrawListIndex < point_types.size()); if (point_types[DrawListIndex] == current_type) - rc.left = row_renderer.DrawColumn(canvas, rc, _T("*")); + rc.left = row_renderer.DrawColumn(canvas, rc, "*"); row_renderer.DrawTextRow(canvas, rc, OrderedTaskPointName(point_types[DrawListIndex])); diff --git a/src/Dialogs/Task/OptionalStartsDialog.cpp b/src/Dialogs/Task/OptionalStartsDialog.cpp index 29b43ba2861..4ec018e3a30 100644 --- a/src/Dialogs/Task/OptionalStartsDialog.cpp +++ b/src/Dialogs/Task/OptionalStartsDialog.cpp @@ -119,7 +119,7 @@ OptionStartsWidget::OnPaintItem(Canvas &canvas, PixelRect rc, const OrderedTaskPoint *tp; if (DrawListIndex == 0) { tp = &task.GetPoint(0); - rc.left = row_renderer.DrawColumn(canvas, rc, _T("*")); + rc.left = row_renderer.DrawColumn(canvas, rc, "*"); } else tp = &task.GetOptionalStartPoint(index_optional_starts); diff --git a/src/Dialogs/Task/TargetDialog.cpp b/src/Dialogs/Task/TargetDialog.cpp index 6233a2111aa..0acc2ff8a4b 100644 --- a/src/Dialogs/Task/TargetDialog.cpp +++ b/src/Dialogs/Task/TargetDialog.cpp @@ -343,14 +343,14 @@ TargetWidget::Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept const auto &button_look = UIGlobals::GetDialogLook().button; - name_button.Create(parent, button_look, _T(""), layout.name_button, + name_button.Create(parent, button_look, "", layout.name_button, control_style, [this](){ OnNameClicked(); }); previous_button.Create(parent, layout.previous_button, control_style, - std::make_unique(button_look, _T("<")), + std::make_unique(button_look, "<"), [this](){ OnPrevClicked(); }); next_button.Create(parent, layout.next_button, control_style, - std::make_unique(button_look, _T(">")), + std::make_unique(button_look, ">"), [this](){ OnNextClicked(); }); const unsigned caption_width = ::Layout::Scale(50); @@ -358,14 +358,14 @@ TargetWidget::Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept range.Create(parent, layout.range, _("Distance"), caption_width, control_style); range.SetHelpText(_("For AAT tasks, this setting can be used to adjust the target points within the AAT sectors. Larger values move the target points to produce larger task distances, smaller values move the target points to produce smaller task distances.")); - range.SetDataField(new DataFieldFloat(_T("%.0f"), _T("%.0f %%"), + range.SetDataField(new DataFieldFloat("%.0f", "%.0f %%", -100, 100, 0, 5, false, this)); radial.Create(parent, layout.radial, _("Radial"), caption_width, control_style); radial.SetHelpText(_("For AAT tasks, this setting can be used to adjust the target points within the AAT sectors. Positive values rotate the range line clockwise, negative values rotate the range line counterclockwise.")); - radial.SetDataField(new DataFieldFloat(_T("%.0f"), _T("%.0f" DEG), + radial.SetDataField(new DataFieldFloat("%.0f", "%.0f" DEG, -90, 90, 0, 5, false, this)); @@ -490,7 +490,7 @@ TargetWidget::UpdateNameButton() const OrderedTask &task = lease->GetOrderedTask(); if (target_point < task.TaskSize()) { const OrderedTaskPoint &tp = task.GetTaskPoint(target_point); - buffer.Format(_T("%u: %s"), target_point, + buffer.Format("%u: %s", target_point, tp.GetWaypoint().name.c_str()); } else buffer.clear(); diff --git a/src/Dialogs/Task/TaskPointDialog.cpp b/src/Dialogs/Task/TaskPointDialog.cpp index c637c9db29a..2db19596d23 100644 --- a/src/Dialogs/Task/TaskPointDialog.cpp +++ b/src/Dialogs/Task/TaskPointDialog.cpp @@ -92,11 +92,11 @@ class TaskPointWidget final } void CreateButtons() { - previous_button = dialog.AddSymbolButton(_T("<"), [this](){ + previous_button = dialog.AddSymbolButton("<", [this](){ OnPreviousClicked(); }); - next_button = dialog.AddSymbolButton(_T(">"), [this](){ + next_button = dialog.AddSymbolButton(">", [this](){ OnNextClicked(); }); } @@ -315,7 +315,7 @@ TaskPointWidget::RefreshView() optional_starts.SetCaption(_("Enable Alternate Starts")); else { StaticString<50> tmp; - tmp.Format(_T("%s (%d)"), _("Edit Alternates"), + tmp.Format("%s (%d)", _("Edit Alternates"), ordered_task.GetOptionalStartPointCount()); optional_starts.SetCaption(tmp); } @@ -332,22 +332,22 @@ TaskPointWidget::RefreshView() switch (tp.GetType()) { case TaskPointType::START: type_buffer = _("Start point"); - name_prefix_buffer = _T("Start: "); + name_prefix_buffer = "Start: "; break; case TaskPointType::AST: type_buffer = _("Task point"); - name_prefix_buffer.Format(_T("%d: "), active_index); + name_prefix_buffer.Format("%d: ", active_index); break; case TaskPointType::AAT: type_buffer = _("Assigned area point"); - name_prefix_buffer.Format(_T("%d: "), active_index); + name_prefix_buffer.Format("%d: ", active_index); break; case TaskPointType::FINISH: type_buffer = _("Finish point"); - name_prefix_buffer = _T("Finish: "); + name_prefix_buffer = "Finish: "; break; default: @@ -358,7 +358,7 @@ TaskPointWidget::RefreshView() { StaticString<100> buffer; - buffer.Format(_T("%s %s"), name_prefix_buffer.c_str(), + buffer.Format("%s %s", name_prefix_buffer.c_str(), tp.GetWaypoint().name.c_str()); waypoint_name.SetText(buffer); } diff --git a/src/Dialogs/Task/Widgets/CylinderZoneEditWidget.cpp b/src/Dialogs/Task/Widgets/CylinderZoneEditWidget.cpp index cdc2b56557a..52f76777594 100644 --- a/src/Dialogs/Task/Widgets/CylinderZoneEditWidget.cpp +++ b/src/Dialogs/Task/Widgets/CylinderZoneEditWidget.cpp @@ -21,7 +21,7 @@ CylinderZoneEditWidget::Prepare(ContainerWindow &parent, ObservationZoneEditWidget::Prepare(parent, rc); AddFloat(_("Radius"), _("Radius of the OZ cylinder."), - _T("%.1f %s"), _T("%.1f"), + "%.1f %s", "%.1f", 0.1, 200, 1, true, UnitGroup::DISTANCE, GetObject().GetRadius(), this); diff --git a/src/Dialogs/Task/Widgets/KeyholeZoneEditWidget.cpp b/src/Dialogs/Task/Widgets/KeyholeZoneEditWidget.cpp index 1f20ece946e..f163506d483 100644 --- a/src/Dialogs/Task/Widgets/KeyholeZoneEditWidget.cpp +++ b/src/Dialogs/Task/Widgets/KeyholeZoneEditWidget.cpp @@ -21,13 +21,13 @@ KeyholeZoneEditWidget::Prepare(ContainerWindow &parent, ObservationZoneEditWidget::Prepare(parent, rc); AddFloat(_("Radius"), _("Radius of the OZ sector."), - _T("%.1f %s"), _T("%.1f"), + "%.1f %s", "%.1f", 0.1, 200, 1, true, UnitGroup::DISTANCE, GetObject().GetRadius(), this); AddFloat(_("Inner radius"), _("Inner radius of the OZ sector."), - _T("%.1f %s"), _T("%.1f"), + "%.1f %s", "%.1f", 0.1, 100, 1, true, UnitGroup::DISTANCE, GetObject().GetInnerRadius(), this); diff --git a/src/Dialogs/Task/Widgets/LineSectorZoneEditWidget.cpp b/src/Dialogs/Task/Widgets/LineSectorZoneEditWidget.cpp index 0ad4beef04b..38e0f158ce1 100644 --- a/src/Dialogs/Task/Widgets/LineSectorZoneEditWidget.cpp +++ b/src/Dialogs/Task/Widgets/LineSectorZoneEditWidget.cpp @@ -20,7 +20,7 @@ LineSectorZoneEditWidget::Prepare(ContainerWindow &parent, const PixelRect &rc) ObservationZoneEditWidget::Prepare(parent, rc); AddFloat(_("Gate width"), _("Width of the start/finish gate."), - _T("%.1f %s"), _T("%.1f"), + "%.1f %s", "%.1f", 0.1, 200, 1, true, UnitGroup::DISTANCE, GetObject().GetLength(), this); diff --git a/src/Dialogs/Task/Widgets/SectorZoneEditWidget.cpp b/src/Dialogs/Task/Widgets/SectorZoneEditWidget.cpp index a68094b000d..039d25c3ee7 100644 --- a/src/Dialogs/Task/Widgets/SectorZoneEditWidget.cpp +++ b/src/Dialogs/Task/Widgets/SectorZoneEditWidget.cpp @@ -25,7 +25,7 @@ SectorZoneEditWidget::Prepare(ContainerWindow &parent, const auto shape = GetObject().GetShape(); AddFloat(_("Radius"), _("Radius of the OZ sector."), - _T("%.1f %s"), _T("%.1f"), + "%.1f %s", "%.1f", 0.1, 200, 1, true, UnitGroup::DISTANCE, GetObject().GetRadius(), this); @@ -47,7 +47,7 @@ SectorZoneEditWidget::Prepare(ContainerWindow &parent, const AnnularSectorZone &annulus = (const AnnularSectorZone &)GetObject(); AddFloat(_("Inner radius"), _("Inner radius of the OZ sector."), - _T("%.1f %s"), _T("%.1f"), + "%.1f %s", "%.1f", 0.1, 100, 1, true, UnitGroup::DISTANCE, annulus.GetInnerRadius(), this); diff --git a/src/Dialogs/Task/dlgTaskHelpers.cpp b/src/Dialogs/Task/dlgTaskHelpers.cpp index d80af94b26c..a7e9235c4ed 100644 --- a/src/Dialogs/Task/dlgTaskHelpers.cpp +++ b/src/Dialogs/Task/dlgTaskHelpers.cpp @@ -97,10 +97,10 @@ OrderedTaskSummary(const OrderedTask *task, char *text, bool linebreaks) OrderedTaskFactoryName(task->GetFactoryType())); } else { if (task->HasTargets()) - StringFormatUnsafe(text, _T("%s%s%s%s%.0f %s%s%s %.0f %s%s%s %.0f %s (%s)"), + StringFormatUnsafe(text, "%s%s%s%s%.0f %s%s%s %.0f %s%s%s %.0f %s (%s)", summary_shape, - validation_errors.IsEmpty() ? _T("") : _T(" / "), - validation_errors.IsEmpty() ? _T("") : getTaskValidationErrors(validation_errors), + validation_errors.IsEmpty() ? "" : " / ", + validation_errors.IsEmpty() ? "" : getTaskValidationErrors(validation_errors), linebreak, (double)Units::ToUserDistance(stats.distance_nominal), Units::GetDistanceName(), @@ -114,10 +114,10 @@ OrderedTaskSummary(const OrderedTask *task, char *text, bool linebreaks) Units::GetDistanceName(), OrderedTaskFactoryName(task->GetFactoryType())); else - StringFormatUnsafe(text, _T("%s%s%s%s%s %.0f %s (%s)"), + StringFormatUnsafe(text, "%s%s%s%s%s %.0f %s (%s)", summary_shape, - validation_errors.IsEmpty() ? _T("") : _T(" / "), - validation_errors.IsEmpty() ? _T("") : getTaskValidationErrors(validation_errors), + validation_errors.IsEmpty() ? "" : " / ", + validation_errors.IsEmpty() ? "" : getTaskValidationErrors(validation_errors), linebreak, _("dist."), (double)Units::ToUserDistance(stats.distance_nominal), @@ -132,19 +132,19 @@ OrderedTaskPointLabel(TaskPointType type, const char *name, { switch (type) { case TaskPointType::START: - StringFormatUnsafe(buffer, _T("S: %s"), name); + StringFormatUnsafe(buffer, "S: %s", name); break; case TaskPointType::AST: - StringFormatUnsafe(buffer, _T("T%d: %s"), index, name); + StringFormatUnsafe(buffer, "T%d: %s", index, name); break; case TaskPointType::AAT: - StringFormatUnsafe(buffer, _T("A%d: %s"), index, name); + StringFormatUnsafe(buffer, "A%d: %s", index, name); break; case TaskPointType::FINISH: - StringFormatUnsafe(buffer, _T("F: %s"), name); + StringFormatUnsafe(buffer, "F: %s", name); break; default: @@ -162,19 +162,19 @@ OrderedTaskPointRadiusLabel(const ObservationZonePoint &ozp, char* buffer) case ObservationZone::Shape::SECTOR: case ObservationZone::Shape::ANNULAR_SECTOR: - StringFormatUnsafe(buffer,_T("%s - %s: %.1f%s"), _("Sector"), _("Radius"), + StringFormatUnsafe(buffer,"%s - %s: %.1f%s", _("Sector"), _("Radius"), (double)Units::ToUserDistance(((const SectorZone &)ozp).GetRadius()), Units::GetDistanceName()); return; case ObservationZone::Shape::LINE: - StringFormatUnsafe(buffer,_T("%s - %s: %.1f%s"), _("Line"), _("Gate width"), + StringFormatUnsafe(buffer,"%s - %s: %.1f%s", _("Line"), _("Gate width"), (double)Units::ToUserDistance(((const LineSectorZone &)ozp).GetLength()), Units::GetDistanceName()); return; case ObservationZone::Shape::CYLINDER: - StringFormatUnsafe(buffer,_T("%s - %s: %.1f%s"), _("Cylinder"), _("Radius"), + StringFormatUnsafe(buffer,"%s - %s: %.1f%s", _("Cylinder"), _("Radius"), (double)Units::ToUserDistance(((const CylinderZone &)ozp).GetRadius()), Units::GetDistanceName()); return; @@ -184,7 +184,7 @@ OrderedTaskPointRadiusLabel(const ObservationZonePoint &ozp, char* buffer) return; case ObservationZone::Shape::CUSTOM_KEYHOLE: - StringFormatUnsafe(buffer,_T("%s - %s: %.1f%s"), _("Keyhole"), _("Radius"), + StringFormatUnsafe(buffer,"%s - %s: %.1f%s", _("Keyhole"), _("Radius"), (double)Units::ToUserDistance(((const KeyholeZone &)ozp).GetRadius()), Units::GetDistanceName()); return; @@ -217,13 +217,13 @@ OrderedTaskPointRadiusLabel(const ObservationZonePoint &ozp, char* buffer) bool OrderedTaskSave(OrderedTask &task) { - char fname[69] = _T(""); + char fname[69] = ""; if (!TextEntryDialog(fname, 64, _("Enter a task name"))) return false; - const auto tasks_path = MakeLocalPath(_T("tasks")); + const auto tasks_path = MakeLocalPath("tasks"); - strcat(fname, _T(".tsk")); + strcat(fname, ".tsk"); task.SetName(fname); SaveTask(AllocatedPath::Build(tasks_path, fname), task); return true; diff --git a/src/Dialogs/TouchTextEntry.cpp b/src/Dialogs/TouchTextEntry.cpp index 653360226ed..ecf081aa5cd 100644 --- a/src/Dialogs/TouchTextEntry.cpp +++ b/src/Dialogs/TouchTextEntry.cpp @@ -169,7 +169,7 @@ TouchTextEntry(char *text, size_t width, ? rc.right : clear_left + Layout::Scale(50); - WndProperty _editor(client_area, look, _T(""), + WndProperty _editor(client_area, look, "", { 0, padding, backspace_left - padding, editor_bottom }, 0, WindowStyle()); _editor.SetReadOnly(); @@ -207,7 +207,7 @@ TouchTextEntry(char *text, size_t width, kb = &keyboard; - Button backspace_button(client_area, look.button, _T("<-"), + Button backspace_button(client_area, look.button, "<-", { backspace_left, padding, rc.right - padding, editor_bottom }, button_style, [](){ OnBackspace(); }); diff --git a/src/Dialogs/Tracking/CloudEnableDialog.cpp b/src/Dialogs/Tracking/CloudEnableDialog.cpp index d82989c16d9..6ce9f075508 100644 --- a/src/Dialogs/Tracking/CloudEnableDialog.cpp +++ b/src/Dialogs/Tracking/CloudEnableDialog.cpp @@ -52,7 +52,7 @@ CloudEnableDialog() noexcept "Do you wish to participate in the field test? This means that your position, thermal/wave locations and other weather data will be transmitted to our test server. You can disable it at any time in the \"Tracking\" settings.\n" "Please help us improve XCSoar!"); - int result = ShowMessageBox(msg, _T("XCSoar Cloud"), + int result = ShowMessageBox(msg, "XCSoar Cloud", MB_YESNOCANCEL|MB_ICONQUESTION); switch (result) { diff --git a/src/Dialogs/Traffic/FlarmTrafficDetails.cpp b/src/Dialogs/Traffic/FlarmTrafficDetails.cpp index 1c32b525819..2c0938f879e 100644 --- a/src/Dialogs/Traffic/FlarmTrafficDetails.cpp +++ b/src/Dialogs/Traffic/FlarmTrafficDetails.cpp @@ -158,11 +158,11 @@ FlarmTrafficDetailsWidget::UpdateChanging(const MoreData &basic) if (target_ok) { FormatUserDistanceSmart(target->distance, tmp, true, 20, 1000); char *p = tmp + strlen(tmp); - *p++ = _T(' '); + *p++ = ' '; FormatAngleDelta(p, 20, target->Bearing() - basic.track); value = tmp; } else - value = _T("--"); + value = "--"; SetText(DISTANCE, value); @@ -172,7 +172,7 @@ FlarmTrafficDetailsWidget::UpdateChanging(const MoreData &basic) if (target->altitude_available) { FormatUserAltitude(target->altitude, p); p += strlen(p); - *p++ = _T(' '); + *p++ = ' '; } Angle dir = Angle::FromXY(target->distance, target->relative_altitude); @@ -180,7 +180,7 @@ FlarmTrafficDetailsWidget::UpdateChanging(const MoreData &basic) value = tmp; } else - value = _T("--"); + value = "--"; SetText(ALTITUDE, value); @@ -189,7 +189,7 @@ FlarmTrafficDetailsWidget::UpdateChanging(const MoreData &basic) FormatUserVerticalSpeed(target->climb_rate_avg30s, tmp); value = tmp; } else - value = _T("--"); + value = "--"; SetText(VARIO, value); } @@ -206,7 +206,7 @@ FlarmTrafficDetailsWidget::Update() const char *value; // Set the dialog caption - StringFormatUnsafe(tmp, _T("%s (%s)"), + StringFormatUnsafe(tmp, "%s (%s)", _("FLARM Traffic Details"), target_id.Format(tmp_id)); dialog.SetCaption(tmp); @@ -219,9 +219,9 @@ FlarmTrafficDetailsWidget::Update() // Fill the frequency field if (!StringIsEmpty(record->frequency)) - value = UnsafeBuildString(tmp, record->frequency.c_str(), _T(" MHz")); + value = UnsafeBuildString(tmp, record->frequency.c_str(), " MHz"); else - value = _T("--"); + value = "--"; SetText(RADIO, value); // Fill the home airfield field @@ -231,13 +231,13 @@ FlarmTrafficDetailsWidget::Update() SetText(PLANE, record->plane_type); } else { // Fill the pilot name field - SetText(PILOT, _T("--")); + SetText(PILOT, "--"); // Fill the frequency field - SetText(RADIO, _T("--")); + SetText(RADIO, "--"); // Fill the home airfield field - SetText(AIRPORT, _T("--")); + SetText(AIRPORT, "--"); // Fill the plane type field const FlarmTraffic* target = @@ -246,7 +246,7 @@ FlarmTrafficDetailsWidget::Update() const char* actype; if (target == nullptr || (actype = FlarmTraffic::GetTypeString(target->type)) == nullptr) - actype = _T("--"); + actype = "--"; SetText(PLANE, actype); } @@ -260,13 +260,13 @@ FlarmTrafficDetailsWidget::Update() BasicStringBuilder builder(tmp, ARRAY_SIZE(tmp)); builder.Append(cs); if (record) - builder.Append(_T(" ("), record->registration.c_str(), _T(")")); + builder.Append(" (", record->registration.c_str(), ")"); value = tmp; } catch (BasicStringBuilder::Overflow) { value = cs; } } else - value = _T("--"); + value = "--"; SetText(CALLSIGN, value); // Update the frequently changing fields too diff --git a/src/Dialogs/Traffic/TeamCodeDialog.cpp b/src/Dialogs/Traffic/TeamCodeDialog.cpp index 292109179bb..65226e6a0cf 100644 --- a/src/Dialogs/Traffic/TeamCodeDialog.cpp +++ b/src/Dialogs/Traffic/TeamCodeDialog.cpp @@ -105,7 +105,7 @@ TeamCodeWidget::Update(const MoreData &basic, const DerivedInfo &calculated) SetText(RELATIVE_BEARING, teamcode_info.teammate_available && basic.track_available ? FormatAngleDelta(teamcode_info.teammate_vector.bearing - basic.track).c_str() - : _T("---")); + : "---"); if (teamcode_info.teammate_available) { SetText(BEARING, @@ -120,7 +120,7 @@ TeamCodeWidget::Update(const MoreData &basic, const DerivedInfo &calculated) SetText(FLARM_LOCK, settings.team_flarm_id.IsDefined() ? settings.team_flarm_callsign.c_str() - : _T("")); + : ""); } void diff --git a/src/Dialogs/Traffic/TrafficList.cpp b/src/Dialogs/Traffic/TrafficList.cpp index 84c600e048f..bb30fd31861 100644 --- a/src/Dialogs/Traffic/TrafficList.cpp +++ b/src/Dialogs/Traffic/TrafficList.cpp @@ -323,7 +323,7 @@ class TrafficFilterWidget : public RowFormWidget { void Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept override { - PrefixDataField *callsign_df = new PrefixDataField(_T(""), listener); + PrefixDataField *callsign_df = new PrefixDataField("", listener); Add(_("Competition ID"), nullptr, callsign_df); } }; @@ -589,21 +589,21 @@ TrafficListWidget::OnPaintItem(Canvas &canvas, PixelRect rc, if (item.IsFlarm()) { if (record != nullptr) - tmp.Format(_T("%s - %s - %s"), + tmp.Format("%s - %s - %s", callsign, record->registration.c_str(), tmp_id); else if (callsign != nullptr) - tmp.Format(_T("%s - %s"), callsign, tmp_id); + tmp.Format("%s - %s", callsign, tmp_id); else - tmp.Format(_T("%s"), tmp_id); + tmp.Format("%s", tmp_id); #ifdef HAVE_SKYLINES_TRACKING } else if (item.IsSkyLines()) { if (!item.name.empty()) tmp = item.name.c_str(); else - tmp.UnsafeFormat(_T("SkyLines %u"), item.skylines_id); + tmp.UnsafeFormat("SkyLines %u", item.skylines_id); #endif } else { - tmp = _T("?"); + tmp = "?"; } if (item.color != FlarmColor::NONE) { @@ -656,14 +656,14 @@ TrafficListWidget::OnPaintItem(Canvas &canvas, PixelRect rc, if (!record->plane_type.empty()) { if (!tmp.empty()) - tmp.append(_T(" - ")); + tmp.append(" - "); tmp.append(record->plane_type); } if (!record->airfield.empty()) { if (!tmp.empty()) - tmp.append(_T(" - ")); + tmp.append(" - "); tmp.append(record->airfield); } @@ -680,12 +680,12 @@ TrafficListWidget::OnPaintItem(Canvas &canvas, PixelRect rc, tmp.clear(); if (!item.near_name.empty()) - tmp.AppendFormat(_T(" near %s (%s)"), + tmp.AppendFormat(" near %s (%s)", item.near_name.c_str(), FormatUserDistanceSmart(item.near_distance).c_str()); if (!tmp.empty()) - tmp.append(_T("; ")); + tmp.append("; "); tmp.append(FormatUserAltitude(item.altitude).c_str()); if (!tmp.empty()) diff --git a/src/Dialogs/Waypoint/WaypointInfoWidget.cpp b/src/Dialogs/Waypoint/WaypointInfoWidget.cpp index e04854dc106..00acfd105de 100644 --- a/src/Dialogs/Waypoint/WaypointInfoWidget.cpp +++ b/src/Dialogs/Waypoint/WaypointInfoWidget.cpp @@ -90,18 +90,18 @@ WaypointInfoWidget::Prepare(ContainerWindow &parent, if (waypoint->radio_frequency.Format(buffer.buffer(), buffer.capacity()) != nullptr) { - buffer += _T(" MHz"); + buffer += " MHz"; AddReadOnly(_("Radio frequency"), nullptr, buffer); } if (waypoint->runway.IsDirectionDefined()) - buffer.UnsafeFormat(_T("%02u"), waypoint->runway.GetDirectionName()); + buffer.UnsafeFormat("%02u", waypoint->runway.GetDirectionName()); else buffer.clear(); if (waypoint->runway.IsLengthDefined()) { if (!buffer.empty()) - buffer += _T("; "); + buffer += "; "; char length_buffer[16]; FormatSmallUserDistance(length_buffer, waypoint->runway.GetLength()); @@ -121,7 +121,7 @@ WaypointInfoWidget::Prepare(ContainerWindow &parent, if (waypoint->has_elevation) AddReadOnly(_("Elevation"), nullptr, FormatUserAltitude(waypoint->elevation)); else - AddReadOnly(_("Elevation"), nullptr, _T("?")); + AddReadOnly(_("Elevation"), nullptr, "?"); if (basic.time_available && basic.date_time_utc.IsDatePlausible()) { const SunEphemeris::Result sun = @@ -131,7 +131,7 @@ WaypointInfoWidget::Prepare(ContainerWindow &parent, const BrokenTime sunrise = BreakHourOfDay(sun.time_of_sunrise); const BrokenTime sunset = BreakHourOfDay(sun.time_of_sunset); - buffer.UnsafeFormat(_T("%02u:%02u - %02u:%02u"), + buffer.UnsafeFormat("%02u:%02u - %02u:%02u", sunrise.hour, sunrise.minute, sunset.hour, sunset.minute); AddReadOnly(_("Daylight time"), nullptr, buffer); @@ -183,7 +183,7 @@ WaypointInfoWidget::Prepare(ContainerWindow &parent, const auto distance = basic.location.Distance(waypoint->location); const auto gr = distance / delta_h; if (GradientValid(gr)) { - buffer.UnsafeFormat(_T("%.1f"), (double)gr); + buffer.UnsafeFormat("%.1f", (double)gr); AddReadOnly(_("Required glide ratio"), nullptr, buffer); } } diff --git a/src/Dialogs/Waypoint/WaypointList.cpp b/src/Dialogs/Waypoint/WaypointList.cpp index 56bde04d531..b2606ae1a22 100644 --- a/src/Dialogs/Waypoint/WaypointList.cpp +++ b/src/Dialogs/Waypoint/WaypointList.cpp @@ -58,16 +58,16 @@ static constexpr int direction_filter_items[] = { }; static const char *const type_filter_items[] = { - _T("*"), _T("Airport"), _T("Landable"), - _T("Turnpoint"), - _T("Start"), - _T("Finish"), - _T("Left FAI Triangle"), - _T("Right FAI Triangle"), - _T("Custom"), - _T("File 1"), _T("File 2"), - _T("Map file"), - _T("Recently Used"), + "*", "Airport", "Landable", + "Turnpoint", + "Start", + "Finish", + "Left FAI Triangle", + "Right FAI Triangle", + "Custom", + "File 1", "File 2", + "Map file", + "Recently Used", nullptr }; @@ -223,9 +223,9 @@ GetDirectionData(char *buffer, size_t size, int direction_filter_index, Angle heading) { if (direction_filter_index == 0) - return _T("*"); + return "*"; else if (direction_filter_index == 1) - StringFormatUnsafe(buffer, _T("HDG(%s)"), + StringFormatUnsafe(buffer, "HDG(%s)", FormatBearing(heading).c_str()); else FormatBearing(buffer, size, direction_filter_items[direction_filter_index]); @@ -319,7 +319,7 @@ WaypointListWidget::Prepare(ContainerWindow &parent, static DataField * CreateNameDataField(Waypoints &waypoints, DataFieldListener *listener) { - return new PrefixDataField(_T(""), [&waypoints](const char *prefix){ + return new PrefixDataField("", [&waypoints](const char *prefix){ static char buffer[256]; return waypoints.SuggestNamePrefix(prefix, buffer, ARRAY_SIZE(buffer)); }, listener); @@ -329,7 +329,7 @@ static DataField * CreateDistanceDataField(DataFieldListener *listener) { DataFieldEnum *df = new DataFieldEnum(listener); - df->addEnumText(_T("*")); + df->addEnumText("*"); for (unsigned i = 1; i < ARRAY_SIZE(distance_filter_items); i++) { df->addEnumText(FormatUserDistance(Units::ToSysDistance(distance_filter_items[i]))); diff --git a/src/Dialogs/Waypoint/dlgWaypointDetails.cpp b/src/Dialogs/Waypoint/dlgWaypointDetails.cpp index 1fd361e1150..e75202af648 100644 --- a/src/Dialogs/Waypoint/dlgWaypointDetails.cpp +++ b/src/Dialogs/Waypoint/dlgWaypointDetails.cpp @@ -407,19 +407,19 @@ WaypointDetailsWidget::Prepare(ContainerWindow &parent, if (!images.empty()) { magnify_button.Create(parent, layout.magnify_button, button_style, - std::make_unique(look.button, _T("+")), + std::make_unique(look.button, "+"), [this](){ OnMagnifyClicked(); }); shrink_button.Create(parent, layout.shrink_button, button_style, - std::make_unique(look.button, _T("-")), + std::make_unique(look.button, "-"), [this](){ OnShrinkClicked(); }); } previous_button.Create(parent, layout.previous_button, button_style, - std::make_unique(look.button, _T("<")), + std::make_unique(look.button, "<"), [this](){ NextPage(-1); }); next_button.Create(parent, layout.next_button, button_style, - std::make_unique(look.button, _T(">")), + std::make_unique(look.button, ">"), [this](){ NextPage(1); }); close_button.Create(parent, look.button, _("Close"), layout.close_button, @@ -613,7 +613,7 @@ static void UpdateCaption(WndForm *form, const Waypoint &waypoint) { StaticString<256> buffer; - buffer.Format(_T("%s: %s"), _("Waypoint"), waypoint.name.c_str()); + buffer.Format("%s: %s", _("Waypoint"), waypoint.name.c_str()); std::string_view key{}; const char *name = nullptr; @@ -623,7 +623,7 @@ UpdateCaption(WndForm *form, const Waypoint &waypoint) break; case WaypointOrigin::USER: - name = _T("user.cup"); + name = "user.cup"; break; case WaypointOrigin::PRIMARY: @@ -646,9 +646,9 @@ UpdateCaption(WndForm *form, const Waypoint &waypoint) if (!key.empty()) { const auto filename = Profile::map.GetPathBase(key); if (filename != nullptr) - buffer.AppendFormat(_T(" (%s)"), filename.c_str()); + buffer.AppendFormat(" (%s)", filename.c_str()); } else if (name != nullptr) - buffer.AppendFormat(_T(" (%s)"), name); + buffer.AppendFormat(" (%s)", name); form->SetCaption(buffer); } diff --git a/src/Dialogs/Waypoint/dlgWaypointEdit.cpp b/src/Dialogs/Waypoint/dlgWaypointEdit.cpp index 2a224ffd1fe..c97ff7752cb 100644 --- a/src/Dialogs/Waypoint/dlgWaypointEdit.cpp +++ b/src/Dialogs/Waypoint/dlgWaypointEdit.cpp @@ -80,7 +80,7 @@ WaypointEditWidget::Prepare(ContainerWindow &, const PixelRect &) noexcept UIGlobals::GetFormatSettings().coordinate_format, this)); AddFloat(_("Altitude"), nullptr, - _T("%.0f %s"), _T("%.0f"), + "%.0f %s", "%.0f", 0, 30000, 5, false, UnitGroup::ALTITUDE, value.GetElevationOrZero()); AddEnum(_("Type"), nullptr, waypoint_types, (unsigned)value.type); diff --git a/src/Dialogs/Weather/MapOverlayWidget.cpp b/src/Dialogs/Weather/MapOverlayWidget.cpp index 1a1009958c5..9a6060656c3 100644 --- a/src/Dialogs/Weather/MapOverlayWidget.cpp +++ b/src/Dialogs/Weather/MapOverlayWidget.cpp @@ -164,8 +164,8 @@ class WeatherMapOverlayListWidget final void OnPaintItem(Canvas &canvas, PixelRect rc, unsigned i) noexcept override { if (int(i) == active_index) { - rc.left = row_renderer.DrawColumn(canvas, rc, _T(" > ")); - rc.right = row_renderer.DrawRightColumn(canvas, rc, _T(" < ")); + rc.left = row_renderer.DrawColumn(canvas, rc, " > "); + rc.right = row_renderer.DrawRightColumn(canvas, rc, " < "); } TextListWidget::OnPaintItem(canvas, rc, i); @@ -231,10 +231,10 @@ WeatherMapOverlayListWidget::UpdateList() } } visitor(items); - const auto weather_path = LocalPath(_T("weather")); - const auto overlay_path = AllocatedPath::Build(weather_path, _T("overlay")); - Directory::VisitSpecificFiles(overlay_path, _T("*.tif"), visitor); - Directory::VisitSpecificFiles(overlay_path, _T("*.tiff"), visitor); + const auto weather_path = LocalPath("weather"); + const auto overlay_path = AllocatedPath::Build(weather_path, "overlay"); + Directory::VisitSpecificFiles(overlay_path, "*.tif", visitor); + Directory::VisitSpecificFiles(overlay_path, "*.tiff", visitor); const unsigned n = items.size(); @@ -276,7 +276,7 @@ SetupOverlay(MapOverlayBitmap &bmp, Path::const_pointer name) /* configure a default, just in case this overlay type is unknown */ bmp.SetAlpha(0.5); - if (StringStartsWithIgnoreCase(name, _T("nb_"))) { + if (StringStartsWithIgnoreCase(name, "nb_")) { name += 3; /* skip "model", go to "met" */ @@ -284,21 +284,21 @@ SetupOverlay(MapOverlayBitmap &bmp, Path::const_pointer name) if (underscore != nullptr) { name = underscore + 1; - if (StringStartsWithIgnoreCase(name, _T("ome_"))) { + if (StringStartsWithIgnoreCase(name, "ome_")) { /* vertical wind */ bmp.SetAlpha(0.5); - } else if (StringStartsWithIgnoreCase(name, _T("w_"))) { + } else if (StringStartsWithIgnoreCase(name, "w_")) { /* horizontal wind */ bmp.SetAlpha(0.7); } } - } else if (StringStartsWithIgnoreCase(name, _T("sat_"))) { + } else if (StringStartsWithIgnoreCase(name, "sat_")) { bmp.IgnoreBitmapAlpha(); bmp.SetAlpha(0.9); - } else if (StringStartsWithIgnoreCase(name, _T("pg_"))) { + } else if (StringStartsWithIgnoreCase(name, "pg_")) { /* precipitation */ bmp.SetAlpha(0.4); - } else if (StringStartsWithIgnoreCase(name, _T("Vertikalwind"))) { + } else if (StringStartsWithIgnoreCase(name, "Vertikalwind")) { /* name of a draft file I got from DWD */ // TODO: remove obsolete prefix bmp.IgnoreBitmapAlpha(); @@ -364,7 +364,7 @@ WeatherMapOverlayListWidget::UseClicked(unsigned i) item.path = std::move(overlay->path); UpdatePreview(item.path); } catch (...) { - ShowError(std::current_exception(), _T("pc_met")); + ShowError(std::current_exception(), "pc_met"); } } } @@ -399,7 +399,7 @@ WeatherMapOverlayListWidget::UpdateClicked() SetOverlay(overlay->path, info.label.c_str()); item.path = std::move(overlay->path); } catch (...) { - ShowError(std::current_exception(), _T("pc_met")); + ShowError(std::current_exception(), "pc_met"); break; } } diff --git a/src/Dialogs/Weather/NOAADetails.cpp b/src/Dialogs/Weather/NOAADetails.cpp index 49bdd476dbd..a0cee05d934 100644 --- a/src/Dialogs/Weather/NOAADetails.cpp +++ b/src/Dialogs/Weather/NOAADetails.cpp @@ -54,20 +54,20 @@ NOAADetailsWidget::CreateButtons(WidgetDialog &buttons) void NOAADetailsWidget::Update() { - std::string metar_taf = _T(""); + std::string metar_taf = ""; NOAAFormatter::Format(*station_iterator, metar_taf); SetText(metar_taf.c_str()); StaticString<100> caption; - caption.Format(_T("%s: "), _("METAR and TAF")); + caption.Format("%s: ", _("METAR and TAF")); if (!station_iterator->parsed_metar_available || !station_iterator->parsed_metar.name_available) caption += station_iterator->GetCodeT(); else - caption.AppendFormat(_T("%s (%s)"), + caption.AppendFormat("%s (%s)", station_iterator->parsed_metar.name.c_str(), station_iterator->GetCodeT()); diff --git a/src/Dialogs/Weather/NOAAList.cpp b/src/Dialogs/Weather/NOAAList.cpp index c8f9a5d9007..238597cf82b 100644 --- a/src/Dialogs/Weather/NOAAList.cpp +++ b/src/Dialogs/Weather/NOAAList.cpp @@ -158,7 +158,7 @@ UpdateTask(NOAAStore::Item &item, ProgressListener &progress) noexcept inline void NOAAListWidget::AddClicked() { - char code[5] = _T(""); + char code[5] = ""; if (!TextEntryDialog(code, 5, _("Airport ICAO code"))) return; diff --git a/src/Dialogs/Weather/PCMetDialog.cpp b/src/Dialogs/Weather/PCMetDialog.cpp index ffef9932494..9d050ace9ae 100644 --- a/src/Dialogs/Weather/PCMetDialog.cpp +++ b/src/Dialogs/Weather/PCMetDialog.cpp @@ -32,7 +32,7 @@ BitmapDialog(const Bitmap &bitmap) TWidgetDialog dialog(WidgetDialog::Full{}, UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T("pc_met"), new ViewImageWidget(bitmap)); + "pc_met", new ViewImageWidget(bitmap)); dialog.AddButton(_("Close"), mrOK); // dialog.SetWidget(); dialog.ShowModal(); @@ -60,7 +60,7 @@ BitmapDialog(const PCMet::ImageType &type, const PCMet::ImageArea &area) bitmap.LoadFile(*path); BitmapDialog(bitmap); } catch (...) { - ShowError(std::current_exception(), _T("pc_met")); + ShowError(std::current_exception(), "pc_met"); } } @@ -150,7 +150,7 @@ CreatePCMetWidget() const auto &settings = CommonInterface::GetComputerSettings().weather.pcmet; if (!settings.www_credentials.IsDefined()) return std::make_unique(UIGlobals::GetDialogLook(), - _T("No account was configured.")); + "No account was configured."); auto area_widget = std::make_unique(); auto type_widget = std::make_unique(*area_widget); diff --git a/src/Dialogs/Weather/RASPDialog.cpp b/src/Dialogs/Weather/RASPDialog.cpp index 502282e01b0..0f4ef796fb1 100644 --- a/src/Dialogs/Weather/RASPDialog.cpp +++ b/src/Dialogs/Weather/RASPDialog.cpp @@ -52,7 +52,7 @@ RASPSettingsPanel::FillItemControl() noexcept auto &df = (DataFieldEnum &)GetDataField(ITEM); df.ClearChoices(); - df.AddChoice(-1, _T("none"), _T("none"), nullptr); + df.AddChoice(-1, "none", "none", nullptr); for (unsigned i = 0; i < rasp->GetItemCount(); i++) { const auto &mi = rasp->GetItemInfo(i); const char *label = mi.label; @@ -87,7 +87,7 @@ RASPSettingsPanel::UpdateTimeControl() noexcept rasp->ForEachTime(item_index, [&time_df](BrokenTime t){ char timetext[10]; - _stprintf(timetext, _T("%02u:%02u"), t.hour, t.minute); + _stprintf(timetext, "%02u:%02u", t.hour, t.minute); time_df.addEnumText(timetext, t.GetMinuteOfDay()); }); @@ -107,7 +107,7 @@ RASPSettingsPanel::Prepare([[maybe_unused]] ContainerWindow &parent, WndProperty *wp; wp = AddFile(_("File"), nullptr, - ProfileKeys::RaspFile, _T("*-rasp*.dat\0"), + ProfileKeys::RaspFile, "*-rasp*.dat\0", FileType::RASP); wp->GetDataField()->SetOnModified([this]{ if (SaveValueFileReader(FILE, ProfileKeys::RaspFile)) { diff --git a/src/Dialogs/Weather/WeatherDialog.cpp b/src/Dialogs/Weather/WeatherDialog.cpp index 16af2592232..377bbdf1c79 100644 --- a/src/Dialogs/Weather/WeatherDialog.cpp +++ b/src/Dialogs/Weather/WeatherDialog.cpp @@ -23,7 +23,7 @@ static void SetTitle(WndForm &form, const TabWidget &pager) { StaticString<128> title; - title.Format(_T("%s: %s"), _("Weather"), + title.Format("%s: %s", _("Weather"), pager.GetButtonCaption(pager.GetCurrentIndex())); form.SetCaption(title); } @@ -53,22 +53,22 @@ ShowWeatherDialog(const char *page) /* setup tabs */ #ifdef HAVE_NOAA - if (page != nullptr && StringIsEqual(page, _T("list"))) + if (page != nullptr && StringIsEqual(page, "list")) start_page = widget.GetSize(); widget.AddTab(CreateNOAAListWidget(), _("METAR and TAF")); #endif - if (page != nullptr && StringIsEqual(page, _T("rasp"))) + if (page != nullptr && StringIsEqual(page, "rasp")) start_page = widget.GetSize(); - widget.AddTab(CreateRaspWidget(), _T("RASP")); + widget.AddTab(CreateRaspWidget(), "RASP"); #ifdef HAVE_PCMET - if (page != nullptr && StringIsEqual(page, _T("pc_met"))) + if (page != nullptr && StringIsEqual(page, "pc_met")) start_page = widget.GetSize(); - widget.AddTab(CreatePCMetWidget(), _T("pc_met")); + widget.AddTab(CreatePCMetWidget(), "pc_met"); #endif #if 0 @@ -77,11 +77,11 @@ ShowWeatherDialog(const char *page) eventually, we should refactor the code to be generic, allowing arbitrary georeferenced images */ - if (page != nullptr && StringIsEqual(page, _T("overlay"))) + if (page != nullptr && StringIsEqual(page, "overlay")) start_page = widget.GetSize(); // TODO: better and translatable title? - widget.AddTab(CreateWeatherMapOverlayWidget(), _T("Overlay")); + widget.AddTab(CreateWeatherMapOverlayWidget(), "Overlay"); #endif /* restore previous page */ diff --git a/src/Dialogs/dlgAnalysis.cpp b/src/Dialogs/dlgAnalysis.cpp index 7f859b29ed2..5e863381151 100644 --- a/src/Dialogs/dlgAnalysis.cpp +++ b/src/Dialogs/dlgAnalysis.cpp @@ -281,11 +281,11 @@ AnalysisWidget::Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept info.Create(parent, layout.info); const auto &button_look = dialog.GetLook().button; - details_button.Create(parent, button_look, _T("Calc"), layout.details_button, + details_button.Create(parent, button_look, "Calc", layout.details_button, button_style, [this](){ OnCalcClicked(); }); - previous_button.Create(parent, button_look, _T("<"), layout.previous_button, + previous_button.Create(parent, button_look, "<", layout.previous_button, button_style, [this](){ NextPage(-1); }); - next_button.Create(parent, button_look, _T(">"), layout.next_button, + next_button.Create(parent, button_look, ">", layout.next_button, button_style, [this](){ NextPage(1); }); close_button.Create(parent, button_look, _("Close"), layout.close_button, button_style, dialog.MakeModalResultCallback(mrOK)); @@ -450,7 +450,7 @@ AnalysisWidget::Update() switch (page) { case AnalysisPage::BAROGRAPH: - StringFormatUnsafe(sTmp, _T("%s: %s"), _("Analysis"), + StringFormatUnsafe(sTmp, "%s: %s", _("Analysis"), _("Barograph")); dialog.SetCaption(sTmp); BarographCaption(sTmp, glide_computer.GetFlightStats()); @@ -459,7 +459,7 @@ AnalysisWidget::Update() break; case AnalysisPage::CLIMB: - StringFormatUnsafe(sTmp, _T("%s: %s"), _("Analysis"), + StringFormatUnsafe(sTmp, "%s: %s", _("Analysis"), _("Climb")); dialog.SetCaption(sTmp); ClimbChartCaption(sTmp, glide_computer.GetFlightStats()); @@ -468,32 +468,32 @@ AnalysisWidget::Update() break; case AnalysisPage::THERMAL_BAND: - StringFormatUnsafe(sTmp, _T("%s: %s"), _("Analysis"), + StringFormatUnsafe(sTmp, "%s: %s", _("Analysis"), _("Thermal Band")); dialog.SetCaption(sTmp); ClimbChartCaption(sTmp, glide_computer.GetFlightStats()); info.SetText(sTmp); - SetCalcCaption(_T("")); + SetCalcCaption(""); break; case AnalysisPage::VARIO_HISTOGRAM: - StringFormatUnsafe(sTmp, _T("%s: %s"), _("Analysis"), + StringFormatUnsafe(sTmp, "%s: %s", _("Analysis"), _("Vario Histogram")); dialog.SetCaption(sTmp); - info.SetText(_T("")); - SetCalcCaption(_T("")); + info.SetText(""); + SetCalcCaption(""); break; case AnalysisPage::WIND: - StringFormatUnsafe(sTmp, _T("%s: %s"), _("Analysis"), + StringFormatUnsafe(sTmp, "%s: %s", _("Analysis"), _("Wind at Altitude")); dialog.SetCaption(sTmp); - info.SetText(_T("")); + info.SetText(""); SetCalcCaption(_("Set Wind")); break; case AnalysisPage::POLAR: - StringFormatUnsafe(sTmp, _T("%s: %s (%s %d kg)"), _("Analysis"), + StringFormatUnsafe(sTmp, "%s: %s (%s %d kg)", _("Analysis"), _("Glide Polar"), _("Mass"), (int)settings_computer.polar.glide_polar_task.GetTotalMass()); dialog.SetCaption(sTmp); @@ -503,7 +503,7 @@ AnalysisWidget::Update() break; case AnalysisPage::MACCREADY: - StringFormatUnsafe(sTmp, _T("%s: %s"), _("Analysis"), + StringFormatUnsafe(sTmp, "%s: %s", _("Analysis"), _("MacCready Speeds")); dialog.SetCaption(sTmp); MacCreadyCaption(sTmp, settings_computer.polar.glide_polar_task); @@ -512,7 +512,7 @@ AnalysisWidget::Update() break; case AnalysisPage::TEMPTRACE: - StringFormatUnsafe(sTmp, _T("%s: %s"), _("Analysis"), + StringFormatUnsafe(sTmp, "%s: %s", _("Analysis"), _("Temperature Trace")); dialog.SetCaption(sTmp); TemperatureChartCaption(sTmp, glide_computer.GetCuSonde()); @@ -521,7 +521,7 @@ AnalysisWidget::Update() break; case AnalysisPage::TASK_SPEED: - StringFormatUnsafe(sTmp, _T("%s: %s"), _("Analysis"), + StringFormatUnsafe(sTmp, "%s: %s", _("Analysis"), _("Task Speed")); dialog.SetCaption(sTmp); TaskSpeedCaption(sTmp, glide_computer.GetFlightStats(), @@ -531,7 +531,7 @@ AnalysisWidget::Update() break; case AnalysisPage::TASK: - StringFormatUnsafe(sTmp, _T("%s: %s"), _("Analysis"), + StringFormatUnsafe(sTmp, "%s: %s", _("Analysis"), _("Task")); dialog.SetCaption(sTmp); FlightStatisticsRenderer::CaptionTask(sTmp, calculated); @@ -540,20 +540,20 @@ AnalysisWidget::Update() break; case AnalysisPage::CONTEST: - StringFormatUnsafe(sTmp, _T("%s: %s"), _("Analysis"), + StringFormatUnsafe(sTmp, "%s: %s", _("Analysis"), ContestToString(settings_computer.contest.contest)); dialog.SetCaption(sTmp); - SetCalcCaption(_T("")); + SetCalcCaption(""); FlightStatisticsRenderer::CaptionContest(sTmp, settings_computer.contest, calculated); info.SetText(sTmp); break; case AnalysisPage::AIRSPACE: - StringFormatUnsafe(sTmp, _T("%s: %s"), _("Analysis"), + StringFormatUnsafe(sTmp, "%s: %s", _("Analysis"), _("Airspace")); dialog.SetCaption(sTmp); - info.SetText(_T("")); + info.SetText(""); SetCalcCaption(_("Warnings")); break; @@ -588,9 +588,9 @@ AnalysisWidget::NextPage(int Step) void AnalysisWidget::OnGesture(const char *gesture) { - if (StringIsEqual(gesture, _T("R"))) + if (StringIsEqual(gesture, "R")) NextPage(-1); - else if (StringIsEqual(gesture, _T("L"))) + else if (StringIsEqual(gesture, "L")) NextPage(+1); } diff --git a/src/Dialogs/dlgChecklist.cpp b/src/Dialogs/dlgChecklist.cpp index 410925641ce..d82589a8eb4 100644 --- a/src/Dialogs/dlgChecklist.cpp +++ b/src/Dialogs/dlgChecklist.cpp @@ -40,7 +40,7 @@ UpdateCaption(WndForm &form, const Checklist &checklist, std::size_t page) const auto &p = checklist[page]; if (!p.title.empty()) { - buffer.append(_T(": ")); + buffer.append(": "); buffer.append(p.title); } @@ -52,7 +52,7 @@ LoadChecklist() noexcept try { Checklist c; - auto file_reader = OpenDataFile(_T(XCSCHKLIST)); + auto file_reader = OpenDataFile(XCSCHKLIST); BufferedReader reader{*file_reader}; StringConverter string_converter{Charset::UTF8}; diff --git a/src/Dialogs/dlgCredits.cpp b/src/Dialogs/dlgCredits.cpp index 5320cc3eb4d..275065eec1d 100644 --- a/src/Dialogs/dlgCredits.cpp +++ b/src/Dialogs/dlgCredits.cpp @@ -68,7 +68,7 @@ LogoPageWindow::OnPaint(Canvas &canvas) noexcept canvas.SetTextColor(COLOR_BLACK); x = middle; - const char *version = _T("Version: "); + const char *version = "Version: "; PixelSize ts = canvas.CalcTextSize(version); PixelSize ts2 = canvas.CalcTextSize(OpenSoar_VersionString); x = middle - ((ts.width + ts2.width) / 2 ); @@ -80,19 +80,19 @@ LogoPageWindow::OnPaint(Canvas &canvas) noexcept #ifdef GIT_COMMIT_ID y += ts.height + Layout::FastScale(2); x = middle; - const char *git = _T("git: "); + const char *git = "git: "; ts = canvas.CalcTextSize(git); - ts2 = canvas.CalcTextSize(_T(GIT_COMMIT_ID)); + ts2 = canvas.CalcTextSize(GIT_COMMIT_ID); x = middle - ((ts.width + ts2.width) / 2 ); canvas.DrawText({x, y}, git); x += ts.width; - canvas.DrawText({x, y}, _T(GIT_COMMIT_ID)); + canvas.DrawText({x, y}, GIT_COMMIT_ID); y += ts.height + Layout::FastScale(2); #endif y += Layout::FastScale(8); - const char *visit = _T("Vist us at:"); - const char *url = _T("https://xcsoar.org"); + const char *visit = "Vist us at:"; + const char *url = "https://xcsoar.org"; ts = canvas.CalcTextSize(visit); ts2 = canvas.CalcTextSize(url); x = middle - (ts.width / 2); diff --git a/src/Dialogs/dlgInfoBoxAccess.cpp b/src/Dialogs/dlgInfoBoxAccess.cpp index 80a50dbf2d9..4419af00e35 100644 --- a/src/Dialogs/dlgInfoBoxAccess.cpp +++ b/src/Dialogs/dlgInfoBoxAccess.cpp @@ -59,7 +59,7 @@ dlgInfoBoxAccessShowModeless(const int id, const InfoBoxPanel *panels) if (widget == NULL) continue; - if (!found_setup && StringIsEqual(panels->name, _T("Setup"))) { + if (!found_setup && StringIsEqual(panels->name, "Setup")) { /* add a "Switch InfoBox" button to the "Setup" tab - kludge! */ found_setup = true; diff --git a/src/Dialogs/dlgQuickMenu.cpp b/src/Dialogs/dlgQuickMenu.cpp index 00b83411e5a..f24e5403bf9 100644 --- a/src/Dialogs/dlgQuickMenu.cpp +++ b/src/Dialogs/dlgQuickMenu.cpp @@ -185,7 +185,7 @@ QuickMenu::UpdateCaption() noexcept StaticString<32> buffer; unsigned pageSize = GetWindow().GetNumColumns() * grid_view.GetNumRows(); unsigned lastPage = buttons.size() / pageSize; - buffer.Format(_T("Quick Menu %d/%d"), + buffer.Format("Quick Menu %d/%d", grid_view.GetCurrentPage() + 1, lastPage + 1); dialog.SetCaption(buffer); } @@ -274,7 +274,7 @@ ShowQuickMenu(UI::SingleWindow &parent, const Menu &menu) noexcept void dlgQuickMenuShowModal(UI::SingleWindow &parent, [[maybe_unused]] const char *mode) noexcept { - const auto *menu = InputEvents::GetMenu(_T("RemoteStick")); + const auto *menu = InputEvents::GetMenu("RemoteStick"); if (menu == nullptr) return; diff --git a/src/Dialogs/dlgStatus.cpp b/src/Dialogs/dlgStatus.cpp index 8d2b5f81111..30e5e379dbe 100644 --- a/src/Dialogs/dlgStatus.cpp +++ b/src/Dialogs/dlgStatus.cpp @@ -25,7 +25,7 @@ static void SetTitle(WndForm &form, const TabWidget &pager) { StaticString<128> title; - title.Format(_T("%s: %s"), _("Status"), + title.Format("%s: %s", _("Status"), pager.GetButtonCaption(pager.GetCurrentIndex())); form.SetCaption(title); } diff --git a/src/Engine/Contest/Solvers/Contests.cpp b/src/Engine/Contest/Solvers/Contests.cpp index df7f18199cb..3403d6029b8 100644 --- a/src/Engine/Contest/Solvers/Contests.cpp +++ b/src/Engine/Contest/Solvers/Contests.cpp @@ -5,22 +5,22 @@ #include "util/Macros.hpp" static const char *const contest_to_string[] = { - _T("OLC Sprint"), - _T("OLC FAI"), - _T("OLC Classic"), - _T("OLC League"), - _T("OLC Plus"), - _T("XContest"), - _T("DHV-XC"), - _T("SIS-AT"), - _T("FFVV NetCoupe"), - _T("DMSt"), - _T("WeGlide FREE"), - _T("WeGlide Distance"), - _T("WeGlide FAI"), - _T("WeGlide O&R"), - _T("Charron"), - _T("None"), + "OLC Sprint", + "OLC FAI", + "OLC Classic", + "OLC League", + "OLC Plus", + "XContest", + "DHV-XC", + "SIS-AT", + "FFVV NetCoupe", + "DMSt", + "WeGlide FREE", + "WeGlide Distance", + "WeGlide FAI", + "WeGlide O&R", + "Charron", + "None", }; const char* diff --git a/src/Engine/Waypoint/Waypoints.cpp b/src/Engine/Waypoint/Waypoints.cpp index c705dc47547..a3e5230d94f 100644 --- a/src/Engine/Waypoint/Waypoints.cpp +++ b/src/Engine/Waypoint/Waypoints.cpp @@ -349,7 +349,7 @@ Waypoints::GenerateTakeoffPoint(const GeoPoint& location, Waypoint to_point(location); to_point.elevation = terrain_alt; to_point.has_elevation = true; - to_point.name = _T("(takeoff)"); + to_point.name = "(takeoff)"; to_point.type = Waypoint::Type::OUTLANDING; return to_point; } @@ -359,7 +359,7 @@ Waypoints::AddTakeoffPoint(const GeoPoint& location, const double terrain_alt) noexcept { // remove old one first - WaypointPtr old_takeoff_point = LookupName(_T("(takeoff)")); + WaypointPtr old_takeoff_point = LookupName("(takeoff)"); if (old_takeoff_point != nullptr) Erase(std::move(old_takeoff_point)); diff --git a/src/FLARM/FlarmNetReader.cpp b/src/FLARM/FlarmNetReader.cpp index 651c664e744..351de62753c 100644 --- a/src/FLARM/FlarmNetReader.cpp +++ b/src/FLARM/FlarmNetReader.cpp @@ -82,9 +82,9 @@ LoadRecord(FlarmNetRecord &record, const char *line) LoadString(line + 158, 7, record.frequency); // Terminate callsign string on first whitespace - for (char *i = record.callsign.buffer(); *i != _T('\0'); ++i) + for (char *i = record.callsign.buffer(); *i != '\0'; ++i) if (IsWhitespaceFast(*i)) - *i = _T('\0'); + *i = '\0'; return true; } diff --git a/src/FLARM/Glue.cpp b/src/FLARM/Glue.cpp index 9f84e212fb3..5e12434cdf8 100644 --- a/src/FLARM/Glue.cpp +++ b/src/FLARM/Glue.cpp @@ -50,7 +50,7 @@ LoadSecondary(FlarmNameDatabase &db) noexcept try { LogString("OpenFLARMDetails"); - auto reader = OpenDataFile(_T("xcsoar-flarm.txt")); + auto reader = OpenDataFile("xcsoar-flarm.txt"); BufferedReader buffered_reader{*reader}; LoadFlarmNameFile(buffered_reader, db); } catch (...) { @@ -96,7 +96,7 @@ SaveFlarmColors() noexcept static void SaveSecondary(FlarmNameDatabase &flarm_names) noexcept try { - FileOutputStream fos(LocalPath(_T("xcsoar-flarm.txt"))); + FileOutputStream fos(LocalPath("xcsoar-flarm.txt")); BufferedOutputStream bos(fos); SaveFlarmNameFile(bos, flarm_names); bos.Flush(); diff --git a/src/FLARM/Traffic.cpp b/src/FLARM/Traffic.cpp index aee6ec4fc89..08fc7154784 100644 --- a/src/FLARM/Traffic.cpp +++ b/src/FLARM/Traffic.cpp @@ -4,11 +4,11 @@ #include "FLARM/Traffic.hpp" static constexpr const char *acTypes[] = { - _T("Unknown"), _T("Glider"), _T("TowPlane"), - _T("Helicopter"), _T("Parachute"), _T("DropPlane"), _T("HangGlider"), - _T("ParaGlider"), _T("PoweredAircraft"), _T("JetAircraft"), - _T("FlyingSaucer"), _T("Balloon"), _T("Airship"), _T("UAV"), - _T("Unknown"), _T("StaticObject") }; + "Unknown", "Glider", "TowPlane", + "Helicopter", "Parachute", "DropPlane", "HangGlider", + "ParaGlider", "PoweredAircraft", "JetAircraft", + "FlyingSaucer", "Balloon", "Airship", "UAV", + "Unknown", "StaticObject" }; const char * FlarmTraffic::GetTypeString(AircraftType type) noexcept diff --git a/src/Form/Control.cpp b/src/Form/Control.cpp index 1e04fa2bbe1..34fe8577e6a 100644 --- a/src/Form/Control.cpp +++ b/src/Form/Control.cpp @@ -14,7 +14,7 @@ void WindowControl::SetCaption(const char *Value) noexcept { if (Value == nullptr) - Value = _T(""); + Value = ""; if (!caption.equals(Value)) { caption = Value; diff --git a/src/Form/DataField/Angle.cpp b/src/Form/DataField/Angle.cpp index 9b67cce2771..f6917d884ab 100644 --- a/src/Form/DataField/Angle.cpp +++ b/src/Form/DataField/Angle.cpp @@ -53,14 +53,14 @@ AngleDataField::ModifyValue(Angle _value) noexcept const char * AngleDataField::GetAsString() const noexcept { - _stprintf(string_buffer, _T("%u"), GetIntegerValue()); + _stprintf(string_buffer, "%u", GetIntegerValue()); return string_buffer; } const char * AngleDataField::GetAsDisplayString() const noexcept { - _stprintf(string_buffer, _T("%u°"), GetIntegerValue()); + _stprintf(string_buffer, "%u°", GetIntegerValue()); return string_buffer; } @@ -89,8 +89,8 @@ static void AppendComboValue(ComboList &combo_list, unsigned value) noexcept { char buffer1[16], buffer2[16]; - _stprintf(buffer1, _T("%u"), value); - _stprintf(buffer2, _T("%u°"), value); + _stprintf(buffer1, "%u", value); + _stprintf(buffer2, "%u°", value); combo_list.Append(value, buffer1, buffer2); } diff --git a/src/Form/DataField/ComboList.cpp b/src/Form/DataField/ComboList.cpp index a8ec0438baf..88cbd0f7983 100644 --- a/src/Form/DataField/ComboList.cpp +++ b/src/Form/DataField/ComboList.cpp @@ -15,7 +15,7 @@ ComboList::Item::Item(int _int_value, display_string(_display_string), help_text(_help_text != nullptr ? _help_text - : _T("")) + : "") { } diff --git a/src/Form/DataField/Enum.cpp b/src/Form/DataField/Enum.cpp index 6907310bd1e..17ee3057ab4 100644 --- a/src/Form/DataField/Enum.cpp +++ b/src/Form/DataField/Enum.cpp @@ -118,7 +118,7 @@ DataFieldEnum::GetAsString() const noexcept { if (entries.empty()) { assert(value == 0); - return _T(""); + return ""; } else { assert(value < entries.size()); return entries[value].GetString(); @@ -130,7 +130,7 @@ DataFieldEnum::GetAsDisplayString() const noexcept { if (entries.empty()) { assert(value == 0); - return _T(""); + return ""; } else { assert(value < entries.size()); return entries[value].GetDisplayString(); diff --git a/src/Form/DataField/File.cpp b/src/Form/DataField/File.cpp index 14b0556e254..e8c6e51220b 100644 --- a/src/Form/DataField/File.cpp +++ b/src/Form/DataField/File.cpp @@ -23,14 +23,14 @@ static bool IsInternalFile(const char *str) noexcept { static const char *const ifiles[] = { - _T("xcsoar-checklist.txt"), - _T("xcsoar-flarm.txt"), - _T("xcsoar-marks.txt"), - _T("xcsoar-persist.log"), - _T("xcsoar-startup.log"), - _T("xcsoar.log"), - _T("xcsoar-rasp.dat"), - _T("user.cup"), + "xcsoar-checklist.txt", + "xcsoar-flarm.txt", + "xcsoar-marks.txt", + "xcsoar-persist.log", + "xcsoar-startup.log", + "xcsoar.log", + "xcsoar-rasp.dat", + "user.cup", nullptr }; @@ -177,7 +177,7 @@ FileDataField::GetValue() const noexcept if (current_index >= files.size()) // TODO: return nullptr instead of empty string? - return Path(_T("")); + return Path(""); const Path path = files[current_index].path; assert(path != nullptr); @@ -205,8 +205,8 @@ FileDataField::AddNull() noexcept assert(!files.full()); Item &item = files.append(); - item.filename = Path(_T("")); - item.path = Path(_T("")); + item.filename = Path(""); + item.path = Path(""); } const char * @@ -218,7 +218,7 @@ FileDataField::GetAsString() const noexcept if (current_index < files.size()) return files[current_index].path.c_str(); else - return _T(""); + return ""; } const char * @@ -236,7 +236,7 @@ FileDataField::GetAsDisplayString() const noexcept if (current_index < files.size()) return files[current_index].filename.c_str(); else - return _T(""); + return ""; } void @@ -336,9 +336,9 @@ FileDataField::CreateComboList([[maybe_unused]] const char *reference) const noe /* yes - append the absolute path to allow the user to see the difference */ strcpy(buffer, path.c_str()); - strcat(buffer, _T(" (")); + strcat(buffer, " ("); strcat(buffer, files[i].path.c_str()); - strcat(buffer, _T(")")); + strcat(buffer, ")"); display_string = buffer; } diff --git a/src/Form/DataField/Float.cpp b/src/Form/DataField/Float.cpp index 24508cf14a2..60b9091dec4 100644 --- a/src/Form/DataField/Float.cpp +++ b/src/Form/DataField/Float.cpp @@ -121,7 +121,7 @@ DataFieldFloat::CreateComboList(const char *reference_string) const noexcept auto first = corrected_value - surrounding_items * mStep; if (first > mMin + epsilon) /* there are values before "first" - give the user a choice */ - combo_list.Append(ComboList::Item::PREVIOUS_PAGE, _T("<>")); + combo_list.Append(ComboList::Item::PREVIOUS_PAGE, "<>"); else if (first < mMin - epsilon) first = int(mMin / mStep) * mStep; @@ -181,7 +181,7 @@ DataFieldFloat::CreateComboList(const char *reference_string) const noexcept if (last < mMax - epsilon) /* there are values after "last" - give the user a choice */ - combo_list.Append(ComboList::Item::NEXT_PAGE, _T("<>")); + combo_list.Append(ComboList::Item::NEXT_PAGE, "<>"); return combo_list; } diff --git a/src/Form/DataField/Float.hpp b/src/Form/DataField/Float.hpp index 8965b8b9064..5d67dbc9331 100644 --- a/src/Form/DataField/Float.hpp +++ b/src/Form/DataField/Float.hpp @@ -30,7 +30,7 @@ class DataFieldFloat final : public NumberDataField { :NumberDataField(Type::REAL, true, edit_format, display_format, listener), mValue(_value), mMin(_min), mMax(_max), mStep(_step), mSpeedup(0), mFine(_fine), - unit(_T("")) {} + unit("") {} void SetUnits(const char *text) noexcept { unit = text; diff --git a/src/Form/DataField/GeoPoint.cpp b/src/Form/DataField/GeoPoint.cpp index 32c6363f9c6..a61e9903c86 100644 --- a/src/Form/DataField/GeoPoint.cpp +++ b/src/Form/DataField/GeoPoint.cpp @@ -18,7 +18,7 @@ const char * GeoPointDataField::GetAsString() const noexcept { if (!value.IsValid()) - return _T(""); + return ""; return FormatGeoPoint(value, string_buffer, std::size(string_buffer), format); diff --git a/src/Form/DataField/Integer.cpp b/src/Form/DataField/Integer.cpp index bfd57af4624..525ad38f812 100644 --- a/src/Form/DataField/Integer.cpp +++ b/src/Form/DataField/Integer.cpp @@ -107,7 +107,7 @@ DataFieldInteger::CreateComboList(const char *reference_string) const noexcept int first = corrected_value - (int)surrounding_items * step; if (first > min) /* there are values before "first" - give the user a choice */ - combo_list.Append(ComboList::Item::PREVIOUS_PAGE, _T("<>")); + combo_list.Append(ComboList::Item::PREVIOUS_PAGE, "<>"); else if (first < min) first = min; @@ -137,7 +137,7 @@ DataFieldInteger::CreateComboList(const char *reference_string) const noexcept if (last < max) /* there are values after "last" - give the user a choice */ - combo_list.Append(ComboList::Item::NEXT_PAGE, _T("<>")); + combo_list.Append(ComboList::Item::NEXT_PAGE, "<>"); return combo_list; } diff --git a/src/Form/DataField/Number.cpp b/src/Form/DataField/Number.cpp index 4f4251b5d27..c78a587b4a1 100644 --- a/src/Form/DataField/Number.cpp +++ b/src/Form/DataField/Number.cpp @@ -17,5 +17,5 @@ NumberDataField::SetFormat(const char *text) noexcept { edit_format = text; display_format = text; - display_format += _T(" %s") ; + display_format += " %s" ; } diff --git a/src/Form/DataField/Password.cpp b/src/Form/DataField/Password.cpp index a8f14dceea6..e00f2346aac 100644 --- a/src/Form/DataField/Password.cpp +++ b/src/Form/DataField/Password.cpp @@ -8,7 +8,7 @@ const char * PasswordDataField::GetAsDisplayString() const noexcept { - const char *obfuscated = _T("********************************"); + const char *obfuscated = "********************************"; const size_t obfuscated_length = strlen(obfuscated); size_t length = std::min(strlen(GetAsString()), obfuscated_length); return obfuscated + (obfuscated_length - length); diff --git a/src/Form/DataField/Prefix.cpp b/src/Form/DataField/Prefix.cpp index c703e0093d4..44839899eb1 100644 --- a/src/Form/DataField/Prefix.cpp +++ b/src/Form/DataField/Prefix.cpp @@ -10,7 +10,7 @@ PrefixDataField::GetAsDisplayString() const noexcept { const char *s = DataFieldString::GetAsDisplayString(); if (StringIsEmpty(s)) - s = _T("*"); + s = "*"; return s; } @@ -22,7 +22,7 @@ PrefixDataField::Inc() noexcept return; const char current = GetAsString()[0]; - const char *p = current != _T('\0') + const char *p = current != '\0' ? StringFind(chars, current) : nullptr; @@ -32,7 +32,7 @@ PrefixDataField::Inc() noexcept else next = p[1]; - const char new_value[2] = { next, _T('\0') }; + const char new_value[2] = { next, '\0' }; ModifyValue(new_value); } @@ -46,19 +46,19 @@ PrefixDataField::Dec() noexcept const char current = GetAsString()[0]; char next; - if (current == _T('\0')) + if (current == '\0') next = chars[strlen(chars) - 1]; else { - const char *p = current != _T('\0') + const char *p = current != '\0' ? StringFind(chars, current) : nullptr; if (p > chars) next = p[-1]; else - next = _T('\0'); + next = '\0'; } - const char new_value[2] = { next, _T('\0') }; + const char new_value[2] = { next, '\0' }; ModifyValue(new_value); } diff --git a/src/Form/DataField/Prefix.hpp b/src/Form/DataField/Prefix.hpp index 23d8225727e..2da2fa6ae40 100644 --- a/src/Form/DataField/Prefix.hpp +++ b/src/Form/DataField/Prefix.hpp @@ -21,7 +21,7 @@ class PrefixDataField final : public DataFieldString { :DataFieldString(Type::PREFIX, value, listener), allowed_characters(_allowed_characters) {} - PrefixDataField(const char *value=_T(""), + PrefixDataField(const char *value="", DataFieldListener *listener=nullptr) noexcept :DataFieldString(Type::PREFIX, value, listener) {} @@ -38,7 +38,7 @@ class PrefixDataField final : public DataFieldString { [[gnu::pure]] const char *GetAllowedCharacters() const noexcept { return allowed_characters - ? allowed_characters(_T("")) - : _T("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + ? allowed_characters("") + : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; } }; diff --git a/src/Form/DataField/RoughTime.cpp b/src/Form/DataField/RoughTime.cpp index cf7d7637579..68d728352b0 100644 --- a/src/Form/DataField/RoughTime.cpp +++ b/src/Form/DataField/RoughTime.cpp @@ -22,9 +22,9 @@ const char * RoughTimeDataField::GetAsString() const noexcept { if (!value.IsValid()) - return _T(""); + return ""; - _stprintf(buffer, _T("%02u:%02u"), value.GetHour(), value.GetMinute()); + _stprintf(buffer, "%02u:%02u", value.GetHour(), value.GetMinute()); return buffer; } @@ -32,10 +32,10 @@ const char * RoughTimeDataField::GetAsDisplayString() const noexcept { if (!value.IsValid()) - return _T(""); + return ""; RoughTime local_value = value + time_zone; - _stprintf(buffer, _T("%02u:%02u"), + _stprintf(buffer, "%02u:%02u", local_value.GetHour(), local_value.GetMinute()); return buffer; } diff --git a/src/Form/DataField/Time.cpp b/src/Form/DataField/Time.cpp index 7476264c22d..5a30dda6817 100644 --- a/src/Form/DataField/Time.cpp +++ b/src/Form/DataField/Time.cpp @@ -12,7 +12,7 @@ static bool data_field_key_up = false; const char * DataFieldTime::GetAsString() const noexcept { - StringFormatUnsafe(string_buffer, _T("%d"), value); + StringFormatUnsafe(string_buffer, "%d", value); return string_buffer; } @@ -71,7 +71,7 @@ DataFieldTime::AppendComboValue(ComboList &combo_list, std::chrono::seconds value) const noexcept { char buffer2[32]; - StringFormatUnsafe(buffer2, _T("%ld"), (long)value.count()); + StringFormatUnsafe(buffer2, "%ld", (long)value.count()); combo_list.Append(value.count(), buffer2, FormatTimespanSmart(value, max_tokens)); } @@ -94,7 +94,7 @@ DataFieldTime::CreateComboList(const char *reference_string) const noexcept auto first = corrected_value - (int)surrounding_items * step; if (first > min) /* there are values before "first" - give the user a choice */ - combo_list.Append(ComboList::Item::PREVIOUS_PAGE, _T("<>")); + combo_list.Append(ComboList::Item::PREVIOUS_PAGE, "<>"); else if (first < min) first = min; @@ -123,7 +123,7 @@ DataFieldTime::CreateComboList(const char *reference_string) const noexcept if (last < max) /* there are values after "last" - give the user a choice */ - combo_list.Append(ComboList::Item::NEXT_PAGE, _T("<>")); + combo_list.Append(ComboList::Item::NEXT_PAGE, "<>"); return combo_list; } diff --git a/src/Form/DigitEntry.cpp b/src/Form/DigitEntry.cpp index 9f70ef9ae65..6259ce3cde6 100644 --- a/src/Form/DigitEntry.cpp +++ b/src/Form/DigitEntry.cpp @@ -244,7 +244,7 @@ DigitEntry::CalculateLayout() const unsigned min_value_height = control_height * 3 / 2; - PixelSize digit_size = look.text_font.TextSize(_T("8")); + PixelSize digit_size = look.text_font.TextSize("8"); digit_size.height += 2 * padding; if (digit_size.height < min_value_height) digit_size.height = min_value_height; @@ -1016,70 +1016,70 @@ DigitEntry::OnPaint(Canvas &canvas) noexcept } const char *text = buffer; - buffer[1] = _T('\0'); + buffer[1] = '\0'; switch (c.type) { case Column::Type::DIGIT: case Column::Type::DIGIT6: assert(c.value < 10); - buffer[0] = _T('0') + c.value; + buffer[0] = '0' + c.value; break; case Column::Type::HOUR: assert(c.value < 24); - _stprintf(buffer, _T("%02u"), c.value); + _stprintf(buffer, "%02u", c.value); break; case Column::Type::DIGIT36: assert(c.value < 36); - _stprintf(buffer, _T("%02u"), c.value); + _stprintf(buffer, "%02u", c.value); break; case Column::Type::DIGIT19: assert(c.value < 19); - _stprintf(buffer, _T("%02u"), c.value); + _stprintf(buffer, "%02u", c.value); break; case Column::Type::SIGN: - buffer[0] = c.IsNegative() ? _T('-') : _T('+'); + buffer[0] = c.IsNegative() ? '-' : '+'; break; case Column::Type::DECIMAL_POINT: - buffer[0] = _T('.'); + buffer[0] = '.'; break; case Column::Type::COLON: - buffer[0] = _T(':'); + buffer[0] = ':'; break; case Column::Type::NORTH_SOUTH: - buffer[0] = c.IsNegative() ? _T('S') : _T('N'); + buffer[0] = c.IsNegative() ? 'S' : 'N'; break; case Column::Type::EAST_WEST: - buffer[0] = c.IsNegative() ? _T('W') : _T('E'); + buffer[0] = c.IsNegative() ? 'W' : 'E'; break; case Column::Type::DEGREES: - text = _T("°"); + text = "°"; break; case Column::Type::APOSTROPHE: - text = _T("'"); + text = "'"; break; case Column::Type::QUOTE: - text = _T("\""); + text = "\""; break; case Column::Type::DAY: - _stprintf(buffer, _T("%02u"), c.value + 1); + _stprintf(buffer, "%02u", c.value + 1); break; case Column::Type::MONTH: - _stprintf(buffer, _T("%02u"), c.value + 1); + _stprintf(buffer, "%02u", c.value + 1); break; case Column::Type::YEAR: - _stprintf(buffer, _T("%04u"), c.value + 1900); + _stprintf(buffer, "%04u", c.value + 1900); break; case Column::Type::UNIT: @@ -1089,7 +1089,7 @@ DigitEntry::OnPaint(Canvas &canvas) noexcept } if (c.IsEditable() && !valid) - buffer[0] = _T('\0'); + buffer[0] = '\0'; const int x = (c.left + c.right - canvas.CalcTextWidth(text)) / 2; diff --git a/src/Form/Form.cpp b/src/Form/Form.cpp index 59c5f654b61..65dd2b869b0 100644 --- a/src/Form/Form.cpp +++ b/src/Form/Form.cpp @@ -528,7 +528,7 @@ void WndForm::SetCaption(const char *_caption) { if (_caption == nullptr) - _caption = _T(""); + _caption = ""; if (caption != _caption) { caption = _caption; diff --git a/src/Form/TabMenuDisplay.cpp b/src/Form/TabMenuDisplay.cpp index 574a747f5b7..fb3ee7c0f7d 100644 --- a/src/Form/TabMenuDisplay.cpp +++ b/src/Form/TabMenuDisplay.cpp @@ -53,7 +53,7 @@ TabMenuDisplay::GetCaption(char buffer[], size_t size) const noexcept const unsigned page = pager.GetCurrentIndex(); if (page >= PAGE_OFFSET) { const unsigned i = page - PAGE_OFFSET; - StringFormat(buffer, size, _T("%s > %s"), + StringFormat(buffer, size, "%s > %s", gettext(GetPageParentCaption(i)), buttons[i].caption); return buffer; diff --git a/src/Formatter/AirspaceFormatter.cpp b/src/Formatter/AirspaceFormatter.cpp index 635404fdaf7..30e05eb8845 100644 --- a/src/Formatter/AirspaceFormatter.cpp +++ b/src/Formatter/AirspaceFormatter.cpp @@ -6,24 +6,24 @@ #include "util/Macros.hpp" static const char *const airspace_class_names[] = { - _T("Unknown"), - _T("Restricted"), - _T("Prohibited"), - _T("Danger Area"), - _T("Class A"), - _T("Class B"), - _T("Class C"), - _T("Class D"), - _T("No Gliders"), - _T("CTR"), - _T("Wave"), - _T("Task Area"), - _T("Class E"), - _T("Class F"), - _T("Transponder Mandatory Zone"), - _T("Class G"), - _T("Military Aerodrome Traffic Zone"), - _T("Radio Mandatory Zone"), + "Unknown", + "Restricted", + "Prohibited", + "Danger Area", + "Class A", + "Class B", + "Class C", + "Class D", + "No Gliders", + "CTR", + "Wave", + "Task Area", + "Class E", + "Class F", + "Transponder Mandatory Zone", + "Class G", + "Military Aerodrome Traffic Zone", + "Radio Mandatory Zone", }; static_assert(ARRAY_SIZE(airspace_class_names) == @@ -32,24 +32,24 @@ static_assert(ARRAY_SIZE(airspace_class_names) == "airspace classes"); static const char *const airspace_class_short_names[] = { - _T("?"), - _T("R"), - _T("P"), - _T("Q"), - _T("A"), - _T("B"), - _T("C"), - _T("D"), - _T("GP"), - _T("CTR"), - _T("W"), - _T("AAT"), - _T("E"), - _T("F"), - _T("TMZ"), - _T("G"), - _T("MATZ"), - _T("RMZ"), + "?", + "R", + "P", + "Q", + "A", + "B", + "C", + "D", + "GP", + "CTR", + "W", + "AAT", + "E", + "F", + "TMZ", + "G", + "MATZ", + "RMZ", }; static_assert(ARRAY_SIZE(airspace_class_short_names) == diff --git a/src/Formatter/AirspaceUserUnitsFormatter.cpp b/src/Formatter/AirspaceUserUnitsFormatter.cpp index d450180ebcc..165e601001e 100644 --- a/src/Formatter/AirspaceUserUnitsFormatter.cpp +++ b/src/Formatter/AirspaceUserUnitsFormatter.cpp @@ -18,28 +18,28 @@ AirspaceFormatter::FormatAltitudeShort(char *buffer, switch (altitude.reference) { case AltitudeReference::AGL: if (altitude.altitude_above_terrain <= 0) - strcpy(buffer, _T("GND")); + strcpy(buffer, "GND"); else if (include_unit) - StringFormatUnsafe(buffer, _T("%d %s AGL"), + StringFormatUnsafe(buffer, "%d %s AGL", iround(Units::ToUserAltitude(altitude.altitude_above_terrain)), Units::GetAltitudeName()); else - StringFormatUnsafe(buffer, _T("%d AGL"), + StringFormatUnsafe(buffer, "%d AGL", iround(Units::ToUserAltitude(altitude.altitude_above_terrain))); break; case AltitudeReference::STD: - StringFormatUnsafe(buffer, _T("FL%d"), iround(altitude.flight_level)); + StringFormatUnsafe(buffer, "FL%d", iround(altitude.flight_level)); break; case AltitudeReference::MSL: if (include_unit) - StringFormatUnsafe(buffer, _T("%d %s"), + StringFormatUnsafe(buffer, "%d %s", iround(Units::ToUserAltitude(altitude.altitude)), Units::GetAltitudeName()); else - StringFormatUnsafe(buffer, _T("%d"), + StringFormatUnsafe(buffer, "%d", iround(Units::ToUserAltitude(altitude.altitude))); break; } @@ -56,13 +56,13 @@ AirspaceFormatter::FormatAltitude(char *buffer, Units::GetUserAltitudeUnit() == Unit::METER) /* additionally show airspace altitude in feet, because aviation charts usually print altitudes in feet */ - StringFormatUnsafe(buffer + strlen(buffer), _T(" (%d %s)"), + StringFormatUnsafe(buffer + strlen(buffer), " (%d %s)", iround(Units::ToUserUnit(altitude.altitude, Unit::FEET)), Units::GetUnitName(Unit::FEET)); if (altitude.reference != AltitudeReference::MSL && altitude.altitude > 0) - StringFormatUnsafe(buffer + strlen(buffer), _T(" %d %s"), + StringFormatUnsafe(buffer + strlen(buffer), " %d %s", iround(Units::ToUserAltitude(altitude.altitude)), Units::GetAltitudeName()); } diff --git a/src/Formatter/AngleFormatter.cpp b/src/Formatter/AngleFormatter.cpp index 202193e9cda..6dae4c171a9 100644 --- a/src/Formatter/AngleFormatter.cpp +++ b/src/Formatter/AngleFormatter.cpp @@ -16,9 +16,9 @@ FormatBearing(char *buffer, size_t size, unsigned value_degrees, assert(size >= 8); if (suffix != NULL) - StringFormat(buffer, size, _T("%u° %s"), value_degrees, suffix); + StringFormat(buffer, size, "%u° %s", value_degrees, suffix); else - StringFormat(buffer, size, _T("%u°"), value_degrees); + StringFormat(buffer, size, "%u°", value_degrees); } void @@ -35,11 +35,11 @@ FormatAngleDelta(char *buffer, size_t size, Angle value) auto degrees = lround(value.AsDelta().Degrees()); if (degrees > 1) - StringFormat(buffer, size, _T("%u°»"), unsigned(degrees)); + StringFormat(buffer, size, "%u°»", unsigned(degrees)); else if (degrees < -1) - StringFormat(buffer, size, _T("«%u°"), unsigned(-degrees)); + StringFormat(buffer, size, "«%u°", unsigned(-degrees)); else - strcpy(buffer, _T("« * »")); + strcpy(buffer, "« * »"); } void @@ -50,7 +50,7 @@ FormatVerticalAngleDelta(char *buffer, size_t size, Angle value) auto degrees = lround(value.AsDelta().Degrees()); if (degrees < -1 || degrees > 1) - StringFormat(buffer, size, _T("%+d°"), int(degrees)); + StringFormat(buffer, size, "%+d°", int(degrees)); else - strcpy(buffer, _T("--")); + strcpy(buffer, "--"); } diff --git a/src/Formatter/ByteSizeFormatter.cpp b/src/Formatter/ByteSizeFormatter.cpp index 33f869e34f0..0adbe8afc57 100644 --- a/src/Formatter/ByteSizeFormatter.cpp +++ b/src/Formatter/ByteSizeFormatter.cpp @@ -13,8 +13,8 @@ FormatByteSize(char *buffer, size_t size, unsigned long bytes, bool simple) assert(buffer != NULL); assert(size >= 8); - static const char *const units[] = { _T("B"), _T("KB"), _T("MB"), _T("GB") }; - static const char *const simple_units[] = { _T("B"), _T("K"), _T("M"), _T("G") }; + static const char *const units[] = { "B", "KB", "MB", "GB" }; + static const char *const simple_units[] = { "B", "K", "M", "G" }; double value = bytes; @@ -25,11 +25,11 @@ FormatByteSize(char *buffer, size_t size, unsigned long bytes, bool simple) const char *format; if (value >= 100 || i == 0) - format = simple ? _T("%.0f%s") : _T("%.0f %s"); + format = simple ? "%.0f%s" : "%.0f %s"; else if (value >= 10) - format = simple ? _T("%.1f%s") : _T("%.1f %s"); + format = simple ? "%.1f%s" : "%.1f %s"; else - format = simple ? _T("%.1f%s") : _T("%.2f %s"); + format = simple ? "%.1f%s" : "%.2f %s"; StringFormat(buffer, size, format, value, unit); } diff --git a/src/Formatter/GeoPointFormatter.cpp b/src/Formatter/GeoPointFormatter.cpp index d4beae37b04..fba008a650a 100644 --- a/src/Formatter/GeoPointFormatter.cpp +++ b/src/Formatter/GeoPointFormatter.cpp @@ -30,7 +30,7 @@ FormatLongitude(Angle longitude, char *buffer, size_t size, int dd, mm, ss; // Calculate Longitude sign - char sign = longitude.IsNegative() ? _T('W') : _T('E'); + char sign = longitude.IsNegative() ? 'W' : 'E'; double mlong(longitude.AbsoluteDegrees()); @@ -53,7 +53,7 @@ FormatLongitude(Angle longitude, char *buffer, size_t size, mm -= 60; } // Save the string to the buffer - StringFormat(buffer, size, _T("%03d" ) _T(DEG) _T("%02d'%02d\" %c"), + StringFormat(buffer, size, "%03d" DEG "%02d'%02d\" %c", dd, mm, ss, sign); break; @@ -66,7 +66,7 @@ FormatLongitude(Angle longitude, char *buffer, size_t size, // Calculate seconds mlong = (mlong - mm) * 60.0; // Save the string to the buffer - StringFormat(buffer, size, _T("%03d") _T(DEG) _T("%02d'%04.1f\" %c"), + StringFormat(buffer, size, "%03d" DEG "%02d'%04.1f\" %c", dd, mm, mlong, sign); break; @@ -76,13 +76,13 @@ FormatLongitude(Angle longitude, char *buffer, size_t size, // Calculate minutes mlong = (mlong - dd) * 60.0; // Save the string to the buffer - StringFormat(buffer, size, _T("%03d") _T(DEG) _T("%06.3f' %c"), + StringFormat(buffer, size, "%03d" DEG "%06.3f' %c", dd, mlong, sign); break; case CoordinateFormat::DD_DDDDD: // Save the string to the buffer - StringFormat(buffer, size, _T("%09.5f" DEG " %c"), mlong, sign); + StringFormat(buffer, size, "%09.5f" DEG " %c", mlong, sign); break; case CoordinateFormat::UTM: @@ -99,7 +99,7 @@ FormatLatitude(Angle latitude, char *buffer, size_t size, int dd, mm, ss; // Calculate Latitude sign - char sign = latitude.IsNegative() ? _T('S') : _T('N'); + char sign = latitude.IsNegative() ? 'S' : 'N'; double mlat(latitude.AbsoluteDegrees()); @@ -122,7 +122,7 @@ FormatLatitude(Angle latitude, char *buffer, size_t size, mm -= 60; } // Save the string to the buffer - StringFormat(buffer, size, _T("%02d") _T(DEG) _T("%02d'%02d\" %c"), + StringFormat(buffer, size, "%02d" DEG "%02d'%02d\" %c", dd, mm, ss, sign); break; @@ -135,7 +135,7 @@ FormatLatitude(Angle latitude, char *buffer, size_t size, // Calculate seconds mlat = (mlat - mm) * 60.0; // Save the string to the buffer - StringFormat(buffer, size, _T("%02d") _T(DEG) _T("%02d'%04.1f\" %c"), + StringFormat(buffer, size, "%02d" DEG "%02d'%04.1f\" %c", dd, mm, mlat, sign); break; @@ -145,13 +145,13 @@ FormatLatitude(Angle latitude, char *buffer, size_t size, // Calculate minutes mlat = (mlat - dd) * 60.0; // Save the string to the buffer - StringFormat(buffer, size, _T("%02d") _T(DEG) _T("%06.3f' %c"), + StringFormat(buffer, size, "%02d" DEG "%06.3f' %c", dd, mlat, sign); break; case CoordinateFormat::DD_DDDDD: // Save the string to the buffer - StringFormat(buffer, size, _T("%08.5f" DEG " %c"), mlat, sign); + StringFormat(buffer, size, "%08.5f" DEG " %c", mlat, sign); break; case CoordinateFormat::UTM: @@ -163,10 +163,10 @@ FormatLatitude(Angle latitude, char *buffer, size_t size, static char * FormatUTM(const GeoPoint &location, char *buffer, size_t size, - char separator = _T(' ')) + char separator = ' ') { UTM utm = UTM::FromGeoPoint(location); - StringFormat(buffer, size, _T("%u%c%c%.0f%c%.0f"), + StringFormat(buffer, size, "%u%c%c%.0f%c%.0f", utm.zone_number, utm.zone_letter, separator, (double)utm.easting, separator, (double)utm.northing); diff --git a/src/Formatter/GeoPointFormatter.hpp b/src/Formatter/GeoPointFormatter.hpp index 5eddc8c3a6e..12a22baac75 100644 --- a/src/Formatter/GeoPointFormatter.hpp +++ b/src/Formatter/GeoPointFormatter.hpp @@ -34,12 +34,12 @@ bool FormatLatitude(Angle latitude, char *buffer, size_t size, * Convert a GeoPoint into a formatted string. */ char *FormatGeoPoint(const GeoPoint &location, char *buffer, size_t size, - CoordinateFormat format, char separator = _T(' ')); + CoordinateFormat format, char separator = ' '); [[gnu::pure]] static inline BasicStringBuffer FormatGeoPoint(const GeoPoint &location, CoordinateFormat format, - char separator = _T(' ')) + char separator = ' ') { BasicStringBuffer buffer; auto result = FormatGeoPoint(location, buffer.data(), buffer.capacity(), diff --git a/src/Formatter/GlideRatioFormatter.cpp b/src/Formatter/GlideRatioFormatter.cpp index 2f24a83ee22..e43bac94e4d 100644 --- a/src/Formatter/GlideRatioFormatter.cpp +++ b/src/Formatter/GlideRatioFormatter.cpp @@ -14,5 +14,5 @@ FormatGlideRatio(char *buffer, size_t size, double gr) assert(size >= 8); StringFormat(buffer, size, - fabs(gr) < 100 ? _T("%.1f") : _T("%.0f"), (double) gr); + fabs(gr) < 100 ? "%.1f" : "%.0f", (double) gr); } diff --git a/src/Formatter/IGCFilenameFormatter.cpp b/src/Formatter/IGCFilenameFormatter.cpp index 030535294cb..3453fd24af9 100644 --- a/src/Formatter/IGCFilenameFormatter.cpp +++ b/src/Formatter/IGCFilenameFormatter.cpp @@ -14,9 +14,9 @@ NumToIGCChar(unsigned num) assert(num <= 35); if (num < 10) - return _T('1') + (num - 1); + return '1' + (num - 1); - return _T('A') + (num - 10); + return 'A' + (num - 10); } void @@ -32,7 +32,7 @@ FormatIGCFilename(char* buffer, const BrokenDate &date, char cday = NumToIGCChar(date.day); char cflight = NumToIGCChar(flight_number); - StringFormatUnsafe(buffer, _T("%c%c%c%c%s%c.igc"), + StringFormatUnsafe(buffer, "%c%c%c%c%s%c.igc", cyear, cmonth, cday, manufacturer, logger_id, cflight); } @@ -52,7 +52,7 @@ FormatIGCFilenameLong(char* buffer, const BrokenDate &date, assert(logger_id != NULL); assert(strlen(logger_id) == 3); - StringFormatUnsafe(buffer, _T("%04u-%02u-%02u-%s-%s-%02u.igc"), + StringFormatUnsafe(buffer, "%04u-%02u-%02u-%s-%s-%02u.igc", date.year, date.month, date.day, manufacturer, logger_id, flight_number); } diff --git a/src/Formatter/TimeFormatter.cpp b/src/Formatter/TimeFormatter.cpp index 8b8fb7b7207..97fb9a49d57 100644 --- a/src/Formatter/TimeFormatter.cpp +++ b/src/Formatter/TimeFormatter.cpp @@ -29,12 +29,12 @@ void FormatTime(char *buffer, FloatDuration _time) noexcept { if (_time.count() < 0) { - *buffer++ = _T('-'); + *buffer++ = '-'; _time = -_time; } const BrokenTime time = BrokenTime::FromSinceMidnightChecked(_time); - _stprintf(buffer, _T("%02u:%02u:%02u"), + _stprintf(buffer, "%02u:%02u:%02u", time.hour, time.minute, time.second); } @@ -42,7 +42,7 @@ void FormatTimeLong(char *buffer, FloatDuration _time) noexcept { if (_time.count() < 0) { - *buffer++ = _T('-'); + *buffer++ = '-'; _time = -_time; } @@ -51,7 +51,7 @@ FormatTimeLong(char *buffer, FloatDuration _time) noexcept _time -= FloatDuration{trunc(_time.count())}; unsigned millisecond = uround(_time.count() * 1000); - _stprintf(buffer, _T("%02u:%02u:%02u.%03u"), + _stprintf(buffer, "%02u:%02u:%02u.%03u", time.hour, time.minute, time.second, millisecond); } @@ -59,29 +59,29 @@ void FormatSignedTimeHHMM(char *buffer, std::chrono::seconds _time) noexcept { if (_time.count() < 0) { - *buffer++ = _T('-'); + *buffer++ = '-'; _time = -_time; } const BrokenTime time = BrokenTime::FromSinceMidnightChecked(_time); - _stprintf(buffer, _T("%02u:%02u"), time.hour, time.minute); + _stprintf(buffer, "%02u:%02u", time.hour, time.minute); } void FormatTimeTwoLines(char *buffer1, char *buffer2, std::chrono::seconds _time) noexcept { if (_time >= std::chrono::hours{24}) { - strcpy(buffer1, _T(">24h")); + strcpy(buffer1, ">24h"); buffer2[0] = '\0'; return; } if (_time <= -std::chrono::hours{24}) { - strcpy(buffer1, _T("<-24h")); + strcpy(buffer1, "<-24h"); buffer2[0] = '\0'; return; } if (_time.count() < 0) { - *buffer1++ = _T('-'); + *buffer1++ = '-'; _time = -_time; } @@ -89,10 +89,10 @@ FormatTimeTwoLines(char *buffer1, char *buffer2, std::chrono::seconds _time) noe if (time.hour > 0) { // hh:mm, ss // Set Value - _stprintf(buffer1, _T("%02u:%02u"), time.hour, time.minute); - _stprintf(buffer2, _T("%02u"), time.second); + _stprintf(buffer1, "%02u:%02u", time.hour, time.minute); + _stprintf(buffer2, "%02u", time.second); } else { // mm'ss - _stprintf(buffer1, _T("%02u'%02u"), time.minute, time.second); + _stprintf(buffer1, "%02u'%02u", time.minute, time.second); buffer2[0] = '\0'; } } @@ -177,16 +177,16 @@ FormatTimespanSmart(char *buffer, std::chrono::seconds timespan, // Output if (timespan.count() < 0) { - *buffer = _T('-'); + *buffer = '-'; buffer++; } - *buffer = _T('\0'); + *buffer = '\0'; StaticString<16> component_buffer; if (show_days) { - component_buffer.Format(_T("%u days"), days); + component_buffer.Format("%u days", days); strcat(buffer, component_buffer); } @@ -194,7 +194,7 @@ FormatTimespanSmart(char *buffer, std::chrono::seconds timespan, if (!StringIsEmpty(buffer)) strcat(buffer, separator); - component_buffer.Format(_T("%u h"), hours); + component_buffer.Format("%u h", hours); strcat(buffer, component_buffer); } @@ -202,7 +202,7 @@ FormatTimespanSmart(char *buffer, std::chrono::seconds timespan, if (!StringIsEmpty(buffer)) strcat(buffer, separator); - component_buffer.Format(_T("%u min"), minutes); + component_buffer.Format("%u min", minutes); strcat(buffer, component_buffer); } @@ -210,7 +210,7 @@ FormatTimespanSmart(char *buffer, std::chrono::seconds timespan, if (!StringIsEmpty(buffer)) strcat(buffer, separator); - component_buffer.Format(_T("%u sec"), seconds); + component_buffer.Format("%u sec", seconds); strcat(buffer, component_buffer); } } diff --git a/src/Formatter/TimeFormatter.hpp b/src/Formatter/TimeFormatter.hpp index 684092e3c41..aff881d0d2e 100644 --- a/src/Formatter/TimeFormatter.hpp +++ b/src/Formatter/TimeFormatter.hpp @@ -89,12 +89,12 @@ FormatTimeTwoLines(char *buffer1, char *buffer2, void FormatTimespanSmart(char *buffer, std::chrono::seconds timespan, unsigned max_tokens = 1, - const char *separator = _T(" ")) noexcept; + const char *separator = " ") noexcept; [[gnu::const]] static inline BasicStringBuffer FormatTimespanSmart(std::chrono::seconds timespan, unsigned max_tokens = 1, - const char *separator = _T(" ")) noexcept + const char *separator = " ") noexcept { BasicStringBuffer buffer; FormatTimespanSmart(buffer.data(), timespan, max_tokens, separator); @@ -104,7 +104,7 @@ FormatTimespanSmart(std::chrono::seconds timespan, unsigned max_tokens = 1, [[gnu::const]] static inline auto FormatTimespanSmart(FloatDuration timespan, unsigned max_tokens = 1, - const char *separator = _T(" ")) noexcept + const char *separator = " ") noexcept { return FormatTimespanSmart(std::chrono::duration_cast(timespan), max_tokens, separator); diff --git a/src/Formatter/Units.cpp b/src/Formatter/Units.cpp index 0c5246051eb..54a1fd8c45f 100644 --- a/src/Formatter/Units.cpp +++ b/src/Formatter/Units.cpp @@ -17,10 +17,10 @@ FormatInteger(char *buffer, const int ivalue = iround(uvalue); if (include_unit) - StringFormatUnsafe(buffer, include_sign ? _T("%+d %s") : _T("%d %s"), + StringFormatUnsafe(buffer, include_sign ? "%+d %s" : "%d %s", ivalue, Units::GetUnitName(unit)); else - StringFormatUnsafe(buffer, include_sign ? _T("%+d") : _T("%d"), ivalue); + StringFormatUnsafe(buffer, include_sign ? "%+d" : "%d", ivalue); } void @@ -38,10 +38,10 @@ FormatWingLoading(char *buffer, double value, Unit unit, int precision = uvalue > 20 ? 0 : 1; if (include_unit) - _stprintf(buffer, _T("%.*f %s"), precision, (double)uvalue, + _stprintf(buffer, "%.*f %s", precision, (double)uvalue, Units::GetUnitName(unit)); else - _stprintf(buffer, _T("%.*f"), precision, (double)uvalue); + _stprintf(buffer, "%.*f", precision, (double)uvalue); } void @@ -65,10 +65,10 @@ FormatDistance(char *buffer, double value, Unit unit, value = Units::ToUserUnit(value, unit); if (include_unit) - StringFormatUnsafe(buffer, _T("%.*f %s"), precision, (double)value, + StringFormatUnsafe(buffer, "%.*f %s", precision, (double)value, Units::GetUnitName(unit)); else - StringFormatUnsafe(buffer, _T("%.*f"), precision, (double)value); + StringFormatUnsafe(buffer, "%.*f", precision, (double)value); } [[gnu::const]] @@ -96,10 +96,10 @@ FormatSmallDistance(char *buffer, double value, Unit unit, value = Units::ToUserUnit(value, unit); if (include_unit) - StringFormatUnsafe(buffer, _T("%.*f %s"), precision, (double)value, + StringFormatUnsafe(buffer, "%.*f %s", precision, (double)value, Units::GetUnitName(unit)); else - StringFormatUnsafe(buffer, _T("%.*f"), precision, (double)value); + StringFormatUnsafe(buffer, "%.*f", precision, (double)value); return unit; } @@ -147,10 +147,10 @@ FormatSpeed(char *buffer, const int prec = precision && value < 100; if (include_unit) - StringFormatUnsafe(buffer, _T("%.*f %s"), prec, (double)value, + StringFormatUnsafe(buffer, "%.*f %s", prec, (double)value, Units::GetUnitName(unit)); else - StringFormatUnsafe(buffer, _T("%.*f"), prec, (double)value); + StringFormatUnsafe(buffer, "%.*f", prec, (double)value); } const char* @@ -158,9 +158,9 @@ GetVerticalSpeedFormat(Unit unit, bool include_unit, bool include_sign) { static const char *const format[2][2][2]= { // 0 0 0 0 0 1 0 1 0 0 1 1 - { { _T("%.1f"), _T("%+.1f") }, { _T("%.1f %s"), _T("%+.1f %s") } }, + { { "%.1f", "%+.1f" }, { "%.1f %s", "%+.1f %s" } }, // 1 0 0 1 0 1 1 1 0 1 1 1 - { { _T("%.0f"), _T("%+.0f") }, { _T("%.0f %s"), _T("%+.0f %s") } } + { { "%.0f", "%+.0f" }, { "%.0f %s", "%+.0f %s" } } }; return format[unit == Unit::FEET_PER_MINUTE] @@ -204,10 +204,10 @@ FormatTemperature(char *buffer, double value, Unit unit, value = Units::ToUserUnit(value, unit); if (include_unit) - StringFormatUnsafe(buffer, _T("%.0f %s"), + StringFormatUnsafe(buffer, "%.0f %s", (double)value, Units::GetUnitName(unit)); else - StringFormatUnsafe(buffer, _T("%.0f"), (double)value); + StringFormatUnsafe(buffer, "%.0f", (double)value); } void @@ -229,9 +229,9 @@ const char* GetPressureFormat(Unit unit, bool include_unit) { if (include_unit) - return unit == Unit::INCH_MERCURY ? _T("%.2f %s") : _T("%.f %s"); + return unit == Unit::INCH_MERCURY ? "%.2f %s" : "%.f %s"; else - return unit == Unit::INCH_MERCURY ? _T("%.2f") : _T("%.f"); + return unit == Unit::INCH_MERCURY ? "%.2f" : "%.f"; } double diff --git a/src/Formatter/UserGeoPointFormatter.hpp b/src/Formatter/UserGeoPointFormatter.hpp index b92b2468ed4..e30b9c7ba54 100644 --- a/src/Formatter/UserGeoPointFormatter.hpp +++ b/src/Formatter/UserGeoPointFormatter.hpp @@ -35,11 +35,11 @@ bool FormatLatitude(Angle latitude, char *buffer, size_t size); * Convert a GeoPoint into a formatted string. */ char *FormatGeoPoint(const GeoPoint &location, char *buffer, size_t size, - char separator = _T(' ')); + char separator = ' '); [[gnu::pure]] static inline BasicStringBuffer -FormatGeoPoint(const GeoPoint &location, char separator = _T(' ')) +FormatGeoPoint(const GeoPoint &location, char separator = ' ') { BasicStringBuffer buffer; auto result = FormatGeoPoint(location, buffer.data(), buffer.capacity(), diff --git a/src/Gauge/BigTrafficWidget.cpp b/src/Gauge/BigTrafficWidget.cpp index 679e50da93f..3ed9eb35859 100644 --- a/src/Gauge/BigTrafficWidget.cpp +++ b/src/Gauge/BigTrafficWidget.cpp @@ -565,16 +565,16 @@ struct TrafficWidget::Windows { Windows(TrafficWidget &widget, ContainerWindow &parent, const PixelRect &r, const ButtonLook &button_look, const FlarmTrafficLook &flarm_look) - :zoom_in_button(MakeSymbolButton(parent, button_look, _T("+"), r, + :zoom_in_button(MakeSymbolButton(parent, button_look, "+", r, [&widget](){ widget.ZoomIn(); })), zoom_out_button(MakeSymbolButton(parent, button_look, - _T("-"), r, + "-", r, [&widget](){ widget.ZoomOut(); })), previous_item_button(MakeSymbolButton(parent, button_look, - _T("<"), r, + "<", r, [&widget](){ widget.PreviousTarget(); })), next_item_button(MakeSymbolButton(parent, button_look, - _T(">"), r, + ">", r, [&widget](){ widget.NextTarget(); })), details_button(parent, button_look, _("Details"), r, WindowStyle(), @@ -811,23 +811,23 @@ FlarmTrafficControl::OnMouseDouble([[maybe_unused]] PixelPoint p) noexcept bool FlarmTrafficControl::OnMouseGesture(const char* gesture) { - if (StringIsEqual(gesture, _T("U"))) { + if (StringIsEqual(gesture, "U")) { ZoomIn(); return true; } - if (StringIsEqual(gesture, _T("D"))) { + if (StringIsEqual(gesture, "D")) { ZoomOut(); return true; } - if (StringIsEqual(gesture, _T("UD"))) { + if (StringIsEqual(gesture, "UD")) { SetAutoZoom(true); return true; } - if (StringIsEqual(gesture, _T("DR"))) { + if (StringIsEqual(gesture, "DR")) { OpenDetails(); return true; } - if (StringIsEqual(gesture, _T("RL"))) { + if (StringIsEqual(gesture, "RL")) { SwitchData(); return true; } diff --git a/src/Gauge/FlarmTrafficWindow.cpp b/src/Gauge/FlarmTrafficWindow.cpp index 2f61b2b49cf..2c2eed11631 100644 --- a/src/Gauge/FlarmTrafficWindow.cpp +++ b/src/Gauge/FlarmTrafficWindow.cpp @@ -450,7 +450,7 @@ FlarmTrafficWindow::PaintTargetInfoSmall(Canvas &canvas, // Write the relativ altitude devided by 100 to the Buffer StaticString<10> buffer; - const auto relalt_s = buffer.Format(_T("%d"), abs(relalt)); + const auto relalt_s = buffer.Format("%d", abs(relalt)); // Select font canvas.SetBackgroundTransparent(); @@ -611,9 +611,9 @@ FlarmTrafficWindow::PaintNorth(Canvas &canvas) const noexcept const auto radar_mid = radar_renderer.GetCenter(); const PixelPoint q = radar_mid + iround(p * radar_renderer.GetRadius()); - PixelSize s = canvas.CalcTextSize(_T("N")); + PixelSize s = canvas.CalcTextSize("N"); canvas.DrawCircle(q, s.height * 0.65); - canvas.DrawText(q - s / 2u, _T("N")); + canvas.DrawText(q - s / 2u, "N"); } static void diff --git a/src/Gauge/GaugeThermalAssistant.cpp b/src/Gauge/GaugeThermalAssistant.cpp index 88966a3918f..d92d4175a12 100644 --- a/src/Gauge/GaugeThermalAssistant.cpp +++ b/src/Gauge/GaugeThermalAssistant.cpp @@ -81,7 +81,7 @@ GaugeThermalAssistantWindow::OnMouseUp([[maybe_unused]] PixelPoint p) noexcept ReleaseCapture(); if (was_pressed) - InputEvents::eventThermalAssistant(_T("")); + InputEvents::eventThermalAssistant(""); return true; } diff --git a/src/Gauge/GaugeVario.cpp b/src/Gauge/GaugeVario.cpp index 16b2e9ba4f2..e07c13ee580 100644 --- a/src/Gauge/GaugeVario.cpp +++ b/src/Gauge/GaugeVario.cpp @@ -14,8 +14,8 @@ static constexpr double DELTA_V_STEP = 4.0; static constexpr double DELTA_V_LIMIT = 16.0; -#define TEXT_BUG _T("Bug") -#define TEXT_BALLAST _T("Bal") +#define TEXT_BUG "Bug" +#define TEXT_BALLAST "Bal" inline GaugeVario::BallastGeometry::BallastGeometry(const VarioLook &look, @@ -56,7 +56,7 @@ GaugeVario::BallastGeometry::BallastGeometry(const VarioLook &look, look.text_font->GetCapitalHeight(); // get max value size - tSize = look.text_font->TextSize(_T("100%")); + tSize = look.text_font->TextSize("100%"); value_rect.right = value_rect.left + tSize.width; // update back rect with max label size @@ -96,7 +96,7 @@ GaugeVario::BugsGeometry::BugsGeometry(const VarioLook &look, + look.text_font->GetHeight() - look.text_font->GetAscentHeight(); - tSize = look.text_font->TextSize(_T("100%")); + tSize = look.text_font->TextSize("100%"); value_rect.right = value_rect.left + tSize.width; value_rect.bottom = value_rect.top + @@ -232,7 +232,7 @@ GaugeVario::RenderBackground(Canvas &canvas, const PixelRect &rc) noexcept geometry.offset)); char label[16]; - StringFormatUnsafe(label, _T("%d"), i * tick_value_step); + StringFormatUnsafe(label, "%d", i * tick_value_step); const auto label_size = canvas.CalcTextSize(label); @@ -258,14 +258,14 @@ GaugeVario::OnPaintBuffer(Canvas &canvas) noexcept // JMW averager now displays netto average if not circling RenderValue(canvas, geometry.average, average_di, Units::ToUserVSpeed(Calculated().circling ? Calculated().average : Calculated().netto_average), - Calculated().circling ? _T("Avg") : _T("NetAvg")); + Calculated().circling ? "Avg" : "NetAvg"); } if (Settings().show_mc) { auto mc = Units::ToUserVSpeed(GetGlidePolar().GetMC()); RenderValue(canvas, geometry.mc, mc_di, mc, - GetComputerSettings().task.auto_mc ? _T("Auto MC") : _T("MC")); + GetComputerSettings().task.auto_mc ? "Auto MC" : "MC"); } if (Settings().show_speed_to_fly) @@ -336,7 +336,7 @@ GaugeVario::OnPaintBuffer(Canvas &canvas) noexcept RenderValue(canvas, geometry.gross, gross_di, vvaldisplay, - _T("Gross")); + "Gross"); } RenderZero(canvas); @@ -517,7 +517,7 @@ GaugeVario::RenderValue(Canvas &canvas, const LabelValueGeometry &g, char buffer[18]; canvas.SetBackgroundColor(look.background_color); canvas.SetTextColor(look.text_color); - _stprintf(buffer, _T("%.1f"), (double)value); + _stprintf(buffer, "%.1f", (double)value); canvas.Select(look.value_font); const unsigned width = canvas.CalcTextSize(buffer).width; @@ -704,7 +704,7 @@ GaugeVario::RenderBallast(Canvas &canvas) noexcept // new ballast 0, hide value if (ballast > 0) { char buffer[18]; - _stprintf(buffer, _T("%u%%"), ballast); + _stprintf(buffer, "%u%%", ballast); canvas.SetTextColor(look.text_color); if (IsPersistent()) @@ -747,7 +747,7 @@ GaugeVario::RenderBugs(Canvas &canvas) noexcept if (bugs > 0) { char buffer[18]; - _stprintf(buffer, _T("%d%%"), bugs); + _stprintf(buffer, "%d%%", bugs); canvas.SetTextColor(look.text_color); if (IsPersistent()) canvas.DrawOpaqueText(g.value_pos, g.value_rect, buffer); diff --git a/src/InfoBoxes/Content/Alternate.cpp b/src/InfoBoxes/Content/Alternate.cpp index bdfcce7af8e..f8fe8c717f3 100644 --- a/src/InfoBoxes/Content/Alternate.cpp +++ b/src/InfoBoxes/Content/Alternate.cpp @@ -101,7 +101,7 @@ InfoBoxContentAlternateGR::Update(InfoBoxData &data) noexcept alternate = NULL; } - data.FmtTitle(_T("Altn {} GR"), index + 1); + data.FmtTitle("Altn {} GR", index + 1); if (alternate == NULL) { data.SetInvalid(); @@ -115,7 +115,7 @@ InfoBoxContentAlternateGR::Update(InfoBoxData &data) noexcept if (gradient < 0) { data.SetValueColor(0); - data.SetValue(_T("+++")); + data.SetValue("+++"); return; } if (::GradientValid(gradient)) { diff --git a/src/InfoBoxes/Content/Altitude.cpp b/src/InfoBoxes/Content/Altitude.cpp index 88e0d56226a..55c23ea5845 100644 --- a/src/InfoBoxes/Content/Altitude.cpp +++ b/src/InfoBoxes/Content/Altitude.cpp @@ -148,10 +148,10 @@ UpdateInfoBoxAltitudeFlightLevel(InfoBoxData &data) noexcept data.SetTitleColor(0); // Set Value - data.FmtValue(_T("{:03}"), iround(Altitude / 100)); + data.FmtValue("{:03}", iround(Altitude / 100)); // Set Comment - data.FmtComment(_T("{}ft"), iround(Altitude)); + data.FmtComment("{}ft", iround(Altitude)); } else if (basic.gps_altitude_available && settings_computer.pressure_available) { @@ -163,10 +163,10 @@ UpdateInfoBoxAltitudeFlightLevel(InfoBoxData &data) noexcept data.SetTitleColor(1); // Set Value - data.FmtValue(_T("{:03}"), iround(Altitude / 100)); + data.FmtValue("{:03}", iround(Altitude / 100)); // Set Comment - data.FmtComment(_T("{}ft"), iround(Altitude)); + data.FmtComment("{}ft", iround(Altitude)); } else if ((basic.baro_altitude_available || basic.gps_altitude_available) && !settings_computer.pressure_available) { diff --git a/src/InfoBoxes/Content/Contest.cpp b/src/InfoBoxes/Content/Contest.cpp index 35c1bbea3fa..c922f5cab76 100644 --- a/src/InfoBoxes/Content/Contest.cpp +++ b/src/InfoBoxes/Content/Contest.cpp @@ -71,7 +71,7 @@ InfoBoxContentContest::Update(InfoBoxData &data) noexcept // Set Value data.SetValueFromDistance(result_contest.distance); - data.FmtComment(_T("{:.1f} pts"), result_contest.score); + data.FmtComment("{:.1f} pts", result_contest.score); } const InfoBoxPanel * @@ -106,5 +106,5 @@ InfoBoxContentContestSpeed::Update(InfoBoxData &data) noexcept // Set Value data.SetValueFromTaskSpeed(result_contest.GetSpeed()); - data.FmtComment(_T("{:.1f} pts"), result_contest.score); + data.FmtComment("{:.1f} pts", result_contest.score); } diff --git a/src/InfoBoxes/Content/Engine.cpp b/src/InfoBoxes/Content/Engine.cpp index ff5d33899d1..b4d28842e65 100644 --- a/src/InfoBoxes/Content/Engine.cpp +++ b/src/InfoBoxes/Content/Engine.cpp @@ -21,7 +21,7 @@ UpdateInfoBoxContentCHT(InfoBoxData &data) noexcept return; } - data.FmtValue(_T("{:3.0f}"), basic.engine.cht_temperature.ToUser()); + data.FmtValue("{:3.0f}", basic.engine.cht_temperature.ToUser()); data.SetValueUnit(Units::current.temperature_unit); } @@ -35,7 +35,7 @@ UpdateInfoBoxContentEGT(InfoBoxData &data) noexcept return; } - data.FmtValue(_T("{:3.0f}"), basic.engine.egt_temperature.ToUser()); + data.FmtValue("{:3.0f}", basic.engine.egt_temperature.ToUser()); data.SetValueUnit(Units::current.temperature_unit); } @@ -49,6 +49,6 @@ UpdateInfoBoxContentRPM(InfoBoxData &data) noexcept return; } - data.FmtValue(_T("{}"), Units::ToUserRotation(basic.engine.revolutions_per_second)); + data.FmtValue("{}", Units::ToUserRotation(basic.engine.revolutions_per_second)); data.SetValueUnit(Units::current.rotation_unit); } diff --git a/src/InfoBoxes/Content/Factory.cpp b/src/InfoBoxes/Content/Factory.cpp index 2f1952f7c06..4452c9256f5 100644 --- a/src/InfoBoxes/Content/Factory.cpp +++ b/src/InfoBoxes/Content/Factory.cpp @@ -273,9 +273,9 @@ static constexpr MetaData meta_data[] = { // e_Fin_GR_TE { - _T("Final GR (TE) deprecated"), - _T("---"), - _T("Deprecated, there is no TE compensation on GR, you should switch to the \"Final GR\" info box."), + "Final GR (TE) deprecated", + "---", + "Deprecated, there is no TE compensation on GR, you should switch to the \"Final GR\" info box.", UpdateInfoBoxFinalGR, }, diff --git a/src/InfoBoxes/Content/Glide.cpp b/src/InfoBoxes/Content/Glide.cpp index 7f606fc9682..f5ec5fc0ac4 100644 --- a/src/InfoBoxes/Content/Glide.cpp +++ b/src/InfoBoxes/Content/Glide.cpp @@ -55,9 +55,9 @@ UpdateInfoBoxGRAvg(InfoBoxData &data) noexcept // Set Value if (average_gr < 0) - data.SetValue(_T("^^^")); + data.SetValue("^^^"); else if (!::GradientValid(average_gr)) - data.SetValue(_T("+++")); + data.SetValue("+++"); else data.SetValueFromGlideRatio(average_gr); } diff --git a/src/InfoBoxes/Content/MacCready.cpp b/src/InfoBoxes/Content/MacCready.cpp index 9da4e5c0cac..d06061706a1 100644 --- a/src/InfoBoxes/Content/MacCready.cpp +++ b/src/InfoBoxes/Content/MacCready.cpp @@ -18,7 +18,7 @@ SetVSpeed(InfoBoxData &data, double value) noexcept { char buffer[32]; FormatUserVerticalSpeed(value, buffer, false); - data.SetValue(buffer[0] == _T('+') ? buffer + 1 : buffer); + data.SetValue(buffer[0] == '+' ? buffer + 1 : buffer); data.SetValueUnit(Units::current.vertical_speed_unit); } diff --git a/src/InfoBoxes/Content/Other.cpp b/src/InfoBoxes/Content/Other.cpp index 32d2360b307..4f5a8219892 100644 --- a/src/InfoBoxes/Content/Other.cpp +++ b/src/InfoBoxes/Content/Other.cpp @@ -27,7 +27,7 @@ UpdateInfoBoxHeartRate(InfoBoxData &data) noexcept return; } - data.FmtValue(_T("{}"), basic.heart_rate); + data.FmtValue("{}", basic.heart_rate); } void @@ -39,7 +39,7 @@ UpdateInfoBoxGLoad(InfoBoxData &data) noexcept } // Set Value - data.FmtValue(_T("{:2.2f}"), CommonInterface::Basic().acceleration.g_load); + data.FmtValue("{:2.2f}", CommonInterface::Basic().acceleration.g_load); } void @@ -54,7 +54,7 @@ UpdateInfoBoxBattery(InfoBoxData &data) noexcept switch (external.status) { case Power::ExternalInfo::Status::OFF: if (CommonInterface::Basic().battery_level_available) - data.FmtComment(_T("{}; {}%"), + data.FmtComment("{}; {}%", _("AC Off"), (int)CommonInterface::Basic().battery_level); else @@ -187,7 +187,7 @@ UpdateInfoBoxNbrSat(InfoBoxData &data) noexcept data.SetComment(_("No GPS")); else if (gps.satellites_used_available) { // known number of sats - data.FmtValue(_T("{}"), gps.satellites_used); + data.FmtValue("{}", gps.satellites_used); } else { // valid but unknown number of sats data.SetValueInvalid(); diff --git a/src/InfoBoxes/Content/Task.cpp b/src/InfoBoxes/Content/Task.cpp index eac4f88949f..9da4e18b2f0 100644 --- a/src/InfoBoxes/Content/Task.cpp +++ b/src/InfoBoxes/Content/Task.cpp @@ -122,7 +122,7 @@ InfoBoxContentNextWaypoint::Update(InfoBoxData &data) noexcept // Set Comment if (way_point->radio_frequency.IsDefined()) { const unsigned freq = way_point->radio_frequency.GetKiloHertz(); - data.FmtComment(_T("{}.{:03} {}"), + data.FmtComment("{}.{:03} {}", freq / 1000, freq % 1000, way_point->comment); } else @@ -254,10 +254,10 @@ UpdateInfoBoxNextETA(InfoBoxData &data) noexcept std::chrono::duration_cast(task_stats.current_leg.solution_remaining.time_elapsed); // Set Value - data.FmtValue(_T("{:02}:{:02}"), t.hour, t.minute); + data.FmtValue("{:02}:{:02}", t.hour, t.minute); // Set Comment - data.FmtComment(_T("{:02}"), t.second); + data.FmtComment("{:02}", t.second); } static void @@ -342,7 +342,7 @@ UpdateInfoBoxNextGR(InfoBoxData &data) noexcept auto gradient = CommonInterface::Calculated().task_stats.current_leg.gradient; if (gradient <= 0) { - data.SetValue(_T("+++")); + data.SetValue("+++"); return; } if (::GradientValid(gradient)) { @@ -402,10 +402,10 @@ UpdateInfoBoxFinalETA(InfoBoxData &data) noexcept std::chrono::duration_cast(task_stats.total.solution_remaining.time_elapsed); // Set Value - data.FmtValue(_T("{:02}:{:02}"), t.hour, t.minute); + data.FmtValue("{:02}:{:02}", t.hour, t.minute); // Set Comment - data.FmtComment(_T("{:02}"), t.second); + data.FmtComment("{:02}", t.second); } void @@ -508,7 +508,7 @@ UpdateInfoBoxFinalGR(InfoBoxData &data) noexcept auto gradient = task_stats.total.gradient; if (gradient <= 0) { - data.SetValue(_T("+++")); + data.SetValue("+++"); return; } if (::GradientValid(gradient)) @@ -723,8 +723,8 @@ UpdateInfoBoxNextETAVMG(InfoBoxData &data) noexcept if (now_local.IsPlausible()) { const std::chrono::seconds dd{long(d/v)}; const BrokenTime t = now_local + dd; - data.FmtValue(_T("{:02}:{:02}"), t.hour, t.minute); - data.FmtComment(_T("{:02}"), t.second); + data.FmtValue("{:02}:{:02}", t.hour, t.minute); + data.FmtComment("{:02}", t.second); } } @@ -803,7 +803,7 @@ UpdateInfoBoxStartOpen(InfoBoxData &data) noexcept } else if (open.HasBegun(now)) { if (open.GetEnd().IsValid()) { unsigned seconds = SecondsUntil(now_s, open.GetEnd()); - data.FmtValue(_T("{:02}:{:02}"), seconds / 60, seconds % 60); + data.FmtValue("{:02}:{:02}", seconds / 60, seconds % 60); data.SetValueColor(3); } else data.SetValueInvalid(); @@ -811,7 +811,7 @@ UpdateInfoBoxStartOpen(InfoBoxData &data) noexcept data.SetComment(_("Open")); } else { unsigned seconds = SecondsUntil(now_s, open.GetStart()); - data.FmtValue(_T("{:02}:{:02}"), seconds / 60, seconds % 60); + data.FmtValue("{:02}:{:02}", seconds / 60, seconds % 60); data.SetValueColor(2); data.SetComment(_("Waiting")); } @@ -848,7 +848,7 @@ UpdateInfoBoxStartOpenArrival(InfoBoxData &data) noexcept } else if (open.HasBegun(arrival)) { if (open.GetEnd().IsValid()) { unsigned seconds = SecondsUntil(arrival_s, open.GetEnd()); - data.FmtValue(_T("{:02}:{:02}"), seconds / 60, seconds % 60); + data.FmtValue("{:02}:{:02}", seconds / 60, seconds % 60); data.SetValueColor(3); } else data.SetValueInvalid(); @@ -856,7 +856,7 @@ UpdateInfoBoxStartOpenArrival(InfoBoxData &data) noexcept data.SetComment(_("Open")); } else { unsigned seconds = SecondsUntil(arrival_s, open.GetStart()); - data.FmtValue(_T("{:02}:{:02}"), seconds / 60, seconds % 60); + data.FmtValue("{:02}:{:02}", seconds / 60, seconds % 60); data.SetValueColor(2); data.SetComment(_("Waiting")); } @@ -946,7 +946,7 @@ UpdateInfoTaskETAorAATdT(InfoBoxData& data) noexcept UpdateInfoBoxTaskAATimeDelta(data); data.SetComment(eta_text); - data.SetTitle(_T("AAT delta time")); + data.SetTitle("AAT delta time"); } else - data.SetTitle(_T("Task arrival time")); + data.SetTitle("Task arrival time"); } diff --git a/src/InfoBoxes/Content/Team.cpp b/src/InfoBoxes/Content/Team.cpp index e097327b658..1ff425093b3 100644 --- a/src/InfoBoxes/Content/Team.cpp +++ b/src/InfoBoxes/Content/Team.cpp @@ -115,7 +115,7 @@ UpdateInfoBoxTeamBearing(InfoBoxData &data) noexcept else if (!settings.team_flarm_callsign.empty()) data.SetComment(settings.team_flarm_callsign.c_str()); else - data.SetComment(_T("???")); + data.SetComment("???"); if (flarm.FindTraffic(settings.team_flarm_id) != NULL) data.SetCommentColor(2); @@ -145,7 +145,7 @@ UpdateInfoBoxTeamBearingDiff(InfoBoxData &data) noexcept else if (!StringIsEmpty(settings.team_flarm_callsign)) data.SetComment(settings.team_flarm_callsign); else - data.SetComment(_T("???")); + data.SetComment("???"); if (flarm.FindTraffic(settings.team_flarm_id) != NULL) data.SetCommentColor(2); @@ -172,7 +172,7 @@ UpdateInfoBoxTeamDistance(InfoBoxData &data) noexcept else if (!StringIsEmpty(settings.team_flarm_callsign)) data.SetComment(settings.team_flarm_callsign); else - data.SetComment(_T("???")); + data.SetComment("???"); data.SetCommentColor(teamcode_info.flarm_teammate_code_current ? 2 : 1); } diff --git a/src/InfoBoxes/Content/Thermal.cpp b/src/InfoBoxes/Content/Thermal.cpp index 9766233bf76..823b89e6b75 100644 --- a/src/InfoBoxes/Content/Thermal.cpp +++ b/src/InfoBoxes/Content/Thermal.cpp @@ -18,7 +18,7 @@ SetVSpeed(InfoBoxData &data, double value) noexcept { char buffer[32]; FormatUserVerticalSpeed(value, buffer, false); - data.SetValue(buffer[0] == _T('+') ? buffer + 1 : buffer); + data.SetValue(buffer[0] == '+' ? buffer + 1 : buffer); data.SetValueUnit(Units::current.vertical_speed_unit); } @@ -219,7 +219,7 @@ UpdateInfoBoxCircleDiameter(InfoBoxData &data) noexcept Angle::FullCircle().Native() / turn_rate.Native(); StaticString<16> duration_buffer; - duration_buffer.Format(_T("%u s"), int(circle_duration)); + duration_buffer.Format("%u s", int(circle_duration)); strcpy (buffer, duration_buffer); data.SetComment (buffer); } diff --git a/src/InfoBoxes/Content/Time.cpp b/src/InfoBoxes/Content/Time.cpp index bd6bb96aca9..c7fa0f376e3 100644 --- a/src/InfoBoxes/Content/Time.cpp +++ b/src/InfoBoxes/Content/Time.cpp @@ -24,7 +24,7 @@ UpdateInfoBoxTimeLocal(InfoBoxData &data) noexcept FormatLocalTimeHHMM(data.value.buffer(), basic.time, settings.utc_offset); // Set Comment - data.FmtComment(_T("{:02}"), basic.date_time_utc.second); + data.FmtComment("{:02}", basic.date_time_utc.second); } void @@ -39,10 +39,10 @@ UpdateInfoBoxTimeUTC(InfoBoxData &data) noexcept // Set Value const BrokenDateTime t = basic.date_time_utc; - data.FmtValue(_T("{:02}:{:02}"), t.hour, t.minute); + data.FmtValue("{:02}:{:02}", t.hour, t.minute); // Set Comment - data.FmtComment(_T("{:02}"), t.second); + data.FmtComment("{:02}", t.second); } void diff --git a/src/InfoBoxes/Content/Weather.cpp b/src/InfoBoxes/Content/Weather.cpp index a2395ff3401..1fa72a68dc9 100644 --- a/src/InfoBoxes/Content/Weather.cpp +++ b/src/InfoBoxes/Content/Weather.cpp @@ -29,7 +29,7 @@ UpdateInfoBoxHumidity(InfoBoxData &data) noexcept } // Set Value - data.FmtValue( _T("{}"), (int)basic.humidity); + data.FmtValue( "{}", (int)basic.humidity); } void @@ -42,7 +42,7 @@ UpdateInfoBoxTemperature(InfoBoxData &data) noexcept } // Set Value - data.FmtValue(_T("{:2.1f}"), basic.temperature.ToUser()); + data.FmtValue("{:2.1f}", basic.temperature.ToUser()); data.SetValueUnit(Units::current.temperature_unit); } @@ -51,7 +51,7 @@ void InfoBoxContentTemperatureForecast::Update(InfoBoxData &data) noexcept { auto temperature = CommonInterface::GetComputerSettings().forecast_temperature; - data.FmtValue(_T("{:2.1f}"), temperature.ToUser()); + data.FmtValue("{:2.1f}", temperature.ToUser()); data.SetValueUnit(Units::current.temperature_unit); } @@ -104,7 +104,7 @@ UpdateInfoBoxWindSpeed(InfoBoxData &data) noexcept } // Set Value - data.FmtValue(_T("{:2.0f}"), Units::ToUserWindSpeed(info.wind.norm)); + data.FmtValue("{:2.0f}", Units::ToUserWindSpeed(info.wind.norm)); // Set Unit data.SetValueUnit(Units::current.wind_speed_unit); @@ -137,7 +137,7 @@ void UpdateInfoBoxInstWindSpeed(InfoBoxData &data) noexcept { } // Set Value - data.FmtValue(_T("{:2.0f}"), + data.FmtValue("{:2.0f}", Units::ToUserWindSpeed(info.external_instantaneous_wind.norm)); // Set Unit @@ -173,7 +173,7 @@ UpdateInfoBoxHeadWind(InfoBoxData &data) noexcept } // Set Value - data.FmtValue(_T("{:2.0f}"), Units::ToUserWindSpeed(info.head_wind)); + data.FmtValue("{:2.0f}", Units::ToUserWindSpeed(info.head_wind)); // Set Unit data.SetValueUnit(Units::current.wind_speed_unit); @@ -191,7 +191,7 @@ UpdateInfoBoxHeadWindSimplified(InfoBoxData &data) noexcept auto value = basic.true_airspeed - basic.ground_speed; // Set Value - data.FmtValue(_T("{:2.0f}"), Units::ToUserWindSpeed(value)); + data.FmtValue("{:2.0f}", Units::ToUserWindSpeed(value)); // Set Unit data.SetValueUnit(Units::current.wind_speed_unit); @@ -214,7 +214,7 @@ InfoBoxContentWindArrow::Update(InfoBoxData &data) noexcept FormatUserWindSpeed(info.wind.norm, speed_buffer, true, false); StaticString<36> buffer; - buffer.Format(_T("%s / %s"), + buffer.Format("%s / %s", FormatBearing(info.wind.bearing).c_str(), speed_buffer); data.SetComment(buffer); diff --git a/src/InfoBoxes/Data.cpp b/src/InfoBoxes/Data.cpp index 395b4adc2d2..1dfbd8da557 100644 --- a/src/InfoBoxes/Data.cpp +++ b/src/InfoBoxes/Data.cpp @@ -24,7 +24,7 @@ void InfoBoxData::SetValueInvalid() noexcept { SetValueColor(0); - SetValue(_T("---")); + SetValue("---"); SetValueUnit(Unit::UNDEFINED); } diff --git a/src/InfoBoxes/Data.hpp b/src/InfoBoxes/Data.hpp index 14905531333..60a125b0301 100644 --- a/src/InfoBoxes/Data.hpp +++ b/src/InfoBoxes/Data.hpp @@ -128,7 +128,7 @@ struct InfoBoxData { /** * Sets the InfoBox value to the given angle. */ - void SetValue(Angle value, const char *suffix=_T("")) noexcept; + void SetValue(Angle value, const char *suffix="") noexcept; void SetValueFromBearingDifference(Angle delta) noexcept; @@ -199,7 +199,7 @@ struct InfoBoxData { /** * Sets the InfoBox comment to the given angle. */ - void SetComment(Angle comment, const char *suffix=_T("")) noexcept; + void SetComment(Angle comment, const char *suffix="") noexcept; void SetCommentFromDistance(double value) noexcept; diff --git a/src/InfoBoxes/Format.cpp b/src/InfoBoxes/Format.cpp index 076de9a9a38..ff899dc6835 100644 --- a/src/InfoBoxes/Format.cpp +++ b/src/InfoBoxes/Format.cpp @@ -51,19 +51,19 @@ InfoBoxData::SetValueFromTimeTwoLines(std::chrono::seconds dd) noexcept void InfoBoxData::SetValueFromPercent(double dd) noexcept { - FmtValue(_T("{}"), (int)dd); + FmtValue("{}", (int)dd); SetValueUnit(Unit::PERCENT); } void InfoBoxData::SetCommentFromPercent(double dd) noexcept { - FmtComment(_T("{} %"), (int)(dd)); + FmtComment("{} %", (int)(dd)); } void InfoBoxData::SetValueFromVoltage(double dd) noexcept { - FmtValue(_T("{:2.1f}"), dd); + FmtValue("{:2.1f}", dd); SetValueUnit(Unit::VOLT); } diff --git a/src/InfoBoxes/InfoBoxManager.cpp b/src/InfoBoxes/InfoBoxManager.cpp index 56cdae0ba0e..6ff2ec2c2e1 100644 --- a/src/InfoBoxes/InfoBoxManager.cpp +++ b/src/InfoBoxes/InfoBoxManager.cpp @@ -206,7 +206,7 @@ InfoBoxManager::ShowInfoBoxPicker(const int i) noexcept /* let the user select */ StaticString<20> caption; - caption.Format(_T("%s: %d"), _("InfoBox"), i + 1); + caption.Format("%s: %d", _("InfoBox"), i + 1); int result = ComboPicker(caption, list, nullptr, true); if (result < 0) return; diff --git a/src/InfoBoxes/InfoBoxSettings.cpp b/src/InfoBoxes/InfoBoxSettings.cpp index 0e0fbe5778a..b4ef74f74f1 100644 --- a/src/InfoBoxes/InfoBoxSettings.cpp +++ b/src/InfoBoxes/InfoBoxSettings.cpp @@ -60,7 +60,7 @@ InfoBoxSettings::SetDefaults() noexcept panels[2].name = N_("FinalGlide"); for (unsigned i = PREASSIGNED_PANELS; i < MAX_PANELS; i++) - panels[i].name.Format(_T("AUX-%u"), i-2); + panels[i].name.Format("AUX-%u", i-2); for (unsigned i = 0; i < DFLT_CONFIG_PANELS; i++) for (unsigned j = 0; j < DFLT_CONFIG_BOXES; j++) diff --git a/src/InfoBoxes/Panel/ATCReference.cpp b/src/InfoBoxes/Panel/ATCReference.cpp index c27db49b34b..e6aed7104b3 100644 --- a/src/InfoBoxes/Panel/ATCReference.cpp +++ b/src/InfoBoxes/Panel/ATCReference.cpp @@ -41,7 +41,7 @@ ATCReferencePanel::UpdateValues() noexcept ? data_components->waypoints->GetNearest(location, 100) : nullptr; - SetText(WAYPOINT, waypoint != nullptr ? waypoint->name.c_str() : _T("---")); + SetText(WAYPOINT, waypoint != nullptr ? waypoint->name.c_str() : "---"); const char *location_string; char buffer[64]; @@ -50,7 +50,7 @@ ATCReferencePanel::UpdateValues() noexcept CommonInterface::GetUISettings().format.coordinate_format); location_string = buffer; } else - location_string = _T("---"); + location_string = "---"; SetText(LOCATION, location_string); } diff --git a/src/InfoBoxes/Panel/ATCSetup.cpp b/src/InfoBoxes/Panel/ATCSetup.cpp index aa8157c3afe..4d616eb298f 100644 --- a/src/InfoBoxes/Panel/ATCSetup.cpp +++ b/src/InfoBoxes/Panel/ATCSetup.cpp @@ -34,7 +34,7 @@ ATCSetupPanel::Prepare(ContainerWindow &parent, AddFloat(_("Mag declination"), _("Magnetic declination used to calculate radial to reference. Negative values are W declination, positive is E."), - _T("%.0f°"), _T("%.0f°"), // unfortunately AngleDataField does not + "%.0f°", "%.0f°", // unfortunately AngleDataField does not -30.0, +30.0, 1.0, false, // support negative values to handle declination.Degrees(), // this formatting more gracefully this); diff --git a/src/InfoBoxes/Panel/AltitudeSimulator.cpp b/src/InfoBoxes/Panel/AltitudeSimulator.cpp index 5c498120fbf..b1ef1d19479 100644 --- a/src/InfoBoxes/Panel/AltitudeSimulator.cpp +++ b/src/InfoBoxes/Panel/AltitudeSimulator.cpp @@ -39,6 +39,6 @@ LoadAltitudeSimulatorPanel([[maybe_unused]] unsigned id) return nullptr; return std::make_unique(UIGlobals::GetDialogLook().button, - _T("%+.0f"), + "%+.0f", 10, 100); } diff --git a/src/InfoBoxes/Panel/RadioEdit.cpp b/src/InfoBoxes/Panel/RadioEdit.cpp index 0a88320dfd2..0617bd1980a 100644 --- a/src/InfoBoxes/Panel/RadioEdit.cpp +++ b/src/InfoBoxes/Panel/RadioEdit.cpp @@ -11,7 +11,7 @@ class RadioOffsetButtons final : public OffsetButtonsWidget { public: RadioOffsetButtons(bool active_freq) noexcept - :OffsetButtonsWidget(UIGlobals::GetDialogLook().button, _T("%.0f kHz"), 5, 1000),set_active_freq(active_freq) {} + :OffsetButtonsWidget(UIGlobals::GetDialogLook().button, "%.0f kHz", 5, 1000),set_active_freq(active_freq) {} protected: /* virtual methods from OffsetButtonsWidget */ diff --git a/src/Input/InputConfig.cpp b/src/Input/InputConfig.cpp index c956cf1d03c..2b6ef16ec17 100644 --- a/src/Input/InputConfig.cpp +++ b/src/Input/InputConfig.cpp @@ -14,10 +14,10 @@ void InputConfig::SetDefaults() noexcept { modes.resize(4); - modes[0] = _T("default"); - modes[1] = _T("pan"); - modes[2] = _T("infobox"); - modes[3] = _T("Menu"); + modes[0] = "default"; + modes[1] = "pan"; + modes[2] = "infobox"; + modes[3] = "Menu"; std::fill_n(&Key2Event[0][0], MAX_MODE*MAX_KEY, 0); #ifdef ENABLE_SDL diff --git a/src/Input/InputEvents.cpp b/src/Input/InputEvents.cpp index 5a516e08f83..52fd30fc8cb 100644 --- a/src/Input/InputEvents.cpp +++ b/src/Input/InputEvents.cpp @@ -230,7 +230,7 @@ InputEvents::UpdateOverlayMode() noexcept /* build the "flavoured" mode name from the current "major" mode and the flavour name */ StaticString name; - name.Format(_T("%s.%s"), input_config.modes[current_mode].c_str(), + name.Format("%s.%s", input_config.modes[current_mode].c_str(), flavour); /* see if it exists */ diff --git a/src/Input/InputEventsActions.cpp b/src/Input/InputEventsActions.cpp index 4f3d9b83238..97db9aa60e6 100644 --- a/src/Input/InputEventsActions.cpp +++ b/src/Input/InputEventsActions.cpp @@ -152,7 +152,7 @@ InputEvents::eventMarkLocation(const char *misc) { const NMEAInfo &basic = CommonInterface::Basic(); - if (StringIsEqual(misc, _T("reset"))) { + if (StringIsEqual(misc, "reset")) { ScopeSuspendAllThreads suspend; data_components->waypoints->EraseUserMarkers(); } else { @@ -167,10 +167,10 @@ InputEvents::eventMarkLocation(const char *misc) Waypoint wp = factory.Create(location); factory.FallbackElevation(wp); - char name[64] = _T("Marker"); + char name[64] = "Marker"; if (basic.date_time_utc.IsPlausible()) { auto *p = name + StringLength(name); - *p++ = _T(' ' ); + *p++ = ' ' ; FormatISO8601(p, basic.date_time_utc); } @@ -180,7 +180,7 @@ InputEvents::eventMarkLocation(const char *misc) SuspendAppendSaveWaypoint(std::move(wp)); if (CommonInterface::GetUISettings().sound.sound_modes_enabled) - PlayResource(_T("IDR_WAV_CLEAR")); + PlayResource("IDR_WAV_CLEAR"); } trigger_redraw(); @@ -238,27 +238,27 @@ InputEvents::eventScreenModes(const char *misc) const UIState &ui_state = CommonInterface::GetUIState(); - if (StringIsEqual(misc, _T("normal"))) { + if (StringIsEqual(misc, "normal")) { PageActions::OpenLayout(PageLayout::Default()); - } else if (StringIsEqual(misc, _T("auxilary"))) { + } else if (StringIsEqual(misc, "auxilary")) { PageActions::OpenLayout(PageLayout::Aux()); - } else if (StringIsEqual(misc, _T("toggleauxiliary"))) { + } else if (StringIsEqual(misc, "toggleauxiliary")) { PageActions::OpenLayout(ui_state.auxiliary_enabled ? PageLayout::Default() : PageLayout::Aux()); - } else if (StringIsEqual(misc, _T("full"))) { + } else if (StringIsEqual(misc, "full")) { PageActions::OpenLayout(PageLayout::FullScreen()); - } else if (StringIsEqual(misc, _T("togglefull"))) { + } else if (StringIsEqual(misc, "togglefull")) { CommonInterface::main_window->SetFullScreen( !CommonInterface::main_window->GetFullScreen()); - } else if (StringIsEqual(misc, _T("show"))) { + } else if (StringIsEqual(misc, "show")) { if (CommonInterface::main_window->GetFullScreen()) Message::AddMessage(_("Screen Mode Full")); else if (ui_state.auxiliary_enabled) Message::AddMessage(_("Auxiliary InfoBoxes")); else Message::AddMessage(_("Default InfoBoxes")); - } else if (StringIsEqual(misc, _T("previous"))) + } else if (StringIsEqual(misc, "previous")) PageActions::Prev(); else PageActions::Next(); @@ -316,11 +316,11 @@ InputEvents::eventChecklist([[maybe_unused]] const char *misc) void InputEvents::eventStatus(const char *misc) { - if (StringIsEqual(misc, _T("system"))) { + if (StringIsEqual(misc, "system")) { dlgStatusShowModal(1); - } else if (StringIsEqual(misc, _T("task"))) { + } else if (StringIsEqual(misc, "task")) { dlgStatusShowModal(2); - } else if (StringIsEqual(misc, _T("aircraft"))) { + } else if (StringIsEqual(misc, "aircraft")) { dlgStatusShowModal(0); } else { dlgStatusShowModal(-1); @@ -358,7 +358,7 @@ InputEvents::eventWaypointDetails(const char *misc) bool allow_navigation = true; bool allow_edit = true; - if (StringIsEqual(misc, _T("current"))) { + if (StringIsEqual(misc, "current")) { if (!backend_components->protected_task_manager) return; @@ -374,7 +374,7 @@ InputEvents::eventWaypointDetails(const char *misc) editor doesn't know how to do that */ allow_navigation = false; allow_edit = false; - } else if (StringIsEqual(misc, _T("select"))) { + } else if (StringIsEqual(misc, "select")) { wp = ShowWaypointListDialog(*data_components->waypoints, basic.location); } if (wp) @@ -420,7 +420,7 @@ InputEvents::eventAutoLogger(const char *misc) return; if (auto_logger == LoggerSettings::AutoLogger::START_ONLY && - !StringIsEqual(misc, _T("start"))) + !StringIsEqual(misc, "start")) return; eventLogger(misc); @@ -451,38 +451,38 @@ try { const ComputerSettings &settings_computer = CommonInterface::GetComputerSettings(); - if (StringIsEqual(misc, _T("start ask"))) + if (StringIsEqual(misc, "start ask")) logger->GUIStartLogger(basic, settings_computer, backend_components->protected_task_manager.get()); - else if (StringIsEqual(misc, _T("start"))) + else if (StringIsEqual(misc, "start")) logger->GUIStartLogger(basic, settings_computer, backend_components->protected_task_manager.get(), true); - else if (StringIsEqual(misc, _T("stop ask"))) + else if (StringIsEqual(misc, "stop ask")) logger->GUIStopLogger(basic); - else if (StringIsEqual(misc, _T("stop"))) + else if (StringIsEqual(misc, "stop")) logger->GUIStopLogger(basic, true); - else if (StringIsEqual(misc, _T("toggle ask"))) + else if (StringIsEqual(misc, "toggle ask")) logger->GUIToggleLogger(basic, settings_computer, backend_components->protected_task_manager.get()); - else if (StringIsEqual(misc, _T("toggle"))) + else if (StringIsEqual(misc, "toggle")) logger->GUIToggleLogger(basic, settings_computer, backend_components->protected_task_manager.get(), true); - else if (StringIsEqual(misc, _T("nmea"))) { + else if (StringIsEqual(misc, "nmea")) { backend_components->nmea_logger->ToggleEnabled(); if (backend_components->nmea_logger->IsEnabled()) { Message::AddMessage(_("NMEA log on")); } else { Message::AddMessage(_("NMEA log off")); } - } else if (StringIsEqual(misc, _T("show"))) + } else if (StringIsEqual(misc, "show")) if (logger->IsLoggerActive()) { Message::AddMessage(_("Logger on")); } else { Message::AddMessage(_("Logger off")); } - else if (StringIsEqual(misc, _T("note"), 4)) + else if (StringIsEqual(misc, "note", 4)) // add note to logger file if available.. logger->LoggerNote(misc + 4); } catch (...) { @@ -541,7 +541,7 @@ InputEvents::eventBeep([[maybe_unused]] const char *misc) #ifdef _WIN32 MessageBeep(MB_ICONEXCLAMATION); #else - PlayResource(_T("IDR_WAV_CLEAR")); + PlayResource("IDR_WAV_CLEAR"); #endif } @@ -555,32 +555,32 @@ InputEvents::eventBeep([[maybe_unused]] const char *misc) void InputEvents::eventSetup(const char *misc) { - if (StringIsEqual(misc, _T("Basic"))) + if (StringIsEqual(misc, "Basic")) dlgBasicSettingsShowModal(); - else if (StringIsEqual(misc, _T("Wind"))) + else if (StringIsEqual(misc, "Wind")) ShowWindSettingsDialog(); - else if (StringIsEqual(misc, _T("System"))) + else if (StringIsEqual(misc, "System")) SystemConfiguration(); - else if (StringIsEqual(misc, _T("Task"))) + else if (StringIsEqual(misc, "Task")) dlgTaskManagerShowModal(); - else if (StringIsEqual(misc, _T("Airspace"))) + else if (StringIsEqual(misc, "Airspace")) dlgAirspaceShowModal(false); - else if (StringIsEqual(misc, _T("Weather"))) - ShowWeatherDialog(_T("rasp")); - else if (StringIsEqual(misc, _T("Replay"))) { + else if (StringIsEqual(misc, "Weather")) + ShowWeatherDialog("rasp"); + else if (StringIsEqual(misc, "Replay")) { if (!CommonInterface::MovementDetected() && backend_components->replay) ShowReplayDialog(*backend_components->replay); - } else if (StringIsEqual(misc, _T("Switches"))) + } else if (StringIsEqual(misc, "Switches")) dlgSwitchesShowModal(); - else if (StringIsEqual(misc, _T("Teamcode"))) + else if (StringIsEqual(misc, "Teamcode")) dlgTeamCodeShowModal(); - else if (StringIsEqual(misc, _T("Target"))) + else if (StringIsEqual(misc, "Target")) dlgTargetShowModal(); - else if (StringIsEqual(misc, _T("Plane"))) + else if (StringIsEqual(misc, "Plane")) dlgPlanesShowModal(); - else if (StringIsEqual(misc, _T("Profile"))) + else if (StringIsEqual(misc, "Profile")) ProfileListDialog(); - else if (StringIsEqual(misc, _T("Alternates"))) + else if (StringIsEqual(misc, "Alternates")) dlgAlternatesListShowModal(data_components->waypoints.get()); trigger_redraw(); @@ -627,15 +627,15 @@ void InputEvents::eventExit([[maybe_unused]] const char *misc) { bool force = false; - if (StringIsEqual(misc, _T("system"))) { + if (StringIsEqual(misc, "system")) { UI::TopWindow::SetExitValue(EXIT_SYSTEM); - } else if (StringIsEqual(misc, _T("force"))) { + } else if (StringIsEqual(misc, "force")) { UI::TopWindow::SetExitValue(EXIT_SYSTEM); force = true; - } else if (StringIsEqual(misc, _T("restart"))) { + } else if (StringIsEqual(misc, "restart")) { UI::TopWindow::SetExitValue(EXIT_RESTART); #if defined(IS_OPENVARIO) - } else if (StringIsEqual(misc, _T("newstart"))) { + } else if (StringIsEqual(misc, "newstart")) { UI::TopWindow::SetExitValue(EXIT_NEWSTART); #endif } @@ -648,9 +648,9 @@ void InputEvents::eventShutdown([[maybe_unused]] const char *misc) { #if defined(IS_OPENVARIO) - if (StringIsEqual(misc, _T("reboot"))) { + if (StringIsEqual(misc, "reboot")) { UI::TopWindow::SetExitValue(EXIT_REBOOT); // 20001); - } else if (StringIsEqual(misc, _T("shutdown"))) { + } else if (StringIsEqual(misc, "shutdown")) { UI::TopWindow::SetExitValue(EXIT_SHUTDOWN); // 20002); } #endif @@ -700,13 +700,13 @@ InputEvents::eventUserDisplayModeForce(const char *misc) { UIState &ui_state = CommonInterface::SetUIState(); - if (StringIsEqual(misc, _T("unforce"))) + if (StringIsEqual(misc, "unforce")) ui_state.force_display_mode = DisplayMode::NONE; - else if (StringIsEqual(misc, _T("forceclimb"))) + else if (StringIsEqual(misc, "forceclimb")) ui_state.force_display_mode = DisplayMode::CIRCLING; - else if (StringIsEqual(misc, _T("forcecruise"))) + else if (StringIsEqual(misc, "forcecruise")) ui_state.force_display_mode = DisplayMode::CRUISE; - else if (StringIsEqual(misc, _T("forcefinal"))) + else if (StringIsEqual(misc, "forcefinal")) ui_state.force_display_mode = DisplayMode::FINAL_GLIDE; ActionInterface::UpdateDisplayMode(); @@ -720,7 +720,7 @@ InputEvents::eventAddWaypoint(const char *misc) const DerivedInfo &calculated = CommonInterface::Calculated(); auto &way_points = *data_components->waypoints; - if (StringIsEqual(misc, _T("takeoff"))) { + if (StringIsEqual(misc, "takeoff")) { if (basic.location_available && calculated.terrain_valid) { ScopeSuspendAllThreads suspend; way_points.AddTakeoffPoint(basic.location, calculated.terrain_altitude); @@ -810,9 +810,9 @@ InputEvents::eventExchangeFrequencies([[maybe_unused]] const char *misc) void InputEvents::eventUploadIGCFile([[maybe_unused]] const char *misc) { FileDataField df; - df.ScanMultiplePatterns(_T("*.igc\0")); + df.ScanMultiplePatterns("*.igc\0"); df.SetFileType(FileType::IGC); - if (FilePicker(_T("IGC-FilePicker"), df)) { + if (FilePicker("IGC-FilePicker", df)) { auto path = df.GetValue(); if (!path.empty()) if (WeGlide::UploadIGCFile(path)) { diff --git a/src/Input/InputEventsAirspace.cpp b/src/Input/InputEventsAirspace.cpp index 4f192659032..e2fee74edfc 100644 --- a/src/Input/InputEventsAirspace.cpp +++ b/src/Input/InputEventsAirspace.cpp @@ -34,19 +34,19 @@ InputEvents::eventAirSpace(const char *misc) AirspaceRendererSettings &settings = CommonInterface::SetMapSettings().airspace; - if (StringIsEqual(misc, _T("toggle"))) + if (StringIsEqual(misc, "toggle")) settings.enable = !settings.enable; - else if (StringIsEqual(misc, _T("off"))) + else if (StringIsEqual(misc, "off")) settings.enable = false; - else if (StringIsEqual(misc, _T("on"))) + else if (StringIsEqual(misc, "on")) settings.enable = true; - else if (StringIsEqual(misc, _T("show"))) { + else if (StringIsEqual(misc, "show")) { if (!settings.enable) Message::AddMessage(_("Show airspace off")); if (settings.enable) Message::AddMessage(_("Show airspace on")); return; - } else if (StringIsEqual(misc, _T("list"))) { + } else if (StringIsEqual(misc, "list")) { ShowAirspaceListDialog(*data_components->airspaces, backend_components->GetAirspaceWarnings()); return; diff --git a/src/Input/InputEventsDevice.cpp b/src/Input/InputEventsDevice.cpp index b2e2c324476..5a56a34cb03 100644 --- a/src/Input/InputEventsDevice.cpp +++ b/src/Input/InputEventsDevice.cpp @@ -53,7 +53,7 @@ InputEvents::eventDevice(const char *misc) { assert(misc != NULL); - if (StringIsEqual(misc, _T("list"))) + if (StringIsEqual(misc, "list")) ShowDeviceList(*backend_components->device_blackboard, backend_components->devices.get()); } diff --git a/src/Input/InputEventsLua.cpp b/src/Input/InputEventsLua.cpp index 122d0afb067..c688dd2a787 100644 --- a/src/Input/InputEventsLua.cpp +++ b/src/Input/InputEventsLua.cpp @@ -34,10 +34,10 @@ SelectLuaFile(const char *path) /* no parameter: let user select a *.lua file */ LuaFileVisitor visitor; - Directory::VisitSpecificFiles(LocalPath(_T("lua")), _T("*.lua"), + Directory::VisitSpecificFiles(LocalPath("lua"), "*.lua", visitor, true); if (visitor.combo_list.empty()) { - ShowMessageBox(_("Not found"), _T("RunLuaFile"), + ShowMessageBox(_("Not found"), "RunLuaFile", MB_OK|MB_ICONINFORMATION); return nullptr; } @@ -47,14 +47,14 @@ SelectLuaFile(const char *path) return nullptr; return Path(visitor.combo_list[i].string_value.c_str()); - } else if (StringEndsWith(path, _T(".lua"))) { + } else if (StringEndsWith(path, ".lua")) { /* *.lua file specified: run this file */ return Path(path).IsAbsolute() ? AllocatedPath(Path(path)) - : AllocatedPath::Build(LocalPath(_T("lua")), path); + : AllocatedPath::Build(LocalPath("lua"), path); } else { - ShowMessageBox(_T("RunLuaFile expects *.lua parameter"), - _T("RunLuaFile"), MB_OK|MB_ICONINFORMATION); + ShowMessageBox("RunLuaFile expects *.lua parameter", + "RunLuaFile", MB_OK|MB_ICONINFORMATION); return nullptr; } } @@ -70,7 +70,7 @@ InputEvents::eventRunLuaFile(const char *misc) Lua::StartFile(path); } catch (...) { char buffer[MAX_PATH]; - StringFormat(buffer, MAX_PATH, _T("RunLuaFile %s"), misc); + StringFormat(buffer, MAX_PATH, "RunLuaFile %s", misc); ShowError(std::current_exception(), buffer); } } diff --git a/src/Input/InputEventsMap.cpp b/src/Input/InputEventsMap.cpp index 8a7bd3a8a1c..93bec92acc0 100644 --- a/src/Input/InputEventsMap.cpp +++ b/src/Input/InputEventsMap.cpp @@ -42,40 +42,40 @@ InputEvents::eventZoom(const char* misc) MapSettings &settings_map = CommonInterface::SetMapSettings(); - if (StringIsEqual(misc, _T("auto toggle"))) + if (StringIsEqual(misc, "auto toggle")) sub_AutoZoom(-1); - else if (StringIsEqual(misc, _T("auto on"))) + else if (StringIsEqual(misc, "auto on")) sub_AutoZoom(1); - else if (StringIsEqual(misc, _T("auto off"))) + else if (StringIsEqual(misc, "auto off")) sub_AutoZoom(0); - else if (StringIsEqual(misc, _T("auto show"))) { + else if (StringIsEqual(misc, "auto show")) { if (settings_map.auto_zoom_enabled) Message::AddMessage(_("Auto. zoom on")); else Message::AddMessage(_("Auto. zoom off")); - } else if (StringIsEqual(misc, _T("slowout"))) + } else if (StringIsEqual(misc, "slowout")) sub_ScaleZoom(-1); - else if (StringIsEqual(misc, _T("slowin"))) + else if (StringIsEqual(misc, "slowin")) sub_ScaleZoom(1); - else if (StringIsEqual(misc, _T("out"))) + else if (StringIsEqual(misc, "out")) sub_ScaleZoom(-1); - else if (StringIsEqual(misc, _T("in"))) + else if (StringIsEqual(misc, "in")) sub_ScaleZoom(1); - else if (StringIsEqual(misc, _T("-"))) + else if (StringIsEqual(misc, "-")) sub_ScaleZoom(-1); - else if (StringIsEqual(misc, _T("+"))) + else if (StringIsEqual(misc, "+")) sub_ScaleZoom(1); - else if (StringIsEqual(misc, _T("--"))) + else if (StringIsEqual(misc, "--")) sub_ScaleZoom(-2); - else if (StringIsEqual(misc, _T("++"))) + else if (StringIsEqual(misc, "++")) sub_ScaleZoom(2); - else if (StringIsEqual(misc, _T("circlezoom toggle"))) { + else if (StringIsEqual(misc, "circlezoom toggle")) { settings_map.circle_zoom_enabled = !settings_map.circle_zoom_enabled; - } else if (StringIsEqual(misc, _T("circlezoom on"))) { + } else if (StringIsEqual(misc, "circlezoom on")) { settings_map.circle_zoom_enabled = true; - } else if (StringIsEqual(misc, _T("circlezoom off"))) { + } else if (StringIsEqual(misc, "circlezoom off")) { settings_map.circle_zoom_enabled = false; - } else if (StringIsEqual(misc, _T("circlezoom show"))) { + } else if (StringIsEqual(misc, "circlezoom show")) { if (settings_map.circle_zoom_enabled) Message::AddMessage(_("Circling zoom on")); else @@ -109,25 +109,25 @@ InputEvents::eventZoom(const char* misc) void InputEvents::eventPan(const char *misc) { - if (StringIsEqual(misc, _T("toggle"))) + if (StringIsEqual(misc, "toggle")) TogglePan(); - else if (StringIsEqual(misc, _T("on"))) + else if (StringIsEqual(misc, "on")) EnterPan(); - else if (StringIsEqual(misc, _T("off"))) + else if (StringIsEqual(misc, "off")) LeavePan(); - else if (StringIsEqual(misc, _T("up"))) + else if (StringIsEqual(misc, "up")) sub_PanCursor(0, 1); - else if (StringIsEqual(misc, _T("down"))) + else if (StringIsEqual(misc, "down")) sub_PanCursor(0, -1); - else if (StringIsEqual(misc, _T("left"))) + else if (StringIsEqual(misc, "left")) sub_PanCursor(1, 0); - else if (StringIsEqual(misc, _T("right"))) + else if (StringIsEqual(misc, "right")) sub_PanCursor(-1, 0); XCSoarInterface::SendMapSettings(true); diff --git a/src/Input/InputEventsPage.cpp b/src/Input/InputEventsPage.cpp index dd4f413eb56..48aed4751a5 100644 --- a/src/Input/InputEventsPage.cpp +++ b/src/Input/InputEventsPage.cpp @@ -8,6 +8,6 @@ void InputEvents::eventPage(const char *misc) { - if (StringIsEqual(misc, _T("restore"))) + if (StringIsEqual(misc, "restore")) PageActions::Restore(); } diff --git a/src/Input/InputEventsSettings.cpp b/src/Input/InputEventsSettings.cpp index c22382f9596..cd05b0222c0 100644 --- a/src/Input/InputEventsSettings.cpp +++ b/src/Input/InputEventsSettings.cpp @@ -29,18 +29,18 @@ InputEvents::eventSounds(const char *misc) SoundSettings &settings = CommonInterface::SetUISettings().sound; // bool OldEnableSoundVario = EnableSoundVario; bool enabled = settings.vario.enabled; - if (StringIsEqual(misc, _T("toggle"))) + if (StringIsEqual(misc, "toggle")) settings.vario.enabled = !enabled; - else if (StringIsEqual(misc, _T("on"))) + else if (StringIsEqual(misc, "on")) settings.vario.enabled = true; - else if (StringIsEqual(misc, _T("off"))) + else if (StringIsEqual(misc, "off")) settings.vario.enabled = false; - else if (StringIsEqual(misc, _T("quieter"))) { + else if (StringIsEqual(misc, "quieter")) { settings.vario.volume = settings.vario.volume / 2; if (settings.vario.volume < 1) // settings.vario.max_volume) settings.vario.volume = 1; // don't switch to off! // settings.vario.enabled = false; - } else if (StringIsEqual(misc, _T("louder"))) { + } else if (StringIsEqual(misc, "louder")) { if (settings.vario.volume > 0) settings.vario.volume *= 2; else @@ -48,7 +48,7 @@ InputEvents::eventSounds(const char *misc) if (settings.vario.volume > 100) // settings.vario.max_volume) settings.vario.volume = 100; // settings.vario.enabled = false; - } else if (StringIsEqual(misc, _T("show"))) { + } else if (StringIsEqual(misc, "show")) { if (enabled) Message::AddMessage(_("Vario sounds on")); else @@ -66,19 +66,19 @@ InputEvents::eventSnailTrail(const char *misc) { MapSettings &settings_map = CommonInterface::SetMapSettings(); - if (StringIsEqual(misc, _T("toggle"))) { + if (StringIsEqual(misc, "toggle")) { unsigned trail_length = (int)settings_map.trail.length; trail_length = (trail_length + 1u) % 4u; settings_map.trail.length = (TrailSettings::Length)trail_length; - } else if (StringIsEqual(misc, _T("off"))) + } else if (StringIsEqual(misc, "off")) settings_map.trail.length = TrailSettings::Length::OFF; - else if (StringIsEqual(misc, _T("long"))) + else if (StringIsEqual(misc, "long")) settings_map.trail.length = TrailSettings::Length::LONG; - else if (StringIsEqual(misc, _T("short"))) + else if (StringIsEqual(misc, "short")) settings_map.trail.length = TrailSettings::Length::SHORT; - else if (StringIsEqual(misc, _T("full"))) + else if (StringIsEqual(misc, "full")) settings_map.trail.length = TrailSettings::Length::FULL; - else if (StringIsEqual(misc, _T("show"))) { + else if (StringIsEqual(misc, "show")) { switch (settings_map.trail.length) { case TrailSettings::Length::OFF: Message::AddMessage(_("Snail trail off")); @@ -111,27 +111,27 @@ InputEvents::eventTerrainTopology(const char *misc) void InputEvents::eventTerrainTopography(const char *misc) { - if (StringIsEqual(misc, _T("terrain toggle"))) + if (StringIsEqual(misc, "terrain toggle")) sub_TerrainTopography(-2); - else if (StringIsEqual(misc, _T("topography toggle"))) + else if (StringIsEqual(misc, "topography toggle")) sub_TerrainTopography(-3); - else if (StringIsEqual(misc, _T("topology toggle"))) + else if (StringIsEqual(misc, "topology toggle")) sub_TerrainTopography(-3); - else if (StringIsEqual(misc, _T("terrain on"))) + else if (StringIsEqual(misc, "terrain on")) sub_TerrainTopography(3); - else if (StringIsEqual(misc, _T("terrain off"))) + else if (StringIsEqual(misc, "terrain off")) sub_TerrainTopography(4); - else if (StringIsEqual(misc, _T("topography on"))) + else if (StringIsEqual(misc, "topography on")) sub_TerrainTopography(1); - else if (StringIsEqual(misc, _T("topography off"))) + else if (StringIsEqual(misc, "topography off")) sub_TerrainTopography(2); - else if (StringIsEqual(misc, _T("topology on"))) + else if (StringIsEqual(misc, "topology on")) sub_TerrainTopography(1); - else if (StringIsEqual(misc, _T("topology off"))) + else if (StringIsEqual(misc, "topology off")) sub_TerrainTopography(2); - else if (StringIsEqual(misc, _T("show"))) + else if (StringIsEqual(misc, "show")) sub_TerrainTopography(0); - else if (StringIsEqual(misc, _T("toggle"))) + else if (StringIsEqual(misc, "toggle")) sub_TerrainTopography(-1); XCSoarInterface::SendMapSettings(true); @@ -145,13 +145,13 @@ InputEvents::eventAudioDeadband(const char *misc) { SoundSettings &settings = CommonInterface::SetUISettings().sound; - if (StringIsEqual(misc, _T("+"))) { + if (StringIsEqual(misc, "+")) { if (settings.sound_deadband >= 40) return; ++settings.sound_deadband; } - if (StringIsEqual(misc, _T("-"))) { + if (StringIsEqual(misc, "-")) { if (settings.sound_deadband <= 0) return; @@ -180,21 +180,21 @@ InputEvents::eventBugs(const char *misc) auto BUGS = settings.bugs; auto oldBugs = BUGS; - if (StringIsEqual(misc, _T("up"))) { + if (StringIsEqual(misc, "up")) { BUGS += 1 / 10.; if (BUGS > 1) BUGS = 1; - } else if (StringIsEqual(misc, _T("down"))) { + } else if (StringIsEqual(misc, "down")) { BUGS -= 1 / 10.; if (BUGS < 0.5) BUGS = 0.5; - } else if (StringIsEqual(misc, _T("max"))) + } else if (StringIsEqual(misc, "max")) BUGS = 1; - else if (StringIsEqual(misc, _T("min"))) + else if (StringIsEqual(misc, "min")) BUGS = 0.5; - else if (StringIsEqual(misc, _T("show"))) { + else if (StringIsEqual(misc, "show")) { char Temp[100]; - _stprintf(Temp, _T("%d"), (int)(BUGS * 100)); + _stprintf(Temp, "%d", (int)(BUGS * 100)); Message::AddMessage(_("Bugs performance"), Temp); } @@ -222,21 +222,21 @@ InputEvents::eventBallast(const char *misc) auto BALLAST = polar.GetBallast(); auto oldBallast = BALLAST; - if (StringIsEqual(misc, _T("up"))) { + if (StringIsEqual(misc, "up")) { BALLAST += 1 / 10.; if (BALLAST >= 1) BALLAST = 1; - } else if (StringIsEqual(misc, _T("down"))) { + } else if (StringIsEqual(misc, "down")) { BALLAST -= 1 / 10.; if (BALLAST < 0) BALLAST = 0; - } else if (StringIsEqual(misc, _T("max"))) + } else if (StringIsEqual(misc, "max")) BALLAST = 1; - else if (StringIsEqual(misc, _T("min"))) + else if (StringIsEqual(misc, "min")) BALLAST = 0; - else if (StringIsEqual(misc, _T("show"))) { + else if (StringIsEqual(misc, "show")) { char Temp[100]; - _stprintf(Temp, _T("%d"), (int)(BALLAST * 100)); + _stprintf(Temp, "%d", (int)(BALLAST * 100)); /* xgettext:no-c-format */ Message::AddMessage(_("Ballast %"), Temp); } @@ -288,15 +288,15 @@ InputEvents::eventProfileSave(const char *misc) void InputEvents::eventAdjustForecastTemperature(const char *misc) { - if (StringIsEqual(misc, _T("+"))) + if (StringIsEqual(misc, "+")) CommonInterface::SetComputerSettings().forecast_temperature += Temperature::FromKelvin(1); - else if (StringIsEqual(misc, _T("-"))) + else if (StringIsEqual(misc, "-")) CommonInterface::SetComputerSettings().forecast_temperature -= Temperature::FromKelvin(1); - else if (StringIsEqual(misc, _T("show"))) { + else if (StringIsEqual(misc, "show")) { auto temperature = CommonInterface::GetComputerSettings().forecast_temperature; char Temp[100]; - _stprintf(Temp, _T("%f"), temperature.ToUser()); + _stprintf(Temp, "%f", temperature.ToUser()); Message::AddMessage(_("Forecast temperature"), Temp); } } @@ -314,21 +314,21 @@ InputEvents::eventDeclutterLabels(const char *misc) static constexpr unsigned int n = ARRAY_SIZE(msg); static const char *const actions[n] = { - _T("all"), - _T("task+landables"), - _T("task"), - _T("none") - _T("task+airfields"), + "all", + "task+landables", + "task", + "none" + "task+airfields", }; WaypointRendererSettings::LabelSelection &wls = CommonInterface::SetMapSettings().waypoint.label_selection; - if (StringIsEqual(misc, _T("toggle"))) { + if (StringIsEqual(misc, "toggle")) { wls = WaypointRendererSettings::LabelSelection(((unsigned)wls + 1) % n); Profile::Set(ProfileKeys::WaypointLabelSelection, (int)wls); - } else if (StringIsEqual(misc, _T("show"))) { + } else if (StringIsEqual(misc, "show")) { char tbuf[64]; - _stprintf(tbuf, _T("%s: %s"), _("Waypoint labels"), + _stprintf(tbuf, "%s: %s", _("Waypoint labels"), gettext(msg[(unsigned)wls])); Message::AddMessage(tbuf); } @@ -351,15 +351,15 @@ InputEvents::eventAirspaceDisplayMode(const char *misc) AirspaceRendererSettings &settings = CommonInterface::SetMapSettings().airspace; - if (StringIsEqual(misc, _T("all"))) + if (StringIsEqual(misc, "all")) settings.altitude_mode = AirspaceDisplayMode::ALLON; - else if (StringIsEqual(misc, _T("clip"))) + else if (StringIsEqual(misc, "clip")) settings.altitude_mode = AirspaceDisplayMode::CLIP; - else if (StringIsEqual(misc, _T("auto"))) + else if (StringIsEqual(misc, "auto")) settings.altitude_mode = AirspaceDisplayMode::AUTO; - else if (StringIsEqual(misc, _T("below"))) + else if (StringIsEqual(misc, "below")) settings.altitude_mode = AirspaceDisplayMode::ALLBELOW; - else if (StringIsEqual(misc, _T("off"))) + else if (StringIsEqual(misc, "off")) settings.altitude_mode = AirspaceDisplayMode::ALLOFF; TriggerMapUpdate(); @@ -370,22 +370,22 @@ InputEvents::eventOrientation(const char *misc) { MapSettings &settings_map = CommonInterface::SetMapSettings(); - if (StringIsEqual(misc, _T("northup"))) { + if (StringIsEqual(misc, "northup")) { settings_map.cruise_orientation = MapOrientation::NORTH_UP; settings_map.circling_orientation = MapOrientation::NORTH_UP; - } else if (StringIsEqual(misc, _T("northcircle"))) { + } else if (StringIsEqual(misc, "northcircle")) { settings_map.cruise_orientation = MapOrientation::TRACK_UP; settings_map.circling_orientation = MapOrientation::NORTH_UP; - } else if (StringIsEqual(misc, _T("trackcircle"))) { + } else if (StringIsEqual(misc, "trackcircle")) { settings_map.cruise_orientation = MapOrientation::NORTH_UP; settings_map.circling_orientation = MapOrientation::TRACK_UP; - } else if (StringIsEqual(misc, _T("trackup"))) { + } else if (StringIsEqual(misc, "trackup")) { settings_map.cruise_orientation = MapOrientation::TRACK_UP; settings_map.circling_orientation = MapOrientation::TRACK_UP; - } else if (StringIsEqual(misc, _T("northtrack"))) { + } else if (StringIsEqual(misc, "northtrack")) { settings_map.cruise_orientation = MapOrientation::TRACK_UP; settings_map.circling_orientation = MapOrientation::TARGET_UP; - } else if (StringIsEqual(misc, _T("targetup"))) { + } else if (StringIsEqual(misc, "targetup")) { settings_map.cruise_orientation = MapOrientation::TARGET_UP; settings_map.circling_orientation = MapOrientation::TARGET_UP; } @@ -448,9 +448,9 @@ InputEvents::sub_TerrainTopography(int vswitch) char buf[128]; if (settings_map.topography_enabled) - _stprintf(buf, _T("\r\n%s / "), _("On")); + _stprintf(buf, "\r\n%s / ", _("On")); else - _stprintf(buf, _T("\r\n%s / "), _("Off")); + _stprintf(buf, "\r\n%s / ", _("Off")); strcat(buf, settings_map.terrain.enable ? _("On") : _("Off")); diff --git a/src/Input/InputEventsTask.cpp b/src/Input/InputEventsTask.cpp index 3281f99568b..7cafd62f448 100644 --- a/src/Input/InputEventsTask.cpp +++ b/src/Input/InputEventsTask.cpp @@ -50,13 +50,13 @@ InputEvents::eventArmAdvance(const char *misc) ProtectedTaskManager::ExclusiveLease task_manager{*backend_components->protected_task_manager}; TaskAdvance &advance = task_manager->SetTaskAdvance(); - if (StringIsEqual(misc, _T("on"))) { + if (StringIsEqual(misc, "on")) { advance.SetArmed(true); - } else if (StringIsEqual(misc, _T("off"))) { + } else if (StringIsEqual(misc, "off")) { advance.SetArmed(false); - } else if (StringIsEqual(misc, _T("toggle"))) { + } else if (StringIsEqual(misc, "toggle")) { advance.ToggleArmed(); - } else if (StringIsEqual(misc, _T("show"))) { + } else if (StringIsEqual(misc, "show")) { switch (advance.GetState()) { case TaskAdvance::MANUAL: Message::AddMessage(_("Advance manually")); @@ -123,28 +123,28 @@ InputEvents::eventMacCready(const char *misc) TaskBehaviour &task_behaviour = CommonInterface::SetComputerSettings().task; - if (StringIsEqual(misc, _T("up"))) { + if (StringIsEqual(misc, "up")) { const auto step = Units::ToSysVSpeed(GetUserVerticalSpeedStep()); ActionInterface::OffsetManualMacCready(step); - } else if (StringIsEqual(misc, _T("down"))) { + } else if (StringIsEqual(misc, "down")) { const auto step = Units::ToSysVSpeed(GetUserVerticalSpeedStep()); ActionInterface::OffsetManualMacCready(-step); - } else if (StringIsEqual(misc, _T("auto toggle"))) { + } else if (StringIsEqual(misc, "auto toggle")) { task_behaviour.auto_mc = !task_behaviour.auto_mc; Profile::Set(ProfileKeys::AutoMc, task_behaviour.auto_mc); - } else if (StringIsEqual(misc, _T("auto on"))) { + } else if (StringIsEqual(misc, "auto on")) { task_behaviour.auto_mc = true; Profile::Set(ProfileKeys::AutoMc, true); - } else if (StringIsEqual(misc, _T("auto off"))) { + } else if (StringIsEqual(misc, "auto off")) { task_behaviour.auto_mc = false; Profile::Set(ProfileKeys::AutoMc, false); - } else if (StringIsEqual(misc, _T("auto show"))) { + } else if (StringIsEqual(misc, "auto show")) { if (task_behaviour.auto_mc) { Message::AddMessage(_("Auto. MacCready on")); } else { Message::AddMessage(_("Auto. MacCready off")); } - } else if (StringIsEqual(misc, _T("show"))) { + } else if (StringIsEqual(misc, "show")) { Message::AddMessage(_("MacCready "), FormatUserVerticalSpeed(mc, false)); } } @@ -162,17 +162,17 @@ InputEvents::eventAdjustWaypoint(const char *misc) if (protected_task_manager == NULL) return; - if (StringIsEqual(misc, _T("next"))) + if (StringIsEqual(misc, "next")) protected_task_manager->IncrementActiveTaskPoint(1); // next - else if (StringIsEqual(misc, _T("nextwrap"))) + else if (StringIsEqual(misc, "nextwrap")) protected_task_manager->IncrementActiveTaskPoint(1); // next - with wrap - else if (StringIsEqual(misc, _T("previous"))) + else if (StringIsEqual(misc, "previous")) protected_task_manager->IncrementActiveTaskPoint(-1); // previous - else if (StringIsEqual(misc, _T("previouswrap"))) + else if (StringIsEqual(misc, "previouswrap")) protected_task_manager->IncrementActiveTaskPoint(-1); // previous with wrap - else if (StringIsEqual(misc, _T("nextarm"))) + else if (StringIsEqual(misc, "nextarm")) protected_task_manager->IncrementActiveTaskPointArm(1); // arm sensitive next - else if (StringIsEqual(misc, _T("previousarm"))) + else if (StringIsEqual(misc, "previousarm")) protected_task_manager->IncrementActiveTaskPointArm(-1); // arm sensitive previous { @@ -200,11 +200,11 @@ InputEvents::eventAbortTask(const char *misc) ProtectedTaskManager::ExclusiveLease task_manager{*backend_components->protected_task_manager}; - if (StringIsEqual(misc, _T("abort"))) + if (StringIsEqual(misc, "abort")) task_manager->Abort(); - else if (StringIsEqual(misc, _T("resume"))) + else if (StringIsEqual(misc, "resume")) task_manager->Resume(); - else if (StringIsEqual(misc, _T("show"))) { + else if (StringIsEqual(misc, "show")) { switch (task_manager->GetMode()) { case TaskType::ABORT: Message::AddMessage(_("Task aborted")); @@ -293,14 +293,14 @@ InputEvents::eventTaskTransition(const char *misc) if (!backend_components->protected_task_manager) return; - if (StringIsEqual(misc, _T("start"))) { + if (StringIsEqual(misc, "start")) { const StartStats &start_stats = CommonInterface::Calculated().ordered_task_stats.start; if (!start_stats.HasStarted()) return; char TempAll[120]; - _stprintf(TempAll, _T("\r\n%s: %s\r\n%s:%s\r\n%s: %s"), + _stprintf(TempAll, "\r\n%s: %s\r\n%s:%s\r\n%s: %s", _("Altitude"), FormatUserAltitude(start_stats.altitude).c_str(), _("Speed"), @@ -309,9 +309,9 @@ InputEvents::eventTaskTransition(const char *misc) FormatLocalTimeHHMM(start_stats.time, CommonInterface::GetComputerSettings().utc_offset).c_str()); Message::AddMessage(_("Task start"), TempAll); - } else if (StringIsEqual(misc, _T("next"))) { + } else if (StringIsEqual(misc, "next")) { Message::AddMessage(_("Next turnpoint")); - } else if (StringIsEqual(misc, _T("finish"))) { + } else if (StringIsEqual(misc, "finish")) { Message::AddMessage(_("Task finished")); } } diff --git a/src/Input/InputEventsTraffic.cpp b/src/Input/InputEventsTraffic.cpp index 97bb88dd3d2..8f02ac54b35 100644 --- a/src/Input/InputEventsTraffic.cpp +++ b/src/Input/InputEventsTraffic.cpp @@ -12,7 +12,7 @@ void InputEvents::eventFLARMRadar([[maybe_unused]] const char *misc) { - if (StringIsEqual(misc, _T("ForceToggle"))) { + if (StringIsEqual(misc, "ForceToggle")) { CommonInterface::main_window->ToggleForceFLARMRadar(); } else CommonInterface::main_window->ToggleSuppressFLARMRadar(); @@ -31,27 +31,27 @@ InputEvents::eventTraffic(const char *misc) { LoadFlarmDatabases(); - if (StringIsEqual(misc, _T("show"))) { + if (StringIsEqual(misc, "show")) { PageActions::ShowTrafficRadar(); return; } TrafficWidget *traffic_widget = (TrafficWidget *) - CommonInterface::main_window->GetFlavourWidget(_T("Traffic")); + CommonInterface::main_window->GetFlavourWidget("Traffic"); if (traffic_widget == nullptr) return; - if (StringIsEqual(misc, _T("zoom auto toggle"))) { + if (StringIsEqual(misc, "zoom auto toggle")) { traffic_widget->ToggleAutoZoom(); - } else if (StringIsEqual(misc, _T("zoom in"))) { + } else if (StringIsEqual(misc, "zoom in")) { traffic_widget->ZoomIn(); - } else if (StringIsEqual(misc, _T("zoom out"))) { + } else if (StringIsEqual(misc, "zoom out")) { traffic_widget->ZoomOut(); - } else if (StringIsEqual(misc, _T("northup toggle"))) { + } else if (StringIsEqual(misc, "northup toggle")) { traffic_widget->ToggleNorthUp(); - } else if (StringIsEqual(misc, _T("details"))) { + } else if (StringIsEqual(misc, "details")) { traffic_widget->OpenDetails(); - } else if (StringIsEqual(misc, _T("label toggle"))) { + } else if (StringIsEqual(misc, "label toggle")) { traffic_widget->SwitchData(); } } diff --git a/src/Input/InputEventsVega.cpp b/src/Input/InputEventsVega.cpp index aa4267d23eb..fbf9763d2e4 100644 --- a/src/Input/InputEventsVega.cpp +++ b/src/Input/InputEventsVega.cpp @@ -64,27 +64,27 @@ void InputEvents::eventAdjustVarioFilter(const char *misc) { static int naccel = 0; - if (StringIsEqual(misc, _T("slow"))) + if (StringIsEqual(misc, "slow")) AllVegasSendSetting("VarioTimeConstant", 3); - else if (StringIsEqual(misc, _T("medium"))) + else if (StringIsEqual(misc, "medium")) AllVegasSendSetting("VarioTimeConstant", 2); - else if (StringIsEqual(misc, _T("fast"))) + else if (StringIsEqual(misc, "fast")) AllVegasSendSetting("VarioTimeConstant", 1); - else if (StringIsEqual(misc, _T("statistics"))) + else if (StringIsEqual(misc, "statistics")) AllVegasSendSetting("Diagnostics", 1); - else if (StringIsEqual(misc, _T("diagnostics"))) + else if (StringIsEqual(misc, "diagnostics")) AllVegasSendSetting("Diagnostics", 2); - else if (StringIsEqual(misc, _T("psraw"))) + else if (StringIsEqual(misc, "psraw")) AllVegasSendSetting("Diagnostics", 3); - else if (StringIsEqual(misc, _T("switch"))) + else if (StringIsEqual(misc, "switch")) AllVegasSendSetting("Diagnostics", 4); - else if (StringIsEqual(misc, _T("democlimb"))) { + else if (StringIsEqual(misc, "democlimb")) { AllVegasSendSetting("DemoMode", 0); AllVegasSendSetting("DemoMode", 2); - } else if (StringIsEqual(misc, _T("demostf"))) { + } else if (StringIsEqual(misc, "demostf")) { AllVegasSendSetting("DemoMode", 0); AllVegasSendSetting("DemoMode", 1); - } else if (StringIsEqual(misc, _T("accel"))) { + } else if (StringIsEqual(misc, "accel")) { switch (naccel) { case 0: AllVegasRequestSetting("AccelerometerSlopeX"); @@ -106,27 +106,27 @@ InputEvents::eventAdjustVarioFilter(const char *misc) if (naccel > 3) naccel = 0; - } else if (StringIsEqual(misc, _T("xdemo"))) { + } else if (StringIsEqual(misc, "xdemo")) { dlgVegaDemoShowModal(); - } else if (StringIsEqual(misc, _T("zero"))) { + } else if (StringIsEqual(misc, "zero")) { // zero, no mixing if (!CommonInterface::Calculated().flight.flying) { AllVegasSendSetting("ZeroASI", 1); } - } else if (StringIsEqual(misc, _T("save"))) { + } else if (StringIsEqual(misc, "save")) { AllVegasSendSetting("StoreToEeprom", 2); // accel calibration } else if (!CommonInterface::Calculated().flight.flying) { - if (StringIsEqual(misc, _T("X1"))) + if (StringIsEqual(misc, "X1")) AllVegasSendSetting("CalibrateAccel", 1); - else if (StringIsEqual(misc, _T("X2"))) + else if (StringIsEqual(misc, "X2")) AllVegasSendSetting("CalibrateAccel", 2); - else if (StringIsEqual(misc, _T("X3"))) + else if (StringIsEqual(misc, "X3")) AllVegasSendSetting("CalibrateAccel", 3); - else if (StringIsEqual(misc, _T("X4"))) + else if (StringIsEqual(misc, "X4")) AllVegasSendSetting("CalibrateAccel", 4); - else if (StringIsEqual(misc, _T("X5"))) + else if (StringIsEqual(misc, "X5")) AllVegasSendSetting("CalibrateAccel", 5); } } diff --git a/src/Input/InputKeys.cpp b/src/Input/InputKeys.cpp index 807d1ecf50a..f11a2cd8c6d 100644 --- a/src/Input/InputKeys.cpp +++ b/src/Input/InputKeys.cpp @@ -12,64 +12,64 @@ struct string_to_key { }; static constexpr struct string_to_key string_to_key[] = { - { _T("APP1"), KEY_APP1 }, - { _T("APP2"), KEY_APP2 }, - { _T("APP3"), KEY_APP3 }, - { _T("APP4"), KEY_APP4 }, - { _T("APP5"), KEY_APP5 }, - { _T("APP6"), KEY_APP6 }, - { _T("F1"), KEY_F1 }, - { _T("F2"), KEY_F2 }, - { _T("F3"), KEY_F3 }, - { _T("F4"), KEY_F4 }, - { _T("F5"), KEY_F5 }, - { _T("F6"), KEY_F6 }, - { _T("F7"), KEY_F7 }, - { _T("F8"), KEY_F8 }, - { _T("F9"), KEY_F9 }, - { _T("F10"), KEY_F10 }, - { _T("F11"), KEY_F11 }, - { _T("F12"), KEY_F12 }, + { "APP1", KEY_APP1 }, + { "APP2", KEY_APP2 }, + { "APP3", KEY_APP3 }, + { "APP4", KEY_APP4 }, + { "APP5", KEY_APP5 }, + { "APP6", KEY_APP6 }, + { "F1", KEY_F1 }, + { "F2", KEY_F2 }, + { "F3", KEY_F3 }, + { "F4", KEY_F4 }, + { "F5", KEY_F5 }, + { "F6", KEY_F6 }, + { "F7", KEY_F7 }, + { "F8", KEY_F8 }, + { "F9", KEY_F9 }, + { "F10", KEY_F10 }, + { "F11", KEY_F11 }, + { "F12", KEY_F12 }, #ifdef ANDROID /* These keys are used by BlueTooth keypads and available in Android*/ - { _T("BUTTON_R1"), KEYCODE_BUTTON_R1}, - { _T("BUTTON_R2"), KEYCODE_BUTTON_R2}, - { _T("BUTTON_L1"), KEYCODE_BUTTON_L1}, - { _T("BUTTON_L2"), KEYCODE_BUTTON_L2}, - { _T("BUTTON_A"), KEYCODE_BUTTON_A}, - { _T("BUTTON_B"), KEYCODE_BUTTON_B}, - { _T("BUTTON_C"), KEYCODE_BUTTON_C}, - { _T("BUTTON_X"), KEYCODE_BUTTON_X}, - { _T("BUTTON_Y"), KEYCODE_BUTTON_Y}, - { _T("BUTTON_Z"), KEYCODE_BUTTON_Z}, - { _T("MEDIA_NEXT"), KEYCODE_MEDIA_NEXT}, - { _T("MEDIA_PREVIOUS"), KEYCODE_MEDIA_PREVIOUS}, - { _T("MEDIA_PLAY_PAUSE"), KEYCODE_MEDIA_PLAY_PAUSE}, - { _T("VOLUME_UP"), KEY_VOLUME_UP }, - { _T("VOLUME_DOWN"), KEY_VOLUME_DOWN }, + { "BUTTON_R1", KEYCODE_BUTTON_R1}, + { "BUTTON_R2", KEYCODE_BUTTON_R2}, + { "BUTTON_L1", KEYCODE_BUTTON_L1}, + { "BUTTON_L2", KEYCODE_BUTTON_L2}, + { "BUTTON_A", KEYCODE_BUTTON_A}, + { "BUTTON_B", KEYCODE_BUTTON_B}, + { "BUTTON_C", KEYCODE_BUTTON_C}, + { "BUTTON_X", KEYCODE_BUTTON_X}, + { "BUTTON_Y", KEYCODE_BUTTON_Y}, + { "BUTTON_Z", KEYCODE_BUTTON_Z}, + { "MEDIA_NEXT", KEYCODE_MEDIA_NEXT}, + { "MEDIA_PREVIOUS", KEYCODE_MEDIA_PREVIOUS}, + { "MEDIA_PLAY_PAUSE", KEYCODE_MEDIA_PLAY_PAUSE}, + { "VOLUME_UP", KEY_VOLUME_UP }, + { "VOLUME_DOWN", KEY_VOLUME_DOWN }, #endif #ifdef USE_WINUSER /* These Keys are used for the Triadis-RemoteStick, as well as for expanded Keyboard-Events */ - { _T("F13"), KEY_F13 }, - { _T("F14"), KEY_F14 }, - { _T("F15"), KEY_F15 }, - { _T("F16"), KEY_F16 }, - { _T("F17"), KEY_F17 }, - { _T("F18"), KEY_F18 }, - { _T("F19"), KEY_F19 }, - { _T("F20"), KEY_F20 }, + { "F13", KEY_F13 }, + { "F14", KEY_F14 }, + { "F15", KEY_F15 }, + { "F16", KEY_F16 }, + { "F17", KEY_F17 }, + { "F18", KEY_F18 }, + { "F19", KEY_F19 }, + { "F20", KEY_F20 }, #endif - { _T("LEFT"), KEY_LEFT }, - { _T("RIGHT"), KEY_RIGHT }, - { _T("UP"), KEY_UP }, - { _T("DOWN"), KEY_DOWN }, - { _T("RETURN"), KEY_RETURN }, - { _T("ESCAPE"), KEY_ESCAPE }, - { _T("MENU"), KEY_MENU }, - { _T("TAB"), KEY_TAB }, + { "LEFT", KEY_LEFT }, + { "RIGHT", KEY_RIGHT }, + { "UP", KEY_UP }, + { "DOWN", KEY_DOWN }, + { "RETURN", KEY_RETURN }, + { "ESCAPE", KEY_ESCAPE }, + { "MENU", KEY_MENU }, + { "TAB", KEY_TAB }, { NULL } }; diff --git a/src/Input/InputParser.cpp b/src/Input/InputParser.cpp index 699f479c209..118c7133b3e 100644 --- a/src/Input/InputParser.cpp +++ b/src/Input/InputParser.cpp @@ -26,7 +26,7 @@ parse_assignment(char *buffer, const char *&key, const char *&value) if (separator == NULL || separator == buffer) return false; - *separator = _T('\0'); + *separator = '\0'; key = buffer; value = separator + 1; @@ -69,7 +69,7 @@ struct EventBuilder { // All modes are valid at this point int mode_id = config.MakeMode(token); if (mode_id < 0) { - LogFormat(_T("Too many modes: %.*s at %u"), + LogFormat("Too many modes: %.*s at %u", int(token.size()), token.data(), line); continue; } @@ -87,34 +87,34 @@ struct EventBuilder { // Make key (Keyboard input) // key - Hardware key or keyboard - if (type.equals(_T("key"))) { + if (type.equals("key")) { // Get the int key (eg: APP1 vs 'a') unsigned key = ParseKeyCode(data); if (key > 0) config.SetKeyEvent(mode_id, key, event_id); else - LogFormat(_T("Invalid key data: %s at %u"), data.c_str(), line); + LogFormat("Invalid key data: %s at %u", data.c_str(), line); // Make gce (Glide Computer Event) // GCE - Glide Computer Event - } else if (type.equals(_T("gce"))) { + } else if (type.equals("gce")) { // Get the int key (eg: APP1 vs 'a') int key = InputEvents::findGCE(data); if (key >= 0) config.GC2Event[key] = event_id; else - LogFormat(_T("Invalid GCE data: %s at %u"), data.c_str(), line); + LogFormat("Invalid GCE data: %s at %u", data.c_str(), line); // Make gesture (Gesture Event) // Key - Key Event - } else if (type.equals(_T("gesture"))) { + } else if (type.equals("gesture")) { // Check data for invalid characters: bool valid = true; for (const char* c = data; *c; c++) - if (*c != _T('U') && - *c != _T('D') && - *c != _T('R') && - *c != _T('L')) + if (*c != 'U' && + *c != 'D' && + *c != 'R' && + *c != 'L') valid = false; if (valid) { @@ -122,24 +122,24 @@ struct EventBuilder { config.Gesture2Event.Remove(data.c_str()); config.Gesture2Event.Add(data.c_str(), event_id); } else - LogFormat(_T("Invalid gesture data: %s at %u"), data.c_str(), line); + LogFormat("Invalid gesture data: %s at %u", data.c_str(), line); // Make ne (NMEA Event) // NE - NMEA Event - } else if (type.equals(_T("ne"))) { + } else if (type.equals("ne")) { // Get the int key (eg: APP1 vs 'a') int key = InputEvents::findNE(data); if (key >= 0) config.N2Event[key] = event_id; else - LogFormat(_T("Invalid GCE data: %s at %u"), data.c_str(), line); + LogFormat("Invalid GCE data: %s at %u", data.c_str(), line); // label only - no key associated (label can still be touch screen) - } else if (type.equals(_T("label"))) { + } else if (type.equals("label")) { // Nothing to do here... } else { - LogFormat(_T("Invalid type: %s at %u"), type.c_str(), line); + LogFormat("Invalid type: %s at %u", type.c_str(), line); } } } diff --git a/src/Kobo/KoboMenu.cpp b/src/Kobo/KoboMenu.cpp index 93f2ecfd730..abeedd1d5ae 100644 --- a/src/Kobo/KoboMenu.cpp +++ b/src/Kobo/KoboMenu.cpp @@ -140,7 +140,7 @@ Main() main_style.Resizable(); UI::SingleWindow main_window{screen_init.GetDisplay()}; - main_window.Create(_T("XCSoar/KoboMenu"), {600, 800}, main_style); + main_window.Create("XCSoar/KoboMenu", {600, 800}, main_style); main_window.Show(); global_dialog_look = &dialog_look; diff --git a/src/Kobo/NetworkDialog.cpp b/src/Kobo/NetworkDialog.cpp index c985ed4e3e5..44a5cd52d78 100644 --- a/src/Kobo/NetworkDialog.cpp +++ b/src/Kobo/NetworkDialog.cpp @@ -15,7 +15,7 @@ static const char * GetWifiToggleCaption() { - return IsKoboWifiOn() ? _T("Wifi OFF") : _T("Wifi ON"); + return IsKoboWifiOn() ? "Wifi OFF" : "Wifi ON"; } class NetworkWidget final @@ -58,9 +58,9 @@ NetworkWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused] wifi_button = AddButton(_("Wifi"), [](){ ShowWifiDialog(); }); - AddButton(_T("Telnet server"), [](){ KoboRunTelnetd(); }); + AddButton("Telnet server", [](){ KoboRunTelnetd(); }); - AddButton(_T("Ftp server"), [](){ KoboRunFtpd(); }); + AddButton("Ftp server", [](){ KoboRunFtpd(); }); UpdateButtons(); } diff --git a/src/Kobo/PowerOff.cpp b/src/Kobo/PowerOff.cpp index 666bea0c8c0..2fe0793b68c 100644 --- a/src/Kobo/PowerOff.cpp +++ b/src/Kobo/PowerOff.cpp @@ -54,26 +54,26 @@ DrawBanner(Canvas &canvas, PixelRect &rc) const int name_y = rc.top + (banner_height - large_font.GetHeight()) / 2; - const char *const name1 = _T("XC"); + const char *const name1 = "XC"; canvas.DrawText({x, name_y}, name1); x += canvas.CalcTextWidth(name1); - const char *const name2 = _T("Soar"); + const char *const name2 = "Soar"; canvas.SetTextColor(COLOR_GRAY); canvas.DrawText({x, name_y}, name2); canvas.SetTextColor(COLOR_BLACK); x += canvas.CalcTextWidth(name2) + 30; /* some more text */ - const char *const website = _T("www.xcsoar.org"); + const char *const website = "www.xcsoar.org"; canvas.Select(normal_font); canvas.DrawText({x, rc.top + int(banner_height - normal_font.GetHeight()) / 2}, website); - char comment[30] = _T("powered off"); + char comment[30] = "powered off"; const auto power_info = Power::GetInfo(); if (power_info.battery.remaining_percent) { - snprintf ( comment+strlen(comment), 30-strlen(comment), _T(" - battery %d%%"), *power_info.battery.remaining_percent); + snprintf ( comment+strlen(comment), 30-strlen(comment), " - battery %d%%", *power_info.battery.remaining_percent); } canvas.DrawText({rc.right - (int)canvas.CalcTextWidth(comment) - padding, rc.top + padding}, diff --git a/src/Kobo/SystemDialog.cpp b/src/Kobo/SystemDialog.cpp index a5719dfa92b..1b984c400fe 100644 --- a/src/Kobo/SystemDialog.cpp +++ b/src/Kobo/SystemDialog.cpp @@ -107,7 +107,7 @@ SystemWidget::SwitchOTGMode() switch_otg_mode->SetCaption("Enable USB-OTG"); usb_storage->SetEnabled(true); } else { - ShowMessageBox(_T("Failed to switch OTG mode."), _("Error"), MB_OK); + ShowMessageBox("Failed to switch OTG mode.", _("Error"), MB_OK); } } else { success = File::WriteExisting(Path("/sys/kernel/debug/ci_hdrc.0/role"), @@ -119,7 +119,7 @@ SystemWidget::SwitchOTGMode() switch_otg_mode->SetCaption("Disable USB-OTG"); usb_storage->SetEnabled(false); } else { - ShowMessageBox(_T("Failed to switch OTG mode."), _("Error"), MB_OK); + ShowMessageBox("Failed to switch OTG mode.", _("Error"), MB_OK); } } } else { @@ -138,8 +138,8 @@ SystemWidget::SwitchKernel() model != KoboModel::TOUCH2 && model != KoboModel::GLO_HD && model != KoboModel::AURA2 && - ShowMessageBox(_T("This feature was designed for the Kobo Mini, Touch 2.0, Glo HD and Aura 2, but this is not one. Use at your own risk. Continue?"), - _T("USB-OTG"), MB_YESNO) != IDYES) + ShowMessageBox("This feature was designed for the Kobo Mini, Touch 2.0, Glo HD and Aura 2, but this is not one. Use at your own risk. Continue?", + "USB-OTG", MB_YESNO) != IDYES) return; const char *otg_kernel_image, *kobo_kernel_image; @@ -166,7 +166,7 @@ SystemWidget::SwitchKernel() : otg_kernel_image; if (!KoboInstallKernel(kernel_image)) { - ShowMessageBox(_T("Failed to activate kernel."), _("Error"), MB_OK); + ShowMessageBox("Failed to activate kernel.", _("Error"), MB_OK); return; } @@ -178,20 +178,20 @@ inline void SystemWidget::ExportUSBStorage() { if (!KoboUmountData()) { - ShowMessageBox(_T("Failed to unmount data partition."), _("Error"), + ShowMessageBox("Failed to unmount data partition.", _("Error"), MB_OK); return; } if (!KoboExportUSBStorage()) { - ShowMessageBox(_T("Failed to export data partition."), _("Error"), + ShowMessageBox("Failed to export data partition.", _("Error"), MB_OK); KoboMountData(); return; } - ShowMessageBox(_T("Your PC has now access to the data partition until you close this dialog."), - _T("Export USB storage"), + ShowMessageBox("Your PC has now access to the data partition until you close this dialog.", + "Export USB storage", MB_OK); KoboUnexportUSBStorage(); diff --git a/src/Kobo/ToolsDialog.cpp b/src/Kobo/ToolsDialog.cpp index a3db7d6fdee..1861ac56351 100644 --- a/src/Kobo/ToolsDialog.cpp +++ b/src/Kobo/ToolsDialog.cpp @@ -59,7 +59,7 @@ void ToolsWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { ScriptFileVisitor sfv(list); - Directory::VisitFiles(Path(_T("/mnt/onboard/XCSoarData/kobo/scripts")), sfv); + Directory::VisitFiles(Path("/mnt/onboard/XCSoarData/kobo/scripts"), sfv); unsigned len = list.size(); if (len > 0) diff --git a/src/Kobo/WifiDialog.cpp b/src/Kobo/WifiDialog.cpp index 5fdc45b3cf2..928b0c40bd0 100644 --- a/src/Kobo/WifiDialog.cpp +++ b/src/Kobo/WifiDialog.cpp @@ -187,7 +187,7 @@ WifiListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, if (addr.IsDefined()) { /* valid address? */ StaticString<40> addr_str; if (addr.ToString(addr_str.buffer(), addr_str.capacity()) != nullptr) { - state_buffer.Format(_T("%s (%s)"), state, addr_str.c_str()); + state_buffer.Format("%s (%s)", state, addr_str.c_str()); state = state_buffer; } } @@ -204,7 +204,7 @@ WifiListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, if (info.signal_detected) { StaticString<36> text; - text.UnsafeFormat(signal_level_in_dbm ? _T("%s %d dBm") : _T("%s %d"), + text.UnsafeFormat(signal_level_in_dbm ? "%s %d dBm" : "%s %d", wifi_security[info.security], info.signal_level); row_renderer.DrawRightSecondRow(canvas, rc, text); } diff --git a/src/Language/Language.hpp b/src/Language/Language.hpp index 07fb51a9398..fa81b919947 100644 --- a/src/Language/Language.hpp +++ b/src/Language/Language.hpp @@ -41,8 +41,8 @@ const char* gettext(const char* text); /** * For source compatibility with GNU gettext. */ -#define _(x) gettext(_T(x)) -#define N_(x) _T(x) +#define _(x) gettext(x) +#define N_(x) x void reset_gettext_cache(); diff --git a/src/Language/LanguageGlue.cpp b/src/Language/LanguageGlue.cpp index 7333d2b6019..99a3703df77 100644 --- a/src/Language/LanguageGlue.cpp +++ b/src/Language/LanguageGlue.cpp @@ -193,20 +193,20 @@ InitNativeGettext(const char *locale) noexcept static bool ReadBuiltinLanguage(const BuiltinLanguage &language) noexcept { - LogFormat(_T("Language: loading resource '%s'"), language.resource); + LogFormat("Language: loading resource '%s'", language.resource); #ifdef HAVE_BUILTIN_LANGUAGES // Load MO file from resource delete mo_loader; mo_loader = new MOLoader({language.begin, (size_t)language.size}); if (mo_loader->error()) { - LogFormat(_T("Language: could not load resource '%s'"), language.resource); + LogFormat("Language: could not load resource '%s'", language.resource); delete mo_loader; mo_loader = nullptr; return false; } - LogFormat(_T("Loaded translations from resource '%s'"), language.resource); + LogFormat("Loaded translations from resource '%s'", language.resource); mo_file = &mo_loader->get(); #else @@ -242,7 +242,7 @@ static bool LoadLanguageFile([[maybe_unused]] Path path) noexcept { #ifdef HAVE_BUILTIN_LANGUAGES - LogFormat(_T("Language: loading file '%s'"), path.c_str()); + LogFormat("Language: loading file '%s'", path.c_str()); delete mo_loader; mo_loader = nullptr; @@ -250,7 +250,7 @@ LoadLanguageFile([[maybe_unused]] Path path) noexcept try { mo_loader = new MOLoader(path); if (mo_loader->error()) { - LogFormat(_T("Language: could not load file '%s'"), path.c_str()); + LogFormat("Language: could not load file '%s'", path.c_str()); delete mo_loader; mo_loader = nullptr; return false; @@ -260,7 +260,7 @@ LoadLanguageFile([[maybe_unused]] Path path) noexcept return false; } - LogFormat(_T("Loaded translations from file '%s'"), path.c_str()); + LogFormat("Loaded translations from file '%s'", path.c_str()); mo_file = &mo_loader->get(); return true; @@ -293,12 +293,12 @@ ReadLanguageFile() noexcept auto value = Profile::GetPath(ProfileKeys::LanguageFile); - if (value == nullptr || value.empty() || value == Path(_T("auto"))) { + if (value == nullptr || value.empty() || value == Path("auto")) { AutoDetectLanguage(); return; } - if (value == Path(_T("none"))) + if (value == Path("none")) return; Path base = value.GetBase(); diff --git a/src/Language/Table.cpp b/src/Language/Table.cpp index 926ad14847a..6ac2632cf8b 100644 --- a/src/Language/Table.cpp +++ b/src/Language/Table.cpp @@ -78,15 +78,15 @@ extern "C" } #ifdef _WIN32 -#define L(number, locale, code_name, display_name) { number, code_name ## _mo, code_name ## _mo_size, _T( #code_name ".mo"), _T(display_name) } +#define L(number, locale, code_name, display_name) { number, code_name ## _mo, code_name ## _mo_size, #code_name ".mo", display_name } #else -#define L(number, locale, code_name, display_name) { code_name ## _mo, code_name ## _mo_size, _T( #code_name ".mo"), _T(display_name) } +#define L(number, locale, code_name, display_name) { code_name ## _mo, code_name ## _mo_size, #code_name ".mo", display_name } #endif #endif // HAVE_BUILTIN_LANGUAGES #ifdef USE_LIBINTL -#define L(number, locale, code_name, display_name) { #locale ".UTF-8", _T( #code_name ".mo"), _T(display_name) } +#define L(number, locale, code_name, display_name) { #locale ".UTF-8", #code_name ".mo", display_name } #endif // USE_LIBINTL #ifdef _WIN32 diff --git a/src/LocalPath.cpp b/src/LocalPath.cpp index d162a6f3f00..7e4910455f1 100644 --- a/src/LocalPath.cpp +++ b/src/LocalPath.cpp @@ -75,7 +75,7 @@ SetPrimaryDataPath(Path path) noexcept data_paths.emplace_front(path); #ifndef ANDROID - cache_path = LocalPath(_T("cache")); + cache_path = LocalPath("cache"); #endif } @@ -89,7 +89,7 @@ SetSingleDataPath(Path path) noexcept data_paths.emplace_front(path); #ifndef ANDROID - cache_path = LocalPath(_T("cache")); + cache_path = LocalPath("cache"); #endif } @@ -121,7 +121,7 @@ RelativePath(Path path) noexcept return path.RelativeTo(GetPrimaryDataPath()); } -static constexpr char local_path_code[] = _T("%LOCAL_PATH%\\"); +static constexpr char local_path_code[] = "%LOCAL_PATH%\\"; [[gnu::pure]] static const char * @@ -131,7 +131,7 @@ AfterLocalPathCode(const char *p) noexcept if (p == nullptr) return nullptr; - while (*p == _T('/') || *p == _T('\\')) + while (*p == '/' || *p == '\\') ++p; if (StringIsEmpty(p)) @@ -184,7 +184,7 @@ FindDataPathAtModule(HMODULE hModule) noexcept if (GetModuleFileName(hModule, buffer, MAX_PATH) <= 0) return nullptr; - ReplaceBaseName(buffer, _T(OPENSOAR_DATADIR)); + ReplaceBaseName(buffer, OPENSOAR_DATADIR); return Directory::Exists(Path(buffer)) ? AllocatedPath(buffer) : nullptr; @@ -199,7 +199,7 @@ FindDataPaths() noexcept /* Kobo: hard-coded OpenSoarData path */ if constexpr (IsKobo()) { - result.emplace_back(_T(KOBO_USER_DATA DIR_SEPARATOR_S OPENSOAR_DATADIR)); + result.emplace_back(KOBO_USER_DATA DIR_SEPARATOR_S OPENSOAR_DATADIR); return result; } @@ -248,7 +248,7 @@ FindDataPaths() noexcept char buffer[MAX_PATH]; if (SHGetSpecialFolderPath(nullptr, buffer, CSIDL_PERSONAL, result.empty())) - result.emplace_back(AllocatedPath::Build(buffer, _T(OPENSOAR_DATADIR))); + result.emplace_back(AllocatedPath::Build(buffer, OPENSOAR_DATADIR)); } #endif // _WIN32 @@ -321,7 +321,7 @@ InitialiseDataPath() throw std::runtime_error("No Android cache directory"); #else - cache_path = LocalPath(_T("cache")); + cache_path = LocalPath("cache"); #endif } diff --git a/src/LogFile.cpp b/src/LogFile.cpp index f04632d2c5b..6a1dfeb168d 100644 --- a/src/LogFile.cpp +++ b/src/LogFile.cpp @@ -46,12 +46,12 @@ OpenLog() * '-datapath=' * A handler for this is possible but make the management much complicated! */ - path = LocalPath(_T("OpenSoar")); + path = LocalPath("OpenSoar"); /* delete the obsolete log file */ - File::Delete(path + _T("-startup.log")); - auto back_path = path + _T("-old.log"); - path = path + _T(".log"); + File::Delete(path + "-startup.log"); + auto back_path = path + "-old.log"; + path = path + ".log"; File::Replace(path, back_path); #ifdef ANDROID diff --git a/src/Logger/ExternalLogger.cpp b/src/Logger/ExternalLogger.cpp index de8e762a39e..cde81a08c85 100644 --- a/src/Logger/ExternalLogger.cpp +++ b/src/Logger/ExternalLogger.cpp @@ -52,7 +52,7 @@ DoDeviceDeclare(DeviceDescriptor &device, const Declaration &declaration, { TriStateJob job(device, declaration, home); JobDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T(""), job, true); + "", job, true); return job.GetResult(); } @@ -142,7 +142,7 @@ DoReadFlightList(DeviceDescriptor &device, RecordedFlightList &flight_list) { TriStateJob job(device, flight_list); JobDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T(""), job, true); + "", job, true); return job.GetResult(); } @@ -167,7 +167,7 @@ DoDownloadFlight(DeviceDescriptor &device, { TriStateJob job(device, flight, path); JobDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T(""), job, true); + "", job, true); return job.GetResult(); } @@ -222,7 +222,7 @@ ShowFlightList(const RecordedFlightList &flight_list) const RecordedFlightInfo &flight = flight_list[i]; StaticString<64> buffer; - buffer.UnsafeFormat(_T("%04u/%02u/%02u %02u:%02u-%02u:%02u"), + buffer.UnsafeFormat("%04u/%02u/%02u %02u:%02u-%02u:%02u", flight.date.year, flight.date.month, flight.date.day, flight.start_time.hour, flight.start_time.minute, flight.end_time.hour, flight.end_time.minute); @@ -231,7 +231,7 @@ ShowFlightList(const RecordedFlightList &flight_list) } // Show list of the flights - int i = ComboPicker(_T("Choose a flight"), + int i = ComboPicker("Choose a flight", combo, nullptr, false); return i < 0 ? nullptr : &flight_list[i]; @@ -274,7 +274,7 @@ ExternalLogger::DownloadFlightFrom(DeviceDescriptor &device) return; } - const auto logs_path = MakeLocalPath(_T("logs")); + const auto logs_path = MakeLocalPath("logs"); while (true) { // Show list of the flights @@ -284,7 +284,7 @@ ExternalLogger::DownloadFlightFrom(DeviceDescriptor &device) // Download chosen IGC file into temporary file FileTransaction transaction(AllocatedPath::Build(logs_path, - _T("temp.igc"))); + "temp.igc")); try { switch (DoDownloadFlight(device, *flight, transaction.GetTemporaryPath())) { diff --git a/src/Logger/Logger.cpp b/src/Logger/Logger.cpp index 6ae9e1d0d5b..3a3f9fca1fc 100644 --- a/src/Logger/Logger.cpp +++ b/src/Logger/Logger.cpp @@ -69,15 +69,15 @@ Logger::GUIStartLogger(const NMEAInfo& gps_info, if (task) { if (!noAsk) { char TaskMessage[1024]; - strcpy(TaskMessage, _T("Start Logger With Declaration\r\n")); + strcpy(TaskMessage, "Start Logger With Declaration\r\n"); if (decl.Size()) { for (unsigned i = 0; i< decl.Size(); ++i) { strcat(TaskMessage, decl.GetName(i)); - strcat(TaskMessage, _T("\r\n")); + strcat(TaskMessage, "\r\n"); } } else { - strcat(TaskMessage, _T("None")); + strcat(TaskMessage, "None"); } if (ShowMessageBox(TaskMessage, _("Start Logger"), @@ -87,7 +87,7 @@ Logger::GUIStartLogger(const NMEAInfo& gps_info, } const std::lock_guard protect{lock}; - logger.StartLogger(gps_info, settings.logger, _T(""), decl); + logger.StartLogger(gps_info, settings.logger, "", decl); } void diff --git a/src/Logger/LoggerImpl.cpp b/src/Logger/LoggerImpl.cpp index 44dba072e51..9ce2267f253 100644 --- a/src/Logger/LoggerImpl.cpp +++ b/src/Logger/LoggerImpl.cpp @@ -72,7 +72,7 @@ LoggerImpl::StopLogger([[maybe_unused]] const NMEAInfo &gps_info) writer->Flush(); - LogFormat(_T("Logger stopped: %s"), filename.c_str()); + LogFormat("Logger stopped: %s", filename.c_str()); // Logger off writer.reset(); @@ -202,7 +202,7 @@ LoggerImpl::StartLogger(const NMEAInfo &gps_info, assert(writer == nullptr); - const auto logs_path = MakeLocalPath(_T("logs")); + const auto logs_path = MakeLocalPath("logs"); const BrokenDate today = gps_info.date_time_utc.IsDatePlausible() ? gps_info.date_time_utc.GetDate() @@ -226,7 +226,7 @@ LoggerImpl::StartLogger(const NMEAInfo &gps_info, return false; } - LogFormat(_T("Logger Started: %s"), filename.c_str()); + LogFormat("Logger Started: %s", filename.c_str()); return true; } @@ -242,16 +242,16 @@ static const char * GetGPSDeviceName() noexcept { if (is_simulator()) - return _T("Simulator"); + return "Simulator"; const DeviceConfig &device = CommonInterface::GetSystemSettings().devices[0]; if (device.UsesDriver()) return device.driver_name; if (device.IsAndroidInternalGPS()) - return _T("Internal GPS (Android)"); + return "Internal GPS (Android)"; - return _T("Unknown"); + return "Unknown"; } // TODO: fix scope so only gui things can start it @@ -268,8 +268,8 @@ LoggerImpl::StartLogger(const NMEAInfo &gps_info, unsigned asset_length = strlen(asset_number); for (unsigned i = 0; i < 3; i++) logger_id[i] = i < asset_length && IsAlphaNumericASCII(asset_number[i]) ? - asset_number[i] : _T('A'); - logger_id[3] = _T('\0'); + asset_number[i] : 'A'; + logger_id[3] = '\0'; if (!StartLogger(gps_info, settings, logger_id)) return; diff --git a/src/Logger/NMEALogger.cpp b/src/Logger/NMEALogger.cpp index 6d44709fe5a..6bd458de8cb 100644 --- a/src/Logger/NMEALogger.cpp +++ b/src/Logger/NMEALogger.cpp @@ -22,11 +22,11 @@ NMEALogger::Start() assert(dt.IsPlausible()); StaticString<64> name; - name.Format(_T("%04u-%02u-%02u_%02u-%02u.nmea"), + name.Format("%04u-%02u-%02u_%02u-%02u.nmea", dt.year, dt.month, dt.day, dt.hour, dt.minute); - const auto logs_path = MakeLocalPath(_T("logs")); + const auto logs_path = MakeLocalPath("logs"); const auto path = AllocatedPath::Build(logs_path, name); file = std::make_unique(path, diff --git a/src/Look/InfoBoxLook.cpp b/src/Look/InfoBoxLook.cpp index e14ced6c7b0..0107be9cbb8 100644 --- a/src/Look/InfoBoxLook.cpp +++ b/src/Look/InfoBoxLook.cpp @@ -65,18 +65,18 @@ InfoBoxLook::ReinitialiseLayout(unsigned width) const unsigned max_font_height = Layout::FontScale(12); FontDescription title_font_d(8); - AutoSizeFont(title_font_d, width, _T("0123456789")); + AutoSizeFont(title_font_d, width, "0123456789"); if (title_font_d.GetHeight() > max_font_height) title_font_d.SetHeight(max_font_height); title_font.Load(title_font_d); FontDescription value_font_d(10, true); - AutoSizeFont(value_font_d, width, _T("1234m")); + AutoSizeFont(value_font_d, width, "1234m"); value_font.Load(value_font_d); FontDescription small_value_font_d(10); - AutoSizeFont(small_value_font_d, width, _T("12345m")); + AutoSizeFont(small_value_font_d, width, "12345m"); small_value_font.Load(small_value_font_d); unsigned unit_font_height = std::max(value_font_d.GetHeight() * 2u / 5u, 7u); diff --git a/src/Look/StandardFonts.hpp b/src/Look/StandardFonts.hpp index b3a4dc1225e..5f0fff66c22 100644 --- a/src/Look/StandardFonts.hpp +++ b/src/Look/StandardFonts.hpp @@ -9,12 +9,12 @@ static inline const char * GetStandardMonospaceFontFace() noexcept { - return _T("Consolas"); + return "Consolas"; } [[gnu::const]] static inline const char * GetStandardFontFace() noexcept { - return _T("Segeo UI"); + return "Segeo UI"; } diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 5993af9a9ed..4cfbdfedfcd 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -712,7 +712,7 @@ MainWindow::RunTimer() noexcept if (CommonInterface::GetUISettings().thermal_assistant_position == UISettings::ThermalAssistantPosition::OFF) { thermal_assistant.Clear(); } else if (!CommonInterface::Calculated().circling || - InputEvents::IsFlavour(_T("TA"))) { + InputEvents::IsFlavour("TA")) { thermal_assistant.Hide(); } else if (!HasDialog()) { if (!thermal_assistant.IsDefined()) @@ -1107,7 +1107,7 @@ MainWindow::UpdateTrafficGaugeVisibility() noexcept !CommonInterface::GetUIState().screen_blanked && /* hide the traffic gauge while the traffic widget is visible, to avoid showing the same information twice */ - !InputEvents::IsFlavour(_T("Traffic")); + !InputEvents::IsFlavour("Traffic"); if (traffic_visible && suppress_traffic_gauge) { if (flarm.status.available && diff --git a/src/MainWindow.hpp b/src/MainWindow.hpp index 940a9578838..db95369cd21 100644 --- a/src/MainWindow.hpp +++ b/src/MainWindow.hpp @@ -37,7 +37,7 @@ namespace InfoBoxLayout { struct Layout; } * The XCSoar main window. */ class MainWindow : public UI::SingleWindow { - static constexpr const char *title = _T("OpenSoar"); + static constexpr const char *title = "OpenSoar"; Look *look = nullptr; diff --git a/src/MapWindow/GlueMapWindowOverlays.cpp b/src/MapWindow/GlueMapWindowOverlays.cpp index f0ae0997f2c..c41a22d66ec 100644 --- a/src/MapWindow/GlueMapWindowOverlays.cpp +++ b/src/MapWindow/GlueMapWindowOverlays.cpp @@ -121,13 +121,13 @@ GlueMapWindow::DrawPanInfo(Canvas &canvas) const noexcept } char buffer[256]; - FormatGeoPoint(location, buffer, ARRAY_SIZE(buffer), _T('\n')); + FormatGeoPoint(location, buffer, ARRAY_SIZE(buffer), '\n'); char *start = buffer; while (true) { - auto *newline = StringFind(start, _T('\n')); + auto *newline = StringFind(start, '\n'); if (newline != nullptr) - *newline = _T('\0'); + *newline = '\0'; TextInBox(canvas, start, p, mode, render_projection.GetScreenSize()); @@ -310,33 +310,33 @@ GlueMapWindow::DrawMapScale(Canvas &canvas, const PixelRect &rc, buffer.clear(); if (GetMapSettings().auto_zoom_enabled) - buffer = _T("AUTO "); + buffer = "AUTO "; switch (follow_mode) { case FOLLOW_SELF: break; case FOLLOW_PAN: - buffer += _T("PAN "); + buffer += "PAN "; break; } const UIState &ui_state = GetUIState(); if (ui_state.auxiliary_enabled) { buffer += ui_state.panel_name; - buffer += _T(" "); + buffer += " "; } if (Basic().gps.replay) - buffer += _T("REPLAY "); + buffer += "REPLAY "; else if (Basic().gps.simulator) { buffer += _("Simulator"); - buffer += _T(" "); + buffer += " "; } if (GetComputerSettings().polar.ballast_timer_active) buffer.AppendFormat( - _T("BALLAST %d LITERS "), + "BALLAST %d LITERS ", (int)GetComputerSettings().polar.glide_polar_task.GetBallastLitres()); if (rasp_renderer != nullptr) { diff --git a/src/MapWindow/Items/TrafficBuilder.cpp b/src/MapWindow/Items/TrafficBuilder.cpp index 00fa89a0d93..6dc670dafda 100644 --- a/src/MapWindow/Items/TrafficBuilder.cpp +++ b/src/MapWindow/Items/TrafficBuilder.cpp @@ -48,7 +48,7 @@ MapItemListBuilder::AddSkyLinesTraffic() const char *name; if (name_i == data.user_names.end()) { /* no name found */ - buffer.UnsafeFormat(_T("SkyLines %u"), (unsigned)id); + buffer.UnsafeFormat("SkyLines %u", (unsigned)id); name = buffer; } else /* we know the name */ diff --git a/src/MapWindow/MapWindowTask.cpp b/src/MapWindow/MapWindowTask.cpp index 05663bfc221..6777c4ef6da 100644 --- a/src/MapWindow/MapWindowTask.cpp +++ b/src/MapWindow/MapWindowTask.cpp @@ -130,7 +130,7 @@ MapWindow::DrawTaskOffTrackIndicator(Canvas &canvas) noexcept if ((idist != ilast) && (idist > 0) && (idist < 1000)) { char Buffer[5]; - _stprintf(Buffer, _T("%d"), idist); + _stprintf(Buffer, "%d", idist); auto sc = render_projection.GeoToScreen(dloc); PixelSize tsize = canvas.CalcTextSize(Buffer); canvas.DrawText(sc - tsize / 2u, Buffer); diff --git a/src/MapWindow/MapWindowTraffic.cpp b/src/MapWindow/MapWindowTraffic.cpp index 7505ba3fb87..09f26dedd0a 100644 --- a/src/MapWindow/MapWindowTraffic.cpp +++ b/src/MapWindow/MapWindowTraffic.cpp @@ -237,10 +237,10 @@ MapWindow::DrawSkyLinesTraffic(Canvas &canvas) const noexcept const auto name_i = skylines_data->user_names.find(i.first); const char *name = name_i != skylines_data->user_names.end() ? name_i->second.c_str() - : _T(""); + : ""; StaticString<128> buffer; - buffer.Format(_T("%s [%um]"), name, i.second.altitude); + buffer.Format("%s [%um]", name, i.second.altitude); TextInBoxMode mode; mode.shape = LabelShape::OUTLINED; diff --git a/src/Markers/Markers.cpp b/src/Markers/Markers.cpp index 0de4c262a4b..329c3b3382c 100644 --- a/src/Markers/Markers.cpp +++ b/src/Markers/Markers.cpp @@ -14,7 +14,7 @@ MarkLocation(const GeoPoint &loc, const BrokenDateTime &time) try { assert(time.IsPlausible()); - FileOutputStream file(LocalPath(_T("xcsoar-marks.txt")), + FileOutputStream file(LocalPath("xcsoar-marks.txt"), FileOutputStream::Mode::APPEND_OR_CREATE); BufferedOutputStream os(file); os.Fmt("{:02}.{:02}.{:04}\t{:02}:{:02}:{:02}\tLon:{:f}\tLat:{:f}\n", diff --git a/src/Menu/ButtonLabel.cpp b/src/Menu/ButtonLabel.cpp index 01b83d8616f..e6604fb033d 100644 --- a/src/Menu/ButtonLabel.cpp +++ b/src/Menu/ButtonLabel.cpp @@ -38,7 +38,7 @@ GetTextN(const char *src, const char *src_end, if (src == src_end) /* gettext("") returns the PO header, and thus we need to exclude this special case */ - return _T(""); + return ""; const size_t src_length = src_end - src; if (src_length >= buffer_size) @@ -47,7 +47,7 @@ GetTextN(const char *src, const char *src_end, /* copy to buffer, because gettext() expects a null-terminated string */ - *std::copy(src, src_end, buffer) = _T('\0'); + *std::copy(src, src_end, buffer) = '\0'; return gettext(buffer); } @@ -58,7 +58,7 @@ ButtonLabel::Expand(const char *text, std::span buffer) noexcept Expanded expanded; const char *dollar; - if (text == nullptr || *text == _T('\0') || *text == _T(' ')) { + if (text == nullptr || *text == '\0' || *text == ' ') { expanded.visible = false; return expanded; } else if ((dollar = StringFind(text, '$')) == nullptr) { @@ -99,7 +99,7 @@ ButtonLabel::Expand(const char *text, std::span buffer) noexcept char s[100]; expanded.enabled = !ExpandMacros(text, std::span{s}); - if (s[0] == _T('\0') || s[0] == _T(' ')) { + if (s[0] == '\0' || s[0] == ' ') { expanded.visible = false; return expanded; } diff --git a/src/Menu/ExpandMacros.cpp b/src/Menu/ExpandMacros.cpp index 26592863759..62dc2ccec56 100644 --- a/src/Menu/ExpandMacros.cpp +++ b/src/Menu/ExpandMacros.cpp @@ -38,14 +38,14 @@ ExpandTaskMacros(std::string_view name, const TaskStats &ordered_task_stats = calculated.ordered_task_stats; const CommonStats &common_stats = calculated.common_stats; - if (name == _T("CheckTaskResumed")) { + if (name == "CheckTaskResumed") { // TODO code: check, does this need to be set with temporary task? invalid |= common_stats.task_type == TaskType::ABORT || common_stats.task_type == TaskType::GOTO; - return _T(""); - } else if (name == _T("CheckTask")) { + return ""; + } else if (name == "CheckTask") { invalid |= !task_stats.task_valid; - return _T(""); + return ""; } if (!backend_components->protected_task_manager) { @@ -59,24 +59,24 @@ ExpandTaskMacros(std::string_view name, if (task == nullptr || !task_stats.task_valid || common_stats.task_type == TaskType::GOTO) { - if (name == _T("WaypointNext") || - name == _T("WaypointNextArm")) { + if (name == "WaypointNext" || + name == "WaypointNextArm") { invalid = true; return _("Next Turnpoint"); - } else if (name == _T("WaypointPrevious") || - name == _T("WaypointPreviousArm")) { + } else if (name == "WaypointPrevious" || + name == "WaypointPreviousArm") { invalid = true; return _("Previous Turnpoint"); } } else if (common_stats.task_type == TaskType::ABORT) { - if (name == _T("WaypointNext") || - name == _T("WaypointNextArm")) { + if (name == "WaypointNext" || + name == "WaypointNextArm") { invalid |= !common_stats.active_has_next; return common_stats.next_is_last ? _("Furthest Landpoint") : _("Next Landpoint"); - } else if (name == _T("WaypointPrevious") || - name == _T("WaypointPreviousArm")) { + } else if (name == "WaypointPrevious" || + name == "WaypointPreviousArm") { invalid |= !common_stats.active_has_previous; return common_stats.previous_is_first @@ -90,13 +90,13 @@ ExpandTaskMacros(std::string_view name, const bool previous_is_start = common_stats.previous_is_first; const bool has_optional_starts = ordered_task_stats.has_optional_starts; - if (name == _T("WaypointNext")) { + if (name == "WaypointNext") { // Waypoint\nNext invalid |= !common_stats.active_has_next; return next_is_final ? _("Finish Turnpoint") : _("Next Turnpoint"); - } else if (name == _T("WaypointPrevious")) { + } else if (name == "WaypointPrevious") { if (has_optional_starts && !common_stats.active_has_previous) { return _("Next Startpoint"); } else { @@ -106,7 +106,7 @@ ExpandTaskMacros(std::string_view name, : _("Previous Turnpoint"); } - } else if (name == _T("WaypointNextArm")) { + } else if (name == "WaypointNextArm") { // Waypoint\nNext switch (task_manager->GetOrderedTask().GetTaskAdvance().GetState()) { @@ -126,7 +126,7 @@ ExpandTaskMacros(std::string_view name, return _("Arm turn"); } - } else if (name == _T("WaypointPreviousArm")) { + } else if (name == "WaypointPreviousArm") { switch (task_manager->GetOrderedTask().GetTaskAdvance().GetState()) { case TaskAdvance::MANUAL: @@ -152,7 +152,7 @@ ExpandTaskMacros(std::string_view name, } } - if (name == _T("AdvanceArmed")) { + if (name == "AdvanceArmed") { switch (task_manager->GetOrderedTask().GetTaskAdvance().GetState()) { case TaskAdvance::MANUAL: invalid = true; @@ -174,11 +174,11 @@ ExpandTaskMacros(std::string_view name, case TaskAdvance::TURN_DISARMED: return _("Arm\nTurn"); } - } else if (name == _T("CheckAutoMc")) { + } else if (name == "CheckAutoMc") { invalid |= !task_stats.task_valid && settings_computer.task.IsAutoMCFinalGlideEnabled(); - return _T(""); - } else if (name == _T("TaskAbortToggleActionName")) { + return ""; + } else if (name == "TaskAbortToggleActionName") { if (common_stats.task_type == TaskType::GOTO) return ordered_task_stats.task_valid ? _("Resume") @@ -187,10 +187,10 @@ ExpandTaskMacros(std::string_view name, return common_stats.task_type == TaskType::ABORT ? _("Resume") : _("Abort"); - } else if (name == _T("CheckTaskRestart")) { + } else if (name == "CheckTaskRestart") { invalid |= !(common_stats.task_type == TaskType::ORDERED && task_stats.start.HasStarted()); - return _T(""); + return ""; } return nullptr; @@ -201,13 +201,13 @@ static const char * ExpandTrafficMacros(std::string_view name) noexcept { TrafficWidget *widget = (TrafficWidget *) - CommonInterface::main_window->GetFlavourWidget(_T("Traffic")); + CommonInterface::main_window->GetFlavourWidget("Traffic"); if (widget == nullptr) return nullptr; - if (name == _T("TrafficZoomAutoToggleActionName")) + if (name == "TrafficZoomAutoToggleActionName") return widget->GetAutoZoom() ? _("Manual") : _("Auto"); - else if (name == _T("TrafficNorthUpToggleActionName")) + else if (name == "TrafficNorthUpToggleActionName") return widget->GetNorthUp() ? _("Track up") : _("North up"); else return nullptr; @@ -246,7 +246,7 @@ GetUIState() noexcept static const char * LookupMacro(std::string_view name, bool &invalid) noexcept { - if (name ==_T("CheckAirspace")) { + if (name =="CheckAirspace") { invalid |= data_components->airspaces->IsEmpty(); return nullptr; } @@ -262,54 +262,54 @@ LookupMacro(std::string_view name, bool &invalid) noexcept auto vario_sound = CommonInterface::SetUISettings().sound.vario; - if (name ==_T("CheckFLARM")) { + if (name =="CheckFLARM") { invalid |= !Basic().flarm.status.available; return nullptr; - } else if (name == _T("CheckWeather")) { + } else if (name == "CheckWeather") { const auto rasp = DataGlobals::GetRasp(); invalid |= rasp == nullptr || rasp->GetItemCount() == 0; return nullptr; - } else if (name == _T("CheckCircling")) { + } else if (name == "CheckCircling") { invalid |= !Calculated().circling; return nullptr; - } else if (name == _T("CheckVega")) { + } else if (name == "CheckVega") { invalid |= backend_components->devices == nullptr || !backend_components->devices->HasVega(); return nullptr; - } else if (name == _T("CheckReplay")) { + } else if (name == "CheckReplay") { invalid |= CommonInterface::MovementDetected(); return nullptr; - } else if (name == _T("CheckWaypointFile")) { + } else if (name == "CheckWaypointFile") { invalid |= data_components->waypoints->IsEmpty(); return nullptr; - } else if (name == _T("CheckLogger")) { + } else if (name == "CheckLogger") { invalid |= Basic().gps.replay; return nullptr; - } else if (name == _T("CheckNet")) { + } else if (name == "CheckNet") { #ifndef HAVE_HTTP invalid = true; #endif return nullptr; - } else if (name == _T("CheckTerrain")) { + } else if (name == "CheckTerrain") { invalid |= !Calculated().terrain_valid; return nullptr; - } else if (name == _T("AudioOnOff")) { + } else if (name == "AudioOnOff") { StaticString<10> s; - s.Format(_T("(%u/7)"), + s.Format("(%u/7)", vario_sound.volume > 0 ? 1 + (unsigned)log2(vario_sound.volume) : 0); - return vario_sound.enabled ? s.c_str() : _T("-"); - } else if (name == _T("CheckAudioQuiet")) { + return vario_sound.enabled ? s.c_str() : "-"; + } else if (name == "CheckAudioQuiet") { invalid |= !vario_sound.enabled || vario_sound.volume <= 1; return nullptr; - } else if (name == _T("CheckAudioLoud")) { + } else if (name == "CheckAudioLoud") { invalid |= !vario_sound.enabled || vario_sound.volume >= 100; return nullptr; - } else if (name == _T("LoggerActive")) { + } else if (name == "LoggerActive") { return backend_components->igc_logger != nullptr && backend_components->igc_logger->IsLoggerActive() ? _("Stop") : _("Start"); - } else if (name == _T("SnailTrailToggleName")) { + } else if (name == "SnailTrailToggleName") { switch (GetMapSettings().trail.length) { case TrailSettings::Length::OFF: return _("Long"); @@ -325,10 +325,10 @@ LookupMacro(std::string_view name, bool &invalid) noexcept } return nullptr; - } else if (name == _T("AirSpaceToggleName")) { + } else if (name == "AirSpaceToggleName") { return GetMapSettings().airspace.enable ? _("Off") : _("On"); - } else if (name == _T("TerrainTopologyToggleName") || - name == _T("TerrainTopographyToggleName")) { + } else if (name == "TerrainTopologyToggleName" || + name == "TerrainTopographyToggleName") { char val = 0; if (GetMapSettings().topography_enabled) val++; @@ -350,18 +350,18 @@ LookupMacro(std::string_view name, bool &invalid) noexcept } return nullptr; - } else if (name == _T("FullScreenToggleActionName")) { + } else if (name == "FullScreenToggleActionName") { return CommonInterface::main_window->GetFullScreen() ? _("Off") : _("On"); - } else if (name == _T("ZoomAutoToggleActionName")) { + } else if (name == "ZoomAutoToggleActionName") { return GetMapSettings().auto_zoom_enabled ? _("Manual") : _("Auto"); - } else if (name == _T("TopologyToggleActionName") || - name == _T("TopographyToggleActionName")) { + } else if (name == "TopologyToggleActionName" || + name == "TopographyToggleActionName") { return GetMapSettings().topography_enabled ? _("Hide") : _("Show"); - } else if (name == _T("TerrainToggleActionName")) { + } else if (name == "TerrainToggleActionName") { return GetMapSettings().terrain.enable ? _("Hide") : _("Show"); - } else if (name == _T("AirspaceToggleActionName")) { + } else if (name == "AirspaceToggleActionName") { return GetMapSettings().airspace.enable ? _("Hide") : _("Show"); - } else if (name == _T("MapLabelsToggleActionName")) { + } else if (name == "MapLabelsToggleActionName") { static const char *const labels[] = { N_("All"), N_("Task & Landables"), @@ -373,59 +373,59 @@ LookupMacro(std::string_view name, bool &invalid) noexcept static constexpr unsigned int n = ARRAY_SIZE(labels); unsigned int i = (unsigned)GetMapSettings().waypoint.label_selection; return gettext(labels[(i + 1) % n]); - } else if (name == _T("MacCreadyToggleActionName")) { + } else if (name == "MacCreadyToggleActionName") { return GetComputerSettings().task.auto_mc ? _("Manual") : _("Auto"); - } else if (name == _T("AuxInfoToggleActionName")) { + } else if (name == "AuxInfoToggleActionName") { return GetUIState().auxiliary_enabled ? _("Off") : _("On"); - } else if (name == _T("DispModeClimbShortIndicator")) { + } else if (name == "DispModeClimbShortIndicator") { return GetUIState().force_display_mode == DisplayMode::CIRCLING - ? _T("*") : _T(""); - } else if (name == _T("DispModeCruiseShortIndicator")) { + ? "*" : ""; + } else if (name == "DispModeCruiseShortIndicator") { return GetUIState().force_display_mode == DisplayMode::CRUISE - ? _T("*") : _T(""); - } else if (name == _T("DispModeAutoShortIndicator")) { + ? "*" : ""; + } else if (name == "DispModeAutoShortIndicator") { return GetUIState().force_display_mode == DisplayMode::NONE - ? _T("*") : _T(""); - } else if (name == _T("DispModeFinalShortIndicator")) { + ? "*" : ""; + } else if (name == "DispModeFinalShortIndicator") { return GetUIState().force_display_mode == DisplayMode::FINAL_GLIDE - ? _T("*") : _T(""); - } else if (name == _T("AirspaceModeAllShortIndicator")) { + ? "*" : ""; + } else if (name == "AirspaceModeAllShortIndicator") { return GetMapSettings().airspace.altitude_mode == AirspaceDisplayMode::ALLON - ? _T("*") : _T(""); - } else if (name == _T("AirspaceModeClipShortIndicator")) { + ? "*" : ""; + } else if (name == "AirspaceModeClipShortIndicator") { return GetMapSettings().airspace.altitude_mode == AirspaceDisplayMode::CLIP - ? _T("*") : _T(""); - } else if (name == _T("AirspaceModeAutoShortIndicator")) { + ? "*" : ""; + } else if (name == "AirspaceModeAutoShortIndicator") { return GetMapSettings().airspace.altitude_mode == AirspaceDisplayMode::AUTO - ? _T("*") : _T(""); - } else if (name == _T("AirspaceModeBelowShortIndicator")) { + ? "*" : ""; + } else if (name == "AirspaceModeBelowShortIndicator") { return GetMapSettings().airspace.altitude_mode == AirspaceDisplayMode::ALLBELOW - ? _T("*") : _T(""); - } else if (name == _T("AirspaceModeAllOffIndicator")) { + ? "*" : ""; + } else if (name == "AirspaceModeAllOffIndicator") { return GetMapSettings().airspace.altitude_mode == AirspaceDisplayMode::ALLOFF - ? _T("*") : _T(""); - } else if (name == _T("SnailTrailOffShortIndicator")) { + ? "*" : ""; + } else if (name == "SnailTrailOffShortIndicator") { return GetMapSettings().trail.length == TrailSettings::Length::OFF - ? _T("*") : _T(""); - } else if (name == _T("SnailTrailShortShortIndicator")) { + ? "*" : ""; + } else if (name == "SnailTrailShortShortIndicator") { return GetMapSettings().trail.length == TrailSettings::Length::SHORT - ? _T("*") : _T(""); - } else if (name == _T("SnailTrailLongShortIndicator")) { + ? "*" : ""; + } else if (name == "SnailTrailLongShortIndicator") { return GetMapSettings().trail.length == TrailSettings::Length::LONG - ? _T("*") : _T(""); - } else if (name == _T("SnailTrailFullShortIndicator")) { + ? "*" : ""; + } else if (name == "SnailTrailFullShortIndicator") { return GetMapSettings().trail.length == TrailSettings::Length::FULL - ? _T("*") : _T(""); - } else if (name == _T("AirSpaceOffShortIndicator")) { - return !GetMapSettings().airspace.enable ? _T("*") : _T(""); - } else if (name == _T("AirSpaceOnShortIndicator")) { - return GetMapSettings().airspace.enable ? _T("*") : _T(""); - } else if (name == _T("FlarmDispToggleActionName")) { + ? "*" : ""; + } else if (name == "AirSpaceOffShortIndicator") { + return !GetMapSettings().airspace.enable ? "*" : ""; + } else if (name == "AirSpaceOnShortIndicator") { + return GetMapSettings().airspace.enable ? "*" : ""; + } else if (name == "FlarmDispToggleActionName") { return CommonInterface::GetUISettings().traffic.enable_gauge ? _("Off") : _("On"); - } else if (name == _T("ZoomAutoToggleActionName")) { + } else if (name == "ZoomAutoToggleActionName") { return GetMapSettings().auto_zoom_enabled ? _("Manual") : _("Auto"); - } else if (name == _T("NextPageName")) { + } else if (name == "NextPageName") { static char label[64]; // TODO: oh no, a static string buffer! const PageLayout &page = CommonInterface::GetUISettings().pages.pages[PageActions::NextIndex()]; diff --git a/src/Menu/MenuBar.cpp b/src/Menu/MenuBar.cpp index 73f6cf4acb8..f716638cd32 100644 --- a/src/Menu/MenuBar.cpp +++ b/src/Menu/MenuBar.cpp @@ -76,7 +76,7 @@ MenuBar::MenuBar(ContainerWindow &parent, const ButtonLook &look) for (unsigned i = 0; i < MAX_BUTTONS; ++i) { PixelRect button_rc = GetButtonPosition(i, rc); - buttons[i].Create(parent, look, _T(""), button_rc, style); + buttons[i].Create(parent, look, "", button_rc, style); } } diff --git a/src/Menu/MenuData.hpp b/src/Menu/MenuData.hpp index 59fb1658ac5..ae8426112f2 100644 --- a/src/Menu/MenuData.hpp +++ b/src/Menu/MenuData.hpp @@ -32,7 +32,7 @@ class MenuItem { */ [[gnu::pure]] bool IsDynamic() const noexcept { - return label != nullptr && strstr(label, _T("$(")) != nullptr; + return label != nullptr && strstr(label, "$(") != nullptr; } }; diff --git a/src/Monitor/AirspaceWarningMonitor.cpp b/src/Monitor/AirspaceWarningMonitor.cpp index 9bb1c1032c6..0bede527256 100644 --- a/src/Monitor/AirspaceWarningMonitor.cpp +++ b/src/Monitor/AirspaceWarningMonitor.cpp @@ -34,9 +34,9 @@ class AirspaceWarningWidget final AirspaceWarning::State state, const AirspaceInterceptSolution &solution) noexcept { if (state == AirspaceWarning::WARNING_INSIDE) - buffer.Format(_T("%s: %s"), _("Inside airspace"), airspace.GetName()); + buffer.Format("%s: %s", _("Inside airspace"), airspace.GetName()); else - buffer.Format(_T("%s: %s (%s)"), _("Near airspace"), airspace.GetName(), + buffer.Format("%s: %s (%s)", _("Near airspace"), airspace.GetName(), FormatTimespanSmart(solution.elapsed_time, 2).c_str()); @@ -132,7 +132,7 @@ AirspaceWarningMonitor::Check() noexcept // un-blank the display, play a sound ResetUserIdle(); - PlayResource(_T("IDR_WAV_BEEPBWEEP")); + PlayResource("IDR_WAV_BEEPBWEEP"); // show airspace warnings dialog if (CommonInterface::GetUISettings().enable_airspace_warning_dialog) @@ -166,5 +166,5 @@ AirspaceWarningMonitor::Check() noexcept // un-blank the display, play a sound ResetUserIdle(); - PlayResource(_T("IDR_WAV_BEEPBWEEP")); + PlayResource("IDR_WAV_BEEPBWEEP"); } diff --git a/src/Monitor/MatTaskMonitor.cpp b/src/Monitor/MatTaskMonitor.cpp index a8d8f2d7297..8adae698e21 100644 --- a/src/Monitor/MatTaskMonitor.cpp +++ b/src/Monitor/MatTaskMonitor.cpp @@ -29,7 +29,7 @@ class MatTaskAddWidget final [[gnu::pure]] const char *MakeMessage(const Waypoint &wp) { - buffer.Format(_T("%s\n%s"), wp.name.c_str(), _("Add this turn point?")); + buffer.Format("%s\n%s", wp.name.c_str(), _("Add this turn point?")); return buffer; } diff --git a/src/Monitor/TaskConstraintsMonitor.cpp b/src/Monitor/TaskConstraintsMonitor.cpp index 6f565cc1e44..0916bd95a78 100644 --- a/src/Monitor/TaskConstraintsMonitor.cpp +++ b/src/Monitor/TaskConstraintsMonitor.cpp @@ -35,7 +35,7 @@ TaskConstraintsMonitor::Check() !settings.start_constraints.CheckSpeed(basic.ground_speed) && max_start_speed_clock.CheckUpdate(std::chrono::seconds(30))) { StaticString<256> msg; - msg.Format(_T("%s (%s > %s)"), _("Maximum start speed exceeded"), + msg.Format("%s (%s > %s)", _("Maximum start speed exceeded"), FormatUserSpeed(basic.ground_speed).c_str(), FormatUserSpeed(settings.start_constraints.max_speed).c_str()); Message::AddMessage(msg); diff --git a/src/OpenSoar.cpp b/src/OpenSoar.cpp index aeb9089f874..cb99472cdca 100644 --- a/src/OpenSoar.cpp +++ b/src/OpenSoar.cpp @@ -200,7 +200,7 @@ try { ResourceLoader::Init(hInstance); #endif // Write startup note + version to logfile - LogFormat(_T("Starting OpenSoar %s"), OpenSoar_ProductToken); + LogFormat("Starting OpenSoar %s", OpenSoar_ProductToken); // int ret = Main(); diff --git a/src/OpenVario/DisplaySettingsWidget.cpp b/src/OpenVario/DisplaySettingsWidget.cpp index f84442ac491..138cbd3d939 100644 --- a/src/OpenVario/DisplaySettingsWidget.cpp +++ b/src/OpenVario/DisplaySettingsWidget.cpp @@ -60,11 +60,11 @@ enum ControlIndex { }; static constexpr StaticEnumChoice rotation_list[] = { - // { DisplayOrientation::DEFAULT, _T("default") }, - {DisplayOrientation::LANDSCAPE, _T("Landscape (0°)")}, - {DisplayOrientation::PORTRAIT, _T("Portrait (90°)")}, - {DisplayOrientation::REVERSE_LANDSCAPE, _T("Rev. Landscape (180°)")}, - {DisplayOrientation::REVERSE_PORTRAIT, _T("rev. Portrait (270°)")}, + // { DisplayOrientation::DEFAULT, "default" }, + {DisplayOrientation::LANDSCAPE, "Landscape (0°)"}, + {DisplayOrientation::PORTRAIT, "Portrait (90°)"}, + {DisplayOrientation::REVERSE_LANDSCAPE, "Rev. Landscape (180°)"}, + {DisplayOrientation::REVERSE_PORTRAIT, "rev. Portrait (270°)"}, nullptr}; class DisplaySettingsWidget final : public RowFormWidget, DataFieldListener { @@ -127,8 +127,8 @@ DisplaySettingsWidget::Prepare([[maybe_unused]] ContainerWindow &_parent, AddEnum(_("Rotation"), _("Rotation Display OpenVario"), rotation_list, (unsigned)ovdevice.rotation, this); - AddInteger(_("Brightness"), _("Brightness Display OpenVario"), _T("%d%%"), - _T("%d%%"), 10, 100, 10, brightness, this); + AddInteger(_("Brightness"), _("Brightness Display OpenVario"), "%d%%", + "%d%%", 10, 100, 10, brightness, this); AddBoolean(_("Touch enabled"), _("Enabling the tTouch Screen"), ovdevice.touch, this); @@ -170,7 +170,7 @@ ShowDisplaySettingsWidget(ContainerWindow &parent, const DialogLook &look) noexcept { TWidgetDialog sub_dialog( WidgetDialog::Full{}, (UI::SingleWindow &)parent, look, - _T("OpenVario Display Settings")); + "OpenVario Display Settings"); sub_dialog.SetWidget(); sub_dialog.AddButton(_("Close"), mrOK); return sub_dialog.ShowModal(); diff --git a/src/OpenVario/ExtraWidget.cpp b/src/OpenVario/ExtraWidget.cpp index 1101acde79c..b43a2d76194 100644 --- a/src/OpenVario/ExtraWidget.cpp +++ b/src/OpenVario/ExtraWidget.cpp @@ -26,8 +26,8 @@ #include #include -constexpr const char *opensoar = _T("OpenSoar"); -constexpr const char *xcsoar = _T("XCSoar"); +constexpr const char *opensoar = "OpenSoar"; +constexpr const char *xcsoar = "XCSoar"; constexpr const char *main_app = opensoar; constexpr const char *_main_app = "OpenSoar"; // only temporarily @@ -47,7 +47,7 @@ void ExtraWidget::Prepare([[maybe_unused]] ContainerWindow &parent, std::string ImageFile = ""; AddFile(_("Upgrade Firmware"), _("Upgrade Firmware (.img.gz) "), - ImageFile, _T("*.img.gz\0"), FileType::IMAGE); + ImageFile, "*.img.gz\0", FileType::IMAGE); #else AddButton(_("Upgrade Firmware"), [this]() { diff --git a/src/OpenVario/FileMenuWidget.cpp b/src/OpenVario/FileMenuWidget.cpp index b981e7f4b54..177c53ef8cb 100644 --- a/src/OpenVario/FileMenuWidget.cpp +++ b/src/OpenVario/FileMenuWidget.cpp @@ -20,8 +20,8 @@ #include #include -constexpr const char *opensoar = _T("OpenSoar"); -constexpr const char *xcsoar = _T("XCSoar"); +constexpr const char *opensoar = "OpenSoar"; +constexpr const char *xcsoar = "XCSoar"; constexpr const char *main_app = opensoar; constexpr const char *_main_app = "OpenSoar"; // only temporarily @@ -74,7 +74,7 @@ void FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, //----------------------------------------------------- title.Format(_("- Complete System Data Transfers"), main_app); - AddLabel(title); // _T("---OpenSoar Data Files---")); + AddLabel(title); // "---OpenSoar Data Files---"); AddButton(_("Backup: OpenVario System to USB"), []() { static constexpr const char *argv[] = {"/usr/bin/transfer-system.sh", diff --git a/src/OpenVario/OpenVarioBaseMenu.cpp b/src/OpenVario/OpenVarioBaseMenu.cpp index 455eb4b9727..bb814edee99 100644 --- a/src/OpenVario/OpenVarioBaseMenu.cpp +++ b/src/OpenVario/OpenVarioBaseMenu.cpp @@ -152,7 +152,7 @@ class MainMenuWidget final timer.Schedule(std::chrono::seconds{1}); StaticString<256> buffer; - buffer.Format(_T("Starting XCSoar in %u seconds (press any key to cancel)"), + buffer.Format("Starting XCSoar in %u seconds (press any key to cancel)", remaining_seconds); progress_timer->SetText(buffer); } @@ -264,7 +264,7 @@ MainMenuWidget::StartSoarExe(std::string_view _exe, LogFormat("Program file '%s' doesnt exist!", ExePath.c_str()); #ifdef _WIN32 // with Linux ShowMessageBox -> crash! - ShowMessageBox(_("Program file doesnt exist!"), _T("Run"), + ShowMessageBox(_("Program file doesnt exist!"), "Run", MB_OK | MB_ICONEXCLAMATION); #endif } @@ -291,7 +291,7 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, }); //---------------------------------------------------------- - AddReadOnly(_T("")); // split between start cmds and setting + AddReadOnly(""); // split between start cmds and setting //---------------------------------------------------------- AddButton(_("File Transfers"), [this]() { @@ -320,7 +320,7 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, // TWidgetDialog sub_dialog( // WidgetDialog::Full{}, UIGlobals::GetMainWindow(), GetLook(), -// _T("OpenVario Placeholder Settings")); +// "OpenVario Placeholder Settings"); // sub_dialog.SetWidget(display, event_queue, sub_dialog); // // sub_dialog.SetWidget(); // sub_dialog.AddButton(_("Close"), mrOK); @@ -328,32 +328,32 @@ void MainMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, }); //---------------------------------------------------------- - AddReadOnly(_T("")); // split setting and switch off cmds + AddReadOnly(""); // split setting and switch off cmds //---------------------------------------------------------- - auto Btn_Shell = AddButton(_T("Exit to Shell"), + auto Btn_Shell = AddButton("Exit to Shell", [this]() { dialog.SetModalResult(LAUNCH_SHELL); }); #ifndef RELEASE_VERSION - AddButton(_T("Exit to Shell (with Wait)"), + AddButton("Exit to Shell (with Wait)", [this]() { dialog.SetModalResult(LAUNCH_SHELL_STOP); }); #endif auto Btn_Reboot = - AddButton(_T("Reboot"), []() { Run("/sbin/reboot"); }); - // auto Btn_Reboot = AddButton(_T("Reboot"), []() { Run("/sbin/reboot"); }); + AddButton("Reboot", []() { Run("/sbin/reboot"); }); + // auto Btn_Reboot = AddButton("Reboot", []() { Run("/sbin/reboot"); }); auto Btn_Shutdown = - AddButton(_T("Power off"), []() { Run("/sbin/poweroff"); }); - // AddButton(_T("Power off"), []() { "/sbin/poweroff"); }); + AddButton("Power off", []() { Run("/sbin/poweroff"); }); + // AddButton("Power off", []() { "/sbin/poweroff"); }); //---------------------------------------------------------- - progress_timer = RowFormWidget::Add(_T(""), _T(""), true); - // AddReadOnly(_T("")); // Timer-Progress + progress_timer = RowFormWidget::Add("", "", true); + // AddReadOnly(""); // Timer-Progress //---------------------------------------------------------- if (!ovdevice.IsReal()) { - Btn_Shell->SetCaption(_T("Exit")); + Btn_Shell->SetCaption("Exit"); Btn_Reboot->SetEnabled(false); Btn_Shutdown->SetEnabled(false); } @@ -368,7 +368,7 @@ Main(UI::EventQueue &event_queue, UI::SingleWindow &main_window, { TWidgetDialog dialog(WidgetDialog::Full{}, main_window, - dialog_look, _T("OpenVario Base Menu")); + dialog_look, "OpenVario Base Menu"); dialog.SetWidget(main_window.GetDisplay(), event_queue, dialog); return dialog.ShowModal(); @@ -399,7 +399,7 @@ Main() #endif UI::SingleWindow main_window{screen_init.GetDisplay()}; - main_window.Create(_T("OpenSoar/OpenVarioBaseMenu"), {600, 800}, main_style); + main_window.Create("OpenSoar/OpenVarioBaseMenu", {600, 800}, main_style); main_window.Show(); global_dialog_look = &dialog_look; diff --git a/src/OpenVario/System/OpenVarioDevice.cpp b/src/OpenVario/System/OpenVarioDevice.cpp index 7368c022abb..4a7a44938ce 100644 --- a/src/OpenVario/System/OpenVarioDevice.cpp +++ b/src/OpenVario/System/OpenVarioDevice.cpp @@ -65,27 +65,27 @@ OpenVario_Device::Initialise() noexcept { home.SetUTF8(getenv("HOME")); home_path = Path(home); #ifdef _WIN32 - data_path = Path(_T("D:/Data/OpenSoarData")); + data_path = Path("D:/Data/OpenSoarData"); #else - data_path = Path(_T("data")); + data_path = Path("data"); system_config = - AllocatedPath::Build(Path(_T("/boot")), Path(_T("config.uEnv"))); + AllocatedPath::Build(Path("/boot"), Path("config.uEnv")); is_real = File::Exists(system_config); #endif if (!is_real) // a pseudo 'config' file in home_path - system_config = AllocatedPath::Build(home_path, Path(_T("config.uEnv"))); + system_config = AllocatedPath::Build(home_path, Path("config.uEnv")); if (Directory::Exists(data_path)) { // auto config = AllocatedPath::Build(data_path, - // Path(_T("openvario.cfg"))); + // Path("openvario.cfg")); settings_config = - AllocatedPath::Build(data_path, Path(_T("openvario.cfg"))); - upgrade_config = AllocatedPath::Build(data_path, Path(_T("upgrade.cfg"))); + AllocatedPath::Build(data_path, Path("openvario.cfg")); + upgrade_config = AllocatedPath::Build(data_path, Path("upgrade.cfg")); } else { settings_config = - AllocatedPath::Build(home_path, Path(_T("openvario.cfg"))); - upgrade_config = AllocatedPath::Build(home_path, Path(_T("upgrade.cfg"))); + AllocatedPath::Build(home_path, Path("openvario.cfg")); + upgrade_config = AllocatedPath::Build(home_path, Path("upgrade.cfg")); } if (!File::Exists(settings_config)) File::CreateExclusive(settings_config); @@ -95,7 +95,7 @@ OpenVario_Device::Initialise() noexcept { #ifndef DBUS_FUNCTIONS // This path is only for Debug purposes on Non-OpenVario systems internal_config = - AllocatedPath::Build(home_path, Path(_T("ov-internal.cfg"))); + AllocatedPath::Build(home_path, Path("ov-internal.cfg")); #endif //---------------------------- LogFormat("data_path (base) = %s", data_path.ToUTF8().c_str()); @@ -104,14 +104,14 @@ OpenVario_Device::Initialise() noexcept { LogFormat("settings_config = %s", settings_config.ToUTF8().c_str()); LogFormat("system_config = %s", system_config.ToUTF8().c_str()); LogFormat("upgrade_config = %s", upgrade_config.ToUTF8().c_str()); - // the same...: LogFormat(_T("upgrade_config = %s"), upgrade_config.c_str()); + // the same...: LogFormat("upgrade_config = %s", upgrade_config.c_str()); LogFormat("is_real = %s", is_real ? "True" : "False"); LogFormat("exe_path = %s", exe_path.c_str()); LogFormat("bin_path = %s", bin_path.c_str()); #endif //---------------------------- - run_output_file = AllocatedPath::Build(home_path, Path(_T("tmp.txt"))); + run_output_file = AllocatedPath::Build(home_path, Path("tmp.txt")); LoadSettings(); initialised = true; } @@ -211,7 +211,7 @@ OpenVario_Device::GetBrightness() noexcept char line[4]; int result = 10; - if (File::ReadString(Path(_T("/sys/class/backlight/lcd/brightness")), line, sizeof(line))) { + if (File::ReadString(Path("/sys/class/backlight/lcd/brightness"), line, sizeof(line))) { result = atoi(line); } @@ -227,14 +227,14 @@ OpenVario_Device::SetBrightness(uint_least8_t value) noexcept brightness = value; settings.insert_or_assign("Brightness", std::to_string(value)); - File::WriteExisting(Path(_T("/sys/class/backlight/lcd/brightness")), fmt::format_int{value}.c_str()); + File::WriteExisting(Path("/sys/class/backlight/lcd/brightness"), fmt::format_int{value}.c_str()); } DisplayOrientation OpenVario_Device::GetRotation() { std::map> map; - LoadConfigFile(map, system_config); // Path(_T("/boot/config.uEnv"))); + LoadConfigFile(map, system_config); // Path("/boot/config.uEnv")); if (map.contains("Rotation")) // this is wrong!!! map.erase("Rotation"); @@ -256,7 +256,7 @@ OpenVario_Device::SetRotation(DisplayOrientation orientation, int mode) { std::map> map; - LoadConfigFile(map, system_config); // Path(_T("/boot/config.uEnv"))); + LoadConfigFile(map, system_config); // Path("/boot/config.uEnv")); if (map.contains("Rotation")) // this is wrong!!! map.erase("Rotation"); @@ -288,7 +288,7 @@ OpenVario_Device::SetRotation(DisplayOrientation orientation, int mode) if (map["rotation"] != rot_string) { if (mode & 2) { - File::WriteExisting(Path(_T("/sys/class/graphics/fbcon/rotate")), + File::WriteExisting(Path("/sys/class/graphics/fbcon/rotate"), rot_string.c_str()); } @@ -352,11 +352,11 @@ OpenVario_Device::GetSystemStatus(std::string_view system) noexcept Path run_tmp_file(_dirname.data()); if (system == "sensord") - file = _T("SensorD.txt"); + file = "SensorD.txt"; else if (system == "variod") - file = _T("VarioD.txt"); + file = "VarioD.txt"; else if (system == "dropbear.socket") - file = _T("SSH.txt"); + file = "SSH.txt"; AllocatedPath _tmp_file = AllocatedPath::Build(home_path, Path(file)); Path tmp_file = _tmp_file; diff --git a/src/OpenVario/System/OpenVarioTools.cpp b/src/OpenVario/System/OpenVarioTools.cpp index 79399ff9530..5354db9de67 100644 --- a/src/OpenVario/System/OpenVarioTools.cpp +++ b/src/OpenVario/System/OpenVarioTools.cpp @@ -32,13 +32,13 @@ CalibrateSensors() noexcept "sensord.service", nullptr}; RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T("Calibrate Sensors"), stop_sensord, [](int status) { + "Calibrate Sensors", stop_sensord, [](int status) { return status == EXIT_SUCCESS ? mrOK : 0; }); AtScopeExit() { RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T("Calibrate Sensors"), start_sensord, [](int status) { + "Calibrate Sensors", start_sensord, [](int status) { return status == EXIT_SUCCESS ? mrOK : 0; }); }; @@ -51,7 +51,7 @@ CalibrateSensors() noexcept static constexpr int RESULT_BOARD_NOT_INITIALISED = 100; int result = RunProcessDialog( UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T("Calibrate Sensors"), calibrate_sensors, [](int status) { + "Calibrate Sensors", calibrate_sensors, [](int status) { return status == STATUS_BOARD_NOT_INITIALISED ? RESULT_BOARD_NOT_INITIALISED : 0; @@ -60,8 +60,8 @@ CalibrateSensors() noexcept return; /* initialise the sensors? */ - if (ShowMessageBox(_T("Sensorboard is virgin. Do you want to initialise it?"), - _T("Calibrate Sensors"), MB_YESNO) != IDYES) + if (ShowMessageBox("Sensorboard is virgin. Do you want to initialise it?", + "Calibrate Sensors", MB_YESNO) != IDYES) return; static constexpr const char *init_sensors[] = {"/opt/bin/sensorcal", "-i", @@ -69,7 +69,7 @@ CalibrateSensors() noexcept result = RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T("Calibrate Sensors"), init_sensors, [](int status) { + "Calibrate Sensors", init_sensors, [](int status) { return status == EXIT_SUCCESS ? mrOK : 0; }); if (result != mrOK) @@ -77,7 +77,7 @@ CalibrateSensors() noexcept /* calibrate again */ RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T("Calibrate Sensors"), calibrate_sensors, [](int status) { + "Calibrate Sensors", calibrate_sensors, [](int status) { return status == STATUS_BOARD_NOT_INITIALISED ? RESULT_BOARD_NOT_INITIALISED : 0; diff --git a/src/OpenVario/System/Setting/RotationWidget.cpp b/src/OpenVario/System/Setting/RotationWidget.cpp index 04395066e8b..6052c12bd2e 100644 --- a/src/OpenVario/System/Setting/RotationWidget.cpp +++ b/src/OpenVario/System/Setting/RotationWidget.cpp @@ -66,7 +66,7 @@ void SettingRotationWidget::SaveRotation(const int rotationInt) { - File::WriteExisting(Path(_T("/sys/class/graphics/fbcon/rotate")), (rotationString).c_str()); + File::WriteExisting(Path("/sys/class/graphics/fbcon/rotate"), (rotationString).c_str()); // int rotationInt = stoi(rotationString); // ChangeConfigInt("rotation", rotationInt, ovdevice.GetSettingsConfig()); // TODO(August2111): move the from ovdevice.settings to ovdevice.sysetm @@ -81,23 +81,23 @@ void SettingRotationWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { - AddButton(_T("Landscape"), [this](){ + AddButton("Landscape", [this](){ // SaveRotation("2"); // Display::Rotate(DisplayOrientation::LANDSCAPE); ovdevice.SetRotation(DisplayOrientation::LANDSCAPE); }); - AddButton(_T("Portrait (90°)"), [this](){ + AddButton("Portrait (90°)", [this](){ //SaveRotation("1"); ovdevice.SetRotation(DisplayOrientation::REVERSE_PORTRAIT); }); - AddButton(_T("Landscape (180°)"), [this](){ + AddButton("Landscape (180°)", [this](){ // SaveRotation("4"); ovdevice.SetRotation(DisplayOrientation::REVERSE_LANDSCAPE); }); - AddButton(_T("Portrait (270°)"), [this](){ + AddButton("Portrait (270°)", [this](){ // SaveRotation("3"); ovdevice.SetRotation(DisplayOrientation::PORTRAIT); }); @@ -108,7 +108,7 @@ ShowRotationSettingsWidget(ContainerWindow &parent, const DialogLook &look) noexcept { TWidgetDialog sub_dialog( WidgetDialog::Full{}, (UI::SingleWindow &)parent, look, - _T("OpenVario Rotation Settings")); + "OpenVario Rotation Settings"); sub_dialog.SetWidget(); sub_dialog.AddButton(_("Close"), mrOK); return sub_dialog.ShowModal(); diff --git a/src/OpenVario/System/SystemMenuWidget.cpp b/src/OpenVario/System/SystemMenuWidget.cpp index 8859167fd98..de87e69d5e9 100644 --- a/src/OpenVario/System/SystemMenuWidget.cpp +++ b/src/OpenVario/System/SystemMenuWidget.cpp @@ -73,7 +73,7 @@ class ScreenSSHWidget final : public RowFormWidget { void ScreenSSHWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { - AddButton(_T("Enable"), []() { + AddButton("Enable", []() { static constexpr const char *argv[] = { "/bin/sh", "-c", "systemctl enable --now dropbear.socket && printf '\nSSH has been enabled'", @@ -81,48 +81,48 @@ void ScreenSSHWidget::Prepare([[maybe_unused]] ContainerWindow &parent, nullptr}; RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T("Enable"), argv); + "Enable", argv); }); - AddButton(_T("Disable"), []() { + AddButton("Disable", []() { static constexpr const char *argv[] = { "/bin/sh", "-c", "systemctl disable --now dropbear.socket && printf '\nSSH has been disabled'", nullptr}; RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T("Disable"), argv); + "Disable", argv); }); - AddButton(_T("IsEnabled"), []() { + AddButton("IsEnabled", []() { static constexpr const char *argv[] = { "/bin/sh", "-c", "systemctl is-enabled dropbear.socket", nullptr}; RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T("IsEnabled"), argv); + "IsEnabled", argv); }); - AddButton(_T("IsActive"), []() { + AddButton("IsActive", []() { static constexpr const char *argv[] = { "/bin/sh", "-c", "systemctl is-active dropbear.socket", nullptr}; RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T("IsActive"), argv); + "IsActive", argv); }); - AddButton(_T("GetStatus"), []() { + AddButton("GetStatus", []() { static constexpr const char *argv[] = { "/bin/sh", "-c", "systemctl is-enabled dropbear.socket", "systemctl is-active dropbear.socket", nullptr}; RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T("GetStatus"), argv); + "GetStatus", argv); }); - AddButton(_T("GetStatus2"), []() { + AddButton("GetStatus2", []() { static constexpr const char *argv[] = { "/bin/sh", "-c", "/bin/systemctl is-enabled dropbear.socket", @@ -130,7 +130,7 @@ void ScreenSSHWidget::Prepare([[maybe_unused]] ContainerWindow &parent, "/bin/systemctl is-active dropbear.socket", nullptr}; RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T("GetStatus2"), argv); + "GetStatus2", argv); }); } @@ -152,11 +152,11 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, #if 1 // the variant with command line... // UI::SingleWindow main_window = - AddButton(_T("SSH"), [this]() { + AddButton("SSH", [this]() { TWidgetDialog sub_dialog(WidgetDialog::Full{}, // dialog.GetMainWindow(), GetLook(), UIGlobals::GetMainWindow(), GetLook(), - _T("Enable or Disable SSH")); + "Enable or Disable SSH"); sub_dialog.SetWidget(); sub_dialog.AddButton(_("Close"), mrOK); return sub_dialog.ShowModal(); @@ -170,7 +170,7 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T("Update System"), argv); + "Update System", argv); }); AddButton(_("Calibrate Sensors"), CalibrateSensors); @@ -183,7 +183,7 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, ContainerWindow::SetExitValue(LAUNCH_TOUCH_CALIBRATE); UIActions::SignalShutdown(true); return mrOK; - // InputEvents::eventShutdown(_T("reboot")); + // InputEvents::eventShutdown("reboot"); // dialog.SetModalResult(LAUNCH_TOUCH_CALIBRATE); // dialog.SetModalResult(LAUNCH_TOUCH_CALIBRATE); @@ -193,14 +193,14 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, nullptr}; RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T("Calibrate Touch"), argv); + "Calibrate Touch", argv); #else // const UI::ScopeDropMaster drop_master{display}; // const UI::ScopeSuspendEventQueue // suspend_event_queue{event_queue}; // RunProcessDialog(UIGlobals::GetMainWindow(), // UIGlobals::GetDialogLook(), - // _T("System Info"), "/usr/bin/ov-calibrate-ts.sh"); + // "System Info", "/usr/bin/ov-calibrate-ts.sh"); // Run("/usr/bin/ov-calibrate-ts.sh"); #endif #endif @@ -214,7 +214,7 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T("System Info"), argv); + "System Info", argv); }); AddButton(_("List Dir"), []() { @@ -222,12 +222,12 @@ SystemMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _T("List Dir"), argv); + "List Dir", argv); }); AddButton(_("Test-Process 2"), [this]() { StaticString<0x200> str; - str.Format(_T("%s/%s"), ovdevice.GetHomePath().c_str(), _T("process.txt")); + str.Format("%s/%s", ovdevice.GetHomePath().c_str(), "process.txt"); Path output = Path(str); auto ret_value = Run( @@ -249,7 +249,7 @@ ShowSystemMenuWidget(ContainerWindow &parent, { TWidgetDialog sub_dialog( WidgetDialog::Full{}, (UI::SingleWindow &) parent, look, - _T("OpenVario System Menu")); + "OpenVario System Menu"); sub_dialog.SetWidget(); sub_dialog.AddButton(_("Close"), mrOK); return sub_dialog.ShowModal(); diff --git a/src/OpenVario/System/WifiDialogOV.cpp b/src/OpenVario/System/WifiDialogOV.cpp index 8dc161a99af..95d848fc06a 100644 --- a/src/OpenVario/System/WifiDialogOV.cpp +++ b/src/OpenVario/System/WifiDialogOV.cpp @@ -202,15 +202,15 @@ WifiListWidget::ScanWifi() { #ifdef __MSVC__ char buffer[0x1000]; - auto file = Path(_T("connman-scan-results.txt")); - File::ReadString(Path(_T("/Data/connman-services.txt")), buffer, sizeof(buffer)); + auto file = Path("connman-scan-results.txt"); + File::ReadString(Path("/Data/connman-services.txt"), buffer, sizeof(buffer)); File::CreateExclusive(file); File::WriteExisting(file, buffer); #else - Run(Path(_T("connman-technologies.txt")), connmanctl, "technologies"); - Run(Path(_T("connman-enable.txt")), connmanctl, "enable", "wifi"); - Run(Path(_T("connman-scan.txt")), connmanctl, "scan", "wifi"); - Run(Path(_T("connman-scan-results.txt")), connmanctl, "services"); + Run(Path("connman-technologies.txt"), connmanctl, "technologies"); + Run(Path("connman-enable.txt"), connmanctl, "enable", "wifi"); + Run(Path("connman-scan.txt"), connmanctl, "scan", "wifi"); + Run(Path("connman-scan-results.txt"), connmanctl, "services"); #endif } @@ -264,8 +264,8 @@ WifiListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, if (addr.IsDefined()) { /* valid address? */ // StaticString<40> addr_str; StaticString<40> addr_str; - addr_str = _T("192.186.0.1"); - state_buffer.Format(_T("%s (%s)"), state, addr_str.c_str()); + addr_str = "192.186.0.1"; + state_buffer.Format("%s (%s)", state, addr_str.c_str()); state = state_buffer; } #else @@ -275,7 +275,7 @@ WifiListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, // StaticString<40> addr_str; StaticString<40> addr_str; if (addr.ToString(addr_str.buffer(), addr_str.capacity()) != nullptr) { - state_buffer.Format(_T("%s (%s)"), state, addr_str.c_str()); + state_buffer.Format("%s (%s)", state, addr_str.c_str()); state = state_buffer; } } @@ -304,7 +304,7 @@ WifiListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, if (info.signal_level >= 0) { StaticString<32> text; - text.UnsafeFormat(_T("%s %u"), _W(wifi_security[info.security]), + text.UnsafeFormat("%s %u", _W(wifi_security[info.security]), info.signal_level); row_renderer.DrawRightSecondRow(canvas, rc, text); } @@ -315,13 +315,13 @@ WifiListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, void WifiListWidget::WifiDisconnect( const char *ssid) { auto network = FindVisibleBySSID(ssid); // StaticString<0x100> base_id; -// base_id.Format(_T("wifi_%s_%s_managed_"), _W(network->mac_id.c_str()), +// base_id.Format("wifi_%s_%s_managed_", _W(network->mac_id.c_str()), // _W(network->bssid.c_str())); #if defined(IS_OPENVARIO_CB2) // disconnect port - Run(Path(_T("wifi-disconnect.txt")), connmanctl, "disconnect", network->base_id.c_str()); + Run(Path("wifi-disconnect.txt"), connmanctl, "disconnect", network->base_id.c_str()); #endif - ShowMessageBox(_W(network->base_id.c_str()), _T("Disconnected"), MB_OK); + ShowMessageBox(_W(network->base_id.c_str()), "Disconnected", MB_OK); } void WifiListWidget::WifiConnect(enum WifiSecurity security, @@ -329,25 +329,25 @@ void WifiListWidget::WifiConnect(enum WifiSecurity security, const char *ssid, const char *psk) { { -// ShowMessageBox(_W(psk), _T("Wifi-Passphrase"), MB_OK); +// ShowMessageBox(_W(psk), "Wifi-Passphrase", MB_OK); auto network = FindVisibleBySSID(ssid); std::cout << "Test: " << 1 << std::endl; // StaticString<0x100> base_id; -// base_id.Format(_T("wifi_%s_%s_managed_"), _W(network->mac_id.c_str()), +// base_id.Format("wifi_%s_%s_managed_", _W(network->mac_id.c_str()), // _W(network->bssid.c_str())); // std::cout << "Test: " << 2 << std::endl; // switch (network->security) { // case WPA_SECURITY: -// base_id.append(_T("psk")); +// base_id.append("psk"); // break; // case WEP_SECURITY: -// base_id.append(_T("wep")); +// base_id.append("wep"); // break; // case OPEN_SECURITY: // default: -// base_id.append(_T("none")); +// base_id.append("none"); // break; // } @@ -366,24 +366,24 @@ void WifiListWidget::WifiConnect(enum WifiSecurity security, IPv6.privacy=disabled #endif // WithWPA StaticString<0x1000> buffer; - buffer.Format(_T("[%s]\n"), _W(network->base_id.c_str())); - buffer.AppendFormat(_T("Type=%s\n"), _W("wifi")); - buffer.AppendFormat(_T("Name=%s\n"), _W(ssid)); - buffer.AppendFormat(_T("SSID=%s\n"), + buffer.Format("[%s]\n", _W(network->base_id.c_str())); + buffer.AppendFormat("Type=%s\n", _W("wifi")); + buffer.AppendFormat("Name=%s\n", _W(ssid)); + buffer.AppendFormat("SSID=%s\n", _W(network->bssid.c_str())); // _W(network->bssid); - buffer.AppendFormat(_T("Frequency=%d\n"), 2412); - // buffer.AppendFormat(_T("Favorite=true\n")); - buffer.append(_T("Favorite=true\n")); - buffer.append(_T("AutoConnect=true\n")); - buffer.AppendFormat(_T("Passphrase=%s\n"), _W(psk)); - // buffer.AppendFormat(_T("Modified=2024-02-01T12:38:31Z\n")); - buffer.AppendFormat(_T("IPv4.method=%s\n"), _T("dhcp")); - // buffer.AppendFormat(_T("IPv4.DHCP.LastAddress=192.168.178.32\n")); - buffer.append(_T("IPv6.method=off\n")); - buffer.append(_T("IPv6.privacy=disabled\n")); + buffer.AppendFormat("Frequency=%d\n", 2412); + // buffer.AppendFormat("Favorite=true\n"); + buffer.append("Favorite=true\n"); + buffer.append("AutoConnect=true\n"); + buffer.AppendFormat("Passphrase=%s\n", _W(psk)); + // buffer.AppendFormat("Modified=2024-02-01T12:38:31Z\n"); + buffer.AppendFormat("IPv4.method=%s\n", "dhcp"); + // buffer.AppendFormat("IPv4.DHCP.LastAddress=192.168.178.32\n"); + buffer.append("IPv6.method=off\n"); + buffer.append("IPv6.privacy=disabled\n"); std::cout << "Test: " << 6 << std::endl; std::cout << _A(buffer.c_str()) << std::endl; - ShowMessageBox(buffer.c_str(), _T("WifiConnect"), MB_OK); + ShowMessageBox(buffer.c_str(), "WifiConnect", MB_OK); std::cout << "Test: " << 7 << std::endl; Path base_id(_W(network->base_id.c_str())); @@ -391,13 +391,13 @@ void WifiListWidget::WifiConnect(enum WifiSecurity security, #if defined(IS_OPENVARIO_CB2) // save on the connman setting location: auto ssid_path = - AllocatedPath::Build(Path(_T("/var/lib/connman")), base_id); + AllocatedPath::Build(Path("/var/lib/connman"), base_id); #else auto ssid_path = AllocatedPath::Build(ovdevice.GetDataPath(), base_id); ssid_path = AllocatedPath::Build(ssid_path, base_id); #endif - auto setting_file = AllocatedPath::Build(ssid_path, Path(_T("settings"))); + auto setting_file = AllocatedPath::Build(ssid_path, Path("settings")); if (File::Exists(setting_file)) File::Delete(setting_file); else @@ -407,15 +407,15 @@ void WifiListWidget::WifiConnect(enum WifiSecurity security, #if defined(IS_OPENVARIO_CB2) // disable wifi - Run(Path(_T("wifi-disable.txt")), connmanctl, "disable", "wifi"); + Run(Path("wifi-disable.txt"), connmanctl, "disable", "wifi"); // wait a second std::this_thread::sleep_for(std::chrono::seconds(1)); // enable wifi again for AutoConnect - Run(Path(_T("wifi-enable.txt")), connmanctl, "enable", "wifi"); + Run(Path("wifi-enable.txt"), connmanctl, "enable", "wifi"); // wait a second after wifi enabling (?) std::this_thread::sleep_for(std::chrono::seconds(1)); // ask state of the wifi connection - Run(Path(_T("wifi-connect.txt")), connmanctl, "services", + Run(Path("wifi-connect.txt"), connmanctl, "services", network->base_id.c_str()); #endif } @@ -475,15 +475,15 @@ WifiListWidget::ReConnect() #if defined(IS_OPENVARIO_CB2) // disable wifi - Run(Path(_T("wifi-disable.txt")), connmanctl, "disable", "wifi"); + Run(Path("wifi-disable.txt"), connmanctl, "disable", "wifi"); // wait a second std::this_thread::sleep_for(std::chrono::seconds(1)); // enable wifi again for AutoConnect - Run(Path(_T("wifi-enable.txt")), connmanctl, "enable", "wifi"); + Run(Path("wifi-enable.txt"), connmanctl, "enable", "wifi"); // wait a second after wifi enabling (?) std::this_thread::sleep_for(std::chrono::seconds(1)); // // ask state of the wifi connection -// Run(Path(_T("wifi-connect.txt")), connmanctl, "services", +// Run(Path("wifi-connect.txt"), connmanctl, "services", // network->base_id.c_str()); #endif @@ -712,13 +712,13 @@ try { unsigned ScanResults(WifiVisibleNetwork *dest, unsigned max) { - const Path file = Path(_T("connman-scan-results.txt")); + const Path file = Path("connman-scan-results.txt"); if (File::Exists(file)) { // ConsoleOperationEnvironment env; NullOperationEnvironment env; auto n = ParseConnmanScan(dest, file, env, max); - auto file2 = Path(_T("connman-services.txt")); + auto file2 = Path("connman-services.txt"); if (File::Exists(file2)) File::Delete(file2); File::Rename(file, file2); diff --git a/src/OpenVario/SystemSettingsWidget.cpp b/src/OpenVario/SystemSettingsWidget.cpp index 53a30ae8f42..3c50854ea82 100644 --- a/src/OpenVario/SystemSettingsWidget.cpp +++ b/src/OpenVario/SystemSettingsWidget.cpp @@ -71,22 +71,22 @@ class SystemSettingsWidget final : public RowFormWidget, DataFieldListener { #ifdef OPENVARIOBASEMENU static constexpr StaticEnumChoice timeout_list[] = { - { 0, _T("immediately"), }, - { 1, _T("1s"), }, - { 3, _T("3s"), }, - { 5, _T("5s"), }, - { 10, _T("10s"), }, - { 30, _T("30s"), }, - { 60, _T("1min"), }, - { -1, _T("never"), }, + { 0, "immediately", }, + { 1, "1s", }, + { 3, "3s", }, + { 5, "5s", }, + { 10, "10s", }, + { 30, "30s", }, + { 60, "1min", }, + { -1, "never", }, nullptr }; #endif static constexpr StaticEnumChoice enable_list[] = { - { SSHStatus::ENABLED, _T("enabled"), }, - { SSHStatus::DISABLED, _T("disabled"), }, - { SSHStatus::TEMPORARY, _T("temporary"), }, + { SSHStatus::ENABLED, "enabled", }, + { SSHStatus::DISABLED, "disabled", }, + { SSHStatus::TEMPORARY, "temporary", }, nullptr }; @@ -109,7 +109,7 @@ SystemSettingsWidget::OnModified([[maybe_unused]] DataField &df) noexcept } else if (IsDataField(FIRMWARE, df)) { // (DataFieldInteger*)df) // ConvertString - ShowMessageBox(_T("FirmWare-Selection"), _T("??File??"), MB_OKCANCEL); + ShowMessageBox("FirmWare-Selection", "??File??", MB_OKCANCEL); } } @@ -121,12 +121,12 @@ SystemSettingsWidget::Prepare(ContainerWindow &parent, AddReadOnly(_("Current OpenSoar"), _("Current firmware version of OpenVario"), #if defined(PROGRAM_VERSION) - _T(PROGRAM_VERSION)); + PROGRAM_VERSION); #else - _T("7.42.21.3")); + "7.42.21.3"); #endif AddFile(_("OV-Firmware"), _("Current firmware file version of OpenVario"), - "OVImage", _T("*.img.gz\0"), FileType::IMAGE); // no callback... , this); + "OVImage", "*.img.gz\0", FileType::IMAGE); // no callback... , this); AddBoolean( _("Settings Enabled"), @@ -144,7 +144,7 @@ SystemSettingsWidget::Prepare(ContainerWindow &parent, #endif auto btnWifi = AddButton( - _T("Settings Wifi"), [this]() { + "Settings Wifi", [this]() { ShowWifiDialog(); }); btnWifi->SetEnabled(true); // dependend on availability? Missing: @@ -154,7 +154,7 @@ SystemSettingsWidget::Prepare(ContainerWindow &parent, #ifdef _DEBUG AddInteger(_("IntegerTest"), - _("IntegerTest."), _T("%d"), _T("%d"), 0, + _("IntegerTest."), "%d", "%d", 0, 99999, 1, ovdevice.iTest); #endif @@ -232,7 +232,7 @@ ShowSystemSettingsWidget(ContainerWindow &parent, { TWidgetDialog sub_dialog( WidgetDialog::Full{}, (UI::SingleWindow &) parent, look, - _T("OpenVario System Settings")); + "OpenVario System Settings"); sub_dialog.SetWidget(); sub_dialog.AddButton(_("Save"), mrOK); sub_dialog.AddButton(_("Close"), mrOK); diff --git a/src/Operation/ConsoleOperationEnvironment.cpp b/src/Operation/ConsoleOperationEnvironment.cpp index 2d08672a377..8d0725bf4ba 100644 --- a/src/Operation/ConsoleOperationEnvironment.cpp +++ b/src/Operation/ConsoleOperationEnvironment.cpp @@ -8,13 +8,13 @@ void ConsoleOperationEnvironment::SetErrorMessage(const char *text) noexcept { - _ftprintf(stderr, _T("ERROR: %s\n"), text); + _ftprintf(stderr, "ERROR: %s\n", text); } void ConsoleOperationEnvironment::SetText(const char *text) noexcept { - _tprintf(_T("%s\n"), text); + _tprintf("%s\n", text); } void diff --git a/src/Operation/MessageOperationEnvironment.cpp b/src/Operation/MessageOperationEnvironment.cpp index 2145f0876d9..a84ee849e5d 100644 --- a/src/Operation/MessageOperationEnvironment.cpp +++ b/src/Operation/MessageOperationEnvironment.cpp @@ -7,5 +7,5 @@ void MessageOperationEnvironment::SetErrorMessage(const char *text) noexcept { - ShowMessageBox(text, _T(""), MB_OK|MB_ICONERROR); + ShowMessageBox(text, "", MB_OK|MB_ICONERROR); } diff --git a/src/Operation/ThreadedOperationEnvironment.hpp b/src/Operation/ThreadedOperationEnvironment.hpp index a949f917147..96bca187d3f 100644 --- a/src/Operation/ThreadedOperationEnvironment.hpp +++ b/src/Operation/ThreadedOperationEnvironment.hpp @@ -27,7 +27,7 @@ class ThreadedOperationEnvironment bool update_text, update_progress_range, update_progress_position; Data() noexcept - :text(_T("")), + :text(""), progress_range(0u), progress_position(0u), update_error(false), update_text(false), update_progress_range(false), update_progress_position(false) {} diff --git a/src/PageSettings.cpp b/src/PageSettings.cpp index 68ebc7e9a60..179d67c530f 100644 --- a/src/PageSettings.cpp +++ b/src/PageSettings.cpp @@ -14,7 +14,7 @@ PageLayout::MakeTitle(const InfoBoxSettings &info_box_settings, const bool concise) const noexcept { if (!valid) - return _T("---"); + return "---"; switch (main) { case PageLayout::Main::MAP: @@ -49,7 +49,7 @@ PageLayout::MakeTitle(const InfoBoxSettings &info_box_settings, builder.Append(' '); builder.Append(_("Auto")); } else { - builder.Append(_T(" (")); + builder.Append(" ("); builder.Append(_("Auto")); builder.Append(')'); } @@ -68,7 +68,7 @@ PageLayout::MakeTitle(const InfoBoxSettings &info_box_settings, case Bottom::CROSS_SECTION: // TODO: better text and translate - builder.Append(_T(", XS")); + builder.Append(", XS"); break; case Bottom::MAX: diff --git a/src/Polar/Parser.cpp b/src/Polar/Parser.cpp index 090e634d4b5..7baa70dcc25 100644 --- a/src/Polar/Parser.cpp +++ b/src/Polar/Parser.cpp @@ -14,23 +14,23 @@ ParsePolarShape(PolarShape &shape, const char *s) noexcept { char *p; auto v1 = Units::ToSysUnit(ParseDouble(s, &p), Unit::KILOMETER_PER_HOUR); - if (*p != _T(',')) + if (*p != ',') return false; auto w1 = ParseDouble(p + 1, &p); - if (*p != _T(',')) + if (*p != ',') return false; auto v2 = Units::ToSysUnit(ParseDouble(p + 1, &p), Unit::KILOMETER_PER_HOUR); - if (*p != _T(',')) + if (*p != ',') return false; auto w2 = ParseDouble(p + 1, &p); - if (*p != _T(',')) + if (*p != ',') return false; auto v3 = Units::ToSysUnit(ParseDouble(p + 1, &p), Unit::KILOMETER_PER_HOUR); - if (*p != _T(',')) + if (*p != ',') return false; auto w3 = ParseDouble(p + 1, &p); @@ -54,42 +54,42 @@ ParsePolar(PolarInfo &polar_r, const char *s) noexcept // *LS-3 WinPilot POLAR file: MassDryGross[kg], MaxWaterBallast[liters], Speed1[km/h], Sink1[m/s], Speed2, Sink2, Speed3, Sink3 // 403, 101, 115.03, -0.86, 174.04, -1.76, 212.72, -3.4 - if (s[0] == _T('*')) + if (s[0] == '*') /* a comment */ return false; char *p; polar.shape.reference_mass = ParseDouble(s, &p); - if (*p != _T(',')) + if (*p != ',') return false; polar.max_ballast = ParseDouble(p + 1, &p); - if (*p != _T(',')) + if (*p != ',') return false; polar.shape[0].v = Units::ToSysUnit(ParseDouble(p + 1, &p), Unit::KILOMETER_PER_HOUR); - if (*p != _T(',')) + if (*p != ',') return false; polar.shape[0].w = ParseDouble(p + 1, &p); - if (*p != _T(',')) + if (*p != ',') return false; polar.shape[1].v = Units::ToSysUnit(ParseDouble(p + 1, &p), Unit::KILOMETER_PER_HOUR); - if (*p != _T(',')) + if (*p != ',') return false; polar.shape[1].w = ParseDouble(p + 1, &p); - if (*p != _T(',')) + if (*p != ',') return false; polar.shape[2].v = Units::ToSysUnit(ParseDouble(p + 1, &p), Unit::KILOMETER_PER_HOUR); - if (*p != _T(',')) + if (*p != ',') return false; polar.shape[2].w = ParseDouble(p + 1, &p); - polar.wing_area = (*p != _T(',')) ? 0. : ParseDouble(p + 1, &p); - polar.v_no = (*p != _T(',')) ? 0. : ParseDouble(p + 1, &p); + polar.wing_area = (*p != ',') ? 0. : ParseDouble(p + 1, &p); + polar.v_no = (*p != ',') ? 0. : ParseDouble(p + 1, &p); polar_r = polar; return true; diff --git a/src/Polar/PolarStore.cpp b/src/Polar/PolarStore.cpp index 5c74c557021..405b071b501 100644 --- a/src/Polar/PolarStore.cpp +++ b/src/Polar/PolarStore.cpp @@ -39,7 +39,7 @@ Item::ToPolarInfo() const noexcept } static constexpr Item default_polar = { - _T("LS-8 (15m)"), 325, 185, 70, -0.51, 115, -0.85, 173, -2.00, 10.5, 0.0, 108, 240, + "LS-8 (15m)", 325, 185, 70, -0.51, 115, -0.85, 173, -2.00, 10.5, 0.0, 108, 240, }; /** @@ -49,206 +49,206 @@ static constexpr Item default_polar = { * for ever. */ static constexpr Item internal_polars[] = { - { _T("206 Hornet"), 318, 100, 80, -0.606, 120, -0.99, 160, -1.918, 9.8, 41.666, 100, 227 }, - { _T("303 Mosquito"), 450, 0, 100.0, -0.68, 120.0, -0.92, 150.0, -1.45, 9.85, 0.0, 107, 242 }, - { _T("304CZ"), 310, 115, 115.03, -0.86, 174.04, -1.76, 212.72, -3.4, 0, 0.0, 110, 235 }, - { _T("401 Kestrel (17m)"), 367, 33, 95, -0.62, 110, -0.76, 175, -2.01, 11.58 , 0.0, 110, 260 }, - { _T("604 Kestrel"), 570, 100, 112.97, -0.72, 150.64, -1.42, 207.13, -4.1, 16.26, 0.0, 114, 455 }, + { "206 Hornet", 318, 100, 80, -0.606, 120, -0.99, 160, -1.918, 9.8, 41.666, 100, 227 }, + { "303 Mosquito", 450, 0, 100.0, -0.68, 120.0, -0.92, 150.0, -1.45, 9.85, 0.0, 107, 242 }, + { "304CZ", 310, 115, 115.03, -0.86, 174.04, -1.76, 212.72, -3.4, 0, 0.0, 110, 235 }, + { "401 Kestrel (17m)", 367, 33, 95, -0.62, 110, -0.76, 175, -2.01, 11.58 , 0.0, 110, 260 }, + { "604 Kestrel", 570, 100, 112.97, -0.72, 150.64, -1.42, 207.13, -4.1, 16.26, 0.0, 114, 455 }, // from Akaflieg Karlsruhe, idaflieg measurement 2017 with new winglet design at Aalen Elchingen - { _T("AK-8"), 362 , 100, 84.1343, -0.6524, 130.0, -0.9474, 170.0, -1.8380, 9.75, 50.0, 107, 233 }, + { "AK-8", 362 , 100, 84.1343, -0.6524, 130.0, -0.9474, 170.0, -1.8380, 9.75, 50.0, 107, 233 }, // from LX8000/9000 simulator - { _T("Antares 18S"), 350, 250, 100, -0.54, 120, -0.63, 150, -1.07, 10.97, 0.0, 120, 295 }, - { _T("Antares 18T"), 395, 205, 100, -0.54, 120, -0.69, 150, -1.11, 10.97, 0.0, 120, 345 }, - { _T("Antares 20E"), 530, 130, 100, -0.52, 120, -0.61, 150, -0.91, 12.6, 0.0, 123, 475 }, + { "Antares 18S", 350, 250, 100, -0.54, 120, -0.63, 150, -1.07, 10.97, 0.0, 120, 295 }, + { "Antares 18T", 395, 205, 100, -0.54, 120, -0.69, 150, -1.11, 10.97, 0.0, 120, 345 }, + { "Antares 20E", 530, 130, 100, -0.52, 120, -0.61, 150, -0.91, 12.6, 0.0, 123, 475 }, - { _T("Apis (13m)"), 200, 45, 100, -0.74, 120, -1.01, 150, -1.66, 10.36, 0.0, 93, 137 }, - { _T("Apis 2 (15m)"), 310, 0, 80, -0.60, 100, -0.75, 140, -1.45, 12.40, 0.0, 98, 215 }, // from LK8000 + { "Apis (13m)", 200, 45, 100, -0.74, 120, -1.01, 150, -1.66, 10.36, 0.0, 93, 137 }, + { "Apis 2 (15m)", 310, 0, 80, -0.60, 100, -0.75, 140, -1.45, 12.40, 0.0, 98, 215 }, // from LK8000 // from Shempp Hirth - { _T("Arcus"), 700, 185, 110, -0.64, 140, -0.88, 180, -1.47, 15.59, 50.0, 120, 430 }, + { "Arcus", 700, 185, 110, -0.64, 140, -0.88, 180, -1.47, 15.59, 50.0, 120, 430 }, - { _T("ASG-29 (15m)"), 362, 165, 108.8, -0.635, 156.4, -1.182, 211.13, -2.540, 9.20, 0.0, 114, 270 }, - { _T("ASG-29 (18m)"), 355, 225, 85, -0.47, 90, -0.48, 185, -2.00, 10.5, 0.0, 121, 280 }, - { _T("ASG-29E (15m)"), 350, 200, 100, -0.64, 120, -0.75, 150, -1.13, 9.2, 0.0, 114, 315 }, - { _T("ASG-29E (18m)"), 400, 200, 90, -0.499, 95.5, -0.510, 196.4, -2.12, 10.5, 0.0, 121, 325 }, - { _T("ASH-25"), 750, 121, 130.01, -0.78, 169.96, -1.4, 219.94, -2.6, 16.31, 0.0, 122, 478 }, - { _T("ASH-26"), 340, 185, 100, -0.56, 120, -0.74, 150, -1.16, 11.7, 0.0, 119, 325 }, - { _T("ASH-26E"), 435, 90, 90, -0.51, 96, -0.53, 185, -2.00, 11.7, 0.0, 119, 360 }, - { _T("ASK-13"), 456, 0, 85, -0.84, 120, -1.5, 150, -2.8, 17.5, 44.444, 79, 296 }, - { _T("ASK-18"), 310, 0, 75, -0.613, 138, -1.773, 200, -4.234, 12.99, 0, 88, 215 }, - { _T("ASK-21"), 468, 0, 74.1, -0.67, 101.9, -0.90, 166.7, -2.68, 17.95, 50.0, 92, 360 }, - { _T("ASK-23"), 330, 0, 100, -0.85, 120, -1.19, 150, -2.02, 12.9, 0.0, 92, 240 }, - { _T("ASW-12"), 394, 189, 95, -0.57, 148, -1.48, 183.09, -2.6, 13.00, 0.0, 110, 324 }, - { _T("ASW-15"), 349, 91, 97.56, -0.77, 156.12, -1.9, 195.15, -3.4, 11.0, 0.0, 97, 210 }, - { _T("ASW-17"), 522, 151, 114.5, -0.7, 169.05, -1.68, 206.5, -2.9, 14.84, 0.0, 115, 405 }, - { _T("ASW-19"), 363, 125, 97.47, -0.74, 155.96, -1.64, 194.96, -3.1, 11.0, 47.222, 100, 240 }, - { _T("ASW-20"), 377, 159, 116.2, -0.77, 174.3, -1.89, 213.04, -3.3, 10.5, 0.0, 108, 255 }, - { _T("ASW-20BL"), 400, 126, 95, -0.628, 148, -1.338, 200, -2.774, 10.49, 0, 112, 275 }, - { _T("ASW-22B"), 597, 303, 80, -0.4015, 120, -0.66, 160, -1.3539, 16.31, 0.0, 123, 270 }, - { _T("ASW-22BLE"), 465, 285, 100, -0.47, 120, -0.63, 150, -1.04, 16.7, 0.0, 124, 275 }, - { _T("ASW-24"), 350, 159, 108.82, -0.73, 142.25, -1.21, 167.41, -1.8, 10.0, 0.0, 107, 230 }, - { _T("ASW-27"), 365, 165, 88.8335, -0.5939, 130.0, -0.8511, 170.0, -1.6104, 9.0, 0.0, 114, 235 }, // from idaflieg 1997 & 2018 - { _T("ASW-28 (15m)"), 310, 200, 92.6, -0.571, 120.38, -0.875, 148.16, -1.394, 10.5, 55.555, 108, 235 }, // from SeeYou - { _T("ASW-28 (18m)"), 345, 190, 65, -0.47, 107, -0.67, 165, -2.00, 10.5, 0.0, 114, 270 }, - { _T("Blanik L13"), 472, 0, 85.0, -0.84, 143.0, -3.32, 200.0, -9.61, 19.1, 0.0, 78, 292 }, + { "ASG-29 (15m)", 362, 165, 108.8, -0.635, 156.4, -1.182, 211.13, -2.540, 9.20, 0.0, 114, 270 }, + { "ASG-29 (18m)", 355, 225, 85, -0.47, 90, -0.48, 185, -2.00, 10.5, 0.0, 121, 280 }, + { "ASG-29E (15m)", 350, 200, 100, -0.64, 120, -0.75, 150, -1.13, 9.2, 0.0, 114, 315 }, + { "ASG-29E (18m)", 400, 200, 90, -0.499, 95.5, -0.510, 196.4, -2.12, 10.5, 0.0, 121, 325 }, + { "ASH-25", 750, 121, 130.01, -0.78, 169.96, -1.4, 219.94, -2.6, 16.31, 0.0, 122, 478 }, + { "ASH-26", 340, 185, 100, -0.56, 120, -0.74, 150, -1.16, 11.7, 0.0, 119, 325 }, + { "ASH-26E", 435, 90, 90, -0.51, 96, -0.53, 185, -2.00, 11.7, 0.0, 119, 360 }, + { "ASK-13", 456, 0, 85, -0.84, 120, -1.5, 150, -2.8, 17.5, 44.444, 79, 296 }, + { "ASK-18", 310, 0, 75, -0.613, 138, -1.773, 200, -4.234, 12.99, 0, 88, 215 }, + { "ASK-21", 468, 0, 74.1, -0.67, 101.9, -0.90, 166.7, -2.68, 17.95, 50.0, 92, 360 }, + { "ASK-23", 330, 0, 100, -0.85, 120, -1.19, 150, -2.02, 12.9, 0.0, 92, 240 }, + { "ASW-12", 394, 189, 95, -0.57, 148, -1.48, 183.09, -2.6, 13.00, 0.0, 110, 324 }, + { "ASW-15", 349, 91, 97.56, -0.77, 156.12, -1.9, 195.15, -3.4, 11.0, 0.0, 97, 210 }, + { "ASW-17", 522, 151, 114.5, -0.7, 169.05, -1.68, 206.5, -2.9, 14.84, 0.0, 115, 405 }, + { "ASW-19", 363, 125, 97.47, -0.74, 155.96, -1.64, 194.96, -3.1, 11.0, 47.222, 100, 240 }, + { "ASW-20", 377, 159, 116.2, -0.77, 174.3, -1.89, 213.04, -3.3, 10.5, 0.0, 108, 255 }, + { "ASW-20BL", 400, 126, 95, -0.628, 148, -1.338, 200, -2.774, 10.49, 0, 112, 275 }, + { "ASW-22B", 597, 303, 80, -0.4015, 120, -0.66, 160, -1.3539, 16.31, 0.0, 123, 270 }, + { "ASW-22BLE", 465, 285, 100, -0.47, 120, -0.63, 150, -1.04, 16.7, 0.0, 124, 275 }, + { "ASW-24", 350, 159, 108.82, -0.73, 142.25, -1.21, 167.41, -1.8, 10.0, 0.0, 107, 230 }, + { "ASW-27", 365, 165, 88.8335, -0.5939, 130.0, -0.8511, 170.0, -1.6104, 9.0, 0.0, 114, 235 }, // from idaflieg 1997 & 2018 + { "ASW-28 (15m)", 310, 200, 92.6, -0.571, 120.38, -0.875, 148.16, -1.394, 10.5, 55.555, 108, 235 }, // from SeeYou + { "ASW-28 (18m)", 345, 190, 65, -0.47, 107, -0.67, 165, -2.00, 10.5, 0.0, 114, 270 }, + { "Blanik L13", 472, 0, 85.0, -0.84, 143.0, -3.32, 200.0, -9.61, 19.1, 0.0, 78, 292 }, // from factory polar (flight manual) - { _T("Blanik L13-AC"), 500, 0, 70, -0.85, 110, -1.25, 160, -3.2, 17.44, 44.44, 78, 306 }, - { _T("Blanik L23"), 510, 0, 95.0, -0.94, 148.0, -2.60, 200.0, -6.37, 19.1, 0.0, 80, 310 }, - { _T("Carat"), 470, 0, 100, -0.83, 120, -1.04, 150, -1.69, 10.58, 0.0, 93, 341 }, - { _T("Cirrus (18m)"), 330, 100, 100, -0.74, 120, -1.06, 150, -1.88, 12.6, 0.0, 102, 260 }, + { "Blanik L13-AC", 500, 0, 70, -0.85, 110, -1.25, 160, -3.2, 17.44, 44.44, 78, 306 }, + { "Blanik L23", 510, 0, 95.0, -0.94, 148.0, -2.60, 200.0, -6.37, 19.1, 0.0, 80, 310 }, + { "Carat", 470, 0, 100, -0.83, 120, -1.04, 150, -1.69, 10.58, 0.0, 93, 341 }, + { "Cirrus (18m)", 330, 100, 100, -0.74, 120, -1.06, 150, -1.88, 12.6, 0.0, 102, 260 }, // Idaflieg measurement, 28.08.2015 at Aalen Elchingen - { _T("D-43 18m"), 668, 0, 100, -0.62, 130, -0.863, 170, -1.672, 15.93, 250, 99, }, + { "D-43 18m", 668, 0, 100, -0.62, 130, -0.863, 170, -1.672, 15.93, 250, 99, }, - { _T("Delta USHPA-2"), 100, 0, 30, -1.10, 44.3, -1.52, 58.0, -3.60, 0, 0.0, 0, 5 }, - { _T("Delta USHPA-3"), 100, 0, 37, -0.95, 48.1, -1.15, 73.0, -3.60, 0, 0.0, 0, 5 }, - { _T("Delta USHPA-4"), 100, 0, 37, -0.89, 48.3, -1.02, 76.5, -3.30, 0, 0.0, 0, 5 }, - { _T("DG-1000 (20m)"), 613, 160, 106.0, -0.62, 153.0, -1.53, 200.0, -3.2, 17.51, 0.0, 111, 415 }, - { _T("DG-100"), 300, 100, 100, -0.73, 120, -1.00, 150, -1.7, 11.0, 0.0, 100, 230 }, - { _T("DG-200"), 300, 120, 100, -0.68, 120, -0.86, 150, -1.3, 10.0, 0.0, 107, 230 }, - { _T("DG-300"), 310, 190, 95.0, -0.66, 140.0, -1.28, 160.0, -1.70, 10.27, 0.0, 104, 235 }, - { _T("DG-400 (15m)"), 440, 90, 115, -0.76, 160.53, -1.22, 210.22, -2.3, 10.0, 0.0, 107, 306 }, - { _T("DG-400 (17m)"), 444, 90, 118.28, -0.68, 163.77, -1.15, 198.35, -1.8, 10.57, 0.0, 109, 310 }, - { _T("DG-500 (20m)"), 659, 100, 115.4, -0.71, 152.01, -1.28, 190.02, -2.3, 18.29, 0.0, 104, 390 }, - { _T("DG-600 (15m)"), 327, 180, 100, -0.60, 120, -0.76, 150, -1.19, 10.95, 0.0, 110, 255 }, - { _T("DG-800B (15m)"), 468, 100, 103.610, -0.6535, 130.0, -0.8915, 170.0, -1.4807, 10.68, 52.8, 113, 340 }, - { _T("DG-800B (18m)"), 472, 100, 90.0086, -0.5496, 130.0, -0.7920, 170.0, -1.4248, 11.81, 52.8, 119, 344 }, + { "Delta USHPA-2", 100, 0, 30, -1.10, 44.3, -1.52, 58.0, -3.60, 0, 0.0, 0, 5 }, + { "Delta USHPA-3", 100, 0, 37, -0.95, 48.1, -1.15, 73.0, -3.60, 0, 0.0, 0, 5 }, + { "Delta USHPA-4", 100, 0, 37, -0.89, 48.3, -1.02, 76.5, -3.30, 0, 0.0, 0, 5 }, + { "DG-1000 (20m)", 613, 160, 106.0, -0.62, 153.0, -1.53, 200.0, -3.2, 17.51, 0.0, 111, 415 }, + { "DG-100", 300, 100, 100, -0.73, 120, -1.00, 150, -1.7, 11.0, 0.0, 100, 230 }, + { "DG-200", 300, 120, 100, -0.68, 120, -0.86, 150, -1.3, 10.0, 0.0, 107, 230 }, + { "DG-300", 310, 190, 95.0, -0.66, 140.0, -1.28, 160.0, -1.70, 10.27, 0.0, 104, 235 }, + { "DG-400 (15m)", 440, 90, 115, -0.76, 160.53, -1.22, 210.22, -2.3, 10.0, 0.0, 107, 306 }, + { "DG-400 (17m)", 444, 90, 118.28, -0.68, 163.77, -1.15, 198.35, -1.8, 10.57, 0.0, 109, 310 }, + { "DG-500 (20m)", 659, 100, 115.4, -0.71, 152.01, -1.28, 190.02, -2.3, 18.29, 0.0, 104, 390 }, + { "DG-600 (15m)", 327, 180, 100, -0.60, 120, -0.76, 150, -1.19, 10.95, 0.0, 110, 255 }, + { "DG-800B (15m)", 468, 100, 103.610, -0.6535, 130.0, -0.8915, 170.0, -1.4807, 10.68, 52.8, 113, 340 }, + { "DG-800B (18m)", 472, 100, 90.0086, -0.5496, 130.0, -0.7920, 170.0, -1.4248, 11.81, 52.8, 119, 344 }, // as taken from handbook of DG-800S the pure glider variant - { _T("DG-800S (15m)"), 370, 150, 92.1255, -0.5811, 130.0, -0.9754, 170.0, -1.6933, 10.68, 52.8, 113, 260 }, - { _T("DG-800S (18m)"), 350, 150, 77.5081, -0.4733, 130.0, -0.9257, 170.0, -1.7948, 11.81, 52.8, 119, 264 }, + { "DG-800S (15m)", 370, 150, 92.1255, -0.5811, 130.0, -0.9754, 170.0, -1.6933, 10.68, 52.8, 113, 260 }, + { "DG-800S (18m)", 350, 150, 77.5081, -0.4733, 130.0, -0.9257, 170.0, -1.7948, 11.81, 52.8, 119, 264 }, - { _T("Dimona"), 670, 100, 100, -1.29, 120, -1.61, 150, -2.45, 15.3, 0.0, 68, 470 }, - { _T("Discus 2b"), 312, 200, 105, -0.66, 150, -1.05, 200, -2.0, 10.6, 0.0, 108, 252 }, - { _T("Discus 2c (18m)"), 377, 188, 100, -0.57, 120, -0.76, 150, -1.33, 11.36, 55.555, 114, 280 }, - { _T("Discus"), 350, 182, 95, -0.63, 140, -1.23, 180, -2.29, 10.58, 55.555, 107, 233 }, - { _T("Duo Discus"), 615, 80, 103, -0.64, 152, -1.25, 200, -2.51, 16.4, 0.0, 112, 420 }, - { _T("Duo Discus T"), 615, 80, 103, -0.64, 152, -1.25, 200, -2.51, 16.4, 0.0, 112, 445 }, - { _T("Duo Discus xT"), 700, 50, 110, -0.664, 155, -1.206, 200, -2.287, 16.40, 50.0, 113, 445 }, - { _T("EB 28"), 670, 180, 100, -0.46, 120, -0.61, 150, -0.96, 16.8, 0.0, 125, 570 }, - { _T("EB 28 Edition"), 670, 180, 100, -0.47, 120, -0.63, 150, -0.97, 16.5, 0.0, 125, 570 }, - { _T("G 102 Astir CS"), 330, 90, 75.0, -0.7, 93.0, -0.74, 185.00, -3.1, 12.40, 0.0, 96, 255 }, + { "Dimona", 670, 100, 100, -1.29, 120, -1.61, 150, -2.45, 15.3, 0.0, 68, 470 }, + { "Discus 2b", 312, 200, 105, -0.66, 150, -1.05, 200, -2.0, 10.6, 0.0, 108, 252 }, + { "Discus 2c (18m)", 377, 188, 100, -0.57, 120, -0.76, 150, -1.33, 11.36, 55.555, 114, 280 }, + { "Discus", 350, 182, 95, -0.63, 140, -1.23, 180, -2.29, 10.58, 55.555, 107, 233 }, + { "Duo Discus", 615, 80, 103, -0.64, 152, -1.25, 200, -2.51, 16.4, 0.0, 112, 420 }, + { "Duo Discus T", 615, 80, 103, -0.64, 152, -1.25, 200, -2.51, 16.4, 0.0, 112, 445 }, + { "Duo Discus xT", 700, 50, 110, -0.664, 155, -1.206, 200, -2.287, 16.40, 50.0, 113, 445 }, + { "EB 28", 670, 180, 100, -0.46, 120, -0.61, 150, -0.96, 16.8, 0.0, 125, 570 }, + { "EB 28 Edition", 670, 180, 100, -0.47, 120, -0.63, 150, -0.97, 16.5, 0.0, 125, 570 }, + { "G 102 Astir CS", 330, 90, 75.0, -0.7, 93.0, -0.74, 185.00, -3.1, 12.40, 0.0, 96, 255 }, // from factory polar (flight manual) by Christopher Schenk - { _T("G 102 Club Astir IIIb"), 380, 0, 75.0, -0.6, 100.0, -0.70, 180.00, -3.1, 12.40, 0.0, 91, 255 }, - { _T("G 102 Standard Astir III"), 380, 70, 75.0, -0.6, 100.0, -0.70, 180.00, -2.8, 12.40, 0.0, 100, 260 }, + { "G 102 Club Astir IIIb", 380, 0, 75.0, -0.6, 100.0, -0.70, 180.00, -3.1, 12.40, 0.0, 91, 255 }, + { "G 102 Standard Astir III", 380, 70, 75.0, -0.6, 100.0, -0.70, 180.00, -2.8, 12.40, 0.0, 100, 260 }, - { _T("G 103 Twin 2"), 580, 0, 99, -0.8, 175.01, -1.95, 225.02, -3.8, 17.52, 0.0, 92, 390 }, - { _T("G 104 Speed Astir"), 351, 90, 90, -0.63, 105, -0.72, 157, -2.00, 11.5, 0.0, 105, 265 }, - { _T("Genesis II"), 374, 151, 94, -0.61, 141.05, -1.18, 172.4, -2.0, 11.24, 0.0, 107, 240 }, - { _T("Glasfluegel 304"), 305, 145, 100, -0.78, 120, -0.97, 150, -1.43, 9.9, 0.0, 110, 235 }, - { _T("H-201 Std Libelle"), 304, 50, 97, -0.79, 152.43, -1.91, 190.54, -3.3, 9.8, 41.666, 98, 185 }, - { _T("H-205 Club Libelle"), 295, 0, 100, -0.85, 120, -1.21, 150, -2.01, 9.8, 41.666, 96, 200 }, - { _T("H-301 Libelle"), 300, 50, 94, -0.68, 147.71, -2.03, 184.64, -4.1, 9.8, 41.666, 100, 180 }, - { _T("IS-28B2"), 590, 0, 100, -0.82, 160, -2.28, 200, -4.27, 18.24, 0.0, 84, 375 }, - { _T("IS-29D2 Lark"), 360, 0, 100, -0.82, 135.67, -1.55, 184.12, -3.3, 10.4, 0.0, 96, 240 }, - { _T("Janus (18m)"), 498, 240, 100, -0.71, 120, -0.92, 150, -1.46, 16.6, 0.0, 102, 405 }, - { _T("Janus C FG"), 603, 170, 115.5, -0.76, 171.79, -1.98, 209.96, -4.0, 17.4, 47.222, 106, 405 }, // obviously wrong - { _T("Janus C RG"), 519, 240, 90, -0.60, 120, -0.88, 160, -1.64, 17.3, 50, 108, 405 }, // from factory polar - { _T("JS-1B (18m)"), 405, 180, 108, -0.57, 152, -1.06, 180, -1.65, 11.25, 56.3, 121, 310 }, // from factory polar - { _T("JS-1C (21m)"), 441, 180, 108, -0.52, 156, -1.1, 180, -1.62, 12.25, 56.3, 126, 330 }, // from factory polar - { _T("JS-3 (15m)"), 350, 158, 100, -0.6, 130, -0.8, 160, -1.2, 8.75, 57.5, 116, 270 }, // from factory polar - { _T("JS-3 (18m)"), 398, 158, 100, -0.55, 130, -0.72, 160, -1.12, 9.95, 57.5, 122, 282 }, // from factory polar - { _T("Ka 2b"), 418, 0, 87, -0.9, 120, -1.5, 150, -2.6, 17.5, 0.0, 78, 278 }, - { _T("Ka 4 Rhoenlerche"), 360, 0, 65, -0.95, 120, -2.5, 140, -3.5, 16.34, 0.0, 54, 220 }, - { _T("Ka 6CR"), 310, 0, 64.83 , -0.67 , 130.0, -2.26 , 170.0, -4.69 , 12.5 , 0.0 , 82, 185 }, - { _T("Ka 6E"), 310, 0, 87.35, -0.81, 141.92, -2.03, 174.68, -3.5, 12.4, 0.0, 85, 185 }, // from idaflieg measured 1970 - { _T("Ka 7"), 445, 0, 87, -0.92, 120, -1.55, 150, -2.7, 17.5, 0.0, 78, 285 }, - { _T("Ka 8"), 290, 0, 74.1, -0.76, 101.9, -1.27, 166.7, -4.64, 14.15, 0.0, 76, 190 }, - { _T("L 33 Solo"), 330, 0, 87.2, -0.8, 135.64, -1.73, 174.4, -3.4, 11.0, 0.0, 86, 210 }, - { _T("LAK-12"), 430, 190, 75, -0.48, 125, -0.88, 175, -1.97, 14.63, 48.611, 114, 360 }, // from marius@sargevicius.com - { _T("LAK-17 (15m)"), 285, 215, 100, -0.60, 120, -0.72, 150, -1.09, 9.06, 0.0, 113, 220 }, - { _T("LAK-17 (18m)"), 295, 205, 100, -0.56, 120, -0.74, 150, -1.16, 9.8, 0.0, 119, 225 }, - { _T("LAK17a (15m)"), 285, 180, 95, -0.574, 148, -1.310, 200, -2.885, 9.06, 0.0, 113, 220 }, - { _T("LAK17a (18m)"), 298, 180, 115, -0.680, 158, -1.379, 200, -2.975, 9.80, 0.0, 119, 225 }, - { _T("LAK-19 (15m)"), 285, 195, 100, -0.64, 120, -0.85, 150, -1.41, 9.06, 0.0, 108, 220 }, - { _T("LAK-19 (18m)"), 295, 185, 100, -0.60, 120, -0.82, 150, -1.34, 9.8, 0.0, 114, 226 }, - { _T("LS-10s (15m)"), 370, 170, 100, -0.64, 120, -0.80, 150, -1.26, 10.27, 0.0, 113, 288 }, - { _T("LS-10s (18m)"), 380, 220, 100, -0.58, 120, -0.75, 150, -1.21, 11.45, 0.0, 119, 295 }, - { _T("LS-1c"), 350, 91, 115.87, -1.02, 154.49, -1.84, 193.12, -3.3, 9.74, 0.0, 98, 200 }, - { _T("LS-1f"), 345, 80, 100, -0.75, 120, -0.98, 150, -1.6, 9.74, 0.0, 100, 230 }, // from idaflieg - { _T("LS-3 (17m)"), 325, 0, 100, -0.61, 120, -0.84, 150, -1.53, 11.22, 0.0, 109, 255 }, - { _T("LS-3"), 383, 121, 93.0, -0.64, 127.0, -0.93, 148.2, -1.28, 10.5, 0.0, 107, 270 }, - { _T("LS-4"), 361, 121, 100, -0.69, 120, -0.87, 150, -1.44, 10.5, 0.0, 104, 235 }, + { "G 103 Twin 2", 580, 0, 99, -0.8, 175.01, -1.95, 225.02, -3.8, 17.52, 0.0, 92, 390 }, + { "G 104 Speed Astir", 351, 90, 90, -0.63, 105, -0.72, 157, -2.00, 11.5, 0.0, 105, 265 }, + { "Genesis II", 374, 151, 94, -0.61, 141.05, -1.18, 172.4, -2.0, 11.24, 0.0, 107, 240 }, + { "Glasfluegel 304", 305, 145, 100, -0.78, 120, -0.97, 150, -1.43, 9.9, 0.0, 110, 235 }, + { "H-201 Std Libelle", 304, 50, 97, -0.79, 152.43, -1.91, 190.54, -3.3, 9.8, 41.666, 98, 185 }, + { "H-205 Club Libelle", 295, 0, 100, -0.85, 120, -1.21, 150, -2.01, 9.8, 41.666, 96, 200 }, + { "H-301 Libelle", 300, 50, 94, -0.68, 147.71, -2.03, 184.64, -4.1, 9.8, 41.666, 100, 180 }, + { "IS-28B2", 590, 0, 100, -0.82, 160, -2.28, 200, -4.27, 18.24, 0.0, 84, 375 }, + { "IS-29D2 Lark", 360, 0, 100, -0.82, 135.67, -1.55, 184.12, -3.3, 10.4, 0.0, 96, 240 }, + { "Janus (18m)", 498, 240, 100, -0.71, 120, -0.92, 150, -1.46, 16.6, 0.0, 102, 405 }, + { "Janus C FG", 603, 170, 115.5, -0.76, 171.79, -1.98, 209.96, -4.0, 17.4, 47.222, 106, 405 }, // obviously wrong + { "Janus C RG", 519, 240, 90, -0.60, 120, -0.88, 160, -1.64, 17.3, 50, 108, 405 }, // from factory polar + { "JS-1B (18m)", 405, 180, 108, -0.57, 152, -1.06, 180, -1.65, 11.25, 56.3, 121, 310 }, // from factory polar + { "JS-1C (21m)", 441, 180, 108, -0.52, 156, -1.1, 180, -1.62, 12.25, 56.3, 126, 330 }, // from factory polar + { "JS-3 (15m)", 350, 158, 100, -0.6, 130, -0.8, 160, -1.2, 8.75, 57.5, 116, 270 }, // from factory polar + { "JS-3 (18m)", 398, 158, 100, -0.55, 130, -0.72, 160, -1.12, 9.95, 57.5, 122, 282 }, // from factory polar + { "Ka 2b", 418, 0, 87, -0.9, 120, -1.5, 150, -2.6, 17.5, 0.0, 78, 278 }, + { "Ka 4 Rhoenlerche", 360, 0, 65, -0.95, 120, -2.5, 140, -3.5, 16.34, 0.0, 54, 220 }, + { "Ka 6CR", 310, 0, 64.83 , -0.67 , 130.0, -2.26 , 170.0, -4.69 , 12.5 , 0.0 , 82, 185 }, + { "Ka 6E", 310, 0, 87.35, -0.81, 141.92, -2.03, 174.68, -3.5, 12.4, 0.0, 85, 185 }, // from idaflieg measured 1970 + { "Ka 7", 445, 0, 87, -0.92, 120, -1.55, 150, -2.7, 17.5, 0.0, 78, 285 }, + { "Ka 8", 290, 0, 74.1, -0.76, 101.9, -1.27, 166.7, -4.64, 14.15, 0.0, 76, 190 }, + { "L 33 Solo", 330, 0, 87.2, -0.8, 135.64, -1.73, 174.4, -3.4, 11.0, 0.0, 86, 210 }, + { "LAK-12", 430, 190, 75, -0.48, 125, -0.88, 175, -1.97, 14.63, 48.611, 114, 360 }, // from marius@sargevicius.com + { "LAK-17 (15m)", 285, 215, 100, -0.60, 120, -0.72, 150, -1.09, 9.06, 0.0, 113, 220 }, + { "LAK-17 (18m)", 295, 205, 100, -0.56, 120, -0.74, 150, -1.16, 9.8, 0.0, 119, 225 }, + { "LAK17a (15m)", 285, 180, 95, -0.574, 148, -1.310, 200, -2.885, 9.06, 0.0, 113, 220 }, + { "LAK17a (18m)", 298, 180, 115, -0.680, 158, -1.379, 200, -2.975, 9.80, 0.0, 119, 225 }, + { "LAK-19 (15m)", 285, 195, 100, -0.64, 120, -0.85, 150, -1.41, 9.06, 0.0, 108, 220 }, + { "LAK-19 (18m)", 295, 185, 100, -0.60, 120, -0.82, 150, -1.34, 9.8, 0.0, 114, 226 }, + { "LS-10s (15m)", 370, 170, 100, -0.64, 120, -0.80, 150, -1.26, 10.27, 0.0, 113, 288 }, + { "LS-10s (18m)", 380, 220, 100, -0.58, 120, -0.75, 150, -1.21, 11.45, 0.0, 119, 295 }, + { "LS-1c", 350, 91, 115.87, -1.02, 154.49, -1.84, 193.12, -3.3, 9.74, 0.0, 98, 200 }, + { "LS-1f", 345, 80, 100, -0.75, 120, -0.98, 150, -1.6, 9.74, 0.0, 100, 230 }, // from idaflieg + { "LS-3 (17m)", 325, 0, 100, -0.61, 120, -0.84, 150, -1.53, 11.22, 0.0, 109, 255 }, + { "LS-3", 383, 121, 93.0, -0.64, 127.0, -0.93, 148.2, -1.28, 10.5, 0.0, 107, 270 }, + { "LS-4", 361, 121, 100, -0.69, 120, -0.87, 150, -1.44, 10.5, 0.0, 104, 235 }, // Derived from Idaflieg measurements, D-7742, measured at 13-15/8/1991 in Aalen. Empty mass from comments by the owner here: https://www.youtube.com/watch?v=wSX3k-Lp7HA. - { _T("LS-5"), 461, 120, 75, -0.45, 135, -1.0, 172.5, -1.9, 13.9, 0.0, 118, 361 }, - { _T("LS-6 (15m)"), 327, 160, 90, -0.6, 100, -0.658, 183, -1.965, 10.53, 0.0, 111, 265 }, - { _T("LS-6 (18m)"), 330, 140, 90, -0.51, 100, -0.57, 183, -2.00, 11.4, 0.0, 117, 272 }, - { _T("LS-7wl"), 350, 150, 103.77, -0.73, 155.65, -1.47, 180.00, -2.66, 9.80, 0.0, 107, 235 }, - { _T("LS-8 (15m)"), 325, 185, 70, -0.51, 115, -0.85, 173, -2.00, 10.5, 0.0, 108, 240 }, - { _T("LS-8 (18m)"), 325, 185, 80, -0.51, 94, -0.56, 173, -2.00, 11.4, 0.0, 114, 250 }, - { _T("Mini Nimbus"), 345, 155, 100, -0.69, 120, -0.92, 150, -1.45, 9.86, 55.555, 107, 235 }, - { _T("Nimbus 2"), 493, 159, 119.83, -0.75, 179.75, -2.14, 219.69, -3.8, 14.41, 44.444, 114, 350 }, - { _T("Nimbus 3"), 527, 159, 116.18, -0.67, 174.28, -1.81, 232.37, -3.8, 16.70, 52.777, 122, 396 }, - { _T("Nimbus 3DM"), 820, 168, 114.97, -0.57, 157.42, -0.98, 222.24, -2.3, 16.70, 52.777, 121, 595 }, - { _T("Nimbus 3D"), 712, 168, 93.64, -0.46, 175.42, -1.48, 218.69, -2.5, 16.70, 52.777, 121, 485 }, - { _T("Nimbus 3T"), 577, 310, 141.7, -0.99, 182.35, -1.89, 243.13, -4.0, 16.70, 52.777, 121, 422 }, - { _T("Nimbus 4"), 597, 303, 85.1, -0.41, 127.98, -0.75, 162.74, -1.4, 17.8, 50.0, 124, 470 }, - { _T("Nimbus 4DM"), 820, 168, 100.01, -0.48, 150.01, -0.87, 190.76, -1.6, 17.8, 50.0, 123, 595 }, - { _T("Nimbus 4D"), 743, 303, 107.5, -0.5, 142.74, -0.83, 181.51, -1.6, 17.8, 50.0, 123, 515 }, - { _T("Para Competition"), 100, 0, 39.0, -1.0, 45.0, -1.1, 64.0, -2.30, 0, 0.0, 0 }, - { _T("Para EN A/DHV1"), 100, 0, 29.0, -1.1, 34.0, -1.3, 44.0, -2.30, 0, 0.0, 0 }, - { _T("Para EN B/DHV12"), 100, 0, 29.5, -1.1, 37.0, -1.2, 50.0, -2.30, 0, 0.0, 0 }, - { _T("Para EN C/DHV2"), 110, 4.19, 33.0, -1.0, 39.0, -1.2, 56.0, -2.30, 0, 0.0, 0 }, - { _T("Para EN D/DHV23"), 100, 0, 33.0, -1.1, 41.0, -1.2, 58.0, -2.30, 0, 0.0, 0 }, - { _T("Pegase 101A"), 344, 120, 85.0, -0.62, 105, -0.75, 175, -2.54, 10.5, 0.0, 102, 252 }, - { _T("Phoebus C"), 310, 150, 100, -0.70, 120, -0.98, 150, -1.58, 14.06, 0.0, 100, 225 }, - { _T("PIK-20B"), 354, 144, 102.5, -0.69, 157.76, -1.59, 216.91, -3.6, 10.0, 0.0, 102, 240 }, - { _T("PIK-20D"), 348, 144, 100, -0.69, 156.54, -1.78, 215.24, -4.2, 10.0, 0.0, 104, 227 }, - { _T("PIK-20E"), 437, 80, 109.61, -0.83, 166.68, -2, 241.15, -4.7, 10.0, 0.0, 104, 324 }, - { _T("PIK-30M"), 460, 0, 123.6, -0.78, 152.04, -1.12, 200.22, -2.2, 10.63, 0.0, 0, 347 }, + { "LS-5", 461, 120, 75, -0.45, 135, -1.0, 172.5, -1.9, 13.9, 0.0, 118, 361 }, + { "LS-6 (15m)", 327, 160, 90, -0.6, 100, -0.658, 183, -1.965, 10.53, 0.0, 111, 265 }, + { "LS-6 (18m)", 330, 140, 90, -0.51, 100, -0.57, 183, -2.00, 11.4, 0.0, 117, 272 }, + { "LS-7wl", 350, 150, 103.77, -0.73, 155.65, -1.47, 180.00, -2.66, 9.80, 0.0, 107, 235 }, + { "LS-8 (15m)", 325, 185, 70, -0.51, 115, -0.85, 173, -2.00, 10.5, 0.0, 108, 240 }, + { "LS-8 (18m)", 325, 185, 80, -0.51, 94, -0.56, 173, -2.00, 11.4, 0.0, 114, 250 }, + { "Mini Nimbus", 345, 155, 100, -0.69, 120, -0.92, 150, -1.45, 9.86, 55.555, 107, 235 }, + { "Nimbus 2", 493, 159, 119.83, -0.75, 179.75, -2.14, 219.69, -3.8, 14.41, 44.444, 114, 350 }, + { "Nimbus 3", 527, 159, 116.18, -0.67, 174.28, -1.81, 232.37, -3.8, 16.70, 52.777, 122, 396 }, + { "Nimbus 3DM", 820, 168, 114.97, -0.57, 157.42, -0.98, 222.24, -2.3, 16.70, 52.777, 121, 595 }, + { "Nimbus 3D", 712, 168, 93.64, -0.46, 175.42, -1.48, 218.69, -2.5, 16.70, 52.777, 121, 485 }, + { "Nimbus 3T", 577, 310, 141.7, -0.99, 182.35, -1.89, 243.13, -4.0, 16.70, 52.777, 121, 422 }, + { "Nimbus 4", 597, 303, 85.1, -0.41, 127.98, -0.75, 162.74, -1.4, 17.8, 50.0, 124, 470 }, + { "Nimbus 4DM", 820, 168, 100.01, -0.48, 150.01, -0.87, 190.76, -1.6, 17.8, 50.0, 123, 595 }, + { "Nimbus 4D", 743, 303, 107.5, -0.5, 142.74, -0.83, 181.51, -1.6, 17.8, 50.0, 123, 515 }, + { "Para Competition", 100, 0, 39.0, -1.0, 45.0, -1.1, 64.0, -2.30, 0, 0.0, 0 }, + { "Para EN A/DHV1", 100, 0, 29.0, -1.1, 34.0, -1.3, 44.0, -2.30, 0, 0.0, 0 }, + { "Para EN B/DHV12", 100, 0, 29.5, -1.1, 37.0, -1.2, 50.0, -2.30, 0, 0.0, 0 }, + { "Para EN C/DHV2", 110, 4.19, 33.0, -1.0, 39.0, -1.2, 56.0, -2.30, 0, 0.0, 0 }, + { "Para EN D/DHV23", 100, 0, 33.0, -1.1, 41.0, -1.2, 58.0, -2.30, 0, 0.0, 0 }, + { "Pegase 101A", 344, 120, 85.0, -0.62, 105, -0.75, 175, -2.54, 10.5, 0.0, 102, 252 }, + { "Phoebus C", 310, 150, 100, -0.70, 120, -0.98, 150, -1.58, 14.06, 0.0, 100, 225 }, + { "PIK-20B", 354, 144, 102.5, -0.69, 157.76, -1.59, 216.91, -3.6, 10.0, 0.0, 102, 240 }, + { "PIK-20D", 348, 144, 100, -0.69, 156.54, -1.78, 215.24, -4.2, 10.0, 0.0, 104, 227 }, + { "PIK-20E", 437, 80, 109.61, -0.83, 166.68, -2, 241.15, -4.7, 10.0, 0.0, 104, 324 }, + { "PIK-30M", 460, 0, 123.6, -0.78, 152.04, -1.12, 200.22, -2.2, 10.63, 0.0, 0, 347 }, // Derived from Pilatus B4 PH-448, fixed gear serial production, measured at Idaflieg-vergleichsfliegen at Aalen in the year 1973. - { _T("Pilatus B4 FG"), 306, 0, 90.0, -0.847, 126.0, -1.644, 198.0, -5.098, 14.0, 0.0, 86, 230 }, - { _T("PW-5 Smyk"), 300, 0, 99.5, -0.95, 158.48, -2.85, 198.1, -5.1, 10.16, 0.0, 85, 190 }, - { _T("PW-6"), 546, 0, 104, -0.847, 152, -1.994, 200, -4.648, 15.3, 0, 86, 360 }, - { _T("R-26S Gobe"), 420, 0, 60.0, -1.02, 80.0, -0.96, 120.0, -2.11, 18.00, 30.5, 0, 230 }, - { _T("Russia AC-4"), 250, 0, 99.3, -0.92, 140.01, -1.8, 170.01, -2.9, 7.70, 0.0, 84, 140 }, - { _T("SF-27B"), 300, 0, 100, -0.81, 120, -1.27, 150, -2.50, 13, 0.0, 88, 220 }, - { _T("SGS 1-26E"), 315, 0, 82.3, -1.04, 117.73, -1.88, 156.86, -3.8, 14.87, 0.0, 63, 202 }, - { _T("SGS 1-34"), 354, 0, 89.82, -0.8, 143.71, -2.1, 179.64, -3.8, 14.03, 0.0, 85, 259 }, - { _T("SGS 1-35A"), 381, 179, 98.68, -0.74, 151.82, -1.8, 202.87, -3.9, 9.64, 0.0, 0, 180 }, - { _T("SGS 1-36 Sprite"), 322, 0, 75.98, -0.68, 132.96, -2, 170.95, -4.1, 13.10, 0.0, 76, 215 }, - { _T("SGS 2-33"), 470, 0, 82.32, -0.96, 130.0, -1.74, 170.0, -3.44, 20.35, 33, 54, 272 }, + { "Pilatus B4 FG", 306, 0, 90.0, -0.847, 126.0, -1.644, 198.0, -5.098, 14.0, 0.0, 86, 230 }, + { "PW-5 Smyk", 300, 0, 99.5, -0.95, 158.48, -2.85, 198.1, -5.1, 10.16, 0.0, 85, 190 }, + { "PW-6", 546, 0, 104, -0.847, 152, -1.994, 200, -4.648, 15.3, 0, 86, 360 }, + { "R-26S Gobe", 420, 0, 60.0, -1.02, 80.0, -0.96, 120.0, -2.11, 18.00, 30.5, 0, 230 }, + { "Russia AC-4", 250, 0, 99.3, -0.92, 140.01, -1.8, 170.01, -2.9, 7.70, 0.0, 84, 140 }, + { "SF-27B", 300, 0, 100, -0.81, 120, -1.27, 150, -2.50, 13, 0.0, 88, 220 }, + { "SGS 1-26E", 315, 0, 82.3, -1.04, 117.73, -1.88, 156.86, -3.8, 14.87, 0.0, 63, 202 }, + { "SGS 1-34", 354, 0, 89.82, -0.8, 143.71, -2.1, 179.64, -3.8, 14.03, 0.0, 85, 259 }, + { "SGS 1-35A", 381, 179, 98.68, -0.74, 151.82, -1.8, 202.87, -3.9, 9.64, 0.0, 0, 180 }, + { "SGS 1-36 Sprite", 322, 0, 75.98, -0.68, 132.96, -2, 170.95, -4.1, 13.10, 0.0, 76, 215 }, + { "SGS 2-33", 470, 0, 82.32, -0.96, 130.0, -1.74, 170.0, -3.44, 20.35, 33, 54, 272 }, // From Silene E78/E78B manual, available on Issoire Aviation website - { _T("Silene E78"), 450, 0, 75, -0.548, 125, -1.267, 160, -2.439, 18, 47.222, 0, 365 }, - { _T("Skylark 4"), 395, 0, 78, -0.637, 139, -2, 200, -5.092, 16.1, 0, 84, 258 }, - { _T("Std Austria S"), 297, 0, 70.0, -0.70, 118.0, -1.0, 145.0, -1.5, 13.5 , 38.9, 90, 205}, // From Schempp-Hirth sales handout, potentially too good - { _T("Std Cirrus"), 337, 80, 93.23, -0.74, 149.17, -1.71, 205.1, -4.2, 10.04, 0.0, 99, 215 }, - { _T("Stemme S-10"), 850, 0, 133.47, -0.83, 167.75, -1.41, 205.03, -2.3, 18.70, 0.0, 110, 645 }, - { _T("SZD-30 Pirat"), 370, 0, 80, -0.72, 100, -0.98, 150, -2.46, 13.8, 0.0, 86, 260 }, - { _T("SZD-36 Cobra"), 350, 30, 70.8, -0.60, 94.5, -0.69, 148.1, -1.83, 11.6, 0.0, 98, 275 }, - { _T("SZD-42 Jantar II"), 482, 191, 109.5, -0.66, 157.14, -1.47, 196.42, -2.7, 14.27, 0.0, 113, 362 }, - { _T("SZD-48-2 Jantar Std 2"), 375, 150, 100, -0.73, 120, -0.95, 150, -1.60, 10.66, 0.0, 100, 274 }, - { _T("SZD-48-3 Jantar Std 3"), 326, 150, 95, -0.66, 180, -2.24, 220, -3.85, 10.66, 0.0, 100, 274 }, - { _T("SZD-50 Puchacz"), 435, 135, 100, -1.00, 120, -1.42, 150, -2.35, 18.16, 0.0, 84, 370 }, - { _T("SZD-51-1 Junior"), 333, 0, 70, -0.58, 130, -1.6, 180, -3.6, 12.51, 0.0, 90, 242 }, + { "Silene E78", 450, 0, 75, -0.548, 125, -1.267, 160, -2.439, 18, 47.222, 0, 365 }, + { "Skylark 4", 395, 0, 78, -0.637, 139, -2, 200, -5.092, 16.1, 0, 84, 258 }, + { "Std Austria S", 297, 0, 70.0, -0.70, 118.0, -1.0, 145.0, -1.5, 13.5 , 38.9, 90, 205}, // From Schempp-Hirth sales handout, potentially too good + { "Std Cirrus", 337, 80, 93.23, -0.74, 149.17, -1.71, 205.1, -4.2, 10.04, 0.0, 99, 215 }, + { "Stemme S-10", 850, 0, 133.47, -0.83, 167.75, -1.41, 205.03, -2.3, 18.70, 0.0, 110, 645 }, + { "SZD-30 Pirat", 370, 0, 80, -0.72, 100, -0.98, 150, -2.46, 13.8, 0.0, 86, 260 }, + { "SZD-36 Cobra", 350, 30, 70.8, -0.60, 94.5, -0.69, 148.1, -1.83, 11.6, 0.0, 98, 275 }, + { "SZD-42 Jantar II", 482, 191, 109.5, -0.66, 157.14, -1.47, 196.42, -2.7, 14.27, 0.0, 113, 362 }, + { "SZD-48-2 Jantar Std 2", 375, 150, 100, -0.73, 120, -0.95, 150, -1.60, 10.66, 0.0, 100, 274 }, + { "SZD-48-3 Jantar Std 3", 326, 150, 95, -0.66, 180, -2.24, 220, -3.85, 10.66, 0.0, 100, 274 }, + { "SZD-50 Puchacz", 435, 135, 100, -1.00, 120, -1.42, 150, -2.35, 18.16, 0.0, 84, 370 }, + { "SZD-51-1 Junior", 333, 0, 70, -0.58, 130, -1.6, 180, -3.6, 12.51, 0.0, 90, 242 }, // From Perkoz handbook - { _T("SZD-54-2 Perkoz (FT 17m)") /* flat tip */, 442, 0, 98, -0.92, 174, -4.35, 250, -13.22, 16.36, 47.05, 98, 375 }, - { _T("SZD-54-2 Perkoz (WL 17m)") /* winglet */, 442, 0, 99, -0.86, 175, -4.22, 250, -13.01, 16.36, 47.05, 98, 375 }, - { _T("SZD-54-2 Perkoz (WL 20m)") /* long winglet */, 442, 0, 91, -0.69, 170, -3.98, 250, -12.66, 17.30, 47.05, 102, 380 }, + { "SZD-54-2 Perkoz (FT 17m)" /* flat tip */, 442, 0, 98, -0.92, 174, -4.35, 250, -13.22, 16.36, 47.05, 98, 375 }, + { "SZD-54-2 Perkoz (WL 17m)" /* winglet */, 442, 0, 99, -0.86, 175, -4.22, 250, -13.01, 16.36, 47.05, 98, 375 }, + { "SZD-54-2 Perkoz (WL 20m)" /* long winglet */, 442, 0, 91, -0.69, 170, -3.98, 250, -12.66, 17.30, 47.05, 102, 380 }, - { _T("SZD-55-1 Promyk"), 350, 200, 100.0, -0.66, 120, -0.86, 150, -1.4, 9.60, 0.0, 106, 215 }, - { _T("SZD-9 bis 1E Bocian"), 540, 0, 70, -0.83, 90, -1.00, 140, -2.53, 20, 0.0, 76, 330 }, - { _T("Taurus"), 472, 0, 100, -0.71, 120, -0.83, 150, -1.35, 12.26, 0.0, 99, 306 }, - { _T("Ventus 2c (18m)"), 385, 180, 80.0, -0.5, 120.0, -0.73, 180.0, -2.0, 11.03, 55.555, 120, 260 }, - { _T("Ventus 2cT (18m)"), 410, 110, 100.0, -0.62, 150.0, -1.2, 200.0, -2.3, 11.03, 55.555, 120, 305 }, - { _T("Ventus 2cx (18m)"), 385, 215, 80.0, -0.5, 120.0, -0.73, 180.0, -2.0, 11.03, 55.555, 120, 265 }, - { _T("Ventus 2cxT (18m)"), 470, 130, 100.0, -0.56, 150.0, -1.13, 200.0, -2.28, 11.03, 55.555, 120, 310 }, - { _T("Ventus a/b (16.6m)"), 358, 151, 100.17, -0.64, 159.69, -1.47, 239.54, -4.3, 9.96, 55.555, 113, 250 }, - { _T("Ventus b (15m)"), 341, 151, 97.69, -0.68, 156.3, -1.46, 234.45, -3.9, 9.51, 55.555, 110, 240 }, - { _T("Ventus cM (17.6)"), 430, 0, 100.17, -0.6, 159.7, -1.32, 210.54, -2.5, 10.14, 55.555, 115, 360 }, + { "SZD-55-1 Promyk", 350, 200, 100.0, -0.66, 120, -0.86, 150, -1.4, 9.60, 0.0, 106, 215 }, + { "SZD-9 bis 1E Bocian", 540, 0, 70, -0.83, 90, -1.00, 140, -2.53, 20, 0.0, 76, 330 }, + { "Taurus", 472, 0, 100, -0.71, 120, -0.83, 150, -1.35, 12.26, 0.0, 99, 306 }, + { "Ventus 2c (18m)", 385, 180, 80.0, -0.5, 120.0, -0.73, 180.0, -2.0, 11.03, 55.555, 120, 260 }, + { "Ventus 2cT (18m)", 410, 110, 100.0, -0.62, 150.0, -1.2, 200.0, -2.3, 11.03, 55.555, 120, 305 }, + { "Ventus 2cx (18m)", 385, 215, 80.0, -0.5, 120.0, -0.73, 180.0, -2.0, 11.03, 55.555, 120, 265 }, + { "Ventus 2cxT (18m)", 470, 130, 100.0, -0.56, 150.0, -1.13, 200.0, -2.28, 11.03, 55.555, 120, 310 }, + { "Ventus a/b (16.6m)", 358, 151, 100.17, -0.64, 159.69, -1.47, 239.54, -4.3, 9.96, 55.555, 113, 250 }, + { "Ventus b (15m)", 341, 151, 97.69, -0.68, 156.3, -1.46, 234.45, -3.9, 9.51, 55.555, 110, 240 }, + { "Ventus cM (17.6)", 430, 0, 100.17, -0.6, 159.7, -1.32, 210.54, -2.5, 10.14, 55.555, 115, 360 }, // from LK8000 - { _T("VSO-10 Gradient"), 347, 0, 90, -0.78, 130, -1.41, 160, -2.44, 12.0, 44.444, 96, 250 }, - { _T("VT-116 Orlik II"), 335, 0, 80, -0.7, 100, -1.05, 120, -1.65, 12.8, 33.333, 86, 215 }, + { "VSO-10 Gradient", 347, 0, 90, -0.78, 130, -1.41, 160, -2.44, 12.0, 44.444, 96, 250 }, + { "VT-116 Orlik II", 335, 0, 80, -0.7, 100, -1.05, 120, -1.65, 12.8, 33.333, 86, 215 }, // from factory polar. // flight manual http://www.issoire-aviation.fr/doc_avia_gen/MdV_WA26P_R2.pdf // Contest handicap reference: http://docplayer.fr/79733029-Handicaps-planeurs-ffvv.html - { _T("WA 26 P Squale"), 330, 0, 80, -0.61, 152, -2, 174, -3.0, 12.6, 0.0, 86, 228 }, + { "WA 26 P Squale", 330, 0, 80, -0.61, 152, -2, 174, -3.0, 12.6, 0.0, 86, 228 }, - { _T("Zuni II"), 358, 182, 110, -0.88, 167, -2.21, 203.72, -3.6, 10.13, 0.0, 0, 238 }, + { "Zuni II", 358, 182, 110, -0.88, 167, -2.21, 203.72, -3.6, 10.13, 0.0, 0, 238 }, }; const Item & diff --git a/src/PopupMessage.cpp b/src/PopupMessage.cpp index 62749d4f38f..ef334c9412b 100644 --- a/src/PopupMessage.cpp +++ b/src/PopupMessage.cpp @@ -66,7 +66,7 @@ PopupMessage::Message::AppendTo(StaticString<2000> &buffer, } if (!buffer.empty()) - buffer.append(_T("\r\n")); + buffer.append("\r\n"); buffer.append(text); return true; } @@ -320,7 +320,7 @@ PopupMessage::AddMessage(const char* text, const char *data) noexcept char msgcache[1024]; strcpy(msgcache, text); if (data != nullptr) { - strcat(msgcache, _T(" ")); + strcat(msgcache, " "); strcat(msgcache, data); } diff --git a/src/Profile/DeviceConfig.cpp b/src/Profile/DeviceConfig.cpp index ce0448dab69..680945f5d77 100644 --- a/src/Profile/DeviceConfig.cpp +++ b/src/Profile/DeviceConfig.cpp @@ -91,13 +91,13 @@ LoadPath(const ProfileMap &map, DeviceConfig &config, unsigned n) if (retvalue && !config.path.empty()) { if ((config.path.back() == char(':')) && /* In Windows the value itself should be only have the short */ - config.path.StartsWith(_T("COM"))) { + config.path.StartsWith("COM")) { /* old-style raw names has a trailing colon (for backwards compatibility with older XCSoar versions) */ config.path.Truncate(config.path.length() - 1); // write back this (short) value to the profile: ((ProfileMap)map).Set(buffer, config.path); - } else if (config.path.StartsWith(_T("\\\\.\\COM"))) { + } else if (config.path.StartsWith("\\\\.\\COM")) { /* since 7.30 the raw names in the XCSoar config has the UNC style (compatibility with this XCSoar versions config) */ config.path = config.path + 4; diff --git a/src/Profile/GeoValue.cpp b/src/Profile/GeoValue.cpp index 4143c22821d..18b15389136 100644 --- a/src/Profile/GeoValue.cpp +++ b/src/Profile/GeoValue.cpp @@ -15,13 +15,13 @@ ProfileMap::GetGeoPoint(std::string_view key, GeoPoint &value) const noexcept char *endptr; double longitude = ParseDouble(p, &endptr); - if (endptr == p || *endptr != _T(' ') || + if (endptr == p || *endptr != ' ' || longitude < -180.0 || longitude > 180.0) return false; p = endptr + 1; double latitude = ParseDouble(p, &endptr); - if (endptr == p || *endptr != _T('\0') || + if (endptr == p || *endptr != '\0' || latitude < -90.0 || latitude > 90.0) return false; diff --git a/src/Profile/InfoBoxConfig.cpp b/src/Profile/InfoBoxConfig.cpp index 7024d8490c1..26ed2b4bd7a 100644 --- a/src/Profile/InfoBoxConfig.cpp +++ b/src/Profile/InfoBoxConfig.cpp @@ -127,7 +127,7 @@ Profile::Load(const ProfileMap &map, InfoBoxSettings &settings) sprintf(profileKey, "InfoBoxPanel%uName", i); map.Get(profileKey, panel.name); if (panel.name.empty()) - _stprintf(panel.name.buffer(), _T("AUX-%u"), i-2); + _stprintf(panel.name.buffer(), "AUX-%u", i-2); } for (unsigned j = 0; j < panel.MAX_CONTENTS; ++j) { diff --git a/src/Profile/PathValue.cpp b/src/Profile/PathValue.cpp index ae093024d91..9a7e05879e4 100644 --- a/src/Profile/PathValue.cpp +++ b/src/Profile/PathValue.cpp @@ -39,7 +39,7 @@ static Path BackslashBaseName(const char *p) noexcept { if (DIR_SEPARATOR != '\\') { - const auto *backslash = StringFindLast(p, _T('\\')); + const auto *backslash = StringFindLast(p, '\\'); if (backslash != NULL) p = backslash + 1; } @@ -61,7 +61,7 @@ void ProfileMap::SetPath(std::string_view key, Path value) noexcept { if (value == nullptr || StringIsEmpty(value.c_str())) - Set(key, _T("")); + Set(key, ""); else { const auto contracted = ContractLocalPath(value); if (contracted != nullptr) diff --git a/src/Profile/Profile.cpp b/src/Profile/Profile.cpp index d5fbb82ea58..41f8b111d56 100644 --- a/src/Profile/Profile.cpp +++ b/src/Profile/Profile.cpp @@ -46,7 +46,7 @@ Profile::LoadFile(Path path) noexcept { try { LoadFile(map, path); - LogFormat(_T("Loaded profile from %s"), path.c_str()); + LogFormat("Loaded profile from %s", path.c_str()); } catch (...) { LogError(std::current_exception(), "Failed to load profile"); } @@ -74,7 +74,7 @@ Profile::Save() noexcept void Profile::SaveFile(Path path) { - LogFormat(_T("Saving profile to %s"), path.c_str()); + LogFormat("Saving profile to %s", path.c_str()); SaveFile(map, path); } @@ -91,7 +91,7 @@ Profile::SetFiles(Path override_path) noexcept startProfileFile = LocalPath(override_path); else { std::string t(override_path.c_str()); - t += _T(".prf"); + t += ".prf"; startProfileFile = LocalPath(t.c_str()); } } else @@ -100,7 +100,7 @@ Profile::SetFiles(Path override_path) noexcept } // Set the default profile file - startProfileFile = LocalPath(_T(XCSPROFILE)); + startProfileFile = LocalPath(XCSPROFILE); } AllocatedPath diff --git a/src/Profile/ProfileMap.hpp b/src/Profile/ProfileMap.hpp index 0ec6114f804..8d4d17cd092 100644 --- a/src/Profile/ProfileMap.hpp +++ b/src/Profile/ProfileMap.hpp @@ -95,7 +95,7 @@ GetEnum(std::string_view key, T &value) noexcept static inline void Set(std::string_view key, bool value) noexcept { - Set(key, value ? _T("1") : _T("0")); + Set(key, value ? "1" : "0"); } void diff --git a/src/Profile/StringValue.cpp b/src/Profile/StringValue.cpp index 355282c790c..4dd1586979c 100644 --- a/src/Profile/StringValue.cpp +++ b/src/Profile/StringValue.cpp @@ -11,7 +11,7 @@ ProfileMap::Get(std::string_view key, std::span value) const noexcept { const char *src = Get(key); if (src == nullptr) { - value[0] = _T('\0'); + value[0] = '\0'; return false; } diff --git a/src/Profile/TrackingProfile.cpp b/src/Profile/TrackingProfile.cpp index 3cc0c00e45c..c8f26830637 100644 --- a/src/Profile/TrackingProfile.cpp +++ b/src/Profile/TrackingProfile.cpp @@ -44,10 +44,10 @@ static void Load(const ProfileMap &map, map.Get(ProfileKeys::LiveTrack24Enabled, settings.enabled); if (!map.Get(ProfileKeys::LiveTrack24Server, settings.server)) - settings.server = _T("www.livetrack24.com"); - else if (StringIsEqual(settings.server, _T("livexc.dhv1.de"))) { + settings.server = "www.livetrack24.com"; + else if (StringIsEqual(settings.server, "livexc.dhv1.de")) { // DHV tracking server moved to new host (#3208) - settings.server = _T("livexc.dhv.de"); + settings.server = "livexc.dhv.de"; } map.Get(ProfileKeys::LiveTrack24Username, settings.username); diff --git a/src/ProgressWindow.cpp b/src/ProgressWindow.cpp index 91b27929076..c4334bc0dea 100644 --- a/src/ProgressWindow.cpp +++ b/src/ProgressWindow.cpp @@ -81,7 +81,7 @@ ProgressWindow::SetMessage(const char *text) noexcept AssertThread(); if (text == nullptr) - text = _T(""); + text = ""; message = text; Invalidate(message_position); diff --git a/src/RadioFrequency.cpp b/src/RadioFrequency.cpp index aff4c9312df..4e569c5e9ed 100644 --- a/src/RadioFrequency.cpp +++ b/src/RadioFrequency.cpp @@ -20,7 +20,7 @@ RadioFrequency::Format(char *buffer, size_t max_size) const noexcept unsigned mhz = khz / 1000; khz %= 1000; - StringFormat(buffer, max_size, _T("%u.%03u"), mhz, khz); + StringFormat(buffer, max_size, "%u.%03u", mhz, khz); return buffer; } diff --git a/src/Renderer/AirspaceListRenderer.cpp b/src/Renderer/AirspaceListRenderer.cpp index aabd9667a65..02ab81f0fb3 100644 --- a/src/Renderer/AirspaceListRenderer.cpp +++ b/src/Renderer/AirspaceListRenderer.cpp @@ -71,7 +71,7 @@ AirspaceListRenderer::Draw(Canvas &canvas, const PixelRect rc, { StaticString<256> comment(AirspaceFormatter::GetClass(airspace)); - comment.AppendFormat(_T(" - %s - %s"), + comment.AppendFormat(" - %s - %s", FormatUserDistanceSmart(vector.distance).c_str(), FormatBearing(vector.bearing).c_str()); diff --git a/src/Renderer/BarographRenderer.cpp b/src/Renderer/BarographRenderer.cpp index 12e36a7068b..1ee9fc7a183 100644 --- a/src/Renderer/BarographRenderer.cpp +++ b/src/Renderer/BarographRenderer.cpp @@ -21,15 +21,15 @@ BarographCaption(char *sTmp, const FlightStatistics &fs) { const std::lock_guard lock{fs.mutex}; if (!fs.altitude_ceiling.HasResult() || fs.altitude_base.IsEmpty()) { - sTmp[0] = _T('\0'); + sTmp[0] = '\0'; } else if (fs.altitude_ceiling.GetCount() < 4) { - StringFormatUnsafe(sTmp, _T("%s:\r\n %.0f-%.0f %s"), + StringFormatUnsafe(sTmp, "%s:\r\n %.0f-%.0f %s", _("Working band"), (double)Units::ToUserAltitude(fs.GetMinWorkingHeight()), (double)Units::ToUserAltitude(fs.GetMaxWorkingHeight()), Units::GetAltitudeName()); } else { - StringFormatUnsafe(sTmp, _T("%s:\r\n %.0f-%.0f %s\r\n\r\n%s:\r\n %.0f %s/hr"), + StringFormatUnsafe(sTmp, "%s:\r\n %.0f-%.0f %s\r\n\r\n%s:\r\n %.0f %s/hr", _("Working band"), (double)Units::ToUserAltitude(fs.GetMinWorkingHeight()), (double)Units::ToUserAltitude(fs.GetMaxWorkingHeight()), @@ -99,8 +99,8 @@ RenderBarograph(Canvas &canvas, const PixelRect rc, const ProtectedTaskManager *_task) { ChartRenderer chart(chart_look, canvas, rc); - chart.SetXLabel(_T("t"), _T("hr")); - chart.SetYLabel(_T("h"), Units::GetAltitudeName()); + chart.SetXLabel("t", "hr"); + chart.SetYLabel("h", Units::GetAltitudeName()); chart.Begin(); if (!fs.altitude.HasResult()) { diff --git a/src/Renderer/ChartRenderer.cpp b/src/Renderer/ChartRenderer.cpp index fd330cfbb26..ff23a3b1716 100644 --- a/src/Renderer/ChartRenderer.cpp +++ b/src/Renderer/ChartRenderer.cpp @@ -38,14 +38,14 @@ void ChartRenderer::SetXLabel(const char *text, const char *unit) noexcept { StringFormat(x_label.data(), x_label.capacity(), - _T("%s [%s]"), text, unit); + "%s [%s]", text, unit); } void ChartRenderer::SetYLabel(const char *text, const char *unit) noexcept { StringFormat(y_label.data(), y_label.capacity(), - _T("%s [%s]"), text, unit); + "%s [%s]", text, unit); } void @@ -445,13 +445,13 @@ ChartRenderer::FormatTicText(const double val, const double step, if (units == UnitFormat::TIME) { const unsigned total_minutes(val * 60); - StringFormat(buffer.data(), buffer.capacity(), _T("%u:%02u"), + StringFormat(buffer.data(), buffer.capacity(), "%u:%02u", total_minutes / 60, total_minutes % 60); } else { if (step < 1) { - StringFormat(buffer.data(), buffer.capacity(), _T("%.1f"), val); + StringFormat(buffer.data(), buffer.capacity(), "%.1f", val); } else { - StringFormat(buffer.data(), buffer.capacity(), _T("%.0f"), val); + StringFormat(buffer.data(), buffer.capacity(), "%.0f", val); } } diff --git a/src/Renderer/ClimbChartRenderer.cpp b/src/Renderer/ClimbChartRenderer.cpp index 05a0f1958d3..27d5e5b0eef 100644 --- a/src/Renderer/ClimbChartRenderer.cpp +++ b/src/Renderer/ClimbChartRenderer.cpp @@ -21,14 +21,14 @@ ClimbChartCaption(char *sTmp, { const std::lock_guard lock{fs.mutex}; if (fs.thermal_average.IsEmpty()) { - sTmp[0] = _T('\0'); + sTmp[0] = '\0'; } else if (fs.thermal_average.GetCount() == 1) { - StringFormatUnsafe(sTmp, _T("%s:\r\n %3.1f %s"), + StringFormatUnsafe(sTmp, "%s:\r\n %3.1f %s", _("Avg. climb"), (double)Units::ToUserVSpeed(fs.thermal_average.GetAverageY()), Units::GetVerticalSpeedName()); } else { - StringFormatUnsafe(sTmp, _T("%s:\r\n %3.1f %s\r\n\r\n%s:\r\n %3.2f %s/hr"), + StringFormatUnsafe(sTmp, "%s:\r\n %3.1f %s\r\n\r\n%s:\r\n %3.2f %s/hr", _("Avg. climb"), (double)Units::ToUserVSpeed(fs.thermal_average.GetAverageY()), Units::GetVerticalSpeedName(), @@ -48,8 +48,8 @@ RenderClimbChart(Canvas &canvas, const PixelRect rc, const TaskManager &task) { ChartRenderer chart(chart_look, canvas, rc); - chart.SetXLabel(_T("t"), _T("hr")); - chart.SetYLabel(_T("w"), Units::GetVerticalSpeedName()); + chart.SetXLabel("t", "hr"); + chart.SetYLabel("w", Units::GetVerticalSpeedName()); chart.Begin(); if (fs.thermal_average.IsEmpty()) { @@ -98,7 +98,7 @@ RenderClimbChart(Canvas &canvas, const PixelRect rc, ChartLook::STYLE_REDTHICKDASH); chart.DrawLabel({chart.GetXMin()*0.9+chart.GetXMax()*0.1, MACCREADY}, - _T("MC")); + "MC"); chart.Finish(); } diff --git a/src/Renderer/CuRenderer.cpp b/src/Renderer/CuRenderer.cpp index ad921aaaf69..41d5117c7bf 100644 --- a/src/Renderer/CuRenderer.cpp +++ b/src/Renderer/CuRenderer.cpp @@ -20,8 +20,8 @@ RenderTemperatureChart(Canvas &canvas, const PixelRect rc, const CuSonde &cu_sonde) { ChartRenderer chart(chart_look, canvas, rc); - chart.SetXLabel(_T("T"), Units::GetTemperatureName()); - chart.SetYLabel(_T("h"), Units::GetAltitudeName()); + chart.SetXLabel("T", Units::GetTemperatureName()); + chart.SetYLabel("h", Units::GetAltitudeName()); chart.Begin(); int hmin = 10000; @@ -103,15 +103,15 @@ RenderTemperatureChart(Canvas &canvas, const PixelRect rc, if (ipos > 2) { if (!labelDry) { chart.DrawLabel({cu_sonde.cslevels[i + 1].dry_temperature.ToUser(), alt}, - _T("DALR")); + "DALR"); labelDry = true; } else if (!labelAir) { chart.DrawLabel({cu_sonde.cslevels[i + 1].air_temperature.ToUser(), alt}, - _T("Air")); + "Air"); labelAir = true; } else if (!labelDew && has_dewpoint) { chart.DrawLabel({cu_sonde.cslevels[i + 1].dewpoint.ToUser(), alt}, - _T("Dew")); + "Dew"); labelDew = true; } } @@ -123,7 +123,7 @@ RenderTemperatureChart(Canvas &canvas, const PixelRect rc, void TemperatureChartCaption(char *sTmp, const CuSonde &cu_sonde) { - StringFormatUnsafe(sTmp, _T("%s:\r\n %5.0f %s\r\n\r\n%s:\r\n %5.0f %s\r\n"), + StringFormatUnsafe(sTmp, "%s:\r\n %5.0f %s\r\n\r\n%s:\r\n %5.0f %s\r\n", _("Thermal height"), (double)Units::ToUserAltitude(cu_sonde.thermal_height), Units::GetAltitudeName(), diff --git a/src/Renderer/FlightListRenderer.cpp b/src/Renderer/FlightListRenderer.cpp index 9a3304a96cf..760b8f58400 100644 --- a/src/Renderer/FlightListRenderer.cpp +++ b/src/Renderer/FlightListRenderer.cpp @@ -21,7 +21,7 @@ FlightListRenderer::Draw(Canvas &canvas, PixelRect rc) if (flights.empty()) { auto center = rc.GetCenter(); - const char *text = _T("No flights"); + const char *text = "No flights"; PixelSize size = canvas.CalcTextSize(text); canvas.DrawText(center - size / 2u, text); return; @@ -36,8 +36,8 @@ FlightListRenderer::Draw(Canvas &canvas, PixelRect rc) return; const unsigned row_height = font_height + padding; - const unsigned date_width = canvas.CalcTextWidth(_T("2222-22-22")) + padding * 4; - const unsigned time_width = canvas.CalcTextWidth(_T("22:22")) + padding * 4; + const unsigned date_width = canvas.CalcTextWidth("2222-22-22") + padding * 4; + const unsigned time_width = canvas.CalcTextWidth("22:22") + padding * 4; canvas.Select(header_font); @@ -51,36 +51,36 @@ FlightListRenderer::Draw(Canvas &canvas, PixelRect rc) StaticString<64> buffer; if (flight.date.IsPlausible()) { - buffer.UnsafeFormat(_T("%04u-%02u-%02u "), flight.date.year, + buffer.UnsafeFormat("%04u-%02u-%02u ", flight.date.year, flight.date.month, flight.date.day); canvas.DrawText({x, y}, buffer); } else - canvas.DrawText({x, y}, _T("____-__-__")); + canvas.DrawText({x, y}, "____-__-__"); x += date_width; if (flight.start_time.IsPlausible()) { - buffer.UnsafeFormat(_T("%02u:%02u "), + buffer.UnsafeFormat("%02u:%02u ", flight.start_time.hour, flight.start_time.minute); canvas.DrawText({x, y}, buffer); } else - canvas.DrawText({x, y}, _T("--:--")); + canvas.DrawText({x, y}, "--:--"); x += time_width; if (flight.end_time.IsPlausible()) { - buffer.UnsafeFormat(_T("%02u:%02u"), + buffer.UnsafeFormat("%02u:%02u", flight.end_time.hour, flight.end_time.minute); canvas.DrawText({x, y}, buffer); } else - canvas.DrawText({x, y}, _T("--:--")); + canvas.DrawText({x, y}, "--:--"); x += time_width; if (flight.Duration().count() >= 0) { BrokenTime duration = BrokenTime::FromSinceMidnight(flight.Duration()); - buffer.UnsafeFormat(_T("%02u:%02u"), + buffer.UnsafeFormat("%02u:%02u", duration.hour, duration.minute); canvas.DrawText({x, y}, buffer); } else - canvas.DrawText({x, y}, _T("--:--")); + canvas.DrawText({x, y}, "--:--"); x += time_width; y -= row_height; @@ -89,13 +89,13 @@ FlightListRenderer::Draw(Canvas &canvas, PixelRect rc) { int x = rc.left + padding; - canvas.DrawText({x, y}, _T("Date")); + canvas.DrawText({x, y}, "Date"); x += date_width; - canvas.DrawText({x, y}, _T("Time")); + canvas.DrawText({x, y}, "Time"); x += time_width; x += time_width; - canvas.DrawText({x, y}, _T("Duration")); + canvas.DrawText({x, y}, "Duration"); } } diff --git a/src/Renderer/FlightStatisticsRenderer.cpp b/src/Renderer/FlightStatisticsRenderer.cpp index bc70d6102b4..1b884a904ac 100644 --- a/src/Renderer/FlightStatisticsRenderer.cpp +++ b/src/Renderer/FlightStatisticsRenderer.cpp @@ -203,8 +203,8 @@ FlightStatisticsRenderer::CaptionContest(char *sTmp, StringFormatUnsafe(sTmp, (Layout::landscape - ? _T("%s:\r\n%s\r\n%s (FAI)\r\n%s:\r\n%.1f %s\r\n%s: %s\r\n%s: %s\r\n") - : _T("%s: %s\r\n%s (FAI)\r\n%s: %.1f %s\r\n%s: %s\r\n%s: %s\r\n")), + ? "%s:\r\n%s\r\n%s (FAI)\r\n%s:\r\n%.1f %s\r\n%s: %s\r\n%s: %s\r\n" + : "%s: %s\r\n%s (FAI)\r\n%s: %.1f %s\r\n%s: %s\r\n%s: %s\r\n"), _("Distance"), FormatUserDistanceSmart(result_classic.distance).c_str(), FormatUserDistanceSmart(result_fai.distance).c_str(), @@ -222,8 +222,8 @@ FlightStatisticsRenderer::CaptionContest(char *sTmp, StringFormatUnsafe(sTmp, (Layout::landscape - ? _T("%s:\r\n%s (Free)\r\n%s (Triangle)\r\n%s:\r\n%.1f %s\r\n%s: %s\r\n%s: %s\r\n") - : _T("%s: %s (Free)\r\n%s (Triangle)\r\n%s: %.1f %s\r\n%s: %s\r\n%s: %s\r\n")), + ? "%s:\r\n%s (Free)\r\n%s (Triangle)\r\n%s:\r\n%.1f %s\r\n%s: %s\r\n%s: %s\r\n" + : "%s: %s (Free)\r\n%s (Triangle)\r\n%s: %.1f %s\r\n%s: %s\r\n%s: %s\r\n"), _("Distance"), FormatUserDistanceSmart(result_free.distance).c_str(), FormatUserDistanceSmart(result_triangle.distance).c_str(), @@ -249,8 +249,8 @@ FlightStatisticsRenderer::CaptionContest(char *sTmp, StringFormatUnsafe(sTmp, (Layout::landscape - ? _T("%s:\r\n%s\r\n%s:\r\n%.1f %s\r\n%s: %s\r\n%s: %s\r\n") - : _T("%s: %s\r\n%s: %.1f %s\r\n%s: %s\r\n%s: %s\r\n")), + ? "%s:\r\n%s\r\n%s:\r\n%.1f %s\r\n%s: %s\r\n%s: %s\r\n" + : "%s: %s\r\n%s: %.1f %s\r\n%s: %s\r\n%s: %s\r\n"), _("Distance"), FormatUserDistanceSmart(result_olc.distance).c_str(), _("Score"), (double)result_olc.score, _("pts"), @@ -352,7 +352,7 @@ FlightStatisticsRenderer::CaptionTask(char *sTmp, const DerivedInfo &derived) no if (Layout::landscape) { StringFormatUnsafe(sTmp, - _T("%s:\r\n %s\r\n%s:\r\n %s\r\n%s:\r\n %5.0f %s\r\n%s:\r\n %5.0f %s\r\n"), + "%s:\r\n %s\r\n%s:\r\n %s\r\n%s:\r\n %5.0f %s\r\n%s:\r\n %5.0f %s\r\n", _("Task to go"), timetext1.c_str(), _("AAT to go"), timetext2.c_str(), _("Distance to go"), @@ -362,7 +362,7 @@ FlightStatisticsRenderer::CaptionTask(char *sTmp, const DerivedInfo &derived) no Units::GetTaskSpeedName()); } else { StringFormatUnsafe(sTmp, - _T("%s: %s\r\n%s: %s\r\n%s: %5.0f %s\r\n%s: %5.0f %s\r\n"), + "%s: %s\r\n%s: %s\r\n%s: %5.0f %s\r\n%s: %5.0f %s\r\n", _("Task to go"), timetext1.c_str(), _("AAT to go"), timetext2.c_str(), _("Distance to go"), @@ -373,7 +373,7 @@ FlightStatisticsRenderer::CaptionTask(char *sTmp, const DerivedInfo &derived) no Units::GetTaskSpeedName()); } } else { - StringFormatUnsafe(sTmp, _T("%s: %s\r\n%s: %5.0f %s\r\n"), + StringFormatUnsafe(sTmp, "%s: %s\r\n%s: %5.0f %s\r\n", _("Task to go"), FormatSignedTimeHHMM(task_stats.total.time_remaining_now).c_str(), _("Distance to go"), diff --git a/src/Renderer/GlidePolarInfoRenderer.cpp b/src/Renderer/GlidePolarInfoRenderer.cpp index 741761ce248..2308b60b3f3 100644 --- a/src/Renderer/GlidePolarInfoRenderer.cpp +++ b/src/Renderer/GlidePolarInfoRenderer.cpp @@ -27,14 +27,14 @@ RenderGlidePolarInfo(Canvas &canvas, const PixelRect rc, int left = rc.left*0.8 + rc.right*0.2; - text.Format(_T("%s: %s"), _("Mass"), value.c_str()); + text.Format("%s: %s", _("Mass"), value.c_str()); canvas.DrawText({left, rc.bottom - (int)Layout::Scale(50u)}, text); double wl = glide_polar.GetWingLoading(); if (wl != 0) { FormatUserWingLoading(wl, value.buffer(), true); - text.Format(_T("%s: %s"), _("Wing loading"), value.c_str()); + text.Format("%s: %s", _("Wing loading"), value.c_str()); canvas.DrawText({left, rc.bottom - (int)Layout::Scale(35u)}, text); diff --git a/src/Renderer/GlidePolarRenderer.cpp b/src/Renderer/GlidePolarRenderer.cpp index 3d3fad7e89b..835874439e4 100644 --- a/src/Renderer/GlidePolarRenderer.cpp +++ b/src/Renderer/GlidePolarRenderer.cpp @@ -19,13 +19,13 @@ void GlidePolarCaption(char *sTmp, const GlidePolar &glide_polar) { if (!glide_polar.IsValid()) { - *sTmp = _T('\0'); + *sTmp = '\0'; return; } _stprintf(sTmp, Layout::landscape ? - _T("%s:\r\n %d\r\n at %d %s\r\n\r\n%s:\r\n %3.2f %s\r\n at %d %s") : - _T("%s:\r\n %d at %d %s\r\n%s:\r\n %3.2f %s at %d %s"), + "%s:\r\n %d\r\n at %d %s\r\n\r\n%s:\r\n %3.2f %s\r\n at %d %s" : + "%s:\r\n %d at %d %s\r\n%s:\r\n %3.2f %s at %d %s", _("L/D"), (int)glide_polar.GetBestLD(), (int)Units::ToUserSpeed(glide_polar.GetVBestLD()), @@ -44,8 +44,8 @@ RenderGlidePolar(Canvas &canvas, const PixelRect rc, const GlidePolar &glide_polar) { ChartRenderer chart(chart_look, canvas, rc); - chart.SetXLabel(_T("V"), Units::GetSpeedName()); - chart.SetYLabel(_T("w"), Units::GetVerticalSpeedName()); + chart.SetXLabel("V", Units::GetSpeedName()); + chart.SetYLabel("w", Units::GetVerticalSpeedName()); chart.Begin(); if (!glide_polar.IsValid()) { @@ -127,10 +127,10 @@ RenderGlidePolar(Canvas &canvas, const PixelRect rc, // draw labels and other overlays double vv = 0.9*vmax+0.1*vmin; - chart.DrawLabel({vv, -glide_polar.SinkRate(vv)}, _T("Polar")); + chart.DrawLabel({vv, -glide_polar.SinkRate(vv)}, "Polar"); vv = 0.8*vmax+0.2*vmin; - chart.DrawLabel({vv, MACCREADY + slope * vv}, _T("Best glide")); - chart.DrawLabel({v_dolphin_last_l, w_dolphin_last_l},_T("Dolphin")); + chart.DrawLabel({vv, MACCREADY + slope * vv}, "Best glide"); + chart.DrawLabel({v_dolphin_last_l, w_dolphin_last_l},"Dolphin"); RenderGlidePolarInfo(canvas, rc, chart_look, glide_polar); diff --git a/src/Renderer/MacCreadyRenderer.cpp b/src/Renderer/MacCreadyRenderer.cpp index d00a052c9a8..1b8102d5fd2 100644 --- a/src/Renderer/MacCreadyRenderer.cpp +++ b/src/Renderer/MacCreadyRenderer.cpp @@ -19,12 +19,12 @@ void MacCreadyCaption(char *sTmp, const GlidePolar &glide_polar) { if (!glide_polar.IsValid()) { - *sTmp = _T('\0'); + *sTmp = '\0'; return; } _stprintf(sTmp, - _T("%s: %d %s\r\n%s: %d %s"), + "%s: %d %s\r\n%s: %d %s", _("Vopt"), (int)Units::ToUserSpeed(glide_polar.GetVBestLD()), Units::GetSpeedName(), @@ -40,8 +40,8 @@ RenderMacCready(Canvas &canvas, const PixelRect rc, const GlidePolar &glide_polar) { ChartRenderer chart(chart_look, canvas, rc); - chart.SetYLabel(_T("V"), Units::GetSpeedName()); - chart.SetXLabel(_T("MC"), Units::GetVerticalSpeedName()); + chart.SetYLabel("V", Units::GetSpeedName()); + chart.SetXLabel("MC", Units::GetVerticalSpeedName()); chart.Begin(); if (!glide_polar.IsValid()) { @@ -83,9 +83,9 @@ RenderMacCready(Canvas &canvas, const PixelRect rc, // draw labels and other overlays gp.SetMC(0.9*MAX_MACCREADY); - chart.DrawLabel({0.9*MAX_MACCREADY, gp.GetVBestLD()}, _T("Vopt")); + chart.DrawLabel({0.9*MAX_MACCREADY, gp.GetVBestLD()}, "Vopt"); gp.SetMC(0.9*MAX_MACCREADY); - chart.DrawLabel({0.9*MAX_MACCREADY, gp.GetAverageSpeed()}, _T("Vave")); + chart.DrawLabel({0.9*MAX_MACCREADY, gp.GetAverageSpeed()}, "Vave"); chart.Finish(); diff --git a/src/Renderer/MapItemListRenderer.cpp b/src/Renderer/MapItemListRenderer.cpp index f2934dcf714..c18d8ae848b 100644 --- a/src/Renderer/MapItemListRenderer.cpp +++ b/src/Renderer/MapItemListRenderer.cpp @@ -55,21 +55,21 @@ Draw(Canvas &canvas, const PixelRect rc, { char info_buffer[256]; if (item.vector.IsValid()) - StringFormatUnsafe(info_buffer, _T("%s: %s, %s: %s"), + StringFormatUnsafe(info_buffer, "%s: %s, %s: %s", _("Distance"), FormatUserDistanceSmart(item.vector.distance).c_str(), _("Direction"), FormatBearing(item.vector.bearing).c_str()); else - StringFormatUnsafe(info_buffer, _T("%s: %s, %s: %s"), - _("Distance"), _T("???"), _("Direction"), _T("???")); + StringFormatUnsafe(info_buffer, "%s: %s, %s: %s", + _("Distance"), "???", _("Direction"), "???"); row_renderer.DrawFirstRow(canvas, rc, info_buffer); - StringFormatUnsafe(info_buffer, _T("%s: %s"), _("Elevation"), + StringFormatUnsafe(info_buffer, "%s: %s", _("Elevation"), item.HasElevation() ? FormatUserAltitude(item.elevation).c_str() - : _T("???")); + : "???"); row_renderer.DrawSecondRow(canvas, rc, info_buffer); } @@ -130,10 +130,10 @@ Draw(Canvas &canvas, PixelRect rc, FormatRelativeUserAltitude(relative_arrival_altitude, altitude_buffer); - buffer.AppendFormat(_T("%s %s, "), altitude_buffer, _("AGL")); + buffer.AppendFormat("%s %s, ", altitude_buffer, _("AGL")); } - buffer.AppendFormat(_T("%s %s"), + buffer.AppendFormat("%s %s", FormatUserAltitude(item.reach.direct).c_str(), _("MSL")); @@ -144,7 +144,7 @@ Draw(Canvas &canvas, PixelRect rc, // Format comment row if (reach_relevant) { - buffer.Format(_T("%s: "), _("around terrain")); + buffer.Format("%s: ", _("around terrain")); if (item.HasElevation()) { int relative_arrival_altitude = @@ -153,16 +153,16 @@ Draw(Canvas &canvas, PixelRect rc, FormatRelativeUserAltitude(relative_arrival_altitude, altitude_buffer); - buffer.AppendFormat(_T("%s %s, "), altitude_buffer, _("AGL")); + buffer.AppendFormat("%s %s, ", altitude_buffer, _("AGL")); } - buffer.AppendFormat(_T("%s %s, "), + buffer.AppendFormat("%s %s, ", FormatUserAltitude(item.reach.terrain).c_str(), _("MSL")); } else if (item.HasElevation() && item.reach.direct >= item.elevation + item.safety_height && item.reach.terrain_valid == ReachResult::Validity::UNREACHABLE) { - buffer.UnsafeFormat(_T("%s "), _("Unreachable due to terrain.")); + buffer.UnsafeFormat("%s ", _("Unreachable due to terrain.")); } else { buffer.clear(); } @@ -254,7 +254,7 @@ Draw(Canvas &canvas, PixelRect rc, if (timespan.count() < 0) timespan += hours{24}; - buffer.Format(_T("%s: %s - left %s ago (%s)"), + buffer.Format("%s: %s - left %s ago (%s)", _("Avg. lift"), FormatUserVerticalSpeed(thermal.lift_rate).c_str(), FormatTimespanSmart(timespan).c_str(), @@ -332,7 +332,7 @@ Draw(Canvas &canvas, PixelRect rc, // Append name to the title, if it exists const char *callsign = FlarmDetails::LookupCallsign(item.id); if (callsign != nullptr && !StringIsEmpty(callsign)) { - title_string.append(_T(", ")); + title_string.append(", "); title_string.append(callsign); } @@ -349,11 +349,11 @@ Draw(Canvas &canvas, PixelRect rc, // Generate the line of info about the target, if it's available if (traffic != nullptr) { if (traffic->altitude_available) - info_string.AppendFormat(_T(", %s: %s"), _("Altitude"), + info_string.AppendFormat(", %s: %s", _("Altitude"), FormatUserAltitude(traffic->altitude).c_str()); if (traffic->climb_rate_avg30s_available) { - info_string.AppendFormat(_T(", %s: %s"), _("Vario"), + info_string.AppendFormat(", %s: %s", _("Vario"), FormatUserVerticalSpeed(traffic->climb_rate_avg30s).c_str()); } } diff --git a/src/Renderer/NOAAListRenderer.cpp b/src/Renderer/NOAAListRenderer.cpp index 48541378096..1663479e027 100644 --- a/src/Renderer/NOAAListRenderer.cpp +++ b/src/Renderer/NOAAListRenderer.cpp @@ -17,7 +17,7 @@ NOAAListRenderer::Draw(Canvas &canvas, const PixelRect rc, title = station.GetCodeT(); if (station.parsed_metar_available && station.parsed_metar.name_available) - title.AppendFormat(_T(": %s"), station.parsed_metar.name.c_str()); + title.AppendFormat(": %s", station.parsed_metar.name.c_str()); row_renderer.DrawFirstRow(canvas, rc, title); diff --git a/src/Renderer/TaskLegRenderer.cpp b/src/Renderer/TaskLegRenderer.cpp index dee87b99612..58195cb6bec 100644 --- a/src/Renderer/TaskLegRenderer.cpp +++ b/src/Renderer/TaskLegRenderer.cpp @@ -66,7 +66,7 @@ RenderTaskLegs(ChartRenderer &chart, ChartLook::STYLE_GRIDZERO); } if (y>=0) { - StringFormatUnsafe(sTmp, _T("%d"), i); + StringFormatUnsafe(sTmp, "%d", i); chart.DrawLabel({x, chart.GetYMax()*y + chart.GetYMin()*(1-y)}, sTmp); } diff --git a/src/Renderer/TaskSpeedRenderer.cpp b/src/Renderer/TaskSpeedRenderer.cpp index 0a267e6aa85..306ca70e244 100644 --- a/src/Renderer/TaskSpeedRenderer.cpp +++ b/src/Renderer/TaskSpeedRenderer.cpp @@ -20,12 +20,12 @@ TaskSpeedCaption(char *sTmp, const GlidePolar &glide_polar) { if (!glide_polar.IsValid() || fs.task_speed.IsEmpty()) { - *sTmp = _T('\0'); + *sTmp = '\0'; return; } _stprintf(sTmp, - _T("%s: %d %s\r\n%s: %d %s"), + "%s: %d %s\r\n%s: %d %s", _("Vave"), (int)Units::ToUserTaskSpeed(fs.task_speed.GetAverageY()), Units::GetTaskSpeedName(), @@ -44,8 +44,8 @@ RenderSpeed(Canvas &canvas, const PixelRect rc, const GlidePolar &glide_polar) { ChartRenderer chart(chart_look, canvas, rc); - chart.SetXLabel(_T("t"), _T("hr")); - chart.SetYLabel(_T("V"), Units::GetTaskSpeedName()); + chart.SetXLabel("t", "hr"); + chart.SetYLabel("V", Units::GetTaskSpeedName()); chart.Begin(); if (!fs.task_speed.HasResult() || !task.CheckOrderedTask()) { @@ -93,10 +93,10 @@ RenderSpeed(Canvas &canvas, const PixelRect rc, chart.DrawTrend(fs.task_speed, ChartLook::STYLE_BLUETHINDASH); chart.DrawLabel({chart.GetXMin()*0.9+chart.GetXMax()*0.1, vref}, - _T("Vest")); + "Vest"); const double tref = chart.GetXMin()*0.5+chart.GetXMax()*0.5; - chart.DrawLabel({tref, fs.task_speed.GetYAt(tref)}, _T("Vave")); + chart.DrawLabel({tref, fs.task_speed.GetYAt(tref)}, "Vave"); chart.Finish(); } diff --git a/src/Renderer/ThermalBandRenderer.cpp b/src/Renderer/ThermalBandRenderer.cpp index d2b116b81a1..cdc0d375872 100644 --- a/src/Renderer/ThermalBandRenderer.cpp +++ b/src/Renderer/ThermalBandRenderer.cpp @@ -133,7 +133,7 @@ ThermalBandRenderer::DrawRiskMC(const DerivedInfo &calculated, chart.DrawLineGraph(tmp, (is_map || is_infobox)? ChartLook::STYLE_WHITE: ChartLook::STYLE_REDTHICKDASH); if (!is_map && !is_infobox) { - chart.DrawLabel({rmc, h_m}, _T("MC")); + chart.DrawLabel({rmc, h_m}, "MC"); } } @@ -225,8 +225,8 @@ ThermalBandRenderer::DrawThermalBand(const MoreData &basic, { ChartRenderer chart(chart_look, canvas, rc, !is_map); if (!is_map) { - chart.SetXLabel(_T("w"), Units::GetVerticalSpeedName()); - chart.SetYLabel(_T("h AGL"), Units::GetAltitudeName()); + chart.SetXLabel("w", Units::GetVerticalSpeedName()); + chart.SetYLabel("h AGL", Units::GetAltitudeName()); } chart.Begin(); diff --git a/src/Renderer/UnitSymbolRenderer.cpp b/src/Renderer/UnitSymbolRenderer.cpp index 0f2be5edcc4..e1037748d6d 100644 --- a/src/Renderer/UnitSymbolRenderer.cpp +++ b/src/Renderer/UnitSymbolRenderer.cpp @@ -18,33 +18,33 @@ struct UnitSymbolStrings { static constexpr UnitSymbolStrings symbol_strings[] = { { nullptr, nullptr }, - { nullptr, _T("km"), false }, - { nullptr, _T("NM"), false }, - { nullptr, _T("mi"), false }, - { _T("km"), _T("h"), true }, - { nullptr, _T("kt"), false }, - { _T("mp"), _T("h"), false }, - { _T("m"), _T("s"), true }, - { _T("ft"), _T("min"), true }, - { nullptr, _T("m"), false }, - { nullptr, _T("ft"), false }, - { nullptr, _T("FL"), false }, - { nullptr, _T("K"), false }, - { _T(DEG), _T("C"), false }, - { _T(DEG), _T("F"), false }, - { _T("h"), _T("Pa"), false }, - { nullptr, _T("mb"), false }, - { _T("mm"), _T("Hg"), false }, - { _T("in"), _T("Hg"), false }, - { _T("kg"), _T("m²"), true }, - { _T("lb"), _T("ft²"), true }, - { nullptr, _T("kg"), false }, - { nullptr, _T("lb"), false }, - { _T("%"), _T(" "), false }, - { nullptr, _T(":1"), false }, - { nullptr, _T("V"), false }, - { nullptr, _T("Hz"), false }, - { nullptr, _T("rpm"), false }, + { nullptr, "km", false }, + { nullptr, "NM", false }, + { nullptr, "mi", false }, + { "km", "h", true }, + { nullptr, "kt", false }, + { "mp", "h", false }, + { "m", "s", true }, + { "ft", "min", true }, + { nullptr, "m", false }, + { nullptr, "ft", false }, + { nullptr, "FL", false }, + { nullptr, "K", false }, + { DEG, "C", false }, + { DEG, "F", false }, + { "h", "Pa", false }, + { nullptr, "mb", false }, + { "mm", "Hg", false }, + { "in", "Hg", false }, + { "kg", "m²", true }, + { "lb", "ft²", true }, + { nullptr, "kg", false }, + { nullptr, "lb", false }, + { "%", " ", false }, + { nullptr, ":1", false }, + { nullptr, "V", false }, + { nullptr, "Hz", false }, + { nullptr, "rpm", false }, }; static_assert(ARRAY_SIZE(symbol_strings) == (size_t)Unit::COUNT, diff --git a/src/Renderer/VarioHistogramRenderer.cpp b/src/Renderer/VarioHistogramRenderer.cpp index 9fef157d17a..548169280cb 100644 --- a/src/Renderer/VarioHistogramRenderer.cpp +++ b/src/Renderer/VarioHistogramRenderer.cpp @@ -24,7 +24,7 @@ RenderVarioHistogram(Canvas &canvas, const PixelRect rc, const GlidePolar &glide_polar) { ChartRenderer chart(chart_look, canvas, rc); - chart.SetYLabel(_T("w"), Units::GetVerticalSpeedName()); + chart.SetYLabel("w", Units::GetVerticalSpeedName()); chart.Begin(); if (fs.vario_cruise_histogram.empty() && @@ -92,8 +92,8 @@ RenderVarioHistogram(Canvas &canvas, const PixelRect rc, chart.DrawYGrid(Units::ToSysVSpeed(1), 1, ChartRenderer::UnitFormat::NUMERIC); const double tref = chart.GetXMin()*0.1+chart.GetXMax()*0.9; - chart.DrawLabel({tref, mc}, _T("MC")); - chart.DrawLabel({tref, s}, _T("S cruise")); + chart.DrawLabel({tref, mc}, "MC"); + chart.DrawLabel({tref, s}, "S cruise"); chart.Finish(); } diff --git a/src/Renderer/WaypointListRenderer.cpp b/src/Renderer/WaypointListRenderer.cpp index 7b57f1f0b4e..0697f32bb07 100644 --- a/src/Renderer/WaypointListRenderer.cpp +++ b/src/Renderer/WaypointListRenderer.cpp @@ -20,19 +20,19 @@ static void FormatWaypointDetails(Buffer &buffer, const Waypoint &waypoint) { if (waypoint.has_elevation) - buffer.Format(_T("%s: %s"), _("Elevation"), + buffer.Format("%s: %s", _("Elevation"), FormatUserAltitude(waypoint.elevation).c_str()); else - buffer.Format(_T("%s: %s"), _("Elevation"), _T("?")); + buffer.Format("%s: %s", _("Elevation"), "?"); if (waypoint.radio_frequency.IsDefined()) { char radio[16]; waypoint.radio_frequency.Format(radio, 16); - buffer.AppendFormat(_T(" - %s MHz"), radio); + buffer.AppendFormat(" - %s MHz", radio); } if (!waypoint.comment.empty()) { - buffer.AppendFormat(_T(" - %s"), waypoint.comment.c_str()); + buffer.AppendFormat(" - %s", waypoint.comment.c_str()); } } @@ -74,7 +74,7 @@ Draw(Canvas &canvas, PixelRect rc, // Draw waypoint name if (!waypoint.shortname.empty()) { const auto waypoint_title = waypoint.name + - _T(" (") + waypoint.shortname + _T(")"); + " (" + waypoint.shortname + ")"; row_renderer.DrawFirstRow(canvas, rc, waypoint_title.c_str()); } else { @@ -131,13 +131,13 @@ WaypointListRenderer::Draw(Canvas &canvas, PixelRect rc, char alt[20], radio[20]; FormatRelativeUserAltitude(arrival_altitude, alt, true); - buffer.Format(_T("%s: %s - %s: %s"), _("Distance"), + buffer.Format("%s: %s - %s: %s", _("Distance"), FormatUserDistanceSmart(distance).c_str(), _("Arrival Alt"), alt); if (waypoint.radio_frequency.IsDefined()) { waypoint.radio_frequency.Format(radio, ARRAY_SIZE(radio)); - buffer.AppendFormat(_T(" - %s MHz"), radio); + buffer.AppendFormat(" - %s MHz", radio); } row_renderer.DrawSecondRow(canvas, rc, buffer); @@ -145,7 +145,7 @@ WaypointListRenderer::Draw(Canvas &canvas, PixelRect rc, // Draw waypoint name if (!waypoint.shortname.empty()) { const auto waypoint_title = waypoint.name + - _(" (") + waypoint.shortname + _T(")"); + _(" (") + waypoint.shortname + ")"; row_renderer.DrawFirstRow(canvas, rc, waypoint_title.c_str()); } else { diff --git a/src/Renderer/WaypointRenderer.cpp b/src/Renderer/WaypointRenderer.cpp index b7d4e39bd28..569d968aa9a 100644 --- a/src/Renderer/WaypointRenderer.cpp +++ b/src/Renderer/WaypointRenderer.cpp @@ -175,7 +175,7 @@ class WaypointVisitorMap final protected: void FormatTitle(char *buffer, size_t buffer_size, const Waypoint &way_point) const noexcept { - buffer[0] = _T('\0'); + buffer[0] = '\0'; switch (settings.display_text_type) { case WaypointRendererSettings::DisplayTextType::NAME: @@ -197,7 +197,7 @@ class WaypointVisitorMap final case WaypointRendererSettings::DisplayTextType::FIRST_WORD: CopyTruncateString(buffer, buffer_size, way_point.name.c_str()); char *tmp; - tmp = strstr(buffer, _T(" ")); + tmp = strstr(buffer, " "); if (tmp != nullptr) tmp[0] = '\0'; break; @@ -245,17 +245,17 @@ class WaypointVisitorMap final size_t length = strlen(buffer); if (length > 0) - buffer[length++] = _T(':'); + buffer[length++] = ':'; if (settings.arrival_height_display == WaypointRendererSettings::ArrivalHeightDisplay::REQUIRED_GR_AND_TERRAIN && reach.IsReachableTerrain()) { int uah_terrain = (int)Units::ToUserAltitude(reach.terrain); - StringFormatUnsafe(buffer + length, _T("%.1f/%d%s"), (double) gr, + StringFormatUnsafe(buffer + length, "%.1f/%d%s", (double) gr, uah_terrain, altitude_unit); return; } - StringFormatUnsafe(buffer + length, _T("%.1f"), (double) gr); + StringFormatUnsafe(buffer + length, "%.1f", (double) gr); return; } @@ -275,25 +275,25 @@ class WaypointVisitorMap final if (settings.arrival_height_display == WaypointRendererSettings::ArrivalHeightDisplay::TERRAIN) { if (reach.IsReachableTerrain()) { if (length > 0) - buffer[length++] = _T(':'); - StringFormatUnsafe(buffer + length, _T("%d%s"), + buffer[length++] = ':'; + StringFormatUnsafe(buffer + length, "%d%s", uah_terrain, altitude_unit); } return; } if (length > 0) - buffer[length++] = _T(':'); + buffer[length++] = ':'; if (settings.arrival_height_display == WaypointRendererSettings::ArrivalHeightDisplay::GLIDE_AND_TERRAIN && reach.IsReachableDirect() && reach.IsReachableTerrain() && reach.IsDeltaConsiderable()) { - StringFormatUnsafe(buffer + length, _T("%d/%d%s"), uah_glide, + StringFormatUnsafe(buffer + length, "%d/%d%s", uah_glide, uah_terrain, altitude_unit); return; } - StringFormatUnsafe(buffer + length, _T("%d%s"), uah_glide, altitude_unit); + StringFormatUnsafe(buffer + length, "%d%s", uah_glide, altitude_unit); } void DrawWaypoint(const VisibleWaypoint &vwp) noexcept { diff --git a/src/Renderer/WindArrowRenderer.cpp b/src/Renderer/WindArrowRenderer.cpp index b5d4125c763..23eb69360a9 100644 --- a/src/Renderer/WindArrowRenderer.cpp +++ b/src/Renderer/WindArrowRenderer.cpp @@ -91,7 +91,7 @@ WindArrowRenderer::Draw(Canvas &canvas, const Angle screen_angle, // Draw wind speed label StaticString<12> buffer; - buffer.Format(_T("%i"), iround(Units::ToUserWindSpeed(wind.norm))); + buffer.Format("%i", iround(Units::ToUserWindSpeed(wind.norm))); canvas.SetTextColor(COLOR_BLACK); canvas.Select(*look.font); diff --git a/src/Renderer/WindChartRenderer.cpp b/src/Renderer/WindChartRenderer.cpp index 8366c3357e3..3442ce835b6 100644 --- a/src/Renderer/WindChartRenderer.cpp +++ b/src/Renderer/WindChartRenderer.cpp @@ -43,8 +43,8 @@ RenderWindChart(Canvas &canvas, const PixelRect rc, LeastSquares windstats_mag; ChartRenderer chart(chart_look, canvas, rc); - chart.SetXLabel(_T("w"), Units::GetSpeedName()); - chart.SetYLabel(_T("h"), Units::GetAltitudeName()); + chart.SetXLabel("w", Units::GetSpeedName()); + chart.SetYLabel("h", Units::GetAltitudeName()); chart.Begin(); if (fs.altitude_base.IsEmpty() || fs.altitude_ceiling.IsEmpty()) { diff --git a/src/Replay/Replay.cpp b/src/Replay/Replay.cpp index f9aa826a593..79c3f9eefb7 100644 --- a/src/Replay/Replay.cpp +++ b/src/Replay/Replay.cpp @@ -49,7 +49,7 @@ Replay::Start(Path _path) if (path == nullptr || path.empty()) { replay = new DemoReplayGlue(device_blackboard, task_manager); - } else if (path.EndsWithIgnoreCase(_T(".igc"))) { + } else if (path.EndsWithIgnoreCase(".igc")) { replay = new IgcReplay(std::make_unique(path)); cli = new CatmullRomInterpolator(FloatDuration{0.98}); diff --git a/src/Repository/Glue.cpp b/src/Repository/Glue.cpp index fbeb8b23ef3..959ffaa661e 100644 --- a/src/Repository/Glue.cpp +++ b/src/Repository/Glue.cpp @@ -18,5 +18,5 @@ EnqueueRepositoryDownload(bool force) return; repository_downloaded = true; - Net::DownloadManager::Enqueue(REPOSITORY_URI, Path(_T("repository"))); + Net::DownloadManager::Enqueue(REPOSITORY_URI, Path("repository")); } diff --git a/src/Startup.cpp b/src/Startup.cpp index 68ac73e20ad..ff9c17b166c 100644 --- a/src/Startup.cpp +++ b/src/Startup.cpp @@ -142,8 +142,8 @@ static void AfterStartup() { try { - const auto lua_path = LocalPath(_T("lua")); - Lua::StartFile(AllocatedPath::Build(lua_path, _T("init.lua"))); + const auto lua_path = LocalPath("lua"); + Lua::StartFile(AllocatedPath::Build(lua_path, "init.lua")); } catch (...) { LogError(std::current_exception()); } @@ -562,7 +562,7 @@ Startup(UI::Display &display) if (!is_simulator() && computer_settings.logger.enable_flight_logger) { backend_components->flight_logger = std::make_unique(live_blackboard); - backend_components->flight_logger->SetPath(LocalPath(_T("flights.log"))); + backend_components->flight_logger->SetPath(LocalPath("flights.log")); } if (computer_settings.logger.enable_nmea_logger) diff --git a/src/SystemSettings.cpp b/src/SystemSettings.cpp index e11b626df79..7b2200bc364 100644 --- a/src/SystemSettings.cpp +++ b/src/SystemSettings.cpp @@ -15,11 +15,11 @@ SystemSettings::SetDefaults() } else { devices[0].port_type = DeviceConfig::PortType::SERIAL; #ifdef _WIN32 - devices[0].path = _T("COM1"); + devices[0].path = "COM1"; #else - devices[0].path = _T("/dev/tty0"); + devices[0].path = "/dev/tty0"; #endif devices[0].baud_rate = 4800; - devices[0].driver_name = _T("Generic"); + devices[0].driver_name = "Generic"; } } diff --git a/src/Task/DefaultTask.hpp b/src/Task/DefaultTask.hpp index cee174e9187..83362c7f734 100644 --- a/src/Task/DefaultTask.hpp +++ b/src/Task/DefaultTask.hpp @@ -9,7 +9,7 @@ struct TaskBehaviour; class OrderedTask; class Waypoints; -#define default_task_path _T("Default.tsk") +#define default_task_path "Default.tsk" /** * Creates an ordered task based on the Default.tsk file diff --git a/src/Task/Serialiser.cpp b/src/Task/Serialiser.cpp index 0ffcb30575a..60232e5f25e 100644 --- a/src/Task/Serialiser.cpp +++ b/src/Task/Serialiser.cpp @@ -26,16 +26,16 @@ GetName(TaskPointType type, bool mode_optional_start) gcc_unreachable(); case TaskPointType::START: - return mode_optional_start ? _T("OptionalStart") : _T("Start"); + return mode_optional_start ? "OptionalStart" : "Start"; case TaskPointType::AST: - return _T("Turn"); + return "Turn"; case TaskPointType::AAT: - return _T("Area"); + return "Area"; case TaskPointType::FINISH: - return _T("Finish"); + return "Finish"; } gcc_unreachable(); @@ -215,23 +215,23 @@ GetTaskFactoryType(TaskFactoryType type) { switch(type) { case TaskFactoryType::FAI_GENERAL: - return _T("FAIGeneral"); + return "FAIGeneral"; case TaskFactoryType::FAI_TRIANGLE: - return _T("FAITriangle"); + return "FAITriangle"; case TaskFactoryType::FAI_OR: - return _T("FAIOR"); + return "FAIOR"; case TaskFactoryType::FAI_GOAL: - return _T("FAIGoal"); + return "FAIGoal"; case TaskFactoryType::RACING: - return _T("RT"); + return "RT"; case TaskFactoryType::AAT: - return _T("AAT"); + return "AAT"; case TaskFactoryType::MAT: - return _T("MAT"); + return "MAT"; case TaskFactoryType::MIXED: - return _T("Mixed"); + return "Mixed"; case TaskFactoryType::TOURING: - return _T("Touring"); + return "Touring"; case TaskFactoryType::COUNT: gcc_unreachable(); } diff --git a/src/Task/TaskFile.cpp b/src/Task/TaskFile.cpp index cc7dfe62975..0847d67a281 100644 --- a/src/Task/TaskFile.cpp +++ b/src/Task/TaskFile.cpp @@ -14,20 +14,20 @@ std::unique_ptr TaskFile::Create(Path path) { // If XCSoar task file -> return new TaskFileXCSoar - if (path.EndsWithIgnoreCase(_T(".tsk"))) + if (path.EndsWithIgnoreCase(".tsk")) return std::make_unique(path); // If SeeYou task file -> return new TaskFileSeeYou - if (path.EndsWithIgnoreCase(_T(".cup"))) + if (path.EndsWithIgnoreCase(".cup")) return std::make_unique(path); // If IGC file -> return new TaskFileIGC - if (path.EndsWithIgnoreCase(_T(".igc"))) + if (path.EndsWithIgnoreCase(".igc")) return std::make_unique(path); /* TODO ".xctsk" is not a real filename suffix; there is just the MIME type "application/xctsk" */ - if (path.EndsWithIgnoreCase(_T(".xctsk"))) + if (path.EndsWithIgnoreCase(".xctsk")) return std::make_unique(path); // unknown task file type diff --git a/src/Task/TaskFileIGC.cpp b/src/Task/TaskFileIGC.cpp index ebb1286ea97..835b0ac30e6 100644 --- a/src/Task/TaskFileIGC.cpp +++ b/src/Task/TaskFileIGC.cpp @@ -27,7 +27,7 @@ try { bool header_found = false; while ((line = reader.ReadLine()) != nullptr) { // Skip lines which are not declaration records - if (*line != _T('C')) + if (*line != 'C') continue; if (!header_found) { @@ -91,11 +91,11 @@ TaskFileIGC::GetTask(const TaskBehaviour &task_behaviour, waypoint_name.clear(); waypoint_name.UnsafeAppendASCII(it.name); } else if (i == 0) - waypoint_name = _T("Start"); + waypoint_name = "Start"; else if (i == num_turnpoints - 1) - waypoint_name = _T("Finish"); + waypoint_name = "Finish"; else - waypoint_name.Format(_T("%s #%u"), _T("Turnpoint"), i); + waypoint_name.Format("%s #%u", "Turnpoint", i); auto wp = MakeWaypoint(it.location, waypoint_name.c_str()); diff --git a/src/Task/TaskStore.cpp b/src/Task/TaskStore.cpp index 552596c47ad..e0c27f799d1 100644 --- a/src/Task/TaskStore.cpp +++ b/src/Task/TaskStore.cpp @@ -42,11 +42,11 @@ class TaskFileVisitor: public File::Visitor // If the task file holds more than one task const auto &saved_name = list[i]; if (!saved_name.empty()) { - name += _T(": "); + name += ": "; name += saved_name.c_str(); } else if (count > 1) { // .. append " - Task #[n]" suffix to the task name - name.AppendFormat(_T(": %s #%d"), _("Task"), i + 1); + name.AppendFormat(": %s #%d", _("Task"), i + 1); } // Add the task to the TaskStore @@ -71,11 +71,11 @@ TaskStore::Scan(bool extra) // scan files TaskFileVisitor tfv(store); - VisitDataFiles(_T("*.tsk"), tfv); + VisitDataFiles("*.tsk", tfv); if (extra) { - VisitDataFiles(_T("*.cup"), tfv); - VisitDataFiles(_T("*.igc"), tfv); + VisitDataFiles("*.cup", tfv); + VisitDataFiles("*.igc", tfv); } std::sort(store.begin(), store.end()); diff --git a/src/Task/ValidationErrorStrings.cpp b/src/Task/ValidationErrorStrings.cpp index 5fec7b58cf2..77e741f2325 100644 --- a/src/Task/ValidationErrorStrings.cpp +++ b/src/Task/ValidationErrorStrings.cpp @@ -40,7 +40,7 @@ getTaskValidationErrors(const TaskValidationErrorSet v) const char *current = gettext(validation_error_strings[i]); if (strlen(err) + strlen(current) + 1 < MAX_PATH) { strcat(err, current); - strcat(err, _T("\n")); + strcat(err, "\n"); } } diff --git a/src/TeamCode/TeamCode.cpp b/src/TeamCode/TeamCode.cpp index 9753b7a3cba..e0d67b4e3aa 100644 --- a/src/TeamCode/TeamCode.cpp +++ b/src/TeamCode/TeamCode.cpp @@ -69,7 +69,7 @@ NumberToTeamCode(unsigned value, char *code, unsigned n_digits) n_digits = CountDigits(value); char *p = code + n_digits; - *p-- = _T('\0'); + *p-- = '\0'; do { unsigned digit_value = value % BASE; diff --git a/src/Terrain/RasterTerrain.cpp b/src/Terrain/RasterTerrain.cpp index 07a3cdacd43..35129de31e2 100644 --- a/src/Terrain/RasterTerrain.cpp +++ b/src/Terrain/RasterTerrain.cpp @@ -15,7 +15,7 @@ #include "util/ConvertString.hpp" #include "LogFile.hpp" -static const char *const terrain_cache_name = _T("terrain"); +static const char *const terrain_cache_name = "terrain"; inline bool RasterTerrain::LoadCache(FileCache &cache, Path path) diff --git a/src/Topography/Index.cpp b/src/Topography/Index.cpp index a96641b4830..a54373da5a6 100644 --- a/src/Topography/Index.cpp +++ b/src/Topography/Index.cpp @@ -82,7 +82,7 @@ ParseTopographyIndexLine(const char *line) noexcept // Parse shape range char *endptr; entry.shape_range = strtod(p + 1, &endptr) * 1000; - if (*endptr != _T(',')) + if (*endptr != ',') return std::nullopt; p = endptr + 1; @@ -112,21 +112,21 @@ ParseTopographyIndexLine(const char *line) noexcept // Parse shape field for text display entry.shape_field = strtol(p + 1, &endptr, 10) - 1; - if (*endptr != _T(',')) + if (*endptr != ',') return std::nullopt; p = endptr + 1; // Parse red component of line / shading colour uint8_t red = (uint8_t)strtol(p, &endptr, 10); - if (*endptr != _T(',')) + if (*endptr != ',') return std::nullopt; p = endptr + 1; // Parse green component of line / shading colour uint8_t green = (uint8_t)strtol(p, &endptr, 10); - if (*endptr != _T(',')) + if (*endptr != ',') return std::nullopt; p = endptr + 1; @@ -138,7 +138,7 @@ ParseTopographyIndexLine(const char *line) noexcept // Parse pen width of lines entry.pen_width = 1; - if (*p == _T(',')) { + if (*p == ',') { entry.pen_width = strtoul(p + 1, &endptr, 10); if (entry.pen_width < 1) entry.pen_width = 1; @@ -150,14 +150,14 @@ ParseTopographyIndexLine(const char *line) noexcept // Parse range for displaying labels entry.label_range = entry.shape_range; - if (*p == _T(',')) { + if (*p == ',') { entry.label_range = strtod(p + 1, &endptr) * 1000; p = endptr; } // Parse range for displaying labels with "important" rendering style entry.important_label_range = 0; - if (*p == _T(',')) { + if (*p == ',') { entry.important_label_range = strtod(p + 1, &endptr) * 1000; p = endptr; } @@ -165,7 +165,7 @@ ParseTopographyIndexLine(const char *line) noexcept // Handle alpha component // If not present at all (i.e. v6.6 or earlier file), default to 100% opaque uint8_t alpha = 255; - if (*p == _T(',')) { + if (*p == ',') { // An alpha component of shading colour is present (v6.7 or later file). alpha = (uint8_t)strtol(p + 1, &endptr, 10); // Ignore a totally transparent file! diff --git a/src/Tracking/LiveTrack24/Settings.hpp b/src/Tracking/LiveTrack24/Settings.hpp index 57ec426ec18..059469249c6 100644 --- a/src/Tracking/LiveTrack24/Settings.hpp +++ b/src/Tracking/LiveTrack24/Settings.hpp @@ -36,7 +36,7 @@ struct Settings { void SetDefaults() { enabled = false; - server = _T("www.livetrack24.com"); + server = "www.livetrack24.com"; username.clear(); password.clear(); diff --git a/src/TransponderCode.cpp b/src/TransponderCode.cpp index 96d5abdce67..bf29934ca4f 100644 --- a/src/TransponderCode.cpp +++ b/src/TransponderCode.cpp @@ -12,7 +12,7 @@ TransponderCode::Format(char *buffer, std::size_t max_size) const noexcept if (!IsDefined()) return nullptr; - StringFormat(buffer, max_size, _T("%04o"), value); + StringFormat(buffer, max_size, "%04o", value); return buffer; } diff --git a/src/UIActions.cpp b/src/UIActions.cpp index 9b10adf1460..7cd8c173953 100644 --- a/src/UIActions.cpp +++ b/src/UIActions.cpp @@ -37,22 +37,22 @@ UIActions::CheckShutdown() switch (UI::TopWindow::GetExitValue()) { #if defined(IS_OPENVARIO) case EXIT_REBOOT: - return ShowMessageBox(_("Reboot System?"), _T("OpenSoar"), + return ShowMessageBox(_("Reboot System?"), "OpenSoar", MB_YESNO | MB_ICONQUESTION) == IDYES; case EXIT_SHUTDOWN: - return ShowMessageBox(_("Shutdown System?"), _T("OpenSoar"), + return ShowMessageBox(_("Shutdown System?"), "OpenSoar", MB_YESNO | MB_ICONQUESTION) == IDYES; case EXIT_NEWSTART: - return ShowMessageBox(_("Quit and Restart OpenSoar?"), _T("OpenSoar"), + return ShowMessageBox(_("Quit and Restart OpenSoar?"), "OpenSoar", MB_YESNO | MB_ICONQUESTION) == IDYES; #endif case EXIT_RESTART: - return ShowMessageBox(_("Short Internal Restart?"), _T("OpenSoar"), + return ShowMessageBox(_("Short Internal Restart?"), "OpenSoar", MB_YESNO | MB_ICONQUESTION) == IDYES; case EXIT_SYSTEM: default: - return ShowMessageBox(_("Quit program?"), _T("OpenSoar"), + return ShowMessageBox(_("Quit program?"), "OpenSoar", MB_YESNO | MB_ICONQUESTION) == IDYES; } } @@ -60,35 +60,35 @@ UIActions::CheckShutdown() void UIActions::ShowTrafficRadar() { - if (InputEvents::IsFlavour(_T("Traffic"))) + if (InputEvents::IsFlavour("Traffic")) return; LoadFlarmDatabases(); CommonInterface::main_window->SetWidget(new TrafficWidget()); - InputEvents::SetFlavour(_T("Traffic")); + InputEvents::SetFlavour("Traffic"); } void UIActions::ShowThermalAssistant() { - if (InputEvents::IsFlavour(_T("TA"))) + if (InputEvents::IsFlavour("TA")) return; auto ta_widget = new BigThermalAssistantWidget(CommonInterface::GetLiveBlackboard(), UIGlobals::GetLook().thermal_assistant_dialog); CommonInterface::main_window->SetWidget(ta_widget); - InputEvents::SetFlavour(_T("TA")); + InputEvents::SetFlavour("TA"); } void UIActions::ShowHorizon() { - if (InputEvents::IsFlavour(_T("Horizon"))) + if (InputEvents::IsFlavour("Horizon")) return; auto widget = new HorizonWidget(); CommonInterface::main_window->SetWidget(widget); - InputEvents::SetFlavour(_T("Horizon")); + InputEvents::SetFlavour("Horizon"); } diff --git a/src/UIUtil/GestureManager.cpp b/src/UIUtil/GestureManager.cpp index 77da6b81bab..a1f0654be35 100644 --- a/src/UIUtil/GestureManager.cpp +++ b/src/UIUtil/GestureManager.cpp @@ -9,15 +9,15 @@ getDirection(int dx, int dy) { if (dy < 0 && -dy >= abs(dx) * 2) - return _T('U'); + return 'U'; if (dy > 0 && dy >= abs(dx) * 2) - return _T('D'); + return 'D'; if (dx > 0 && dx >= abs(dy) * 2) - return _T('R'); + return 'R'; if (dx < 0 && -dx >= abs(dy) * 2) - return _T('L'); + return 'L'; - return _T('\0'); + return '\0'; } bool diff --git a/src/Units/Descriptor.cpp b/src/Units/Descriptor.cpp index 2112f825e10..ab29ee2137b 100644 --- a/src/Units/Descriptor.cpp +++ b/src/Units/Descriptor.cpp @@ -13,33 +13,33 @@ const UnitDescriptor Units::unit_descriptors[] = { { nullptr, 1, 0 }, - { _T("km"), 0.001, 0 }, - { _T("NM"), 0.000539956803, 0 }, - { _T("mi"), 0.000621371192, 0 }, - { _T("km/h"), 3.6, 0 }, - { _T("kt"), 1.94384449, 0 }, - { _T("mph"), 2.23693629, 0 }, - { _T("m/s"), 1, 0 }, - { _T("fpm"), 196.850394, 0 }, - { _T("m"), 1, 0 }, - { _T("ft"), 3.2808399, 0 }, - { _T("FL"), 0.032808399, 0 }, - { _T("K"), 1, 0 }, - { _T(DEG) _T("C"), 1, -CELSIUS_OFFSET }, - { _T(DEG) _T("F"), 1.8, -459.67 }, - { _T("hPa"), 1, 0 }, - { _T("mb"), 1, 0 }, - { _T("mmHg"), 0.7500616827041698, 0 }, - { _T("inHg"), 0.0295287441401431, 0 }, - { _T("kg/m²"), 1, 0 }, - { _T("lb/ft²"), 0.204816144, 0 }, - { _T("kg"), 1, 0 }, - { _T("lb"), 2.20462, 0 }, - { _T("%"), 1, 0 }, - { _T(":1"), 1, 0 }, - { _T("V"), 1, 0 }, - { _T("Hz"), 1, 0 }, - { _T("rpm"), 60, 0 }, + { "km", 0.001, 0 }, + { "NM", 0.000539956803, 0 }, + { "mi", 0.000621371192, 0 }, + { "km/h", 3.6, 0 }, + { "kt", 1.94384449, 0 }, + { "mph", 2.23693629, 0 }, + { "m/s", 1, 0 }, + { "fpm", 196.850394, 0 }, + { "m", 1, 0 }, + { "ft", 3.2808399, 0 }, + { "FL", 0.032808399, 0 }, + { "K", 1, 0 }, + { DEG "C", 1, -CELSIUS_OFFSET }, + { DEG "F", 1.8, -459.67 }, + { "hPa", 1, 0 }, + { "mb", 1, 0 }, + { "mmHg", 0.7500616827041698, 0 }, + { "inHg", 0.0295287441401431, 0 }, + { "kg/m²", 1, 0 }, + { "lb/ft²", 0.204816144, 0 }, + { "kg", 1, 0 }, + { "lb", 2.20462, 0 }, + { "%", 1, 0 }, + { ":1", 1, 0 }, + { "V", 1, 0 }, + { "Hz", 1, 0 }, + { "rpm", 60, 0 }, }; static_assert(ARRAY_SIZE(Units::unit_descriptors) == (size_t)Unit::COUNT, diff --git a/src/Units/UnitsGlue.cpp b/src/Units/UnitsGlue.cpp index a1897a5e8c9..5b21767a7ec 100644 --- a/src/Units/UnitsGlue.cpp +++ b/src/Units/UnitsGlue.cpp @@ -48,9 +48,9 @@ enum { #if !defined(HAVE_POSIX) || defined(ANDROID) const struct language_unit_map language_table[] = { - { MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_UK), _T("en_UK"), 1 }, - { MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), _T("en_US"), 2 }, - { MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_AUS), _T("en_AU"), 3 }, + { MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_UK), "en_UK", 1 }, + { MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), "en_US", 2 }, + { MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_AUS), "en_AU", 3 }, { 0, nullptr, 0 } }; diff --git a/src/VALI-XCS.cpp b/src/VALI-XCS.cpp index 8f3ca7736d1..3d4b7b00604 100644 --- a/src/VALI-XCS.cpp +++ b/src/VALI-XCS.cpp @@ -32,7 +32,7 @@ ValidateXCS(Path path, GRecord &oGRecord) STATUS_t eStatus = eValidationFileNotFound; FILE *inFile = nullptr; - inFile = _tfopen(path.c_str(), _T("r")); + inFile = _tfopen(path.c_str(), "r"); if (inFile == nullptr) return eStatus; diff --git a/src/Version.cpp b/src/Version.cpp index 7ca77bc1707..6522ec436db 100644 --- a/src/Version.cpp +++ b/src/Version.cpp @@ -39,8 +39,8 @@ # define GIT_SUFFIX #endif -const char OpenSoar_Version[] = _T(VERSION); -const char OpenSoar_VersionLong[] = _T(VERSION VERSION_SUFFIX); -const char OpenSoar_VersionString[] = _T(VERSION VERSION_SUFFIX "-" TARGET); -const char OpenSoar_VersionStringOld[] = _T(TARGET " " VERSION VERSION_SUFFIX); -const char OpenSoar_ProductToken[] = _T("OpenSoar v" VERSION VERSION_SUFFIX "-" TARGET GIT_SUFFIX); +const char OpenSoar_Version[] = VERSION; +const char OpenSoar_VersionLong[] = VERSION VERSION_SUFFIX; +const char OpenSoar_VersionString[] = VERSION VERSION_SUFFIX "-" TARGET; +const char OpenSoar_VersionStringOld[] = TARGET " " VERSION VERSION_SUFFIX; +const char OpenSoar_ProductToken[] = "OpenSoar v" VERSION VERSION_SUFFIX "-" TARGET GIT_SUFFIX; diff --git a/src/Waypoint/Patterns.hpp b/src/Waypoint/Patterns.hpp index 383f63af692..f7298724424 100644 --- a/src/Waypoint/Patterns.hpp +++ b/src/Waypoint/Patterns.hpp @@ -5,4 +5,4 @@ #include -#define WAYPOINT_FILE_PATTERNS _T("*.dat\0*.xcw\0*.cup\0*.wpz\0*.wpt\0") +#define WAYPOINT_FILE_PATTERNS "*.dat\0*.xcw\0*.cup\0*.wpz\0*.wpt\0" diff --git a/src/Waypoint/SaveGlue.cpp b/src/Waypoint/SaveGlue.cpp index bc69eecc326..7f9ca026bb8 100644 --- a/src/Waypoint/SaveGlue.cpp +++ b/src/Waypoint/SaveGlue.cpp @@ -12,7 +12,7 @@ void WaypointGlue::SaveWaypoints(const Waypoints &way_points) { - const auto path = LocalPath(_T("user.cup")); + const auto path = LocalPath("user.cup"); FileOutputStream file(path); BufferedOutputStream writer(file); @@ -22,13 +22,13 @@ WaypointGlue::SaveWaypoints(const Waypoints &way_points) writer.Flush(); file.Commit(); - LogFormat(_T("Waypoint file '%s' saved"), path.c_str()); + LogFormat("Waypoint file '%s' saved", path.c_str()); } void WaypointGlue::SaveWaypoint(const Waypoint &wp) { - const auto path = LocalPath(_T("user.cup")); + const auto path = LocalPath("user.cup"); FileOutputStream file(path, FileOutputStream::Mode::APPEND_OR_CREATE); BufferedOutputStream writer(file); diff --git a/src/Waypoint/WaypointFileType.cpp b/src/Waypoint/WaypointFileType.cpp index ebcb92343d8..30c87c9f02a 100644 --- a/src/Waypoint/WaypointFileType.cpp +++ b/src/Waypoint/WaypointFileType.cpp @@ -13,20 +13,20 @@ WaypointFileType DetermineWaypointFileType(Path path) noexcept { // If WinPilot waypoint file -> save type and return true - if (path.EndsWithIgnoreCase(_T(".dat")) || - path.EndsWithIgnoreCase(_T(".xcw"))) + if (path.EndsWithIgnoreCase(".dat") || + path.EndsWithIgnoreCase(".xcw")) return WaypointFileType::WINPILOT; // If SeeYou waypoint file -> save type and return true - if (path.EndsWithIgnoreCase(_T(".cup"))) + if (path.EndsWithIgnoreCase(".cup")) return WaypointFileType::SEEYOU; // If Zander waypoint file -> save type and return true - if (path.EndsWithIgnoreCase(_T(".wpz"))) + if (path.EndsWithIgnoreCase(".wpz")) return WaypointFileType::ZANDER; // If FS waypoint file -> save type and return true - if (path.EndsWithIgnoreCase(_T(".wpt"))) { + if (path.EndsWithIgnoreCase(".wpt")) { try { FileReader r{path}; char buffer[4096]; diff --git a/src/Waypoint/WaypointGlue.cpp b/src/Waypoint/WaypointGlue.cpp index a8f465bcd18..d06e9e0884d 100644 --- a/src/Waypoint/WaypointGlue.cpp +++ b/src/Waypoint/WaypointGlue.cpp @@ -29,7 +29,7 @@ try { progress); return true; } catch (...) { - LogFormat(_T("Failed to read waypoint file: %s"), path.c_str()); + LogFormat("Failed to read waypoint file: %s", path.c_str()); LogError(std::current_exception()); return false; } @@ -45,7 +45,7 @@ try { progress); return true; } catch (...) { - LogFormat(_T("Failed to read waypoint file: %s"), path.c_str()); + LogFormat("Failed to read waypoint file: %s", path.c_str()); LogError(std::current_exception()); return false; } @@ -62,7 +62,7 @@ try { progressg); return true; } catch (...) { - LogFormat(_T("Failed to read waypoint file: %s"), path); + LogFormat("Failed to read waypoint file: %s", path); LogError(std::current_exception()); return false; } @@ -116,7 +116,7 @@ LoadWaypoints(Waypoints &way_points, const RasterTerrain *terrain, } } //Load user.cup - LoadWaypointFile(way_points, LocalPath(_T("user.cup")), + LoadWaypointFile(way_points, LocalPath("user.cup"), WaypointFileType::SEEYOU, WaypointOrigin::USER, terrain, progress); // Optimise the waypoint list after attaching new waypoints diff --git a/src/Waypoint/WaypointReaderFS.cpp b/src/Waypoint/WaypointReaderFS.cpp index 045e6870f87..96d33a838f5 100644 --- a/src/Waypoint/WaypointReaderFS.cpp +++ b/src/Waypoint/WaypointReaderFS.cpp @@ -12,11 +12,11 @@ static bool ParseAngle(const char *src, Angle &angle) noexcept { bool is_positive; - if (src[0] == _T('N') || src[0] == _T('n') || - src[0] == _T('E') || src[0] == _T('e')) + if (src[0] == 'N' || src[0] == 'n' || + src[0] == 'E' || src[0] == 'e') is_positive = true; - else if (src[0] == _T('S') || src[0] == _T('s') || - src[0] == _T('W') || src[0] == _T('w')) + else if (src[0] == 'S' || src[0] == 's' || + src[0] == 'W' || src[0] == 'w') is_positive = false; else return false; @@ -25,17 +25,17 @@ ParseAngle(const char *src, Angle &angle) noexcept src++; long deg = strtol(src, &endptr, 10); - if (endptr == src || *endptr != _T(' ')) + if (endptr == src || *endptr != ' ') return false; src = endptr; long min = strtol(src, &endptr, 10); - if (endptr == src || *endptr != _T(' ')) + if (endptr == src || *endptr != ' ') return false; src = endptr; double sec = strtod(src, &endptr); - if (endptr == src || *endptr != _T(' ')) + if (endptr == src || *endptr != ' ') return false; auto value = deg + (double)min / 60 + sec / 3600; @@ -80,12 +80,12 @@ ParseLocationUTM(const char *src, GeoPoint &p) noexcept src++; long easting = strtol(src, &endptr, 10); - if (endptr == src || *endptr != _T(' ')) + if (endptr == src || *endptr != ' ') return false; src = endptr; long northing = strtol(src, &endptr, 10); - if (endptr == src || *endptr != _T(' ')) + if (endptr == src || *endptr != ' ') return false; UTM u(zone_number, zone_letter, easting, northing); diff --git a/src/Waypoint/WaypointReaderWinPilot.cpp b/src/Waypoint/WaypointReaderWinPilot.cpp index 7382d896934..d96ef60c1c5 100644 --- a/src/Waypoint/WaypointReaderWinPilot.cpp +++ b/src/Waypoint/WaypointReaderWinPilot.cpp @@ -206,7 +206,7 @@ WaypointReaderWinPilot::ParseLine(const char *line, Waypoints &waypoints) return true; // If comment - if (line[0] == _T('*')) { + if (line[0] == '*') { if (first) { first = false; welt2000_format = strstr(line, "WRITTEN BY WELT2000") != nullptr; diff --git a/src/Weather/METARParser.cpp b/src/Weather/METARParser.cpp index 401849e2914..eec81b46595 100644 --- a/src/Weather/METARParser.cpp +++ b/src/Weather/METARParser.cpp @@ -33,9 +33,9 @@ class METARLine { :start(strdup(line)), data(start), end(start + strlen(line)) { // Trim possible = character at the end (End-of-METAR character) - if (start != end && *(end - 1) == _T('=')) { + if (start != end && *(end - 1) == '=') { end--; - *end = _T('\0'); + *end = '\0'; } } @@ -51,9 +51,9 @@ class METARLine { const char *start = data; - auto *seperator = StringFind(data, _T(' ')); + auto *seperator = StringFind(data, ' '); if (seperator != NULL && seperator < end) { - *seperator = _T('\0'); + *seperator = '\0'; data = seperator + 1; } else { data = end; @@ -88,7 +88,7 @@ DetectTimeCodeToken(const char *token) if (strlen(token) != 7) return false; - return token[6] == _T('Z') || token[6] == _T('z'); + return token[6] == 'Z' || token[6] == 'z'; } static bool @@ -122,11 +122,11 @@ DetectWindToken(const char *token) if (length != 8 && length != 7) return false; - if (!StringIsEqualIgnoreCase(token + 5, _T("MPS")) && - !StringIsEqualIgnoreCase(token + 5, _T("KT"))) + if (!StringIsEqualIgnoreCase(token + 5, "MPS") && + !StringIsEqualIgnoreCase(token + 5, "KT")) return false; - bool variable = (StringIsEqualIgnoreCase(token, _T("VRB"), 3)); + bool variable = (StringIsEqualIgnoreCase(token, "VRB", 3)); for (unsigned i = variable ? 3 : 0; i < 5; ++i) if (!IsDigitASCII(token[i])) @@ -141,7 +141,7 @@ ParseWind(const char *token, ParsedMETAR &parsed) assert(DetectWindToken(token)); // variable wind directions - if (StringIsEqualIgnoreCase(token, _T("VRB"), 3)) + if (StringIsEqualIgnoreCase(token, "VRB", 3)) // parsing okay but don't provide wind return true; @@ -153,9 +153,9 @@ ParseWind(const char *token, ParsedMETAR &parsed) unsigned bearing = (int)(wind_code / 100); wind_code -= bearing * 100; - if (StringIsEqualIgnoreCase(endptr, _T("MPS"))) + if (StringIsEqualIgnoreCase(endptr, "MPS")) parsed.wind.norm = wind_code; - else if (StringIsEqualIgnoreCase(endptr, _T("KT"))) + else if (StringIsEqualIgnoreCase(endptr, "KT")) parsed.wind.norm = Units::ToSysUnit(wind_code, Unit::KNOTS); else return false; @@ -169,7 +169,7 @@ ParseWind(const char *token, ParsedMETAR &parsed) static bool DetectCAVOK(const char *token) { - return (strlen(token) == 5 && StringIsEqualIgnoreCase(token, _T("CAVOK"))); + return (strlen(token) == 5 && StringIsEqualIgnoreCase(token, "CAVOK")); } /** Detects a token with exactly 5 digits */ @@ -216,13 +216,13 @@ DetectTemperaturesToken(const char *token) if (IsDigitASCII(token[i])) continue; - if (token[i] == _T('/')) { + if (token[i] == '/') { divider_found = true; minus_possible = true; continue; } - if (minus_possible && (token[i] == _T('M') || token[i] == _T('m'))) + if (minus_possible && (token[i] == 'M' || token[i] == 'm')) continue; return false; @@ -234,7 +234,7 @@ DetectTemperaturesToken(const char *token) static const char * ParseTemperature(const char *token, double &temperature) { - bool negative = (token[0] == _T('M') || token[0] == _T('m')); + bool negative = (token[0] == 'M' || token[0] == 'm'); if (negative) token++; @@ -258,7 +258,7 @@ ParseTemperatures(const char *token, ParsedMETAR &parsed) if ((token = ParseTemperature(token, parsed.temperature)) == NULL) return false; - if (*token != _T('/')) + if (*token != '/') return false; token++; @@ -277,7 +277,7 @@ DetectAdditionalTemperaturesToken(const char *token) if (strlen(token) != 9) return false; - if (token[0] != _T('T') && token[0] != _T('t')) + if (token[0] != 'T' && token[0] != 't') return false; for (unsigned i = 1; i < 9; ++i) { @@ -323,11 +323,11 @@ DetectQNHToken(const char *token) unsigned length = strlen(token); // International style - if (token[0] == _T('Q') || token[0] == _T('q')) + if (token[0] == 'Q' || token[0] == 'q') return length <= 5 && length >= 4; // American style - if (token[0] == _T('A') || token[0] == _T('a')) + if (token[0] == 'A' || token[0] == 'a') return length == 5; return false; @@ -339,7 +339,7 @@ ParseQNH(const char *token, ParsedMETAR &parsed) assert(DetectQNHToken(token)); // International style (hPa) - if (token[0] == _T('Q') || token[0] == _T('q')) { + if (token[0] == 'Q' || token[0] == 'q') { token++; char *endptr; @@ -353,7 +353,7 @@ ParseQNH(const char *token, ParsedMETAR &parsed) } // American style (inHg) - if (token[0] == _T('A') || token[0] == _T('a')) { + if (token[0] == 'A' || token[0] == 'a') { token++; char *endptr; @@ -465,15 +465,15 @@ ParseLocation(const char *buffer, ParsedMETAR &parsed) unsigned lat_min = ParseUnsigned(end, &end, 10); unsigned lat_sec = 0; - if (*end == _T('-')) { + if (*end == '-') { ++end; lat_sec = ParseUnsigned(end, &end, 10); } bool north; - if (*end == _T('N') || *end == _T('n')) + if (*end == 'N' || *end == 'n') north = true; - else if (*end == _T('S') || *end == _T('s')) + else if (*end == 'S' || *end == 's') north = false; else return false; @@ -492,15 +492,15 @@ ParseLocation(const char *buffer, ParsedMETAR &parsed) unsigned lon_min = ParseUnsigned(end, &end, 10); unsigned lon_sec = 0; - if (*end == _T('-')) { + if (*end == '-') { ++end; lon_sec = ParseUnsigned(end, &end, 10); } bool east; - if (*end == _T('E') || *end == _T('e')) + if (*end == 'E' || *end == 'e') east = true; - else if (*end == _T('W') || *end == _T('w')) + else if (*end == 'W' || *end == 'w') east = false; else return false; @@ -530,9 +530,9 @@ METARParser::ParseDecoded(const METAR::ContentString &decoded, const char *start = decoded.c_str(); const char *end = start + strlen(start); - const auto *opening_brace = StringFind(start, _T('(')); - const auto *closing_brace = StringFind(start, _T(')')); - const auto *line_break = StringFind(start, _T('\n')); + const auto *opening_brace = StringFind(start, '('); + const auto *closing_brace = StringFind(start, ')'); + const auto *line_break = StringFind(start, '\n'); if (line_break == NULL || line_break >= end || opening_brace == NULL || opening_brace >= line_break || @@ -540,7 +540,7 @@ METARParser::ParseDecoded(const METAR::ContentString &decoded, return; while (opening_brace >= start && - (*opening_brace == _T('(') || *opening_brace == _T(' '))) + (*opening_brace == '(' || *opening_brace == ' ')) opening_brace--; unsigned name_length = opening_brace - start + 1; @@ -551,7 +551,7 @@ METARParser::ParseDecoded(const METAR::ContentString &decoded, do closing_brace++; - while (*closing_brace == _T(' ')); + while (*closing_brace == ' '); ParseLocation(closing_brace, parsed); } diff --git a/src/Weather/NOAAFormatter.cpp b/src/Weather/NOAAFormatter.cpp index 0a3fc44a433..88cd0bdc3ec 100644 --- a/src/Weather/NOAAFormatter.cpp +++ b/src/Weather/NOAAFormatter.cpp @@ -20,7 +20,7 @@ class NOAALineSplitter NOAALineSplitter(const char *_start):start(_start) {} bool HasNext() const { - return start != NULL && start[0] != _T('\0'); + return start != NULL && start[0] != '\0'; } Range Next() { @@ -29,7 +29,7 @@ class NOAALineSplitter const char *line_start = start; // Search for next line break - const auto *line_break = StringFind(line_start, _T('\n')); + const auto *line_break = StringFind(line_start, '\n'); if (!line_break) { // if no line break was found start = NULL; @@ -57,7 +57,7 @@ FormatDecodedMETARLine(const char *line, unsigned length, { const char *end = line + length; - const char *colon = (const char *)memchr(line, _T(':'), length); + const char *colon = (const char *)memchr(line, ':', length); if (!colon) return false; @@ -66,19 +66,19 @@ FormatDecodedMETARLine(const char *line, unsigned length, return false; const char *value = colon + 1; - while (*value == _T(' ')) + while (*value == ' ') value++; unsigned value_length = end - value; - if (CheckTitle(line, title_length, _T("Wind"))) { + if (CheckTitle(line, title_length, "Wind")) { StaticString<256> buffer; if (!parsed.wind_available) { - buffer.Format(_T("%s: "), _("Wind")); + buffer.Format("%s: ", _("Wind")); buffer.append({value, value_length}); } else { - buffer.Format(_T("%s: %.0f" DEG " %s"), _("Wind"), + buffer.Format("%s: %.0f" DEG " %s", _("Wind"), (double)parsed.wind.bearing.Degrees(), FormatUserWindSpeed(parsed.wind.norm).c_str()); } @@ -87,61 +87,61 @@ FormatDecodedMETARLine(const char *line, unsigned length, return true; } - if (CheckTitle(line, title_length, _T("Temperature"))) { + if (CheckTitle(line, title_length, "Temperature")) { StaticString<256> buffer; if (!parsed.temperatures_available) { - buffer.Format(_T("%s: "), _("Temperature")); + buffer.Format("%s: ", _("Temperature")); buffer.append({value, value_length}); } else { char temperature_buffer[16]; FormatUserTemperature(parsed.temperature, temperature_buffer); - buffer.Format(_T("%s: %s"), _("Temperature"), temperature_buffer); + buffer.Format("%s: %s", _("Temperature"), temperature_buffer); } output += buffer; output += '\n'; return true; } - if (CheckTitle(line, title_length, _T("Dew Point"))) { + if (CheckTitle(line, title_length, "Dew Point")) { StaticString<256> buffer; if (!parsed.temperatures_available) { - buffer.Format(_T("%s: "), _("Dew Point")); + buffer.Format("%s: ", _("Dew Point")); buffer.append({value, value_length}); } else { char temperature_buffer[16]; FormatUserTemperature(parsed.dew_point, temperature_buffer); - buffer.Format(_T("%s: %s"), _("Dew Point"), temperature_buffer); + buffer.Format("%s: %s", _("Dew Point"), temperature_buffer); } output += buffer; output += '\n'; return true; } - if (CheckTitle(line, title_length, _T("Pressure (altimeter)"))) { + if (CheckTitle(line, title_length, "Pressure (altimeter)")) { StaticString<256> buffer; if (!parsed.qnh_available) { - buffer.Format(_T("%s: "), _("Pressure")); + buffer.Format("%s: ", _("Pressure")); buffer.append({value, value_length}); } else { char qnh_buffer[16]; FormatUserPressure(parsed.qnh, qnh_buffer); - buffer.Format(_T("%s: %s"), _("Pressure"), qnh_buffer); + buffer.Format("%s: %s", _("Pressure"), qnh_buffer); } output += buffer; output += '\n'; return true; } - if (CheckTitle(line, title_length, _T("Visibility"))) { + if (CheckTitle(line, title_length, "Visibility")) { StaticString<256> buffer; - buffer.Format(_T("%s: "), _("Visibility")); + buffer.Format("%s: ", _("Visibility")); if (!parsed.visibility_available) { buffer.append({value, value_length}); } else { @@ -156,9 +156,9 @@ FormatDecodedMETARLine(const char *line, unsigned length, return true; } - if (CheckTitle(line, title_length, _T("Sky conditions"))) { + if (CheckTitle(line, title_length, "Sky conditions")) { StaticString<256> buffer; - buffer.Format(_T("%s: "), _("Sky Conditions")); + buffer.Format("%s: ", _("Sky Conditions")); StaticString<64> _value; _value.assign({value, value_length}); @@ -170,9 +170,9 @@ FormatDecodedMETARLine(const char *line, unsigned length, return true; } - if (CheckTitle(line, title_length, _T("Weather"))) { + if (CheckTitle(line, title_length, "Weather")) { StaticString<256> buffer; - buffer.Format(_T("%s: "), _("Weather")); + buffer.Format("%s: ", _("Weather")); StaticString<64> _value; _value.assign({value, value_length}); @@ -188,7 +188,7 @@ FormatDecodedMETARLine(const char *line, unsigned length, title.assign({line, title_length}); StaticString<256> buffer; - buffer.Format(_T("%s: "), gettext(title.c_str())); + buffer.Format("%s: ", gettext(title.c_str())); buffer.append({value, value_length}); output += buffer; @@ -254,11 +254,11 @@ NOAAFormatter::Format(const NOAAStore::Item &station, std::string &output) else output += station.metar.decoded.c_str(); - output += _T("\n\n"); + output += "\n\n"; output += station.metar.content.c_str(); } - output += _T("\n\n"); + output += "\n\n"; if (!station.taf_available) output += _("No TAF available!"); diff --git a/src/Weather/NOAAGlue.cpp b/src/Weather/NOAAGlue.cpp index 95172a9ae2e..d14ce9e03f8 100644 --- a/src/Weather/NOAAGlue.cpp +++ b/src/Weather/NOAAGlue.cpp @@ -14,7 +14,7 @@ NOAAStore::LoadFromString(const char *string) { const char *s = string; while (s != NULL && *s) { - const char *next = strchr(s, _T(',')); + const char *next = strchr(s, ','); if ((next != NULL && next - s == 4) || (next == NULL && strlen(s) == 4)) { char code[5]; std::copy_n(s, 4, code); @@ -44,10 +44,10 @@ NOAAStore::SaveToProfile() for (auto i = begin(), e = end(); i != e; ++i) { const char *code = i->code; p = std::copy_n(code, strlen(code), p); - *p++ = _T(','); + *p++ = ','; } - *p = _T('\0'); + *p = '\0'; Profile::Set(ProfileKeys::WeatherStations, buffer); } diff --git a/src/Weather/PCMet/Images.cpp b/src/Weather/PCMet/Images.cpp index dc449aba0b8..1a7d9774deb 100644 --- a/src/Weather/PCMet/Images.cpp +++ b/src/Weather/PCMet/Images.cpp @@ -19,71 +19,71 @@ #define PCMET_URI "https://www.flugwetter.de" static constexpr PCMet::ImageArea rad_lokal_areas[] = { - { "pro", _T("Prötzel") }, - { "drs", _T("Dresden") }, - { "eis", _T("Eisberg") }, - { "emd", _T("Emden") }, - { "ess", _T("Essen") }, - { "fbg", _T("Feldberg") }, - { "fld", _T("Flechtdorf") }, - { "boo", _T("Boostedt") }, - { "hnr", _T("Hannover") }, - { "mem", _T("Memmingen") }, - { "isn", _T("Isen") }, - { "neu", _T("Neuhaus") }, - { "nhb", _T("Neuheilenbach") }, - { "oft", _T("Offenthal") }, - { "ros", _T("Rostock") }, - { "tur", _T("Türkheim") }, - { "umd", _T("Ummendorf") }, - { "eddb", _T("EDDB") }, - { "eddc", _T("EDDC") }, - { "edde", _T("EDDE") }, - { "eddf", _T("EDDF") }, - { "eddg", _T("EDDG") }, - { "eddh", _T("EDDH") }, - { "eddk", _T("EDDK") }, - { "eddl", _T("EDDL") }, - { "eddm", _T("EDDM") }, - { "eddn", _T("EDDN") }, - { "eddp", _T("EDDP") }, - { "eddr", _T("EDDR") }, - { "edds", _T("EDDS") }, - { "eddt", _T("EDDT") }, - { "eddv", _T("EDDV") }, - { "eddw", _T("EDDW") }, + { "pro", "Prötzel" }, + { "drs", "Dresden" }, + { "eis", "Eisberg" }, + { "emd", "Emden" }, + { "ess", "Essen" }, + { "fbg", "Feldberg" }, + { "fld", "Flechtdorf" }, + { "boo", "Boostedt" }, + { "hnr", "Hannover" }, + { "mem", "Memmingen" }, + { "isn", "Isen" }, + { "neu", "Neuhaus" }, + { "nhb", "Neuheilenbach" }, + { "oft", "Offenthal" }, + { "ros", "Rostock" }, + { "tur", "Türkheim" }, + { "umd", "Ummendorf" }, + { "eddb", "EDDB" }, + { "eddc", "EDDC" }, + { "edde", "EDDE" }, + { "eddf", "EDDF" }, + { "eddg", "EDDG" }, + { "eddh", "EDDH" }, + { "eddk", "EDDK" }, + { "eddl", "EDDL" }, + { "eddm", "EDDM" }, + { "eddn", "EDDN" }, + { "eddp", "EDDP" }, + { "eddr", "EDDR" }, + { "edds", "EDDS" }, + { "eddt", "EDDT" }, + { "eddv", "EDDV" }, + { "eddw", "EDDW" }, { nullptr, nullptr } }; static constexpr PCMet::ImageArea rad_areas[] = { - { "de", _T("Deutschland") }, - { "eu", _T("Europa") }, + { "de", "Deutschland" }, + { "eu", "Europa" }, { nullptr, nullptr } }; static constexpr PCMet::ImageArea sat_areas[] = { - { "vis_hrv_eu", _T("Mitteleuropa HRV") }, - { "ir_rgb_eu", _T("Mitteleuropa RGB") }, - { "ir_108_eu", _T("Mitteleuropa IR") }, - { "vis_hrv_ce", _T("Mitteleuropa HRV") }, - { "ir_rgb_ce", _T("Mitteleuropa RGB") }, - { "ir_108_ce", _T("Mitteleuropa IR") }, - { "vis_hrv_mdl", _T("Deutschland HRV") }, - { "ir_rgb_mdl", _T("Deutschland RGB") }, - { "ir_108_mdl", _T("Deutschland IR") }, - { "vis_hrv_ndl", _T("Deutschland Nord HRV") }, - { "ir_rgb_ndl", _T("Deutschland Nord RGB") }, - { "ir_108_ndl", _T("Deutschland Nord IR") }, - { "vis_hrv_sdl", _T("Deutschland Süd HRV") }, - { "ir_rgb_sdl", _T("Deutschland Süd RGB") }, - { "ir_108_sdl", _T("Deutschland Süd IR") }, + { "vis_hrv_eu", "Mitteleuropa HRV" }, + { "ir_rgb_eu", "Mitteleuropa RGB" }, + { "ir_108_eu", "Mitteleuropa IR" }, + { "vis_hrv_ce", "Mitteleuropa HRV" }, + { "ir_rgb_ce", "Mitteleuropa RGB" }, + { "ir_108_ce", "Mitteleuropa IR" }, + { "vis_hrv_mdl", "Deutschland HRV" }, + { "ir_rgb_mdl", "Deutschland RGB" }, + { "ir_108_mdl", "Deutschland IR" }, + { "vis_hrv_ndl", "Deutschland Nord HRV" }, + { "ir_rgb_ndl", "Deutschland Nord RGB" }, + { "ir_108_ndl", "Deutschland Nord IR" }, + { "vis_hrv_sdl", "Deutschland Süd HRV" }, + { "ir_rgb_sdl", "Deutschland Süd RGB" }, + { "ir_108_sdl", "Deutschland Süd IR" }, { nullptr, nullptr } }; const PCMet::ImageType PCMet::image_types[] = { - { "rad_lokal/einzelstandorte.htm", _T("Lokale RADAR-Bilder"), rad_lokal_areas }, - { "rad/index.htm", _T("RADAR"), rad_areas }, - { "sat/index.htm", _T("Satellitenbilder"), sat_areas }, + { "rad_lokal/einzelstandorte.htm", "Lokale RADAR-Bilder", rad_lokal_areas }, + { "rad/index.htm", "RADAR", rad_areas }, + { "sat/index.htm", "Satellitenbilder", sat_areas }, { nullptr, nullptr, nullptr }, }; @@ -143,7 +143,7 @@ PCMet::DownloadLatestImage(const char *type, const char *area, // TODO: verify file name // TODO: delete the old directory XCSoarData/pc_met? - const auto cache_path = MakeCacheDirectory(_T("pc_met")); + const auto cache_path = MakeCacheDirectory("pc_met"); auto path = AllocatedPath::Build(cache_path, UTF8ToWideConverter(name.c_str())); diff --git a/src/Weather/PCMet/Overlays.cpp b/src/Weather/PCMet/Overlays.cpp index 00a3098716a..88de99f904f 100644 --- a/src/Weather/PCMet/Overlays.cpp +++ b/src/Weather/PCMet/Overlays.cpp @@ -25,7 +25,7 @@ static constexpr const char *type_names[] = { }; static constexpr const char *type_labels[] = { - _T("Vertikal"), + "Vertikal", }; static_assert(ARRAY_SIZE(type_names) == unsigned(PCMet::OverlayInfo::Type::COUNT), @@ -40,8 +40,8 @@ static constexpr const char *area_names[] = { }; static constexpr const char *area_labels[] = { - _T("Nord"), - _T("Süd"), + "Nord", + "Süd", }; static_assert(ARRAY_SIZE(area_names) == unsigned(PCMet::OverlayInfo::Area::COUNT), @@ -54,7 +54,7 @@ static void MakeOverlayLabel(PCMet::OverlayInfo &info) { StaticString<64> label; - label.Format(_T("%s %s %um +%uh"), + label.Format("%s %s %um +%uh", type_labels[unsigned(info.type)], area_labels[unsigned(info.area)], info.level, @@ -83,9 +83,9 @@ FindLatestOverlay(PCMet::OverlayInfo &info) } } visitor(info); - const auto cache_path = MakeCacheDirectory(_T("pc_met")); + const auto cache_path = MakeCacheDirectory("pc_met"); StaticString<256> pattern; - pattern.Format(_T("%s_%s_lv_%06u_p_%03u_*.tiff"), + pattern.Format("%s_%s_lv_%06u_p_%03u_*.tiff", type_names[unsigned(info.type)], area_names[unsigned(info.area)], info.level, info.step); @@ -127,7 +127,7 @@ PCMet::DownloadOverlay(const OverlayInfo &info, BrokenDateTime now_utc, area_names[unsigned(info.area)], info.level, info.step, run); - const auto cache_path = MakeCacheDirectory(_T("pc_met")); + const auto cache_path = MakeCacheDirectory("pc_met"); auto path = AllocatedPath::Build(cache_path, UTF8ToWideConverter(url.c_str() + sizeof(PCMET_FTP))); diff --git a/src/Weather/Rasp/Configured.cpp b/src/Weather/Rasp/Configured.cpp index f19cd84f8a8..f7cd84fc15b 100644 --- a/src/Weather/Rasp/Configured.cpp +++ b/src/Weather/Rasp/Configured.cpp @@ -14,7 +14,7 @@ LoadConfiguredRasp() noexcept if (path == nullptr) /* if no path is configured, attempt to load xcsoar-rasp.dat (XCSoar < 7.29) */ - path = LocalPath(_T(RASP_FILENAME)); + path = LocalPath(RASP_FILENAME); auto rasp = std::make_shared(std::move(path)); rasp->ScanAll(); diff --git a/src/Weather/Rasp/RaspStore.cpp b/src/Weather/Rasp/RaspStore.cpp index 9fdd45bab59..b8181947af6 100644 --- a/src/Weather/Rasp/RaspStore.cpp +++ b/src/Weather/Rasp/RaspStore.cpp @@ -24,52 +24,52 @@ static constexpr RaspStore::MapInfo WeatherDescriptors[] = { { - _T("wstar"), + "wstar", N_("W*"), N_("Average dry thermal updraft strength near mid-BL height. Subtract glider descent rate to get average vario reading for cloudless thermals. Updraft strengths will be stronger than this forecast if convective clouds are present, since cloud condensation adds buoyancy aloft (i.e. this neglects \"cloudsuck\"). W* depends upon both the surface heating and the BL depth."), }, { - _T("wstar_bsratio"), + "wstar_bsratio", N_("W*"), N_("Average dry thermal updraft strength near mid-BL height. Subtract glider descent rate to get average vario reading for cloudless thermals. Updraft strengths will be stronger than this forecast if convective clouds are present, since cloud condensation adds buoyancy aloft (i.e. this neglects \"cloudsuck\"). W* depends upon both the surface heating and the BL depth."), }, { - _T("blwindspd"), + "blwindspd", N_("BL Wind spd"), N_("The speed and direction of the vector-averaged wind in the BL. This prediction can be misleading if there is a large change in wind direction through the BL."), }, { - _T("hbl"), + "hbl", N_("H bl"), N_("Height of the top of the mixing layer, which for thermal convection is the average top of a dry thermal. Over flat terrain, maximum thermalling heights will be lower due to the glider descent rate and other factors. In the presence of clouds (which release additional buoyancy aloft, creating \"cloudsuck\") the updraft top will be above this forecast, but the maximum thermalling height will then be limited by the cloud base. Further, when the mixing results from shear turbulence rather than thermal mixing this parameter is not useful for glider flying. "), }, { - _T("dwcrit"), + "dwcrit", N_("dwcrit"), N_("This parameter estimates the height above ground at which the average dry updraft strength drops below 225 fpm and is expected to give better quantitative numbers for the maximum cloudless thermalling height than the BL Top height, especially when mixing results from vertical wind shear rather than thermals. (Note: the present assumptions tend to underpredict the max. thermalling height for dry consitions.) In the presence of clouds the maximum thermalling height may instead be limited by the cloud base. Being for \"dry\" thermals, this parameter omits the effect of \"cloudsuck\"."), }, { - _T("blcloudpct"), + "blcloudpct", N_("bl cloud"), N_("This parameter provides an additional means of evaluating the formation of clouds within the BL and might be used either in conjunction with or instead of the other cloud prediction parameters. It assumes a very simple relationship between cloud cover percentage and the maximum relative humidity within the BL. The cloud base height is not predicted, but is expected to be below the BL Top height."), }, { - _T("sfctemp"), + "sfctemp", N_("Sfc temp"), N_("The temperature at a height of 2m above ground level. This can be compared to observed surface temperatures as an indication of model simulation accuracy; e.g. if observed surface temperatures are significantly below those forecast, then soaring conditions will be poorer than forecast."), }, { - _T("hwcrit"), + "hwcrit", N_("hwcrit"), N_("This parameter estimates the height at which the average dry updraft strength drops below 225 fpm and is expected to give better quantitative numbers for the maximum cloudless thermalling height than the BL Top height, especially when mixing results from vertical wind shear rather than thermals. (Note: the present assumptions tend to underpredict the max. thermalling height for dry consitions.) In the presence of clouds the maximum thermalling height may instead be limited by the cloud base. Being for \"dry\" thermals, this parameter omits the effect of \"cloudsuck\"."), }, { - _T("wblmaxmin"), + "wblmaxmin", N_("wblmaxmin"), N_("Maximum grid-area-averaged extensive upward or downward motion within the BL as created by horizontal wind convergence. Positive convergence is associated with local small-scale convergence lines. Negative convergence (divergence) produces subsiding vertical motion, creating low-level inversions which limit thermalling heights."), }, { - _T("blcwbase"), + "blcwbase", N_("blcwbase"), nullptr, }, @@ -178,7 +178,7 @@ try { if (!StringEndsWith(name.c_str(), ".jp2")) continue; - MapItem item(_T("")); + MapItem item(""); auto dot = name.find('.'); if (dot == name.npos || dot == 0 || diff --git a/src/Weather/Rasp/RaspStyle.cpp b/src/Weather/Rasp/RaspStyle.cpp index 94443649172..39a3f0bd8d7 100644 --- a/src/Weather/Rasp/RaspStyle.cpp +++ b/src/Weather/Rasp/RaspStyle.cpp @@ -419,65 +419,65 @@ static constexpr ColorRamp rasp_colors_cloudfraction_accumulated[NUM_COLOR_RAMP_ }; const RaspStyle rasp_styles[] = { - { _T("wstar"), rasp_colors[0], + { "wstar", rasp_colors[0], 2, // max range 256*(2**2) = 1024 cm/s = 10 m/s false }, - { _T("wstar_bsratio"), rasp_colors[0], + { "wstar_bsratio", rasp_colors[0], 2, // max range 256*(2**2) = 1024 cm/s = 10 m/s false }, - { _T("blwindspd"), rasp_colors[1], 3, false }, - { _T("hbl"), rasp_colors[2], 4, false }, - { _T("dwcrit"), rasp_colors[2], 4, false }, - { _T("blcloudpct"), rasp_colors[3], 0, true }, - { _T("sfctemp"), rasp_colors[4], 0, false }, - { _T("hwcrit"), rasp_colors[2], 4, false }, - { _T("wblmaxmin"), rasp_colors[5], + { "blwindspd", rasp_colors[1], 3, false }, + { "hbl", rasp_colors[2], 4, false }, + { "dwcrit", rasp_colors[2], 4, false }, + { "blcloudpct", rasp_colors[3], 0, true }, + { "sfctemp", rasp_colors[4], 0, false }, + { "hwcrit", rasp_colors[2], 4, false }, + { "wblmaxmin", rasp_colors[5], 1, // max range 256*(1**2) = 512 cm/s = 5.0 m/s false }, - { _T("blcwbase"), rasp_colors[2], 4, false }, + { "blcwbase", rasp_colors[2], 4, false }, // Thermalmap.info Colorschemes and Rasp file names - { _T("ThermalStrength"), rasp_colors_thermalstrength, 4, false }, - { _T("ThermalHeight"), rasp_colors_thermalheight, 4, false }, - { _T("Convergence"), rasp_colors_verticalspeed, 5, false }, - { _T("Wave_1000m"), rasp_colors_verticalspeed, 5, false }, - { _T("Wave_2000m"), rasp_colors_verticalspeed, 5, false }, - { _T("Wave_3000m"), rasp_colors_verticalspeed, 5, false }, - { _T("Wave_4000m"), rasp_colors_verticalspeed, 5, false }, - { _T("Wave_5000m"), rasp_colors_verticalspeed, 5, false }, - { _T("Wave_6000m"), rasp_colors_verticalspeed, 5, false }, - { _T("Wave_7000m"), rasp_colors_verticalspeed, 5, false }, - { _T("Temperature2m"), rasp_colors_temperature, 4, false }, - { _T("Rain"), rasp_colors_rain, 3, false }, - { _T("PFD_Day_DuoDiscus"), rasp_colors_pfd_ls4, 3, false }, - { _T("PFD_Day_LS4"), rasp_colors_pfd_ls4, 3, false }, - { _T("PFD_Day_K8"), rasp_colors_pfd_ls4, 3, false }, - { _T("Windspeed_10m"), rasp_colors_bl_avg_windspeed, 3, false }, - { _T("Windspeed_500m"), rasp_colors_bl_avg_windspeed, 3, false }, - { _T("Windspeed_1000m"), rasp_colors_bl_avg_windspeed, 3, false }, - { _T("Windspeed_1500m"), rasp_colors_bl_avg_windspeed, 3, false }, - { _T("Windspeed_2000m"), rasp_colors_bl_avg_windspeed, 3, false }, - { _T("Windspeed_2500m"), rasp_colors_bl_avg_windspeed, 3, false }, - { _T("Windspeed_3000m"), rasp_colors_bl_avg_windspeed, 3, false }, - { _T("Windspeed_3500m"), rasp_colors_bl_avg_windspeed, 3, false }, - { _T("Windspeed_4000m"), rasp_colors_bl_avg_windspeed, 3, false }, - { _T("Windspeed_4500m"), rasp_colors_bl_avg_windspeed, 3, false }, - { _T("Windspeed_5000m"), rasp_colors_bl_avg_windspeed, 3, false }, - { _T("Windspeed_5500m"), rasp_colors_bl_avg_windspeed, 3, false }, - { _T("Windspeed_6000m"), rasp_colors_bl_avg_windspeed, 3, false }, - { _T("Windspeed_6500m"), rasp_colors_bl_avg_windspeed, 3, false }, - { _T("Windspeed_7000m"), rasp_colors_bl_avg_windspeed, 3, false }, - { _T("VerticalWindShear"), rasp_colors_bl_avg_windspeed, 3, false }, - { _T("BL_AverageWindSpeed"), rasp_colors_bl_avg_windspeed, 3, false }, - { _T("XCSpeed_LS4"), rasp_colors_xcspeed_ls4, 3, false }, - { _T("XCSpeed_DuoDiscus"), rasp_colors_xcspeed_ls4, 3, false }, - { _T("XCSpeed_K8"), rasp_colors_xcspeed_k8, 3, false }, - { _T("SurfaceHeatFlux"), rasp_colors_surface_heat_flux, 6, false }, - { _T("SeaLevelPressure"), rasp_colors_sealevel_pressure, 7, false }, - { _T("Cloudfraction_Low"), rasp_colors_cloudfraction_low, 4, false }, - { _T("Cloudfraction_Mid"), rasp_colors_cloudfraction_mid, 4, false }, - { _T("Cloudfraction_High"), rasp_colors_cloudfraction_high, 4, false }, - { _T("Cloudfraction_Accumulated"), rasp_colors_cloudfraction_accumulated, 4, false }, + { "ThermalStrength", rasp_colors_thermalstrength, 4, false }, + { "ThermalHeight", rasp_colors_thermalheight, 4, false }, + { "Convergence", rasp_colors_verticalspeed, 5, false }, + { "Wave_1000m", rasp_colors_verticalspeed, 5, false }, + { "Wave_2000m", rasp_colors_verticalspeed, 5, false }, + { "Wave_3000m", rasp_colors_verticalspeed, 5, false }, + { "Wave_4000m", rasp_colors_verticalspeed, 5, false }, + { "Wave_5000m", rasp_colors_verticalspeed, 5, false }, + { "Wave_6000m", rasp_colors_verticalspeed, 5, false }, + { "Wave_7000m", rasp_colors_verticalspeed, 5, false }, + { "Temperature2m", rasp_colors_temperature, 4, false }, + { "Rain", rasp_colors_rain, 3, false }, + { "PFD_Day_DuoDiscus", rasp_colors_pfd_ls4, 3, false }, + { "PFD_Day_LS4", rasp_colors_pfd_ls4, 3, false }, + { "PFD_Day_K8", rasp_colors_pfd_ls4, 3, false }, + { "Windspeed_10m", rasp_colors_bl_avg_windspeed, 3, false }, + { "Windspeed_500m", rasp_colors_bl_avg_windspeed, 3, false }, + { "Windspeed_1000m", rasp_colors_bl_avg_windspeed, 3, false }, + { "Windspeed_1500m", rasp_colors_bl_avg_windspeed, 3, false }, + { "Windspeed_2000m", rasp_colors_bl_avg_windspeed, 3, false }, + { "Windspeed_2500m", rasp_colors_bl_avg_windspeed, 3, false }, + { "Windspeed_3000m", rasp_colors_bl_avg_windspeed, 3, false }, + { "Windspeed_3500m", rasp_colors_bl_avg_windspeed, 3, false }, + { "Windspeed_4000m", rasp_colors_bl_avg_windspeed, 3, false }, + { "Windspeed_4500m", rasp_colors_bl_avg_windspeed, 3, false }, + { "Windspeed_5000m", rasp_colors_bl_avg_windspeed, 3, false }, + { "Windspeed_5500m", rasp_colors_bl_avg_windspeed, 3, false }, + { "Windspeed_6000m", rasp_colors_bl_avg_windspeed, 3, false }, + { "Windspeed_6500m", rasp_colors_bl_avg_windspeed, 3, false }, + { "Windspeed_7000m", rasp_colors_bl_avg_windspeed, 3, false }, + { "VerticalWindShear", rasp_colors_bl_avg_windspeed, 3, false }, + { "BL_AverageWindSpeed", rasp_colors_bl_avg_windspeed, 3, false }, + { "XCSpeed_LS4", rasp_colors_xcspeed_ls4, 3, false }, + { "XCSpeed_DuoDiscus", rasp_colors_xcspeed_ls4, 3, false }, + { "XCSpeed_K8", rasp_colors_xcspeed_k8, 3, false }, + { "SurfaceHeatFlux", rasp_colors_surface_heat_flux, 6, false }, + { "SeaLevelPressure", rasp_colors_sealevel_pressure, 7, false }, + { "Cloudfraction_Low", rasp_colors_cloudfraction_low, 4, false }, + { "Cloudfraction_Mid", rasp_colors_cloudfraction_mid, 4, false }, + { "Cloudfraction_High", rasp_colors_cloudfraction_high, 4, false }, + { "Cloudfraction_Accumulated", rasp_colors_cloudfraction_accumulated, 4, false }, { nullptr, rasp_colors[0], 2, false } }; diff --git a/src/Widget/ArrowPagerWidget.cpp b/src/Widget/ArrowPagerWidget.cpp index b8678104c84..ded14075897 100644 --- a/src/Widget/ArrowPagerWidget.cpp +++ b/src/Widget/ArrowPagerWidget.cpp @@ -111,10 +111,10 @@ ArrowPagerWidget::Prepare(ContainerWindow &parent, style.TabStop(); previous_button.Create(parent, layout.previous_button, style, - std::make_unique(look, _T("<")), + std::make_unique(look, "<"), [this](){ Previous(false); }); next_button.Create(parent, layout.next_button, style, - std::make_unique(look, _T(">")), + std::make_unique(look, ">"), [this](){ Next(false); }); close_button.Create(parent, look, _("Close"), layout.close_button, style, close_callback); diff --git a/src/Widget/KeyboardWidget.cpp b/src/Widget/KeyboardWidget.cpp index 74c354042fd..e03a05a4e1a 100644 --- a/src/Widget/KeyboardWidget.cpp +++ b/src/Widget/KeyboardWidget.cpp @@ -12,30 +12,30 @@ #include static constexpr char keyboard_letters[] = - _T("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"; void KeyboardWidget::Prepare(ContainerWindow &parent, const PixelRect &rc) noexcept { PrepareSize(rc); - char caption[] = _T(" "); + char caption[] = " "; for (const char *i = keyboard_letters; !StringIsEmpty(i); ++i) { caption[0] = *i; AddButton(parent, caption, *i); } - AddButton(parent, _T("Space"), ' '); - AddButton(parent, _T("."), '.'); - AddButton(parent, _T("@"), '@'); - AddButton(parent, _T("-"), '-'); + AddButton(parent, "Space", ' '); + AddButton(parent, ".", '.'); + AddButton(parent, "@", '@'); + AddButton(parent, "-", '-'); if (show_shift_button) { WindowStyle style; style.Hide(); shift_button.Create(parent, { 0, 0, 16, 16 }, style, - std::make_unique(look, _T("v")), + std::make_unique(look, "v"), [this](){ OnShiftClicked(); }); } UpdateShiftState(); @@ -139,7 +139,7 @@ KeyboardWidget::MoveButtonsToRow(const PixelRect &rc, if (StringIsEmpty(buttons)) return; - for (unsigned i = 0; buttons[i] != _T('\0'); i++) { + for (unsigned i = 0; buttons[i] != '\0'; i++) { MoveButton(buttons[i], rc.GetTopLeft() + PixelSize(i * button_size.width + offset, row * button_size.height)); @@ -149,25 +149,25 @@ KeyboardWidget::MoveButtonsToRow(const PixelRect &rc, void KeyboardWidget::MoveButtons(const PixelRect &rc) { - MoveButtonsToRow(rc, _T("1234567890"), 0); - MoveButtonsToRow(rc, _T("QWERTYUIOP"), 1); - MoveButtonsToRow(rc, _T("ASDFGHJKL"), 2, button_size.width / 3); - MoveButtonsToRow(rc, _T("ZXCVBNM@."), 3, button_size.width); + MoveButtonsToRow(rc, "1234567890", 0); + MoveButtonsToRow(rc, "QWERTYUIOP", 1); + MoveButtonsToRow(rc, "ASDFGHJKL", 2, button_size.width / 3); + MoveButtonsToRow(rc, "ZXCVBNM@.", 3, button_size.width); if (IsLandscape(rc)) { - MoveButton(_T('-'), + MoveButton('-', rc.GetTopLeft() + PixelSize{button_size.width * 9, Layout::Scale(160U)}); - MoveButton(_T(' '), + MoveButton(' ', rc.GetTopLeft() + PixelSize{Layout::Scale(80U), Layout::Scale(160U)}); - ResizeButton(_T(' '), {Layout::Scale(93U), Layout::Scale(40U)}); + ResizeButton(' ', {Layout::Scale(93U), Layout::Scale(40U)}); } else { - MoveButton(_T('-'), + MoveButton('-', rc.GetTopLeft() + PixelSize{button_size.width * 8, button_size.height * 4}); - MoveButton(_T(' '), + MoveButton(' ', rc.GetTopLeft() + PixelSize{button_size.width * 2, button_size.height * 4}); - ResizeButton(_T(' '), {button_size.width * 11 / 2, button_size.height}); + ResizeButton(' ', {button_size.width * 11 / 2, button_size.height}); } if (show_shift_button) @@ -207,7 +207,7 @@ void KeyboardWidget::UpdateShiftState() { if (show_shift_button) - shift_button.SetCaption(shift_state ? _T("v") : _T("^")); + shift_button.SetCaption(shift_state ? "v" : "^"); for (unsigned i = 0; i < num_buttons; ++i) { unsigned uch = buttons[i].GetCharacter(); diff --git a/src/Widget/RowFormWidget.cpp b/src/Widget/RowFormWidget.cpp index fe634fceee1..4548ed4280b 100644 --- a/src/Widget/RowFormWidget.cpp +++ b/src/Widget/RowFormWidget.cpp @@ -431,7 +431,7 @@ PixelSize RowFormWidget::GetMinimumSize() const noexcept { const unsigned value_width = - look.text_font.TextSize(_T("Foo Bar Foo Bar")).width; + look.text_font.TextSize("Foo Bar Foo Bar").width; const bool expert = UIGlobals::GetDialogSettings().expert; @@ -451,7 +451,7 @@ PixelSize RowFormWidget::GetMaximumSize() const noexcept { const unsigned value_width = - look.text_font.TextSize(_T("Foo Bar Foo Bar")).width * 2; + look.text_font.TextSize("Foo Bar Foo Bar").width * 2; const unsigned edit_width = vertical ? std::max(GetRecommendedCaptionWidth(), value_width) diff --git a/src/Widget/RowFormWidget.hpp b/src/Widget/RowFormWidget.hpp index a8bb54f8bc1..6fe3bd1cce4 100644 --- a/src/Widget/RowFormWidget.hpp +++ b/src/Widget/RowFormWidget.hpp @@ -528,7 +528,7 @@ class RowFormWidget : public WindowWidget { } void ClearText(unsigned i) noexcept { - SetText(i, _T("")); + SetText(i, ""); } /** @@ -610,7 +610,7 @@ class RowFormWidget : public WindowWidget { * to indicate that there's no valid value currently. */ void ClearValue(unsigned i) noexcept { - GetControl(i).SetText(_T("")); + GetControl(i).SetText(""); } [[gnu::pure]] diff --git a/src/XCSoar.cpp b/src/XCSoar.cpp index 69c80be26ff..99206e94ec1 100644 --- a/src/XCSoar.cpp +++ b/src/XCSoar.cpp @@ -129,7 +129,7 @@ try { InitialiseDataPath(); // Write startup note + version to logfile - LogFormat(_T("Starting XCSoar %s"), XCSoar_ProductToken); + LogFormat("Starting XCSoar %s", XCSoar_ProductToken); // Read options from the command line { diff --git a/src/io/FileOutputStream.cxx b/src/io/FileOutputStream.cxx index b6bcb3493a5..c61b96d6cc2 100644 --- a/src/io/FileOutputStream.cxx +++ b/src/io/FileOutputStream.cxx @@ -64,7 +64,7 @@ FileOutputStream::OpenCreate(bool visible) { if (!visible) { /* attempt to create a temporary file */ - tmp_path = path.WithSuffix(_T(".tmp")); + tmp_path = path.WithSuffix(".tmp"); Delete(tmp_path); handle = CreateFile(tmp_path.c_str(), GENERIC_WRITE, 0, nullptr, diff --git a/src/io/FileTransaction.cpp b/src/io/FileTransaction.cpp index 7c14df06fd9..6a0ba4c3cca 100644 --- a/src/io/FileTransaction.cpp +++ b/src/io/FileTransaction.cpp @@ -14,9 +14,9 @@ MakeTemporaryPath(Path path) noexcept assert(path != nullptr); #ifdef HAVE_POSIX - return path + _T(".tmp"); + return path + ".tmp"; #else - return path.WithSuffix(_T(".tmp")); + return path.WithSuffix(".tmp"); #endif } diff --git a/src/lua/Dialogs.cpp b/src/lua/Dialogs.cpp index 0d686d6a73e..a0d1e9c9d94 100644 --- a/src/lua/Dialogs.cpp +++ b/src/lua/Dialogs.cpp @@ -19,7 +19,7 @@ l_alert(lua_State *L) if (message != nullptr) { const UTF8ToWideConverter c_message(message); if (c_message.IsValid()) - ShowMessageBox(c_message, _T("Lua"), MB_OK|MB_ICONINFORMATION); + ShowMessageBox(c_message, "Lua", MB_OK|MB_ICONINFORMATION); } return 0; @@ -28,7 +28,7 @@ l_alert(lua_State *L) static void DialogCatchCallback(Lua::Error &&error) { - ShowError(std::make_exception_ptr(std::move(error)), _T("Lua")); + ShowError(std::make_exception_ptr(std::move(error)), "Lua"); } void diff --git a/src/lua/Full.cpp b/src/lua/Full.cpp index 2b0764c34f4..8626c0f5cdc 100644 --- a/src/lua/Full.cpp +++ b/src/lua/Full.cpp @@ -51,7 +51,7 @@ Lua::NewFullState() { SetPackagePath(L, - WideToUTF8Converter(LocalPath(_T("lua" DIR_SEPARATOR_S "?.lua")).c_str())); + WideToUTF8Converter(LocalPath("lua" DIR_SEPARATOR_S "?.lua").c_str())); } return L; } diff --git a/src/net/client/WeGlide/UploadIGCFile.cpp b/src/net/client/WeGlide/UploadIGCFile.cpp index 87e816e06aa..7be0841a056 100644 --- a/src/net/client/WeGlide/UploadIGCFile.cpp +++ b/src/net/client/WeGlide/UploadIGCFile.cpp @@ -85,9 +85,9 @@ UploadSuccessDialog(const FlightData &flight_data) noexcept // TODO: Create a real Dialog with fields in 'src/Dialogs/Cloud/weglide'! // With this Dialog insert the possibilty to update/patch the flight // f.e. copilot in double seater, scoring class, short comment and so on - const auto display_string = fmt::format(_T("{}: {}\n{}: {}\n{}: {} ({})\n" - "{}: {} ({})\n{}: {}, {}: {}"), - _T("Flight ID"), flight_data.flight_id, + const auto display_string = fmt::format("{}: {}\n{}: {}\n{}: {} ({})\n" + "{}: {} ({})\n{}: {}, {}: {}", + "Flight ID", flight_data.flight_id, _("Date"), flight_data.scoring_date.c_str(), _("Username"), flight_data.user.name.c_str(), flight_data.user.id, _("Plane"), flight_data.aircraft.name.c_str(), flight_data.aircraft.id, diff --git a/src/system/FileUtil.cpp b/src/system/FileUtil.cpp index 4722766766f..5fa418be80a 100644 --- a/src/system/FileUtil.cpp +++ b/src/system/FileUtil.cpp @@ -64,7 +64,7 @@ Directory::Exists(Path path) noexcept static bool IsDots(const char *str) noexcept { - return StringIsEqual(str, _T(".")) || StringIsEqual(str, _T("..")); + return StringIsEqual(str, ".") || StringIsEqual(str, ".."); } #endif @@ -87,7 +87,7 @@ checkFilter(const char *filename, const char *filter) noexcept static bool ScanFiles(File::Visitor &visitor, Path sPath, - const char* filter = _T("*")) + const char* filter = "*") { char DirPath[MAX_PATH]; char FileName[MAX_PATH]; @@ -99,7 +99,7 @@ ScanFiles(File::Visitor &visitor, Path sPath, DirPath[0] = 0; // "/test/data/something/" - strcat(DirPath, _T(DIR_SEPARATOR_S)); + strcat(DirPath, DIR_SEPARATOR_S); strcpy(FileName, DirPath); // "/test/data/something/*.igc" @@ -149,7 +149,7 @@ ScanFiles(File::Visitor &visitor, Path sPath, static bool ScanDirectories(File::Visitor &visitor, bool recursive, - Path sPath, const char* filter = _T("*")) + Path sPath, const char* filter = "*") { #ifdef HAVE_POSIX DIR *dir = opendir(sPath.c_str()); @@ -164,7 +164,7 @@ ScanDirectories(File::Visitor &visitor, bool recursive, struct dirent *ent; while ((ent = readdir(dir)) != nullptr) { // omit '.', '..' and any other files/directories starting with '.' - if (*ent->d_name == _T('.')) + if (*ent->d_name == '.') continue; strcpy(FileName + FileNameLength, ent->d_name); @@ -207,9 +207,9 @@ ScanDirectories(File::Visitor &visitor, bool recursive, return true; // "test/data/something/" - strcat(DirPath, _T(DIR_SEPARATOR_S)); + strcat(DirPath, DIR_SEPARATOR_S); // "test/data/something/*" - strcat(FileName, _T(DIR_SEPARATOR_S "*")); + strcat(FileName, DIR_SEPARATOR_S "*"); // Find the first file WIN32_FIND_DATA FindFileData; diff --git a/src/system/Path.cpp b/src/system/Path.cpp index 0d657fd3955..260e337ea55 100644 --- a/src/system/Path.cpp +++ b/src/system/Path.cpp @@ -66,9 +66,9 @@ Path::IsBase() const noexcept assert(*this != nullptr); #ifdef _WIN32 - return strpbrk(c_str(), _T("/\\")) == nullptr; + return strpbrk(c_str(), "/\\") == nullptr; #else - return StringFind(c_str(), _T('/')) == nullptr; + return StringFind(c_str(), '/') == nullptr; #endif } @@ -76,9 +76,9 @@ Path::IsBase() const noexcept static Path::const_pointer LastSeparator(Path::const_pointer path) noexcept { - const auto *p = StringFindLast(path, _T('/')); + const auto *p = StringFindLast(path, '/'); #ifdef _WIN32 - const auto *backslash = StringFindLast(path, _T('\\')); + const auto *backslash = StringFindLast(path, '\\'); if (p == nullptr || backslash > p) p = backslash; #endif @@ -93,7 +93,7 @@ Path::GetParent() const noexcept const const_pointer v = c_str(); const const_pointer p = LastSeparator(v); if (p == nullptr || p == v) - return AllocatedPath(_T(".")); + return AllocatedPath("."); return AllocatedPath(v, p); } @@ -149,14 +149,14 @@ Path::GetSuffix() const noexcept assert(!StringIsEmpty(base.c_str())); - return StringFindLast(base.c_str() + 1, _T('.')); + return StringFindLast(base.c_str() + 1, '.'); } AllocatedPath Path::WithSuffix(const_pointer new_suffix) const noexcept { assert(new_suffix != nullptr); - assert(*new_suffix == _T('.')); + assert(*new_suffix == '.'); auto old_suffix = GetSuffix(); return old_suffix != nullptr diff --git a/src/system/PathName.cpp b/src/system/PathName.cpp index 0abb6d32331..86ffd9dc6bb 100644 --- a/src/system/PathName.cpp +++ b/src/system/PathName.cpp @@ -8,9 +8,9 @@ static const char * LastSeparator(const char *path) { - const auto *p = StringFindLast(path, _T('/')); + const auto *p = StringFindLast(path, '/'); #ifdef _WIN32 - const auto *backslash = StringFindLast(path, _T('\\')); + const auto *backslash = StringFindLast(path, '\\'); if (p == nullptr || backslash > p) p = backslash; #endif diff --git a/src/system/Process.cpp b/src/system/Process.cpp index 27871e47a2d..aa827e629a1 100644 --- a/src/system/Process.cpp +++ b/src/system/Process.cpp @@ -27,7 +27,7 @@ #include // static std::filesystem::path output; -// static Path output = Path(_T("")); +// static Path output = Path(""); static Path output; #include @@ -122,7 +122,7 @@ try { #if PROCESS_DEBUG_OUTPUT // def DEBUG_OPENVARIO std::cout << "Start Run with:" << std::endl; if (!output.empty()) - LogFormat(_T("Process.cpp - Run with output: %s"), output.c_str()); + LogFormat("Process.cpp - Run with output: %s", output.c_str()); else LogFormat("Process.cpp - Run w/o output"); #endif diff --git a/src/ui/canvas/custom/Bitmap.cpp b/src/ui/canvas/custom/Bitmap.cpp index 5f202f41676..b9cb59bcadb 100644 --- a/src/ui/canvas/custom/Bitmap.cpp +++ b/src/ui/canvas/custom/Bitmap.cpp @@ -36,11 +36,11 @@ static UncompressedImage DecompressImageFile(Path path) { #ifdef USE_LIBTIFF - if (path.EndsWithIgnoreCase(_T(".tif")) || path.EndsWithIgnoreCase(_T(".tiff"))) + if (path.EndsWithIgnoreCase(".tif") || path.EndsWithIgnoreCase(".tiff")) return LoadTiff(path); #endif - if (path.EndsWithIgnoreCase(_T(".png"))) + if (path.EndsWithIgnoreCase(".png")) return LoadPNG(path); return LoadJPEGFile(path); diff --git a/src/ui/canvas/custom/GeoBitmap.cpp b/src/ui/canvas/custom/GeoBitmap.cpp index 05f26075da5..36a09cc2d03 100644 --- a/src/ui/canvas/custom/GeoBitmap.cpp +++ b/src/ui/canvas/custom/GeoBitmap.cpp @@ -22,8 +22,8 @@ GeoQuadrilateral Bitmap::LoadGeoFile([[maybe_unused]] Path path) { #ifdef USE_GEOTIFF - if (path.EndsWithIgnoreCase(_T(".tif")) || - path.EndsWithIgnoreCase(_T(".tiff"))) { + if (path.EndsWithIgnoreCase(".tif") || + path.EndsWithIgnoreCase(".tiff")) { auto result = LoadGeoTiff(path); if (!Load(std::move(result.first))) throw std::runtime_error("Failed to use geo image file"); diff --git a/src/ui/canvas/custom/LibJPEG.cpp b/src/ui/canvas/custom/LibJPEG.cpp index 2d1a46f7cb0..6d42096dbca 100644 --- a/src/ui/canvas/custom/LibJPEG.cpp +++ b/src/ui/canvas/custom/LibJPEG.cpp @@ -30,7 +30,7 @@ JpegErrorExit(j_common_ptr cinfo) UncompressedImage LoadJPEGFile(Path path) { - FILE *file = _tfopen(path.c_str(), _T("rb")); + FILE *file = _tfopen(path.c_str(), "rb"); if (file == nullptr) return UncompressedImage(); diff --git a/src/ui/canvas/custom/MoreCanvas.cpp b/src/ui/canvas/custom/MoreCanvas.cpp index 12809615018..c53f2d92cc5 100644 --- a/src/ui/canvas/custom/MoreCanvas.cpp +++ b/src/ui/canvas/custom/MoreCanvas.cpp @@ -52,24 +52,24 @@ Canvas::DrawFormattedText(const PixelRect r, const std::string_view text, char *const duplicated = new char[text.size() + 1], *p = duplicated; unsigned lines = 1; for (char ch : text) { - if (ch == _T('\n')) { + if (ch == '\n') { /* explicit line break */ if (++lines > max_lines) break; - ch = _T('\0'); - } else if (ch == _T('\r')) + ch = '\0'; + } else if (ch == '\r') /* skip */ continue; else if ((unsigned)ch < 0x20) /* replace non-printable characters */ - ch = _T(' '); + ch = ' '; *p++ = ch; } - *p = _T('\0'); + *p = '\0'; const size_t len = p - duplicated; // simple wordbreak algorithm. looks for single spaces only, no tabs, @@ -80,10 +80,10 @@ Canvas::DrawFormattedText(const PixelRect r, const std::string_view text, // remove words from behind till line fits or no more space is found while (sz.width > r.GetWidth() && - (p = StringFindLast(duplicated + i, _T(' '))) != nullptr) { + (p = StringFindLast(duplicated + i, ' ')) != nullptr) { if (prev_p) - *prev_p = _T(' '); - *p = _T('\0'); + *prev_p = ' '; + *p = '\0'; prev_p = p; sz = CalcTextSize(duplicated + i); } @@ -104,7 +104,7 @@ Canvas::DrawFormattedText(const PixelRect r, const std::string_view text, ? (r.top + r.bottom - lines * skip) / 2 : r.top; for (size_t i = 0; i < len; i += strlen(duplicated + i) + 1) { - if (duplicated[i] != _T('\0')) { + if (duplicated[i] != '\0') { int x; if (format & (DT_RIGHT | DT_CENTER)) { PixelSize sz = CalcTextSize(duplicated + i); diff --git a/src/ui/canvas/gdi/Canvas.hpp b/src/ui/canvas/gdi/Canvas.hpp index f9a2fb7c242..1a0e1a712ee 100644 --- a/src/ui/canvas/gdi/Canvas.hpp +++ b/src/ui/canvas/gdi/Canvas.hpp @@ -230,7 +230,7 @@ class Canvas { * without the need to create a HBRUSH * Here is no need to use UTF8TextOut - because all strings are empty */ ::SetBkColor(dc, color); - ::ExtTextOut(dc, rc.left, rc.top, ETO_OPAQUE, &rc, _T(""), 0, nullptr); + ::ExtTextOut(dc, rc.left, rc.top, ETO_OPAQUE, &rc, "", 0, nullptr); } void DrawFilledRectangle(const PixelRect &rc, const Color color) { diff --git a/src/ui/control/TerminalWindow.cpp b/src/ui/control/TerminalWindow.cpp index a5d6e849430..ae7d9f6217d 100644 --- a/src/ui/control/TerminalWindow.cpp +++ b/src/ui/control/TerminalWindow.cpp @@ -76,7 +76,7 @@ void TerminalWindow::OnCreate() { PaintWindow::OnCreate(); - cell_size = look.font.TextSize(_T("W")); + cell_size = look.font.TextSize("W"); cursor_x = 0; cursor_y = 0; data.Reset(); diff --git a/src/ui/control/custom/LargeTextWindow.cpp b/src/ui/control/custom/LargeTextWindow.cpp index 78073615bf0..cacb461d6ca 100644 --- a/src/ui/control/custom/LargeTextWindow.cpp +++ b/src/ui/control/custom/LargeTextWindow.cpp @@ -27,7 +27,7 @@ LargeTextWindow::GetRowCount() const { const char *str = value.c_str(); unsigned row_count = 1; - while ((str = StringFind(str, _T('\n'))) != nullptr) { + while ((str = StringFind(str, '\n')) != nullptr) { str++; row_count++; } diff --git a/src/ui/control/gdi/LargeTextWindow.cpp b/src/ui/control/gdi/LargeTextWindow.cpp index 4e4a0057fc4..bb7e828193a 100644 --- a/src/ui/control/gdi/LargeTextWindow.cpp +++ b/src/ui/control/gdi/LargeTextWindow.cpp @@ -27,21 +27,21 @@ LargeTextWindow::SetText(const char *text) const char* p2 = text; char* p3 = buffer; - for (; *p2 != _T('\0'); p2++) { - if (*p2 == _T('\n')) { - *p3 = _T('\r'); + for (; *p2 != '\0'; p2++) { + if (*p2 == '\n') { + *p3 = '\r'; p3++; - *p3 = _T('\r'); + *p3 = '\r'; p3++; - *p3 = _T('\n'); - } else if (*p2 == _T('\r')) { + *p3 = '\n'; + } else if (*p2 == '\r') { continue; } else { *p3 = *p2; } p3++; } - *p3 = _T('\0'); + *p3 = '\0'; ::SetWindowText(hWnd, buffer); } diff --git a/src/ui/window/PaintWindow.hpp b/src/ui/window/PaintWindow.hpp index cb028f42ec5..17c32cbee8c 100644 --- a/src/ui/window/PaintWindow.hpp +++ b/src/ui/window/PaintWindow.hpp @@ -41,7 +41,7 @@ class PaintWindow : public Window { void Create(ContainerWindow &parent, PixelRect rc, const WindowStyle style=WindowStyle()) noexcept { - Create(parent, _T("PaintWindow"), rc, style); + Create(parent, "PaintWindow", rc, style); } #endif /* USE_WINUSER */ diff --git a/src/ui/window/SingleWindow.hpp b/src/ui/window/SingleWindow.hpp index 2293cd71b80..ddb4208cadb 100644 --- a/src/ui/window/SingleWindow.hpp +++ b/src/ui/window/SingleWindow.hpp @@ -20,7 +20,7 @@ struct Event; */ class SingleWindow : public TopWindow { #ifdef USE_WINUSER - static constexpr const char *class_name = _T("XCSoarMain"); + static constexpr const char *class_name = "XCSoarMain"; #endif std::forward_list dialogs; diff --git a/src/ui/window/gdi/Window.cpp b/src/ui/window/gdi/Window.cpp index 42ea5284675..318d093cedc 100644 --- a/src/ui/window/gdi/Window.cpp +++ b/src/ui/window/gdi/Window.cpp @@ -38,7 +38,7 @@ Window::Create(ContainerWindow *parent, const char *cls, const char *text, void Window::CreateMessageWindow() noexcept { - hWnd = ::CreateWindowEx(0, _T("PaintWindow"), nullptr, 0, 0, 0, 0, 0, + hWnd = ::CreateWindowEx(0, "PaintWindow", nullptr, 0, 0, 0, 0, 0, HWND_MESSAGE, nullptr, nullptr, this); assert(hWnd != nullptr); diff --git a/src/unix/tchar.h b/src/unix/tchar.h index 2475a4a0500..1388aee00f8 100644 --- a/src/unix/tchar.h +++ b/src/unix/tchar.h @@ -5,8 +5,8 @@ #ifdef LIBCXX /* libc++ uses "_T" as template argument names; this conflicts with - the macro "_T()" defined below. To work around that problem, - include all relevant libc++ headers before defining _T() */ + the macro "" defined below. To work around that problem, + include all relevant libc++ headers before defining */ #include #endif @@ -17,7 +17,6 @@ #define _ftprintf fprintf #define _vftprintf vfprintf #define _fputts fputs -#define _T(x) x #define _topen open #define _tfopen fopen #define _TEOF EOF diff --git a/src/util/DollarExpand.hpp b/src/util/DollarExpand.hpp index db93b94901f..dd6101e0795 100644 --- a/src/util/DollarExpand.hpp +++ b/src/util/DollarExpand.hpp @@ -22,12 +22,12 @@ DollarExpand(const char *src, std::span dest, std::invocable auto lookup_function) noexcept { while (true) { - auto dollar = StringFind(src, _T("$(")); + auto dollar = StringFind(src, "$("); if (dollar == nullptr) break; auto name_start = dollar + 2; - auto closing = StringFind(name_start, _T(')')); + auto closing = StringFind(name_start, ')'); if (closing == nullptr) break; diff --git a/src/util/EscapeBackslash.cpp b/src/util/EscapeBackslash.cpp index 78f5232860e..d15ace2505e 100644 --- a/src/util/EscapeBackslash.cpp +++ b/src/util/EscapeBackslash.cpp @@ -34,7 +34,7 @@ UnescapeBackslash(std::string_view old_string) noexcept } } - buffer[used++] = _T('\0'); + buffer[used++] = '\0'; return strdup(buffer); } diff --git a/src/util/RadixTree.hpp b/src/util/RadixTree.hpp index 05ad0df2f6c..846d70bd2bb 100644 --- a/src/util/RadixTree.hpp +++ b/src/util/RadixTree.hpp @@ -308,7 +308,7 @@ class RadixTree { node = node->next_sibling) *dest++ = node->label[0u]; - *dest = _T('\0'); + *dest = '\0'; return retval; } @@ -323,7 +323,7 @@ class RadixTree { /* return one character */ dest[0u] = m.node->label[(unsigned)(m.key - prefix)]; - dest[1] = _T('\0'); + dest[1] = '\0'; return dest; } @@ -708,7 +708,7 @@ class RadixTree { Node root; public: - constexpr RadixTree() noexcept:root(_T("")) {} + constexpr RadixTree() noexcept:root("") {} /** * Gets a value for the specified key. Returns the parameter @@ -829,8 +829,8 @@ class RadixTree { */ template void VisitAllPairs(V &visitor) const { - root.VisitValues(_T(""), visitor); - root.VisitAllChildren(_T(""), visitor); + root.VisitValues("", visitor); + root.VisitAllChildren("", visitor); } /** diff --git a/src/util/TruncateString.cpp b/src/util/TruncateString.cpp index e57b167784a..7803ee0079d 100644 --- a/src/util/TruncateString.cpp +++ b/src/util/TruncateString.cpp @@ -20,7 +20,7 @@ CopyTruncateString(char *dest, size_t dest_size, const char *src) size_t copy = std::min(src_length, dest_size - 1); auto *p = std::copy_n(src, copy, dest); - *p = _T('\0'); + *p = '\0'; return CropIncompleteUTF8(dest); } diff --git a/test/src/ContestPrinting.cpp b/test/src/ContestPrinting.cpp index 0e3b9a8dce0..34b4d544803 100644 --- a/test/src/ContestPrinting.cpp +++ b/test/src/ContestPrinting.cpp @@ -14,7 +14,7 @@ PrintHelper::contestmanager_print(const ContestManager &man, const Trace &trace_triangle, const Trace &trace_sprint) { - Directory::Create(Path(_T("output/results"))); + Directory::Create(Path("output/results")); { std::ofstream fs("output/results/res-olc-trace.txt"); diff --git a/test/src/DebugPort.cpp b/test/src/DebugPort.cpp index f9a5c72ae34..00178059507 100644 --- a/test/src/DebugPort.cpp +++ b/test/src/DebugPort.cpp @@ -19,39 +19,39 @@ ParsePortArgs(Args &args) config.path = args.ExpectNextT().c_str(); #ifndef NDEBUG - if (config.path.equals(_T("dump"))) { + if (config.path.equals("dump")) { config = ParsePortArgs(args); config.dump_port = true; return config; } #endif - if (config.path.equals(_T("k6bt"))) { + if (config.path.equals("k6bt")) { config = ParsePortArgs(args); config.k6bt = true; return config; } - if (config.path.equals(_T("pty"))) { + if (config.path.equals("pty")) { config.port_type = DeviceConfig::PortType::PTY; config.path = args.ExpectNextT().c_str(); return config; } - if (config.path.equals(_T("tcp"))) { + if (config.path.equals("tcp")) { config.port_type = DeviceConfig::PortType::TCP_LISTENER; config.tcp_port = atoi(args.ExpectNext()); return config; } - if (config.path.equals(_T("tcp_client"))) { + if (config.path.equals("tcp_client")) { config.port_type = DeviceConfig::PortType::TCP_CLIENT; config.ip_address = args.ExpectNextT().c_str(); config.tcp_port = atoi(args.ExpectNext()); return config; } - if (config.path.equals(_T("udp"))) { + if (config.path.equals("udp")) { config.port_type = DeviceConfig::PortType::UDP_LISTENER; config.tcp_port = atoi(args.ExpectNext()); return config; diff --git a/test/src/DebugReplayNMEA.cpp b/test/src/DebugReplayNMEA.cpp index c316c1e99bd..6b8e25ddcfe 100644 --- a/test/src/DebugReplayNMEA.cpp +++ b/test/src/DebugReplayNMEA.cpp @@ -27,7 +27,7 @@ DebugReplayNMEA::Create(Path input_file, const std::string &driver_name) { const struct DeviceRegister *driver = FindDriverByName(driver_name.c_str()); if (driver == NULL) { - _ftprintf(stderr, _T("No such driver: %s\n"), driver_name.c_str()); + _ftprintf(stderr, "No such driver: %s\n", driver_name.c_str()); return nullptr; } diff --git a/test/src/DownloadFile.cpp b/test/src/DownloadFile.cpp index 11f1ddaf043..7036b37ee8b 100644 --- a/test/src/DownloadFile.cpp +++ b/test/src/DownloadFile.cpp @@ -59,7 +59,7 @@ class MyResponseHandler final : public CurlResponseHandler { static void Download(CurlGlobal &curl, const char *url, Path path) { - FILE *file = path != nullptr ? _tfopen(path.c_str(), _T("wb")) : nullptr; + FILE *file = path != nullptr ? _tfopen(path.c_str(), "wb") : nullptr; MyResponseHandler handler(file); CurlRequest request(curl, url, handler); diff --git a/test/src/DumpFlarmNet.cpp b/test/src/DumpFlarmNet.cpp index a0562be4aa7..7a66b2c5f53 100644 --- a/test/src/DumpFlarmNet.cpp +++ b/test/src/DumpFlarmNet.cpp @@ -19,7 +19,7 @@ int main(int argc, char **argv) for (auto i = database.begin(), end = database.end(); i != end; ++i) { const FlarmNetRecord &record = i->second; - _tprintf(_T("%s\t%s\t%s\t%s\n"), + _tprintf("%s\t%s\t%s\t%s\n", record.id.c_str(), record.pilot.c_str(), record.registration.c_str(), record.callsign.c_str()); } diff --git a/test/src/DumpTaskFile.cpp b/test/src/DumpTaskFile.cpp index 126a21bb4c9..8ce4fb07312 100644 --- a/test/src/DumpTaskFile.cpp +++ b/test/src/DumpTaskFile.cpp @@ -46,7 +46,7 @@ try { }); } else { for (const auto &i : file->GetList()) - _tprintf(_T("task: %s\n"), i.c_str()); + _tprintf("task: %s\n", i.c_str()); } return EXIT_SUCCESS; diff --git a/test/src/FakeMessage.cpp b/test/src/FakeMessage.cpp index 51b6d941720..6e2ba616485 100644 --- a/test/src/FakeMessage.cpp +++ b/test/src/FakeMessage.cpp @@ -9,5 +9,5 @@ void Message::AddMessage(const char *text, [[maybe_unused]] const char *data) noexcept { - _ftprintf(stderr, _T("%s\n"), text); + _ftprintf(stderr, "%s\n", text); } diff --git a/test/src/FakeProfile.cpp b/test/src/FakeProfile.cpp index 95fb25c4d33..6346ee51d38 100644 --- a/test/src/FakeProfile.cpp +++ b/test/src/FakeProfile.cpp @@ -26,7 +26,7 @@ bool Profile::Get([[maybe_unused]] std::string_view key, std::span value) noexcept { - value[0] = _T('\0'); + value[0] = '\0'; return false; } diff --git a/test/src/FlightTable.cpp b/test/src/FlightTable.cpp index 4fca9efdd76..bdabef310b3 100644 --- a/test/src/FlightTable.cpp +++ b/test/src/FlightTable.cpp @@ -36,7 +36,7 @@ class FlightCheck { } void print_flight() { - _tprintf(_T("%s,%04u-%02u-%02u,%02u:%02u,%02u:%02u\n"), name.c_str(), + _tprintf("%s,%04u-%02u-%02u,%02u:%02u,%02u:%02u\n", name.c_str(), year, month, day, takeoff.time.hour, takeoff.time.minute, landing.time.hour, landing.time.minute); @@ -140,7 +140,7 @@ IGCFileVisitor::Visit(Path path, Path filename) int main([[maybe_unused]] int argc, [[maybe_unused]] char **argv) try { IGCFileVisitor visitor; - Directory::VisitSpecificFiles(Path(_T(".")), _T("*.igc"), visitor); + Directory::VisitSpecificFiles(Path("."), "*.igc", visitor); return 0; } catch (...) { PrintException(std::current_exception()); diff --git a/test/src/KeyCodeDumper.cpp b/test/src/KeyCodeDumper.cpp index b6930f3cd81..d055f5fd130 100644 --- a/test/src/KeyCodeDumper.cpp +++ b/test/src/KeyCodeDumper.cpp @@ -83,12 +83,12 @@ class KeyCodeDumper : public PaintWindow { canvas.SetBackgroundTransparent(); canvas.Select(normal_font); - unsigned text_height = canvas.CalcTextSize(_T("W")).height; + unsigned text_height = canvas.CalcTextSize("W").height; for (int i = num_events - 1, y = 4; i >= 0; --i, y += text_height) { const struct key_event &event = events[i]; char buffer[64]; - _stprintf(buffer, _T("key %s = 0x%x"), - event.down ? _T("down") : _T("up"), event.code); + _stprintf(buffer, "key %s = 0x%x", + event.down ? "down" : "up", event.code); canvas.DrawText({4, y}, buffer); } } @@ -102,7 +102,7 @@ class TestWindow final : public UI::SingleWindow { using UI::SingleWindow::SingleWindow; void Create(PixelSize size) { - SingleWindow::Create(_T("KeyCodeDumper"), size); + SingleWindow::Create("KeyCodeDumper", size); PixelRect rc = GetClientRect(); @@ -114,7 +114,7 @@ class TestWindow final : public UI::SingleWindow { button_rc.top = (rc.top + rc.bottom + 1) / 2; close_button.Create(*this, *button_look, - _T("Close"), button_rc, + "Close", button_rc, WindowStyle(), [this](){ Close(); }); diff --git a/test/src/Main.hpp b/test/src/Main.hpp index 13c98104dab..e0c754932ed 100644 --- a/test/src/Main.hpp +++ b/test/src/Main.hpp @@ -162,7 +162,7 @@ class TestMainWindow : public UI::SingleWindow { SingleWindow::OnCreate(); #ifdef ENABLE_CLOSE_BUTTON - close_button.Create(*this, *button_look, _T("Close"), + close_button.Create(*this, *button_look, "Close", GetCloseButtonRect(GetClientRect()), WindowStyle(), [this](){ Close(); }); @@ -287,7 +287,7 @@ WinMain([[maybe_unused]] HINSTANCE hInstance, [[maybe_unused]] HINSTANCE hPrevIn #ifdef ENABLE_MAIN_WINDOW main_window = new TestMainWindow(screen_init.GetDisplay()); - main_window->Create(_T("Test"), window_size); + main_window->Create("Test", window_size); main_window->Show(); #endif diff --git a/test/src/NearestWaypoints.cpp b/test/src/NearestWaypoints.cpp index cd38cac89a4..26a182b5e44 100644 --- a/test/src/NearestWaypoints.cpp +++ b/test/src/NearestWaypoints.cpp @@ -94,7 +94,7 @@ PrintWaypoint(const Waypoint *waypoint) if (!waypoint) printf("\n"); else - _ftprintf(stdout, _T("%f %f %.0f %s\n"), + _ftprintf(stdout, "%f %f %.0f %s\n", (double)waypoint->location.latitude.Degrees(), (double)waypoint->location.longitude.Degrees(), (double)waypoint->GetElevationOrZero(), diff --git a/test/src/Printing.cpp b/test/src/Printing.cpp index 913a7311156..520d1fc0004 100644 --- a/test/src/Printing.cpp +++ b/test/src/Printing.cpp @@ -81,7 +81,7 @@ void PrintHelper::trace_print([[maybe_unused]] const Trace& trace, [[maybe_unused]] const GeoPoint &loc) { - Directory::Create(Path(_T("output/results"))); + Directory::Create(Path("output/results")); std::ofstream fs("output/results/res-trace.txt"); for (auto it = trace.begin(); it != trace.end(); ++it) diff --git a/test/src/RunAnalysis.cpp b/test/src/RunAnalysis.cpp index 8f101c84987..f2637bef6a0 100644 --- a/test/src/RunAnalysis.cpp +++ b/test/src/RunAnalysis.cpp @@ -173,7 +173,7 @@ Main(UI::Display &display) delete replay; UI::SingleWindow main_window{display}; - main_window.Create(_T("RunAnalysis"), + main_window.Create("RunAnalysis", {640, 480}); dlgAnalysisShowModal(main_window, *look, blackboard, glide_computer, diff --git a/test/src/RunAngleEntry.cpp b/test/src/RunAngleEntry.cpp index b440af79d74..4f9a7c2916f 100644 --- a/test/src/RunAngleEntry.cpp +++ b/test/src/RunAngleEntry.cpp @@ -14,7 +14,7 @@ static void Main([[maybe_unused]] TestMainWindow &main_window) { Angle value = Angle::Zero(); - if (!AngleEntryDialog(_T("The caption"), value)) + if (!AngleEntryDialog("The caption", value)) return; printf("%ld\n", lround(value.Degrees())); diff --git a/test/src/RunCanvas.cpp b/test/src/RunCanvas.cpp index f9fae24a6d2..efac95efbd0 100644 --- a/test/src/RunCanvas.cpp +++ b/test/src/RunCanvas.cpp @@ -42,7 +42,7 @@ class TestWindow final : public UI::SingleWindow { using UI::SingleWindow::SingleWindow; void Create(PixelSize size) { - SingleWindow::Create(_T("RunCanvas"), size); + SingleWindow::Create("RunCanvas", size); PixelRect rc = GetClientRect(); @@ -54,7 +54,7 @@ class TestWindow final : public UI::SingleWindow { button_rc.left += 5; button_rc.right = button_rc.left + 65; - buffer_button.Create(*this, *button_look, _T("Buffer"), button_rc, + buffer_button.Create(*this, *button_look, "Buffer", button_rc, WindowStyle(), [this](){ buffered = !buffered; @@ -70,7 +70,7 @@ class TestWindow final : public UI::SingleWindow { button_rc.right = rc.right - 5; button_rc.left = button_rc.right - 65; - close_button.Create(*this, *button_look, _T("Close"), button_rc, + close_button.Create(*this, *button_look, "Close", button_rc, WindowStyle(), [this](){ Close(); }); } @@ -105,7 +105,7 @@ class TestWindow final : public UI::SingleWindow { std::min(width, height) / 3, Angle::Zero(), Angle::Degrees(90), false); - label = _T("segment 0-90 horizon=false"); + label = "segment 0-90 horizon=false"; break; case 1: @@ -113,13 +113,13 @@ class TestWindow final : public UI::SingleWindow { std::min(width, height) / 3, Angle::Degrees(45), Angle::Degrees(180), true); - label = _T("segment 45-180 horizon=true"); + label = "segment 45-180 horizon=true"; break; case 2: canvas.DrawCircle(center, std::min(width, height) / 3); - label = _T("circle"); + label = "circle"; break; case 3: @@ -132,20 +132,20 @@ class TestWindow final : public UI::SingleWindow { button_renderer.DrawButton(canvas, rc, page == 4 ? ButtonState::PRESSED : ButtonState::ENABLED); label = page == 4 - ? _T("button down=true") : _T("button down=false"); + ? "button down=true" : "button down=false"; } break; case 5: canvas.Select(red_brush); canvas.DrawPolygon(p1, 3); - label = _T("big polygon"); + label = "big polygon"; break; case 6: canvas.Select(red_brush); canvas.DrawPolygon(p2, 3); - label = _T("huge polygon"); + label = "huge polygon"; break; default: @@ -158,7 +158,7 @@ class TestWindow final : public UI::SingleWindow { canvas.DrawText({5, 5}, label); #ifndef ENABLE_OPENGL canvas.DrawText({5, 25}, - buffered ? _T("buffered") : _T("not buffered")); + buffered ? "buffered" : "not buffered"); #endif } diff --git a/test/src/RunChartRenderer.cpp b/test/src/RunChartRenderer.cpp index 5b3002ce201..20a75de470b 100644 --- a/test/src/RunChartRenderer.cpp +++ b/test/src/RunChartRenderer.cpp @@ -13,8 +13,8 @@ #include "Renderer/ChartRenderer.hpp" static const char *const chart_names[] = { - _T("Line"), - _T("Line2"), + "Line", + "Line2", }; class ChartWindow : public PaintWindow { @@ -51,8 +51,8 @@ void ChartWindow::DrawChart(ChartRenderer &renderer) { if (chart == 1) { - renderer.SetXLabel(_T("VVV"),_T("m/s")); - renderer.SetYLabel(_T("AAA"),_T("m/s")); + renderer.SetXLabel("VVV","m/s"); + renderer.SetYLabel("AAA","m/s"); } renderer.Begin(); @@ -84,7 +84,7 @@ ChartWindow::DrawChart(ChartRenderer &renderer) renderer.DrawYGrid(20, 20, ChartRenderer::UnitFormat::NUMERIC); - renderer.DrawLabel({50, 50}, _T("hello")); + renderer.DrawLabel({50, 50}, "hello"); } renderer.Finish(); @@ -104,7 +104,7 @@ class TestWindow : public UI::SingleWindow, } void Create(const DialogLook &look, PixelSize size) { - SingleWindow::Create(_T("RunChartRenderer"), size); + SingleWindow::Create("RunChartRenderer", size); const PixelRect rc = GetClientRect(); @@ -127,7 +127,7 @@ class TestWindow : public UI::SingleWindow, PixelRect button_rc = rc; button_rc.right = list_rc.right; button_rc.top = button_rc.bottom - 30; - close_button.Create(*this, *button_look, _T("Close"), button_rc, + close_button.Create(*this, *button_look, "Close", button_rc, WindowStyle(), [this](){ Close(); }); diff --git a/test/src/RunCirclingWind.cpp b/test/src/RunCirclingWind.cpp index 455f162f854..fbb863150fa 100644 --- a/test/src/RunCirclingWind.cpp +++ b/test/src/RunCirclingWind.cpp @@ -46,7 +46,7 @@ int main(int argc, char **argv) char time_buffer[32]; FormatTime(time_buffer, replay->Basic().time); - _tprintf(_T("%s %d %d %g\n"), + _tprintf("%s %d %d %g\n", time_buffer, result.quality, (int)result.wind.bearing.Degrees(), (double)result.wind.norm); diff --git a/test/src/RunDateEntry.cpp b/test/src/RunDateEntry.cpp index 8a777749f3f..b5b717ae204 100644 --- a/test/src/RunDateEntry.cpp +++ b/test/src/RunDateEntry.cpp @@ -14,7 +14,7 @@ static void Main([[maybe_unused]] TestMainWindow &main_window) { auto value = BrokenDate::TodayUTC(); - if (!DateEntryDialog(_T("The caption"), value, true)) + if (!DateEntryDialog("The caption", value, true)) return; if (value.IsPlausible()) diff --git a/test/src/RunDeclare.cpp b/test/src/RunDeclare.cpp index fafcf6f5d41..6798788da63 100644 --- a/test/src/RunDeclare.cpp +++ b/test/src/RunDeclare.cpp @@ -33,13 +33,13 @@ PrintMoreUsage() const struct DeviceRegister *driver; for (unsigned i = 0; (driver = GetDriverByIndex(i)) != NULL; ++i) if (driver->HasPassThrough()) - _ftprintf(stderr, _T("\t%s\n"), driver->name); + _ftprintf(stderr, "\t%s\n", driver->name); fputs("Where DRIVER is one of:\n", stderr); for (unsigned i = 0; (driver = GetDriverByIndex(i)) != NULL; ++i) if (driver->CanDeclare()) - _ftprintf(stderr, _T("\t%s\n"), driver->name); + _ftprintf(stderr, "\t%s\n", driver->name); } bool @@ -117,19 +117,19 @@ try { } LoggerSettings logger_settings; - logger_settings.pilot_name = _T("Foo Bar"); + logger_settings.pilot_name = "Foo Bar"; Plane plane; - plane.registration = _T("D-3003"); - plane.competition_id = _T("33"); - plane.type = _T("Cirrus"); + plane.registration = "D-3003"; + plane.competition_id = "33"; + plane.type = "Cirrus"; Declaration declaration(logger_settings, plane, NULL); - declaration.Append(MakeWaypoint(_T("Bergneustadt"), 488, + declaration.Append(MakeWaypoint("Bergneustadt", 488, 7.7061111111111114, 51.051944444444445)); - declaration.Append(MakeWaypoint(_T("Foo"), 488, 8, 52)); - declaration.Append(MakeWaypoint(_T("Bar"), 488, 7.5, 50)); - declaration.Append(MakeWaypoint(_T("Bergneustadt"), 488, + declaration.Append(MakeWaypoint("Foo", 488, 8, 52)); + declaration.Append(MakeWaypoint("Bar", 488, 7.5, 50)); + declaration.Append(MakeWaypoint("Bergneustadt", 488, 7.7061111111111114, 51.051944444444445)); Device *through_device = NULL; @@ -137,12 +137,12 @@ try { const struct DeviceRegister *through_driver = FindDriverByName(through_name); if (through_driver == NULL) { - _ftprintf(stderr, _T("No such driver: %s\n"), through_name); + _ftprintf(stderr, "No such driver: %s\n", through_name); return EXIT_FAILURE; } if (!through_driver->HasPassThrough()) { - _ftprintf(stderr, _T("Not a pass-through driver: %s\n"), through_name); + _ftprintf(stderr, "Not a pass-through driver: %s\n", through_name); return EXIT_FAILURE; } @@ -154,12 +154,12 @@ try { const struct DeviceRegister *driver = FindDriverByName(driver_name); if (driver == NULL) { - _ftprintf(stderr, _T("No such driver: %s\n"), driver_name); + _ftprintf(stderr, "No such driver: %s\n", driver_name); return EXIT_FAILURE; } if (!driver->CanDeclare()) { - _ftprintf(stderr, _T("Not a logger driver: %s\n"), driver_name); + _ftprintf(stderr, "Not a logger driver: %s\n", driver_name); return EXIT_FAILURE; } @@ -168,7 +168,7 @@ try { assert(device != NULL); if (through_device != NULL && !through_device->EnablePassThrough(env)) { - _ftprintf(stderr, _T("Failed to enable pass-through mode: %s\n"), + _ftprintf(stderr, "Failed to enable pass-through mode: %s\n", through_name); return EXIT_FAILURE; } diff --git a/test/src/RunDeviceDriver.cpp b/test/src/RunDeviceDriver.cpp index 33a7b8452a5..4da28ffb27b 100644 --- a/test/src/RunDeviceDriver.cpp +++ b/test/src/RunDeviceDriver.cpp @@ -177,7 +177,7 @@ int main(int argc, char **argv) driver = FindDriverByName(driver_name.c_str()); if (driver == nullptr) { - _ftprintf(stderr, _T("No such driver: %s\n"), driver_name.c_str()); + _ftprintf(stderr, "No such driver: %s\n", driver_name.c_str()); return 1; } diff --git a/test/src/RunEnableNMEA.cpp b/test/src/RunEnableNMEA.cpp index 86d28ad575e..3808ede03b9 100644 --- a/test/src/RunEnableNMEA.cpp +++ b/test/src/RunEnableNMEA.cpp @@ -26,7 +26,7 @@ PrintMoreUsage() const struct DeviceRegister *driver; for (unsigned i = 0; (driver = GetDriverByIndex(i)) != NULL; ++i) - _ftprintf(stderr, _T("\t%s\n"), driver->name); + _ftprintf(stderr, "\t%s\n", driver->name); } bool @@ -75,7 +75,7 @@ try { const struct DeviceRegister *driver = FindDriverByName(driver_name); if (driver == NULL) { - _ftprintf(stderr, _T("No such driver: %s\n"), driver_name); + _ftprintf(stderr, "No such driver: %s\n", driver_name); return EXIT_FAILURE; } diff --git a/test/src/RunExternalWind.cpp b/test/src/RunExternalWind.cpp index 34867d7eb8e..dfb1bf3879e 100644 --- a/test/src/RunExternalWind.cpp +++ b/test/src/RunExternalWind.cpp @@ -30,7 +30,7 @@ int main(int argc, char **argv) char time_buffer[32]; FormatTime(time_buffer, basic.time); - _tprintf(_T("%s %d %g\n"), + _tprintf("%s %d %g\n", time_buffer, (int)basic.external_wind.bearing.Degrees(), (double)basic.external_wind.norm); diff --git a/test/src/RunFlarmUtils.cpp b/test/src/RunFlarmUtils.cpp index b27b8846738..70f65d959e8 100644 --- a/test/src/RunFlarmUtils.cpp +++ b/test/src/RunFlarmUtils.cpp @@ -26,7 +26,7 @@ ChangePilot(FlarmDevice &flarm, OperationEnvironment &env) while (true) { char old_pilot_name[64]; if (flarm.GetPilot(old_pilot_name, 64, env)) - _tprintf(_T("Old pilot name: \"%s\"\n"), old_pilot_name); + _tprintf("Old pilot name: \"%s\"\n", old_pilot_name); fprintf(stdout, "Please enter the new pilot name:\n"); fprintf(stdout, "> "); @@ -56,7 +56,7 @@ ChangeCoPilot(FlarmDevice &flarm, OperationEnvironment &env) while (true) { char old_copilot_name[64]; if (flarm.GetCoPilot(old_copilot_name, 64, env)) - _tprintf(_T("Old copilot name: \"%s\"\n"), old_copilot_name); + _tprintf("Old copilot name: \"%s\"\n", old_copilot_name); fprintf(stdout, "Please enter the new copilot name:\n"); fprintf(stdout, "> "); @@ -86,7 +86,7 @@ ChangePlaneType(FlarmDevice &flarm, OperationEnvironment &env) while (true) { char old_plane_type[64]; if (flarm.GetPlaneType(old_plane_type, 64, env)) - _tprintf(_T("Old plane type: \"%s\"\n"), old_plane_type); + _tprintf("Old plane type: \"%s\"\n", old_plane_type); fprintf(stdout, "Please enter the new plane type:\n"); fprintf(stdout, "> "); @@ -116,7 +116,7 @@ ChangeRegistration(FlarmDevice &flarm, OperationEnvironment &env) while (true) { char old_registration[64]; if (flarm.GetPlaneRegistration(old_registration, 64, env)) - _tprintf(_T("Old plane registratio: \"%s\"\n"), old_registration); + _tprintf("Old plane registratio: \"%s\"\n", old_registration); fprintf(stdout, "Please enter the new plane registration:\n"); fprintf(stdout, "> "); @@ -146,7 +146,7 @@ ChangeCompetitionId(FlarmDevice &flarm, OperationEnvironment &env) while (true) { char old_id[64]; if (flarm.GetCompetitionId(old_id, 64, env)) - _tprintf(_T("Old competition id: \"%s\"\n"), old_id); + _tprintf("Old competition id: \"%s\"\n", old_id); fprintf(stdout, "Please enter the new competition id:\n"); fprintf(stdout, "> "); @@ -176,7 +176,7 @@ ChangeCompetitionClass(FlarmDevice &flarm, OperationEnvironment &env) while (true) { char old_comp_class[64]; if (flarm.GetCompetitionClass(old_comp_class, 64, env)) - _tprintf(_T("Old competition class: \"%s\"\n"), old_comp_class); + _tprintf("Old competition class: \"%s\"\n", old_comp_class); fprintf(stdout, "Please enter the new competition class:\n"); fprintf(stdout, "> "); diff --git a/test/src/RunFlightListRenderer.cpp b/test/src/RunFlightListRenderer.cpp index 761bdff6c09..a85886aaccc 100644 --- a/test/src/RunFlightListRenderer.cpp +++ b/test/src/RunFlightListRenderer.cpp @@ -45,13 +45,13 @@ class MainWindow final : public UI::SingleWindow using UI::SingleWindow::SingleWindow; void Create(PixelSize size) { - SingleWindow::Create(_T("Test"), size); + SingleWindow::Create("Test", size); WindowStyle style; style.Disable(); const PixelRect rc = GetClientRect(); - close_button.Create(*this, *button_look, _T("Close"), GetButtonRect(rc), + close_button.Create(*this, *button_look, "Close", GetButtonRect(rc), WindowStyle(), [this](){ Close(); }); test_window.Create(*this, rc, style); diff --git a/test/src/RunFlyingComputer.cpp b/test/src/RunFlyingComputer.cpp index 33ddc98f75f..790b5d00d59 100644 --- a/test/src/RunFlyingComputer.cpp +++ b/test/src/RunFlyingComputer.cpp @@ -15,7 +15,7 @@ LogEvent(const char *event, TimeStamp time, const GeoPoint &location) noexcept char time_buffer[32]; FormatTime(time_buffer, time); - _tprintf(_T("%s %s %s\n"), time_buffer, + _tprintf("%s %s %s\n", time_buffer, FormatGeoPoint(location, CoordinateFormat::DDMMSS).c_str(), event); } @@ -35,11 +35,11 @@ int main(int argc, char **argv) const FlyingState &flight = replay->Calculated().flight; if (flight.flying && !last_flying) - LogEvent(_T("take-off"), flight.takeoff_time, flight.takeoff_location); + LogEvent("take-off", flight.takeoff_time, flight.takeoff_location); else if (!flight.flying && last_flying) - LogEvent(_T("landing"), flight.landing_time, flight.landing_location); + LogEvent("landing", flight.landing_time, flight.landing_location); else if (flight.release_time.IsDefined() && !last_released) - LogEvent(_T("release"), flight.release_time, flight.release_location); + LogEvent("release", flight.release_time, flight.release_location); last_flying = flight.flying; last_released = flight.release_time.IsDefined(); @@ -47,7 +47,7 @@ int main(int argc, char **argv) const FlyingState &flight = replay->Calculated().flight; if (flight.far_distance >= 0) - _tprintf(_T("far %u km at %s\n"), unsigned(flight.far_distance / 1000), + _tprintf("far %u km at %s\n", unsigned(flight.far_distance / 1000), FormatGeoPoint(flight.far_location, CoordinateFormat::DDMMSS).c_str()); diff --git a/test/src/RunGeoPointEntry.cpp b/test/src/RunGeoPointEntry.cpp index 3153434d5fd..5ced25e8f13 100644 --- a/test/src/RunGeoPointEntry.cpp +++ b/test/src/RunGeoPointEntry.cpp @@ -20,11 +20,11 @@ Main([[maybe_unused]] TestMainWindow &main_window) GeoPoint value = GeoPoint(Angle::Degrees(7.7061111111111114), Angle::Degrees(51.051944444444445)); - if (!GeoPointEntryDialog(_T("The caption"), value, format, true)) + if (!GeoPointEntryDialog("The caption", value, format, true)) return; if (value.IsValid()) - _tprintf(_T("%s\n"), + _tprintf("%s\n", FormatGeoPoint(value, CoordinateFormat::DDMMSS).c_str()); else printf("invalid\n"); diff --git a/test/src/RunIGCWriter.cpp b/test/src/RunIGCWriter.cpp index 77f491edac9..7be87562c39 100644 --- a/test/src/RunIGCWriter.cpp +++ b/test/src/RunIGCWriter.cpp @@ -23,12 +23,12 @@ int main(int argc, char **argv) if (!replay->Next()) return 0; - const char *driver_name = _T("Unknown"); + const char *driver_name = "Unknown"; IGCWriter writer(output_file); - writer.WriteHeader(replay->Basic().date_time_utc, _T("Manfred Mustermann"), _T("Manuela Mustermann"), - _T("Ventus"), _T("D-1234"), - _T("MM"), "FOO", driver_name, true); + writer.WriteHeader(replay->Basic().date_time_utc, "Manfred Mustermann", "Manuela Mustermann", + "Ventus", "D-1234", + "MM", "FOO", driver_name, true); GPSClock log_clock; while (replay->Next()) diff --git a/test/src/RunInputParser.cpp b/test/src/RunInputParser.cpp index b099104a2fe..a6326cad085 100644 --- a/test/src/RunInputParser.cpp +++ b/test/src/RunInputParser.cpp @@ -39,7 +39,7 @@ InputEvents::findNE([[maybe_unused]] const char *data) static void Dump(InputConfig::Event &event, unsigned id) { - _tprintf(_T(" Event[%u]: '%s' misc='%s'\n"), id, + _tprintf(" Event[%u]: '%s' misc='%s'\n", id, (const char *)event.event, event.misc); } @@ -59,7 +59,7 @@ try { } for (unsigned mode = 0; mode < config.modes.size(); ++mode) { - _tprintf(_T("Mode '%s'\n"), config.modes[mode].c_str()); + _tprintf("Mode '%s'\n", config.modes[mode].c_str()); for (unsigned key = 0; key < InputConfig::MAX_KEY; ++key) { unsigned event = config.Key2Event[mode][key]; @@ -78,7 +78,7 @@ try { for (unsigned i = 0; i < Menu::MAX_ITEMS; ++i) { const MenuItem &mi = config.menus[mode][i]; if (mi.IsDefined()) { - _tprintf(_T(" Menu[%u] = '%s'\n"), i, mi.label); + _tprintf(" Menu[%u] = '%s'\n", i, mi.label); unsigned event = mi.event; assert(event < InputConfig::MAX_EVENTS); do { diff --git a/test/src/RunJobDialog.cpp b/test/src/RunJobDialog.cpp index 9fa90a20d47..a9a06be7634 100644 --- a/test/src/RunJobDialog.cpp +++ b/test/src/RunJobDialog.cpp @@ -12,7 +12,7 @@ class TestJob : public Job { public: virtual void Run(OperationEnvironment &env) { - env.SetText(_T("Working...")); + env.SetText("Working..."); env.SetProgressRange(30); for (unsigned i = 0; i < 30 && !env.IsCancelled(); ++i) { env.SetProgressPosition(i); @@ -25,5 +25,5 @@ static void Main(TestMainWindow &main_window) { TestJob job; - JobDialog(main_window, *dialog_look, _T("RunJobDialog"), job); + JobDialog(main_window, *dialog_look, "RunJobDialog", job); } diff --git a/test/src/RunListControl.cpp b/test/src/RunListControl.cpp index 5946b7adfe6..d7bb9fa5d36 100644 --- a/test/src/RunListControl.cpp +++ b/test/src/RunListControl.cpp @@ -13,7 +13,7 @@ static void PaintItemCallback(Canvas &canvas, const PixelRect rc, unsigned idx) { char text[32]; - _stprintf(text, _T("%u"), idx); + _stprintf(text, "%u", idx); canvas.DrawText(rc.WithPadding(2).GetTopLeft(), text); } @@ -21,7 +21,7 @@ static void Main(TestMainWindow &main_window) { WndForm form(*dialog_look); - form.Create(main_window, _T("RunListControl")); + form.Create(main_window, "RunListControl"); ContainerWindow &client_area = form.GetClientAreaWindow(); PixelRect list_rc = client_area.GetClientRect(); diff --git a/test/src/RunLiveTrack24.cpp b/test/src/RunLiveTrack24.cpp index 6a5fec2ebd4..cf759f86f15 100644 --- a/test/src/RunLiveTrack24.cpp +++ b/test/src/RunLiveTrack24.cpp @@ -32,12 +32,12 @@ TestTracking(int argc, char *argv[], LiveTrack24::Client &client) UserID user_id; std::string username, password; if (args.IsEmpty()) { - username = _T(""); - password = _T(""); + username = ""; + password = ""; has_user_id = false; } else { username = args.ExpectNextT(); - password = args.IsEmpty() ? _T("") : args.ExpectNextT(); + password = args.IsEmpty() ? "" : args.ExpectNextT(); user_id = co_await client.GetUserID(username.c_str(), password.c_str()); has_user_id = (user_id != 0); @@ -51,7 +51,7 @@ TestTracking(int argc, char *argv[], LiveTrack24::Client &client) printf("Starting tracking ... "); co_await client.StartTracking(session, username.c_str(), password.c_str(), 10, - VehicleType::GLIDER, _T("Hornet")); + VehicleType::GLIDER, "Hornet"); printf("done\n"); BrokenDate now = BrokenDate::TodayUTC(); @@ -90,7 +90,7 @@ try { Instance instance; Client client{*Net::curl}; - client.SetServer(_T("www.livetrack24.com")); + client.SetServer("www.livetrack24.com"); instance.Run(TestTracking(argc, argv, client)); return EXIT_SUCCESS; } catch (...) { diff --git a/test/src/RunNOAADownloader.cpp b/test/src/RunNOAADownloader.cpp index 76b706f1df6..bd57ad0df77 100644 --- a/test/src/RunNOAADownloader.cpp +++ b/test/src/RunNOAADownloader.cpp @@ -40,41 +40,41 @@ DisplayParsedMETAR(const NOAAStore::Item &station) printf("Parsed Data:\n"); if (parsed.name_available) - _tprintf(_T("Name: %s\n"), parsed.name.c_str()); + _tprintf("Name: %s\n", parsed.name.c_str()); if (parsed.location_available) - _tprintf(_T("Location: %s\n"), + _tprintf("Location: %s\n", FormatGeoPoint(parsed.location, CoordinateFormat::DDMMSS).c_str()); if (parsed.qnh_available) { char buffer[256]; FormatUserPressure(parsed.qnh, buffer); - _tprintf(_T("QNH: %s\n"), buffer); + _tprintf("QNH: %s\n", buffer); } if (parsed.wind_available) { char buffer[256]; FormatUserWindSpeed(parsed.wind.norm, buffer); - _tprintf(_T("Wind: %.0f" DEG " %s\n"), + _tprintf("Wind: %.0f" DEG " %s\n", (double)parsed.wind.bearing.Degrees(), buffer); } if (parsed.temperatures_available) { char buffer[256]; FormatUserTemperature(parsed.temperature, buffer); - _tprintf(_T("Temperature: %s\n"), buffer); + _tprintf("Temperature: %s\n", buffer); FormatUserTemperature(parsed.dew_point, buffer); - _tprintf(_T("Dew point: %s\n"), buffer); + _tprintf("Dew point: %s\n", buffer); } if (parsed.visibility_available) { char buffer[256]; if (parsed.visibility >= 9999) - strcpy(buffer, _T("unlimited")); + strcpy(buffer, "unlimited"); else { FormatUserDistanceSmart(parsed.visibility, buffer); } - _tprintf(_T("Visibility: %s\n"), buffer); + _tprintf("Visibility: %s\n", buffer); } printf("\n"); @@ -99,10 +99,10 @@ DisplayMETAR(const NOAAStore::Item &station) (unsigned)metar.last_update.second); if (!metar.content.empty()) - _tprintf(_T("%s\n\n"), metar.content.c_str()); + _tprintf("%s\n\n", metar.content.c_str()); if (!metar.decoded.empty()) - _tprintf(_T("%s\n\n"), metar.decoded.c_str()); + _tprintf("%s\n\n", metar.decoded.c_str()); DisplayParsedMETAR(station); } @@ -126,7 +126,7 @@ DisplayTAF(const NOAAStore::Item &station) (unsigned)taf.last_update.second); if (!taf.content.empty()) - _tprintf(_T("%s\n\n"), taf.content.c_str()); + _tprintf("%s\n\n", taf.content.c_str()); } int diff --git a/test/src/RunNumberEntry.cpp b/test/src/RunNumberEntry.cpp index 67be01ed20c..b570f94c5bd 100644 --- a/test/src/RunNumberEntry.cpp +++ b/test/src/RunNumberEntry.cpp @@ -13,6 +13,6 @@ static void Main([[maybe_unused]] TestMainWindow &main_window) { unsigned value; - if (NumberEntryDialog(_T("The caption"), value, 6)) + if (NumberEntryDialog("The caption", value, 6)) printf("%u\n", value); } diff --git a/test/src/RunProgressWindow.cpp b/test/src/RunProgressWindow.cpp index 7e0a1ba2d77..76f3b2b009f 100644 --- a/test/src/RunProgressWindow.cpp +++ b/test/src/RunProgressWindow.cpp @@ -11,7 +11,7 @@ static void Main(TestMainWindow &main_window) { ProgressWindow progress(main_window); - progress.SetMessage(_T("Testing...")); + progress.SetMessage("Testing..."); progress.SetRange(0, 1024); progress.SetValue(768); diff --git a/test/src/RunRenderOZ.cpp b/test/src/RunRenderOZ.cpp index cc45a9fa931..c5e5b5e6238 100644 --- a/test/src/RunRenderOZ.cpp +++ b/test/src/RunRenderOZ.cpp @@ -30,18 +30,18 @@ enum { }; static const char *const oz_type_names[NUM_OZ_TYPES] = { - _T("Line"), - _T("Cylinder"), - _T("MAT Cylinder"), - _T("Sector"), - _T("FAI Sector"), - _T("DAeC Keyhole"), - _T("BGA Fixed Course"), - _T("BGA Enhanced Option"), - _T("BGA Start"), - _T("Annular sector"), - _T("Symmetric quadrant"), - _T("Custom Keyhole"), + "Line", + "Cylinder", + "MAT Cylinder", + "Sector", + "FAI Sector", + "DAeC Keyhole", + "BGA Fixed Course", + "BGA Enhanced Option", + "BGA Start", + "Annular sector", + "Symmetric quadrant", + "Custom Keyhole", }; static GeoPoint location(Angle::Degrees(7.7061111111111114), @@ -188,7 +188,7 @@ class TestWindow : public UI::SingleWindow, } void Create(const DialogLook &look, PixelSize size) { - SingleWindow::Create(_T("RunRenderOZ"), size); + SingleWindow::Create("RunRenderOZ", size); const PixelRect rc = GetClientRect(); @@ -211,7 +211,7 @@ class TestWindow : public UI::SingleWindow, PixelRect button_rc = rc; button_rc.right = (rc.left + rc.right) / 2; button_rc.top = button_rc.bottom - 30; - close_button.Create(*this, *button_look, _T("Close"), button_rc, + close_button.Create(*this, *button_look, "Close", button_rc, WindowStyle(), [this](){ Close(); }); diff --git a/test/src/RunTaskEditorDialog.cpp b/test/src/RunTaskEditorDialog.cpp index 54f499302c3..c2ce4202371 100644 --- a/test/src/RunTaskEditorDialog.cpp +++ b/test/src/RunTaskEditorDialog.cpp @@ -65,7 +65,7 @@ LoadFiles() static void CreateDefaultTask(TaskManager &task_manager, const Waypoints &way_points) { - const char start_name[] = _T("Bergneustadt"); + const char start_name[] = "Bergneustadt"; task_manager.set_factory(OrderedTask::FactoryType::MIXED); AbstractTaskFactory &factory = task_manager.GetFactory(); @@ -83,7 +83,7 @@ CreateDefaultTask(TaskManager &task_manager, const Waypoints &way_points) fprintf(stderr, "No start waypoint\n"); } - wp = way_points.lookup_name(_T("Uslar")); + wp = way_points.lookup_name("Uslar"); if (wp != NULL) { tp = factory.createIntermediate(AbstractTaskFactory::AST_CYLINDER, *wp); if (!factory.append(tp, false)) { @@ -93,7 +93,7 @@ CreateDefaultTask(TaskManager &task_manager, const Waypoints &way_points) fprintf(stderr, "No turn point\n"); } - wp = way_points.lookup_name(_T("Suhl Goldlaut")); + wp = way_points.lookup_name("Suhl Goldlaut"); if (wp != NULL) { tp = factory.createIntermediate(AbstractTaskFactory::AST_CYLINDER, *wp); if (!factory.append(tp, false)) { @@ -131,7 +131,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, CreateDefaultTask(task_manager, way_points); SingleWindow main_window; - main_window.set(_T("STATIC"), _T("RunTaskEditorDialog"), + main_window.set("STATIC", "RunTaskEditorDialog", 0, 0, 640, 480); main_window.Show(); diff --git a/test/src/RunTerminal.cpp b/test/src/RunTerminal.cpp index f104238db8d..48ca1da4b81 100644 --- a/test/src/RunTerminal.cpp +++ b/test/src/RunTerminal.cpp @@ -19,7 +19,7 @@ class TestWindow : public UI::SingleWindow { :UI::SingleWindow(display), terminal(look) {} void Create(PixelSize size) { - SingleWindow::Create(_T("RunTerminal"), size); + SingleWindow::Create("RunTerminal", size); PixelRect rc = GetClientRect(); diff --git a/test/src/RunTextEntry.cpp b/test/src/RunTextEntry.cpp index edf48ce7080..6fd4fcc2787 100644 --- a/test/src/RunTextEntry.cpp +++ b/test/src/RunTextEntry.cpp @@ -13,6 +13,6 @@ static void Main([[maybe_unused]] TestMainWindow &main_window) { - char text[64] = _T(""); - TextEntryDialog(text, ARRAY_SIZE(text), _T("The caption")); + char text[64] = ""; + TextEntryDialog(text, ARRAY_SIZE(text), "The caption"); } diff --git a/test/src/RunTimeEntry.cpp b/test/src/RunTimeEntry.cpp index 3d08070430a..56e95a6bc7c 100644 --- a/test/src/RunTimeEntry.cpp +++ b/test/src/RunTimeEntry.cpp @@ -15,7 +15,7 @@ Main([[maybe_unused]] TestMainWindow &main_window) { RoughTime value = RoughTime::Invalid(); const RoughTimeDelta time_zone = RoughTimeDelta::FromMinutes(0); - if (!TimeEntryDialog(_T("The caption"), value, time_zone, true)) + if (!TimeEntryDialog("The caption", value, time_zone, true)) return; if (value.IsValid()) diff --git a/test/src/RunWaveComputer.cpp b/test/src/RunWaveComputer.cpp index 0ed640d5292..455fc7e53f0 100644 --- a/test/src/RunWaveComputer.cpp +++ b/test/src/RunWaveComputer.cpp @@ -43,9 +43,9 @@ int main(int argc, char **argv) if (w.time.IsDefined()) FormatTime(time_buffer, w.time); else - strcpy(time_buffer, _T("?")); + strcpy(time_buffer, "?"); - _tprintf(_T("wave: t=%s location=%f,%f a=%f,%f b=%f,%f location=%s normal=%f\n"), + _tprintf("wave: t=%s location=%f,%f a=%f,%f b=%f,%f location=%s normal=%f\n", time_buffer, (double)w.location.longitude.Degrees(), (double)w.location.latitude.Degrees(), diff --git a/test/src/RunWaypointParser.cpp b/test/src/RunWaypointParser.cpp index 5dde0434b3a..550ca10438e 100644 --- a/test/src/RunWaypointParser.cpp +++ b/test/src/RunWaypointParser.cpp @@ -27,16 +27,16 @@ try { way_points.Optimise(); printf("Size %d\n", way_points.size()); - way_points.VisitNamePrefix(_T(""), [](const auto &p){ + way_points.VisitNamePrefix("", [](const auto &p){ const auto &wp = *p; - _ftprintf(stdout, _T("%s, %f, %f, "), wp.name.c_str(), + _ftprintf(stdout, "%s, %f, %f, ", wp.name.c_str(), wp.location.latitude.Degrees(), wp.location.longitude.Degrees()); if (wp.has_elevation) - _ftprintf(stdout, _T("%.0fm\n"), wp.elevation); + _ftprintf(stdout, "%.0fm\n", wp.elevation); else - _ftprintf(stdout, _T("?\n")); + _ftprintf(stdout, "?\n"); }); return EXIT_SUCCESS; diff --git a/test/src/RunWindComputer.cpp b/test/src/RunWindComputer.cpp index 69ab77c042c..7704f87cd08 100644 --- a/test/src/RunWindComputer.cpp +++ b/test/src/RunWindComputer.cpp @@ -55,7 +55,7 @@ int main(int argc, char **argv) char time_buffer[32]; FormatTime(time_buffer, replay->Basic().time); - _tprintf(_T("%s %d %g\n"), + _tprintf("%s %d %g\n", time_buffer, (int)calculated.estimated_wind.bearing.Degrees(), (double)calculated.estimated_wind.norm); } diff --git a/test/src/RunWindEKF.cpp b/test/src/RunWindEKF.cpp index 20e36b99997..e6f3d279804 100644 --- a/test/src/RunWindEKF.cpp +++ b/test/src/RunWindEKF.cpp @@ -43,7 +43,7 @@ int main(int argc, char **argv) char time_buffer[32]; FormatTime(time_buffer, data.time); - _tprintf(_T("%s %d %g %g %g %d\n"), time_buffer, + _tprintf("%s %d %g %g %g %d\n", time_buffer, (int)result.wind.bearing.Degrees(), (double)result.wind.norm, (double)data.ground_speed, diff --git a/test/src/TaskInfo.cpp b/test/src/TaskInfo.cpp index a0883ab493f..f6b7815e567 100644 --- a/test/src/TaskInfo.cpp +++ b/test/src/TaskInfo.cpp @@ -61,7 +61,7 @@ try { if (task != NULL) { Print(*task); } else { - _ftprintf(stderr, _T("Failed to load %s\n"), path.c_str()); + _ftprintf(stderr, "Failed to load %s\n", path.c_str()); result = EXIT_FAILURE; } diff --git a/test/src/TaskPrinting.cpp b/test/src/TaskPrinting.cpp index 897bfdf68ae..fd5d46e336a 100644 --- a/test/src/TaskPrinting.cpp +++ b/test/src/TaskPrinting.cpp @@ -219,7 +219,7 @@ void PrintHelper::abstracttask_print(const AbstractTask &task, [[maybe_unused]] const AircraftState &state) { - Directory::Create(Path(_T("output/results"))); + Directory::Create(Path("output/results")); std::ofstream fs("output/results/res-stats-all.txt"); const auto &stats = task.GetStats(); diff --git a/test/src/TestAirspaceParser.cpp b/test/src/TestAirspaceParser.cpp index 932c0a95d66..20cc634e8aa 100644 --- a/test/src/TestAirspaceParser.cpp +++ b/test/src/TestAirspaceParser.cpp @@ -44,34 +44,34 @@ static void TestOpenAir() { Airspaces airspaces; - if (!ParseFile(Path(_T("test/data/airspace/openair.txt")), airspaces)) { + if (!ParseFile(Path("test/data/airspace/openair.txt"), airspaces)) { skip(3, 0, "Failed to parse input file"); return; } static constexpr AirspaceClassTestCouple classes[] = { - { _T("Class-R-Test"), RESTRICT }, - { _T("Class-Q-Test"), DANGER }, - { _T("Class-P-Test"), PROHIBITED }, - { _T("Class-CTR-Test"), CTR }, - { _T("Class-A-Test"), CLASSA }, - { _T("Class-B-Test"), CLASSB }, - { _T("Class-C-Test"), CLASSC }, - { _T("Class-D-Test"), CLASSD }, - { _T("Class-GP-Test"), NOGLIDER }, - { _T("Class-W-Test"), WAVE }, - { _T("Class-E-Test"), CLASSE }, - { _T("Class-F-Test"), CLASSF }, - { _T("Class-TMZ-Test"), TMZ }, - { _T("Class-G-Test"), CLASSG }, - { _T("Class-RMZ-Test"), RMZ }, + { "Class-R-Test", RESTRICT }, + { "Class-Q-Test", DANGER }, + { "Class-P-Test", PROHIBITED }, + { "Class-CTR-Test", CTR }, + { "Class-A-Test", CLASSA }, + { "Class-B-Test", CLASSB }, + { "Class-C-Test", CLASSC }, + { "Class-D-Test", CLASSD }, + { "Class-GP-Test", NOGLIDER }, + { "Class-W-Test", WAVE }, + { "Class-E-Test", CLASSE }, + { "Class-F-Test", CLASSF }, + { "Class-TMZ-Test", TMZ }, + { "Class-G-Test", CLASSG }, + { "Class-RMZ-Test", RMZ }, }; ok1(airspaces.GetSize() == 26); for (const auto &as_ : airspaces.QueryAll()) { const AbstractAirspace &airspace = as_.GetAirspace(); - if (StringIsEqual(_T("Circle-Test"), airspace.GetName())) { + if (StringIsEqual("Circle-Test", airspace.GetName())) { if (!ok1(airspace.GetShape() == AbstractAirspace::Shape::CIRCLE)) continue; @@ -79,7 +79,7 @@ TestOpenAir() ok1(equals(circle.GetRadius(), Units::ToSysUnit(5, Unit::NAUTICAL_MILES))); ok1(equals(circle.GetReferenceLocation(), Angle::Degrees(1.091667), Angle::Degrees(0.091667))); - } else if (StringIsEqual(_T("Arc-Test"), airspace.GetName())) { + } else if (StringIsEqual("Arc-Test", airspace.GetName())) { if (!ok1(airspace.GetShape() == AbstractAirspace::Shape::POLYGON)) continue; @@ -87,7 +87,7 @@ TestOpenAir() const SearchPointVector &points = polygon.GetPoints(); ok1(points.size() == 33); - } else if (StringIsEqual(_T("Polygon-Test"), airspace.GetName())) { + } else if (StringIsEqual("Polygon-Test", airspace.GetName())) { if (!ok1(airspace.GetShape() == AbstractAirspace::Shape::POLYGON)) continue; @@ -112,37 +112,37 @@ TestOpenAir() ok1(equals(points[4].GetLocation(), Angle::DMS(1, 30, 30), Angle::DMS(1, 30, 30, true))); - } else if (StringIsEqual(_T("Radio-Test 1 (AR with MHz)"), airspace.GetName())) { + } else if (StringIsEqual("Radio-Test 1 (AR with MHz)", airspace.GetName())) { ok1(airspace.GetRadioFrequency() == RadioFrequency::FromMegaKiloHertz(130, 125)); - } else if (StringIsEqual(_T("Radio-Test 2 (AF without MHz)"), airspace.GetName())) { + } else if (StringIsEqual("Radio-Test 2 (AF without MHz)", airspace.GetName())) { ok1(airspace.GetRadioFrequency() == RadioFrequency::FromMegaKiloHertz(130, 125)); - } else if (StringIsEqual(_T("Height-Test-1"), airspace.GetName())) { + } else if (StringIsEqual("Height-Test-1", airspace.GetName())) { ok1(airspace.GetBase().IsTerrain()); ok1(airspace.GetTop().reference == AltitudeReference::MSL); ok1(equals(airspace.GetTop().altitude, Units::ToSysUnit(2000, Unit::FEET))); - } else if (StringIsEqual(_T("Height-Test-2"), airspace.GetName())) { + } else if (StringIsEqual("Height-Test-2", airspace.GetName())) { ok1(airspace.GetBase().reference == AltitudeReference::MSL); ok1(equals(airspace.GetBase().altitude, 0)); ok1(airspace.GetTop().reference == AltitudeReference::STD); ok1(equals(airspace.GetTop().flight_level, 65)); - } else if (StringIsEqual(_T("Height-Test-3"), airspace.GetName())) { + } else if (StringIsEqual("Height-Test-3", airspace.GetName())) { ok1(airspace.GetBase().reference == AltitudeReference::AGL); ok1(equals(airspace.GetBase().altitude_above_terrain, Units::ToSysUnit(100, Unit::FEET))); ok1(airspace.GetTop().reference == AltitudeReference::MSL); ok1(airspace.GetTop().altitude > Units::ToSysUnit(30000, Unit::FEET)); - } else if (StringIsEqual(_T("Height-Test-4"), airspace.GetName())) { + } else if (StringIsEqual("Height-Test-4", airspace.GetName())) { ok1(airspace.GetBase().reference == AltitudeReference::MSL); ok1(equals(airspace.GetBase().altitude, 100)); ok1(airspace.GetTop().reference == AltitudeReference::MSL); ok1(airspace.GetTop().altitude > Units::ToSysUnit(30000, Unit::FEET)); - } else if (StringIsEqual(_T("Height-Test-5"), airspace.GetName())) { + } else if (StringIsEqual("Height-Test-5", airspace.GetName())) { ok1(airspace.GetBase().reference == AltitudeReference::AGL); ok1(equals(airspace.GetBase().altitude, 100)); ok1(airspace.GetTop().reference == AltitudeReference::MSL); ok1(equals(airspace.GetTop().altitude, 450)); - } else if (StringIsEqual(_T("Height-Test-6"), airspace.GetName())) { + } else if (StringIsEqual("Height-Test-6", airspace.GetName())) { ok1(airspace.GetBase().reference == AltitudeReference::AGL); ok1(equals(airspace.GetBase().altitude_above_terrain, Units::ToSysUnit(50, Unit::FEET))); @@ -160,34 +160,34 @@ static void TestTNP() { Airspaces airspaces; - if (!ParseFile(Path(_T("test/data/airspace/tnp.sua")), airspaces)) { + if (!ParseFile(Path("test/data/airspace/tnp.sua"), airspaces)) { skip(3, 0, "Failed to parse input file"); return; } static constexpr AirspaceClassTestCouple classes[] = { - { _T("Class-R-Test"), RESTRICT }, - { _T("Class-Q-Test"), DANGER }, - { _T("Class-P-Test"), PROHIBITED }, - { _T("Class-CTR-Test"), CTR }, - { _T("Class-A-Test"), CLASSA }, - { _T("Class-B-Test"), CLASSB }, - { _T("Class-C-Test"), CLASSC }, - { _T("Class-D-Test"), CLASSD }, - { _T("Class-W-Test"), WAVE }, - { _T("Class-E-Test"), CLASSE }, - { _T("Class-F-Test"), CLASSF }, - { _T("Class-TMZ-Test"), TMZ }, - { _T("Class-G-Test"), CLASSG }, - { _T("Class-CLASS-C-Test"), CLASSC }, - { _T("Class-MATZ-Test"), MATZ }, + { "Class-R-Test", RESTRICT }, + { "Class-Q-Test", DANGER }, + { "Class-P-Test", PROHIBITED }, + { "Class-CTR-Test", CTR }, + { "Class-A-Test", CLASSA }, + { "Class-B-Test", CLASSB }, + { "Class-C-Test", CLASSC }, + { "Class-D-Test", CLASSD }, + { "Class-W-Test", WAVE }, + { "Class-E-Test", CLASSE }, + { "Class-F-Test", CLASSF }, + { "Class-TMZ-Test", TMZ }, + { "Class-G-Test", CLASSG }, + { "Class-CLASS-C-Test", CLASSC }, + { "Class-MATZ-Test", MATZ }, }; ok1(airspaces.GetSize() == 24); for (const auto &as_ : airspaces.QueryAll()) { const AbstractAirspace &airspace = as_.GetAirspace(); - if (StringIsEqual(_T("Circle-Test"), airspace.GetName())) { + if (StringIsEqual("Circle-Test", airspace.GetName())) { if (!ok1(airspace.GetShape() == AbstractAirspace::Shape::CIRCLE)) continue; @@ -195,7 +195,7 @@ TestTNP() ok1(equals(circle.GetRadius(), Units::ToSysUnit(5, Unit::NAUTICAL_MILES))); ok1(equals(circle.GetReferenceLocation(), Angle::Degrees(1.091667), Angle::Degrees(0.091667))); - } else if (StringIsEqual(_T("Polygon-Test"), airspace.GetName())) { + } else if (StringIsEqual("Polygon-Test", airspace.GetName())) { if (!ok1(airspace.GetShape() == AbstractAirspace::Shape::POLYGON)) continue; @@ -220,35 +220,35 @@ TestTNP() ok1(equals(points[4].GetLocation(), Angle::DMS(1, 30, 30), Angle::DMS(1, 30, 30, true))); - } else if (StringIsEqual(_T("Radio-Test"), airspace.GetName())) { + } else if (StringIsEqual("Radio-Test", airspace.GetName())) { ok1(airspace.GetRadioFrequency() == RadioFrequency::FromMegaKiloHertz(130, 125)); - } else if (StringIsEqual(_T("Height-Test-1"), airspace.GetName())) { + } else if (StringIsEqual("Height-Test-1", airspace.GetName())) { ok1(airspace.GetBase().IsTerrain()); ok1(airspace.GetTop().reference == AltitudeReference::MSL); ok1(equals(airspace.GetTop().altitude, Units::ToSysUnit(2000, Unit::FEET))); - } else if (StringIsEqual(_T("Height-Test-2"), airspace.GetName())) { + } else if (StringIsEqual("Height-Test-2", airspace.GetName())) { ok1(airspace.GetBase().reference == AltitudeReference::MSL); ok1(equals(airspace.GetBase().altitude, 0)); ok1(airspace.GetTop().reference == AltitudeReference::STD); ok1(equals(airspace.GetTop().flight_level, 65)); - } else if (StringIsEqual(_T("Height-Test-3"), airspace.GetName())) { + } else if (StringIsEqual("Height-Test-3", airspace.GetName())) { ok1(airspace.GetBase().reference == AltitudeReference::AGL); ok1(equals(airspace.GetBase().altitude_above_terrain, Units::ToSysUnit(100, Unit::FEET))); ok1(airspace.GetTop().reference == AltitudeReference::MSL); ok1(airspace.GetTop().altitude > Units::ToSysUnit(30000, Unit::FEET)); - } else if (StringIsEqual(_T("Height-Test-4"), airspace.GetName())) { + } else if (StringIsEqual("Height-Test-4", airspace.GetName())) { ok1(airspace.GetBase().reference == AltitudeReference::MSL); ok1(equals(airspace.GetBase().altitude, 100)); ok1(airspace.GetTop().reference == AltitudeReference::MSL); ok1(airspace.GetTop().altitude > Units::ToSysUnit(30000, Unit::FEET)); - } else if (StringIsEqual(_T("Height-Test-5"), airspace.GetName())) { + } else if (StringIsEqual("Height-Test-5", airspace.GetName())) { ok1(airspace.GetBase().reference == AltitudeReference::AGL); ok1(equals(airspace.GetBase().altitude, 100)); ok1(airspace.GetTop().reference == AltitudeReference::MSL); ok1(equals(airspace.GetTop().altitude, 450)); - } else if (StringIsEqual(_T("Height-Test-6"), airspace.GetName())) { + } else if (StringIsEqual("Height-Test-6", airspace.GetName())) { ok1(airspace.GetBase().reference == AltitudeReference::AGL); ok1(equals(airspace.GetBase().altitude_above_terrain, Units::ToSysUnit(50, Unit::FEET))); @@ -266,7 +266,7 @@ static void TestOpenAirExtended() { Airspaces airspaces; - if (!ParseFile(Path(_T("test/data/airspace/openair_extended.txt")), airspaces)) { + if (!ParseFile(Path("test/data/airspace/openair_extended.txt"), airspaces)) { skip(3, 0, "Failed to parse input file"); return; } @@ -275,10 +275,10 @@ TestOpenAirExtended() for (const auto &as_ : airspaces.QueryAll()) { const AbstractAirspace &airspace = as_.GetAirspace(); - if (StringIsEqual(_T("Type-TMA-Test"), airspace.GetName())) { - ok1(StringIsEqual(_T("TMA"), airspace.GetType())); - } else if (StringIsEqual(_T("Type-GLIDING_SECTOR-Test"), airspace.GetName())) { - ok1(StringIsEqual(_T("GLIDING_SECTOR"), airspace.GetType())); + if (StringIsEqual("Type-TMA-Test", airspace.GetName())) { + ok1(StringIsEqual("TMA", airspace.GetType())); + } else if (StringIsEqual("Type-GLIDING_SECTOR-Test", airspace.GetName())) { + ok1(StringIsEqual("GLIDING_SECTOR", airspace.GetType())); } } } diff --git a/test/src/TestByteSizeFormatter.cpp b/test/src/TestByteSizeFormatter.cpp index c848087b3b1..d8b3c5c2485 100644 --- a/test/src/TestByteSizeFormatter.cpp +++ b/test/src/TestByteSizeFormatter.cpp @@ -13,104 +13,104 @@ int main() char buffer[256]; FormatByteSize(buffer, ARRAY_SIZE(buffer), 0); - ok1(StringIsEqual(buffer, _T("0 B"))); + ok1(StringIsEqual(buffer, "0 B")); FormatByteSize(buffer, ARRAY_SIZE(buffer), 1); - ok1(StringIsEqual(buffer, _T("1 B"))); + ok1(StringIsEqual(buffer, "1 B")); FormatByteSize(buffer, ARRAY_SIZE(buffer), 9); - ok1(StringIsEqual(buffer, _T("9 B"))); + ok1(StringIsEqual(buffer, "9 B")); FormatByteSize(buffer, ARRAY_SIZE(buffer), 10); - ok1(StringIsEqual(buffer, _T("10 B"))); + ok1(StringIsEqual(buffer, "10 B")); FormatByteSize(buffer, ARRAY_SIZE(buffer), 345); - ok1(StringIsEqual(buffer, _T("345 B"))); + ok1(StringIsEqual(buffer, "345 B")); FormatByteSize(buffer, ARRAY_SIZE(buffer), 1 * 1024); - ok1(StringIsEqual(buffer, _T("1.00 KB"))); + ok1(StringIsEqual(buffer, "1.00 KB")); FormatByteSize(buffer, ARRAY_SIZE(buffer), 1 * 1024 + 512); - ok1(StringIsEqual(buffer, _T("1.50 KB"))); + ok1(StringIsEqual(buffer, "1.50 KB")); FormatByteSize(buffer, ARRAY_SIZE(buffer), 9 * 1024); - ok1(StringIsEqual(buffer, _T("9.00 KB"))); + ok1(StringIsEqual(buffer, "9.00 KB")); FormatByteSize(buffer, ARRAY_SIZE(buffer), 10 * 1024); - ok1(StringIsEqual(buffer, _T("10.0 KB"))); + ok1(StringIsEqual(buffer, "10.0 KB")); FormatByteSize(buffer, ARRAY_SIZE(buffer), 345 * 1024); - ok1(StringIsEqual(buffer, _T("345 KB"))); + ok1(StringIsEqual(buffer, "345 KB")); FormatByteSize(buffer, ARRAY_SIZE(buffer), 1 * 1024 * 1024); - ok1(StringIsEqual(buffer, _T("1.00 MB"))); + ok1(StringIsEqual(buffer, "1.00 MB")); FormatByteSize(buffer, ARRAY_SIZE(buffer), 1 * 1024 * 1024 + 512 * 1024); - ok1(StringIsEqual(buffer, _T("1.50 MB"))); + ok1(StringIsEqual(buffer, "1.50 MB")); FormatByteSize(buffer, ARRAY_SIZE(buffer), 9 * 1024 * 1024); - ok1(StringIsEqual(buffer, _T("9.00 MB"))); + ok1(StringIsEqual(buffer, "9.00 MB")); FormatByteSize(buffer, ARRAY_SIZE(buffer), 10 * 1024 * 1024); - ok1(StringIsEqual(buffer, _T("10.0 MB"))); + ok1(StringIsEqual(buffer, "10.0 MB")); FormatByteSize(buffer, ARRAY_SIZE(buffer), 345 * 1024 * 1024); - ok1(StringIsEqual(buffer, _T("345 MB"))); + ok1(StringIsEqual(buffer, "345 MB")); FormatByteSize(buffer, ARRAY_SIZE(buffer), 1 * 1024 * 1024 * 1024); - ok1(StringIsEqual(buffer, _T("1.00 GB"))); + ok1(StringIsEqual(buffer, "1.00 GB")); FormatByteSize(buffer, ARRAY_SIZE(buffer), 0, true); - ok1(StringIsEqual(buffer, _T("0B"))); + ok1(StringIsEqual(buffer, "0B")); FormatByteSize(buffer, ARRAY_SIZE(buffer), 1, true); - ok1(StringIsEqual(buffer, _T("1B"))); + ok1(StringIsEqual(buffer, "1B")); FormatByteSize(buffer, ARRAY_SIZE(buffer), 10, true); - ok1(StringIsEqual(buffer, _T("10B"))); + ok1(StringIsEqual(buffer, "10B")); FormatByteSize(buffer, ARRAY_SIZE(buffer), 345, true); - ok1(StringIsEqual(buffer, _T("345B"))); + ok1(StringIsEqual(buffer, "345B")); FormatByteSize(buffer, ARRAY_SIZE(buffer), 1 * 1024, true); - ok1(StringIsEqual(buffer, _T("1.0K"))); + ok1(StringIsEqual(buffer, "1.0K")); FormatByteSize(buffer, ARRAY_SIZE(buffer), 1 * 1024 + 512, true); - ok1(StringIsEqual(buffer, _T("1.5K"))); + ok1(StringIsEqual(buffer, "1.5K")); FormatByteSize(buffer, ARRAY_SIZE(buffer), 9 * 1024, true); - ok1(StringIsEqual(buffer, _T("9.0K"))); + ok1(StringIsEqual(buffer, "9.0K")); FormatByteSize(buffer, ARRAY_SIZE(buffer), 10 * 1024, true); - ok1(StringIsEqual(buffer, _T("10.0K"))); + ok1(StringIsEqual(buffer, "10.0K")); FormatByteSize(buffer, ARRAY_SIZE(buffer), 345 * 1024, true); - ok1(StringIsEqual(buffer, _T("345K"))); + ok1(StringIsEqual(buffer, "345K")); FormatByteSize(buffer, ARRAY_SIZE(buffer), 1 * 1024 * 1024, true); - ok1(StringIsEqual(buffer, _T("1.0M"))); + ok1(StringIsEqual(buffer, "1.0M")); FormatByteSize(buffer, ARRAY_SIZE(buffer), 1 * 1024 * 1024 + 512 * 1024, true); - ok1(StringIsEqual(buffer, _T("1.5M"))); + ok1(StringIsEqual(buffer, "1.5M")); FormatByteSize(buffer, ARRAY_SIZE(buffer), 9 * 1024 * 1024, true); - ok1(StringIsEqual(buffer, _T("9.0M"))); + ok1(StringIsEqual(buffer, "9.0M")); FormatByteSize(buffer, ARRAY_SIZE(buffer), 10 * 1024 * 1024, true); - ok1(StringIsEqual(buffer, _T("10.0M"))); + ok1(StringIsEqual(buffer, "10.0M")); FormatByteSize(buffer, ARRAY_SIZE(buffer), 345 * 1024 * 1024, true); - ok1(StringIsEqual(buffer, _T("345M"))); + ok1(StringIsEqual(buffer, "345M")); FormatByteSize(buffer, ARRAY_SIZE(buffer), 1 * 1024 * 1024 * 1024, true); - ok1(StringIsEqual(buffer, _T("1.0G"))); + ok1(StringIsEqual(buffer, "1.0G")); return exit_status(); diff --git a/test/src/TestDriver.cpp b/test/src/TestDriver.cpp index 4516a04ae44..8fcf51dd48e 100644 --- a/test/src/TestDriver.cpp +++ b/test/src/TestDriver.cpp @@ -1613,17 +1613,17 @@ TestDeclare(const struct DeviceRegister &driver) ok1(device != NULL); LoggerSettings logger_settings; - logger_settings.pilot_name = _T("Foo Bar"); + logger_settings.pilot_name = "Foo Bar"; Plane plane; - plane.registration = _T("D-3003"); - plane.competition_id = _T("33"); - plane.type = _T("Cirrus"); + plane.registration = "D-3003"; + plane.competition_id = "33"; + plane.type = "Cirrus"; Declaration declaration(logger_settings, plane, NULL); const GeoPoint gp(Angle::Degrees(7.7061111111111114), Angle::Degrees(51.051944444444445)); Waypoint wp(gp); - wp.name = _T("Foo"); + wp.name = "Foo"; wp.elevation = 123; wp.has_elevation = true; declaration.Append(wp); diff --git a/test/src/TestFileUtil.cpp b/test/src/TestFileUtil.cpp index f45e48ef94a..5a9e1700d6b 100644 --- a/test/src/TestFileUtil.cpp +++ b/test/src/TestFileUtil.cpp @@ -17,13 +17,13 @@ class TestingFileVisitor: public File::Visitor void Visit([[maybe_unused]] Path path, Path filename) { - if (filename == Path(_T("a.txt"))) { + if (filename == Path("a.txt")) { ok(true, "a.txt"); - } else if (filename == Path(_T("b.txt"))) { + } else if (filename == Path("b.txt")) { ok(true, "b.txt"); - } else if (filename == Path(_T("c.tx"))) { + } else if (filename == Path("c.tx")) { ok(!filtered, "c.tx"); - } else if (filename == Path(_T("d.txt"))) { + } else if (filename == Path("d.txt")) { ok(recursive, "d.txt"); } else { ok(false, "unexpected file"); @@ -35,25 +35,25 @@ int main() { plan_tests(17); - ok1(Directory::Exists(Path(_T("test/data/file_visitor_test")))); - ok1(File::Exists(Path(_T("test/data/file_visitor_test/a.txt")))); - ok1(File::Exists(Path(_T("test/data/file_visitor_test/b.txt")))); - ok1(File::Exists(Path(_T("test/data/file_visitor_test/c.tx")))); - ok1(File::Exists(Path(_T("test/data/file_visitor_test/subfolder/d.txt")))); + ok1(Directory::Exists(Path("test/data/file_visitor_test"))); + ok1(File::Exists(Path("test/data/file_visitor_test/a.txt"))); + ok1(File::Exists(Path("test/data/file_visitor_test/b.txt"))); + ok1(File::Exists(Path("test/data/file_visitor_test/c.tx"))); + ok1(File::Exists(Path("test/data/file_visitor_test/subfolder/d.txt"))); TestingFileVisitor fv1(false, false); - Directory::VisitFiles(Path(_T("test/data/file_visitor_test")), fv1, false); + Directory::VisitFiles(Path("test/data/file_visitor_test"), fv1, false); TestingFileVisitor fv2(true, false); - Directory::VisitFiles(Path(_T("test/data/file_visitor_test")), fv2, true); + Directory::VisitFiles(Path("test/data/file_visitor_test"), fv2, true); TestingFileVisitor fv3(false, true); - Directory::VisitSpecificFiles(Path(_T("test/data/file_visitor_test")), - _T("*.txt"), fv3, false); + Directory::VisitSpecificFiles(Path("test/data/file_visitor_test"), + "*.txt", fv3, false); TestingFileVisitor fv4(true, true); - Directory::VisitSpecificFiles(Path(_T("test/data/file_visitor_test")), - _T("*.txt"), fv4, true); + Directory::VisitSpecificFiles(Path("test/data/file_visitor_test"), + "*.txt", fv4, true); return exit_status(); } diff --git a/test/src/TestFlarmNet.cpp b/test/src/TestFlarmNet.cpp index dc1e37a7318..b2853c09202 100644 --- a/test/src/TestFlarmNet.cpp +++ b/test/src/TestFlarmNet.cpp @@ -13,7 +13,7 @@ int main() plan_tests(15); FlarmNetDatabase db; - int count = FlarmNetReader::LoadFile(Path(_T("test/data/flarmnet/data.fln")), + int count = FlarmNetReader::LoadFile(Path("test/data/flarmnet/data.fln"), db); ok1(count == 6); @@ -22,30 +22,30 @@ int main() const FlarmNetRecord *record = db.FindRecordById(id); ok1(record != NULL); - ok1(StringIsEqual(record->id, _T("DDA85C"))); - ok1(StringIsEqual(record->pilot, _T("Tobias Bieniek"))); - ok1(StringIsEqual(record->airfield, _T("AACHEN"))); - ok1(StringIsEqual(record->plane_type, _T("Hornet"))); - ok1(StringIsEqual(record->registration, _T("D-4449"))); - ok1(StringIsEqual(record->callsign, _T("TH"))); - ok1(StringIsEqual(record->frequency, _T("130.625"))); + ok1(StringIsEqual(record->id, "DDA85C")); + ok1(StringIsEqual(record->pilot, "Tobias Bieniek")); + ok1(StringIsEqual(record->airfield, "AACHEN")); + ok1(StringIsEqual(record->plane_type, "Hornet")); + ok1(StringIsEqual(record->registration, "D-4449")); + ok1(StringIsEqual(record->callsign, "TH")); + ok1(StringIsEqual(record->frequency, "130.625")); const FlarmNetRecord *array[3]; - ok1(db.FindRecordsByCallSign(_T("TH"), array, 3) == 2); + ok1(db.FindRecordsByCallSign("TH", array, 3) == 2); bool found4449 = false, found5799 = false; for (unsigned i = 0; i < 2; i++) { record = array[i]; - if (StringIsEqual(record->registration, _T("D-4449"))) + if (StringIsEqual(record->registration, "D-4449")) found4449 = true; - if (StringIsEqual(record->registration, _T("D-5799"))) + if (StringIsEqual(record->registration, "D-5799")) found5799 = true; } ok1(found4449); ok1(found5799); FlarmId ids[3]; - ok1(db.FindIdsByCallSign(_T("TH"), ids, 3) == 2); + ok1(db.FindIdsByCallSign("TH", ids, 3) == 2); id = FlarmId::Parse("DDA85C", NULL); FlarmId id2 = FlarmId::Parse("DDA896", NULL); diff --git a/test/src/TestGRecord.cpp b/test/src/TestGRecord.cpp index 35f9a5a13a1..de5e8702de3 100644 --- a/test/src/TestGRecord.cpp +++ b/test/src/TestGRecord.cpp @@ -22,10 +22,10 @@ int main() try { plan_tests(4); - CheckGRecord(_T("test/data/grecord64a.igc")); - CheckGRecord(_T("test/data/grecord64b.igc")); - CheckGRecord(_T("test/data/grecord65a.igc")); - CheckGRecord(_T("test/data/grecord65b.igc")); + CheckGRecord("test/data/grecord64a.igc"); + CheckGRecord("test/data/grecord64b.igc"); + CheckGRecord("test/data/grecord65a.igc"); + CheckGRecord("test/data/grecord65b.igc"); return exit_status(); } catch (...) { diff --git a/test/src/TestGeoPointFormatter.cpp b/test/src/TestGeoPointFormatter.cpp index 0277cbf5740..667013a63f8 100644 --- a/test/src/TestGeoPointFormatter.cpp +++ b/test/src/TestGeoPointFormatter.cpp @@ -8,12 +8,12 @@ static bool StringIsEqualWildcard(const char *string1, const char *string2, - char wildcard = _T('*')) + char wildcard = '*') { while (*string1 == *string2 || *string1 == wildcard || *string2 == wildcard) { - if (*string1 == _T('\0') && *string2 == _T('\0')) + if (*string1 == '\0' && *string2 == '\0') return true; string1++; @@ -36,67 +36,67 @@ int main() // Test DD.ddddd FormatGeoPoint(location1, buffer, ARRAY_SIZE(buffer), CoordinateFormat::DD_DDDDD); - ok1(StringIsEqual(buffer, _T("49.48715° N 008.46632° E"))); + ok1(StringIsEqual(buffer, "49.48715° N 008.46632° E")); FormatGeoPoint(location2, buffer, ARRAY_SIZE(buffer), CoordinateFormat::DD_DDDDD); - ok1(StringIsEqual(buffer, _T("32.65333° S 070.01167° W"))); + ok1(StringIsEqual(buffer, "32.65333° S 070.01167° W")); // Test DDMM.mmm FormatGeoPoint(location1, buffer, ARRAY_SIZE(buffer), CoordinateFormat::DDMM_MMM); - ok1(StringIsEqual(buffer, _T("49°29.229' N 008°27.979' E"))); + ok1(StringIsEqual(buffer, "49°29.229' N 008°27.979' E")); FormatGeoPoint(location2, buffer, ARRAY_SIZE(buffer), CoordinateFormat::DDMM_MMM); - ok1(StringIsEqual(buffer, _T("32°39.200' S 070°00.700' W"))); + ok1(StringIsEqual(buffer, "32°39.200' S 070°00.700' W")); // Test DDMMSS FormatGeoPoint(location1, buffer, ARRAY_SIZE(buffer), CoordinateFormat::DDMMSS); - ok1(StringIsEqual(buffer, _T("49°29'14\" N 008°27'59\" E"))); + ok1(StringIsEqual(buffer, "49°29'14\" N 008°27'59\" E")); FormatGeoPoint(location2, buffer, ARRAY_SIZE(buffer), CoordinateFormat::DDMMSS); - ok1(StringIsEqual(buffer, _T("32°39'12\" S 070°00'42\" W"))); + ok1(StringIsEqual(buffer, "32°39'12\" S 070°00'42\" W")); // Test DDMMSS.s FormatGeoPoint(location1, buffer, ARRAY_SIZE(buffer), CoordinateFormat::DDMMSS_S); - ok1(StringIsEqual(buffer, _T("49°29'13.8\" N 008°27'58.8\" E"))); + ok1(StringIsEqual(buffer, "49°29'13.8\" N 008°27'58.8\" E")); FormatGeoPoint(location2, buffer, ARRAY_SIZE(buffer), CoordinateFormat::DDMMSS_S); - ok1(StringIsEqual(buffer, _T("32°39'12.0\" S 070°00'42.0\" W"))); + ok1(StringIsEqual(buffer, "32°39'12.0\" S 070°00'42.0\" W")); // Test UTM FormatGeoPoint(location1, buffer, ARRAY_SIZE(buffer), CoordinateFormat::UTM); - ok1(StringIsEqualWildcard(buffer, _T("32U 4613** 5481***"))); + ok1(StringIsEqualWildcard(buffer, "32U 4613** 5481***")); FormatGeoPoint(location2, buffer, ARRAY_SIZE(buffer), CoordinateFormat::UTM); - ok1(StringIsEqualWildcard(buffer, _T("19H 4051** 6386***"))); + ok1(StringIsEqualWildcard(buffer, "19H 4051** 6386***")); // Test separator FormatGeoPoint(location1, buffer, ARRAY_SIZE(buffer), - CoordinateFormat::DDMMSS, _T('\n')); - ok1(StringIsEqual(buffer, _T("49°29'14\" N\n008°27'59\" E"))); + CoordinateFormat::DDMMSS, '\n'); + ok1(StringIsEqual(buffer, "49°29'14\" N\n008°27'59\" E")); FormatGeoPoint(location2, buffer, ARRAY_SIZE(buffer), - CoordinateFormat::DDMMSS, _T('\n')); - ok1(StringIsEqual(buffer, _T("32°39'12\" S\n070°00'42\" W"))); + CoordinateFormat::DDMMSS, '\n'); + ok1(StringIsEqual(buffer, "32°39'12\" S\n070°00'42\" W")); FormatGeoPoint(location1, buffer, ARRAY_SIZE(buffer), - CoordinateFormat::UTM, _T('\n')); - ok1(StringIsEqualWildcard(buffer, _T("32U\n4613**\n5481***"))); + CoordinateFormat::UTM, '\n'); + ok1(StringIsEqualWildcard(buffer, "32U\n4613**\n5481***")); FormatGeoPoint(location2, buffer, ARRAY_SIZE(buffer), - CoordinateFormat::UTM, _T('\n')); - ok1(StringIsEqualWildcard(buffer, _T("19H\n4051**\n6386***"))); + CoordinateFormat::UTM, '\n'); + ok1(StringIsEqualWildcard(buffer, "19H\n4051**\n6386***")); return exit_status(); diff --git a/test/src/TestIGCFilenameFormatter.cpp b/test/src/TestIGCFilenameFormatter.cpp index 6a4a53d419a..ea818fd2f86 100644 --- a/test/src/TestIGCFilenameFormatter.cpp +++ b/test/src/TestIGCFilenameFormatter.cpp @@ -11,14 +11,14 @@ TestShort() { char buffer[256]; - FormatIGCFilename(buffer, BrokenDate(2012, 2, 10), _T('T'), _T("ABC"), 1); - ok1(StringIsEqual(buffer, _T("22ATABC1.igc"))); + FormatIGCFilename(buffer, BrokenDate(2012, 2, 10), 'T', "ABC", 1); + ok1(StringIsEqual(buffer, "22ATABC1.igc")); - FormatIGCFilename(buffer, BrokenDate(2010, 1, 1), _T('X'), _T("234"), 15); - ok1(StringIsEqual(buffer, _T("011X234F.igc"))); + FormatIGCFilename(buffer, BrokenDate(2010, 1, 1), 'X', "234", 15); + ok1(StringIsEqual(buffer, "011X234F.igc")); - FormatIGCFilename(buffer, BrokenDate(2009, 12, 1), _T('X'), _T("234"), 35); - ok1(StringIsEqual(buffer, _T("9C1X234Z.igc"))); + FormatIGCFilename(buffer, BrokenDate(2009, 12, 1), 'X', "234", 35); + ok1(StringIsEqual(buffer, "9C1X234Z.igc")); } static void @@ -27,16 +27,16 @@ TestLong() char buffer[256]; FormatIGCFilenameLong(buffer, BrokenDate(2012, 2, 10), - _T("XYZ"), _T("ABC"), 1); - ok1(StringIsEqual(buffer, _T("2012-02-10-XYZ-ABC-01.igc"))); + "XYZ", "ABC", 1); + ok1(StringIsEqual(buffer, "2012-02-10-XYZ-ABC-01.igc")); FormatIGCFilenameLong(buffer, BrokenDate(2010, 1, 1), - _T("BLA"), _T("234"), 15); - ok1(StringIsEqual(buffer, _T("2010-01-01-BLA-234-15.igc"))); + "BLA", "234", 15); + ok1(StringIsEqual(buffer, "2010-01-01-BLA-234-15.igc")); FormatIGCFilenameLong(buffer, BrokenDate(2009, 12, 1), - _T("S45"), _T("234"), 35); - ok1(StringIsEqual(buffer, _T("2009-12-01-S45-234-35.igc"))); + "S45", "234", 35); + ok1(StringIsEqual(buffer, "2009-12-01-S45-234-35.igc")); } static void @@ -45,11 +45,11 @@ TestChar() char buffer[256]; FormatIGCFilename(buffer, BrokenDate(2012, 2, 10), 'T', "ABC", 1); - ok1(StringIsEqual(buffer, _T("22ATABC1.igc"))); + ok1(StringIsEqual(buffer, "22ATABC1.igc")); FormatIGCFilenameLong(buffer, BrokenDate(2012, 2, 10), "XYZ", "ABC", 1); - ok1(StringIsEqual(buffer, _T("2012-02-10-XYZ-ABC-01.igc"))); + ok1(StringIsEqual(buffer, "2012-02-10-XYZ-ABC-01.igc")); } int main() diff --git a/test/src/TestLogger.cpp b/test/src/TestLogger.cpp index 42332cd6b2f..5d80a6bf491 100644 --- a/test/src/TestLogger.cpp +++ b/test/src/TestLogger.cpp @@ -91,12 +91,12 @@ Run(IGCWriter &writer) i.ProvidePressureAltitude(490); i.ProvideBaroAltitudeTrue(400); - writer.WriteHeader(i.date_time_utc, _T("Pilot Name"), _T("CoPilot Name"), _T("ASK-21"), - _T("D-1234"), _T("34"), "FOO", _T("bar"), false); + writer.WriteHeader(i.date_time_utc, "Pilot Name", "CoPilot Name", "ASK-21", + "D-1234", "34", "FOO", "bar", false); writer.StartDeclaration(i.date_time_utc, 3); - writer.AddDeclaration(home, _T("Bergneustadt")); - writer.AddDeclaration(tp, _T("Suhl")); - writer.AddDeclaration(home, _T("Bergneustadt")); + writer.AddDeclaration(home, "Bergneustadt"); + writer.AddDeclaration(tp, "Suhl"); + writer.AddDeclaration(home, "Bergneustadt"); writer.EndDeclaration(); writer.LogEmptyFRecord(i.date_time_utc); @@ -106,7 +106,7 @@ Run(IGCWriter &writer) i.date_time_utc.second += 5; writer.LogEvent(i, "my_event"); i.date_time_utc.second += 5; - writer.LoggerNote(_T("my_note")); + writer.LoggerNote("my_note"); int satellites[GPSState::MAXSATELLITES]; for (unsigned i = 0; i < GPSState::MAXSATELLITES; ++i) @@ -139,7 +139,7 @@ int main() try { plan_tests(51); - const Path path(_T("output/test/test.igc")); + const Path path("output/test/test.igc"); File::Delete(path); Run(path); diff --git a/test/src/TestMETARParser.cpp b/test/src/TestMETARParser.cpp index 7493fff9237..c71b9ce9ab6 100644 --- a/test/src/TestMETARParser.cpp +++ b/test/src/TestMETARParser.cpp @@ -18,12 +18,12 @@ main() { ParsedMETAR parsed; - metar.content = _T("EDDL 231050Z 31007MPS 9999 FEW020 SCT130 23/18 Q1015 NOSIG"); - metar.decoded = _T(""); + metar.content = "EDDL 231050Z 31007MPS 9999 FEW020 SCT130 23/18 Q1015 NOSIG"; + metar.decoded = ""; if (!ok1(METARParser::Parse(metar, parsed))) return exit_status(); - ok1(parsed.icao_code == _T("EDDL")); + ok1(parsed.icao_code == "EDDL"); ok1(parsed.day_of_month == 23); ok1(parsed.hour == 10); ok1(parsed.minute == 50); @@ -42,13 +42,13 @@ main() } { ParsedMETAR parsed; - metar.content = _T("METAR KTTN 051853Z 04011KT 1/2SM VCTS SN FZFG BKN003 OVC010 M02/M02 A3006 RMK AO2 TSB40 SLP176 P0002 T10171017="); - metar.decoded = _T("Pudahuel, Chile (SCEL) 33-23S 070-47W 476M\r\n" - "Nov 04, 2011 - 07:50 PM EDT / 2011.11.04 2350 UTC\r\n"); + metar.content = "METAR KTTN 051853Z 04011KT 1/2SM VCTS SN FZFG BKN003 OVC010 M02/M02 A3006 RMK AO2 TSB40 SLP176 P0002 T10171017="; + metar.decoded = "Pudahuel, Chile (SCEL) 33-23S 070-47W 476M\r\n" + "Nov 04, 2011 - 07:50 PM EDT / 2011.11.04 2350 UTC\r\n"; if (!ok1(METARParser::Parse(metar, parsed))) return exit_status(); - ok1(parsed.icao_code == _T("KTTN")); + ok1(parsed.icao_code == "KTTN"); ok1(parsed.day_of_month == 5); ok1(parsed.hour == 18); ok1(parsed.minute == 53); @@ -68,13 +68,13 @@ main() } { ParsedMETAR parsed; - metar.content = _T("METAR EDJA 231950Z VRB01KT CAVOK 21/17 Q1017="); - metar.decoded = _T("Duesseldorf, Germany (EDDL) 51-18N 006-46E 41M\r\n" - "Nov 04, 2011 - 07:50 PM EDT / 2011.11.04 2350 UTC\r\n"); + metar.content = "METAR EDJA 231950Z VRB01KT CAVOK 21/17 Q1017="; + metar.decoded = "Duesseldorf, Germany (EDDL) 51-18N 006-46E 41M\r\n" + "Nov 04, 2011 - 07:50 PM EDT / 2011.11.04 2350 UTC\r\n"; if (!ok1(METARParser::Parse(metar, parsed))) return exit_status(); - ok1(parsed.icao_code == _T("EDJA")); + ok1(parsed.icao_code == "EDJA"); ok1(parsed.day_of_month == 23); ok1(parsed.hour == 19); ok1(parsed.minute == 50); diff --git a/test/src/TestPlanes.cpp b/test/src/TestPlanes.cpp index b729e215dcf..eabe299967c 100644 --- a/test/src/TestPlanes.cpp +++ b/test/src/TestPlanes.cpp @@ -18,13 +18,13 @@ static void TestReader() { Plane plane; - PlaneGlue::ReadFile(plane, Path(_T("test/data/D-4449.xcp"))); + PlaneGlue::ReadFile(plane, Path("test/data/D-4449.xcp")); - ok1(plane.registration == _T("D-4449")); - ok1(plane.competition_id == _T("TH")); - ok1(plane.type == _T("Hornet")); + ok1(plane.registration == "D-4449"); + ok1(plane.competition_id == "TH"); + ok1(plane.type == "Hornet"); ok1(plane.handicap == 100); - ok1(plane.polar_name == _T("Hornet")); + ok1(plane.polar_name == "Hornet"); ok1(equals(plane.polar_shape[0].v, Units::ToSysUnit(80, Unit::KILOMETER_PER_HOUR))); ok1(equals(plane.polar_shape[1].v, @@ -44,7 +44,7 @@ TestReader() ok1(equals(plane.weglide_glider_type, 261)); plane = Plane(); - PlaneGlue::ReadFile(plane, Path(_T("test/data/D-4449dry.xcp"))); + PlaneGlue::ReadFile(plane, Path("test/data/D-4449dry.xcp")); ok1(equals(plane.empty_mass, 212)); } @@ -52,11 +52,11 @@ static void TestWriter() { Plane plane; - plane.registration = _T("D-4449"); - plane.competition_id = _T("TH"); - plane.type = _T("Hornet"); + plane.registration = "D-4449"; + plane.competition_id = "TH"; + plane.type = "Hornet"; plane.handicap = 100; - plane.polar_name = _T("Hornet"); + plane.polar_name = "Hornet"; plane.polar_shape[0].v = Units::ToSysUnit(80, Unit::KILOMETER_PER_HOUR); plane.polar_shape[1].v = Units::ToSysUnit(120, Unit::KILOMETER_PER_HOUR); plane.polar_shape[2].v = Units::ToSysUnit(160, Unit::KILOMETER_PER_HOUR); @@ -72,9 +72,9 @@ TestWriter() plane.wing_area = 9.8; plane.weglide_glider_type = 160; - PlaneGlue::WriteFile(plane, Path(_T("output/D-4449.xcp"))); + PlaneGlue::WriteFile(plane, Path("output/D-4449.xcp")); - FileLineReaderA reader(Path(_T("output/D-4449.xcp"))); + FileLineReaderA reader(Path("output/D-4449.xcp")); unsigned count = 0; bool found1 = false, found2 = false, found3 = false, found4 = false; diff --git a/test/src/TestPolars.cpp b/test/src/TestPolars.cpp index 27c50a938b7..86ddb6c0c62 100644 --- a/test/src/TestPolars.cpp +++ b/test/src/TestPolars.cpp @@ -59,7 +59,7 @@ TestFileImport() { // Test LoadFromFile() PolarInfo polar; - PolarGlue::LoadFromFile(polar, Path(_T("test/data/test.plr"))); + PolarGlue::LoadFromFile(polar, Path("test/data/test.plr")); ok1(equals(polar.shape.reference_mass, 318)); ok1(equals(polar.max_ballast, 100)); ok1(equals(polar.shape[0].v, 22.2222222)); @@ -96,23 +96,23 @@ struct PerformanceItem { static const PerformanceItem performanceData[] = { /* 206 Hornet */ - { _T("206 Hornet"), true, 38, true, 103, true, 0.6, true, 74 }, + { "206 Hornet", true, 38, true, 103, true, 0.6, true, 74 }, /* Discus */ - { _T("Discus"), true, 43, false, 0, true, 0.59, false, 0 }, + { "Discus", true, 43, false, 0, true, 0.59, false, 0 }, /* G-103 TWIN II (PIL)*/ - { _T("G 103 Twin 2"), true, 38.5, true, 95, true, 0.64, true, 80 }, + { "G 103 Twin 2", true, 38.5, true, 95, true, 0.64, true, 80 }, /* H-201 Std. Libelle */ - { _T("H-201 Std Libelle"), true, 38, true, 90, true, 0.6, true, 75 }, + { "H-201 Std Libelle", true, 38, true, 90, true, 0.6, true, 75 }, /* Ka6 CR */ - { _T("Ka 6CR"), true, 30, true, 85, true, 0.65, true, 72 }, + { "Ka 6CR", true, 30, true, 85, true, 0.65, true, 72 }, /* K8 */ - { _T("Ka 8"), true, 25, true, 75, false, 0, true, 62 }, + { "Ka 8", true, 25, true, 75, false, 0, true, 62 }, /* LS-4 */ - { _T("LS-4"), true, 40.5, false, 0, true, 0.60, false, 0 }, + { "LS-4", true, 40.5, false, 0, true, 0.60, false, 0 }, /* Std. Cirrus */ - { _T("Std Cirrus"), true, 38.5, false, 0, true, 0.6, false, 0 }, + { "Std Cirrus", true, 38.5, false, 0, true, 0.6, false, 0 }, /* LS-1f */ - { _T("LS-1f"), true, 38.2, false, 0, true, 0.64, false, 0 }, + { "LS-1f", true, 38.2, false, 0, true, 0.64, false, 0 }, }; static bool diff --git a/test/src/TestProfile.cpp b/test/src/TestProfile.cpp index 25112d66580..75355a107be 100644 --- a/test/src/TestProfile.cpp +++ b/test/src/TestProfile.cpp @@ -69,9 +69,9 @@ TestWriter() Profile::Set("key1", 4); Profile::Set("key2", "value2"); - Profile::SaveFile(Path(_T("output/TestProfileWriter.prf"))); + Profile::SaveFile(Path("output/TestProfileWriter.prf")); - FileLineReaderA reader(Path(_T("output/TestProfileWriter.prf"))); + FileLineReaderA reader(Path("output/TestProfileWriter.prf")); unsigned count = 0; bool found1 = false, found2 = false; @@ -95,7 +95,7 @@ static void TestReader() { Profile::Clear(); - Profile::LoadFile(Path(_T("test/data/TestProfileReader.prf"))); + Profile::LoadFile(Path("test/data/TestProfileReader.prf")); { int value; @@ -108,7 +108,7 @@ TestReader() StaticString<32> value; ok1(Profile::Exists("key2")); ok1(Profile::Get("key2", value)); - ok1(value == _T("value")); + ok1(value == "value"); } { diff --git a/test/src/TestRadixTree.cpp b/test/src/TestRadixTree.cpp index b33a3e2770d..f9f59c5a548 100644 --- a/test/src/TestRadixTree.cpp +++ b/test/src/TestRadixTree.cpp @@ -60,133 +60,133 @@ int main() char buffer[64], *suggest; RadixTree irt; - irt.Add(_T("foo"), 42); + irt.Add("foo", 42); ok1(all_sum(irt) == 42); - ok1(prefix_sum(irt, _T("")) == 42); - ok1(prefix_sum(irt, _T("f")) == 42); - ok1(prefix_sum(irt, _T("fo")) == 42); - ok1(prefix_sum(irt, _T("foo")) == 42); - ok1(prefix_sum(irt, _T("foobar")) == 0); + ok1(prefix_sum(irt, "") == 42); + ok1(prefix_sum(irt, "f") == 42); + ok1(prefix_sum(irt, "fo") == 42); + ok1(prefix_sum(irt, "foo") == 42); + ok1(prefix_sum(irt, "foobar") == 0); - irt.Add(_T("foa"), 0); + irt.Add("foa", 0); ok1(all_sum(irt) == 42); check_ascending_keys(irt); - suggest = irt.Suggest(_T("xyz"), buffer, 64); + suggest = irt.Suggest("xyz", buffer, 64); ok1(suggest == NULL); - suggest = irt.Suggest(_T(""), buffer, 64); + suggest = irt.Suggest("", buffer, 64); ok1(suggest != NULL); - ok1(StringIsEqual(suggest, _T("f"))); + ok1(StringIsEqual(suggest, "f")); - suggest = irt.Suggest(_T("f"), buffer, 64); + suggest = irt.Suggest("f", buffer, 64); ok1(suggest != NULL); - ok1(StringIsEqual(suggest, _T("o"))); + ok1(StringIsEqual(suggest, "o")); - suggest = irt.Suggest(_T("foo"), buffer, 64); + suggest = irt.Suggest("foo", buffer, 64); ok1(suggest != NULL); - ok1(StringIsEqual(suggest, _T(""))); + ok1(StringIsEqual(suggest, "")); - irt.Add(_T("bar"), 1); + irt.Add("bar", 1); ok1(all_sum(irt) == 43); - ok1(prefix_sum(irt, _T("")) == 43); - ok1(prefix_sum(irt, _T("f")) == 42); + ok1(prefix_sum(irt, "") == 43); + ok1(prefix_sum(irt, "f") == 42); - suggest = irt.Suggest(_T(""), buffer, 64); + suggest = irt.Suggest("", buffer, 64); ok1(suggest != NULL); - ok1(StringIsEqual(suggest, _T("bf"))); + ok1(StringIsEqual(suggest, "bf")); - suggest = irt.Suggest(_T("ba"), buffer, 64); + suggest = irt.Suggest("ba", buffer, 64); ok1(suggest != NULL); - ok1(StringIsEqual(suggest, _T("r"))); + ok1(StringIsEqual(suggest, "r")); - irt.Add(_T("foo"), 2); + irt.Add("foo", 2); ok1(all_sum(irt) == 45); - ok1(prefix_sum(irt, _T("")) == 45); - ok1(prefix_sum(irt, _T("f")) == 44); - ok1(prefix_sum(irt, _T("fo")) == 44); - ok1(prefix_sum(irt, _T("foo")) == 44); - ok1(prefix_sum(irt, _T("foobar")) == 0); - - ok1(irt.Get(_T("foo"), 0) == 42 || irt.Get(_T("foo"), 0) == 2); - ok1(irt.GetIf(_T("foo"), 0, [](auto i){ return i == 42; }) == 42); - ok1(irt.GetIf(_T("foo"), 0, [](auto i){ return i == 2; }) == 2); - ok1(irt.GetIf(_T("foo"), 0, [](auto i){ return i == 22; }) == 0); - - suggest = irt.Suggest(_T("foo"), buffer, 64); + ok1(prefix_sum(irt, "") == 45); + ok1(prefix_sum(irt, "f") == 44); + ok1(prefix_sum(irt, "fo") == 44); + ok1(prefix_sum(irt, "foo") == 44); + ok1(prefix_sum(irt, "foobar") == 0); + + ok1(irt.Get("foo", 0) == 42 || irt.Get("foo", 0) == 2); + ok1(irt.GetIf("foo", 0, [](auto i){ return i == 42; }) == 42); + ok1(irt.GetIf("foo", 0, [](auto i){ return i == 2; }) == 2); + ok1(irt.GetIf("foo", 0, [](auto i){ return i == 22; }) == 0); + + suggest = irt.Suggest("foo", buffer, 64); ok1(suggest != NULL); - ok1(StringIsEqual(suggest, _T(""))); + ok1(StringIsEqual(suggest, "")); - irt.Add(_T("baz"), 3); + irt.Add("baz", 3); ok1(all_sum(irt) == 48); - ok1(prefix_sum(irt, _T("b")) == 4); - ok1(prefix_sum(irt, _T("ba")) == 4); - ok1(prefix_sum(irt, _T("bar")) == 1); - ok1(prefix_sum(irt, _T("baz")) == 3); + ok1(prefix_sum(irt, "b") == 4); + ok1(prefix_sum(irt, "ba") == 4); + ok1(prefix_sum(irt, "bar") == 1); + ok1(prefix_sum(irt, "baz") == 3); - suggest = irt.Suggest(_T(""), buffer, 64); + suggest = irt.Suggest("", buffer, 64); ok1(suggest != NULL); - ok1(StringIsEqual(suggest, _T("bf"))); + ok1(StringIsEqual(suggest, "bf")); - suggest = irt.Suggest(_T("ba"), buffer, 64); + suggest = irt.Suggest("ba", buffer, 64); ok1(suggest != NULL); - ok1(StringIsEqual(suggest, _T("rz"))); + ok1(StringIsEqual(suggest, "rz")); - irt.Add(_T("foobar"), 4); + irt.Add("foobar", 4); ok1(all_sum(irt) == 52); - ok1(prefix_sum(irt, _T("f")) == 48); - ok1(prefix_sum(irt, _T("fo")) == 48); - ok1(prefix_sum(irt, _T("foo")) == 48); - ok1(prefix_sum(irt, _T("foobar")) == 4); + ok1(prefix_sum(irt, "f") == 48); + ok1(prefix_sum(irt, "fo") == 48); + ok1(prefix_sum(irt, "foo") == 48); + ok1(prefix_sum(irt, "foobar") == 4); - suggest = irt.Suggest(_T("foo"), buffer, 64); + suggest = irt.Suggest("foo", buffer, 64); ok1(suggest != NULL); - ok1(StringIsEqual(suggest, _T("b"))); + ok1(StringIsEqual(suggest, "b")); - irt.Add(_T("fo"), 5); + irt.Add("fo", 5); ok1(all_sum(irt) == 57); - ok1(prefix_sum(irt, _T("f")) == 53); - ok1(prefix_sum(irt, _T("fo")) == 53); - ok1(prefix_sum(irt, _T("foo")) == 48); - ok1(prefix_sum(irt, _T("foobar")) == 4); + ok1(prefix_sum(irt, "f") == 53); + ok1(prefix_sum(irt, "fo") == 53); + ok1(prefix_sum(irt, "foo") == 48); + ok1(prefix_sum(irt, "foobar") == 4); - irt.Add(_T("fooz"), 6); + irt.Add("fooz", 6); ok1(all_sum(irt) == 63); - ok1(prefix_sum(irt, _T("f")) == 59); - ok1(prefix_sum(irt, _T("fo")) == 59); - ok1(prefix_sum(irt, _T("foo")) == 54); + ok1(prefix_sum(irt, "f") == 59); + ok1(prefix_sum(irt, "fo") == 59); + ok1(prefix_sum(irt, "foo") == 54); - suggest = irt.Suggest(_T("foo"), buffer, 64); + suggest = irt.Suggest("foo", buffer, 64); ok1(suggest != NULL); - ok1(StringIsEqual(suggest, _T("bz"))); + ok1(StringIsEqual(suggest, "bz")); - irt.Add(_T("fooy"), 7); + irt.Add("fooy", 7); ok1(all_sum(irt) == 70); - ok1(prefix_sum(irt, _T("f")) == 66); - ok1(prefix_sum(irt, _T("fo")) == 66); - ok1(prefix_sum(irt, _T("foo")) == 61); + ok1(prefix_sum(irt, "f") == 66); + ok1(prefix_sum(irt, "fo") == 66); + ok1(prefix_sum(irt, "foo") == 61); - suggest = irt.Suggest(_T("foo"), buffer, 64); + suggest = irt.Suggest("foo", buffer, 64); ok1(suggest != NULL); - ok1(StringIsEqual(suggest, _T("byz"))); + ok1(StringIsEqual(suggest, "byz")); - irt.Add(_T("foo"), 8); + irt.Add("foo", 8); ok1(all_sum(irt) == 78); - ok1(prefix_sum(irt, _T("foo")) == 69); + ok1(prefix_sum(irt, "foo") == 69); - irt.Remove(_T("foo"), 42); + irt.Remove("foo", 42); ok1(all_sum(irt) == 36); - ok1(prefix_sum(irt, _T("foo")) == 27); + ok1(prefix_sum(irt, "foo") == 27); - irt.Remove(_T("foo")); + irt.Remove("foo"); ok1(all_sum(irt) == 26); - ok1(prefix_sum(irt, _T("")) == 26); - ok1(prefix_sum(irt, _T("foo")) == 17); + ok1(prefix_sum(irt, "") == 26); + ok1(prefix_sum(irt, "foo") == 17); - irt.Add(_T(""), 9); + irt.Add("", 9); ok1(all_sum(irt) == 35); - ok1(prefix_sum(irt, _T("")) == 35); - ok1(prefix_sum(irt, _T("foo")) == 17); + ok1(prefix_sum(irt, "") == 35); + ok1(prefix_sum(irt, "foo") == 17); check_ascending_keys(irt); diff --git a/test/src/TestStrings.cpp b/test/src/TestStrings.cpp index be4f94055b6..a3a7383c841 100644 --- a/test/src/TestStrings.cpp +++ b/test/src/TestStrings.cpp @@ -24,37 +24,37 @@ int main() ok1(StringIsEqual("This is a funny test case!", "This is a funny test case!")); - ok1(StringIsEqual(_T(""), _T(""))); - ok1(!StringIsEqual(_T("a"), _T(""))); - ok1(!StringIsEqual(_T(""), _T("a"))); - ok1(StringIsEqual(_T("aaa"), _T("aaa"))); - ok1(!StringIsEqual(_T("aaa"), _T("a"))); - ok1(!StringIsEqual(_T("aaa"), _T("bbb"))); - ok1(!StringIsEqual(_T("bbb"), _T("aaa"))); + ok1(StringIsEqual("", "")); + ok1(!StringIsEqual("a", "")); + ok1(!StringIsEqual("", "a")); + ok1(StringIsEqual("aaa", "aaa")); + ok1(!StringIsEqual("aaa", "a")); + ok1(!StringIsEqual("aaa", "bbb")); + ok1(!StringIsEqual("bbb", "aaa")); - ok1(StringIsEqual(_T("This is a funny test case!"), - _T("This is a funny test case!"))); + ok1(StringIsEqual("This is a funny test case!", + "This is a funny test case!")); // Test StringStartsWith() - ok1(StringStartsWith(_T(""), _T(""))); - ok1(StringStartsWith(_T("a"), _T(""))); - ok1(!StringStartsWith(_T(""), _T("a"))); - ok1(StringStartsWith(_T("aaa"), _T("aaa"))); - ok1(StringStartsWith(_T("aaa"), _T("a"))); - ok1(!StringStartsWith(_T("bbb"), _T("aaa"))); + ok1(StringStartsWith("", "")); + ok1(StringStartsWith("a", "")); + ok1(!StringStartsWith("", "a")); + ok1(StringStartsWith("aaa", "aaa")); + ok1(StringStartsWith("aaa", "a")); + ok1(!StringStartsWith("bbb", "aaa")); // Test StringAfterPrefix() - ok1(StringIsEqual(StringAfterPrefix(_T(""), _T("")), _T(""))); - ok1(StringIsEqual(StringAfterPrefix(_T("a"), _T("")), _T("a"))); - ok1(StringAfterPrefix(_T(""), _T("a")) == NULL); - ok1(StringIsEqual(StringAfterPrefix(_T("aaa"), _T("aaa")), _T(""))); - ok1(StringIsEqual(StringAfterPrefix(_T("aaa"), _T("a")), _T("aa"))); - ok1(StringAfterPrefix(_T("bbb"), _T("aaa")) == NULL); - ok1(StringIsEqual(StringAfterPrefix(_T("This is a funny test case!"), - _T("This is")), - _T(" a funny test case!"))); + ok1(StringIsEqual(StringAfterPrefix("", ""), "")); + ok1(StringIsEqual(StringAfterPrefix("a", ""), "a")); + ok1(StringAfterPrefix("", "a") == NULL); + ok1(StringIsEqual(StringAfterPrefix("aaa", "aaa"), "")); + ok1(StringIsEqual(StringAfterPrefix("aaa", "a"), "aa")); + ok1(StringAfterPrefix("bbb", "aaa") == NULL); + ok1(StringIsEqual(StringAfterPrefix("This is a funny test case!", + "This is"), + " a funny test case!")); return exit_status(); } diff --git a/test/src/TestTaskSave.cpp b/test/src/TestTaskSave.cpp index 257a18790f4..bf8b15b1296 100644 --- a/test/src/TestTaskSave.cpp +++ b/test/src/TestTaskSave.cpp @@ -15,7 +15,7 @@ static TaskBehaviour task_behaviour; static OrderedTaskSettings ordered_task_settings; -static constexpr Path task_path{_T("output/results/Test-Task.tsk")}; +static constexpr Path task_path{"output/results/Test-Task.tsk"}; static constexpr GeoPoint MakeGeoPoint(double longitude, double latitude) noexcept @@ -46,9 +46,9 @@ MakeWaypointPtr(Args&&... args) noexcept return WaypointPtr(new Waypoint(MakeWaypoint(std::forward(args)...))); } -static const auto wp1_str = _T("wp-01"); -static const auto wp2_str = _T("wp-02"); -static const auto wp3_str = _T("wp-03"); +static const auto wp1_str = "wp-01"; +static const auto wp2_str = "wp-02"; +static const auto wp3_str = "wp-03"; static const auto wp1 = MakeWaypointPtr(0, 45, 50, wp1_str, 100); static const auto wp2 = MakeWaypointPtr(0, 45.3, 50, wp2_str, 102); @@ -97,7 +97,7 @@ TestAll() int main() { - Directory::Create(Path{_T("output/results")}); + Directory::Create(Path{"output/results"}); plan_tests(10); task_behaviour.SetDefaults(); diff --git a/test/src/TestTaskWaypoint.cpp b/test/src/TestTaskWaypoint.cpp index d9fda957a17..5016bb1a550 100644 --- a/test/src/TestTaskWaypoint.cpp +++ b/test/src/TestTaskWaypoint.cpp @@ -33,14 +33,14 @@ TaskWaypointTest::Run() { GeoPoint gp(Angle::Degrees(20), Angle::Degrees(50)); Waypoint wp(gp); - wp.name = _T("Test"); + wp.name = "Test"; wp.elevation = 42; wp.has_elevation = true; DummyTaskWaypoint tw(TaskPointType::AST, WaypointPtr(new Waypoint(wp))); const Waypoint &wp2 = tw.GetWaypoint(); - ok1(wp2.name == _T("Test")); + ok1(wp2.name == "Test"); ok1(equals(tw.GetBaseElevation(), 42)); ok1(wp2.has_elevation); ok1(equals(tw.GetBaseElevation(), wp2.elevation)); diff --git a/test/src/TestTeamCode.cpp b/test/src/TestTeamCode.cpp index d69ef4edd0b..129c81852c2 100644 --- a/test/src/TestTeamCode.cpp +++ b/test/src/TestTeamCode.cpp @@ -14,22 +14,22 @@ int main() tc.Update(Angle::Degrees(90), 5000); - ok1(StringIsEqual(tc.GetCode(), _T("901E"))); + ok1(StringIsEqual(tc.GetCode(), "901E")); ok1(iround(tc.GetBearing().Degrees()) == 90); ok1(equals(tc.GetRange(), 5000)); tc.Update(Angle::Degrees(359), 25000); - ok1(StringIsEqual(tc.GetCode(), _T("ZW6Y"))); + ok1(StringIsEqual(tc.GetCode(), "ZW6Y")); ok1(iround(tc.GetBearing().Degrees()) == 359); ok1(equals(tc.GetRange(), 25000)); tc.Update(Angle::Degrees(180), 800000); - ok1(StringIsEqual(tc.GetCode(), _T("I0668"))); + ok1(StringIsEqual(tc.GetCode(), "I0668")); ok1(iround(tc.GetBearing().Degrees()) == 180); ok1(equals(tc.GetRange(), 800000)); tc.Update(Angle::Degrees(270), 100); - ok1(StringIsEqual(tc.GetCode(), _T("R01"))); + ok1(StringIsEqual(tc.GetCode(), "R01")); ok1(iround(tc.GetBearing().Degrees()) == 270); ok1(equals(tc.GetRange(), 100)); diff --git a/test/src/TestTimeFormatter.cpp b/test/src/TestTimeFormatter.cpp index bea7c91680a..70267bcbea2 100644 --- a/test/src/TestTimeFormatter.cpp +++ b/test/src/TestTimeFormatter.cpp @@ -12,37 +12,37 @@ TestFormat() char buffer[256]; FormatTime(buffer, FloatDuration{}); - ok1(StringIsEqual(buffer, _T("00:00:00"))); + ok1(StringIsEqual(buffer, "00:00:00")); FormatTime(buffer, std::chrono::seconds{1}); - ok1(StringIsEqual(buffer, _T("00:00:01"))); + ok1(StringIsEqual(buffer, "00:00:01")); FormatTime(buffer, std::chrono::seconds{59}); - ok1(StringIsEqual(buffer, _T("00:00:59"))); + ok1(StringIsEqual(buffer, "00:00:59")); FormatTime(buffer, std::chrono::seconds{60}); - ok1(StringIsEqual(buffer, _T("00:01:00"))); + ok1(StringIsEqual(buffer, "00:01:00")); FormatTime(buffer, std::chrono::seconds{60 * 5}); - ok1(StringIsEqual(buffer, _T("00:05:00"))); + ok1(StringIsEqual(buffer, "00:05:00")); FormatTime(buffer, std::chrono::seconds{60 * 59}); - ok1(StringIsEqual(buffer, _T("00:59:00"))); + ok1(StringIsEqual(buffer, "00:59:00")); FormatTime(buffer, std::chrono::seconds{60 * 60}); - ok1(StringIsEqual(buffer, _T("01:00:00"))); + ok1(StringIsEqual(buffer, "01:00:00")); FormatTime(buffer, std::chrono::seconds{60 * 60 * 3 + 60 * 25}); - ok1(StringIsEqual(buffer, _T("03:25:00"))); + ok1(StringIsEqual(buffer, "03:25:00")); FormatTime(buffer, std::chrono::seconds{60 * 60 * 19 + 60 * 47 + 43}); - ok1(StringIsEqual(buffer, _T("19:47:43"))); + ok1(StringIsEqual(buffer, "19:47:43")); FormatTime(buffer, std::chrono::seconds{-(60 * 59)}); - ok1(StringIsEqual(buffer, _T("-00:59:00"))); + ok1(StringIsEqual(buffer, "-00:59:00")); FormatTime(buffer, std::chrono::seconds{-(60 * 60 * 19 + 60 * 47 + 43)}); - ok1(StringIsEqual(buffer, _T("-19:47:43"))); + ok1(StringIsEqual(buffer, "-19:47:43")); } static void @@ -51,37 +51,37 @@ TestFormatLong() char buffer[256]; FormatTimeLong(buffer, {}); - ok1(StringIsEqual(buffer, _T("00:00:00.000"))); + ok1(StringIsEqual(buffer, "00:00:00.000")); FormatTimeLong(buffer, FloatDuration{1.123}); - ok1(StringIsEqual(buffer, _T("00:00:01.123"))); + ok1(StringIsEqual(buffer, "00:00:01.123")); FormatTimeLong(buffer, std::chrono::seconds{59}); - ok1(StringIsEqual(buffer, _T("00:00:59.000"))); + ok1(StringIsEqual(buffer, "00:00:59.000")); FormatTimeLong(buffer, FloatDuration{60.001}); - ok1(StringIsEqual(buffer, _T("00:01:00.001"))); + ok1(StringIsEqual(buffer, "00:01:00.001")); FormatTimeLong(buffer, std::chrono::seconds{60 * 5}); - ok1(StringIsEqual(buffer, _T("00:05:00.000"))); + ok1(StringIsEqual(buffer, "00:05:00.000")); FormatTimeLong(buffer, std::chrono::seconds{60 * 59}); - ok1(StringIsEqual(buffer, _T("00:59:00.000"))); + ok1(StringIsEqual(buffer, "00:59:00.000")); FormatTimeLong(buffer, std::chrono::seconds{60 * 60}); - ok1(StringIsEqual(buffer, _T("01:00:00.000"))); + ok1(StringIsEqual(buffer, "01:00:00.000")); FormatTimeLong(buffer, std::chrono::seconds{60 * 60 * 3 + 60 * 25}); - ok1(StringIsEqual(buffer, _T("03:25:00.000"))); + ok1(StringIsEqual(buffer, "03:25:00.000")); FormatTimeLong(buffer, FloatDuration{60 * 60 * 19 + 60 * 47 + 43.765}); - ok1(StringIsEqual(buffer, _T("19:47:43.765"))); + ok1(StringIsEqual(buffer, "19:47:43.765")); FormatTimeLong(buffer, std::chrono::seconds{-(60 * 59)}); - ok1(StringIsEqual(buffer, _T("-00:59:00.000"))); + ok1(StringIsEqual(buffer, "-00:59:00.000")); FormatTimeLong(buffer, FloatDuration{-(60 * 60 * 19 + 60 * 47 + 43.765)}); - ok1(StringIsEqual(buffer, _T("-19:47:43.765"))); + ok1(StringIsEqual(buffer, "-19:47:43.765")); } static void @@ -90,37 +90,37 @@ TestHHMM() char buffer[256]; FormatSignedTimeHHMM(buffer, {}); - ok1(StringIsEqual(buffer, _T("00:00"))); + ok1(StringIsEqual(buffer, "00:00")); FormatSignedTimeHHMM(buffer, std::chrono::seconds{1}); - ok1(StringIsEqual(buffer, _T("00:00"))); + ok1(StringIsEqual(buffer, "00:00")); FormatSignedTimeHHMM(buffer, std::chrono::seconds{59}); - ok1(StringIsEqual(buffer, _T("00:00"))); + ok1(StringIsEqual(buffer, "00:00")); FormatSignedTimeHHMM(buffer, std::chrono::seconds{60}); - ok1(StringIsEqual(buffer, _T("00:01"))); + ok1(StringIsEqual(buffer, "00:01")); FormatSignedTimeHHMM(buffer, std::chrono::seconds{60 * 5}); - ok1(StringIsEqual(buffer, _T("00:05"))); + ok1(StringIsEqual(buffer, "00:05")); FormatSignedTimeHHMM(buffer, std::chrono::seconds{60 * 59}); - ok1(StringIsEqual(buffer, _T("00:59"))); + ok1(StringIsEqual(buffer, "00:59")); FormatSignedTimeHHMM(buffer, std::chrono::seconds{60 * 60}); - ok1(StringIsEqual(buffer, _T("01:00"))); + ok1(StringIsEqual(buffer, "01:00")); FormatSignedTimeHHMM(buffer, std::chrono::seconds{60 * 60 * 3 + 60 * 25}); - ok1(StringIsEqual(buffer, _T("03:25"))); + ok1(StringIsEqual(buffer, "03:25")); FormatSignedTimeHHMM(buffer, std::chrono::seconds{60 * 60 * 19 + 60 * 47}); - ok1(StringIsEqual(buffer, _T("19:47"))); + ok1(StringIsEqual(buffer, "19:47")); FormatSignedTimeHHMM(buffer, std::chrono::seconds{-(60 * 59)}); - ok1(StringIsEqual(buffer, _T("-00:59"))); + ok1(StringIsEqual(buffer, "-00:59")); FormatSignedTimeHHMM(buffer, std::chrono::seconds{-(60 * 60 * 19 + 60 * 47)}); - ok1(StringIsEqual(buffer, _T("-19:47"))); + ok1(StringIsEqual(buffer, "-19:47")); } #include @@ -131,54 +131,54 @@ TestTwoLines() char buffer[256], buffer2[256]; FormatTimeTwoLines(buffer, buffer2, {}); - ok1(StringIsEqual(buffer, _T("00'00"))); - ok1(StringIsEqual(buffer2, _T(""))); + ok1(StringIsEqual(buffer, "00'00")); + ok1(StringIsEqual(buffer2, "")); FormatTimeTwoLines(buffer, buffer2, std::chrono::seconds{1}); - ok1(StringIsEqual(buffer, _T("00'01"))); - ok1(StringIsEqual(buffer2, _T(""))); + ok1(StringIsEqual(buffer, "00'01")); + ok1(StringIsEqual(buffer2, "")); FormatTimeTwoLines(buffer, buffer2, std::chrono::seconds{59}); - ok1(StringIsEqual(buffer, _T("00'59"))); - ok1(StringIsEqual(buffer2, _T(""))); + ok1(StringIsEqual(buffer, "00'59")); + ok1(StringIsEqual(buffer2, "")); FormatTimeTwoLines(buffer, buffer2, std::chrono::seconds{60}); - ok1(StringIsEqual(buffer, _T("01'00"))); - ok1(StringIsEqual(buffer2, _T(""))); + ok1(StringIsEqual(buffer, "01'00")); + ok1(StringIsEqual(buffer2, "")); FormatTimeTwoLines(buffer, buffer2, std::chrono::seconds{60 * 5}); - ok1(StringIsEqual(buffer, _T("05'00"))); - ok1(StringIsEqual(buffer2, _T(""))); + ok1(StringIsEqual(buffer, "05'00")); + ok1(StringIsEqual(buffer2, "")); FormatTimeTwoLines(buffer, buffer2, std::chrono::seconds{60 * 59}); - ok1(StringIsEqual(buffer, _T("59'00"))); - ok1(StringIsEqual(buffer2, _T(""))); + ok1(StringIsEqual(buffer, "59'00")); + ok1(StringIsEqual(buffer2, "")); FormatTimeTwoLines(buffer, buffer2, std::chrono::seconds{60 * 60}); - ok1(StringIsEqual(buffer, _T("01:00"))); - ok1(StringIsEqual(buffer2, _T("00"))); + ok1(StringIsEqual(buffer, "01:00")); + ok1(StringIsEqual(buffer2, "00")); FormatTimeTwoLines(buffer, buffer2, std::chrono::seconds{60 * 60 * 3 + 60 * 25 + 13}); - ok1(StringIsEqual(buffer, _T("03:25"))); - ok1(StringIsEqual(buffer2, _T("13"))); + ok1(StringIsEqual(buffer, "03:25")); + ok1(StringIsEqual(buffer2, "13")); FormatTimeTwoLines(buffer, buffer2, std::chrono::seconds{60 * 60 * 19 + 60 * 47 + 28}); - ok1(StringIsEqual(buffer, _T("19:47"))); - ok1(StringIsEqual(buffer2, _T("28"))); + ok1(StringIsEqual(buffer, "19:47")); + ok1(StringIsEqual(buffer2, "28")); FormatTimeTwoLines(buffer, buffer2, std::chrono::seconds{-(60 * 59)}); - ok1(StringIsEqual(buffer, _T("-59'00"))); - ok1(StringIsEqual(buffer2, _T(""))); + ok1(StringIsEqual(buffer, "-59'00")); + ok1(StringIsEqual(buffer2, "")); FormatTimeTwoLines(buffer, buffer2, std::chrono::seconds{-(60 * 60 * 19 + 60 * 47 + 28)}); - ok1(StringIsEqual(buffer, _T("-19:47"))); - ok1(StringIsEqual(buffer2, _T("28"))); + ok1(StringIsEqual(buffer, "-19:47")); + ok1(StringIsEqual(buffer2, "28")); } static void TestSmart(int _time, const char *expected_output1, const char *expected_output2, const char *expected_output3, - const char *expected_output4, const char *separator = _T(" ")) + const char *expected_output4, const char *separator = " ") { char buffer[256]; @@ -200,39 +200,39 @@ TestSmart(int _time, const char *expected_output1, static void TestSmart() { - TestSmart(0, _T("0 sec"), _T("0 sec"), _T("0 sec"), _T("0 sec")); - TestSmart(1, _T("1 sec"), _T("1 sec"), _T("1 sec"), _T("1 sec")); - TestSmart(59, _T("59 sec"), _T("59 sec"), _T("59 sec"), _T("59 sec")); - TestSmart(60, _T("1 min"), _T("1 min"), _T("1 min"), _T("1 min")); + TestSmart(0, "0 sec", "0 sec", "0 sec", "0 sec"); + TestSmart(1, "1 sec", "1 sec", "1 sec", "1 sec"); + TestSmart(59, "59 sec", "59 sec", "59 sec", "59 sec"); + TestSmart(60, "1 min", "1 min", "1 min", "1 min"); - TestSmart(60 + 59, _T("1 min"), _T("1 min 59 sec"), _T("1 min 59 sec"), - _T("1 min 59 sec")); + TestSmart(60 + 59, "1 min", "1 min 59 sec", "1 min 59 sec", + "1 min 59 sec"); - TestSmart(60 * 5 + 34, _T("5 min"), _T("5 min 34 sec"), _T("5 min 34 sec"), - _T("5 min 34 sec")); + TestSmart(60 * 5 + 34, "5 min", "5 min 34 sec", "5 min 34 sec", + "5 min 34 sec"); - TestSmart(60 * 59, _T("59 min"), _T("59 min"), _T("59 min"), _T("59 min")); - TestSmart(60 * 60, _T("1 h"), _T("1 h"), _T("1 h"), _T("1 h")); + TestSmart(60 * 59, "59 min", "59 min", "59 min", "59 min"); + TestSmart(60 * 60, "1 h", "1 h", "1 h", "1 h"); - TestSmart(60 * 60 * 3 + 60 * 25, _T("3 h"), _T("3 h 25 min"), - _T("3 h 25 min"), _T("3 h 25 min")); + TestSmart(60 * 60 * 3 + 60 * 25, "3 h", "3 h 25 min", + "3 h 25 min", "3 h 25 min"); - TestSmart(60 * 60 * 19 + 60 * 47, _T("19 h"), _T("19 h 47 min"), - _T("19 h 47 min"), _T("19 h 47 min")); + TestSmart(60 * 60 * 19 + 60 * 47, "19 h", "19 h 47 min", + "19 h 47 min", "19 h 47 min"); - TestSmart(60 * 60 * 19 + 47, _T("19 h"), _T("19 h"), - _T("19 h 0 min 47 sec"), _T("19 h 0 min 47 sec")); + TestSmart(60 * 60 * 19 + 47, "19 h", "19 h", + "19 h 0 min 47 sec", "19 h 0 min 47 sec"); - TestSmart(60 * 60 * 19 + 60 * 47 + 5, _T("19 h"), _T("19 h 47 min"), - _T("19 h 47 min 5 sec"), _T("19 h 47 min 5 sec")); + TestSmart(60 * 60 * 19 + 60 * 47 + 5, "19 h", "19 h 47 min", + "19 h 47 min 5 sec", "19 h 47 min 5 sec"); - TestSmart(60 * 60 * 24 * 3 + 60 * 60 * 19 + 60 * 47 + 5, _T("3 days"), - _T("3 days 19 h"), _T("3 days 19 h 47 min"), - _T("3 days 19 h 47 min 5 sec")); + TestSmart(60 * 60 * 24 * 3 + 60 * 60 * 19 + 60 * 47 + 5, "3 days", + "3 days 19 h", "3 days 19 h 47 min", + "3 days 19 h 47 min 5 sec"); - TestSmart(-(60 * 60 * 24 * 3 + 60 * 60 * 19 + 60 * 47 + 5), _T("-3 days"), - _T("-3 days 19 h"), _T("-3 days 19 h 47 min"), - _T("-3 days 19 h 47 min 5 sec")); + TestSmart(-(60 * 60 * 24 * 3 + 60 * 60 * 19 + 60 * 47 + 5), "-3 days", + "-3 days 19 h", "-3 days 19 h 47 min", + "-3 days 19 h 47 min 5 sec"); } int main() diff --git a/test/src/TestTrace.cpp b/test/src/TestTrace.cpp index 7168d5bb84d..e7849bcbfc6 100644 --- a/test/src/TestTrace.cpp +++ b/test/src/TestTrace.cpp @@ -78,7 +78,7 @@ try { if (argc > 1) { n = atoi(argv[1]); } - TestTrace(Path(_T("test/data/09kc3ov3.igc")), n); + TestTrace(Path("test/data/09kc3ov3.igc"), n); } else { assert(argc >= 3); unsigned n = atoi(argv[2]); diff --git a/test/src/TestTransponderCode.cpp b/test/src/TestTransponderCode.cpp index 85dfebc6061..2771fb3d264 100644 --- a/test/src/TestTransponderCode.cpp +++ b/test/src/TestTransponderCode.cpp @@ -13,14 +13,14 @@ int main() { plan_tests(13); - ok1(TransponderCode::Parse(_T("7000")).IsDefined()); + ok1(TransponderCode::Parse("7000").IsDefined()); ok1(TransponderCode{07000}.IsDefined()); ok1(equals(TransponderCode().GetCode(), 0)); - ok1(!TransponderCode::Parse(_T("7797")).IsDefined()); + ok1(!TransponderCode::Parse("7797").IsDefined()); ok1(!TransponderCode{7797}.IsDefined()); ok1(!TransponderCode::Null().IsDefined()); - ok1(!TransponderCode::Parse(_T("20000")).IsDefined()); + ok1(!TransponderCode::Parse("20000").IsDefined()); ok1(!TransponderCode{20000}.IsDefined()); TransponderCode code{04567}; @@ -28,13 +28,13 @@ int main() char buf[12]; ok1(StringIsEqual(code.Format(buf, std::size(buf)), - _T("4567"))); + "4567")); code.Clear(); ok1(!code.IsDefined()); ok1(code.Format(buf, std::size(buf)) == nullptr); - code = TransponderCode::Parse(_T("4567")); + code = TransponderCode::Parse("4567"); ok1(code.IsDefined()); return exit_status(); diff --git a/test/src/TestUnitsFormatter.cpp b/test/src/TestUnitsFormatter.cpp index a6b91be91df..ee1314c92ad 100644 --- a/test/src/TestUnitsFormatter.cpp +++ b/test/src/TestUnitsFormatter.cpp @@ -16,22 +16,22 @@ TestAltitude() // Test FormatAltitude() FormatAltitude(buffer, 1234, Unit::METER); - ok1(StringIsEqual(buffer, _T("1234 m"))); + ok1(StringIsEqual(buffer, "1234 m")); FormatAltitude(buffer, Units::ToSysUnit(1234, Unit::FEET), Unit::FEET); - ok1(StringIsEqual(buffer, _T("1234 ft"))); + ok1(StringIsEqual(buffer, "1234 ft")); FormatAltitude(buffer, -1234, Unit::METER); - ok1(StringIsEqual(buffer, _T("-1234 m"))); + ok1(StringIsEqual(buffer, "-1234 m")); FormatAltitude(buffer, Units::ToSysUnit(-1234, Unit::FEET), Unit::FEET); - ok1(StringIsEqual(buffer, _T("-1234 ft"))); + ok1(StringIsEqual(buffer, "-1234 ft")); FormatAltitude(buffer, 1234, Unit::METER, false); - ok1(StringIsEqual(buffer, _T("1234"))); + ok1(StringIsEqual(buffer, "1234")); FormatAltitude(buffer, -1234, Unit::METER, false); - ok1(StringIsEqual(buffer, _T("-1234"))); + ok1(StringIsEqual(buffer, "-1234")); } static void @@ -41,24 +41,24 @@ TestRelativeAltitude() // Test FormatRelativeAltitude() FormatRelativeAltitude(buffer, 1234, Unit::METER); - ok1(StringIsEqual(buffer, _T("+1234 m"))); + ok1(StringIsEqual(buffer, "+1234 m")); FormatRelativeAltitude(buffer, Units::ToSysUnit(1234, Unit::FEET), Unit::FEET); - ok1(StringIsEqual(buffer, _T("+1234 ft"))); + ok1(StringIsEqual(buffer, "+1234 ft")); FormatRelativeAltitude(buffer, -1234, Unit::METER); - ok1(StringIsEqual(buffer, _T("-1234 m"))); + ok1(StringIsEqual(buffer, "-1234 m")); FormatRelativeAltitude(buffer, Units::ToSysUnit(-1234, Unit::FEET), Unit::FEET); - ok1(StringIsEqual(buffer, _T("-1234 ft"))); + ok1(StringIsEqual(buffer, "-1234 ft")); FormatRelativeAltitude(buffer, 1234, Unit::METER, false); - ok1(StringIsEqual(buffer, _T("+1234"))); + ok1(StringIsEqual(buffer, "+1234")); FormatRelativeAltitude(buffer, -1234, Unit::METER, false); - ok1(StringIsEqual(buffer, _T("-1234"))); + ok1(StringIsEqual(buffer, "-1234")); } static void @@ -68,70 +68,70 @@ TestDistance() // Test FormatDistance() FormatDistance(buffer, 123.4, Unit::METER); - ok1(StringIsEqual(buffer, _T("123 m"))); + ok1(StringIsEqual(buffer, "123 m")); FormatDistance(buffer, 123.4, Unit::METER, false); - ok1(StringIsEqual(buffer, _T("123"))); + ok1(StringIsEqual(buffer, "123")); FormatDistance(buffer, 123.4, Unit::METER, true, 1); - ok1(StringIsEqual(buffer, _T("123.4 m"))); + ok1(StringIsEqual(buffer, "123.4 m")); FormatDistance(buffer, 123.4, Unit::METER, false, 1); - ok1(StringIsEqual(buffer, _T("123.4"))); + ok1(StringIsEqual(buffer, "123.4")); FormatDistance(buffer, 123.4, Unit::METER, true, 2); - ok1(StringIsEqual(buffer, _T("123.40 m"))); + ok1(StringIsEqual(buffer, "123.40 m")); FormatDistance(buffer, 123.4, Unit::METER, false, 2); - ok1(StringIsEqual(buffer, _T("123.40"))); + ok1(StringIsEqual(buffer, "123.40")); FormatDistance(buffer, Units::ToSysUnit(123.4, Unit::KILOMETER), Unit::KILOMETER); - ok1(StringIsEqual(buffer, _T("123 km"))); + ok1(StringIsEqual(buffer, "123 km")); FormatDistance(buffer, Units::ToSysUnit(123.4, Unit::KILOMETER), Unit::KILOMETER, false); - ok1(StringIsEqual(buffer, _T("123"))); + ok1(StringIsEqual(buffer, "123")); FormatDistance(buffer, Units::ToSysUnit(123.4, Unit::KILOMETER), Unit::KILOMETER, true, 1); - ok1(StringIsEqual(buffer, _T("123.4 km"))); + ok1(StringIsEqual(buffer, "123.4 km")); FormatDistance(buffer, Units::ToSysUnit(123.4, Unit::KILOMETER), Unit::KILOMETER, false, 1); - ok1(StringIsEqual(buffer, _T("123.4"))); + ok1(StringIsEqual(buffer, "123.4")); FormatDistance(buffer, Units::ToSysUnit(123.4, Unit::NAUTICAL_MILES), Unit::NAUTICAL_MILES); - ok1(StringIsEqual(buffer, _T("123 NM"))); + ok1(StringIsEqual(buffer, "123 NM")); FormatDistance(buffer, Units::ToSysUnit(123.4, Unit::NAUTICAL_MILES), Unit::NAUTICAL_MILES, false); - ok1(StringIsEqual(buffer, _T("123"))); + ok1(StringIsEqual(buffer, "123")); FormatDistance(buffer, Units::ToSysUnit(123.4, Unit::NAUTICAL_MILES), Unit::NAUTICAL_MILES, true, 1); - ok1(StringIsEqual(buffer, _T("123.4 NM"))); + ok1(StringIsEqual(buffer, "123.4 NM")); FormatDistance(buffer, Units::ToSysUnit(123.4, Unit::NAUTICAL_MILES), Unit::NAUTICAL_MILES, false, 1); - ok1(StringIsEqual(buffer, _T("123.4"))); + ok1(StringIsEqual(buffer, "123.4")); FormatDistance(buffer, Units::ToSysUnit(123.4, Unit::STATUTE_MILES), Unit::STATUTE_MILES); - ok1(StringIsEqual(buffer, _T("123 mi"))); + ok1(StringIsEqual(buffer, "123 mi")); FormatDistance(buffer, Units::ToSysUnit(123.4, Unit::STATUTE_MILES), Unit::STATUTE_MILES, false); - ok1(StringIsEqual(buffer, _T("123"))); + ok1(StringIsEqual(buffer, "123")); FormatDistance(buffer, Units::ToSysUnit(123.4, Unit::STATUTE_MILES), Unit::STATUTE_MILES, true, 1); - ok1(StringIsEqual(buffer, _T("123.4 mi"))); + ok1(StringIsEqual(buffer, "123.4 mi")); FormatDistance(buffer, Units::ToSysUnit(123.4, Unit::STATUTE_MILES), Unit::STATUTE_MILES, false, 1); - ok1(StringIsEqual(buffer, _T("123.4"))); + ok1(StringIsEqual(buffer, "123.4")); } static void @@ -141,66 +141,66 @@ TestSmallDistance() // Test FormatSmallDistance() FormatSmallDistance(buffer, 123.4, Unit::METER); - ok1(StringIsEqual(buffer, _T("123 m"))); + ok1(StringIsEqual(buffer, "123 m")); FormatSmallDistance(buffer, 123.4, Unit::METER, false); - ok1(StringIsEqual(buffer, _T("123"))); + ok1(StringIsEqual(buffer, "123")); FormatSmallDistance(buffer, 123.4, Unit::METER, true, 1); - ok1(StringIsEqual(buffer, _T("123.4 m"))); + ok1(StringIsEqual(buffer, "123.4 m")); FormatSmallDistance(buffer, 123.4, Unit::METER, false, 1); - ok1(StringIsEqual(buffer, _T("123.4"))); + ok1(StringIsEqual(buffer, "123.4")); FormatSmallDistance(buffer, 123.4, Unit::METER, true, 2); - ok1(StringIsEqual(buffer, _T("123.40 m"))); + ok1(StringIsEqual(buffer, "123.40 m")); FormatSmallDistance(buffer, 123.4, Unit::METER, false, 2); - ok1(StringIsEqual(buffer, _T("123.40"))); + ok1(StringIsEqual(buffer, "123.40")); FormatSmallDistance(buffer, 123.4, Unit::KILOMETER); - ok1(StringIsEqual(buffer, _T("123 m"))); + ok1(StringIsEqual(buffer, "123 m")); FormatSmallDistance(buffer, 123.4, Unit::KILOMETER, false); - ok1(StringIsEqual(buffer, _T("123"))); + ok1(StringIsEqual(buffer, "123")); FormatSmallDistance(buffer, 123.4, Unit::KILOMETER, true, 1); - ok1(StringIsEqual(buffer, _T("123.4 m"))); + ok1(StringIsEqual(buffer, "123.4 m")); FormatSmallDistance(buffer, 123.4, Unit::KILOMETER, false, 1); - ok1(StringIsEqual(buffer, _T("123.4"))); + ok1(StringIsEqual(buffer, "123.4")); FormatSmallDistance(buffer, Units::ToSysUnit(123.4, Unit::FEET), Unit::NAUTICAL_MILES); - ok1(StringIsEqual(buffer, _T("123 ft"))); + ok1(StringIsEqual(buffer, "123 ft")); FormatSmallDistance(buffer, Units::ToSysUnit(123.4, Unit::FEET), Unit::NAUTICAL_MILES, false); - ok1(StringIsEqual(buffer, _T("123"))); + ok1(StringIsEqual(buffer, "123")); FormatSmallDistance(buffer, Units::ToSysUnit(123.4, Unit::FEET), Unit::NAUTICAL_MILES, true, 1); - ok1(StringIsEqual(buffer, _T("123.4 ft"))); + ok1(StringIsEqual(buffer, "123.4 ft")); FormatSmallDistance(buffer, Units::ToSysUnit(123.4, Unit::FEET), Unit::NAUTICAL_MILES, false, 1); - ok1(StringIsEqual(buffer, _T("123.4"))); + ok1(StringIsEqual(buffer, "123.4")); FormatSmallDistance(buffer, Units::ToSysUnit(123.4, Unit::FEET), Unit::STATUTE_MILES); - ok1(StringIsEqual(buffer, _T("123 ft"))); + ok1(StringIsEqual(buffer, "123 ft")); FormatSmallDistance(buffer, Units::ToSysUnit(123.4, Unit::FEET), Unit::STATUTE_MILES, false); - ok1(StringIsEqual(buffer, _T("123"))); + ok1(StringIsEqual(buffer, "123")); FormatSmallDistance(buffer, Units::ToSysUnit(123.4, Unit::FEET), Unit::STATUTE_MILES, true, 1); - ok1(StringIsEqual(buffer, _T("123.4 ft"))); + ok1(StringIsEqual(buffer, "123.4 ft")); FormatSmallDistance(buffer, Units::ToSysUnit(123.4, Unit::FEET), Unit::STATUTE_MILES, false, 1); - ok1(StringIsEqual(buffer, _T("123.4"))); + ok1(StringIsEqual(buffer, "123.4")); } static void @@ -227,114 +227,114 @@ TestDistanceSmart() // Test FormatDistanceSmart() // Test Meter - TestDistanceSmart(0.1234, Unit::METER, Unit::METER, _T("0.12 m"), - _T("0.12")); + TestDistanceSmart(0.1234, Unit::METER, Unit::METER, "0.12 m", + "0.12"); - TestDistanceSmart(1.234, Unit::METER, Unit::METER, _T("1.23 m"), - _T("1.23")); + TestDistanceSmart(1.234, Unit::METER, Unit::METER, "1.23 m", + "1.23"); - TestDistanceSmart(12.34, Unit::METER, Unit::METER, _T("12.3 m"), - _T("12.3")); + TestDistanceSmart(12.34, Unit::METER, Unit::METER, "12.3 m", + "12.3"); - TestDistanceSmart(123.4, Unit::METER, Unit::METER, _T("123 m"), - _T("123")); + TestDistanceSmart(123.4, Unit::METER, Unit::METER, "123 m", + "123"); - TestDistanceSmart(1234, Unit::METER, Unit::METER, _T("1234 m"), - _T("1234")); + TestDistanceSmart(1234, Unit::METER, Unit::METER, "1234 m", + "1234"); - TestDistanceSmart(12345, Unit::METER, Unit::METER, _T("12345 m"), - _T("12345")); + TestDistanceSmart(12345, Unit::METER, Unit::METER, "12345 m", + "12345"); - TestDistanceSmart(123456, Unit::METER, Unit::METER, _T("123456 m"), - _T("123456")); + TestDistanceSmart(123456, Unit::METER, Unit::METER, "123456 m", + "123456"); // Test Kilometer TestDistanceSmart(Units::ToSysUnit(0.1234, Unit::KILOMETER), - Unit::KILOMETER, Unit::METER, _T("123 m"), _T("123")); + Unit::KILOMETER, Unit::METER, "123 m", "123"); TestDistanceSmart(Units::ToSysUnit(1.234, Unit::KILOMETER), - Unit::KILOMETER, Unit::METER, _T("1234 m"), _T("1234")); + Unit::KILOMETER, Unit::METER, "1234 m", "1234"); TestDistanceSmart(Units::ToSysUnit(2.345, Unit::KILOMETER), - Unit::KILOMETER, Unit::METER, _T("2345 m"), _T("2345")); + Unit::KILOMETER, Unit::METER, "2345 m", "2345"); TestDistanceSmart(Units::ToSysUnit(2.634, Unit::KILOMETER), - Unit::KILOMETER, Unit::KILOMETER, _T("2.63 km"), - _T("2.63")); + Unit::KILOMETER, Unit::KILOMETER, "2.63 km", + "2.63"); TestDistanceSmart(Units::ToSysUnit(12.34, Unit::KILOMETER), - Unit::KILOMETER, Unit::KILOMETER, _T("12.3 km"), - _T("12.3")); + Unit::KILOMETER, Unit::KILOMETER, "12.3 km", + "12.3"); TestDistanceSmart(Units::ToSysUnit(123.4, Unit::KILOMETER), - Unit::KILOMETER, Unit::KILOMETER, _T("123 km"), _T("123")); + Unit::KILOMETER, Unit::KILOMETER, "123 km", "123"); // Test Nautical Miles TestDistanceSmart(Units::ToSysUnit(123.4, Unit::FEET), - Unit::NAUTICAL_MILES, Unit::FEET, _T("123 ft"), _T("123")); + Unit::NAUTICAL_MILES, Unit::FEET, "123 ft", "123"); TestDistanceSmart(Units::ToSysUnit(1234, Unit::FEET), - Unit::NAUTICAL_MILES, Unit::FEET, _T("1234 ft"), - _T("1234")); + Unit::NAUTICAL_MILES, Unit::FEET, "1234 ft", + "1234"); TestDistanceSmart(Units::ToSysUnit(2345, Unit::FEET), - Unit::NAUTICAL_MILES, Unit::FEET, _T("2345 ft"), - _T("2345")); + Unit::NAUTICAL_MILES, Unit::FEET, "2345 ft", + "2345"); TestDistanceSmart(Units::ToSysUnit(0.61, Unit::NAUTICAL_MILES), - Unit::NAUTICAL_MILES, Unit::NAUTICAL_MILES, _T("0.61 NM"), - _T("0.61")); + Unit::NAUTICAL_MILES, Unit::NAUTICAL_MILES, "0.61 NM", + "0.61"); TestDistanceSmart(Units::ToSysUnit(1.234, Unit::NAUTICAL_MILES), - Unit::NAUTICAL_MILES, Unit::NAUTICAL_MILES, _T("1.23 NM"), - _T("1.23")); + Unit::NAUTICAL_MILES, Unit::NAUTICAL_MILES, "1.23 NM", + "1.23"); TestDistanceSmart(Units::ToSysUnit(12.34, Unit::NAUTICAL_MILES), - Unit::NAUTICAL_MILES, Unit::NAUTICAL_MILES, _T("12.3 NM"), - _T("12.3")); + Unit::NAUTICAL_MILES, Unit::NAUTICAL_MILES, "12.3 NM", + "12.3"); TestDistanceSmart(Units::ToSysUnit(123.4, Unit::NAUTICAL_MILES), - Unit::NAUTICAL_MILES, Unit::NAUTICAL_MILES, _T("123 NM"), - _T("123")); + Unit::NAUTICAL_MILES, Unit::NAUTICAL_MILES, "123 NM", + "123"); // Test Statute Miles TestDistanceSmart(Units::ToSysUnit(123.4, Unit::FEET), - Unit::STATUTE_MILES, Unit::FEET, _T("123 ft"), _T("123")); + Unit::STATUTE_MILES, Unit::FEET, "123 ft", "123"); TestDistanceSmart(Units::ToSysUnit(1234, Unit::FEET), - Unit::STATUTE_MILES, Unit::FEET, _T("1234 ft"), _T("1234")); + Unit::STATUTE_MILES, Unit::FEET, "1234 ft", "1234"); TestDistanceSmart(Units::ToSysUnit(2345, Unit::FEET), - Unit::STATUTE_MILES, Unit::FEET, _T("2345 ft"), _T("2345")); + Unit::STATUTE_MILES, Unit::FEET, "2345 ft", "2345"); TestDistanceSmart(Units::ToSysUnit(0.71, Unit::STATUTE_MILES), - Unit::STATUTE_MILES, Unit::STATUTE_MILES, _T("0.71 mi"), - _T("0.71")); + Unit::STATUTE_MILES, Unit::STATUTE_MILES, "0.71 mi", + "0.71"); TestDistanceSmart(Units::ToSysUnit(1.234, Unit::STATUTE_MILES), - Unit::STATUTE_MILES, Unit::STATUTE_MILES, _T("1.23 mi"), - _T("1.23")); + Unit::STATUTE_MILES, Unit::STATUTE_MILES, "1.23 mi", + "1.23"); TestDistanceSmart(Units::ToSysUnit(12.34, Unit::STATUTE_MILES), - Unit::STATUTE_MILES, Unit::STATUTE_MILES, _T("12.3 mi"), - _T("12.3")); + Unit::STATUTE_MILES, Unit::STATUTE_MILES, "12.3 mi", + "12.3"); TestDistanceSmart(Units::ToSysUnit(123.4, Unit::STATUTE_MILES), - Unit::STATUTE_MILES, Unit::STATUTE_MILES, _T("123 mi"), - _T("123")); + Unit::STATUTE_MILES, Unit::STATUTE_MILES, "123 mi", + "123"); // Test thresholds TestDistanceSmart(Units::ToSysUnit(0.9, Unit::KILOMETER), - Unit::KILOMETER, Unit::METER, _T("900 m"), _T("900"), 1000); + Unit::KILOMETER, Unit::METER, "900 m", "900", 1000); TestDistanceSmart(Units::ToSysUnit(1.1, Unit::KILOMETER), - Unit::KILOMETER, Unit::KILOMETER, _T("1.10 km"), _T("1.10"), 1000); + Unit::KILOMETER, Unit::KILOMETER, "1.10 km", "1.10", 1000); TestDistanceSmart(Units::ToSysUnit(1.1, Unit::KILOMETER), - Unit::KILOMETER, Unit::KILOMETER, _T("1.1 km"), _T("1.1"), 1000, 10); + Unit::KILOMETER, Unit::KILOMETER, "1.1 km", "1.1", 1000, 10); TestDistanceSmart(Units::ToSysUnit(1.1, Unit::KILOMETER), - Unit::KILOMETER, Unit::KILOMETER, _T("1 km"), _T("1"), 1000, 1); + Unit::KILOMETER, Unit::KILOMETER, "1 km", "1", 1000, 1); } @@ -345,55 +345,55 @@ TestSpeed() // Test FormatSpeed() FormatSpeed(buffer, 23.46, Unit::METER_PER_SECOND); - ok1(StringIsEqual(buffer, _T("23 m/s"))); + ok1(StringIsEqual(buffer, "23 m/s")); FormatSpeed(buffer, 23.46, Unit::METER_PER_SECOND, true, true); - ok1(StringIsEqual(buffer, _T("23.5 m/s"))); + ok1(StringIsEqual(buffer, "23.5 m/s")); FormatSpeed(buffer, 23.46, Unit::METER_PER_SECOND, false); - ok1(StringIsEqual(buffer, _T("23"))); + ok1(StringIsEqual(buffer, "23")); FormatSpeed(buffer, 23.46, Unit::METER_PER_SECOND, false, true); - ok1(StringIsEqual(buffer, _T("23.5"))); + ok1(StringIsEqual(buffer, "23.5")); FormatSpeed(buffer, Units::ToSysUnit(123.43, Unit::KILOMETER_PER_HOUR), Unit::KILOMETER_PER_HOUR); - ok1(StringIsEqual(buffer, _T("123 km/h"))); + ok1(StringIsEqual(buffer, "123 km/h")); FormatSpeed(buffer, Units::ToSysUnit(123.43, Unit::KILOMETER_PER_HOUR), Unit::KILOMETER_PER_HOUR, true, true); - ok1(StringIsEqual(buffer, _T("123 km/h"))); + ok1(StringIsEqual(buffer, "123 km/h")); FormatSpeed(buffer, Units::ToSysUnit(83.43, Unit::KILOMETER_PER_HOUR), Unit::KILOMETER_PER_HOUR, true, true); - ok1(StringIsEqual(buffer, _T("83.4 km/h"))); + ok1(StringIsEqual(buffer, "83.4 km/h")); FormatSpeed(buffer, Units::ToSysUnit(123.43, Unit::KNOTS), Unit::KNOTS); - ok1(StringIsEqual(buffer, _T("123 kt"))); + ok1(StringIsEqual(buffer, "123 kt")); FormatSpeed(buffer, Units::ToSysUnit(123.43, Unit::KNOTS), Unit::KNOTS, true, true); - ok1(StringIsEqual(buffer, _T("123 kt"))); + ok1(StringIsEqual(buffer, "123 kt")); FormatSpeed(buffer, Units::ToSysUnit(83.43, Unit::KNOTS), Unit::KNOTS, true, true); - ok1(StringIsEqual(buffer, _T("83.4 kt"))); + ok1(StringIsEqual(buffer, "83.4 kt")); FormatSpeed(buffer, Units::ToSysUnit(123.43, Unit::STATUTE_MILES_PER_HOUR), Unit::STATUTE_MILES_PER_HOUR); - ok1(StringIsEqual(buffer, _T("123 mph"))); + ok1(StringIsEqual(buffer, "123 mph")); FormatSpeed(buffer, Units::ToSysUnit(123.43, Unit::STATUTE_MILES_PER_HOUR), Unit::STATUTE_MILES_PER_HOUR, true, true); - ok1(StringIsEqual(buffer, _T("123 mph"))); + ok1(StringIsEqual(buffer, "123 mph")); FormatSpeed(buffer, Units::ToSysUnit(83.43, Unit::STATUTE_MILES_PER_HOUR), Unit::STATUTE_MILES_PER_HOUR, true, true); - ok1(StringIsEqual(buffer, _T("83.4 mph"))); + ok1(StringIsEqual(buffer, "83.4 mph")); } static void @@ -403,28 +403,28 @@ TestVerticalSpeed() // Test FormatVerticalSpeed() FormatVerticalSpeed(buffer, 1.42, Unit::METER_PER_SECOND); - ok1(StringIsEqual(buffer, _T("+1.4 m/s"))); + ok1(StringIsEqual(buffer, "+1.4 m/s")); FormatVerticalSpeed(buffer, 1.42, Unit::METER_PER_SECOND, false); - ok1(StringIsEqual(buffer, _T("+1.4"))); + ok1(StringIsEqual(buffer, "+1.4")); FormatVerticalSpeed(buffer, Units::ToSysUnit(2.47, Unit::KNOTS), Unit::KNOTS); - ok1(StringIsEqual(buffer, _T("+2.5 kt"))); + ok1(StringIsEqual(buffer, "+2.5 kt")); FormatVerticalSpeed(buffer, Units::ToSysUnit(2.47, Unit::KNOTS), Unit::KNOTS, false); - ok1(StringIsEqual(buffer, _T("+2.5"))); + ok1(StringIsEqual(buffer, "+2.5")); FormatVerticalSpeed(buffer, Units::ToSysUnit(245.4, Unit::FEET_PER_MINUTE), Unit::FEET_PER_MINUTE); - ok1(StringIsEqual(buffer, _T("+245 fpm"))); + ok1(StringIsEqual(buffer, "+245 fpm")); FormatVerticalSpeed(buffer, Units::ToSysUnit(245.4, Unit::FEET_PER_MINUTE), Unit::FEET_PER_MINUTE, false); - ok1(StringIsEqual(buffer, _T("+245"))); + ok1(StringIsEqual(buffer, "+245")); } static void @@ -434,30 +434,30 @@ TestTemperature() // Test FormatTemperature() FormatTemperature(buffer, 293.93, Unit::KELVIN); - ok1(StringIsEqual(buffer, _T("294 K"))); + ok1(StringIsEqual(buffer, "294 K")); FormatTemperature(buffer, 293.93, Unit::KELVIN, false); - ok1(StringIsEqual(buffer, _T("294"))); + ok1(StringIsEqual(buffer, "294")); FormatTemperature(buffer, Units::ToSysUnit(13.4, Unit::DEGREES_CELCIUS), Unit::DEGREES_CELCIUS); - ok1(StringIsEqual(buffer, _T("13 " DEG "C"))); + ok1(StringIsEqual(buffer, "13 " DEG "C")); FormatTemperature(buffer, Units::ToSysUnit(13.4, Unit::DEGREES_CELCIUS), Unit::DEGREES_CELCIUS, false); - ok1(StringIsEqual(buffer, _T("13"))); + ok1(StringIsEqual(buffer, "13")); FormatTemperature(buffer, Units::ToSysUnit(92.7, Unit::DEGREES_FAHRENHEIT), Unit::DEGREES_FAHRENHEIT); - ok1(StringIsEqual(buffer, _T("93 " DEG "F"))); + ok1(StringIsEqual(buffer, "93 " DEG "F")); FormatTemperature(buffer, Units::ToSysUnit(92.7, Unit::DEGREES_FAHRENHEIT), Unit::DEGREES_FAHRENHEIT, false); - ok1(StringIsEqual(buffer, _T("93"))); + ok1(StringIsEqual(buffer, "93")); } static void @@ -468,36 +468,36 @@ TestPressure() // Test FormatPressure() FormatPressure(buffer, AtmosphericPressure::HectoPascal(1013.25), Unit::HECTOPASCAL); - ok1(StringIsEqual(buffer, _T("1013 hPa"))); + ok1(StringIsEqual(buffer, "1013 hPa")); FormatPressure(buffer, AtmosphericPressure::HectoPascal(1013.25), Unit::HECTOPASCAL, false); - ok1(StringIsEqual(buffer, _T("1013"))); + ok1(StringIsEqual(buffer, "1013")); FormatPressure(buffer, AtmosphericPressure::HectoPascal(1013.25), Unit::MILLIBAR); - ok1(StringIsEqual(buffer, _T("1013 mb"))); + ok1(StringIsEqual(buffer, "1013 mb")); FormatPressure(buffer, AtmosphericPressure::HectoPascal(1013.25), Unit::MILLIBAR, false); - ok1(StringIsEqual(buffer, _T("1013"))); + ok1(StringIsEqual(buffer, "1013")); FormatPressure(buffer, AtmosphericPressure::HectoPascal( Units::ToSysUnit(103, Unit::TORR)), Unit::TORR); - ok1(StringIsEqual(buffer, _T("103 mmHg"))); + ok1(StringIsEqual(buffer, "103 mmHg")); FormatPressure(buffer, AtmosphericPressure::HectoPascal( Units::ToSysUnit(103, Unit::TORR)), Unit::TORR, false); - ok1(StringIsEqual(buffer, _T("103"))); + ok1(StringIsEqual(buffer, "103")); FormatPressure(buffer, AtmosphericPressure::HectoPascal( Units::ToSysUnit(29.92, Unit::INCH_MERCURY)), Unit::INCH_MERCURY); - ok1(StringIsEqual(buffer, _T("29.92 inHg"))); + ok1(StringIsEqual(buffer, "29.92 inHg")); FormatPressure(buffer, AtmosphericPressure::HectoPascal( Units::ToSysUnit(29.92, Unit::INCH_MERCURY)), Unit::INCH_MERCURY, false); - ok1(StringIsEqual(buffer, _T("29.92"))); + ok1(StringIsEqual(buffer, "29.92")); } int main() diff --git a/test/src/TestWaypointReader.cpp b/test/src/TestWaypointReader.cpp index e66a56b232e..f90655b9f34 100644 --- a/test/src/TestWaypointReader.cpp +++ b/test/src/TestWaypointReader.cpp @@ -86,7 +86,7 @@ static void TestWinPilot(const wp_vector &org_wp) { Waypoints way_points; - if (!TestWaypointFile(Path(_T("test/data/waypoints.dat")), way_points, + if (!TestWaypointFile(Path("test/data/waypoints.dat"), way_points, org_wp.size())) { skip(10 * org_wp.size(), 0, "opening waypoint file failed"); return; @@ -126,7 +126,7 @@ TestSeeYou(const wp_vector &org_wp) { // Test a SeeYou waypoint file with no runway width field: Waypoints way_points; - if (!TestWaypointFile(Path(_T("test/data/waypoints.cup")), way_points, + if (!TestWaypointFile(Path("test/data/waypoints.cup"), way_points, org_wp.size())) { skip(9 * org_wp.size(), 0, "opening waypoints.cup failed"); } else { @@ -138,7 +138,7 @@ TestSeeYou(const wp_vector &org_wp) // Test a SeeYou waypoint file with a runway width field: Waypoints way_points2; - if (!TestWaypointFile(Path(_T("test/data/waypoints2.cup")), way_points2, + if (!TestWaypointFile(Path("test/data/waypoints2.cup"), way_points2, org_wp.size())) { skip(9 * org_wp.size(), 0, "opening waypoints2.cup failed"); return; @@ -150,7 +150,7 @@ TestSeeYou(const wp_vector &org_wp) } // Test a SeeYou waypoint file with useradata and pics fields: Waypoints way_points3; - if (!TestWaypointFile(Path(_T("test/data/waypoints3.cup")), way_points3, + if (!TestWaypointFile(Path("test/data/waypoints3.cup"), way_points3, org_wp.size())) { skip(9 * org_wp.size(), 0, "opening waypoints3.cup failed"); return; @@ -192,7 +192,7 @@ static void TestZander(const wp_vector &org_wp) { Waypoints way_points; - if (!TestWaypointFile(Path(_T("test/data/waypoints.wpz")), way_points, + if (!TestWaypointFile(Path("test/data/waypoints.wpz"), way_points, org_wp.size())) { skip(10 * org_wp.size(), 0, "opening waypoint file failed"); return; @@ -209,7 +209,7 @@ static void TestFS(const wp_vector &org_wp) { Waypoints way_points; - if (!TestWaypointFile(Path(_T("test/data/waypoints_geo.wpt")), way_points, + if (!TestWaypointFile(Path("test/data/waypoints_geo.wpt"), way_points, org_wp.size())) { skip(3 * org_wp.size(), 0, "opening waypoint file failed"); return; @@ -225,7 +225,7 @@ static void TestFS_UTM(const wp_vector &org_wp) { Waypoints way_points; - if (!TestWaypointFile(Path(_T("test/data/waypoints_utm.wpt")), way_points, + if (!TestWaypointFile(Path("test/data/waypoints_utm.wpt"), way_points, org_wp.size())) { skip(3 * org_wp.size(), 0, "opening waypoint file failed"); return; @@ -241,7 +241,7 @@ static void TestOzi(const wp_vector &org_wp) { Waypoints way_points; - if (!TestWaypointFile(Path(_T("test/data/waypoints_ozi.wpt")), way_points, + if (!TestWaypointFile(Path("test/data/waypoints_ozi.wpt"), way_points, org_wp.size())) { skip(3 * org_wp.size(), 0, "opening waypoint file failed"); return; @@ -257,7 +257,7 @@ static void TestCompeGPS(const wp_vector &org_wp) { Waypoints way_points; - if (!TestWaypointFile(Path(_T("test/data/waypoints_compe_geo.wpt")), way_points, + if (!TestWaypointFile(Path("test/data/waypoints_compe_geo.wpt"), way_points, org_wp.size())) { skip(3 * org_wp.size(), 0, "opening waypoint file failed"); return; @@ -265,7 +265,7 @@ TestCompeGPS(const wp_vector &org_wp) for (auto i : org_wp) { size_t pos; - while ((pos = i.name.find_first_of(_T(' '))) != std::string::npos) + while ((pos = i.name.find_first_of(' ')) != std::string::npos) i.name.erase(pos, 1); TruncateStrip(i.name, 6); @@ -278,7 +278,7 @@ static void TestCompeGPS_UTM(const wp_vector &org_wp) { Waypoints way_points; - if (!TestWaypointFile(Path(_T("test/data/waypoints_compe_utm.wpt")), way_points, + if (!TestWaypointFile(Path("test/data/waypoints_compe_utm.wpt"), way_points, org_wp.size())) { skip(3 * org_wp.size(), 0, "opening waypoint file failed"); return; @@ -286,7 +286,7 @@ TestCompeGPS_UTM(const wp_vector &org_wp) for (auto i : org_wp) { size_t pos; - while ((pos = i.name.find_first_of(_T(' '))) != std::string::npos) + while ((pos = i.name.find_first_of(' ')) != std::string::npos) i.name.erase(pos, 1); TruncateStrip(i.name, 6); @@ -332,8 +332,8 @@ CreateOriginalWaypoints() Waypoint wp(loc); wp.elevation = 488; wp.has_elevation = true; - wp.name = _T("Bergneustadt"); - wp.comment = _T("Rabbit holes, 20\" ditch south end of rwy"); + wp.name = "Bergneustadt"; + wp.comment = "Rabbit holes, 20\" ditch south end of rwy"; wp.runway.SetDirection(Angle::Degrees(40)); wp.runway.SetLength(590); @@ -351,8 +351,8 @@ CreateOriginalWaypoints() Waypoint wp2(loc); wp2.elevation = 6962; wp2.has_elevation = true; - wp2.name = _T("Aconcagua"); - wp2.comment = _T("Highest mountain in south-america"); + wp2.name = "Aconcagua"; + wp2.comment = "Highest mountain in south-america"; wp2.type = Waypoint::Type::MOUNTAIN_TOP; wp2.flags.turn_point = true; @@ -368,8 +368,8 @@ CreateOriginalWaypoints() Waypoint wp3(loc); wp3.elevation = 227; wp3.has_elevation = true; - wp3.name = _T("Golden Gate Bridge"); - wp3.comment = _T(""); + wp3.name = "Golden Gate Bridge"; + wp3.comment = ""; wp3.type = Waypoint::Type::BRIDGE; wp3.flags.turn_point = true; @@ -385,7 +385,7 @@ CreateOriginalWaypoints() Waypoint wp4(loc); wp4.elevation = 123; wp4.has_elevation = true; - wp4.name = _T("Red Square"); + wp4.name = "Red Square"; wp4.runway.SetDirection(Angle::Degrees(90)); wp4.runway.SetLength((unsigned)Units::ToSysUnit(0.01, Unit::STATUTE_MILES)); @@ -403,8 +403,8 @@ CreateOriginalWaypoints() Waypoint wp5(loc); wp5.elevation = 5; wp5.has_elevation = true; - wp5.name = _T("Sydney Opera"); - wp5.comment = _T(""); + wp5.name = "Sydney Opera"; + wp5.comment = ""; wp5.type = Waypoint::Type::NORMAL; wp5.flags.turn_point = true; diff --git a/test/src/TestWaypoints.cpp b/test/src/TestWaypoints.cpp index 91c2e7afd85..6a9fb5f0662 100644 --- a/test/src/TestWaypoints.cpp +++ b/test/src/TestWaypoints.cpp @@ -65,15 +65,15 @@ AddSpiralWaypoints(Waypoints &waypoints, StaticString<256> buffer; if (i % 7 == 0) { - buffer = _T("Airfield"); + buffer = "Airfield"; waypoint.type = Waypoint::Type::AIRFIELD; } else if (i % 3 == 0) { - buffer = _T("Field"); + buffer = "Field"; waypoint.type = Waypoint::Type::OUTLANDING; } else - buffer = _T("Waypoint"); + buffer = "Waypoint"; - buffer.AppendFormat(_T(" #%d"), i + 1); + buffer.AppendFormat(" #%d", i + 1); waypoint.name = buffer; waypoints.Append(std::move(waypoint)); @@ -98,7 +98,7 @@ TestLookups(const Waypoints &waypoints, const GeoPoint ¢er) ok1((waypoint = waypoints.LookupLocation(center, 0)) != NULL); ok1(waypoint->original_id == 0); - ok1((waypoint = waypoints.LookupName(_T("Waypoint #5"))) != NULL); + ok1((waypoint = waypoints.LookupName("Waypoint #5")) != NULL); ok1(waypoint->original_id == 4); ok1((waypoint = waypoints.LookupLocation(waypoint->location, 10000)) != NULL); @@ -130,12 +130,12 @@ TestNamePrefixVisitor(const Waypoints &waypoints, const char *prefix, static void TestNamePrefixVisitor(const Waypoints &waypoints) { - TestNamePrefixVisitor(waypoints, _T(""), 151); - TestNamePrefixVisitor(waypoints, _T("Foo"), 0); - TestNamePrefixVisitor(waypoints, _T("a"), 0); - TestNamePrefixVisitor(waypoints, _T("A"), 22); - TestNamePrefixVisitor(waypoints, _T("Air"), 22); - TestNamePrefixVisitor(waypoints, _T("Field"), 51 - 8); + TestNamePrefixVisitor(waypoints, "", 151); + TestNamePrefixVisitor(waypoints, "Foo", 0); + TestNamePrefixVisitor(waypoints, "a", 0); + TestNamePrefixVisitor(waypoints, "A", 22); + TestNamePrefixVisitor(waypoints, "Air", 22); + TestNamePrefixVisitor(waypoints, "Field", 51 - 8); } class CloserThan @@ -271,12 +271,12 @@ TestReplace(Waypoints& waypoints, unsigned id) std::string oldName = wp->name; Waypoint copy = *wp; - copy.name = _T("Fred"); + copy.name = "Fred"; waypoints.Replace(wp, std::move(copy)); waypoints.Optimise(); wp = waypoints.LookupId(id); - return wp != NULL && wp->name != oldName && wp->name == _T("Fred"); + return wp != NULL && wp->name != oldName && wp->name == "Fred"; } int diff --git a/test/src/ViewImage.cpp b/test/src/ViewImage.cpp index cc9f5216447..975d1a3e35f 100644 --- a/test/src/ViewImage.cpp +++ b/test/src/ViewImage.cpp @@ -42,7 +42,7 @@ static void Main(UI::Display &display) { TestWindow window{display}; - window.Create(_T("ViewImage"), {640, 480}); + window.Create("ViewImage", {640, 480}); if (!window.LoadFile(path)) { fprintf(stderr, "Failed to load file\n"); exit(EXIT_FAILURE); diff --git a/test/src/harness_airspace.cpp b/test/src/harness_airspace.cpp index 2cd94b62922..a26662bfe00 100644 --- a/test/src/harness_airspace.cpp +++ b/test/src/harness_airspace.cpp @@ -25,7 +25,7 @@ airspace_random_properties(AbstractAirspace& as) AirspaceAltitude top; base.altitude = rand()%4000; top.altitude = base.altitude+rand()%3000; - as.SetProperties(_T("hello"), asclass, _T("E"), base, top); + as.SetProperties("hello", asclass, "E", base, top); } @@ -45,7 +45,7 @@ void setup_airspaces(Airspaces& airspaces, const GeoPoint& center, const unsigne std::ofstream *fin = NULL; if (verbose) { - Directory::Create(Path(_T("output/results"))); + Directory::Create(Path("output/results")); fin = new std::ofstream("output/results/res-bb-in.txt"); } @@ -240,7 +240,7 @@ void scan_airspaces(const AircraftState state, { const double range(20000.0); - Directory::Create(Path(_T("output/results"))); + Directory::Create(Path("output/results")); { AirspaceVisitorPrint pvisitor("output/results/res-bb-range.txt", diff --git a/test/src/harness_flight.cpp b/test/src/harness_flight.cpp index 8c0b991b97d..e46ad38950f 100644 --- a/test/src/harness_flight.cpp +++ b/test/src/harness_flight.cpp @@ -97,7 +97,7 @@ run_flight(TestFlightComponents components, TaskManager &task_manager, autopilot.SetSpeedFactor(speed_factor); - Directory::Create(Path(_T("output/results"))); + Directory::Create(Path("output/results")); std::ofstream f4("output/results/res-sample.txt"); std::ofstream f5("output/results/res-sample-filtered.txt"); diff --git a/test/src/harness_waypoints.cpp b/test/src/harness_waypoints.cpp index 54adbe763f5..a70161bc130 100644 --- a/test/src/harness_waypoints.cpp +++ b/test/src/harness_waypoints.cpp @@ -35,7 +35,7 @@ bool SetupWaypoints(Waypoints &waypoints, const unsigned n) wp = waypoints.Create(GeoPoint(Angle::Degrees(1), Angle::Degrees(1))); - wp.name = _T("Hello"); + wp.name = "Hello"; wp.type = Waypoint::Type::AIRFIELD; wp.elevation = 0.5; wp.has_elevation = true; @@ -43,7 +43,7 @@ bool SetupWaypoints(Waypoints &waypoints, const unsigned n) wp = waypoints.Create(GeoPoint(Angle::Degrees(0.8), Angle::Degrees(0.5))); - wp.name = _T("Unk"); + wp.name = "Unk"; wp.type = Waypoint::Type::AIRFIELD; wp.elevation = 0.25; wp.has_elevation = true; @@ -77,7 +77,7 @@ bool SetupWaypoints(Waypoints &waypoints, const unsigned n) waypoints.Optimise(); if (verbose) { - Directory::Create(Path(_T("output/results"))); + Directory::Create(Path("output/results")); std::ofstream fin("output/results/res-wp-in.txt"); for (unsigned i=1; i<=waypoints.size(); i++) { const auto wpt = waypoints.LookupId(i); diff --git a/test/src/test_debug.cpp b/test/src/test_debug.cpp index 9c2cb7bd942..60322b21fcd 100644 --- a/test/src/test_debug.cpp +++ b/test/src/test_debug.cpp @@ -19,8 +19,8 @@ int output_skip = 5; AutopilotParameters autopilot_parms; int terrain_height = 1; -AllocatedPath replay_file = Path(_T("test/data/0asljd01.igc")); -AllocatedPath waypoint_file = Path(_T("test/data/waypoints_geo.wpt")); +AllocatedPath replay_file = Path("test/data/0asljd01.igc"); +AllocatedPath waypoint_file = Path("test/data/waypoints_geo.wpt"); AllocatedPath task_file; double range_threshold = 15000; diff --git a/test/src/test_mc.cpp b/test/src/test_mc.cpp index b5b18e6a0b9..a6b042b72f6 100644 --- a/test/src/test_mc.cpp +++ b/test/src/test_mc.cpp @@ -255,7 +255,7 @@ int main() { plan_tests(3); - Directory::Create(Path(_T("output/results"))); + Directory::Create(Path("output/results")); ok(test_mc(),"mc output",0); ok(test_stf(),"mc stf",0); diff --git a/test/src/test_reach.cpp b/test/src/test_reach.cpp index d873d94e529..6b49abde540 100644 --- a/test/src/test_reach.cpp +++ b/test/src/test_reach.cpp @@ -51,7 +51,7 @@ test_reach(const RasterMap &map, double mwind, double mc, double height_min_work PrintHelper::print(reach_working); { - Directory::Create(Path(_T("output/results"))); + Directory::Create(Path("output/results")); std::ofstream fout("output/results/terrain.txt"); unsigned nx = 100; unsigned ny = 100; diff --git a/test/src/test_replay_olc.cpp b/test/src/test_replay_olc.cpp index fb5a507b6d7..1a2bdc8a2cb 100644 --- a/test/src/test_replay_olc.cpp +++ b/test/src/test_replay_olc.cpp @@ -71,7 +71,7 @@ inline void load_score_file(std::ifstream& fscore, inline void load_scores(unsigned &contest_handicap) { // replay_file - const auto score_file = replay_file.WithSuffix(_T(".txt")); + const auto score_file = replay_file.WithSuffix(".txt"); if (verbose) { std::cout << "# replay file: " << replay_file << "\n"; std::cout << "# score file: " << score_file << "\n"; @@ -114,7 +114,7 @@ static bool test_replay(const Contest olc_type, const ContestResult &official_score) { - Directory::Create(Path(_T("output/results"))); + Directory::Create(Path("output/results")); std::ofstream f("output/results/res-sample.txt"); GlidePolar glide_polar(2); diff --git a/test/src/test_replay_retrospective.cpp b/test/src/test_replay_retrospective.cpp index 0c79745443f..984ef469112 100644 --- a/test/src/test_replay_retrospective.cpp +++ b/test/src/test_replay_retrospective.cpp @@ -18,7 +18,7 @@ static bool test_replay_retrospective() { - Directory::Create(_T("output/results")); + Directory::Create("output/results"); std::ofstream f("output/results/res-sample.txt"); Waypoints waypoints; diff --git a/test/src/test_replay_task.cpp b/test/src/test_replay_task.cpp index 5fa4bc4eaa4..1743ef11bd1 100644 --- a/test/src/test_replay_task.cpp +++ b/test/src/test_replay_task.cpp @@ -77,7 +77,7 @@ class ReplayLoggerSim: public IgcReplay static bool test_replay() { - Directory::Create(Path(_T("output/results"))); + Directory::Create(Path("output/results")); std::ofstream f("output/results/res-sample.txt"); GlidePolar glide_polar(4.0); @@ -184,8 +184,8 @@ int main(int argc, char** argv) try { output_skip = 60; - replay_file = Path(_T("test/data/apf-bug554.igc")); - task_file = Path(_T("test/data/apf-bug554.tsk")); + replay_file = Path("test/data/apf-bug554.igc"); + task_file = Path("test/data/apf-bug554.tsk"); if (!ParseArgs(argc,argv)) { return 0; diff --git a/test/src/test_route.cpp b/test/src/test_route.cpp index 45290f59193..6c5ad5a0a15 100644 --- a/test/src/test_route.cpp +++ b/test/src/test_route.cpp @@ -38,7 +38,7 @@ test_route(const unsigned n_airspaces, const RasterMap& map) setup_airspaces(airspaces, map.GetMapCenter(), n_airspaces); { - Directory::Create(Path(_T("output/results"))); + Directory::Create(Path("output/results")); std::ofstream fout("output/results/terrain.txt"); unsigned nx = 100; diff --git a/test/src/test_troute.cpp b/test/src/test_troute.cpp index 60cf84e11e1..e1111ae04ec 100644 --- a/test/src/test_troute.cpp +++ b/test/src/test_troute.cpp @@ -44,7 +44,7 @@ test_troute(const RasterMap &map, double mwind, double mc, int ceiling) bool retval= true; { - Directory::Create(Path(_T("output/results"))); + Directory::Create(Path("output/results")); std::ofstream fout ("output/results/terrain.txt"); unsigned nx = 100; unsigned ny = 100; diff --git a/tools/GenerateResources.pl b/tools/GenerateResources.pl index f213067c5d2..9af92af0902 100755 --- a/tools/GenerateResources.pl +++ b/tools/GenerateResources.pl @@ -37,7 +37,7 @@ ($) my ($name, $size) = @$i; my $variable = "resource_${name}"; $variable =~ s,\.,_,g; - print " { _T(\"${name}\"), { ${variable}, ${size} } },\n"; + print " { \"${name}\", { ${variable}, ${size} } },\n"; } print " { 0, {} }\n"; print "};\n"; diff --git a/tools/Text2Event.pl b/tools/Text2Event.pl index c35975bb3e7..491936eea99 100755 --- a/tools/Text2Event.pl +++ b/tools/Text2Event.pl @@ -4,6 +4,6 @@ use warnings; while (<>) { - print qq'{ _T("$1"), &InputEvents::event$1 },\n' + print qq'{ "$1", &InputEvents::event$1 },\n' if /^\s*void event([a-zA-Z0-9]+)/; } diff --git a/tools/Text2GCE.pl b/tools/Text2GCE.pl index fd8b12d1e59..e14be90f348 100755 --- a/tools/Text2GCE.pl +++ b/tools/Text2GCE.pl @@ -4,6 +4,6 @@ use warnings; while (<>) { - print qq'_T("$1"),\n' + print qq'"$1",\n' if /GCE_([A-Z0-9_]+)/; } diff --git a/tools/Text2NE.pl b/tools/Text2NE.pl index 56260cc0db1..fc9374c4d2a 100755 --- a/tools/Text2NE.pl +++ b/tools/Text2NE.pl @@ -4,6 +4,6 @@ use warnings; while (<>) { - print qq'_T("$1"),\n' + print qq'"$1",\n' if /NE_([A-Z0-9_]+)/; } diff --git a/tools/polar_import.py b/tools/polar_import.py index 2f9ee81c90d..3202a71c33e 100755 --- a/tools/polar_import.py +++ b/tools/polar_import.py @@ -116,7 +116,7 @@ def get_current_xc_polar(glider, weight=0.0): return None ret = None for line in f: - if line[0:7] != " { _T(" : continue + if line[0:4] != " { " : continue if glider in line: ##357, 165, 108.8, -0.64, 156.4, -1.18, 211.13, -2.5, 9.0, 0.0, 114 ret = polar() @@ -210,7 +210,7 @@ def polar_store_line(p, wingload=0.0): minsinkspeed = p._x[np.argmax(p._y)] threedots = [minsinkspeed, 130.0, 170.0] print("XCSoar PolarStore template:") - print(' { _T("' + p._name + '"),', wieght, ", 0.0,", threedots[0], ',', p1d(threedots[0]), ',', threedots[1], ',', p1d(threedots[1]), ',', threedots[2],',', p1d(threedots[2]), ',', p._S, ", 0.0, 0 },") + print(' { "' + p._name + '",', wieght, ", 0.0,", threedots[0], ',', p1d(threedots[0]), ',', threedots[1], ',', p1d(threedots[1]), ',', threedots[2],',', p1d(threedots[2]), ',', p._S, ", 0.0, 0 },") print("The raw file for this:") print(p._name) print(p._w) diff --git a/tools/xci2cpp.pl b/tools/xci2cpp.pl index 6a18fd263a4..a04f4aa8c65 100755 --- a/tools/xci2cpp.pl +++ b/tools/xci2cpp.pl @@ -167,7 +167,7 @@ (\%) sub c_string($) { my $value = shift; return 'NULL' unless defined $value; - return qq|_T("$value")|; + return qq|"$value"|; } print "static const char *const default_modes[] = {\n"; @@ -215,7 +215,7 @@ ($) print "static constexpr struct flat_label default_labels[] = {\n"; foreach my $l (@labels) { my ($mode, $label, $location, $event) = @$l; - print qq| { $mode, $location, $event, _T("$label") },\n|; + print qq| { $mode, $location, $event, "$label" },\n|; } print " { 0, 0, 0, NULL },\n"; print "};\n"; @@ -223,7 +223,7 @@ ($) print "static constexpr struct flat_gesture_map default_gesture2event[] = {\n"; foreach my $g (@gestures) { my ($mode, $event, $data) = @$g; - print " { $mode, $event, _T(\"$data\") },\n"; + print " { $mode, $event, \"$data\" },\n"; } print " { 0, 0, NULL },\n"; print "};\n"; diff --git a/tools/xcs2cpp.pl b/tools/xcs2cpp.pl index 4ff8a00da98..54df1baf219 100755 --- a/tools/xcs2cpp.pl +++ b/tools/xcs2cpp.pl @@ -9,7 +9,7 @@ sub c_string($) { my $value = shift; return 'NULL' unless defined $value; - return qq|_T("$value")|; + return qq|"$value"|; } sub c_bool($) { From e950e149faad05df827137552bda932c41a4f4f8 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 25 Apr 2024 10:55:20 +0200 Subject: [PATCH 385/403] [UTF8] Replace NarrowString with StaticString in src/*, tools/* and test/* in src: 60 items in test: 11 items in tools: 1 item --- src/Device/Driver/EWMicroRecorder.cpp | 2 +- src/Device/Driver/FLARM/Declare.cpp | 2 +- src/Device/Driver/FLARM/Device.cpp | 8 ++++---- src/Device/Driver/LX/Internal.hpp | 2 +- src/Device/Driver/LX/NanoDeclare.cpp | 4 ++-- src/Device/Driver/Larus.cpp | 2 +- src/Dialogs/Device/FLARM/ConfigWidget.cpp | 2 +- src/Dialogs/Device/LX/LXNAVVarioConfigWidget.cpp | 2 +- src/FLARM/Version.hpp | 4 ++-- src/Formatter/NMEAFormatter.cpp | 2 +- src/HexDump.hpp | 2 +- src/IGC/IGCDeclaration.hpp | 4 ++-- src/NMEA/DeviceInfo.hpp | 8 ++++---- src/OpenVario/OpenVarioBaseMenu.cpp | 6 +++--- src/OpenVario/System/WifiDialogOV.cpp | 8 ++++---- src/OpenVario/System/WifiSupplicantOV.hpp | 16 ++++++++-------- src/Plane/PlaneFileGlue.cpp | 2 +- src/Profile/GeoValue.cpp | 2 +- src/Repository/AvailableFile.hpp | 2 +- src/Tracking/LiveTrack24/Client.cpp | 8 ++++---- src/Tracking/LiveTrack24/Client.hpp | 2 +- src/Waypoint/WaypointReaderOzi.cpp | 4 ++-- src/Weather/PCMet/Overlays.cpp | 2 +- src/XML/DataNode.cpp | 4 ++-- src/net/client/WeGlide/UploadFlight.cpp | 2 +- src/util/StaticString.hxx | 3 +-- test/src/AnalyseFlight.cpp | 2 +- test/src/FLARMEmulator.cpp | 2 +- test/src/FeedFlyNetData.cpp | 4 ++-- test/src/FlightPhaseJSON.cpp | 2 +- test/src/IGC2NMEA.cpp | 6 +++--- test/src/RunDeviceDriver.cpp | 2 +- test/src/RunDownloadFlight.cpp | 2 +- test/src/RunFlightList.cpp | 2 +- tools/gdb.py | 2 +- 35 files changed, 64 insertions(+), 65 deletions(-) diff --git a/src/Device/Driver/EWMicroRecorder.cpp b/src/Device/Driver/EWMicroRecorder.cpp index 10ea4955462..3fad3f9b3ee 100644 --- a/src/Device/Driver/EWMicroRecorder.cpp +++ b/src/Device/Driver/EWMicroRecorder.cpp @@ -183,7 +183,7 @@ WriteCleanString(Port &port, const char *p, OperationEnvironment &env, std::chrono::steady_clock::duration timeout) { - NarrowString<256> buffer; + StaticString<256> buffer; buffer.SetASCII(p); CleanString(buffer.buffer()); diff --git a/src/Device/Driver/FLARM/Declare.cpp b/src/Device/Driver/FLARM/Declare.cpp index eff682185b2..4a131614e3e 100644 --- a/src/Device/Driver/FLARM/Declare.cpp +++ b/src/Device/Driver/FLARM/Declare.cpp @@ -103,7 +103,7 @@ FlarmDevice::DeclareInternal(const Declaration &declaration, * parameter of CopyCleanFlarmString() allows us to trim off excess characters * so that a dodgy waypoint configuration doesn't cause an overflow. */ - NarrowString<90> buffer; + StaticString<90> buffer; const WideToUTF8Converter shortName(declaration.GetShortName(i)); buffer.Format("%02d%05.0f%c,%03d%05.0f%c,", DegLat, (double)MinLat, NoS, diff --git a/src/Device/Driver/FLARM/Device.cpp b/src/Device/Driver/FLARM/Device.cpp index 87794af87dd..101929ee57f 100644 --- a/src/Device/Driver/FLARM/Device.cpp +++ b/src/Device/Driver/FLARM/Device.cpp @@ -177,10 +177,10 @@ bool FlarmDevice::GetConfig(const char *setting, char *buffer, size_t length, OperationEnvironment &env) { - NarrowString<90> request; + StaticString<90> request; request.Format("PFLAC,R,%s", setting); - NarrowString<90> expected_answer(request); + StaticString<90> expected_answer(request); expected_answer[6u] = 'A'; expected_answer.push_back(','); @@ -210,10 +210,10 @@ bool FlarmDevice::SetConfig(const char *setting, const char *value, OperationEnvironment &env) { - NarrowString<90> buffer; + StaticString<90> buffer; buffer.Format("PFLAC,S,%s,%s", setting, value); - NarrowString<90> expected_answer(buffer); + StaticString<90> expected_answer(buffer); expected_answer[6u] = 'A'; Send(buffer, env); diff --git a/src/Device/Driver/LX/Internal.hpp b/src/Device/Driver/LX/Internal.hpp index 46f213e3682..ee7c460b38c 100644 --- a/src/Device/Driver/LX/Internal.hpp +++ b/src/Device/Driver/LX/Internal.hpp @@ -151,7 +151,7 @@ class LXDevice: public AbstractDevice is_v7 = is_sVario = is_nano = is_lx16xx = is_forwarded_nano = false; } - void IdDeviceByName(NarrowString<16> productName) noexcept + void IdDeviceByName(StaticString<16> productName) noexcept { is_v7 = productName.equals("V7"); is_sVario = productName.equals("NINC") || productName.equals("S8x"); diff --git a/src/Device/Driver/LX/NanoDeclare.cpp b/src/Device/Driver/LX/NanoDeclare.cpp index dadde8fc941..72c5b02ecc9 100644 --- a/src/Device/Driver/LX/NanoDeclare.cpp +++ b/src/Device/Driver/LX/NanoDeclare.cpp @@ -17,7 +17,7 @@ NanoWriteDecl(Port &port, OperationEnvironment &env, PortNMEAReader &reader, unsigned row, unsigned n_rows, const char *content) { - NarrowString<256> buffer; + StaticString<256> buffer; buffer.Format("$PLXVC,DECL,W,%u,%u,%s", row, n_rows, content); PortWriteNMEA(port, buffer, env); @@ -35,7 +35,7 @@ NanoWriteDeclFormat(Port &port, OperationEnvironment &env, unsigned row, unsigned n_rows, const char *fmt, Args&&... args) { - NarrowString<256> buffer; + StaticString<256> buffer; buffer.Format(fmt, args...); return NanoWriteDecl(port, env, reader, row, n_rows, buffer); } diff --git a/src/Device/Driver/Larus.cpp b/src/Device/Driver/Larus.cpp index c44e9f1361a..e48c1ec3616 100644 --- a/src/Device/Driver/Larus.cpp +++ b/src/Device/Driver/Larus.cpp @@ -452,7 +452,7 @@ LarusDevice::PutQNH(const AtmosphericPressure &pres, bool LarusDevice::SendCmd(const char *cmd, double value, OperationEnvironment &env) { - NarrowString<80> buffer("PLARS,H,"); + StaticString<80> buffer("PLARS,H,"); buffer.AppendFormat(cmd, value); PortWriteNMEA(port, buffer.c_str(), env); diff --git a/src/Dialogs/Device/FLARM/ConfigWidget.cpp b/src/Dialogs/Device/FLARM/ConfigWidget.cpp index 00d9dfd6a8c..f868846a1cb 100644 --- a/src/Dialogs/Device/FLARM/ConfigWidget.cpp +++ b/src/Dialogs/Device/FLARM/ConfigWidget.cpp @@ -138,7 +138,7 @@ FLARMConfigWidget::Save(bool &_changed) noexcept try { PopupOperationEnvironment env; bool changed = false; - NarrowString<32> buffer; + StaticString<32> buffer; if (SaveValueEnum(Baud, baud)) { buffer.UnsafeFormat("%u", baud); diff --git a/src/Dialogs/Device/LX/LXNAVVarioConfigWidget.cpp b/src/Dialogs/Device/LX/LXNAVVarioConfigWidget.cpp index fcde87cdca6..4fab6299e53 100644 --- a/src/Dialogs/Device/LX/LXNAVVarioConfigWidget.cpp +++ b/src/Dialogs/Device/LX/LXNAVVarioConfigWidget.cpp @@ -75,7 +75,7 @@ LXNAVVarioConfigWidget::Save(bool &_changed) noexcept try { PopupOperationEnvironment env; bool changed = false; - NarrowString<32> buffer; + StaticString<32> buffer; if (SaveValueEnum(BRGPS, brgps)) { buffer.UnsafeFormat("%u", brgps); diff --git a/src/FLARM/Version.hpp b/src/FLARM/Version.hpp index 6a01bf8cd92..5f8ed3a883d 100644 --- a/src/FLARM/Version.hpp +++ b/src/FLARM/Version.hpp @@ -15,8 +15,8 @@ struct FlarmVersion { Validity available; - NarrowString<7> hardware_version, software_version; - NarrowString<19> obstacle_version; + StaticString<7> hardware_version, software_version; + StaticString<19> obstacle_version; constexpr void Clear() noexcept { available.Clear(); diff --git a/src/Formatter/NMEAFormatter.cpp b/src/Formatter/NMEAFormatter.cpp index 54b42658efc..12e655f3c9f 100644 --- a/src/Formatter/NMEAFormatter.cpp +++ b/src/Formatter/NMEAFormatter.cpp @@ -82,7 +82,7 @@ FormatGPGSA(char *buffer, size_t buffer_size, const NMEAInfo &info) noexcept else gps_status = 3; - NarrowString<256> sat_ids; + StaticString<256> sat_ids; sat_ids.clear(); for (unsigned i = 0; i < GPSState::MAXSATELLITES; ++i) { if (info.gps.satellite_ids[i] > 0 && info.gps.satellite_ids_available) { diff --git a/src/HexDump.hpp b/src/HexDump.hpp index b36a9695a4d..21ac52d1e79 100644 --- a/src/HexDump.hpp +++ b/src/HexDump.hpp @@ -20,7 +20,7 @@ static inline void HexDumpLine(const char *prefix, unsigned offset, std::span src) noexcept { - NarrowString<128> line; + StaticString<128> line; line.clear(); for (size_t i = 0; i < src.size(); ++i) { diff --git a/src/IGC/IGCDeclaration.hpp b/src/IGC/IGCDeclaration.hpp index 4aa6dbd3aac..261ac8929c7 100644 --- a/src/IGC/IGCDeclaration.hpp +++ b/src/IGC/IGCDeclaration.hpp @@ -21,7 +21,7 @@ struct IGCDeclarationHeader { unsigned num_turnpoints; /** Optional name of the task */ - NarrowString<256> task_name; + StaticString<256> task_name; }; struct IGCDeclarationTurnpoint { @@ -29,5 +29,5 @@ struct IGCDeclarationTurnpoint { GeoPoint location; /** Optional name of the turnpoint */ - NarrowString<256> name; + StaticString<256> name; }; diff --git a/src/NMEA/DeviceInfo.hpp b/src/NMEA/DeviceInfo.hpp index 0acb4f9a58b..f62714d635c 100644 --- a/src/NMEA/DeviceInfo.hpp +++ b/src/NMEA/DeviceInfo.hpp @@ -23,23 +23,23 @@ struct DeviceInfo { /** * The name of the product. */ - NarrowString<16> product; + StaticString<16> product; /** * The serial number. This is a string because we're not sure if a * device sends non-numeric data here. */ - NarrowString<16> serial; + StaticString<16> serial; /** * The hardware version number. */ - NarrowString<16> hardware_version; + StaticString<16> hardware_version; /** * The software (or firmware) version number. */ - NarrowString<16> software_version; + StaticString<16> software_version; void Clear() { product.clear(); diff --git a/src/OpenVario/OpenVarioBaseMenu.cpp b/src/OpenVario/OpenVarioBaseMenu.cpp index bb814edee99..02759ba5aef 100644 --- a/src/OpenVario/OpenVarioBaseMenu.cpp +++ b/src/OpenVario/OpenVarioBaseMenu.cpp @@ -225,7 +225,7 @@ MainMenuWidget::StartSoarExe(std::string_view _exe, ArgList = {exe.c_str(), "-fly"}; //=============== Datapath ======================= - NarrowString<0x200> datapath("-datapath="); + StaticString<0x200> datapath("-datapath="); if (_datapath.empty()) { _datapath = GetPrimaryDataPath().c_str(); } else { @@ -237,7 +237,7 @@ MainMenuWidget::StartSoarExe(std::string_view _exe, //=============== Profile ======================= if (ovdevice.settings.find("MainProfile") != ovdevice.settings.end()) { - NarrowString<0x80> profile(""); + StaticString<0x80> profile(""); profile = "-profile="; std::string str = ovdevice.settings.find("MainProfile")->second; profile += ovdevice.settings.find("MainProfile")->second; @@ -247,7 +247,7 @@ MainMenuWidget::StartSoarExe(std::string_view _exe, //=============== Profile ======================= #ifdef _WIN32 // OpenVario needs no format field! if (ovdevice.settings.find("Format") != ovdevice.settings.end()) { - NarrowString<0x10> format(""); + StaticString<0x10> format(""); format = "-"; format += ovdevice.settings.find("Format")->second; ArgList.push_back(format.c_str()); diff --git a/src/OpenVario/System/WifiDialogOV.cpp b/src/OpenVario/System/WifiDialogOV.cpp index 95d848fc06a..fb76b8cc64b 100644 --- a/src/OpenVario/System/WifiDialogOV.cpp +++ b/src/OpenVario/System/WifiDialogOV.cpp @@ -72,10 +72,10 @@ class WifiListWidget final : public ListWidget { struct NetworkInfo { - NarrowString<64> mac_id; - NarrowString<64> bssid; - NarrowString<256> ssid; - NarrowString<256> base_id; + StaticString<64> mac_id; + StaticString<64> bssid; + StaticString<256> ssid; + StaticString<256> base_id; int signal_level; int id; diff --git a/src/OpenVario/System/WifiSupplicantOV.hpp b/src/OpenVario/System/WifiSupplicantOV.hpp index 91a4e22d143..8b1ebf64ea7 100644 --- a/src/OpenVario/System/WifiSupplicantOV.hpp +++ b/src/OpenVario/System/WifiSupplicantOV.hpp @@ -17,8 +17,8 @@ enum WifiSecurity { }; struct WifiStatus { - NarrowString<64> bssid; - NarrowString<256> ssid; + StaticString<64> bssid; + StaticString<256> ssid; void Clear() { bssid.clear(); @@ -27,10 +27,10 @@ struct WifiStatus { }; struct WifiVisibleNetwork { - NarrowString<64> mac_id; - NarrowString<64> bssid; - NarrowString<256> ssid; - NarrowString<256> base_id; + StaticString<64> mac_id; + StaticString<64> bssid; + StaticString<256> ssid; + StaticString<256> base_id; unsigned signal_level; enum WifiSecurity security; @@ -41,8 +41,8 @@ struct WifiVisibleNetwork { struct WifiConfiguredNetworkInfo { int id; - NarrowString<64> bssid; - NarrowString<256> ssid; + StaticString<64> bssid; + StaticString<256> ssid; }; #if 0 diff --git a/src/Plane/PlaneFileGlue.cpp b/src/Plane/PlaneFileGlue.cpp index 57d12707ec9..cd961ca36b8 100644 --- a/src/Plane/PlaneFileGlue.cpp +++ b/src/Plane/PlaneFileGlue.cpp @@ -145,7 +145,7 @@ try { void PlaneGlue::Write(const Plane &plane, KeyValueFileWriter &writer) { - NarrowString<255> tmp; + StaticString<255> tmp; writer.Write("Registration", plane.registration); writer.Write("CompetitionID", plane.competition_id); diff --git a/src/Profile/GeoValue.cpp b/src/Profile/GeoValue.cpp index 18b15389136..db38b1802f8 100644 --- a/src/Profile/GeoValue.cpp +++ b/src/Profile/GeoValue.cpp @@ -33,7 +33,7 @@ ProfileMap::GetGeoPoint(std::string_view key, GeoPoint &value) const noexcept void ProfileMap::SetGeoPoint(std::string_view key, const GeoPoint &value) noexcept { - NarrowString<128> buffer; + StaticString<128> buffer; buffer.UnsafeFormat("%f %f", (double)value.longitude.Degrees(), (double)value.latitude.Degrees()); diff --git a/src/Repository/AvailableFile.hpp b/src/Repository/AvailableFile.hpp index b65c8750cf2..93b1fae8289 100644 --- a/src/Repository/AvailableFile.hpp +++ b/src/Repository/AvailableFile.hpp @@ -32,7 +32,7 @@ struct AvailableFile { * A short symbolic name for the area. Empty means this file is * global. */ - NarrowString<8> area; + StaticString<8> area; FileType type; diff --git a/src/Tracking/LiveTrack24/Client.cpp b/src/Tracking/LiveTrack24/Client.cpp index afb6a9c8bb4..0154097164e 100644 --- a/src/Tracking/LiveTrack24/Client.cpp +++ b/src/Tracking/LiveTrack24/Client.cpp @@ -40,7 +40,7 @@ Client::GetUserID(const char *username, const char *password) if (!username2.IsValid() || !password2.IsValid()) throw std::runtime_error("WideToUTF8Converter failed"); - NarrowString<1024> url; + StaticString<1024> url; url.Format("http://%s/client.php?op=login&user=%s&pass=%s", GetServer(), easy.Escape(username2).c_str(), @@ -82,7 +82,7 @@ Client::StartTracking(SessionID session, const char *username, throw std::runtime_error("WideToUTF8Converter failed"); const char *version = OpenSoar_VersionLong; - NarrowString<2048> url; + StaticString<2048> url; url.Format("http://%s/track.php?leolive=2&sid=%u&pid=%u&" "client=%s&v=%s&user=%s&pass=%s&vtype=%u&vname=%s", GetServer(), session, 1, @@ -108,7 +108,7 @@ Client::SendPosition(SessionID session, unsigned packet_id, // http://www.livetrack24.com/track.php?leolive=4&sid=42664778&pid=321& // lat=22.3&lon=40.2&alt=23&sog=40&cog=160&tm=1241422845 - NarrowString<2048> url; + StaticString<2048> url; url.Format("http://%s/track.php?leolive=4&sid=%u&pid=%u&" "lat=%f&lon=%f&alt=%d&sog=%d&cog=%d&tm=%lld", GetServer(), session, packet_id, @@ -126,7 +126,7 @@ Client::EndTracking(SessionID session, unsigned packet_id) { // http://www.livetrack24.com/track.php?leolive=3&sid=42664778&pid=453&prid=0 - NarrowString<1024> url; + StaticString<1024> url; url.Format("http://%s/track.php?leolive=3&sid=%u&pid=%u&prid=0", GetServer(), session, packet_id); diff --git a/src/Tracking/LiveTrack24/Client.hpp b/src/Tracking/LiveTrack24/Client.hpp index 2fc76f3196b..e1f0739113f 100644 --- a/src/Tracking/LiveTrack24/Client.hpp +++ b/src/Tracking/LiveTrack24/Client.hpp @@ -42,7 +42,7 @@ namespace LiveTrack24 { class Client final { CurlGlobal &curl; - NarrowString<256> server; + StaticString<256> server; public: explicit Client(CurlGlobal &_curl) noexcept diff --git a/src/Waypoint/WaypointReaderOzi.cpp b/src/Waypoint/WaypointReaderOzi.cpp index 8f7d867c7f4..f1c8a715fd8 100644 --- a/src/Waypoint/WaypointReaderOzi.cpp +++ b/src/Waypoint/WaypointReaderOzi.cpp @@ -53,11 +53,11 @@ WaypointReaderOzi::ParseLine(const char *line, Waypoints &way_points) GeoPoint location; // Latitude (e.g. 5115.900N) - if (!ParseAngle(NarrowString<40>(NextColumn(rest)), location.latitude)) + if (!ParseAngle(StaticString<40>(NextColumn(rest)), location.latitude)) return false; // Longitude (e.g. 00715.900W) - if (!ParseAngle(NarrowString<40>(NextColumn(rest)), location.longitude)) + if (!ParseAngle(StaticString<40>(NextColumn(rest)), location.longitude)) return false; location.Normalize(); // ensure longitude is within -180:180 diff --git a/src/Weather/PCMet/Overlays.cpp b/src/Weather/PCMet/Overlays.cpp index 88de99f904f..49c4fee6670 100644 --- a/src/Weather/PCMet/Overlays.cpp +++ b/src/Weather/PCMet/Overlays.cpp @@ -121,7 +121,7 @@ PCMet::DownloadOverlay(const OverlayInfo &info, BrokenDateTime now_utc, const unsigned run_hour = (now_utc.hour / 3) * 3; unsigned run = (now_utc.hour / 3) * 300; - NarrowString<256> url; + StaticString<256> url; url.Format(PCMET_FTP "/%s_%s_lv_%06u_p_%03u_%04u.tiff", type_names[unsigned(info.type)], area_names[unsigned(info.area)], diff --git a/src/XML/DataNode.cpp b/src/XML/DataNode.cpp index ba5a47829b8..4df0d116049 100644 --- a/src/XML/DataNode.cpp +++ b/src/XML/DataNode.cpp @@ -132,7 +132,7 @@ WritableDataNode::SetAttribute(const char *name, Angle value) noexcept void WritableDataNode::SetAttribute(const char *name, double value) noexcept { - NarrowString<48> buf; + StaticString<48> buf; buf.UnsafeFormat("%g", value); SetAttribute(name, buf); } @@ -162,7 +162,7 @@ WritableDataNode::SetAttribute(const char *name, RoughTime value) noexcept /* no-op */ return; - NarrowString<8> buffer; + StaticString<8> buffer; buffer.UnsafeFormat("%02u:%02u", value.GetHour(), value.GetMinute()); SetAttribute(name, buffer); } diff --git a/src/net/client/WeGlide/UploadFlight.cpp b/src/net/client/WeGlide/UploadFlight.cpp index 81b98972bfd..4b324443d02 100644 --- a/src/net/client/WeGlide/UploadFlight.cpp +++ b/src/net/client/WeGlide/UploadFlight.cpp @@ -42,7 +42,7 @@ UploadFlight(CurlGlobal &curl, const WeGlideSettings &settings, Path igc_path, ProgressListener &progress) { - NarrowString<0x200> url(settings.default_url); + StaticString<0x200> url(settings.default_url); url += "/igcfile"; CurlEasy easy{url}; diff --git a/src/util/StaticString.hxx b/src/util/StaticString.hxx index 88a0c46f69e..07e4ff83d08 100644 --- a/src/util/StaticString.hxx +++ b/src/util/StaticString.hxx @@ -268,7 +268,7 @@ public: * This is the char-based sister of the StaticString class. */ template -class NarrowString: public StaticStringBase +class StaticString: public StaticStringBase { typedef StaticStringBase Base; @@ -289,4 +289,3 @@ public: } }; -#define StaticString NarrowString diff --git a/test/src/AnalyseFlight.cpp b/test/src/AnalyseFlight.cpp index 032ff0e0577..0467bb7be13 100644 --- a/test/src/AnalyseFlight.cpp +++ b/test/src/AnalyseFlight.cpp @@ -176,7 +176,7 @@ WriteEventAttributes(const BrokenDateTime &time, o = boost::json::value_from(location).as_object(); if (time.IsPlausible()) { - NarrowString<64> buffer; + StaticString<64> buffer; FormatISO8601(buffer.buffer(), time); o.emplace("time", buffer.c_str()); } diff --git a/test/src/FLARMEmulator.cpp b/test/src/FLARMEmulator.cpp index 249240adc2c..140cab47074 100644 --- a/test/src/FLARMEmulator.cpp +++ b/test/src/FLARMEmulator.cpp @@ -21,7 +21,7 @@ FLARMEmulator::PFLAC_S(NMEAInputLine &line) noexcept const auto name = line.ReadView(); const auto value = line.Rest(); - NarrowString<256> value_buffer; + StaticString<256> value_buffer; value_buffer.SetASCII(value); settings[std::string{name}] = value_buffer; diff --git a/test/src/FeedFlyNetData.cpp b/test/src/FeedFlyNetData.cpp index b8438a05f7a..5b568363fff 100644 --- a/test/src/FeedFlyNetData.cpp +++ b/test/src/FeedFlyNetData.cpp @@ -48,7 +48,7 @@ try { unsigned battery_level = 11; while (true) { if (pressure_clock.CheckUpdate(std::chrono::milliseconds(48))) { - NarrowString<16> sentence; + StaticString<16> sentence; const auto elapsed = ToFloatSeconds(start_clock.Elapsed()); auto vario = sin(elapsed / 3) * cos(elapsed / 10) * @@ -66,7 +66,7 @@ try { } if (battery_clock.CheckUpdate(std::chrono::seconds(11))) { - NarrowString<16> sentence; + StaticString<16> sentence; sentence = "_BAT "; if (battery_level <= 10) diff --git a/test/src/FlightPhaseJSON.cpp b/test/src/FlightPhaseJSON.cpp index 1b6c421ae09..603e724182f 100644 --- a/test/src/FlightPhaseJSON.cpp +++ b/test/src/FlightPhaseJSON.cpp @@ -42,7 +42,7 @@ static boost::json::object WritePhase(Phase &phase) noexcept { boost::json::object object; - NarrowString<64> buffer; + StaticString<64> buffer; FormatISO8601(buffer.buffer(), phase.start_datetime); object.emplace("start_time", buffer.c_str()); diff --git a/test/src/IGC2NMEA.cpp b/test/src/IGC2NMEA.cpp index c9eea2d7d5c..217aad1ddf1 100644 --- a/test/src/IGC2NMEA.cpp +++ b/test/src/IGC2NMEA.cpp @@ -18,7 +18,7 @@ GenerateNMEA(BufferedOutputStream &os, { char gprmc_buffer[100]; FormatGPRMC(gprmc_buffer, sizeof(gprmc_buffer), basic); - NarrowString<256> gprmc("$"); + StaticString<256> gprmc("$"); gprmc.append(gprmc_buffer); AppendNMEAChecksum(gprmc.buffer()); os.Write(gprmc); @@ -26,7 +26,7 @@ GenerateNMEA(BufferedOutputStream &os, char gpgga_buffer[100]; FormatGPGGA(gpgga_buffer, sizeof(gpgga_buffer), basic); - NarrowString<256> gpgga("$"); + StaticString<256> gpgga("$"); gpgga.append(gpgga_buffer); AppendNMEAChecksum(gpgga.buffer()); os.Write(gpgga); @@ -34,7 +34,7 @@ GenerateNMEA(BufferedOutputStream &os, char pgrmz_buffer[100]; FormatPGRMZ(pgrmz_buffer, sizeof(pgrmz_buffer), basic); - NarrowString<256> pgrmz("$"); + StaticString<256> pgrmz("$"); pgrmz.append(pgrmz_buffer); AppendNMEAChecksum(pgrmz.buffer()); os.Write(pgrmz); diff --git a/test/src/RunDeviceDriver.cpp b/test/src/RunDeviceDriver.cpp index 4da28ffb27b..258c8f233c8 100644 --- a/test/src/RunDeviceDriver.cpp +++ b/test/src/RunDeviceDriver.cpp @@ -160,7 +160,7 @@ Dump(const NMEAInfo &basic) int main(int argc, char **argv) { - NarrowString<1024> usage; + StaticString<1024> usage; usage = "DRIVER\n\n" "Where DRIVER is one of:"; { diff --git a/test/src/RunDownloadFlight.cpp b/test/src/RunDownloadFlight.cpp index 5ff98ef97aa..2c619ea075e 100644 --- a/test/src/RunDownloadFlight.cpp +++ b/test/src/RunDownloadFlight.cpp @@ -63,7 +63,7 @@ PrintFlightList(const RecordedFlightList &flight_list) int main(int argc, char **argv) try { - NarrowString<1024> usage; + StaticString<1024> usage; usage = "DRIVER PORT BAUD FILE.igc [FLIGHT NR]\n\n" "Where DRIVER is one of:"; { diff --git a/test/src/RunFlightList.cpp b/test/src/RunFlightList.cpp index 7b28b73da49..bf6eee38c73 100644 --- a/test/src/RunFlightList.cpp +++ b/test/src/RunFlightList.cpp @@ -57,7 +57,7 @@ NMEAParser::TimeHasAdvanced([[maybe_unused]] TimeStamp this_time, int main(int argc, char **argv) try { - NarrowString<1024> usage; + StaticString<1024> usage; usage = "DRIVER PORT BAUD\n\n" "Where DRIVER is one of:"; { diff --git a/tools/gdb.py b/tools/gdb.py index 78f780b5710..89e64a4cd1d 100644 --- a/tools/gdb.py +++ b/tools/gdb.py @@ -245,7 +245,7 @@ def lookup_function(value): return RoughTimePrinter(value) elif typename == 'RoughTimeSpan': return RoughTimeSpanPrinter(value) - elif typename[:12] == 'StaticString' or typename[:12] == 'NarrowString': + elif typename[:12] == 'StaticString': return StaticStringPrinter(value) return None From 835eb45227045a4477e72eca37e9800fa936b0ca Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 1 May 2024 23:25:35 +0200 Subject: [PATCH 386/403] [UTF8] remove UTF8ToWideConverter, WideToUTF8Converter, WideToACPConverter, _A(), _W(), ConvertString.hpp remove ConvertString.cpp from project --- build/libutil.mk | 1 - src/Airspace/AirspaceParser.cpp | 3 +- src/Device/Descriptor.cpp | 24 ++-- src/Device/Driver/AltairPro.cpp | 5 +- src/Device/Driver/EW.cpp | 6 +- src/Device/Driver/FLARM/Declare.cpp | 5 +- src/Device/Driver/FLARM/Device.cpp | 1 - src/Device/Driver/LX/NanoDeclare.cpp | 6 +- src/Device/Port/ConfiguredPort.cpp | 8 +- src/Dialogs/DownloadFilePicker.cpp | 9 +- src/Dialogs/Error.cpp | 6 +- src/Dialogs/FileManager.cpp | 70 ++++----- src/Dialogs/Plane/PlanePolarDialog.cpp | 1 - src/Dialogs/ProcessDialog.cpp | 1 - .../Task/Manager/WeGlideTasksPanel.cpp | 9 +- src/Dialogs/dlgCredits.cpp | 14 +- src/OpenVario/OpenVarioBaseMenu.cpp | 1 - src/OpenVario/System/OpenVarioDevice.cpp | 1 - src/OpenVario/System/OpenVarioTools.cpp | 1 - src/OpenVario/System/SystemMenuWidget.cpp | 1 - src/OpenVario/System/WifiDialogOV.cpp | 39 +++-- src/OpenVario/SystemSettingsWidget.cpp | 1 - src/Operation/Operation.cpp | 3 +- src/Task/Deserialiser.cpp | 11 +- src/Task/Serialiser.cpp | 9 +- src/Task/XCTrackTaskDecoder.cpp | 6 +- src/Terrain/RasterTerrain.cpp | 1 - src/Tracking/LiveTrack24/Client.cpp | 22 +-- src/Tracking/SkyLines/Client.cpp | 4 +- src/Weather/PCMet/Images.cpp | 16 +-- src/Weather/PCMet/Overlays.cpp | 14 +- src/Widget/ProfileRowFormWidget.cpp | 8 +- src/lib/curl/Setup.cxx | 3 +- src/lua/Basic.cpp | 3 +- src/lua/Dialogs.cpp | 5 +- src/lua/Full.cpp | 4 +- src/lua/Geo.cpp | 3 +- src/lua/InputEvent.cpp | 29 ++-- src/lua/Legacy.cpp | 9 +- src/lua/Replay.cpp | 5 +- src/net/client/WeGlide/UploadIGCFile.cpp | 19 ++- src/util/CMakeSource.cmake | 1 - src/util/ConvertString.cpp | 7 - src/util/ConvertString.hpp | 135 ------------------ test/src/Printing.cpp | 3 +- test/src/RunDeviceDriver.cpp | 4 +- test/src/RunDownloadFlight.cpp | 4 +- test/src/RunFlarmUtils.cpp | 19 +-- test/src/RunFlightList.cpp | 4 +- test/src/TestPolars.cpp | 10 +- test/src/harness_airspace.cpp | 3 +- 51 files changed, 154 insertions(+), 423 deletions(-) delete mode 100644 src/util/ConvertString.cpp delete mode 100644 src/util/ConvertString.hpp diff --git a/build/libutil.mk b/build/libutil.mk index f7078db0c72..c7d47f92edb 100644 --- a/build/libutil.mk +++ b/build/libutil.mk @@ -11,7 +11,6 @@ UTIL_SOURCES = \ $(UTIL_SRC_DIR)/ASCII.cxx \ $(UTIL_SRC_DIR)/TruncateString.cpp \ $(UTIL_SRC_DIR)/EscapeBackslash.cpp \ - $(UTIL_SRC_DIR)/ConvertString.cpp \ $(UTIL_SRC_DIR)/StaticString.cxx \ $(UTIL_SRC_DIR)/StringBuilder.cxx \ $(UTIL_SRC_DIR)/StringCompare.cxx \ diff --git a/src/Airspace/AirspaceParser.cpp b/src/Airspace/AirspaceParser.cpp index a93ed6e5ca4..7be96e6384f 100644 --- a/src/Airspace/AirspaceParser.cpp +++ b/src/Airspace/AirspaceParser.cpp @@ -18,7 +18,6 @@ #include "lib/fmt/RuntimeError.hxx" #include "io/BufferedReader.hxx" #include "io/StringConverter.hpp" -#include "util/ConvertString.hpp" #include "util/StaticString.hxx" #include "util/StringCompare.hxx" #include "util/StringSplit.hxx" @@ -975,7 +974,7 @@ ParseAirspaceFile(Airspaces &airspaces, } if (filetype == AirspaceFileType::UNKNOWN) - throw std::runtime_error(WideToUTF8Converter(_("Unknown airspace filetype"))); + throw std::runtime_error(_("Unknown airspace filetype")); // Process final area (if any) temp_area.Commit(airspaces); diff --git a/src/Device/Descriptor.cpp b/src/Device/Descriptor.cpp index 99b73353500..ddaaf6e7898 100644 --- a/src/Device/Descriptor.cpp +++ b/src/Device/Descriptor.cpp @@ -16,7 +16,6 @@ #include "NMEA/Info.hpp" #include "thread/Mutex.hxx" #include "util/StringAPI.hxx" -#include "util/ConvertString.hpp" #include "util/Exception.hxx" #include "Logger/NMEALogger.hpp" #include "Language/Language.hpp" @@ -391,15 +390,15 @@ try { char name_buffer[64]; const char *name = config.GetPortName(name_buffer, 64); - LogError(e, _A(name)); - - const auto _msg = GetFullMessage(e); - if (const UTF8ToWideConverter what{_msg.c_str()}; what.IsValid()) { - LockSetErrorMessage(what); + LogError(e, name); + + // const std::string_view _msg(GetFullMessage(e)); + const auto what = GetFullMessage(e); + if (what.c_str() != nullptr) { StaticString<256> msg; - msg.Format("%s: %s (%s)", _("Unable to open port"), name, - (const char *)what); + LockSetErrorMessage(what.c_str()); + msg.Format("%s: %s (%s)", _("Unable to open port"), name, what.c_str()); env.SetErrorMessage(msg); } @@ -437,11 +436,10 @@ try { const auto e = std::current_exception(); LogError(e); - const auto _msg = GetFullMessage(e); - - if (const UTF8ToWideConverter msg{_msg.c_str()}; msg.IsValid()) { - LockSetErrorMessage(msg); - env.SetErrorMessage(msg); + const auto msg = GetFullMessage(e); + if (msg.c_str() != nullptr) { + LockSetErrorMessage(msg.c_str()); + env.SetErrorMessage(msg.c_str()); } return false; diff --git a/src/Device/Driver/AltairPro.cpp b/src/Device/Driver/AltairPro.cpp index eda5200f783..514179b9a1e 100644 --- a/src/Device/Driver/AltairPro.cpp +++ b/src/Device/Driver/AltairPro.cpp @@ -11,7 +11,6 @@ #include "NMEA/InputLine.hpp" #include "Units/System.hpp" #include "Waypoint/Waypoint.hpp" -#include "util/ConvertString.hpp" #include "util/TruncateString.hpp" #include "util/Macros.hpp" #include "time/TimeoutClock.hpp" @@ -232,8 +231,8 @@ AltairProDevice::PutTurnPoint(const char *propertyName, char NoS, EoW; if (waypoint != nullptr){ - if (WideToACPConverter wp_name{waypoint->name.c_str()}; wp_name.IsValid()) - CopyTruncateString(Name, ARRAY_SIZE(Name), wp_name); + if (waypoint->name.c_str()) + CopyTruncateString(Name, ARRAY_SIZE(Name), waypoint->name.c_str()); else throw std::runtime_error("Invalid string"); diff --git a/src/Device/Driver/EW.cpp b/src/Device/Driver/EW.cpp index a8724a0fc2f..ac43099b39f 100644 --- a/src/Device/Driver/EW.cpp +++ b/src/Device/Driver/EW.cpp @@ -14,7 +14,6 @@ #include "NMEA/Checksum.hpp" #include "Operation/Operation.hpp" #include "util/TruncateString.hpp" -#include "util/ConvertString.hpp" #include "util/ScopeExit.hxx" #include @@ -197,12 +196,11 @@ EWDevice::AddWaypoint(const Waypoint &way_point, OperationEnvironment &env) return false; // copy at most 6 chars - const WideToUTF8Converter name_utf8(way_point.name.c_str()); - if (!name_utf8.IsValid()) + if (way_point.name.empty()) return false; char IDString[12]; - char *end = CopyTruncateString(IDString, 7, name_utf8); + char *end = CopyTruncateString(IDString, 7, way_point.name.c_str()); // fill up with spaces std::fill(end, IDString + 6, ' '); diff --git a/src/Device/Driver/FLARM/Declare.cpp b/src/Device/Driver/FLARM/Declare.cpp index 4a131614e3e..8c7b525ef13 100644 --- a/src/Device/Driver/FLARM/Declare.cpp +++ b/src/Device/Driver/FLARM/Declare.cpp @@ -4,7 +4,6 @@ #include "Device.hpp" #include "Device/Declaration.hpp" #include "Operation/Operation.hpp" -#include "util/ConvertString.hpp" #include "TextProtocol.hpp" bool @@ -104,11 +103,11 @@ FlarmDevice::DeclareInternal(const Declaration &declaration, * so that a dodgy waypoint configuration doesn't cause an overflow. */ StaticString<90> buffer; - const WideToUTF8Converter shortName(declaration.GetShortName(i)); buffer.Format("%02d%05.0f%c,%03d%05.0f%c,", DegLat, (double)MinLat, NoS, DegLon, (double)MinLon, EoW); - CopyCleanFlarmString(buffer.buffer() + buffer.length(), shortName, 6); + CopyCleanFlarmString(buffer.buffer() + buffer.length(), + declaration.GetShortName(i), 6); if (!SetConfig("ADDWP", buffer, env)) return false; diff --git a/src/Device/Driver/FLARM/Device.cpp b/src/Device/Driver/FLARM/Device.cpp index 101929ee57f..6e9a2aba6aa 100644 --- a/src/Device/Driver/FLARM/Device.cpp +++ b/src/Device/Driver/FLARM/Device.cpp @@ -3,7 +3,6 @@ #include "Device.hpp" #include "Device/Port/Port.hpp" -#include "util/ConvertString.hpp" #include "util/StaticString.hxx" #include "util/TruncateString.hpp" #include "util/Macros.hpp" diff --git a/src/Device/Driver/LX/NanoDeclare.cpp b/src/Device/Driver/LX/NanoDeclare.cpp index 72c5b02ecc9..0b5b5e2ebf2 100644 --- a/src/Device/Driver/LX/NanoDeclare.cpp +++ b/src/Device/Driver/LX/NanoDeclare.cpp @@ -10,7 +10,6 @@ #include "time/TimeoutClock.hpp" #include "time/BrokenDateTime.hpp" #include "Operation/Operation.hpp" -#include "util/ConvertString.hpp" static bool NanoWriteDecl(Port &port, OperationEnvironment &env, PortNMEAReader &reader, @@ -47,12 +46,11 @@ NanoWriteDeclString(Port &port, OperationEnvironment &env, unsigned row, unsigned n_rows, const char *prefix, const char *value) { - WideToUTF8Converter narrow_value(value); - if (!narrow_value.IsValid()) + if (!value) return false; return NanoWriteDeclFormat(port, env, reader, row, n_rows, - "%s%s", prefix, (const char *)narrow_value); + "%s%s", prefix, value); } static bool diff --git a/src/Device/Port/ConfiguredPort.cpp b/src/Device/Port/ConfiguredPort.cpp index 782d7c9e678..2cfe12dc181 100644 --- a/src/Device/Port/ConfiguredPort.cpp +++ b/src/Device/Port/ConfiguredPort.cpp @@ -7,7 +7,6 @@ #include "K6BtPort.hpp" #include "Device/Config.hpp" #include "LogFile.hpp" -#include "util/ConvertString.hpp" #include "TCPClientPort.hpp" #ifdef ANDROID @@ -183,12 +182,11 @@ OpenPortInternal(EventLoop &event_loop, Cares::Channel &cares, break; case DeviceConfig::PortType::TCP_CLIENT: { - const WideToUTF8Converter ip_address(config.ip_address); - if (!ip_address.IsValid()) + if (config.ip_address.empty()) throw std::runtime_error("No IP address configured"); - return std::make_unique(event_loop, cares, - ip_address, config.tcp_port, + return std::make_unique(event_loop, cares, config.ip_address, + config.tcp_port, listener, handler); } diff --git a/src/Dialogs/DownloadFilePicker.cpp b/src/Dialogs/DownloadFilePicker.cpp index 912ad0f275e..530fa6bc668 100644 --- a/src/Dialogs/DownloadFilePicker.cpp +++ b/src/Dialogs/DownloadFilePicker.cpp @@ -24,7 +24,6 @@ #include "ui/event/PeriodicTimer.hpp" #include "thread/Mutex.hxx" #include "Operation/ThreadedOperationEnvironment.hpp" -#include "util/ConvertString.hpp" #include @@ -106,12 +105,11 @@ class DownloadProgress final : Net::DownloadListener { * Throws on error. */ static AllocatedPath -DownloadFile(const char *uri, const char *_base) +DownloadFile(const char *uri, const char *base) { assert(Net::DownloadManager::IsAvailable()); - const UTF8ToWideConverter base(_base); - if (!base.IsValid()) + if (!base) return nullptr; ProgressDialog dialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), @@ -285,8 +283,7 @@ DownloadFilePickerWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, { const auto &file = items[i]; - const UTF8ToWideConverter name(file.GetName()); - row_renderer.DrawTextRow(canvas, rc, name); + row_renderer.DrawTextRow(canvas, rc, file.GetName()); } void diff --git a/src/Dialogs/Error.cpp b/src/Dialogs/Error.cpp index 132048640f9..269dbb82c02 100644 --- a/src/Dialogs/Error.cpp +++ b/src/Dialogs/Error.cpp @@ -3,14 +3,13 @@ #include "Error.hpp" #include "Message.hpp" -#include "util/ConvertString.hpp" #include "util/Exception.hxx" #include "util/StaticString.hxx" void ShowError(std::exception_ptr e, const char *caption) noexcept { - ShowMessageBox(UTF8ToWideConverter(GetFullMessage(e).c_str()), caption, + ShowMessageBox(GetFullMessage(e).c_str(), caption, MB_OK|MB_ICONEXCLAMATION); } @@ -19,8 +18,7 @@ ShowError(const char *msg, std::exception_ptr e, const char *caption) noexcept { StaticString<1024> buffer; - buffer.Format("%s\n%s", msg, - UTF8ToWideConverter(GetFullMessage(e).c_str()).c_str()); + buffer.Format("%s\n%s", msg, GetFullMessage(e).c_str()); buffer.CropIncompleteUTF8(); ShowMessageBox(msg, caption, diff --git a/src/Dialogs/FileManager.cpp b/src/Dialogs/FileManager.cpp index 9179fcdc624..0396a17ffa7 100644 --- a/src/Dialogs/FileManager.cpp +++ b/src/Dialogs/FileManager.cpp @@ -18,7 +18,6 @@ #include "Formatter/TimeFormatter.hpp" #include "time/BrokenDateTime.hpp" #include "net/http/Features.hpp" -#include "util/ConvertString.hpp" #include "util/Macros.hpp" #include "Repository/FileRepository.hpp" #include "Repository/Parser.hpp" @@ -42,11 +41,10 @@ static AllocatedPath LocalPath(const AvailableFile &file) { - const UTF8ToWideConverter base(file.GetName()); - if (!base.IsValid()) + if (!file.GetName()) return nullptr; - return LocalPath(base); + return LocalPath(file.GetName()); } #ifdef HAVE_DOWNLOAD_MANAGER @@ -495,11 +493,11 @@ ManagedFileListWidget::Download() return; const AvailableFile &remote_file = *remote_file_p; - const UTF8ToWideConverter base(remote_file.GetName()); - if (!base.IsValid()) + if (!remote_file.GetName()) return; - Net::DownloadManager::Enqueue(remote_file.uri.c_str(), Path(base)); + Net::DownloadManager::Enqueue(remote_file.uri.c_str(), + Path(remote_file.GetName())); #endif } @@ -530,13 +528,11 @@ AddFileListItemRenderer::OnPaintItem(Canvas &canvas, const PixelRect rc, const AvailableFile &file = list[i]; - const UTF8ToWideConverter name(file.GetName()); - if (name.IsValid()) - row_renderer.DrawFirstRow(canvas, rc, name); + if (file.GetName()) + row_renderer.DrawFirstRow(canvas, rc, file.GetName()); - const UTF8ToWideConverter description(file.GetDescription()); - if (description.IsValid()) - row_renderer.DrawSecondRow(canvas, rc, description); + if (file.GetDescription()) + row_renderer.DrawSecondRow(canvas, rc, file.GetDescription()); if (file.update_date.IsPlausible()) { char string_buffer[21]; @@ -559,11 +555,10 @@ ManagedFileListWidget::Add() /* already downloading this file */ continue; - const UTF8ToWideConverter name(remote_file.GetName()); - if (!name.IsValid()) + if (!remote_file.GetName()) continue; - if (FindItem(name) < 0) + if (FindItem(remote_file.GetName()) < 0) list.push_back(remote_file); } @@ -581,11 +576,11 @@ ManagedFileListWidget::Add() assert((unsigned)i < list.size()); const AvailableFile &remote_file = list[i]; - const UTF8ToWideConverter base(remote_file.GetName()); - if (!base.IsValid()) + if (!remote_file.GetName()) return; - Net::DownloadManager::Enqueue(remote_file.GetURI(), Path(base)); + Net::DownloadManager::Enqueue(remote_file.GetURI(), + Path(remote_file.GetName())); #endif } @@ -599,11 +594,11 @@ ManagedFileListWidget::UpdateFiles() { const AvailableFile *remote_file = FindRemoteFile(repository, file.name); if (remote_file != nullptr) { - const UTF8ToWideConverter base(remote_file->GetName()); - if (!base.IsValid()) + if (!remote_file->GetName()) return; - Net::DownloadManager::Enqueue(remote_file->GetURI(), Path(base)); + Net::DownloadManager::Enqueue(remote_file->GetURI(), + Path(remote_file->GetName())); } } } @@ -655,16 +650,10 @@ ManagedFileListWidget::OnDownloadAdded(Path path_relative, if (name == nullptr) return; - const WideToUTF8Converter name2(name.c_str()); - if (!name2.IsValid()) - return; - - const std::string name3(name2); - { const std::lock_guard lock{mutex}; - downloads[name3] = DownloadStatus{size, position}; - failures.erase(name3); + downloads[name.c_str()] = DownloadStatus{size, position}; + failures.erase(name.c_str()); } download_notify.SendNotification(); @@ -677,18 +666,12 @@ ManagedFileListWidget::OnDownloadComplete(Path path_relative) noexcept if (name == nullptr) return; - const WideToUTF8Converter name2(name.c_str()); - if (!name2.IsValid()) - return; - - const std::string name3(name2); - { const std::lock_guard lock{mutex}; - downloads.erase(name3); + downloads.erase(name.c_str()); - if (StringIsEqual(name2, "repository")) { + if (StringIsEqual(name.c_str(), "repository")) { repository_failed = false; repository_modified = true; } @@ -705,22 +688,17 @@ ManagedFileListWidget::OnDownloadError(Path path_relative, if (name == nullptr) return; - const WideToUTF8Converter name2(name.c_str()); - if (!name2.IsValid()) - return; - - const std::string name3(name2); { const std::lock_guard lock{mutex}; - downloads.erase(name3); + downloads.erase(name.c_str()); // TODO: store the error - if (StringIsEqual(name2, "repository")) { + if (StringIsEqual(name.c_str(), "repository")) { repository_failed = true; } else - failures.insert(name3); + failures.insert(name.c_str()); } download_notify.SendNotification(); diff --git a/src/Dialogs/Plane/PlanePolarDialog.cpp b/src/Dialogs/Plane/PlanePolarDialog.cpp index 834fdfe7931..a7e2b77720b 100644 --- a/src/Dialogs/Plane/PlanePolarDialog.cpp +++ b/src/Dialogs/Plane/PlanePolarDialog.cpp @@ -18,7 +18,6 @@ #include "system/Path.hpp" #include "Language/Language.hpp" #include "UIGlobals.hpp" -#include "util/ConvertString.hpp" class PlanePolarWidget final : public RowFormWidget, DataFieldListener { diff --git a/src/Dialogs/ProcessDialog.cpp b/src/Dialogs/ProcessDialog.cpp index 5a1d7932b87..fd4eaf35adc 100644 --- a/src/Dialogs/ProcessDialog.cpp +++ b/src/Dialogs/ProcessDialog.cpp @@ -19,7 +19,6 @@ #include #ifdef _WIN32 // TODO(August2111): needs work! -#include "util/ConvertString.hpp" typedef size_t pid_t; #include #else diff --git a/src/Dialogs/Task/Manager/WeGlideTasksPanel.cpp b/src/Dialogs/Task/Manager/WeGlideTasksPanel.cpp index 3a5c5f54471..7664627765d 100644 --- a/src/Dialogs/Task/Manager/WeGlideTasksPanel.cpp +++ b/src/Dialogs/Task/Manager/WeGlideTasksPanel.cpp @@ -25,7 +25,6 @@ #include "net/http/Init.hpp" #include "lib/curl/Global.hxx" #include "util/Compiler.h" -#include "util/ConvertString.hpp" #include "UIGlobals.hpp" #include "Components.hpp" #include "DataComponents.hpp" @@ -123,12 +122,12 @@ WeGlideTasksPanel::OnPaintItem(Canvas &canvas, const PixelRect rc, assert(idx <= list.size()); const auto &info = list[idx]; - if (UTF8ToWideConverter w{info.name.c_str()}; w.IsValid()) - row_renderer.DrawFirstRow(canvas, rc, w); + if (info.name.c_str()) + row_renderer.DrawFirstRow(canvas, rc, info.name.c_str()); if (selection != WeGlideTaskSelection::USER) - if (UTF8ToWideConverter w{info.user_name.c_str()}; w.IsValid()) - row_renderer.DrawSecondRow(canvas, rc, w); + if (info.user_name.c_str()) + row_renderer.DrawSecondRow(canvas, rc, info.user_name.c_str()); row_renderer.DrawRightSecondRow(canvas, rc, FormatUserDistanceSmart(info.distance)); diff --git a/src/Dialogs/dlgCredits.cpp b/src/Dialogs/dlgCredits.cpp index 275065eec1d..544fc31a08a 100644 --- a/src/Dialogs/dlgCredits.cpp +++ b/src/Dialogs/dlgCredits.cpp @@ -15,7 +15,6 @@ #include "ui/canvas/Font.hpp" #include "Version.hpp" #include "Inflate.hpp" -#include "util/ConvertString.hpp" #include "util/AllocatedString.hxx" #include "Resources.hpp" #include "UIGlobals.hpp" @@ -133,24 +132,19 @@ dlgCreditsShowModal([[maybe_unused]] UI::SingleWindow &parent) const DialogLook &look = UIGlobals::GetDialogLook(); const auto authors = InflateToString(AUTHORS_gz, AUTHORS_gz_size); - const UTF8ToWideConverter authors2(authors.c_str()); - const auto news = InflateToString(OpenSoar_News_md_gz, OpenSoar_News_md_gz_size); - const UTF8ToWideConverter news2(news.c_str()); - const auto license = InflateToString(COPYING_gz, COPYING_gz_size); - const UTF8ToWideConverter license2(license.c_str()); - + WidgetDialog dialog(WidgetDialog::Full{}, UIGlobals::GetMainWindow(), look, _("Credits")); auto pager = std::make_unique(look.button, dialog.MakeModalResultCallback(mrOK)); pager->Add(std::make_unique(CreateLogoPage)); - pager->Add(std::make_unique(look, authors2)); - pager->Add(std::make_unique(look, news2)); - pager->Add(std::make_unique(look, license2)); + pager->Add(std::make_unique(look, authors.c_str())); + pager->Add(std::make_unique(look, news.c_str())); + pager->Add(std::make_unique(look, license.c_str())); dialog.FinishPreliminary(std::move(pager)); dialog.ShowModal(); diff --git a/src/OpenVario/OpenVarioBaseMenu.cpp b/src/OpenVario/OpenVarioBaseMenu.cpp index 02759ba5aef..a8b04cfa0e5 100644 --- a/src/OpenVario/OpenVarioBaseMenu.cpp +++ b/src/OpenVario/OpenVarioBaseMenu.cpp @@ -33,7 +33,6 @@ #include "OpenVario/System/OpenVarioDevice.hpp" #include "OpenVario/System/SystemMenuWidget.hpp" -#include "util/ConvertString.hpp" #include "LocalPath.hpp" #include "LogFile.hpp" #include "Dialogs/Message.hpp" diff --git a/src/OpenVario/System/OpenVarioDevice.cpp b/src/OpenVario/System/OpenVarioDevice.cpp index 4a7a44938ce..6d88c99dbb7 100644 --- a/src/OpenVario/System/OpenVarioDevice.cpp +++ b/src/OpenVario/System/OpenVarioDevice.cpp @@ -21,7 +21,6 @@ #include "Profile/Map.hpp" #include "util/StaticString.hxx" -#include "util/ConvertString.hpp" #include "util/StringCompare.hxx" #include "LogFile.hpp" diff --git a/src/OpenVario/System/OpenVarioTools.cpp b/src/OpenVario/System/OpenVarioTools.cpp index 5354db9de67..660ebfff186 100644 --- a/src/OpenVario/System/OpenVarioTools.cpp +++ b/src/OpenVario/System/OpenVarioTools.cpp @@ -17,7 +17,6 @@ #include "ui/event/Timer.hpp" #include "ui/window/Init.hpp" #include "util/ScopeExit.hxx" -#include "util/ConvertString.hpp" //---------------------------------------------------------- diff --git a/src/OpenVario/System/SystemMenuWidget.cpp b/src/OpenVario/System/SystemMenuWidget.cpp index de87e69d5e9..d6213455a52 100644 --- a/src/OpenVario/System/SystemMenuWidget.cpp +++ b/src/OpenVario/System/SystemMenuWidget.cpp @@ -26,7 +26,6 @@ #include "ui/event/Timer.hpp" #include "ui/window/Init.hpp" #include "util/ScopeExit.hxx" -#include "util/ConvertString.hpp" #include "OpenVario/SystemSettingsWidget.hpp" diff --git a/src/OpenVario/System/WifiDialogOV.cpp b/src/OpenVario/System/WifiDialogOV.cpp index fb76b8cc64b..444be088f00 100644 --- a/src/OpenVario/System/WifiDialogOV.cpp +++ b/src/OpenVario/System/WifiDialogOV.cpp @@ -18,7 +18,6 @@ #include "ui/event/PeriodicTimer.hpp" #include "util/HexFormat.hxx" #include "util/StaticString.hxx" -#include "util/ConvertString.hpp" #include "LocalPath.hpp" #include "LogFile.hpp" @@ -248,8 +247,8 @@ WifiListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, "Open", }; - row_renderer.DrawFirstRow(canvas, rc, _W(info.ssid)); - row_renderer.DrawSecondRow(canvas, rc,_W(info.bssid)); + row_renderer.DrawFirstRow(canvas, rc, info.ssid); + row_renderer.DrawSecondRow(canvas, rc,info.bssid); const char *state = nullptr; StaticString<40> state_buffer; @@ -304,7 +303,7 @@ WifiListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, if (info.signal_level >= 0) { StaticString<32> text; - text.UnsafeFormat("%s %u", _W(wifi_security[info.security]), + text.UnsafeFormat("%s %u", wifi_security[info.security], info.signal_level); row_renderer.DrawRightSecondRow(canvas, rc, text); } @@ -315,13 +314,13 @@ WifiListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, void WifiListWidget::WifiDisconnect( const char *ssid) { auto network = FindVisibleBySSID(ssid); // StaticString<0x100> base_id; -// base_id.Format("wifi_%s_%s_managed_", _W(network->mac_id.c_str()), -// _W(network->bssid.c_str())); +// base_id.Format("wifi_%s_%s_managed_", network->mac_id.c_str()), +// network->bssid.c_str())); #if defined(IS_OPENVARIO_CB2) // disconnect port Run(Path("wifi-disconnect.txt"), connmanctl, "disconnect", network->base_id.c_str()); #endif - ShowMessageBox(_W(network->base_id.c_str()), "Disconnected", MB_OK); + ShowMessageBox(network->base_id.c_str(), "Disconnected", MB_OK); } void WifiListWidget::WifiConnect(enum WifiSecurity security, @@ -329,13 +328,13 @@ void WifiListWidget::WifiConnect(enum WifiSecurity security, const char *ssid, const char *psk) { { -// ShowMessageBox(_W(psk), "Wifi-Passphrase", MB_OK); +// ShowMessageBox(psk, "Wifi-Passphrase", MB_OK); auto network = FindVisibleBySSID(ssid); std::cout << "Test: " << 1 << std::endl; // StaticString<0x100> base_id; -// base_id.Format("wifi_%s_%s_managed_", _W(network->mac_id.c_str()), -// _W(network->bssid.c_str())); +// base_id.Format("wifi_%s_%s_managed_", network->mac_id.c_str()), +// network->bssid.c_str()); // std::cout << "Test: " << 2 << std::endl; // switch (network->security) { @@ -366,27 +365,27 @@ void WifiListWidget::WifiConnect(enum WifiSecurity security, IPv6.privacy=disabled #endif // WithWPA StaticString<0x1000> buffer; - buffer.Format("[%s]\n", _W(network->base_id.c_str())); - buffer.AppendFormat("Type=%s\n", _W("wifi")); - buffer.AppendFormat("Name=%s\n", _W(ssid)); + buffer.Format("[%s]\n", network->base_id.c_str()); + buffer.AppendFormat("Type=%s\n", "wifi"); + buffer.AppendFormat("Name=%s\n", ssid); buffer.AppendFormat("SSID=%s\n", - _W(network->bssid.c_str())); // _W(network->bssid); + network->bssid.c_str()); // network->bssid; buffer.AppendFormat("Frequency=%d\n", 2412); // buffer.AppendFormat("Favorite=true\n"); buffer.append("Favorite=true\n"); buffer.append("AutoConnect=true\n"); - buffer.AppendFormat("Passphrase=%s\n", _W(psk)); + buffer.AppendFormat("Passphrase=%s\n", psk); // buffer.AppendFormat("Modified=2024-02-01T12:38:31Z\n"); buffer.AppendFormat("IPv4.method=%s\n", "dhcp"); // buffer.AppendFormat("IPv4.DHCP.LastAddress=192.168.178.32\n"); buffer.append("IPv6.method=off\n"); buffer.append("IPv6.privacy=disabled\n"); std::cout << "Test: " << 6 << std::endl; - std::cout << _A(buffer.c_str()) << std::endl; + std::cout << buffer << std::endl; ShowMessageBox(buffer.c_str(), "WifiConnect", MB_OK); std::cout << "Test: " << 7 << std::endl; - Path base_id(_W(network->base_id.c_str())); + Path base_id(network->base_id.c_str()); #if defined(IS_OPENVARIO_CB2) // save on the connman setting location: @@ -403,7 +402,7 @@ void WifiListWidget::WifiConnect(enum WifiSecurity security, else Directory::Create(ssid_path); File::CreateExclusive(setting_file); - File::WriteExisting(setting_file, _A(buffer.c_str())); + File::WriteExisting(setting_file, buffer); #if defined(IS_OPENVARIO_CB2) // disable wifi @@ -507,7 +506,7 @@ WifiListWidget::Connect() const auto ssid = info.ssid; StaticString<256> caption; - caption.Format(_("Passphrase of network '%s'"), _W(ssid.c_str())); + caption.Format(_("Passphrase of network '%s'"), ssid.c_str()); StaticString<32> passphrase; passphrase.clear(); @@ -517,7 +516,7 @@ WifiListWidget::Connect() return; WifiConnect(info.security, /* wpa_supplicant, */ info.ssid, - _A(passphrase.c_str())); + passphrase); // } else { // wpa_supplicant.RemoveNetwork(info.id); // wpa_supplicant.SaveConfig(); diff --git a/src/OpenVario/SystemSettingsWidget.cpp b/src/OpenVario/SystemSettingsWidget.cpp index 3c50854ea82..75d535e2461 100644 --- a/src/OpenVario/SystemSettingsWidget.cpp +++ b/src/OpenVario/SystemSettingsWidget.cpp @@ -108,7 +108,6 @@ SystemSettingsWidget::OnModified([[maybe_unused]] DataField &df) noexcept SetEnabled(((const DataFieldBoolean &)df).GetValue()); } else if (IsDataField(FIRMWARE, df)) { // (DataFieldInteger*)df) - // ConvertString ShowMessageBox("FirmWare-Selection", "??File??", MB_OKCANCEL); } } diff --git a/src/Operation/Operation.cpp b/src/Operation/Operation.cpp index 4a682198226..94e7751d354 100644 --- a/src/Operation/Operation.cpp +++ b/src/Operation/Operation.cpp @@ -3,13 +3,12 @@ #include "Operation/Operation.hpp" #include "system/Sleep.h" -#include "util/ConvertString.hpp" #include "util/Exception.hxx" void OperationEnvironment::SetError(std::exception_ptr e) noexcept { - SetErrorMessage(UTF8ToWideConverter(GetFullMessage(e).c_str())); + SetErrorMessage(GetFullMessage(e).c_str()); } bool diff --git a/src/Task/Deserialiser.cpp b/src/Task/Deserialiser.cpp index 049c8f817c2..add690d0b69 100644 --- a/src/Task/Deserialiser.cpp +++ b/src/Task/Deserialiser.cpp @@ -14,7 +14,6 @@ #include "Task/Factory/AbstractTaskFactory.hpp" #include "XML/DataNode.hpp" #include "Engine/Waypoint/Waypoints.hpp" -#include "util/ConvertString.hpp" #include @@ -35,16 +34,14 @@ DeserialiseWaypoint(const ConstDataNode &node, const Waypoints *waypoints) GeoPoint loc; Deserialise(loc, *loc_node); - const char *_name = node.GetAttribute("name"); - if (_name == nullptr) + const char *name = node.GetAttribute("name"); + if (name == nullptr) // Turnpoints need names return nullptr; - const UTF8ToWideConverter name{_name}; - if (waypoints != nullptr) { // Try to find waypoint by name - auto from_database = waypoints->LookupName(name.c_str()); + auto from_database = waypoints->LookupName(name); // If waypoint by name found and closer than 10m to the original if (from_database != nullptr && @@ -70,7 +67,7 @@ DeserialiseWaypoint(const ConstDataNode &node, const Waypoints *waypoints) const char *comment = node.GetAttribute("comment"); if (comment != nullptr) - wp->comment = UTF8ToWideConverter{comment}; + wp->comment = comment; if (node.GetAttribute("altitude", wp->elevation)) wp->has_elevation = true; diff --git a/src/Task/Serialiser.cpp b/src/Task/Serialiser.cpp index 60232e5f25e..bca0802a47e 100644 --- a/src/Task/Serialiser.cpp +++ b/src/Task/Serialiser.cpp @@ -12,7 +12,6 @@ #include "Task/ObservationZones/SymmetricSectorZone.hpp" #include "XML/DataNode.hpp" #include "util/Compiler.h" -#include "util/ConvertString.hpp" #include #include @@ -58,9 +57,9 @@ Serialise(WritableDataNode &node, const GeoPoint &data) static void Serialise(WritableDataNode &node, const Waypoint &data) { - node.SetAttribute("name", WideToUTF8Converter(data.name.c_str())); + node.SetAttribute("name", data.name.c_str()); node.SetAttribute("id", data.id); - node.SetAttribute("comment", WideToUTF8Converter(data.comment.c_str())); + node.SetAttribute("comment", data.comment.c_str()); if (data.has_elevation) node.SetAttribute("altitude", data.elevation); @@ -170,7 +169,7 @@ Serialise(WritableDataNode &node, const OrderedTaskPoint &data, { // do nothing auto child = node.AppendChild("Point"); - child->SetAttribute("type", WideToUTF8Converter(name)); + child->SetAttribute("type", name); Serialise(*child->AppendChild("Waypoint"), data.GetWaypoint()); Serialise(*child->AppendChild("ObservationZone"), @@ -269,7 +268,7 @@ Serialise(WritableDataNode &node, const OrderedTaskSettings &data) void SaveTask(WritableDataNode &node, const OrderedTask &task) { - node.SetAttribute("type", WideToUTF8Converter(GetTaskFactoryType(task.GetFactoryType()))); + node.SetAttribute("type", GetTaskFactoryType(task.GetFactoryType())); Serialise(node, task.GetOrderedTaskSettings()); for (const auto &tp : task.GetPoints()) diff --git a/src/Task/XCTrackTaskDecoder.cpp b/src/Task/XCTrackTaskDecoder.cpp index ceeb4d816c5..a87d999fef6 100644 --- a/src/Task/XCTrackTaskDecoder.cpp +++ b/src/Task/XCTrackTaskDecoder.cpp @@ -12,7 +12,6 @@ #include "Engine/Task/Ordered/Points/ASTPoint.hpp" #include "Engine/Waypoint/Ptr.hpp" #include "Engine/Waypoint/Waypoint.hpp" -#include "util/ConvertString.hpp" #include @@ -95,12 +94,11 @@ DecodeXCTrackTask(const boost::json::value &_j, if (name.empty()) throw std::invalid_argument{"Name is empty"}; - const UTF8ToWideConverter name_t{name.c_str()}; - if (!name_t.IsValid()) + if (!name.c_str()) throw std::invalid_argument{"Malfored name"}; auto oz = std::make_unique(z.location, z.radius); - auto wp = MakeWaypoint(z.location, name_t.c_str()); + auto wp = MakeWaypoint(z.location, name.c_str()); std::unique_ptr tp; diff --git a/src/Terrain/RasterTerrain.cpp b/src/Terrain/RasterTerrain.cpp index 35129de31e2..84d06a9f280 100644 --- a/src/Terrain/RasterTerrain.cpp +++ b/src/Terrain/RasterTerrain.cpp @@ -12,7 +12,6 @@ #include "io/BufferedReader.hxx" #include "system/ConvertPathName.hpp" #include "Operation/Operation.hpp" -#include "util/ConvertString.hpp" #include "LogFile.hpp" static const char *const terrain_cache_name = "terrain"; diff --git a/src/Tracking/LiveTrack24/Client.cpp b/src/Tracking/LiveTrack24/Client.cpp index 0154097164e..28c05d23ee7 100644 --- a/src/Tracking/LiveTrack24/Client.cpp +++ b/src/Tracking/LiveTrack24/Client.cpp @@ -4,7 +4,6 @@ #include "Client.hpp" #include "Operation/Operation.hpp" #include "util/StringCompare.hxx" -#include "util/ConvertString.hpp" #include "lib/curl/CoRequest.hxx" #include "lib/curl/Setup.hxx" #include "lib/fmt/RuntimeError.hxx" @@ -35,16 +34,11 @@ Client::GetUserID(const char *username, const char *password) CurlEasy easy; { - const WideToUTF8Converter username2(username); - const WideToUTF8Converter password2(password); - if (!username2.IsValid() || !password2.IsValid()) - throw std::runtime_error("WideToUTF8Converter failed"); - StaticString<1024> url; url.Format("http://%s/client.php?op=login&user=%s&pass=%s", GetServer(), - easy.Escape(username2).c_str(), - easy.Escape(password2).c_str()); + easy.Escape(username).c_str(), + easy.Escape(password).c_str()); easy.SetURL(url); } @@ -75,12 +69,6 @@ Client::StartTracking(SessionID session, const char *username, CurlEasy easy; { - const WideToUTF8Converter username2(username); - const WideToUTF8Converter password2(password); - const WideToUTF8Converter vname2(vname); - if (!username2.IsValid() || !password2.IsValid() || !vname2.IsValid()) - throw std::runtime_error("WideToUTF8Converter failed"); - const char *version = OpenSoar_VersionLong; StaticString<2048> url; url.Format("http://%s/track.php?leolive=2&sid=%u&pid=%u&" @@ -88,10 +76,10 @@ Client::StartTracking(SessionID session, const char *username, GetServer(), session, 1, // "OpenSoar", easy.Escape(version).c_str(), "XCSoar", easy.Escape(version).c_str(), - easy.Escape(username2).c_str(), - easy.Escape(password2).c_str(), + easy.Escape(username).c_str(), + easy.Escape(password).c_str(), vtype, - easy.Escape(vname2).c_str()); + easy.Escape(vname).c_str()); easy.SetURL(url); } diff --git a/src/Tracking/SkyLines/Client.cpp b/src/Tracking/SkyLines/Client.cpp index 67d59f2c1dc..a3e2ee144c7 100644 --- a/src/Tracking/SkyLines/Client.cpp +++ b/src/Tracking/SkyLines/Client.cpp @@ -14,7 +14,6 @@ #include "net/UniqueSocketDescriptor.hxx" #include "util/CRC16CCITT.hpp" #include "util/UTF8.hpp" -#include "util/ConvertString.hpp" #include #include @@ -167,8 +166,7 @@ SkyLinesTracking::Client::OnUserNameReceived(const UserNameResponsePacket &packe if (!ValidateUTF8(name.c_str())) return; - UTF8ToWideConverter tname(name.c_str()); - handler->OnUserName(FromBE32(packet.user_id), tname); + handler->OnUserName(FromBE32(packet.user_id), name.c_str()); } inline void diff --git a/src/Weather/PCMet/Images.cpp b/src/Weather/PCMet/Images.cpp index 1a7d9774deb..d97741ed8c4 100644 --- a/src/Weather/PCMet/Images.cpp +++ b/src/Weather/PCMet/Images.cpp @@ -9,7 +9,6 @@ #include "lib/curl/Setup.hxx" #include "LocalPath.hpp" #include "system/FileUtil.hpp" -#include "util/ConvertString.hpp" #include "util/StringSplit.hxx" #include @@ -111,17 +110,14 @@ PCMet::DownloadLatestImage(const char *type, const char *area, const PCMetSettings &settings, CurlGlobal &curl, ProgressListener &progress) { - const WideToUTF8Converter username(settings.www_credentials.username); - const WideToUTF8Converter password(settings.www_credentials.password); - char url[256]; snprintf(url, sizeof(url), PCMET_URI "/fw/bilder/%s?type=%s", type, area); // download the HTML page - const auto response = - co_await CoGet(curl, url, username, password, progress); + const auto response = co_await CoGet(curl, url, settings.www_credentials.username, + settings.www_credentials.password, progress); static constexpr char img_needle[] = " @@ -15,7 +14,7 @@ Setup(CurlEasy &easy) { char user_agent[32]; snprintf(user_agent, 32, "XCSoar/%s", // "OpenSoar/%s" ?? - (const char *)WideToUTF8Converter(OpenSoar_Version)); + OpenSoar_Version); easy.SetUserAgent(user_agent); #if !defined(ANDROID) && !defined(_WIN32) diff --git a/src/lua/Basic.cpp b/src/lua/Basic.cpp index ae968d65884..2d44a6477aa 100644 --- a/src/lua/Basic.cpp +++ b/src/lua/Basic.cpp @@ -4,7 +4,6 @@ #include "Basic.hpp" #include "Util.hxx" #include "Version.hpp" -#include "util/ConvertString.hpp" extern "C" { #include @@ -44,7 +43,7 @@ Lua::NewBasicState() lua_newtable(L); SetField(L, RelativeStackIndex{-1}, - "VERSION", WideToUTF8Converter(OpenSoar_Version)); + "VERSION", OpenSoar_Version); // lua_setglobal(L, "xcsoar"); lua_setglobal(L, PROGRAM_NAME_LC); diff --git a/src/lua/Dialogs.cpp b/src/lua/Dialogs.cpp index a0d1e9c9d94..d79fb4d15f1 100644 --- a/src/lua/Dialogs.cpp +++ b/src/lua/Dialogs.cpp @@ -4,7 +4,6 @@ #include "Dialogs.hpp" #include "Catch.hpp" #include "Error.hxx" -#include "util/ConvertString.hpp" #include "Dialogs/Message.hpp" #include "Dialogs/Error.hpp" @@ -17,9 +16,7 @@ l_alert(lua_State *L) { const char *message = lua_tostring(L, 1); if (message != nullptr) { - const UTF8ToWideConverter c_message(message); - if (c_message.IsValid()) - ShowMessageBox(c_message, "Lua", MB_OK|MB_ICONINFORMATION); + ShowMessageBox(message, "Lua", MB_OK|MB_ICONINFORMATION); } return 0; diff --git a/src/lua/Full.cpp b/src/lua/Full.cpp index 8626c0f5cdc..780a5409fff 100644 --- a/src/lua/Full.cpp +++ b/src/lua/Full.cpp @@ -16,7 +16,6 @@ #include "LocalPath.hpp" #include "Compatibility/path.h" #include "system/Path.hpp" -#include "util/ConvertString.hpp" #include "Airspace.hpp" #include "Task.hpp" #include "Settings.hpp" @@ -50,8 +49,7 @@ Lua::NewFullState() InitInputEvent(L); { - SetPackagePath(L, - WideToUTF8Converter(LocalPath("lua" DIR_SEPARATOR_S "?.lua").c_str())); + SetPackagePath(L, LocalPath("lua" DIR_SEPARATOR_S "?.lua").c_str()); } return L; } diff --git a/src/lua/Geo.cpp b/src/lua/Geo.cpp index 49a3c0c960d..3b338cc5bed 100644 --- a/src/lua/Geo.cpp +++ b/src/lua/Geo.cpp @@ -6,7 +6,6 @@ #include "Util.hxx" #include "Geo/GeoPoint.hpp" #include "Formatter/GeoPointFormatter.hpp" -#include "util/ConvertString.hpp" #include "util/StringAPI.hxx" namespace Lua { @@ -66,7 +65,7 @@ static int GeoPointToString(lua_State *L) { auto &gp = LuaGeoPointClass::Cast(L, 1); - Lua::Push(L, WideToUTF8Converter(FormatGeoPoint(gp, CoordinateFormat::DDMMSS))); + Lua::Push(L, FormatGeoPoint(gp, CoordinateFormat::DDMMSS)); return 1; } diff --git a/src/lua/InputEvent.cpp b/src/lua/InputEvent.cpp index 8a40a5a1a40..b517a9a13e9 100644 --- a/src/lua/InputEvent.cpp +++ b/src/lua/InputEvent.cpp @@ -12,7 +12,6 @@ #include "Input/InputKeys.hpp" #include "util/Compiler.h" #include "util/StringAPI.hxx" -#include "util/ConvertString.hpp" #include "Util.hxx" #include "Interface.hpp" @@ -173,21 +172,19 @@ class LuaInputEvent final { else if (StringIsEqual(name, "gesture_", 8)) { // scan for gesture - const UTF8ToWideConverter gesture(name+8); - if (gesture.IsValid()) { + if (name + 8) { auto *input_event = new LuaInputEvent(L, 2); - input_event->AttachGesture(gesture); + input_event->AttachGesture(name + 8); return 1; } } else if (StringIsEqual(name, "key_", 4)) { // scan for key code - const UTF8ToWideConverter keycode(name+4); - if (keycode.IsValid()) { - const unsigned code = ParseKeyCode(keycode); - auto *input_event = new LuaInputEvent(L, 2); - input_event->AttachKey(code); - return 1; - } + if (name + 4) { + const unsigned code = ParseKeyCode(name + 4); + auto *input_event = new LuaInputEvent(L, 2); + input_event->AttachKey(code); + return 1; + } } else { // scan for other enums const unsigned code = luaL_checkoption(L, 1, NULL, event_enum_names); @@ -223,16 +220,14 @@ class LuaInputEvent final { return luaL_error(L, "Invalid parameters"); else if (StringIsEqual(name, "gesture_", 8)) { - const UTF8ToWideConverter gesture(name+8); - if (gesture.IsValid()) { - event_store_gesture.Clear(std::string(gesture)); + if (name + 8) { + event_store_gesture.Clear(std::string(name + 8)); return 1; } } else if (StringIsEqual(name, "key_", 4)) { // scan for key code - const UTF8ToWideConverter keycode(name+4); - if (keycode.IsValid()) { - const unsigned code = ParseKeyCode(keycode); + if (name + 4) { + const unsigned code = ParseKeyCode(name + 4); event_store_key.Clear(code); return 1; } diff --git a/src/lua/Legacy.cpp b/src/lua/Legacy.cpp index 82566b2af07..67e21b662ef 100644 --- a/src/lua/Legacy.cpp +++ b/src/lua/Legacy.cpp @@ -4,7 +4,6 @@ #include "Legacy.hpp" #include "Util.hxx" #include "Input/InputLookup.hpp" -#include "util/ConvertString.hpp" extern "C" { #include @@ -18,15 +17,13 @@ l_fire_legacy_event(lua_State *L) if (event == nullptr) return luaL_error(L, "No InputEvent specified"); - auto *event_function = InputEvents::findEvent(UTF8ToWideConverter(event).c_str()); + auto *event_function = InputEvents::findEvent(event); if (event_function == nullptr) return luaL_error(L, "Unknown InputEvent"); const char *parameter = lua_tostring(L, 2); - if (parameter == nullptr) - parameter = ""; - - event_function(UTF8ToWideConverter(parameter)); + if (parameter != nullptr) + event_function(parameter); return 0; } diff --git a/src/lua/Replay.cpp b/src/lua/Replay.cpp index 6c6160458bf..d3c5985445b 100644 --- a/src/lua/Replay.cpp +++ b/src/lua/Replay.cpp @@ -7,7 +7,6 @@ #include "Util.hxx" #include "system/Path.hpp" #include "Replay/Replay.hpp" -#include "util/ConvertString.hpp" #include "Components.hpp" #include "BackendComponents.hpp" @@ -61,8 +60,8 @@ l_replay_start(lua_State *L) if (lua_gettop(L) != 1) return luaL_error(L, "Invalid parameters"); - const UTF8ToWideConverter filename(luaL_checkstring(L, 1)); - if (filename.IsValid()) { + const char *filename = luaL_checkstring(L, 1); + if (filename) { Path p(filename); try { diff --git a/src/net/client/WeGlide/UploadIGCFile.cpp b/src/net/client/WeGlide/UploadIGCFile.cpp index 7be0841a056..2dc97a06bf6 100644 --- a/src/net/client/WeGlide/UploadIGCFile.cpp +++ b/src/net/client/WeGlide/UploadIGCFile.cpp @@ -18,15 +18,14 @@ #include "Operation/PluggableOperationEnvironment.hpp" #include "system/Path.hpp" #include "util/StaticString.hxx" -#include "util/ConvertString.hpp" #include // Wrapper for getting converted string values of a json string -static const UTF8ToWideConverter +static const char * GetJsonString(boost::json::value json_value, std::string_view key) { - return UTF8ToWideConverter(json_value.at(key).get_string().c_str()); + return json_value.at(key).get_string().c_str(); } namespace WeGlide { @@ -59,20 +58,20 @@ UploadJsonInterpreter(const boost::json::value &json) FlightData flight_data; // flight is the 1st flight object in this array ('at(0)') auto flight = json.as_array().at(0); - flight_data.scoring_date = GetJsonString(flight, "scoring_date").c_str(); + flight_data.scoring_date = GetJsonString(flight, "scoring_date"); flight_data.flight_id = flight.at("id").to_number(); - flight_data.registration = GetJsonString(flight, "registration").c_str(); - flight_data.competition_id = GetJsonString(flight, "competition_id").c_str(); + flight_data.registration = GetJsonString(flight, "registration"); + flight_data.competition_id = GetJsonString(flight, "competition_id"); auto user = flight.at("user").as_object(); flight_data.user.id = user.at("id").to_number(); - flight_data.user.name = GetJsonString(user, "name").c_str(); + flight_data.user.name = GetJsonString(user, "name"); auto aircraft = flight.at("aircraft").as_object(); flight_data.aircraft.id = aircraft.at("id").to_number(); - flight_data.aircraft.name = GetJsonString(aircraft, "name").c_str(); - flight_data.aircraft.kind = GetJsonString(aircraft, "kind").c_str(); - flight_data.aircraft.sc_class = GetJsonString(aircraft, "sc_class").c_str(); + flight_data.aircraft.name = GetJsonString(aircraft, "name"); + flight_data.aircraft.kind = GetJsonString(aircraft, "kind"); + flight_data.aircraft.sc_class = GetJsonString(aircraft, "sc_class"); return flight_data; } diff --git a/src/util/CMakeSource.cmake b/src/util/CMakeSource.cmake index e241220628c..279b3975451 100644 --- a/src/util/CMakeSource.cmake +++ b/src/util/CMakeSource.cmake @@ -1,6 +1,5 @@ set(_SOURCES util/ASCII.cxx - util/ConvertString.cpp util/CRC16CCITT.cpp util/EscapeBackslash.cpp util/Exception.cxx diff --git a/src/util/ConvertString.cpp b/src/util/ConvertString.cpp deleted file mode 100644 index c8ad89883e8..00000000000 --- a/src/util/ConvertString.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -// Copyright The XCSoar Project - -#include "ConvertString.hpp" - - -// removed w/o Unicode \ No newline at end of file diff --git a/src/util/ConvertString.hpp b/src/util/ConvertString.hpp deleted file mode 100644 index 3f8b920167c..00000000000 --- a/src/util/ConvertString.hpp +++ /dev/null @@ -1,135 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -// Copyright The XCSoar Project - -#pragma once - -#include "UTF8.hpp" - -#define _W(text) (text) -#define _A(text) (text) - -#include "StringPointer.hxx" - -#include - -/** - * Convert a UTF-8 string to a char string. The source buffer passed - * to the constructor must be valid as long as this object is being - * used. - */ -class UTF8ToWideConverter { - typedef StringPointer<> Value; - typedef typename Value::const_pointer const_pointer; - - Value value; - -public: - UTF8ToWideConverter(const_pointer _value) noexcept - :value(_value) - { - assert(_value != nullptr); - } - - UTF8ToWideConverter(const UTF8ToWideConverter &other) = delete; - UTF8ToWideConverter &operator=(const UTF8ToWideConverter &other) = delete; - - [[gnu::pure]] - bool IsValid() const noexcept { - assert(value != nullptr); - - return ValidateUTF8(value.c_str()); - } - - const_pointer c_str() const noexcept { - assert(value != nullptr); - - return value.c_str(); - } - - operator const_pointer() const noexcept { - assert(value != nullptr); - - return value.c_str(); - } -}; - -/** - * Convert a char string to UTF-8. The source buffer passed to the - * constructor must be valid as long as this object is being used. - */ -class WideToUTF8Converter { - typedef StringPointer<> Value; - typedef typename Value::const_pointer const_pointer; - - Value value; - -public: - WideToUTF8Converter(const_pointer _value) noexcept - :value(_value) - { - assert(_value != nullptr); - } - - WideToUTF8Converter(const WideToUTF8Converter &other) = delete; - WideToUTF8Converter &operator=(const WideToUTF8Converter &other) = delete; - - [[gnu::pure]] - bool IsValid() const noexcept { - assert(value != nullptr); - - return true; - } - - const_pointer c_str() const noexcept { - assert(value != nullptr); - - return value.c_str(); - } - - operator const_pointer() const noexcept { - assert(value != nullptr); - - return value.c_str(); - } -}; - -/** - * Convert a char string to ACP (Windows ANSI code page). The source - * buffer passed to the constructor must be valid as long as this - * object is being used. - */ -class WideToACPConverter { - typedef StringPointer<> Value; - typedef typename Value::const_pointer const_pointer; - - Value value; - -public: - WideToACPConverter(const_pointer _value) noexcept - :value(_value) - { - assert(_value != nullptr); - } - - WideToACPConverter(const WideToACPConverter &other) = delete; - WideToACPConverter &operator=(const WideToACPConverter &other) = delete; - - [[gnu::pure]] - bool IsValid() const noexcept { - assert(value != nullptr); - - return true; - } - - const_pointer c_str() const noexcept { - assert(value != nullptr); - - return value.c_str(); - } - - operator const_pointer() const noexcept { - assert(value != nullptr); - - return value.c_str(); - } -}; diff --git a/test/src/Printing.cpp b/test/src/Printing.cpp index 520d1fc0004..771282e1980 100644 --- a/test/src/Printing.cpp +++ b/test/src/Printing.cpp @@ -5,14 +5,13 @@ #include "Trace/Trace.hpp" #include "system/FileUtil.hpp" #include "Waypoint/Waypoint.hpp" -#include "util/ConvertString.hpp" #include std::ostream & operator<<(std::ostream &f, Path path) { - f << WideToUTF8Converter(path.c_str()); + f << path.c_str(); return f; } diff --git a/test/src/RunDeviceDriver.cpp b/test/src/RunDeviceDriver.cpp index 258c8f233c8..642feec1756 100644 --- a/test/src/RunDeviceDriver.cpp +++ b/test/src/RunDeviceDriver.cpp @@ -11,7 +11,6 @@ #include "Engine/Waypoint/Waypoints.hpp" #include "Input/InputEvents.hpp" #include "system/Args.hpp" -#include "util/ConvertString.hpp" #include "util/StringStrip.hxx" #include @@ -166,8 +165,7 @@ int main(int argc, char **argv) { const DeviceRegister *driver; for (unsigned i = 0; (driver = GetDriverByIndex(i)) != nullptr; ++i) { - WideToUTF8Converter driver_name(driver->name); - usage.AppendFormat("\n\t%s", (const char *)driver_name); + usage.AppendFormat("\n\t%s", driver->name); } } diff --git a/test/src/RunDownloadFlight.cpp b/test/src/RunDownloadFlight.cpp index 2c619ea075e..734419f5d4a 100644 --- a/test/src/RunDownloadFlight.cpp +++ b/test/src/RunDownloadFlight.cpp @@ -16,7 +16,6 @@ #include "io/async/GlobalAsioThread.hpp" #include "io/async/AsioThread.hpp" #include "io/NullDataHandler.hpp" -#include "util/ConvertString.hpp" #include "util/PrintException.hxx" #include @@ -70,8 +69,7 @@ try { const DeviceRegister *driver; for (unsigned i = 0; (driver = GetDriverByIndex(i)) != NULL; ++i) { if (driver->IsLogger()) { - WideToUTF8Converter driver_name(driver->name); - usage.AppendFormat("\n\t%s", (const char *)driver_name); + usage.AppendFormat("\n\t%s", driver->name); } } } diff --git a/test/src/RunFlarmUtils.cpp b/test/src/RunFlarmUtils.cpp index 70f65d959e8..7d22f6431c0 100644 --- a/test/src/RunFlarmUtils.cpp +++ b/test/src/RunFlarmUtils.cpp @@ -11,7 +11,6 @@ #include "Device/Config.hpp" #include "system/Args.hpp" #include "util/StringStrip.hxx" -#include "util/ConvertString.hpp" #include "util/PrintException.hxx" #include "Operation/ConsoleOperationEnvironment.hpp" #include "io/async/GlobalAsioThread.hpp" @@ -40,8 +39,7 @@ ChangePilot(FlarmDevice &flarm, OperationEnvironment &env) StripRight(pilot_name); fprintf(stdout, "Setting pilot name to \"%s\" ...\n", pilot_name); - const UTF8ToWideConverter value(pilot_name); - if (flarm.SetPilot(value, env)) + if (flarm.SetPilot(pilot_name, env)) fprintf(stdout, "Pilot name set to \"%s\"\n", pilot_name); else fprintf(stdout, "Operation failed!\n"); @@ -70,8 +68,7 @@ ChangeCoPilot(FlarmDevice &flarm, OperationEnvironment &env) StripRight(copilot_name); fprintf(stdout, "Setting copilot name to \"%s\" ...\n", copilot_name); - const UTF8ToWideConverter value(copilot_name); - if (flarm.SetCoPilot(value, env)) + if (flarm.SetCoPilot(copilot_name, env)) fprintf(stdout, "CoPilot name set to \"%s\"\n", copilot_name); else fprintf(stdout, "Operation failed!\n"); @@ -100,8 +97,7 @@ ChangePlaneType(FlarmDevice &flarm, OperationEnvironment &env) StripRight(plane_type); fprintf(stdout, "Setting plane type to \"%s\" ...\n", plane_type); - const UTF8ToWideConverter value(plane_type); - if (flarm.SetPlaneType(value, env)) + if (flarm.SetPlaneType(plane_type, env)) fprintf(stdout, "Plane type set to \"%s\"\n", plane_type); else fprintf(stdout, "Operation failed!\n"); @@ -130,8 +126,7 @@ ChangeRegistration(FlarmDevice &flarm, OperationEnvironment &env) StripRight(registration); fprintf(stdout, "Setting plane registration to \"%s\" ...\n", registration); - const UTF8ToWideConverter value(registration); - if (flarm.SetPlaneRegistration(value, env)) + if (flarm.SetPlaneRegistration(registration, env)) fprintf(stdout, "Plane registration set to \"%s\"\n", registration); else fprintf(stdout, "Operation failed!\n"); @@ -160,8 +155,7 @@ ChangeCompetitionId(FlarmDevice &flarm, OperationEnvironment &env) StripRight(id); fprintf(stdout, "Setting competition id to \"%s\" ...\n", id); - const UTF8ToWideConverter value(id); - if (flarm.SetCompetitionId(value, env)) + if (flarm.SetCompetitionId(id, env)) fprintf(stdout, "competition id set to \"%s\"\n", id); else fprintf(stdout, "Operation failed!\n"); @@ -190,8 +184,7 @@ ChangeCompetitionClass(FlarmDevice &flarm, OperationEnvironment &env) StripRight(comp_class); fprintf(stdout, "Setting competition class to \"%s\" ...\n", comp_class); - const UTF8ToWideConverter value(comp_class); - if (flarm.SetCompetitionClass(value, env)) + if (flarm.SetCompetitionClass(comp_class, env)) fprintf(stdout, "Competition class set to \"%s\"\n", comp_class); else fprintf(stdout, "Operation failed!\n"); diff --git a/test/src/RunFlightList.cpp b/test/src/RunFlightList.cpp index bf6eee38c73..a7e2993a448 100644 --- a/test/src/RunFlightList.cpp +++ b/test/src/RunFlightList.cpp @@ -17,7 +17,6 @@ #include "io/async/GlobalAsioThread.hpp" #include "io/async/AsioThread.hpp" #include "io/NullDataHandler.hpp" -#include "util/ConvertString.hpp" #include "util/PrintException.hxx" #include @@ -64,8 +63,7 @@ try { const DeviceRegister *driver; for (unsigned i = 0; (driver = GetDriverByIndex(i)) != NULL; ++i) { if (driver->IsLogger()) { - WideToUTF8Converter driver_name(driver->name); - usage.AppendFormat("\n\t%s", (const char *)driver_name); + usage.AppendFormat("\n\t%s", driver->name); } } } diff --git a/test/src/TestPolars.cpp b/test/src/TestPolars.cpp index 86ddb6c0c62..c5fc1fb29ef 100644 --- a/test/src/TestPolars.cpp +++ b/test/src/TestPolars.cpp @@ -11,7 +11,6 @@ #include "Polar/Parser.hpp" #include "Polar/PolarFileGlue.hpp" #include "Polar/PolarStore.hpp" -#include "util/ConvertString.hpp" #include "util/Macros.hpp" #include "util/PrintException.hxx" #include "util/StringAPI.hxx" @@ -76,9 +75,7 @@ TestBuiltInPolars() { for (const auto &i : PolarStore::GetAll()) { PolarInfo polar = i.ToPolarInfo(); - - WideToUTF8Converter narrow(i.name); - ok(polar.IsValid(), narrow); + ok(polar.IsValid(), i.name); } } @@ -138,9 +135,8 @@ static void TestBuiltInPolarsPlausibility() { for(unsigned i = 0; i < ARRAY_SIZE(performanceData); i++) { - const char *si = performanceData[i].name; - WideToUTF8Converter polarName(si); - const auto polar = GetPolarByName(si); + const char *polarName = performanceData[i].name; + const auto polar = GetPolarByName(polarName); PolarCoefficients pc = polar.CalculateCoefficients(); ok(pc.IsValid(), polarName); diff --git a/test/src/harness_airspace.cpp b/test/src/harness_airspace.cpp index a26662bfe00..b3c872bdd33 100644 --- a/test/src/harness_airspace.cpp +++ b/test/src/harness_airspace.cpp @@ -11,7 +11,6 @@ #include "Geo/GeoVector.hpp" #include "Formatter/AirspaceFormatter.hpp" #include "system/FileUtil.hpp" -#include "util/ConvertString.hpp" #include #include @@ -116,7 +115,7 @@ class AirspaceVisitorPrint { void Visit(const AbstractAirspace &as) { if (do_report) { *fout << as; - *fout << "# Name: " << WideToUTF8Converter(as.GetName()) + *fout << "# Name: " << as.GetName() << "Base: " << as.GetBase() << " Top: " << as.GetTop() << "\n"; From 91aa009a1f065766ed1bdc8618fbb70c33128aae Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 3 May 2024 12:46:16 +0200 Subject: [PATCH 387/403] [Bugfix] InputEventsSettings.cpp - add missing comma to separate actions items --- src/Input/InputEventsSettings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Input/InputEventsSettings.cpp b/src/Input/InputEventsSettings.cpp index cd05b0222c0..c1c45b4e71a 100644 --- a/src/Input/InputEventsSettings.cpp +++ b/src/Input/InputEventsSettings.cpp @@ -317,7 +317,7 @@ InputEvents::eventDeclutterLabels(const char *misc) "all", "task+landables", "task", - "none" + "none", "task+airfields", }; From 710e8148235cd925d4eb764daad95969e64d605e Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 3 May 2024 17:02:00 +0200 Subject: [PATCH 388/403] lua/InputEvent.cpp - Check if string valid --- src/lua/InputEvent.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lua/InputEvent.cpp b/src/lua/InputEvent.cpp index b517a9a13e9..3dbb32a0acb 100644 --- a/src/lua/InputEvent.cpp +++ b/src/lua/InputEvent.cpp @@ -172,14 +172,14 @@ class LuaInputEvent final { else if (StringIsEqual(name, "gesture_", 8)) { // scan for gesture - if (name + 8) { + if (strlen(name) > 8) { auto *input_event = new LuaInputEvent(L, 2); input_event->AttachGesture(name + 8); return 1; } } else if (StringIsEqual(name, "key_", 4)) { // scan for key code - if (name + 4) { + if (strlen(name) > 4) { const unsigned code = ParseKeyCode(name + 4); auto *input_event = new LuaInputEvent(L, 2); input_event->AttachKey(code); @@ -220,13 +220,13 @@ class LuaInputEvent final { return luaL_error(L, "Invalid parameters"); else if (StringIsEqual(name, "gesture_", 8)) { - if (name + 8) { + if (strlen(name) > 8) { event_store_gesture.Clear(std::string(name + 8)); return 1; } } else if (StringIsEqual(name, "key_", 4)) { // scan for key code - if (name + 4) { + if (strlen(name) > 4) { const unsigned code = ParseKeyCode(name + 4); event_store_key.Clear(code); return 1; From 1956e5b47fb3de786926c96c896e1da1a184067d Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 3 May 2024 18:09:40 +0200 Subject: [PATCH 389/403] lua/InputEvent.cpp - Codacy: handle strings w/o \0-termination --- src/lua/InputEvent.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lua/InputEvent.cpp b/src/lua/InputEvent.cpp index 3dbb32a0acb..24402f0b46d 100644 --- a/src/lua/InputEvent.cpp +++ b/src/lua/InputEvent.cpp @@ -172,14 +172,14 @@ class LuaInputEvent final { else if (StringIsEqual(name, "gesture_", 8)) { // scan for gesture - if (strlen(name) > 8) { + if (*(name + 8)) { auto *input_event = new LuaInputEvent(L, 2); input_event->AttachGesture(name + 8); return 1; } } else if (StringIsEqual(name, "key_", 4)) { - // scan for key code - if (strlen(name) > 4) { + // scan for key code + if (*(name + 4)) { const unsigned code = ParseKeyCode(name + 4); auto *input_event = new LuaInputEvent(L, 2); input_event->AttachKey(code); @@ -220,13 +220,13 @@ class LuaInputEvent final { return luaL_error(L, "Invalid parameters"); else if (StringIsEqual(name, "gesture_", 8)) { - if (strlen(name) > 8) { + if (*(name + 8)) { event_store_gesture.Clear(std::string(name + 8)); return 1; } } else if (StringIsEqual(name, "key_", 4)) { // scan for key code - if (strlen(name) > 4) { + if (*(name + 4)) { const unsigned code = ParseKeyCode(name + 4); event_store_key.Clear(code); return 1; From 97fbc4824830af9283fb699041b0be8d6f3403d0 Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 2 May 2024 11:10:01 +0200 Subject: [PATCH 390/403] [Test] add FakeLogFile.cpp to tests with Config.cpp --- build/test.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build/test.mk b/build/test.mk index 7a999586cd6..d5364de4eab 100644 --- a/build/test.mk +++ b/build/test.mk @@ -666,6 +666,7 @@ TEST_DRIVER_SOURCES = \ $(TEST_SRC_DIR)/FakeMessage.cpp \ $(TEST_SRC_DIR)/FakeGeoid.cpp \ $(TEST_SRC_DIR)/FakeLanguage.cpp \ + $(TEST_SRC_DIR)/FakeLogFile.cpp \ $(TEST_SRC_DIR)/TestDriver.cpp TEST_DRIVER_DEPENDS = DRIVER OPERATION LIBNMEA GEO MATH IO OS THREAD UTIL TIME $(eval $(call link-program,TestDriver,TEST_DRIVER)) @@ -859,6 +860,7 @@ DEBUG_REPLAY_SOURCES = \ $(SRC)/Engine/Task/Stats/ElementStat.cpp \ $(TEST_SRC_DIR)/FakeMessage.cpp \ $(TEST_SRC_DIR)/FakeLanguage.cpp \ + $(TEST_SRC_DIR)/FakeLogFile.cpp \ $(TEST_SRC_DIR)/FakeGeoid.cpp \ $(TEST_SRC_DIR)/DebugReplayIGC.cpp \ $(TEST_SRC_DIR)/DebugReplayNMEA.cpp \ @@ -1243,6 +1245,7 @@ RUN_DEVICE_DRIVER_SOURCES = \ $(SRC)/Formatter/NMEAFormatter.cpp \ $(TEST_SRC_DIR)/FakeMessage.cpp \ $(TEST_SRC_DIR)/FakeLanguage.cpp \ + $(TEST_SRC_DIR)/FakeLogFile.cpp \ $(TEST_SRC_DIR)/FakeGeoid.cpp \ $(TEST_SRC_DIR)/RunDeviceDriver.cpp RUN_DEVICE_DRIVER_DEPENDS = DRIVER OPERATION IO LIBNMEA OS THREAD GEO MATH UTIL TIME From b194030cca27f49f7ebd392b14d40b24de1cddec Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 23 Apr 2024 16:31:39 +0200 Subject: [PATCH 391/403] [Data] Data creation - use *hpp instead if include *.cpp --- Data/CMakeLists.txt | 39 +++++++++++++++++-------------------- build/generate.mk | 28 +++++++++++++------------- src/Input/InputDefaults.cpp | 2 +- src/Input/InputLookup.cpp | 6 +++--- src/StatusMessage.cpp | 2 +- src/lua/InputEvent.cpp | 4 ++-- 6 files changed, 39 insertions(+), 42 deletions(-) diff --git a/Data/CMakeLists.txt b/Data/CMakeLists.txt index 41a6217b0e8..233b47b6655 100644 --- a/Data/CMakeLists.txt +++ b/Data/CMakeLists.txt @@ -274,26 +274,26 @@ endif() ## add_custom_command(TARGET ${TARGET_NAME} PRE_LINK set(INPUTEVENTS_CPP - ${_INCLUDE_OUTPUT}/InputEvents_Char2GCE.cpp + ${_INCLUDE_OUTPUT}/InputEvents_Char2GCE.hpp # ${_INCLUDE_OUTPUT}/InputEvents_Char2GCE.cpp - ${_INCLUDE_OUTPUT}/InputEvents_Char2NE.cpp - ${_INCLUDE_OUTPUT}/InputEvents_Text2Event.cpp - ${_INCLUDE_OUTPUT}/InputEvents_Text2GCE.cpp - ${_INCLUDE_OUTPUT}/InputEvents_Text2NE.cpp - ${_INCLUDE_OUTPUT}/InputEvents_default.cpp + ${_INCLUDE_OUTPUT}/InputEvents_Char2NE.hpp + ${_INCLUDE_OUTPUT}/InputEvents_Text2Event.hpp + ${_INCLUDE_OUTPUT}/InputEvents_Text2GCE.hpp + ${_INCLUDE_OUTPUT}/InputEvents_Text2NE.hpp + ${_INCLUDE_OUTPUT}/InputEvents_default.hpp ) set(DEFAULT_XCI ${_DATA_INPUT}/Input/defaultOV.xci) # set(DEFAULT_XCI ${_DATA_INPUT}/Input/${DEFAULT_XCI_FILE}) - add_custom_command(OUTPUT ${_INCLUDE_OUTPUT}/InputCppFiles.txt - COMMENT Create InputEvents_*.cpp! + add_custom_command(OUTPUT ${INPUTEVENTS_CPP} ${_INCLUDE_OUTPUT}/InputCppFiles.txt + COMMENT Create InputEvents_*.hpp! COMMAND ${CMAKE_COMMAND} -E make_directory ${_INCLUDE_OUTPUT} - COMMAND perl tools/Char2GCE.pl src/Input/InputQueue.hpp >${_INCLUDE_OUTPUT}/InputEvents_Char2GCE.cpp - COMMAND perl tools/Char2NE.pl src/Input/InputQueue.hpp >${_INCLUDE_OUTPUT}/InputEvents_Char2NE.cpp - COMMAND perl tools/Text2Event.pl src/Input/InputEvents.hpp >${_INCLUDE_OUTPUT}/InputEvents_Text2Event.cpp - COMMAND perl tools/Text2GCE.pl src/Input/InputQueue.hpp >${_INCLUDE_OUTPUT}/InputEvents_Text2GCE.cpp - COMMAND perl tools/Text2NE.pl src/Input/InputQueue.hpp >${_INCLUDE_OUTPUT}/InputEvents_Text2NE.cpp - COMMAND perl tools/xci2cpp.pl ${DEFAULT_XCI} >${_INCLUDE_OUTPUT}/InputEvents_default.cpp + COMMAND perl tools/Char2GCE.pl src/Input/InputQueue.hpp >${_INCLUDE_OUTPUT}/InputEvents_Char2GCE.hpp + COMMAND perl tools/Char2NE.pl src/Input/InputQueue.hpp >${_INCLUDE_OUTPUT}/InputEvents_Char2NE.hpp + COMMAND perl tools/Text2Event.pl src/Input/InputEvents.hpp >${_INCLUDE_OUTPUT}/InputEvents_Text2Event.hpp + COMMAND perl tools/Text2GCE.pl src/Input/InputQueue.hpp >${_INCLUDE_OUTPUT}/InputEvents_Text2GCE.hpp + COMMAND perl tools/Text2NE.pl src/Input/InputQueue.hpp >${_INCLUDE_OUTPUT}/InputEvents_Text2NE.hpp + COMMAND perl tools/xci2cpp.pl ${DEFAULT_XCI} >${_INCLUDE_OUTPUT}/InputEvents_default.hpp COMMAND perl tools/xci2cpp.pl ${DEFAULT_XCI} >${_INCLUDE_OUTPUT}/InputCppFiles.txt DEPENDS ${PROJECTGROUP_SOURCE_DIR}/src/Input/InputQueue.hpp ${PROJECTGROUP_SOURCE_DIR}/src/Input/InputEvents.hpp @@ -301,17 +301,14 @@ endif() WORKING_DIRECTORY ${PROJECTGROUP_SOURCE_DIR} ) - add_custom_command( OUTPUT ${OUTPUT_FOLDER}/include/Status_defaults.cpp - # add_custom_command( OUTPUT DefaultStatus - # add_custom_command(TARGET ${TARGET_NAME} PRE_BUILD - # COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECTGROUP_SOURCE_DIR}/${_INCLUDE_OUTPUT} + add_custom_command( OUTPUT ${OUTPUT_FOLDER}/include/Status_defaults.hpp COMMAND ${CMAKE_COMMAND} -E make_directory ${_INCLUDE_OUTPUT} - COMMAND perl tools/xcs2cpp.pl Data/Status/default.xcs >${OUTPUT_FOLDER}/include/Status_defaults.cpp + COMMAND perl tools/xcs2cpp.pl Data/Status/default.xcs >${OUTPUT_FOLDER}/include/Status_defaults.hpp DEPENDS ${_DATA_INPUT}/Status/default.xcs WORKING_DIRECTORY ${PROJECTGROUP_SOURCE_DIR} ) - list(APPEND INPUTEVENTS_CPP ${OUTPUT_FOLDER}/include/Status_defaults.cpp) + list(APPEND INPUTEVENTS_CPP ${OUTPUT_FOLDER}/include/Status_defaults.hpp) # list(APPEND C_FILES ${_INCLUDE_OUTPUT}/Status_defaults.cpp) @@ -382,7 +379,7 @@ add_library(${TARGET_NAME} ${XCSOAR_LIB_TYPE} ${ICON_BITMAPS} ${ICON_FILES} ${PROJECTGROUP_SOURCE_DIR}/tools/Char2GCE.pl - # ${INPUTEVENTS_CPP} + ${INPUTEVENTS_CPP} ${_INCLUDE_OUTPUT}/InputCppFiles.txt # InputCppFiles # role for input files # DefaultStatus # role for status defaults diff --git a/build/generate.mk b/build/generate.mk index 99351228833..645464f1ea8 100644 --- a/build/generate.mk +++ b/build/generate.mk @@ -10,38 +10,38 @@ $(call SRC_TO_OBJ,$(SRC)/Math/FastMath.cpp): $(OUT)/include/MathTables.h $(call SRC_TO_OBJ,$(SRC)/Math/FastTrig.cpp): $(OUT)/include/MathTables.h $(call SRC_TO_OBJ,$(SRC)/Computer/ThermalRecency.cpp): $(OUT)/include/MathTables.h -$(OUT)/include/InputEvents_Text2Event.cpp: $(SRC)/Input/InputEvents.hpp \ +$(OUT)/include/InputEvents_Text2Event.hpp: $(SRC)/Input/InputEvents.hpp \ $(topdir)/tools/Text2Event.pl | $(OUT)/include/dirstamp @$(NQ)echo " GEN $@" $(Q)$(PERL) $(topdir)/tools/Text2Event.pl $< >$@.tmp @mv $@.tmp $@ -$(OUT)/include/InputEvents_Text2GCE.cpp: $(SRC)/Input/InputQueue.hpp \ +$(OUT)/include/InputEvents_Text2GCE.hpp: $(SRC)/Input/InputQueue.hpp \ $(topdir)/tools/Text2GCE.pl | $(OUT)/include/dirstamp @$(NQ)echo " GEN $@" $(Q)$(PERL) $(topdir)/tools/Text2GCE.pl $< >$@.tmp @mv $@.tmp $@ -$(OUT)/include/InputEvents_Text2NE.cpp: $(SRC)/Input/InputQueue.hpp \ +$(OUT)/include/InputEvents_Text2NE.hpp: $(SRC)/Input/InputQueue.hpp \ $(topdir)/tools/Text2NE.pl | $(OUT)/include/dirstamp @$(NQ)echo " GEN $@" $(Q)$(PERL) $(topdir)/tools/Text2NE.pl $< >$@.tmp @mv $@.tmp $@ -$(OUT)/include/InputEvents_Char2GCE.cpp: $(SRC)/Input/InputQueue.hpp \ +$(OUT)/include/InputEvents_Char2GCE.hpp: $(SRC)/Input/InputQueue.hpp \ $(topdir)/tools/Char2GCE.pl | $(OUT)/include/dirstamp @$(NQ)echo " GEN $@" $(Q)$(PERL) $(topdir)/tools/Char2GCE.pl $< >$@.tmp @mv $@.tmp $@ -$(OUT)/include/InputEvents_Char2NE.cpp: $(SRC)/Input/InputQueue.hpp \ +$(OUT)/include/InputEvents_Char2NE.hpp: $(SRC)/Input/InputQueue.hpp \ $(topdir)/tools/Char2NE.pl | $(OUT)/include/dirstamp @$(NQ)echo " GEN $@" $(Q)$(PERL) $(topdir)/tools/Char2NE.pl $< >$@.tmp @mv $@.tmp $@ XCI_LIST = default -XCI_HEADERS = $(patsubst %,$(OUT)/include/InputEvents_%.cpp,$(XCI_LIST)) +XCI_HEADERS = $(patsubst %,$(OUT)/include/InputEvents_%.hpp,$(XCI_LIST)) ifeq ($(TARGET_IS_OPENVARIO),y) GETTEXT_EVENTS = Data/Input/defaultOV.xci @@ -49,7 +49,7 @@ else GETTEXT_EVENTS = Data/Input/default.xci endif -$(OUT)/include/InputEvents_default.cpp: $(topdir)/$(GETTEXT_EVENTS) \ +$(OUT)/include/InputEvents_default.hpp: $(topdir)/$(GETTEXT_EVENTS) \ $(topdir)/tools/xci2cpp.pl \ | $(OUT)/include/dirstamp @$(NQ)echo " GEN $@" @@ -57,23 +57,23 @@ $(OUT)/include/InputEvents_default.cpp: $(topdir)/$(GETTEXT_EVENTS) \ @mv $@.tmp $@ $(call SRC_TO_OBJ,$(SRC)/Input/InputDefaults.cpp): $(XCI_HEADERS) -$(call SRC_TO_OBJ,$(SRC)/Input/InputLookup.cpp): $(OUT)/include/InputEvents_Text2Event.cpp $(OUT)/include/InputEvents_Text2GCE.cpp $(OUT)/include/InputEvents_Text2NE.cpp +$(call SRC_TO_OBJ,$(SRC)/Input/InputLookup.cpp): $(OUT)/include/InputEvents_Text2Event.hpp $(OUT)/include/InputEvents_Text2GCE.hpp $(OUT)/include/InputEvents_Text2NE.hpp -$(call SRC_TO_OBJ,$(SRC)/lua/InputEvent.cpp): $(OUT)/include/InputEvents_Char2GCE.cpp $(OUT)/include/InputEvents_Char2NE.cpp +$(call SRC_TO_OBJ,$(SRC)/lua/InputEvent.cpp): $(OUT)/include/InputEvents_Char2GCE.hpp $(OUT)/include/InputEvents_Char2NE.hpp -$(OUT)/include/Status_defaults.cpp: Data/Status/default.xcs \ +$(OUT)/include/Status_defaults.hpp: Data/Status/default.xcs \ tools/xcs2cpp.pl | $(OUT)/include/dirstamp @$(NQ)echo " GEN $@" $(Q)$(PERL) tools/xcs2cpp.pl $< >$@.tmp @mv $@.tmp $@ SM_OBJ = $(call SRC_TO_OBJ,$(SRC)/StatusMessage.cpp) -$(SM_OBJ): $(OUT)/include/Status_defaults.cpp +$(SM_OBJ): $(OUT)/include/Status_defaults.hpp generate:: $(OUT)/include/MathTables.h $(XCI_HEADERS) \ - $(OUT)/include/Status_defaults.cpp \ - $(OUT)/include/InputEvents_Text2Event.cpp $(OUT)/include/InputEvents_Text2GCE.cpp $(OUT)/include/InputEvents_Text2NE.cpp \ - $(OUT)/include/InputEvents_Char2GCE.cpp $(OUT)/include/InputEvents_Char2NE.cpp + $(OUT)/include/Status_defaults.hpp \ + $(OUT)/include/InputEvents_Text2Event.hpp $(OUT)/include/InputEvents_Text2GCE.hpp $(OUT)/include/InputEvents_Text2NE.hpp \ + $(OUT)/include/InputEvents_Char2GCE.hpp $(OUT)/include/InputEvents_Char2NE.hpp # UNIX resources diff --git a/src/Input/InputDefaults.cpp b/src/Input/InputDefaults.cpp index 656d7616c29..fc5012726c4 100644 --- a/src/Input/InputDefaults.cpp +++ b/src/Input/InputDefaults.cpp @@ -126,7 +126,7 @@ InputEvents::LoadDefaults(InputConfig &input_config) // Get defaults input_config.SetDefaults(); -#include "InputEvents_default.cpp" +#include "InputEvents_default.hpp" apply_defaults(input_config, default_modes, default_events, diff --git a/src/Input/InputLookup.cpp b/src/Input/InputLookup.cpp index 1a51f7006ff..76d7a04668c 100644 --- a/src/Input/InputLookup.cpp +++ b/src/Input/InputLookup.cpp @@ -13,19 +13,19 @@ struct Text2EventSTRUCT { }; static constexpr Text2EventSTRUCT Text2Event[] = { -#include "InputEvents_Text2Event.cpp" +#include "InputEvents_Text2Event.hpp" { nullptr, nullptr } }; // Mapping text names of events to the real thing static const char *const Text2GCE[] = { -#include "InputEvents_Text2GCE.cpp" +#include "InputEvents_Text2GCE.hpp" nullptr }; // Mapping text names of events to the real thing static const char *const Text2NE[] = { -#include "InputEvents_Text2NE.cpp" +#include "InputEvents_Text2NE.hpp" nullptr }; diff --git a/src/StatusMessage.cpp b/src/StatusMessage.cpp index 1dc4f4333d2..8bd80a12d46 100644 --- a/src/StatusMessage.cpp +++ b/src/StatusMessage.cpp @@ -8,7 +8,7 @@ #include static constexpr StatusMessage default_status_messages[] = { -#include "Status_defaults.cpp" +#include "Status_defaults.hpp" }; [[gnu::pure]] diff --git a/src/lua/InputEvent.cpp b/src/lua/InputEvent.cpp index 24402f0b46d..0c51f70c9f3 100644 --- a/src/lua/InputEvent.cpp +++ b/src/lua/InputEvent.cpp @@ -60,8 +60,8 @@ static LuaEventRegistry event_store_key; static constexpr const char* event_enum_names[] = { "nil", -#include "InputEvents_Char2GCE.cpp" -#include "InputEvents_Char2NE.cpp" +#include "InputEvents_Char2GCE.hpp" +#include "InputEvents_Char2NE.hpp" nullptr }; From 9850e640f5127e02ae74144fcbc57e1569b00f95 Mon Sep 17 00:00:00 2001 From: August2111 Date: Tue, 23 Apr 2024 22:11:16 +0200 Subject: [PATCH 392/403] [Data] move generation of ProgramVersion.h to generate.mk --- build/compile.mk | 7 ++++--- build/generate.mk | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/build/compile.mk b/build/compile.mk index b6fb065089f..22409614a3a 100644 --- a/build/compile.mk +++ b/build/compile.mk @@ -3,9 +3,10 @@ # August2111: This part is for OpenSoar only: #============================================ # with changed .config a new ProgramVersion (and a new title.svg) is needed -output/include/ProgramVersion.h: OpenSoar.config - @$(NQ)echo " VERSION: $< ==> $@ " - $(Q)python3 $(topdir)/tools/python/replace.py $< Data/graphics/title.svg $(DATA)/temp/graphics/title.svg $@ + +## output/include/ProgramVersion.h: OpenSoar.config +## @$(NQ)echo " VERSION: $< ==> $@ " +## $(Q)python3 $(topdir)/tools/python/replace.py $< Data/graphics/title.svg $(DATA)/temp/graphics/title.svg $@ # Version.o need the new PROGRAM_VERSION if it is available: Version.o: %.cpp ProgramVersion.h diff --git a/build/generate.mk b/build/generate.mk index 645464f1ea8..64c03541df7 100644 --- a/build/generate.mk +++ b/build/generate.mk @@ -95,3 +95,7 @@ generate:: $(TARGET_OUTPUT_DIR)/include/resource_data.h endif # !TARGET_IS_ANDROID endif + +$(OUT)/include/ProgramVersion.h: OpenSoar.config + @$(NQ)echo " VERSION: $< ==> $@ " + $(Q)python3 $(topdir)/tools/python/replace.py $< Data/graphics/title.svg $(DATA)/temp/graphics/title.svg $@ From 1bae3b8d2e8ceba69c2788af4abf03e01228afbb Mon Sep 17 00:00:00 2001 From: August2111 Date: Thu, 2 May 2024 09:05:25 +0200 Subject: [PATCH 393/403] WaypointReaderWinPilot.cpp - value was declared before in a header --- src/Waypoint/WaypointReaderWinPilot.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Waypoint/WaypointReaderWinPilot.cpp b/src/Waypoint/WaypointReaderWinPilot.cpp index d96ef60c1c5..e97c10d36e7 100644 --- a/src/Waypoint/WaypointReaderWinPilot.cpp +++ b/src/Waypoint/WaypointReaderWinPilot.cpp @@ -142,12 +142,12 @@ ParseAltitude(std::string_view src, double &dest) src.remove_suffix(1); // Parse string - const auto value = ParseInteger(src); - if (!value) + const auto int_value = ParseInteger(src); + if (!int_value) return false; // Convert to system unit if necessary - dest = Units::ToSysUnit(*value, unit); + dest = Units::ToSysUnit(*int_value, unit); return true; } From af5739cbd7d9e1450fa61a7055798b4e67204b90 Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 3 May 2024 11:06:55 +0200 Subject: [PATCH 394/403] MapWindowProjection.cpp - clamp the highest resolution on OpenVario maybe performance problem --- src/Projection/MapWindowProjection.cpp | 44 +++++++++++++++----------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/src/Projection/MapWindowProjection.cpp b/src/Projection/MapWindowProjection.cpp index 845d93979a8..ead314c489c 100644 --- a/src/Projection/MapWindowProjection.cpp +++ b/src/Projection/MapWindowProjection.cpp @@ -9,25 +9,26 @@ #include static constexpr unsigned ScaleList[] = { - 100, - 200, - 300, - 500, - 1000, - 2000, - 3000, - 5000, - 10000, - 20000, - 30000, - 50000, - 75000, - 100000, - 150000, - 200000, - 300000, - 500000, - 1000000, + 100, // + 200, // 2 + 300, // 1.5 + 500, // 1.67 + 1000, // 2 + 2000, // 2 + 3000, // 1.5 + + 5000, // 1.67 = 2.5 + 10000, // 2 = 5 + 20000, // 2 = 10 + 30000, // 1.5 = 15 + 50000, // 1.67 = 25 + 75000, // 1.5 = 38 (37.5) + 100000, // 1.33 = 50 + 150000, // 1.5 = 75 + 200000, // 1.33 = 100 + 300000, // 1.5 = 150 + 500000, // 1.67 = 250 + 1000000, // 2 = 500 }; static constexpr unsigned ScaleListCount = std::size(ScaleList); @@ -56,7 +57,12 @@ double MapWindowProjection::StepMapScale(const double scale, int Step) const noexcept { int i = FindMapScale(scale) + Step; +#ifdef IS_OPENVARIO + // don't use the last scale value on OpenVario (Performance?) + i = std::clamp(i, 0, (int)ScaleListCount - 2); +#else i = std::clamp(i, 0, (int)ScaleListCount - 1); +#endif return CalculateMapScale(i); } From f831b9de8b3b94dd0db34a8bfd071be75b7d5d45 Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 3 May 2024 11:28:07 +0200 Subject: [PATCH 395/403] Data/resources.txt - use a transparent airspace border on GDI instead if this striped one --- Data/resources.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Data/resources.txt b/Data/resources.txt index 4b73734d98f..22dee31ae99 100644 --- a/Data/resources.txt +++ b/Data/resources.txt @@ -25,7 +25,7 @@ bitmap_icon_scaled IDB_AIRPORT_MARGINAL2 "alt2_marginal_airport" bitmap_icon_scaled IDB_AIRPORT_UNREACHABLE2 "alt2_landable_airport" #ifdef USE_GDI -hatch_bitmap IDB_AIRSPACE0 "airspace0" +hatch_bitmap IDB_AIRSPACE0 "airspace3" hatch_bitmap IDB_AIRSPACE1 "airspace1" hatch_bitmap IDB_AIRSPACE2 "airspace2" hatch_bitmap IDB_AIRSPACE3 "airspace3" From 98dea809048a000236064b86668ff516433cd95a Mon Sep 17 00:00:00 2001 From: August2111 Date: Fri, 3 May 2024 11:35:26 +0200 Subject: [PATCH 396/403] [BT] use the (bluetooth_) in all cases and not only with HasLe, because this flag hided the ports of classic bluetooth --- src/Dialogs/Device/PortPicker.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Dialogs/Device/PortPicker.cpp b/src/Dialogs/Device/PortPicker.cpp index 2d35d6c4a26..2c87ec6baec 100644 --- a/src/Dialogs/Device/PortPicker.cpp +++ b/src/Dialogs/Device/PortPicker.cpp @@ -79,7 +79,7 @@ class PortPickerWidget ComboList combo_list; #ifdef ANDROID - Java::LocalObject detect_listener; + Java::LocalObject bluetooth_detect_listener; Java::LocalObject usb_serial_detect_listener; struct DetectedPort { @@ -141,9 +141,8 @@ class PortPickerWidget #ifdef ANDROID if (bluetooth_helper != nullptr) { const auto env = Java::GetEnv(); - if (bluetooth_helper->HasLe(env)) - detect_listener = - bluetooth_helper->AddDetectDeviceListener(env, *this); + bluetooth_detect_listener = + bluetooth_helper->AddDetectDeviceListener(env, *this); } if (usb_serial_helper != nullptr) { @@ -156,10 +155,10 @@ class PortPickerWidget void Hide() noexcept override { #ifdef ANDROID - if (detect_listener) { - bluetooth_helper->RemoveDetectDeviceListener(detect_listener.GetEnv(), - detect_listener); - detect_listener = {}; + if (bluetooth_detect_listener) { + bluetooth_helper->RemoveDetectDeviceListener( + bluetooth_detect_listener.GetEnv(), bluetooth_detect_listener); + bluetooth_detect_listener = {}; } if (usb_serial_detect_listener) { From 9bca19d9ee8f77b3e49c3cb782a7e3fddb83d954 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sat, 4 May 2024 17:28:42 +0200 Subject: [PATCH 397/403] build-docs.yml - for doc creation don't use docker, call native install some packages for build to generate the docs --- .github/workflows/build-docs.yml | 33 +++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index afcca1c326b..a912e236f32 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -16,12 +16,14 @@ on: - master - dev-branch env: - TARGET: manual + TARGET: TARGET_FINAL: OpenSoar-docs TARGET_EXT: pdf + NDK: jobs: opensoar-compile: runs-on: ubuntu-latest + steps: - id: checkout uses: actions/checkout@v4 @@ -34,14 +36,27 @@ jobs: - name: find githash run: | echo "git_hash=$(git rev-parse --short $GITHUB_SHA)" >> $GITHUB_ENV - - name: XCSoar generate Docs - uses: addnab/docker-run-action@v3 - with: - image: ghcr.io/${{ steps.repository.outputs.lowercase }}/opensoar-build:latest - options: -v ${{ github.workspace }}:/opt/opensoar - run: | - cd /opt/opensoar - make manual V=2 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends \ + make \ + python3 \ + librsvg2-bin xsltproc \ + texlive \ + texlive-latex-extra \ + texlive-luatex \ + texlive-lang-french \ + texlive-lang-polish \ + texlive-lang-portuguese \ + texlive-lang-german \ + liblocale-po-perl + + - name: OpenSoar generate Docs + run: | + make manual V=2 + - name: upload artifact uses: actions/upload-artifact@v4 with: From 4b13b9ca36164edc691785087329a65d8213b632 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 8 May 2024 17:53:46 +0200 Subject: [PATCH 398/403] Input/defaultOV.xci - use shortkey 'Q' for (normal) quit the application * add som comments to other shortkeys --- Data/Input/defaultOV.xci | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Data/Input/defaultOV.xci b/Data/Input/defaultOV.xci index e0de4a6e34e..c6c58d7fb3d 100644 --- a/Data/Input/defaultOV.xci +++ b/Data/Input/defaultOV.xci @@ -88,30 +88,41 @@ type=key data=ESCAPE event=Mode default +# Shutdown mode=default pan Nav1 Nav2 Display1 Display2 Config1 Config2 Config3 Info1 Info2 Menu Vario1 Vario2 type=key data=X event=Shutdown shutdown event=Mode default +# Reboot mode=default pan Nav1 Nav2 Display1 Display2 Config1 Config2 Config3 Info1 Info2 Menu Vario1 Vario2 type=key data=R event=Shutdown reboot event=Mode default + mode=default pan Nav1 Nav2 Display1 Display2 Config1 Config2 Config3 Info1 Info2 Menu Vario1 Vario2 type=key data=Y event=Exit restart event=Mode default +# internal New Start mode=default pan Nav1 Nav2 Display1 Display2 Config1 Config2 Config3 Info1 Info2 Menu Vario1 Vario2 type=key data=N event=Exit newstart event=Mode default +# normal Quit = program end +mode=default pan Nav1 Nav2 Display1 Display2 Config1 Config2 Config3 Info1 Info2 Menu Vario1 Vario2 +type=key +data=Q +event=Exit system +event=Mode default + mode=default pantype=key data=ESCAPE event=Page restore From 79a7bdde0ee7f049301a8f3e63d7b5e868fde2c8 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 8 May 2024 17:56:58 +0200 Subject: [PATCH 399/403] MainWindow.cpp - reset the exit value variable to 0 if you escape the quit - set the normal quit value for OpenVario only if you say 'Yes' --- src/MainWindow.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 4cfbdfedfcd..5d054716fe6 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -773,12 +773,15 @@ MainWindow::OnClose() noexcept if (UIActions::CheckShutdown()) { PostQuit(); - } #ifdef IS_OPENVARIO - if (UI::TopWindow::GetExitValue() == 0) - // normal exit code on OpenVario (for Test purpose!) - UI::TopWindow::SetExitValue(EXIT_NORMAL); // unix has only Byte 10000); + if (UI::TopWindow::GetExitValue() == 0) + // normal exit code on OpenVario (for Test purpose!) + UI::TopWindow::SetExitValue(EXIT_NORMAL); // unix has only Byte 10000); #endif + } else { + // No shutdown/restart - set the exit value back to untouched + UI::TopWindow::SetExitValue(0); + } return true; } From 1c659a45c63a7e277039340b3ef84252358982b9 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sun, 12 May 2024 23:17:01 +0200 Subject: [PATCH 400/403] InputEventsActions.cpp - reenable support for (deprecated) shutdown functions --- src/Input/InputEventsActions.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Input/InputEventsActions.cpp b/src/Input/InputEventsActions.cpp index 97db9aa60e6..84738bdd28e 100644 --- a/src/Input/InputEventsActions.cpp +++ b/src/Input/InputEventsActions.cpp @@ -637,6 +637,12 @@ InputEvents::eventExit([[maybe_unused]] const char *misc) #if defined(IS_OPENVARIO) } else if (StringIsEqual(misc, "newstart")) { UI::TopWindow::SetExitValue(EXIT_NEWSTART); +#if 1 // Deprecated: the support in openvario.xci should be removed.. + } else if (StringIsEqual(misc, "reboot")) { + UI::TopWindow::SetExitValue(EXIT_REBOOT); + } else if (StringIsEqual(misc, "shutdown")) { + UI::TopWindow::SetExitValue(EXIT_SHUTDOWN); +#endif // if 1 #endif } UIActions::SignalShutdown(force); From 12d9a0943e316b32f29fd258c04cc877dce3fb42 Mon Sep 17 00:00:00 2001 From: August2111 Date: Wed, 15 May 2024 14:12:28 +0200 Subject: [PATCH 401/403] MapWindowProjection.cpp - reduce ScaleListCount for OpenVario to prevent the ScalingFreeze --- src/Projection/MapWindowProjection.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Projection/MapWindowProjection.cpp b/src/Projection/MapWindowProjection.cpp index ead314c489c..35dd837947c 100644 --- a/src/Projection/MapWindowProjection.cpp +++ b/src/Projection/MapWindowProjection.cpp @@ -31,7 +31,12 @@ static constexpr unsigned ScaleList[] = { 1000000, // 2 = 500 }; -static constexpr unsigned ScaleListCount = std::size(ScaleList); +#ifdef IS_OPENVARIO +// don't use the last scale value on OpenVario (Performance?) + static constexpr unsigned ScaleListCount = std::size(ScaleList) - 1; +#else + static constexpr unsigned ScaleListCount = std::size(ScaleList); +#endif bool MapWindowProjection::WaypointInScaleFilter(const Waypoint &way_point) const noexcept @@ -57,12 +62,7 @@ double MapWindowProjection::StepMapScale(const double scale, int Step) const noexcept { int i = FindMapScale(scale) + Step; -#ifdef IS_OPENVARIO - // don't use the last scale value on OpenVario (Performance?) - i = std::clamp(i, 0, (int)ScaleListCount - 2); -#else i = std::clamp(i, 0, (int)ScaleListCount - 1); -#endif return CalculateMapScale(i); } From 804ac56de82b0b0554e91587037004a991f9eb78 Mon Sep 17 00:00:00 2001 From: August2111 Date: Sun, 21 Apr 2024 22:34:11 +0200 Subject: [PATCH 402/403] Release v7.42.22 --- OpenSoar-News.md | 11 +++++++++++ OpenSoar.config | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/OpenSoar-News.md b/OpenSoar-News.md index 6dee76ae5d9..2502ca00b71 100644 --- a/OpenSoar-News.md +++ b/OpenSoar-News.md @@ -1,3 +1,14 @@ +OpenSoar Version 7.42.22 - 2024/05/21 +--------------- +* Development- remove UNICODE + - the 2nd step: remove all UNICODE code parts, TCHAR, tstring... + - remove alol ConvertString operations (only needed in previous Windows builds + - use for dynamic created, included source code the *.hpp extension (isnstead of *.cpp) + - create the ProgramVersion.h in generate.mk + - solve the bug at creating manual on Github +* OpenVario - clamb highest map resolution ("500km" to "250km") because performance problem +* Android Bluetooth - detect also BT ports on older systems too - without BLE support (f.e. Nexus7 with Android 5) + OpenSoar Version 7.42.22.A - 2024/04/21 - PreRelease A to 7.42.22 --------------- * System: add possibility to restart OpenSoar without exit to system diff --git a/OpenSoar.config b/OpenSoar.config index 8b890ab7191..a25e6983cd6 100644 --- a/OpenSoar.config +++ b/OpenSoar.config @@ -1,4 +1,4 @@ PROGRAM_NAME=OpenSoar -PROGRAM_VERSION=7.42.22.A +PROGRAM_VERSION=7.42.22 ANDROID_VERSIONCODE=22 ANDROID_PACKAGE=de.opensoar From a29a0265aad42166a3a015bd10a342cf40013a40 Mon Sep 17 00:00:00 2001 From: Blaubart Date: Wed, 10 Jul 2024 22:38:39 +0200 Subject: [PATCH 403/403] File transfer menu revised The menu items have been renamed slightly so that there is less text on the buttons. That makes it a little clearer. A new menu item for uploading individual files has also been added. --- src/OpenVario/FileMenuWidget.cpp | 33 +++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/OpenVario/FileMenuWidget.cpp b/src/OpenVario/FileMenuWidget.cpp index 177c53ef8cb..de39976e85e 100644 --- a/src/OpenVario/FileMenuWidget.cpp +++ b/src/OpenVario/FileMenuWidget.cpp @@ -38,21 +38,36 @@ void FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, [[maybe_unused]] const PixelRect &rc) noexcept { StaticString<60> title; + + title.Format(_(" - Upload IGC Files to USB (WIP)"), main_app); + AddLabel(title); - AddButton(_("Upload IGC Files to USB (WIP)"), []() { + AddButton(_("Upload IGC Files"), []() { static constexpr const char *argv[] = { "/usr/bin/download-igc.sh", nullptr }; RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), - _("Download IGC Files"), argv); + _("Download IGC Files to USB"), argv); }); //----------------------------------------------------- - title.Format(_(" - File Transfers %s Data"), main_app); + title.Format(_(" - Upload Files to OpenVario from USB (map, profile, etc.)"), main_app); AddLabel(title); + AddButton(_("Upload Files to OpenVario"), []() { + static constexpr const char *argv[] = {"/usr/bin/transfers.sh", + "upload-data", _main_app, nullptr}; - AddButton(_("Save: OpenVario -> USB"), []() { + StaticString<32> dialog_title; + dialog_title.Format(_("Restore %s"), main_app); + RunProcessDialog(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), + dialog_title, argv); + }); + + title.Format(_(" - Backup and Restore OpenVario Settings and Files to USB"), main_app); + AddLabel(title); + + AddButton(_("Backup OpenSoar"), []() { static constexpr const char *argv[] = { "/usr/bin/transfers.sh", "download-data", _main_app, nullptr }; @@ -62,9 +77,9 @@ void FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, _("Download files"), argv); }); - AddButton(_("Restore: OpenVario <- USB"), []() { + AddButton(_("Restore OpenSoar"), []() { static constexpr const char *argv[] = {"/usr/bin/transfers.sh", - "upload-data", _main_app, nullptr}; + "restore-data", _main_app, nullptr}; StaticString<32> dialog_title; dialog_title.Format(_("Restore %s"), main_app); @@ -73,10 +88,10 @@ void FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, }); //----------------------------------------------------- - title.Format(_("- Complete System Data Transfers"), main_app); + title.Format(_("- Backup and Restore OpenSoar AND OpenVario System to USB"), main_app); AddLabel(title); // "---OpenSoar Data Files---"); - AddButton(_("Backup: OpenVario System to USB"), []() { + AddButton(_("Backup System"), []() { static constexpr const char *argv[] = {"/usr/bin/transfer-system.sh", "backup", _main_app, nullptr }; @@ -86,7 +101,7 @@ void FileMenuWidget::Prepare([[maybe_unused]] ContainerWindow &parent, _("Backup System"), argv); }); - AddButton(_("Restore: OpenVario System from USB"), []() { + AddButton(_("Restore System"), []() { static constexpr const char *argv[] = {"/usr/bin/transfer-system.sh", "restore", _main_app, nullptr };