summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Rettberg2019-05-31 17:43:04 +0200
committerSimon Rettberg2019-05-31 17:43:04 +0200
commit0b903ef40b727181fcf38356fd2486212973dae9 (patch)
tree376521781284ebbefbe70c7d69351517c2960fef /src
parentRemove debug spam (diff)
downloadvmchooser2-0b903ef40b727181fcf38356fd2486212973dae9.tar.gz
vmchooser2-0b903ef40b727181fcf38356fd2486212973dae9.tar.xz
vmchooser2-0b903ef40b727181fcf38356fd2486212973dae9.zip
Fix .conf file reading, add messages/warnings
Diffstat (limited to 'src')
-rw-r--r--src/config.cpp18
-rw-r--r--src/main.cpp1
2 files changed, 16 insertions, 3 deletions
diff --git a/src/config.cpp b/src/config.cpp
index 63630d0..1689b00 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -5,6 +5,7 @@
#include <QCommandLineOption>
#include <QCommandLineParser>
#include <QSettings>
+#include <QDebug>
static QCommandLineParser parser;
static QSettings* configFile = nullptr;
@@ -81,8 +82,16 @@ bool Config::isSet(const ConfigOption* const option)
return false;
if (parser.isSet(option->cmdLine))
return true;
- if (configFile != nullptr && !option->iniKey.isEmpty())
- return !configFile->value(option->iniKey, option->defaultValue).isNull();
+ if (configFile != nullptr && !option->iniKey.isEmpty() && configFile->contains(option->iniKey)) {
+ // Option present in ini...
+ if (option->withArgument) // ...and needs an argument -> set either way
+ return true;
+ // If it doesn't require an argument, special case
+ QString val = configFile->value(option->iniKey).toString().toLower();
+ if (!val.isEmpty() && val != QLatin1String("false") && val != QLatin1String("0") && val != QLatin1String("no") && val != QLatin1String("off"))
+ return true; // Everything except empty string, "false", "0", "no" and "off" is considered as "is set"
+ // Fall though otherwise
+ }
return false;
}
@@ -93,10 +102,13 @@ bool Config::init(const QCoreApplication& app, const ConfigOption* const configF
parser.process(app);
if (configFileName != nullptr && parser.isSet(configFileName->cmdLine)) {
QString file(parser.value(configFileName->cmdLine));
- if (!QFileInfo(file).exists())
+ if (!QFileInfo(file).exists()) {
+ qDebug() << "--config file" << file << "does not exist!";
return false;
+ }
configFile = new QSettings(file, QSettings::IniFormat);
configFile->setIniCodec("UTF-8");
+ qDebug() << "Using config file" << file;
}
return true;
}
diff --git a/src/main.cpp b/src/main.cpp
index 0e3229b..3390101 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -31,6 +31,7 @@ int main(int argc, char *argv[]) {
}
if (Config::isSet(Config::INSECURE)) {
+ qDebug() << "Warning: Certificate validation disabled";
QSslConfiguration sslConf = QSslConfiguration::defaultConfiguration();
sslConf.setPeerVerifyMode(QSslSocket::VerifyNone);
QSslConfiguration::setDefaultConfiguration(sslConf);