From 5d971375f6594e1e19ef0b071e487967c12a527e Mon Sep 17 00:00:00 2001 From: Ludwig Nussel Date: Mon, 14 Feb 2022 15:01:32 +0100 Subject: [PATCH] Add compile time options for telemetry and updates --- src/CMakeLists.txt | 15 +++++++++++++++ src/config.h | 1 - src/imagewriter.cpp | 2 ++ src/main.qml | 2 +- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 348194e..c8bc0a5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,6 +6,9 @@ if (APPLE) set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "" FORCE) endif() +OPTION (ENABLE_CHECK_VERSION "Check for version updates" ON) +OPTION (ENABLE_TELEMETRY "Enable sending telemetry" ON) + project(rpi-imager LANGUAGES CXX C) set(IMAGER_VERSION_MAJOR 1) set(IMAGER_VERSION_MINOR 7) @@ -107,6 +110,18 @@ else() message(STATUS "LTO not supported: <${ipoerror}>") endif() +if(ENABLE_TELEMETRY) + add_definitions(-DTELEMETRY_ENABLED_DEFAULT=true) +else() + add_definitions(-DTELEMETRY_ENABLED_DEFAULT=false) +endif() + +if(ENABLE_CHECK_VERSION) + add_definitions(-DCHECK_VERSION_DEFAULT=true) +else() + add_definitions(-DCHECK_VERSION_DEFAULT=false) +endif() + # Because dependencies are typically not available by default on Windows, build bundled code if (WIN32) # Target Windows 7 (needed for drivelist module) diff --git a/src/config.h b/src/config.h index 75a4110..7262339 100644 --- a/src/config.h +++ b/src/config.h @@ -15,7 +15,6 @@ /* Phone home the name of images downloaded for image popularity ranking */ #define TELEMETRY_URL "https://rpi-imager-stats.raspberrypi.com/downloads" -#define TELEMETRY_ENABLED_DEFAULT true /* Hash algorithm for verifying (uncompressed image) checksum */ #define OSLIST_HASH_ALGORITHM QCryptographicHash::Sha256 diff --git a/src/imagewriter.cpp b/src/imagewriter.cpp index a88dfdb..b7f4cb2 100644 --- a/src/imagewriter.cpp +++ b/src/imagewriter.cpp @@ -1006,6 +1006,8 @@ bool ImageWriter::getBoolSetting(const QString &key) return _settings.value(key, TELEMETRY_ENABLED_DEFAULT).toBool(); else if (key == "eject") return _settings.value(key, true).toBool(); + else if (key == "check_version") + return _settings.value(key, CHECK_VERSION_DEFAULT).toBool(); else return _settings.value(key).toBool(); } diff --git a/src/main.qml b/src/main.qml index b4bc899..b9f605c 100644 --- a/src/main.qml +++ b/src/main.qml @@ -1143,7 +1143,7 @@ ApplicationWindow { if ("imager" in o) { var imager = o["imager"] - if ("latest_version" in imager && "url" in imager) { + if (imageWriter.getBoolSetting("check_version") && "latest_version" in imager && "url" in imager) { if (!imageWriter.isEmbeddedMode() && imageWriter.isVersionNewer(imager["latest_version"])) { updatepopup.url = imager["url"] updatepopup.openPopup()