Index: denali.pro =================================================================== diff -u -rc73feffa73c7fe073a7a7581144f5806dfc91beb -r389f028cb9d4d320eae393de7c4408a58a619356 --- denali.pro (.../denali.pro) (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) +++ denali.pro (.../denali.pro) (revision 389f028cb9d4d320eae393de7c4408a58a619356) @@ -1,6 +1,7 @@ QT += qml quick serialbus concurrent charts bluetooth CONFIG += c++17 warn_on # CONFIG += disable-desktop +# QMAKE_CXX = clazy QMAKE_CXXFLAGS += -Wall -Werror -Wextra -Wimplicit-fallthrough=3 # -save-temps # see .ii # -Wpedantic -Wconversion -Wshadow # these can't always be used, since it gives errors in Qt library. Index: main.cpp =================================================================== diff -u -rc73feffa73c7fe073a7a7581144f5806dfc91beb -r389f028cb9d4d320eae393de7c4408a58a619356 --- main.cpp (.../main.cpp) (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) +++ main.cpp (.../main.cpp) (revision 389f028cb9d4d320eae393de7c4408a58a619356) @@ -101,6 +101,7 @@ QString gActiveCANBus = "can0"; bool gEnableManufacturing = false ; +bool gUseRootHome = false ; QString gParserErrorText = ""; @@ -263,6 +264,12 @@ QCoreApplication::translate("main", "Enables the manufacturing mode to configure the system for the first time.")); parser.addOption(optionEnableManufacturing); + // --- -R : use-root-home + QCommandLineOption optionUseRootHome( + QStringList() << "R" << "use-root-home", + QCoreApplication::translate("main", "In case the application is not in Manufacturing Setup but needs to use root home folder for configurations.")); + parser.addOption(optionUseRootHome); + // --- parse command lines if ( ! parser.parse(qApp->arguments()) ) { gParserErrorText = parser.errorText(); @@ -286,6 +293,7 @@ gEnableDryDemo = parser.isSet(optionEnableDryDemo ); gEnableManufacturing = parser.isSet(optionEnableManufacturing ); + gUseRootHome = parser.isSet(optionUseRootHome ); if ( parser.isSet(optionActiveCANBus ) ) { QString value = parser.value(optionActiveCANBus); @@ -405,7 +413,7 @@ commandlineParse(); // SYSTEM TEST FOR INSTRUCTIONS WHEN THERE IS NO PORT AVAILABLE - // Storage::FileHandler::copyFolder(QString(Storage::USB_Mount_Point) + "Instructions", QString(Storage::Settings_Path_Name)); + // Storage::FileHandler::copyFolder(QString(Storage::USB_Mount_Point) + "Instructions", QString(Storage::Settings_Path())); //! - Translation initialization QTranslator translator; Index: scripts/run.sh =================================================================== diff -u -r99e5b87f73c3b849ba33a212ec84cf4bf6ef38f1 -r389f028cb9d4d320eae393de7c4408a58a619356 --- scripts/run.sh (.../run.sh) (revision 99e5b87f73c3b849ba33a212ec84cf4bf6ef38f1) +++ scripts/run.sh (.../run.sh) (revision 389f028cb9d4d320eae393de7c4408a58a619356) @@ -229,8 +229,8 @@ # Ther need to be an indication in the application itself to go to the manufacturing mode (-E). # otherwise on each update it want to set to -E mode # a good indication would be the Service Password, and it will be implemented soon. - # The -E has been removed for now from run.sh to prevent the setuation mentioned above. - $HOME/$DENALI_BIN -KaukE & # -K & + # The -E has been removed for now from run.sh to prevent the situation mentioned above. + $HOME/$DENALI_BIN -Kauk -R # -E & # -K & else post_log_fail "Unknown Applicaion Version" fi Index: sources/ApplicationController.cpp =================================================================== diff -u -rc73feffa73c7fe073a7a7581144f5806dfc91beb -r389f028cb9d4d320eae393de7c4408a58a619356 --- sources/ApplicationController.cpp (.../ApplicationController.cpp) (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) +++ sources/ApplicationController.cpp (.../ApplicationController.cpp) (revision 389f028cb9d4d320eae393de7c4408a58a619356) @@ -519,6 +519,7 @@ _Settings; QFuture mFuture = QtConcurrent::run([=](){ // made the call a lambda to make sure there is no function to accidentally being called, out of thread [developer safety]. + //TODO The Settings shall be the Singleton SettingsController and modify the MSettings like the others. Storage::Settings settings; settings.read(); }); Index: sources/device/DeviceController.cpp =================================================================== diff -u -rc73feffa73c7fe073a7a7581144f5806dfc91beb -r389f028cb9d4d320eae393de7c4408a58a619356 --- sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) +++ sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision 389f028cb9d4d320eae393de7c4408a58a619356) @@ -30,6 +30,7 @@ #include "ApplicationController.h" #include "FileHandler.h" #include "DeviceModels.h" +#include "Settings.h" // namespace using namespace Model; @@ -111,6 +112,9 @@ DEVICE_DEV_INIT_CONNECTIONS_LIST + connect(this, SIGNAL(didEventThreadChange()), + this, SLOT( onEventThreadChange())); + } /*! @@ -129,6 +133,8 @@ connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(quit())); _thread->start(); moveToThread(_thread); + + emit didEventThreadChange( QPrivateSignal() ); } /*! @@ -583,7 +589,7 @@ MDeviceCryptSetupResponse model; model._data.mAccepted = false; model._data.mMessage = tr("Encrypted Partition %1 started.").arg(_deviceCryptSetupRequest._data.mCommand); - didAttributeResponse(model.data()); + emit didAttributeResponse(model.data()); } /*! @@ -602,8 +608,24 @@ else deviceInfo = _processCryptSetup.readAll(); model.fromByteArray( deviceInfo, &vExitCode ); // DEBUG: qDebug() << model._data.mEchoInfo; - didAttributeResponse(model.data()); + emit didAttributeResponse(model.data()); LOG_APPED_UI(model.data().mMessage); + + + // move the configuration files if the encrypted partition creation was successful. + if ( ! model._data.mAccepted ) return; + QString msg = ""; + int err = 0 ; + //TODO The Settings shall be the Singleton SettingsController and modify the MSettings like the others. + Storage::Settings settings; + err = settings.configurationsMove(&msg); + if ( err ) { + model._data.mAccepted = false ; + model._data.mReason = err ; + model._data.mMessage = msg ; + emit didAttributeResponse(model.data()); + LOG_APPED_UI(model.data().mMessage); + } } ///////////////////////////////////////////// DeviceBluetoothPaired @@ -634,7 +656,7 @@ else deviceInfo = _processBluetoothPairedReset.readAll(); model.fromByteArray( deviceInfo, &vExitCode ); LOG_APPED_UI(model.data().mMessage); - didAttributeResponse(model.data()); + emit didAttributeResponse(model.data()); } ///////////////////////////////////////////// DeviceBluetoothPairedQuery @@ -666,7 +688,7 @@ if ( vStatus ) vExitCode = Device::DeviceError::eDevice_Scripts_Error_Status; else deviceInfo = _processBluetoothPairedQuery.readAll(); model.fromByteArray( deviceInfo, &vExitCode ); - didAttributeResponse(model.data()); + emit didAttributeResponse(model.data()); LOG_APPED_UI(model.data().mMessage); } @@ -724,3 +746,20 @@ _macWireless = vMacWireless .trimmed(); _macBluetooth = vMacBluetooth .trimmed(); } + +void DeviceController::onEventThreadChange() +{ + qDebug() << " ---------- " << __FUNCTION__ << QThread::currentThread()->objectName() << QThread::currentThread() << qApp->thread(); + if ( QThread::currentThread() != &Threads::_DeviceController_Thread ) { + qCritical() << " ***** Device controller thread not initialized correctly ***** "; + } + + // I_AM_HERE + // HERE move the settings read from ApplicationController to here + // here is when the DeviceController is moved to its thread + // and now can start mounting the encrypted partition + // and then read the settings. + // TODO don't forget to check for the required configurations files and parameters in the settings class. + // and take care of the security flag in the Storage class. +} + Index: sources/device/DeviceController.h =================================================================== diff -u -rc73feffa73c7fe073a7a7581144f5806dfc91beb -r389f028cb9d4d320eae393de7c4408a58a619356 --- sources/device/DeviceController.h (.../DeviceController.h) (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) +++ sources/device/DeviceController.h (.../DeviceController.h) (revision 389f028cb9d4d320eae393de7c4408a58a619356) @@ -133,6 +133,8 @@ void onPOSTInformationReady(const QString &vMacEthernet, const QString &vMacWireless, const QString &vMacBluetooth); + void onEventThreadChange (); + protected: void timerEvent(QTimerEvent *) override; @@ -224,6 +226,12 @@ */ void didPOSTInformationReady(const QString &vMacEthernet, const QString &vMacWireless, const QString &vMacBluetooth); + /*! + * \brief didEventThreadChange + * \details this signal will be emitted when the curr + */ + void didEventThreadChange (QPrivateSignal); + private: // ----- USB void usbCheck(); Index: sources/device/DeviceGlobals.h =================================================================== diff -u -r0e122c98700951af539d9f47c5578e26d640fcc7 -r389f028cb9d4d320eae393de7c4408a58a619356 --- sources/device/DeviceGlobals.h (.../DeviceGlobals.h) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) +++ sources/device/DeviceGlobals.h (.../DeviceGlobals.h) (revision 389f028cb9d4d320eae393de7c4408a58a619356) @@ -21,7 +21,7 @@ namespace Device { -const QString _scriptsFolder = Storage::Scripts_Path_Name; +const QString _scriptsFolder = Storage::Scripts_Path_Name(); } Index: sources/device/DeviceView.cpp =================================================================== diff -u -r99e5b87f73c3b849ba33a212ec84cf4bf6ef38f1 -r389f028cb9d4d320eae393de7c4408a58a619356 --- sources/device/DeviceView.cpp (.../DeviceView.cpp) (revision 99e5b87f73c3b849ba33a212ec84cf4bf6ef38f1) +++ sources/device/DeviceView.cpp (.../DeviceView.cpp) (revision 389f028cb9d4d320eae393de7c4408a58a619356) @@ -72,7 +72,7 @@ DeviceCryptSetupRequestData data; data.mCommand = vCommand; bool ok = false; - data.mPassword = encryption::defaultServicePassword( ok ); + data.mPassword = encryption::configurationsPassword( ok ); if ( ! ok ) { // not enough infromation to create a secure passowrd status(tr("Not enough secure information provided")); } Index: sources/gui/qml/globals/Fonts.qml =================================================================== diff -u -r7c7a07e17ffe6636f138f1a99bdbebbbe4fdea08 -r389f028cb9d4d320eae393de7c4408a58a619356 --- sources/gui/qml/globals/Fonts.qml (.../Fonts.qml) (revision 7c7a07e17ffe6636f138f1a99bdbebbbe4fdea08) +++ sources/gui/qml/globals/Fonts.qml (.../Fonts.qml) (revision 389f028cb9d4d320eae393de7c4408a58a619356) @@ -24,7 +24,7 @@ */ QtObject { readonly property int fontPixelButton : 24 - readonly property int fontPixelTitle : 42 + readonly property int fontPixelTitle : 40 // Changed to 40 to match with the Alarm messaging body font size readonly property int fontPixelSection : 36 readonly property int fontPixelDialogText : 22 Index: sources/main.h =================================================================== diff -u -r9c7a790376d07de7ddaa67e39d47102d68693c87 -r389f028cb9d4d320eae393de7c4408a58a619356 --- sources/main.h (.../main.h) (revision 9c7a790376d07de7ddaa67e39d47102d68693c87) +++ sources/main.h (.../main.h) (revision 389f028cb9d4d320eae393de7c4408a58a619356) @@ -101,6 +101,7 @@ extern bool gEnableDryDemo ; extern QString gActiveCANBus ; extern bool gEnableManufacturing ; +extern bool gUseRootHome ; //--------------------------------------------------------------------------------// Index: sources/storage/Settings.cpp =================================================================== diff -u -ra6586ea871f21a08e7d50552983360fb5e344b3a -r389f028cb9d4d320eae393de7c4408a58a619356 --- sources/storage/Settings.cpp (.../Settings.cpp) (revision a6586ea871f21a08e7d50552983360fb5e344b3a) +++ sources/storage/Settings.cpp (.../Settings.cpp) (revision 389f028cb9d4d320eae393de7c4408a58a619356) @@ -31,8 +31,10 @@ bool Settings::isValid(const QString &vSettingFile) { + int err = Settings::Settings_Error::eError_None; if (! QFileInfo::exists(vSettingFile)) { - LOG_DEBUG("Setting file " + vSettingFile + " does not exist."); + err = Settings::Settings_Error::eError_SettingNotExits; + LOG_DEBUG(errorMessage(err).arg(vSettingFile)); return false; } return true; @@ -44,7 +46,7 @@ * \return QString configuration/settings file name */ QString Settings::fileName(const QString &vCategory) { - return QString("%1%2.%3").arg(Storage::Settings_Path_Name).arg(vCategory).arg(_settingsExt); + return QString("%1%2.%3").arg(Storage::Settings_Path()).arg(vCategory).arg(_settingsExt); } /*! @@ -53,17 +55,19 @@ */ int Settings::read() { + int err = Settings::Settings_Error::eError_None; QStringList fileFilter = QStringList() << QString("*.%1").arg(_settingsExt); - QFileInfoList settingFiles = FileHandler::find (Storage::Settings_Path_Name, fileFilter); - QStringList settingFolders = FileHandler::subFolders(Storage::Settings_Path_Name); + QFileInfoList settingFiles = FileHandler::find (Storage::Settings_Path(), fileFilter); + QStringList settingFolders = FileHandler::subFolders(Storage::Settings_Path()); if ( ! settingFolders.count() ) { - LOG_DEBUG(QObject::tr("No setting folder in the %1").arg(Storage::Settings_Path_Name)); - return 1; // TODO : Define an error enum when completed + err = Settings::Settings_Error::eError_No_SettingFolder; + LOG_DEBUG(errorMessage(err).arg(Storage::Settings_Path())); + return err; } for ( QString &settingFolder : settingFolders ) { - QString folder = settingFolder.prepend(Storage::Settings_Path_Name); + QString folder = settingFolder.prepend(Storage::Settings_Path()); settingFiles += FileHandler::find(folder, fileFilter); } // DEBUG: @@ -73,8 +77,9 @@ // QFileInfo("/home/denali/Projects/application/resources/settings/Alarms/Alarms.conf") // }; if ( ! settingFiles.count() ) { - LOG_DEBUG(QObject::tr("No setting files in the %1").arg(Storage::Settings_Path_Name)); - return 2; // TODO : Define an error enum when completed + err = Settings::Settings_Error::eError_No_SettingFile; + LOG_DEBUG(errorMessage(err).arg(Storage::Settings_Path())); + return err; } QList details; @@ -87,7 +92,7 @@ detail.content = file.readAll().trimmed(); if (detail.content.isEmpty()) continue; detail.location = settingFile.absolutePath() + "/"; - detail.category = QString(detail.location + settingFile.baseName()).remove(Storage::Settings_Path_Name); + detail.category = QString(detail.location + settingFile.baseName()).remove(Storage::Settings_Path()); details += detail; } } @@ -161,7 +166,7 @@ // DEBUG: qDebug() << group << line; } } - return 0; + return err; } /*! @@ -177,20 +182,23 @@ // << vValue; QString mFileName = fileName(vCategory); QString mContent; + int err = Settings_Error::eError_None; // -------------------------------------------------------------------------------------------------------------- //Note: the configuration files which can be saved, are like settings and should not have duplicate values. // as an example the Alarm volume can't have two separate duplicate entry in the settings. // -------------------------------------------------------------------------------------------------------------- _Settings.add(vCategory, vGroup, vKey, vValue, false); QString mPath = QFileInfo(mFileName).absolutePath(); if ( mPath.trimmed().isEmpty() ) { - LOG_DEBUG("The settings path is empty."); - return 1; // TODO: define enum + err = Settings_Error::eError_PathEmpty; + LOG_DEBUG(errorMessage(err)); + return err; } if ( ! FileHandler::makeFolder(mPath) ) { - LOG_DEBUG(QString("The settings path %1 can't be created.").arg(mPath)); - return 2; // TODO: define enum + err = Settings_Error::eError_MkDir; + LOG_DEBUG(errorMessage(err).arg(mPath)); + return err; } for ( const auto &group : _Settings.groups(vCategory) ) { @@ -201,9 +209,32 @@ } if ( ! FileHandler::write(mFileName,mContent, false) ) { - LOG_DEBUG(QString("The settings file %1 can't be written.").arg(mFileName)); - return 3; // TODO: define enum + err = Settings_Error::eError_Write; + LOG_DEBUG(errorMessage(err).arg(mFileName)); + return err; } - return 0; + return err; } + +int Settings::configurationsMove(QString *vMessage) +{ + int err = Settings_Error::eError_None ; + Location_Enum loc = Location_Enum ::eInit; + QString src = Settings::location(Location_Enum ::eInit ) ; + QString dst = Settings::location(Location_Enum ::eSecured ) ; + QString msg = ""; + if ( ! Settings ::configurationsPOST(loc )) { msg = errorMessage(err ); LOG_DEBUG(msg); err = Settings_Error::eError_POST ; goto lOut; } + if ( ! FileHandler ::makeFolder ( dst )) { msg = errorMessage(err ); LOG_DEBUG(msg); err = Settings_Error::eError_MkDir ; goto lOut; } + for( QString dir : FileHandler::subFolders(src)) { + QString sub = src + dir; + if ( FileHandler ::copyFolder (sub, dst )) { msg = errorMessage(err, dir); LOG_DEBUG(msg); err = Settings_Error::eError_Copy ; goto lOut; } + if ( FileHandler ::removeFolder (sub )) { msg = errorMessage(err, dir); LOG_DEBUG(msg); err = Settings_Error::eError_Remove ; goto lOut; } + } + + Storage::Settings_Secured(); + +lOut: + if ( vMessage ) *vMessage = msg; + return err; +} Index: sources/storage/Settings.h =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -r389f028cb9d4d320eae393de7c4408a58a619356 --- sources/storage/Settings.h (.../Settings.h) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ sources/storage/Settings.h (.../Settings.h) (revision 389f028cb9d4d320eae393de7c4408a58a619356) @@ -51,7 +51,46 @@ QString content; }; +// TODO make this the SettingsError class +// { Class SettingsError +public: + enum Settings_Error { + eError_None , + eError_POST , + eError_PathEmpty , + eError_MkDir , + eError_Write , + eError_Copy , + eError_Remove , + eError_No_SettingFolder , + eError_No_SettingFile , + eError_SettingNotExits , + }; private: + const QHash settingsError_Message { // no translation for the error. My experience shows the error messages if trasnlated is not useful for serviceability and debugging. + { eError_None , "" }, + { eError_POST , "The configuration source check failed." }, + { eError_PathEmpty , "The settings path is empty." }, + { eError_MkDir , "The configuration folder '%1' cannot be created." }, + { eError_Write , "The settings file %1 can't be written." }, + { eError_Copy , "The configuration folder '%1' cannot be copied." }, + { eError_Remove , "The configuration folder '%1' cannot be removed." }, + { eError_No_SettingFolder , "No setting folder in the %1 path found." }, + { eError_No_SettingFile , "No setting files in the %1 folder found." }, + { eError_SettingNotExits , "The setting file %1 doesn't exists." }, + }; +public: + const QString errorMessage(int vErr, QString vArg1 = "", QString vArg2 = "") { + if ( settingsError_Message.contains(vErr) ) { + if ( ! vArg1.isEmpty() ) return QString(settingsError_Message[vErr]).arg(vArg1); + if ( ! vArg2.isEmpty() ) return QString(settingsError_Message[vErr]).arg(vArg1).arg(vArg2); + /* default */ return QString(settingsError_Message[vErr]); + } + return "[unknown]"; + } +// } Class SettingsError + +private: const QString makeSetting(const char *vPath, const char *vFile) { QString literal(_settingsFormat); return QString(literal.arg(vPath).arg(vFile).arg(_settingsExt)); @@ -66,9 +105,6 @@ public: Settings() {} - int read(); - int save(const QString &vCategory, const QString &vGroup, const QString &vKey, const QString &vValue); - enum Category_Enum { eInstructions , eConfigurationsDataList , // TODO: the category for this conf is not used. may need to be merged into the Settings, but since it is list, It needs a little more thought. @@ -85,6 +121,16 @@ eKeyCancel , }; + enum Location_Enum { + eInit , + eSecured , + }; + + int read (); + int save (const QString &vCategory, const QString &vGroup, const QString &vKey, const QString &vValue); + int configurationsMove ( QString *vMessage = nullptr); + int configurationsPOST (Location_Enum vLoc = Location_Enum::eSecured) { Q_UNUSED(vLoc); return true; } + static QString category(Category_Enum vCategory) { switch (vCategory) { // NOTE: don't use default case eInstructions : return Storage::Settings_Category_Instructions ; @@ -107,6 +153,14 @@ return ""; } + static QString location(Location_Enum vLoc) { + switch (vLoc) { // NOTE: don't use default + case eInit : return Storage::Settings_Path_Init; + case eSecured : return Storage::Settings_Path_Name; + } + return Storage::Settings_Path_Name; + } + static bool isCategoryInstructions (const QString &vCategory) { return vCategory == category( eInstructions ); } static bool isCategoryConfigurationsDataList (const QString &vCategory) { return vCategory == category( eConfigurationsDataList ); } static bool isCategoryAlarms (const QString &vCategory) { return vCategory == category( eAlarms ); } Index: sources/storage/StorageGlobals.cpp =================================================================== diff -u -r0e122c98700951af539d9f47c5578e26d640fcc7 -r389f028cb9d4d320eae393de7c4408a58a619356 --- sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) +++ sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision 389f028cb9d4d320eae393de7c4408a58a619356) @@ -17,6 +17,10 @@ // Project #include "StorageGlobals.h" + +extern bool gEnableManufacturing ; +extern bool gUseRootHome ; + /*! * \brief Storage * \details The container of the constant global variable withing Storage namespace members. @@ -60,13 +64,20 @@ #endif // Screenshot store folder -const char *Screenshot_Base_Path_Name = "Screenshots/"; // this is the base path which will use the USB_Mount_Point to store the screenshots. + const char *Screenshot_Base_Path_Name = "Screenshots/"; // this is the base path which will use the USB_Mount_Point to store the screenshots. // Settings + static bool settings_secured = false; + const char *Settings_Path () { return gUseRootHome ? Settings_Path_Init : ( gEnableManufacturing ? ( settings_secured ? Settings_Path_Name: Settings_Path_Init ) : Settings_Path_Name ); } + void Settings_Secured() { settings_secured = true; } + #ifdef BUILD_FOR_TARGET - const char *Settings_Path_Name = "/home/root/.config/"; + //WARNING: This has to match with the crypt_setup.sh + const char *Settings_Path_Init = "/home/root/.config/"; // this is the manufacturing setup and the user is root. + const char *Settings_Path_Name = "/var/configurations/"; #else // should be in the project application folder. [is tracking by git] + const char *Settings_Path_Init = "/home/denali/Projects/application/resources/settings/"; const char *Settings_Path_Name = "/home/denali/Projects/application/resources/settings/"; #endif const char *Settings_Category_Instructions = "Instructions/Instructions"; @@ -84,10 +95,10 @@ // CloudSync credentials #ifdef BUILD_FOR_TARGET - const char *CloudSync_Base_Path_Name = "/home/root/.cloudSync/"; + const char *CloudSync_Base_Path_Name = gUseRootHome ? "/home/root/.cloudSync/" : "/var/configurations/CloudSync/"; #else // on VM it is a temporary file which is not being tracked - const char *CloudSync_Base_Path_Name = "/home/denali/Desktop/cloudsync/"; + const char *CloudSync_Base_Path_Name = "/home/denali/Desktop/CloudSync/"; #endif #ifdef BUILD_FOR_TARGET @@ -98,13 +109,21 @@ #endif // Scripts -#ifdef BUILD_FOR_TARGET - const char *Scripts_Path_Name = "/home/root/scripts/"; -#else - // should be in the project application folder. [is tracking by git] - const char *Scripts_Path_Name = "/home/denali/Projects/application/scripts/"; -#endif + const QString Scripts_Path_Name() { + #ifdef BUILD_FOR_TARGET + //TODO The manufacturing mode has to run as root + // after the lockdown.sh ran there would be no root user access + // and I am not sure how we reenalbe the root ssh + // and if it is a security risk to give denali access to sshd_config to enable the root ssh within UI App + // lockdown script suppose to be the last thing to do, + // and it is the lockdown.sh script which moves the scripts from root to denali home folder, + // therefore in manufacturing mode we are still running as root. + return QDir::homePath() + ( gEnableManufacturing ? "/scripts/" : "/scripts/" ); + #else + return QDir::homePath() + "/Projects/application/scripts/"; + #endif + } // Please notice that is the folder not the path // and it needs to be concatenated after SDCard_Base_Path_Name for each build configuration @@ -117,7 +136,7 @@ // FIXME : Not sure having global settings object is a good idea. #ifdef BUILD_FOR_TARGET - QSettings WifiSettings("/home/root/wifi.ini", QSettings::IniFormat); + QSettings WifiSettings("/home/denali/wifi.ini", QSettings::IniFormat); #else QSettings WifiSettings("/home/denali/wifi.ini"); #endif Index: sources/storage/StorageGlobals.h =================================================================== diff -u -r0e122c98700951af539d9f47c5578e26d640fcc7 -r389f028cb9d4d320eae393de7c4408a58a619356 --- sources/storage/StorageGlobals.h (.../StorageGlobals.h) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) +++ sources/storage/StorageGlobals.h (.../StorageGlobals.h) (revision 389f028cb9d4d320eae393de7c4408a58a619356) @@ -44,7 +44,10 @@ extern const char *Screenshot_Base_Path_Name; // Settings - extern const char *Settings_Path_Name; + extern void Settings_Secured (); + extern const char *Settings_Path() ; + extern const char *Settings_Path_Init ; + extern const char *Settings_Path_Name ; extern const char *Settings_Category_Instructions ; extern const char *Settings_Category_InstructionsImagesLoc ; extern const char *Settings_Category_ConfigurationsDataList ; @@ -64,7 +67,7 @@ extern const char *CloudSync_Credentials_Folder_Name; // Scripts - extern const char *Scripts_Path_Name; + extern const QString Scripts_Path_Name(); // Log Type Folders extern const char *Log_Folder_Base; // Base Log Folder Index: sources/utility/encryption.cpp =================================================================== diff -u -r76680860f735250b4557eb18fe7422a26c406f23 -r389f028cb9d4d320eae393de7c4408a58a619356 --- sources/utility/encryption.cpp (.../encryption.cpp) (revision 76680860f735250b4557eb18fe7422a26c406f23) +++ sources/utility/encryption.cpp (.../encryption.cpp) (revision 389f028cb9d4d320eae393de7c4408a58a619356) @@ -109,7 +109,7 @@ /*! * \brief encryption::defaultPassword * \details The default password which will be used as an indication that the service password has not been set yet. - * \return the default password as encrypted string. + * \return the default password will be saved as hashed string. */ QString encryption::defaultServicePassword(bool &ok) { @@ -121,3 +121,36 @@ //DEBUG qDebug() << __FUNCTION__ << hashed; return hashed; } + +/*! + * \brief encryption::configurationsPassword + * \details The password which will be used for encrypt partition. + * \return the password will be saved as hashed string. + */ +QString encryption::configurationsPassword(bool &ok, bool vReset) +{ + if ( vReset ) { // "Diality.2023" + const char d [ ] = { 68, 105, 97, 108, 105, 116, 121, 46, 50, 48, 50, 51, 0 }; + return QString(d); + } + const char c [ ] = { + 50, 75, 102, 98, 106, 67, 46, + 68, 89, 115, 116, 109, 46, + 71, 50, 75, 106, 90, 46, + 105, 78, 105, 120, 73, 46, + 78, 105, 51, 50, 89, 46, + 84, 89, 112, 57, 117, 46, + 77, 50, 52, 119, 103, 46, + 50, 89, 98, 98, 106, 46, + 78, 105, 48, 73, 78, 46, + 109, 70, 50, 52, 119, 46, + 103, 50, 76, 76, 90, 46, + 104, 116, 117, 77, 73, 46, + 78, 105, 111, 50, 89, 46, + 84, 89, 112, 57, 117, 46, + 77, 50, 52, 119, + 0 }; + QString hashed = hashedString(QString(c), ok, true); + //DEBUG qDebug() << __FUNCTION__ << hashed; + return hashed; +} Index: sources/utility/encryption.h =================================================================== diff -u -rc73feffa73c7fe073a7a7581144f5806dfc91beb -r389f028cb9d4d320eae393de7c4408a58a619356 --- sources/utility/encryption.h (.../encryption.h) (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) +++ sources/utility/encryption.h (.../encryption.h) (revision 389f028cb9d4d320eae393de7c4408a58a619356) @@ -38,6 +38,7 @@ static QString hashedString (const QString &vString , bool &ok, bool vAddMoreSalt = true); static bool isDefaultServicePassword (const QString &vPassword, bool &ok); - static QString defaultServicePassword ( bool &ok); + static QString defaultServicePassword ( bool &ok); + static QString configurationsPassword ( bool &ok , bool vReset = false); }; Index: sources/view/settings/VDateTime.cpp =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -r389f028cb9d4d320eae393de7c4408a58a619356 --- sources/view/settings/VDateTime.cpp (.../VDateTime.cpp) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ sources/view/settings/VDateTime.cpp (.../VDateTime.cpp) (revision 389f028cb9d4d320eae393de7c4408a58a619356) @@ -178,7 +178,7 @@ void VDateTime::dateTimeUI(const QString &vDateTime) { if ( _process.state() != QProcess::NotRunning ) { return; } - QString mScript = Storage::Scripts_Path_Name; + QString mScript = Storage::Scripts_Path_Name(); mScript += Storage::Date_Time_Set_Sh; _process.start(mScript, QStringList() << vDateTime); } Index: sources/view/settings/VSettings.cpp =================================================================== diff -u -r99e5b87f73c3b849ba33a212ec84cf4bf6ef38f1 -r389f028cb9d4d320eae393de7c4408a58a619356 --- sources/view/settings/VSettings.cpp (.../VSettings.cpp) (revision 99e5b87f73c3b849ba33a212ec84cf4bf6ef38f1) +++ sources/view/settings/VSettings.cpp (.../VSettings.cpp) (revision 389f028cb9d4d320eae393de7c4408a58a619356) @@ -46,6 +46,7 @@ } void VSettings::servicePass_post(const QString &vservicePass) { + //TODO The Settings shall be the Singleton SettingsController and modify the MSettings like the others. Storage::Settings settings; if ( settings.save(servicePassCategory(), servicePassGroup(), servicePassKey(), vservicePass) != 0 ) { servicePass(""); @@ -54,6 +55,7 @@ } void VSettings::roWaterMode_post(const bool &vroWaterMode_post) { + //TODO The Settings shall be the Singleton SettingsController and modify the MSettings like the others. Storage::Settings settings; if ( settings.save(roWaterModeCategory(), roWaterModeGroup(), roWaterModeKey(), QString::number(vroWaterMode_post)) != 0 ) { roWaterMode(false); @@ -62,11 +64,13 @@ } void VSettings::alarmVolume_post(const quint8 &valarmVolume) { + //TODO The Settings shall be the Singleton SettingsController and modify the MSettings like the others. Storage::Settings settings; settings.save(alarmVolumeCategory(), alarmVolumeGroup(), alarmVolumeKey(), QString::number(valarmVolume)); } void VSettings::noCANBus_post(const bool &vnoCANBus) { + //TODO The Settings shall be the Singleton SettingsController and modify the MSettings like the others. Storage::Settings settings; settings.save(noCANBusCategory(), noCANBusGroup(), noCANBusKey(), QString::number(vnoCANBus)); } Index: sources/view/settings/VSettings.h =================================================================== diff -u -r99e5b87f73c3b849ba33a212ec84cf4bf6ef38f1 -r389f028cb9d4d320eae393de7c4408a58a619356 --- sources/view/settings/VSettings.h (.../VSettings.h) (revision 99e5b87f73c3b849ba33a212ec84cf4bf6ef38f1) +++ sources/view/settings/VSettings.h (.../VSettings.h) (revision 389f028cb9d4d320eae393de7c4408a58a619356) @@ -31,7 +31,7 @@ { Q_OBJECT - QString _location = QString(Storage::Settings_Category_InstructionsImagesLoc).arg(Storage::Settings_Path_Name); + QString _location = QString(Storage::Settings_Category_InstructionsImagesLoc).arg(Storage::Settings_Path()); typedef QList TKeysList; typedef struct { QString location; Index: sources/wifi/WifiInterface.h =================================================================== diff -u -r081df84b4b81ab39296f42c3c7e91deb021b8979 -r389f028cb9d4d320eae393de7c4408a58a619356 --- sources/wifi/WifiInterface.h (.../WifiInterface.h) (revision 081df84b4b81ab39296f42c3c7e91deb021b8979) +++ sources/wifi/WifiInterface.h (.../WifiInterface.h) (revision 389f028cb9d4d320eae393de7c4408a58a619356) @@ -70,7 +70,7 @@ QProcess _processSetDNS; WifiNetworkData _network; - const QString _scriptsFolder = Storage::Scripts_Path_Name; + const QString _scriptsFolder = Storage::Scripts_Path_Name(); const QString _iface = "wlan0"; const QString _wpaSupplicantConfPath = QString("/etc/wpa_supplicant/wpa_supplicant-%1.conf").arg(_iface);