Compare commits
No commits in common. "a3aef7594e6a0787a1f7f9dbc7c32f8427a0f841" and "0a33d078be3f59070648c8d33d049f4b1f80d915" have entirely different histories.
a3aef7594e
...
0a33d078be
@ -4,9 +4,6 @@ repository-url="https://git.mimbach49.de/GerhardHoffmann"
|
|||||||
[DIRECTORIES]
|
[DIRECTORIES]
|
||||||
plugin-directory="/usr/lib/"
|
plugin-directory="/usr/lib/"
|
||||||
working-directory="/opt/app/tools/atbupdate/"
|
working-directory="/opt/app/tools/atbupdate/"
|
||||||
psa-config-directory="etc/psa_config/"
|
|
||||||
psa-tariff-directory="etc/psa_tariff/"
|
|
||||||
|
|
||||||
|
|
||||||
[PLUGINS]
|
[PLUGINS]
|
||||||
plugin-name="libCAslave.so"
|
plugin-name="libCAslave.so"
|
||||||
|
@ -90,8 +90,7 @@ HEADERS += \
|
|||||||
../common/include/System.h
|
../common/include/System.h
|
||||||
|
|
||||||
OTHER_FILES += \
|
OTHER_FILES += \
|
||||||
ATBDownloadDCJsonFiles.ini \
|
ATBDownloadDCJsonFiles.ini
|
||||||
../ATBUpdateTool.ini
|
|
||||||
|
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
#include "commandline_parser.h"
|
#include "commandline_parser.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
#include "System.h"
|
|
||||||
|
|
||||||
#include <DeviceController/interfaces.h>
|
#include <DeviceController/interfaces.h>
|
||||||
|
|
||||||
@ -69,8 +68,6 @@ int main(int argc, char **argv) {
|
|||||||
QString plugInDir = parser.plugInDir();
|
QString plugInDir = parser.plugInDir();
|
||||||
QString plugInName = parser.plugInName();
|
QString plugInName = parser.plugInName();
|
||||||
QString workingDir = parser.workingDir();
|
QString workingDir = parser.workingDir();
|
||||||
QString psaConfigDir = parser.psaConfigDir();
|
|
||||||
QString psaTariffDir = parser.psaTariffDir();
|
|
||||||
QString iniFileName = parser.iniFileName();
|
QString iniFileName = parser.iniFileName();
|
||||||
bool const dryRun = parser.dryRun();
|
bool const dryRun = parser.dryRun();
|
||||||
bool const noUpdatePsaHardware = parser.noUpdatePsaHardware();
|
bool const noUpdatePsaHardware = parser.noUpdatePsaHardware();
|
||||||
@ -93,8 +90,6 @@ int main(int argc, char **argv) {
|
|||||||
qInfo() << "plugInDir ................" << plugInDir;
|
qInfo() << "plugInDir ................" << plugInDir;
|
||||||
qInfo() << "plugInName ..............." << plugInName;
|
qInfo() << "plugInName ..............." << plugInName;
|
||||||
qInfo() << "workingDir ..............." << workingDir;
|
qInfo() << "workingDir ..............." << workingDir;
|
||||||
qInfo() << "psaConfigDir ............." << psaConfigDir;
|
|
||||||
qInfo() << "psaTariffDir ............." << psaTariffDir;
|
|
||||||
qInfo() << "dryRun ..................." << dryRun;
|
qInfo() << "dryRun ..................." << dryRun;
|
||||||
qInfo() << "noUpdatePsaHardware ......" << noUpdatePsaHardware;
|
qInfo() << "noUpdatePsaHardware ......" << noUpdatePsaHardware;
|
||||||
qInfo() << "alwaysDownloadConfig ....." << alwaysDownloadConfig;
|
qInfo() << "alwaysDownloadConfig ....." << alwaysDownloadConfig;
|
||||||
@ -113,31 +108,28 @@ int main(int argc, char **argv) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString const &customerRepo = QDir::cleanPath(workingDir + QDir::separator() + QString("customer_%1").arg(customerNr));
|
QString const customerRepo = QDir::cleanPath(workingDir + QDir::separator() + QString("customer_%1").arg(customerNr));
|
||||||
|
|
||||||
|
qCritical() << "Using customer repository" << customerRepo;
|
||||||
|
|
||||||
|
// always execute contents of opkg_commands-file
|
||||||
QStringList filesToUpdate;
|
QStringList filesToUpdate;
|
||||||
|
|
||||||
// etc/psa_config: located under mount-path
|
QDir dir(QDir::cleanPath(customerRepo + QDir::separator() + "etc/psa_config"));
|
||||||
std::optional<QString> mountPath = System::checkForUSBStick(psaConfigDir);
|
|
||||||
if (mountPath.has_value()) {
|
|
||||||
filesToUpdate = System::getJsonFilesOnUsbStick(mountPath.value());
|
|
||||||
} else {
|
|
||||||
qCritical() << "Using customer repository" << customerRepo;
|
|
||||||
|
|
||||||
QDir dir(QDir::cleanPath(customerRepo + QDir::separator() + "etc/psa_config"));
|
if (dir.exists()) {
|
||||||
if (dir.exists()) {
|
QStringList jsons = dir.entryList(QStringList() << "DC2C*.json", QDir::Files);
|
||||||
QStringList jsons = dir.entryList(QStringList() << "DC2C*.json", QDir::Files);
|
if (!jsons.isEmpty()) {
|
||||||
if (!jsons.isEmpty()) {
|
for (QStringList::size_type i=0; i<jsons.size(); ++i) {
|
||||||
for (QStringList::size_type i=0; i<jsons.size(); ++i) {
|
filesToUpdate << QDir::cleanPath(QString("etc/psa_config/") + jsons.at(i));
|
||||||
filesToUpdate << QDir::cleanPath(QString("etc/psa_config/") + jsons.at(i));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
qCritical() << "DIRECTORY" << dir << "DOES NOT EXIST";
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
qCritical() << "DIRECTORY" << dir << "DOES NOT EXIST";
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// qCritical() << "JSON FILES TO UPDATE" << filesToUpdate;
|
qCritical() << "JSON FILES TO UPDATE" << filesToUpdate;
|
||||||
|
|
||||||
Update update(customerRepo,
|
Update update(customerRepo,
|
||||||
QString::number(customerNr),
|
QString::number(customerNr),
|
||||||
@ -146,13 +138,10 @@ int main(int argc, char **argv) {
|
|||||||
plugInName,
|
plugInName,
|
||||||
workingDir);
|
workingDir);
|
||||||
|
|
||||||
update.doUpdate(filesToUpdate, mountPath.has_value());
|
//update.checkJsonVersions();
|
||||||
update.checkJsonVersions();
|
update.doUpdate(filesToUpdate);
|
||||||
//update.checkJsonVersions(filesToUpdate);
|
update.checkJsonVersions(filesToUpdate);
|
||||||
|
|
||||||
if (mountPath.has_value()) {
|
|
||||||
System::umountUSBStick();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
//return a.exec();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -138,11 +138,10 @@ Update::~Update() {
|
|||||||
unloadDCPlugin();
|
unloadDCPlugin();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Update::doUpdate(QStringList const &filesToWorkOn, bool usbStickDetected) {
|
bool Update::doUpdate(QStringList const &filesToWorkOn) {
|
||||||
|
|
||||||
if (!m_hw) {
|
if (!m_hw) {
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << "):"
|
qCritical() << "ERROR!!! m_hw == nullptr";
|
||||||
<< "ERROR!!! m_hw == nullptr";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,12 +149,10 @@ bool Update::doUpdate(QStringList const &filesToWorkOn, bool usbStickDetected) {
|
|||||||
while ((m_sys_areDCdataValid = m_hw->sys_areDCdataValid()) == false) {
|
while ((m_sys_areDCdataValid = m_hw->sys_areDCdataValid()) == false) {
|
||||||
// must deliver 'true', only then are all data from hwapi valid
|
// must deliver 'true', only then are all data from hwapi valid
|
||||||
if (--tries < 0) {
|
if (--tries < 0) {
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << "):"
|
qCritical() << "ERROR!!! DC DATA NOT VALID -> CA-SLAVE-PLUGIN NOT CONNECTED";
|
||||||
<< "ERROR!!! DC DATA NOT VALID -> CA-SLAVE-PLUGIN NOT CONNECTED";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << "):"
|
qCritical() << "ERROR!!! DC DATA NOT VALID -> CA-SLAVE-PLUGIN NOT CONNECTED (" << tries << ")";
|
||||||
<< "ERROR!!! DC DATA NOT VALID -> CA-SLAVE-PLUGIN NOT CONNECTED (" << tries << ")";
|
|
||||||
m_hw->dc_autoRequest(true);
|
m_hw->dc_autoRequest(true);
|
||||||
QThread::msleep(500);
|
QThread::msleep(500);
|
||||||
}
|
}
|
||||||
@ -164,8 +161,7 @@ bool Update::doUpdate(QStringList const &filesToWorkOn, bool usbStickDetected) {
|
|||||||
|
|
||||||
QList<QString>::const_iterator it;
|
QList<QString>::const_iterator it;
|
||||||
for (it = filesToWorkOn.cbegin(); it != filesToWorkOn.cend(); ++it) {
|
for (it = filesToWorkOn.cbegin(); it != filesToWorkOn.cend(); ++it) {
|
||||||
QString const &fToWorkOn = usbStickDetected ? QDir::cleanPath(it->trimmed())
|
QString const &fToWorkOn = QDir::cleanPath(m_customerRepository + QDir::separator() + it->trimmed());
|
||||||
: QDir::cleanPath(m_customerRepository + QDir::separator() + it->trimmed());
|
|
||||||
if (fToWorkOn.contains("DC2C_print", Qt::CaseInsensitive)
|
if (fToWorkOn.contains("DC2C_print", Qt::CaseInsensitive)
|
||||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||||
res = true;
|
res = true;
|
||||||
@ -207,25 +203,6 @@ bool Update::doUpdate(QStringList const &filesToWorkOn, bool usbStickDetected) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Update::checkJsonVersions(QStringList const& jsonFileNames) {
|
bool Update::checkJsonVersions(QStringList const& jsonFileNames) {
|
||||||
if (!m_hw) {
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << "):"
|
|
||||||
<< "ERROR!!! m_hw == nullptr";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int tries = 20;
|
|
||||||
while ((m_sys_areDCdataValid = m_hw->sys_areDCdataValid()) == false) {
|
|
||||||
// must deliver 'true', only then are all data from hwapi valid
|
|
||||||
if (--tries < 0) {
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << "):"
|
|
||||||
<< "ERROR!!! DC DATA NOT VALID -> CA-SLAVE-PLUGIN NOT CONNECTED";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << "):"
|
|
||||||
<< "ERROR!!! DC DATA NOT VALID -> CA-SLAVE-PLUGIN NOT CONNECTED (" << tries << ")";
|
|
||||||
m_hw->dc_autoRequest(true);
|
|
||||||
QThread::msleep(500);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (QStringList::size_type i=0; i < jsonFileNames.size(); ++i) {
|
for (QStringList::size_type i=0; i < jsonFileNames.size(); ++i) {
|
||||||
|
|
||||||
@ -254,7 +231,6 @@ bool Update::checkJsonVersions(QStringList const& jsonFileNames) {
|
|||||||
bool ok = false;
|
bool ok = false;
|
||||||
int n = captured.toInt(&ok);
|
int n = captured.toInt(&ok);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
// note: use 5 (instead of 4 -> index has been shifted)
|
|
||||||
jsonNr = n + 5;
|
jsonNr = n + 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ public:
|
|||||||
|
|
||||||
virtual ~Update() override;
|
virtual ~Update() override;
|
||||||
|
|
||||||
bool doUpdate(QStringList const &jsonFilesToDownload, bool usbStickDetected = false);
|
bool doUpdate(QStringList const &jsonFilesToDownload);
|
||||||
|
|
||||||
bool updatePrinterTemplate(int templateIdx, QString fname) const;
|
bool updatePrinterTemplate(int templateIdx, QString fname) const;
|
||||||
bool updateConfig(QString jsFileToSendToDC);
|
bool updateConfig(QString jsFileToSendToDC);
|
||||||
|
@ -60,16 +60,6 @@ CommandLineParser::CommandLineParser()
|
|||||||
QStringList() << "working-directory" << "working-directory",
|
QStringList() << "working-directory" << "working-directory",
|
||||||
QCoreApplication::translate("main", "working directory of update-script."),
|
QCoreApplication::translate("main", "working directory of update-script."),
|
||||||
QCoreApplication::translate("main", "directory")))
|
QCoreApplication::translate("main", "directory")))
|
||||||
, m_psaConfigDirectoryOption(
|
|
||||||
QCommandLineOption(
|
|
||||||
QStringList() << "psa-config-directory" << "psa-config-directory",
|
|
||||||
QCoreApplication::translate("main", "config directory of json-files sent to dc."),
|
|
||||||
QCoreApplication::translate("main", "directory")))
|
|
||||||
, m_psaTariffDirectoryOption(
|
|
||||||
QCommandLineOption(
|
|
||||||
QStringList() << "psa-tariff-directory" << "psa-tariff-directory",
|
|
||||||
QCoreApplication::translate("main", "tariff directory of tariff-json-files."),
|
|
||||||
QCoreApplication::translate("main", "directory")))
|
|
||||||
, m_dryRunOption(
|
, m_dryRunOption(
|
||||||
QCommandLineOption(
|
QCommandLineOption(
|
||||||
QStringList() << "d" << "dry-run",
|
QStringList() << "d" << "dry-run",
|
||||||
@ -121,12 +111,6 @@ void CommandLineParser::configure() {
|
|||||||
m_workingDirectoryOption.setDefaultValue("/opt/app/tools/atbupdate/");
|
m_workingDirectoryOption.setDefaultValue("/opt/app/tools/atbupdate/");
|
||||||
m_parser.addOption(m_workingDirectoryOption);
|
m_parser.addOption(m_workingDirectoryOption);
|
||||||
|
|
||||||
m_psaConfigDirectoryOption.setDefaultValue("etc/psa_config/");
|
|
||||||
m_parser.addOption(m_psaConfigDirectoryOption);
|
|
||||||
|
|
||||||
m_psaTariffDirectoryOption.setDefaultValue("etc/psa_tariff/");
|
|
||||||
m_parser.addOption(m_psaTariffDirectoryOption);
|
|
||||||
|
|
||||||
m_dryRunOption.setDefaultValue("false");
|
m_dryRunOption.setDefaultValue("false");
|
||||||
m_parser.addOption(m_dryRunOption);
|
m_parser.addOption(m_dryRunOption);
|
||||||
|
|
||||||
@ -167,12 +151,6 @@ void CommandLineParser::readSettings() {
|
|||||||
if (key.contains("working-directory")) {
|
if (key.contains("working-directory")) {
|
||||||
m_workingDir = v.toString();
|
m_workingDir = v.toString();
|
||||||
} else
|
} else
|
||||||
if (key.contains("psa-config-directory")) {
|
|
||||||
m_psaConfigDir = v.toString();
|
|
||||||
} else
|
|
||||||
if (key.contains("psa-tariff-directory")) {
|
|
||||||
m_psaTariffDir = v.toString();
|
|
||||||
} else
|
|
||||||
if (key.contains("dry-run")) {
|
if (key.contains("dry-run")) {
|
||||||
m_dryRun = (v.toBool() ? "true" : "false");
|
m_dryRun = (v.toBool() ? "true" : "false");
|
||||||
} else
|
} else
|
||||||
@ -229,20 +207,6 @@ QString CommandLineParser::plugInName() {
|
|||||||
return m_plugInName;
|
return m_plugInName;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CommandLineParser::psaConfigDir() {
|
|
||||||
if (m_parser.isSet(m_psaConfigDirectoryOption)) {
|
|
||||||
m_psaConfigDir = m_parser.value(m_psaConfigDirectoryOption);
|
|
||||||
}
|
|
||||||
return m_psaConfigDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString CommandLineParser::psaTariffDir() {
|
|
||||||
if (m_parser.isSet(m_psaTariffDirectoryOption)) {
|
|
||||||
m_psaTariffDir = m_parser.value(m_psaTariffDirectoryOption);
|
|
||||||
}
|
|
||||||
return m_psaTariffDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString CommandLineParser::workingDir() {
|
QString CommandLineParser::workingDir() {
|
||||||
if (m_parser.isSet(m_workingDirectoryOption)) {
|
if (m_parser.isSet(m_workingDirectoryOption)) {
|
||||||
m_workingDir = m_parser.value(m_workingDirectoryOption);
|
m_workingDir = m_parser.value(m_workingDirectoryOption);
|
||||||
|
@ -11,8 +11,6 @@ class CommandLineParser : public QCommandLineParser {
|
|||||||
QString m_plugInDir;
|
QString m_plugInDir;
|
||||||
QString m_plugInName;
|
QString m_plugInName;
|
||||||
QString m_workingDir;
|
QString m_workingDir;
|
||||||
QString m_psaConfigDir;
|
|
||||||
QString m_psaTariffDir;
|
|
||||||
QString m_dryRun;
|
QString m_dryRun;
|
||||||
QString m_noUpdatePsaHardware;
|
QString m_noUpdatePsaHardware;
|
||||||
QString m_showYoctoVersion;
|
QString m_showYoctoVersion;
|
||||||
@ -31,8 +29,6 @@ class CommandLineParser : public QCommandLineParser {
|
|||||||
QCommandLineOption m_alwaysDownloadConfigOption;
|
QCommandLineOption m_alwaysDownloadConfigOption;
|
||||||
QCommandLineOption m_alwaysDownloadDCOption;
|
QCommandLineOption m_alwaysDownloadDCOption;
|
||||||
QCommandLineOption m_workingDirectoryOption;
|
QCommandLineOption m_workingDirectoryOption;
|
||||||
QCommandLineOption m_psaConfigDirectoryOption;
|
|
||||||
QCommandLineOption m_psaTariffDirectoryOption;
|
|
||||||
QCommandLineOption m_dryRunOption;
|
QCommandLineOption m_dryRunOption;
|
||||||
QCommandLineOption m_extendedVersionOption;
|
QCommandLineOption m_extendedVersionOption;
|
||||||
QCommandLineOption m_yoctoVersionOption;
|
QCommandLineOption m_yoctoVersionOption;
|
||||||
@ -56,8 +52,6 @@ public:
|
|||||||
QString plugInDir();
|
QString plugInDir();
|
||||||
QString plugInName();
|
QString plugInName();
|
||||||
QString workingDir();
|
QString workingDir();
|
||||||
QString psaConfigDir();
|
|
||||||
QString psaTariffDir();
|
|
||||||
bool dryRun();
|
bool dryRun();
|
||||||
bool noUpdatePsaHardware();
|
bool noUpdatePsaHardware();
|
||||||
bool yoctoVersion();
|
bool yoctoVersion();
|
||||||
|
@ -651,7 +651,6 @@ bool Update::checkDownloadedJsonVersions(QStringList const& jsonFileNames) {
|
|||||||
bool ok = false;
|
bool ok = false;
|
||||||
int n = captured.toInt(&ok);
|
int n = captured.toInt(&ok);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
// note: the '5' is correct
|
|
||||||
jsonNr = n + 5;
|
jsonNr = n + 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -869,7 +869,6 @@ bool Worker::execOpkgCommands() {
|
|||||||
QStringList opkgErrorLst;
|
QStringList opkgErrorLst;
|
||||||
while (!in.atEnd()) {
|
while (!in.atEnd()) {
|
||||||
QString line = in.readLine();
|
QString line = in.readLine();
|
||||||
// TODO: "^\\s*[#]{0,}$" : empty line or comment line starting with #
|
|
||||||
static const QRegularExpression comment("^\\s*#.*$");
|
static const QRegularExpression comment("^\\s*#.*$");
|
||||||
if (line.indexOf(comment, 0) == -1) {
|
if (line.indexOf(comment, 0) == -1) {
|
||||||
// found opkg command
|
// found opkg command
|
||||||
|
@ -3,10 +3,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QStringList>
|
|
||||||
|
|
||||||
#include <optional>
|
|
||||||
#include <initializer_list>
|
|
||||||
|
|
||||||
class System : public QObject
|
class System : public QObject
|
||||||
{
|
{
|
||||||
@ -17,17 +13,16 @@ private:
|
|||||||
|
|
||||||
static QString errorMsg;
|
static QString errorMsg;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static const QStringList allowedJsonFiles;
|
|
||||||
|
|
||||||
static bool checkForSDCard();
|
static bool checkForSDCard();
|
||||||
static bool umountSDCard();
|
static bool umountSDCard();
|
||||||
|
|
||||||
static std::optional<QString> checkForUSBStick(QString const &dirPathUnderMountPath = ".");
|
static bool checkForUSBStick();
|
||||||
static QString getUSBMountPath(QString const &dirPathUnderMountPath = ".");
|
static QString getUSBMountPath();
|
||||||
|
static QString getUSBDeviceName();
|
||||||
//static QString getUSBDeviceName();
|
|
||||||
static bool umountUSBStick();
|
static bool umountUSBStick();
|
||||||
|
|
||||||
static bool test_mount(const QString& dev, const QString &mountpoint);
|
static bool test_mount(const QString& dev, const QString &mountpoint);
|
||||||
@ -53,7 +48,7 @@ public:
|
|||||||
static QString getPTU4SerialNumber();
|
static QString getPTU4SerialNumber();
|
||||||
static QString getPTU4MACAddress();
|
static QString getPTU4MACAddress();
|
||||||
|
|
||||||
static QStringList getJsonFilesOnUsbStick(QString const &mountPath);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -7,52 +7,10 @@
|
|||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDirIterator>
|
|
||||||
|
|
||||||
//#include "version.h"
|
//#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const QStringList System::allowedJsonFiles =
|
|
||||||
std::initializer_list<QString>{
|
|
||||||
QString("DC2C_conf.json"),
|
|
||||||
QString("DC2C_cash.json"),
|
|
||||||
QString("DC2C_device.json"),
|
|
||||||
QString("DC2C_print01.json"),
|
|
||||||
QString("DC2C_print02.json"),
|
|
||||||
QString("DC2C_print03.json"),
|
|
||||||
QString("DC2C_print04.json"),
|
|
||||||
QString("DC2C_print05.json"),
|
|
||||||
QString("DC2C_print06.json"),
|
|
||||||
QString("DC2C_print07.json"),
|
|
||||||
QString("DC2C_print08.json"),
|
|
||||||
QString("DC2C_print09.json"),
|
|
||||||
QString("DC2C_print10.json"),
|
|
||||||
QString("DC2C_print11.json"),
|
|
||||||
QString("DC2C_print12.json"),
|
|
||||||
QString("DC2C_print13.json"),
|
|
||||||
QString("DC2C_print14.json"),
|
|
||||||
QString("DC2C_print15.json"),
|
|
||||||
QString("DC2C_print16.json"),
|
|
||||||
QString("DC2C_print17.json"),
|
|
||||||
QString("DC2C_print18.json"),
|
|
||||||
QString("DC2C_print19.json"),
|
|
||||||
QString("DC2C_print20.json"),
|
|
||||||
QString("DC2C_print21.json"),
|
|
||||||
QString("DC2C_print22.json"),
|
|
||||||
QString("DC2C_print23.json"),
|
|
||||||
QString("DC2C_print24.json"),
|
|
||||||
QString("DC2C_print25.json"),
|
|
||||||
QString("DC2C_print26.json"),
|
|
||||||
QString("DC2C_print27.json"),
|
|
||||||
QString("DC2C_print28.json"),
|
|
||||||
QString("DC2C_print29.json"),
|
|
||||||
QString("DC2C_print30.json"),
|
|
||||||
QString("DC2C_print31.json"),
|
|
||||||
QString("DC2C_print32.json")
|
|
||||||
};
|
|
||||||
|
|
||||||
QString System::errorMsg = "";
|
QString System::errorMsg = "";
|
||||||
|
|
||||||
System::System(QObject *parent) :
|
System::System(QObject *parent) :
|
||||||
@ -251,7 +209,8 @@ bool System::test_dir(const QString& dir)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::optional<QString> System::checkForUSBStick(QString const &dirPathUnderMountPath) {
|
bool System::checkForUSBStick()
|
||||||
|
{
|
||||||
#if defined (ARCH_DesktopLinux)
|
#if defined (ARCH_DesktopLinux)
|
||||||
// DEBUG / TEST:
|
// DEBUG / TEST:
|
||||||
if (QFileInfo(getUSBMountPath()).isDir())
|
if (QFileInfo(getUSBMountPath()).isDir())
|
||||||
@ -260,9 +219,11 @@ std::optional<QString> System::checkForUSBStick(QString const &dirPathUnderMount
|
|||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QString const &mountPath = getUSBMountPath(dirPathUnderMountPath);
|
if (getUSBMountPath().isEmpty()) {
|
||||||
// qCritical() << "MOUNT-PATH" << mountPath;
|
return false;
|
||||||
return mountPath.isEmpty() ? std::nullopt : std::optional<QString>(mountPath);
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -274,7 +235,8 @@ std::optional<QString> System::checkForUSBStick(QString const &dirPathUnderMount
|
|||||||
* Note, do not return an empty string ("") here because a calling method (which could not be
|
* Note, do not return an empty string ("") here because a calling method (which could not be
|
||||||
* identified till now) is relying on this!
|
* identified till now) is relying on this!
|
||||||
*/
|
*/
|
||||||
QString System::getUSBMountPath(QString const &dirPathUnderMountPath) {
|
QString System::getUSBMountPath()
|
||||||
|
{
|
||||||
|
|
||||||
#if defined (ARCH_DesktopLinux)
|
#if defined (ARCH_DesktopLinux)
|
||||||
// DEBUG / TEST:
|
// DEBUG / TEST:
|
||||||
@ -315,13 +277,8 @@ QString System::getUSBMountPath(QString const &dirPathUnderMountPath) {
|
|||||||
|
|
||||||
mountLine = line.split(' ');
|
mountLine = line.split(' ');
|
||||||
if (mountLine.size() > 3) {
|
if (mountLine.size() > 3) {
|
||||||
qCritical() << "System::getUSBMountPath(): " << mountLine.at(0) << " is mounted on " << mountLine.at(2);
|
qDebug() << "System::getUSBMountPath(): " << mountLine.at(0) << " is mounted on " << mountLine.at(2);
|
||||||
QDir d(QDir::cleanPath(mountLine.at(2) + QDir::separator() + dirPathUnderMountPath));
|
return mountLine.at(2);
|
||||||
if (d.exists()) {
|
|
||||||
return mountLine.at(2);
|
|
||||||
} else {
|
|
||||||
qCritical() << "directory" << d.absolutePath() << "does not exist";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -332,27 +289,6 @@ QString System::getUSBMountPath(QString const &dirPathUnderMountPath) {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList System::getJsonFilesOnUsbStick(QString const &mountPath) {
|
|
||||||
QStringList jsonFiles;
|
|
||||||
|
|
||||||
// /media/sda2/etc/psa_config
|
|
||||||
QString const &dirPath = QDir::cleanPath(mountPath + QDir::separator() + "etc" + QDir::separator() + "psa_config");
|
|
||||||
QDir d(dirPath);
|
|
||||||
if (d.exists()) {
|
|
||||||
QDirIterator it(dirPath, QStringList() << "*.json", QDir::Files, QDirIterator::NoIteratorFlags);
|
|
||||||
while (it.hasNext()) {
|
|
||||||
QString const &jsonFile = it.next();
|
|
||||||
QFileInfo fi(jsonFile);
|
|
||||||
if (System::allowedJsonFiles.contains(fi.fileName())) {
|
|
||||||
jsonFiles << jsonFile;
|
|
||||||
} else {
|
|
||||||
qCritical() << "Warning:" << fi.fileName() << "unknown";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return jsonFiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
* static function to check if a mounted sd-card is writable.
|
* static function to check if a mounted sd-card is writable.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user