From 4e06c8f658886370cac819c556beab6ef51a97cb Mon Sep 17 00:00:00 2001 From: Nathaniel van Diepen Date: Fri, 11 Oct 2024 22:40:11 -0600 Subject: [PATCH] Fix #352 (#388) * Fix #352 * Code review changes * Add missing else --- shared/liboxide/devicesettings.cpp | 13 +++++++++++++ shared/liboxide/devicesettings.h | 5 +++++ shared/liboxide/oxide_sentry.cpp | 4 ++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/shared/liboxide/devicesettings.cpp b/shared/liboxide/devicesettings.cpp index 47870b759..308ddc772 100644 --- a/shared/liboxide/devicesettings.cpp +++ b/shared/liboxide/devicesettings.cpp @@ -322,4 +322,17 @@ namespace Oxide { } return physicalKeyboards; } + + const QString& DeviceSettings::version(){ + static QString version; + static std::once_flag flag; + std::call_once(flag, [] { + QSettings settings("/usr/share/remarkable/update.conf", QSettings::IniFormat); + version = settings.value("REMARKABLE_RELEASE_VERSION").toString(); + if (version.isEmpty()) { + qWarning() << "Failed to read version from update.conf"; + } + }); + return version; + } } diff --git a/shared/liboxide/devicesettings.h b/shared/liboxide/devicesettings.h index e7ad2e833..b8a35fb40 100644 --- a/shared/liboxide/devicesettings.h +++ b/shared/liboxide/devicesettings.h @@ -144,6 +144,11 @@ namespace Oxide{ * \return All virtual keyboard devices */ QList virtualKeyboards(); + /*! + * \brief Get the version of the OS + * \return Version string + */ + const QString& version(); private: DeviceType _deviceType; diff --git a/shared/liboxide/oxide_sentry.cpp b/shared/liboxide/oxide_sentry.cpp index 5cbf7976a..79d0f9127 100644 --- a/shared/liboxide/oxide_sentry.cpp +++ b/shared/liboxide/oxide_sentry.cpp @@ -38,7 +38,7 @@ void logMachineIdError(int error, QString name, QString path){ O_WARNING(path + " has the incorrect format"); }else if(error == -EPERM){ O_WARNING(path + " access denied"); - } if(error == -EINVAL){ + }else if(error == -EINVAL){ O_WARNING("Error while reading " + name + ": Buffer invalid"); }else if(error == -ENXIO){ O_WARNING("Error while reading " + name + ": No invocation ID is set"); @@ -168,7 +168,7 @@ namespace Oxide::Sentry{ sentry_value_set_by_key(user, "id", sentry_value_new_string(machineId())); sentry_set_user(user); // Setup context - std::string version = readFile("/etc/version"); + const auto version = deviceSettings.version().toStdString(); sentry_set_tag("os.version", version.c_str()); sentry_set_tag("name", name); sentry_value_t device = sentry_value_new_object();