diff options
author | Scott Murray <scott.murray@konsulko.com> | 2019-09-09 20:08:43 -0400 |
---|---|---|
committer | Scott Murray <scott.murray@konsulko.com> | 2019-09-11 11:15:25 +0000 |
commit | 2d8e7c007c3fc384e6dd69684932e34d966a63db (patch) | |
tree | 3b5fee02c7bfb386b641496690056649acbbd9b7 /app/main.cpp | |
parent | ea7649ee08a382c7a2a72351cfe6857bd1394493 (diff) |
Update default presets locationhalibut_8.0.3halibut_8.0.2halibut/8.0.3halibut/8.0.28.0.38.0.2
Since the changes to run the applications as non-root, the location
of the default preset file has not matched with the agl-driver user
the application runs as. Since simply changing the install location
to /home/1001 would require some post-install SMACK label tinkering,
and is perhaps fragile to the application user, the files are now
instead installed to /etc/xdg/AGL, with the defaults to be used named
radio-presets.conf. Update the QSettings code to first look for
/etc/xdg/AGL/radio-presets.conf before trying the appdata directory.
Bug-AGL: SPEC-2789
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
Change-Id: I6fd32575c4bd8f42f8575a078f62e64555ba50c2
(cherry picked from commit d216c5604b7598f120d7d53754ac5a7791d45be5)
Diffstat (limited to 'app/main.cpp')
-rw-r--r-- | app/main.cpp | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/app/main.cpp b/app/main.cpp index f555475..319e1e7 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -27,8 +27,12 @@ #include <libhomescreen.hpp> #include <qlibwindowmanager.h> #include <stdlib.h> +#include <fcntl.h> +#include <sys/stat.h> #include "PresetDataObject.h" +#define APP_DATA_PRESETS_PATH "/app-data/radio/presets.conf" + int main(int argc, char *argv[]) { QString graphic_role = QString("radio"); @@ -47,9 +51,9 @@ int main(int argc, char *argv[]) // Read presets from configuration file // - // If HOME is set, use $HOME/app-data/radio/presets.conf, else fall back - // to the QSettings default locations with organization "AGL" and a - // file name of radio-presets.conf. See: + // If HOME is set, use $HOME/app-data/radio/presets.conf if it exists, + // else fall back to the QSettings default locations with organization + // "AGL" and a file name of radio-presets.conf. See: // // http://doc.qt.io/qt-5/qsettings.html#platform-specific-notes // @@ -57,13 +61,22 @@ int main(int argc, char *argv[]) // QSettings *pSettings = NULL; char *p = getenv("HOME"); + bool settingsFound = false; if(p) { - QString confPath = p; - confPath.append("/app-data/radio/presets.conf"); - pSettings = new QSettings(confPath, QSettings::NativeFormat); - } else { - pSettings = new QSettings("AGL", "radio-presets"); + struct stat statbuf; + std::string presets(p); + presets += APP_DATA_PRESETS_PATH; + if(stat(presets.c_str(), &statbuf) == 0) { + QString confPath = p; + confPath.append(APP_DATA_PRESETS_PATH); + pSettings = new QSettings(confPath, QSettings::NativeFormat); + settingsFound = true; + } + } + if(!settingsFound) { + pSettings = new QSettings("AGL", "radio-presets"); } + QList<QObject*> presetDataList; int size = pSettings->beginReadArray("fmPresets"); for (int i = 0; i < size; ++i) { |