diff options
author | Dominik Holland <dominik.holland@pelagicore.com> | 2019-07-11 11:52:58 +0200 |
---|---|---|
committer | Dominik Holland <dominik.holland@pelagicore.com> | 2019-07-15 09:34:30 +0000 |
commit | 431fb82c1b08effc825e6eda01a713f2ce781c35 (patch) | |
tree | 3d0b8a340d24a7e999a1c1f48b9c6f8c699350f3 /src/remotesettings | |
parent | 3f8c5458fa0ca2eab73ef20a5b115d61d3ce81d1 (diff) |
[companion-app] Improve how the server url is given to the QtRO backend
When writing the server.conf to the current directory, we might overwrite
the server.conf which is needed by the servers.
To fix this we now create a temporary directory and write the server.conf
there and point to it using the SERVER_CONF env variable.
Change-Id: I19d00ee241f5e1303fe2daf872559dd7a3558b58
Fixes: AUTOSUITE-1094
Reviewed-by: Bramastyo Harimukti Santoso <bramastyo.harimukti.santoso@pelagicore.com>
Diffstat (limited to 'src/remotesettings')
-rw-r--r-- | src/remotesettings/app/client.cpp | 9 | ||||
-rw-r--r-- | src/remotesettings/app/client.h | 3 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/remotesettings/app/client.cpp b/src/remotesettings/app/client.cpp index b50279e1..8442ef3e 100644 --- a/src/remotesettings/app/client.cpp +++ b/src/remotesettings/app/client.cpp @@ -51,6 +51,9 @@ Client::Client(QObject *parent) : QObject(parent), m_timedOut(false), m_settings(QStringLiteral("Luxoft Sweden AB"), QStringLiteral("NeptuneCompanionApp")) { + m_configPath = m_tmpDir.filePath(QStringLiteral("server.conf")); + qputenv("SERVER_CONF_PATH", m_configPath.toLocal8Bit()); + setStatus(tr("Not connected")); connect(&m_connectionMonitoringTimer, &QTimer::timeout, this, &Client::onCMTimeout); connect(&m_connectionMonitoring, &ConnectionMonitoring::counterChanged, @@ -113,11 +116,7 @@ void Client::connectToServer(const QString &serverUrl) remoteSettingsUrl.setPort(m_remoteSettingsPort); driveDataUrl.setPort(m_driveDataPort); - QString configPath(QStringLiteral("./server.conf")); - if (qEnvironmentVariableIsSet("SERVER_CONF_PATH")) - configPath = QString::fromLocal8Bit(qgetenv("SERVER_CONF_PATH")); - - QSettings settings(configPath, QSettings::IniFormat); + QSettings settings(m_configPath, QSettings::IniFormat); settings.beginGroup(QStringLiteral("remotesettings")); settings.setValue(QStringLiteral("Registry"), remoteSettingsUrl.toString()); settings.endGroup(); diff --git a/src/remotesettings/app/client.h b/src/remotesettings/app/client.h index afb49a23..0f2589ed 100644 --- a/src/remotesettings/app/client.h +++ b/src/remotesettings/app/client.h @@ -37,6 +37,7 @@ #include <QTimer> #include <QLoggingCategory> #include <QUrl> +#include <QTemporaryDir> #include "connectionmonitoring.h" @@ -106,6 +107,8 @@ private: QTimer m_connectionMonitoringTimer; QTimer m_reconnectionTimer; + QTemporaryDir m_tmpDir; + QString m_configPath; }; #endif // CLIENT_H |