Add compile time options for telemetry and updates

This commit is contained in:
Ludwig Nussel 2022-02-14 15:01:32 +01:00
parent 0a07169a8a
commit 5d971375f6
4 changed files with 18 additions and 2 deletions

View file

@ -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)

View file

@ -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

View file

@ -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();
}

View file

@ -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()