Index: denali.pro =================================================================== diff -u -r380136967ba230affe91f614a9805319688eb05b -rc73feffa73c7fe073a7a7581144f5806dfc91beb --- denali.pro (.../denali.pro) (revision 380136967ba230affe91f614a9805319688eb05b) +++ denali.pro (.../denali.pro) (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) @@ -371,7 +371,8 @@ \ # Utility sources/utility/crc.h \ sources/utility/format.h \ - sources/utility/types.h + sources/utility/types.h \ + sources/utility/encryption.h SOURCES += \ \ # common @@ -630,7 +631,8 @@ \ # Utility sources/utility/crc.cpp \ sources/utility/format.cpp \ - sources/utility/types.cpp + sources/utility/types.cpp \ + sources/utility/encryption.cpp RESOURCES += \ denali.qrc Index: denali.pro.user =================================================================== diff -u -r1f2e7dbd08b00f8c56eedf29f083733570aa642e -rc73feffa73c7fe073a7a7581144f5806dfc91beb --- denali.pro.user (.../denali.pro.user) (revision 1f2e7dbd08b00f8c56eedf29f083733570aa642e) +++ denali.pro.user (.../denali.pro.user) (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) @@ -1,6 +1,6 @@ - + EnvironmentId @@ -270,7 +270,7 @@ Qt4ProjectManager.Qt4RunConfiguration:/home/denali/Projects/application/denali.pro /home/denali/Projects/application/denali.pro - --disable-alarm-no-minimize + -K false true true Index: main.cpp =================================================================== diff -u -r9c7a790376d07de7ddaa67e39d47102d68693c87 -rc73feffa73c7fe073a7a7581144f5806dfc91beb --- main.cpp (.../main.cpp) (revision 9c7a790376d07de7ddaa67e39d47102d68693c87) +++ main.cpp (.../main.cpp) (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) @@ -202,7 +202,7 @@ QCoreApplication::translate("main", "Disable unhandled messages report as an error in the log")); parser.addOption(optionDisableUnhandledReport); - // --- -d : enable-dialin-unhandled + // --- -d : disable-dialin-unhandled QCommandLineOption optionDisableDialinUnhandled( QStringList() << "d" << "disable-dialin-unhandled", QCoreApplication::translate("main", "Disable the Dialin messages logged as unhandled")); @@ -458,7 +458,6 @@ //! - Initializing Application Controller _ApplicationController.init(Threads::_Application_Thread); - _ApplicationController.initSettings(); ////! - Initializing GUI Controller _GuiController.init(Threads::_Gui_Thread); Index: scripts/run.sh =================================================================== diff -u -r0e122c98700951af539d9f47c5578e26d640fcc7 -rc73feffa73c7fe073a7a7581144f5806dfc91beb --- scripts/run.sh (.../run.sh) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) +++ scripts/run.sh (.../run.sh) (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) @@ -230,7 +230,7 @@ # 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 -Kauk & + $HOME/$DENALI_BIN -K & else post_log_fail "Unknown Applicaion Version" fi Index: sources/ApplicationController.cpp =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -rc73feffa73c7fe073a7a7581144f5806dfc91beb --- sources/ApplicationController.cpp (.../ApplicationController.cpp) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ sources/ApplicationController.cpp (.../ApplicationController.cpp) (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) @@ -146,9 +146,6 @@ connect(&_Logger , SIGNAL(didExportStat (quint32, const QString &, quint8)), this , SLOT( onExportStat (quint32, const QString &, quint8))); - // Settings - move to application thread - connect(this, SIGNAL(didSettingsInit()), - this, SLOT( onSettingsInit())); connect(&_settingsWatcher, SIGNAL(finished ()), this , SLOT(onSettingsUpdate())); @@ -502,31 +499,29 @@ } // disabled coco end + +void ApplicationController::postDoneRequest() +{ + AdjustUIPostFinalResultRequestData data; + data.mResult = _post.isDone(); + emit didAdjustment(data); +} + /*! * \brief ApplicationController::initSettings * \details The external method available to request for initializing the settings * To start the task in Application Tread, emits a signal which will call a slot to take care of the execution. */ void ApplicationController::initSettings() { - // this emit guaranties that the slot will be called in the application thread - // also the signal is private so it will be used internally only. - emit didSettingsInit({}); -} - -/*! - * \brief ApplicationController::onSettingsInit - * \details The slot which will be called to start the settings initialization in Application thread. - * This method also initializes the Settings model singleton object to let it live in the Application thread. - * To start the setting initialization QConcurrent is used with QFuture to signal the Application when it's done. - */ -void ApplicationController::onSettingsInit() -{ // That is enough to call to the I function here to create the object in the thread that Settings is leaving in, // which currently is Application_Thread, since the Settings is created in that thread. _Settings; - QFuture mFuture = QtConcurrent::run(this, &ApplicationController::settingsInit); + 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]. + Storage::Settings settings; + settings.read(); + }); _settingsWatcher.setFuture(mFuture); } @@ -543,6 +538,8 @@ _Settings.datetimeFormat(); emit didSettingsDone(); + + emit didPOSTPass(_post.isDone()); } /*! @@ -594,11 +591,12 @@ * \details Sends the POST Final message */ void ApplicationController::onPOSTDone(bool vPass) { - AdjustUIPostFinalResultRequestData data; - data.mResult = vPass; - emit didAdjustment(data); - LOG_DEBUG("ApplicationPost Done"); + LOG_DEBUG("ApplicationPOST Done"); + initSettings(); + + postDoneRequest(); + versionsRequest(vPass); } @@ -616,17 +614,6 @@ } /*! - * \brief ApplicationController::settingsInit - * \details The Settings read function is called in this method. - * This callback function for the QCuncurrnent run. - */ -void ApplicationController::settingsInit() -{ - Storage::Settings settings; - settings.read(); -} - -/*! * \brief ApplicationController::onstartPOST * \details The POST entry point * - Sends the first async check-in to the HD to let HD know it can start it's POST and UI is ready to communicate. Index: sources/ApplicationController.h =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -rc73feffa73c7fe073a7a7581144f5806dfc91beb --- sources/ApplicationController.h (.../ApplicationController.h) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ sources/ApplicationController.h (.../ApplicationController.h) (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) @@ -73,13 +73,14 @@ void initThread(QThread &vThread); void quitThread(); + void initSetttings(); + void keepAlive(); void createFakeSequencedLongMessage (QVariantList &vData, const int vFakeDataLen); void createFakeSeqAtBeginLongMessage(QVariantList &vData, const int vFakeDataLen); - void settingsInit(); - + void postDoneRequest(); void versionsRequest(bool vPass); private slots: // Should be private for thread safety and is connected internally. @@ -105,7 +106,6 @@ void onFailedTransmit(Sequence seq); - void onSettingsInit(); void onSettingsUpdate(); void onPOSTWiFi (bool vPass); @@ -148,6 +148,20 @@ * \details This signal will be emitted when the settings are read and ready to be used. */ void didSettingsDone (); + /*! + * \brief didPOSTPass + * \details This signal will be emitted when UI is done with the POST and will let other layers to know the result. + * As an example the Manufacturing will not start if the POST filed since it needs POST info for hte Encrypted partition. + * \param vPass - true if passed. + */ + void didPOSTPass (bool vPass); + /*! + * \brief didPOSTInformationReady + * \details this signall will be emitted in case the UI POST is successfull, BEFORE the didPOSTDone. + * \note note that this will be called before the didPOSTDone, to give the opportunity to the observer to update the required information before being notified for the POST result, + * so in case there are things to be done on POST success, the data is ready. + */ + void didPOSTInformationReady(const QString &vMacEthernet, const QString &vMacWreless, const QString &vMacBluetooth); // Device Signal/Slots DEVICE_APP_BRIDGE_DEFINITION_LIST @@ -157,7 +171,6 @@ ACTION_RECEIVE_MODEL_BRIDGE_DEFINITIONS ACTION_RECEIVE_PRIVATE_SLOT_NOEMIT(UIPostFinalResultHDRequestData) { - onPOSTDone(_post.isDone()); emit didActionReceive(vData); } Index: sources/ApplicationPost.cpp =================================================================== diff -u -r7c86f3854db9ad02d95681203198d75a0d65c9fa -rc73feffa73c7fe073a7a7581144f5806dfc91beb --- sources/ApplicationPost.cpp (.../ApplicationPost.cpp) (revision 7c86f3854db9ad02d95681203198d75a0d65c9fa) +++ sources/ApplicationPost.cpp (.../ApplicationPost.cpp) (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) @@ -64,6 +64,8 @@ isWiFi () && isBluetooth () && isCloudSync () && + // isEthernet () && // it is being executed to get the information but is not part of the POST failure. + // isSound () && isYearCheck () ; } @@ -155,13 +157,46 @@ } /*! + * \brief ApplicationPost::checkEthernet + * \details Checks the Ethernet driver is loaded and functional. + * \return false if there is an issue [Removed from the PRS (always true)]. + */ +bool ApplicationPost::checkEthernet() +{ + bool ok = false; + int posDev = -1; + int posMac = -1; + QString section = ""; + posDev = _content.indexOf( _devEthernet ); if ( posDev < 0 ) goto lOut; + section = _content.mid(posDev, _macAppearLen); + posMac = section.indexOf(_macEthernetLabel); if ( posMac < 0 ) goto lOut; + _macEthernet = section.mid(posMac + _macEthernetLabel.length(), _macAddrssLen).toUpper(); if ( _macEthernet.isEmpty() ) goto lOut; + ok = true; + +lOut: + if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_HD_UI_POST_FAILURE_ETHERNET); + emit didEthernet(ok); + return ok; +} + +/*! * \brief ApplicationPost::checkWiFi * \details Checks the WiFi driver is loaded and functional * \return false if there is an issue. */ bool ApplicationPost::checkWiFi() { - bool ok = _content.contains(_postmsg_wifi + _postmsg_postfix_passed); + bool ok = false; + int posDev = -1; + int posMac = -1; + QString section = ""; + posDev = _content.indexOf( _devWireless ); if ( posDev < 0 ) goto lOut; + section = _content.mid(posDev, _macAppearLen); + posMac = section.indexOf(_macWirelessLabel); if ( posMac < 0 ) goto lOut; + _macWireless = section.mid(posMac + _macWirelessLabel.length(), _macAddrssLen).toUpper(); if ( _macWireless.isEmpty() ) goto lOut; + ok = _content.contains(_postmsg_wifi + _postmsg_postfix_passed); + +lOut: if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_HD_UI_POST_FAILURE_WIFI); emit didWiFi(ok); return ok; @@ -174,7 +209,17 @@ */ bool ApplicationPost::checkBluetooth() { - bool ok = _content.contains(_postmsg_bluetooth + _postmsg_postfix_passed); + bool ok = false; + int posDev = -1; + int posMac = -1; + QString section = ""; + posDev = _content.indexOf( _devBluetooth ); if ( posDev < 0 ) goto lOut; + section = _content.mid(posDev, _macAppearLen); + posMac = section.indexOf(_macBluetoothLabel); if ( posMac < 0 ) goto lOut; + _macBluetooth = section.mid(posMac + _macBluetoothLabel.length(), _macAddrssLen).toUpper(); if ( _macBluetooth.isEmpty() ) goto lOut; + ok = _content.contains(_postmsg_bluetooth + _postmsg_postfix_passed); + +lOut: if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_HD_UI_POST_FAILURE_BLUETOOTH); emit didBluetooth(ok); return ok; @@ -197,20 +242,6 @@ } /*! - * \brief ApplicationPost::checkEthernet - * \details Checks the Ethernet driver is loaded and functional. - * \return false if there is an issue [Removed from the PRS (always true)]. - */ -bool ApplicationPost::checkEthernet() -{ - bool ok = true; - // do the test : we are not using this for now since it has been removed from the PRS. - if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_HD_UI_POST_FAILURE_ETHERNET); - emit didEthernet(ok); - return ok; -} - -/*! * \brief ApplicationPost::checkSound * \details Checks the sound driver is loaded. * \return false if there is an issue [No Implementation yet (always true)]. Index: sources/ApplicationPost.h =================================================================== diff -u -r7c86f3854db9ad02d95681203198d75a0d65c9fa -rc73feffa73c7fe073a7a7581144f5806dfc91beb --- sources/ApplicationPost.h (.../ApplicationPost.h) (revision 7c86f3854db9ad02d95681203198d75a0d65c9fa) +++ sources/ApplicationPost.h (.../ApplicationPost.h) (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) @@ -70,6 +70,18 @@ const QString _postmsg_shasum = "App shasum" ; // POSTMSG_SHASUM="App shasum" const QString _postmsg_cloudsync = "CloudSync" ; // POSTMSG_CLOUDSYNC="CloudSync" + const quint8 _macAddrssLen = 17 ; // ff:ff:ff:ff:ff:ff + const quint8 _macAppearLen = 200 ; // the mac address shall be found within the next 200 characters. + const QString _devEthernet = "eth0:" ; + const QString _devWireless = "wlan0:" ; + const QString _devBluetooth = "hci0:" ; + const QString _macEthernetLabel = "link/ether " ; // the last space is important + const QString _macWirelessLabel = "link/ether " ; // the last space is important + const QString _macBluetoothLabel = "BD Address: "; // the last space is important + QString _macEthernet = "" ; + QString _macWireless = "" ; + QString _macBluetooth = "" ; + const int _yearMinimum = 2022 ; // The year to check for minimum // tests // Severity @@ -101,20 +113,24 @@ bool checkYear (); public: - bool isShaSum () { return _isShaSum ; } - bool isCANBus () { return _isCANBus ; } - bool isDisplay () { return _isDisplay ; } - bool isTouch () { return _isTouch ; } - bool isSDCard () { return _isSDCard ; } - bool isRtc () { return _isRtc ; } - bool isWiFi () { return _isWiFi ; } - bool isBluetooth () { return _isBluetooth ; } - bool isCloudSync () { return _isCloudSync ; } - bool isEthernet () { return _isEthernet ; } - bool isSound () { return _isSound ; } - bool isYearCheck () { return _isYearCheck ; } - bool isDone () { return _isDone ; } + bool isShaSum () const { return _isShaSum ; } + bool isCANBus () const { return _isCANBus ; } + bool isDisplay () const { return _isDisplay ; } + bool isTouch () const { return _isTouch ; } + bool isSDCard () const { return _isSDCard ; } + bool isRtc () const { return _isRtc ; } + bool isWiFi () const { return _isWiFi ; } + bool isBluetooth () const { return _isBluetooth ; } + bool isCloudSync () const { return _isCloudSync ; } + bool isEthernet () const { return _isEthernet ; } + bool isSound () const { return _isSound ; } + bool isYearCheck () const { return _isYearCheck ; } + bool isDone () const { return _isDone ; } + QString macEthernet () const { return _macEthernet ; } + QString macWireless () const { return _macWireless ; } + QString macBluetooth () const { return _macBluetooth ; } + public: explicit ApplicationPost(QObject *parent = nullptr); void start(); Index: sources/device/DeviceController.cpp =================================================================== diff -u -r0e122c98700951af539d9f47c5578e26d640fcc7 -rc73feffa73c7fe073a7a7581144f5806dfc91beb --- sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) +++ sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) @@ -106,6 +106,9 @@ connect(&_fileSystemWatcher , SIGNAL( fileChanged(const QString &)), this , SLOT( onWatchFileChanged(const QString &))); + connect(&_ApplicationController , SIGNAL(didPOSTInformationReady(const QString &, const QString &, const QString &)), + this , SLOT( onPOSTInformationReady(const QString &, const QString &, const QString &))); + DEVICE_DEV_INIT_CONNECTIONS_LIST } @@ -714,3 +717,10 @@ { emit didWatchFileChange(vFile); } + +void DeviceController::onPOSTInformationReady(const QString &vMacEthernet, const QString &vMacWireless, const QString &vMacBluetooth) +{ + _macEthernet = vMacEthernet .trimmed(); + _macWireless = vMacWireless .trimmed(); + _macBluetooth = vMacBluetooth .trimmed(); +} Index: sources/device/DeviceController.h =================================================================== diff -u -r0e122c98700951af539d9f47c5578e26d640fcc7 -rc73feffa73c7fe073a7a7581144f5806dfc91beb --- sources/device/DeviceController.h (.../DeviceController.h) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) +++ sources/device/DeviceController.h (.../DeviceController.h) (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) @@ -110,6 +110,10 @@ QFileSystemWatcher _fileSystemWatcher; + QString _macEthernet = ""; + QString _macWireless = ""; + QString _macBluetooth = ""; + //TODO: all of these should use the TimesProcess (instead of QProcess) // to be able to kill the process automatically after the set time out. DEVICE_DEV_DEFINITION_LIST @@ -124,6 +128,11 @@ private slots: void onScreenshot(const QImage &vImage, const QString &vFileName); + void onUSBDriveUmount(); + void onWatchFileChanged(const QString &vFile); + + void onPOSTInformationReady(const QString &vMacEthernet, const QString &vMacWireless, const QString &vMacBluetooth); + protected: void timerEvent(QTimerEvent *) override; @@ -206,7 +215,16 @@ void didWatchFileChange(const QString &vFile); -private slots: + /*! + * \brief didPOSTReady + * \details This signal will be emitted when UI is done with the POST and will let DeviceView update its property(ies). + * \param vMacEthernet - Ethernet Mac Adress + * \param vMacWireless - Wireless Mac Adress + * \param vMacBluetooth - Bluetooth Mac Adress + */ + void didPOSTInformationReady(const QString &vMacEthernet, const QString &vMacWireless, const QString &vMacBluetooth); + +private: // ----- USB void usbCheck(); @@ -215,16 +233,9 @@ void usbRemove(); void usbError (const QString &vDevice); - void onUSBDriveUmount(); - - void onWatchFileChanged(const QString &vFile); - - // ----- SDCard void sdcardSpaceCheck(); + void usbSpaceCheck(); - // ----- USBDrive - void usbSpaceCheck(); - SAFE_CALL_EX(doAddWatch, const QString &) }; } Index: sources/device/DeviceView.cpp =================================================================== diff -u -r0e122c98700951af539d9f47c5578e26d640fcc7 -rc73feffa73c7fe073a7a7581144f5806dfc91beb --- sources/device/DeviceView.cpp (.../DeviceView.cpp) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) +++ sources/device/DeviceView.cpp (.../DeviceView.cpp) (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) @@ -70,10 +70,6 @@ // DEBUG : qDebug() << "HERE Request" << vValue; DeviceCryptSetupRequestData data; data.mCommand = vCommand; - //FIXME:Change this to get it from the encryptString - // Currently located in the QString VSettings::encryptString(const QString &vString) - // Which has to be moved to a better global class. - data.mPassword = "_0.aBc.0_"; emit didAttributeRequest(data); } Index: sources/gui/GuiController.cpp =================================================================== diff -u -r90d21320e3fafd64ee2e9241ce4065aca86625ff -rc73feffa73c7fe073a7a7581144f5806dfc91beb --- sources/gui/GuiController.cpp (.../GuiController.cpp) (revision 90d21320e3fafd64ee2e9241ce4065aca86625ff) +++ sources/gui/GuiController.cpp (.../GuiController.cpp) (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) @@ -101,6 +101,10 @@ connect(&_ApplicationController, SIGNAL(didFailedTransmit(Sequence)), this , SLOT( onFailedTransmit(Sequence))); + // POST result + connect(&_ApplicationController, SIGNAL(didPOSTPass(bool)), + this , SLOT( onPOSTPass(bool))); + // Device Signal/Slots DEVICE_GUI_INIT_CONNECTIONS_LIST @@ -367,3 +371,13 @@ AlarmStatusData data = AlarmGenerator::ALARM_ID_HD_COMM_TIMEOUT(); emit didActionReceive(data); } + +/*! + * \brief GuiController::onPOSTPass + * \details Passes on the Post status + * \param vPass - True if passed + */ +void GuiController::onPOSTPass(bool vPass) +{ + emit didPOSTPass(vPass); +} Index: sources/gui/GuiController.h =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -rc73feffa73c7fe073a7a7581144f5806dfc91beb --- sources/gui/GuiController.h (.../GuiController.h) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ sources/gui/GuiController.h (.../GuiController.h) (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) @@ -90,6 +90,8 @@ void onExportStat (quint32 vIndex, const QString &vFileName, quint8 vPercent); void onFailedTransmit(Sequence seq); + void onPOSTPass (bool vPass); + signals: void didActionReceive (GuiActionType vAction, const QVariantList &vData); // UI <= HD/DG void didActionTransmit(GuiActionType vAction, const QVariantList &vData); // UI => HD/DG @@ -109,6 +111,8 @@ void didExport (); void didExportStat (quint32 vIndex, const QString &vFileName, quint8 vPercent); + void didPOSTPass (bool vPass); + // Device controller signal slots connection DEVICE_GUI_BRIDGE_DEFINITION_LIST Index: sources/gui/GuiView.cpp =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -rc73feffa73c7fe073a7a7581144f5806dfc91beb --- sources/gui/GuiView.cpp (.../GuiView.cpp) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ sources/gui/GuiView.cpp (.../GuiView.cpp) (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) @@ -77,6 +77,9 @@ &_GuiController, SLOT( doExportService (const GuiStringIndexMap &))); connect(this , SIGNAL(didExportTreatment (const GuiStringIndexMap &)), &_GuiController, SLOT( doExportTreatment (const GuiStringIndexMap &))); + + connect(&_GuiController, SIGNAL(didPOSTPass (bool)), + this , SLOT( onPOSTPass (bool))); } /*! @@ -280,7 +283,7 @@ */ bool GuiView::doExportListSelect(quint32 vIndex) { - bool contains = _exportList.contains(vIndex);; + bool contains = _exportList.contains(vIndex); return contains; } @@ -374,3 +377,9 @@ // TODO : the space check should also be done for the USB as destination but needs calculation and will be done later. // usbIsLow ( vPercent <= Storage::Available_Space_Percent ); } + +void GuiView::onPOSTPass(bool vPass) +{ + manufactMode( gEnableManufacturing && vPass ); + postPass(vPass); +} Index: sources/gui/GuiView.h =================================================================== diff -u -r9c7a790376d07de7ddaa67e39d47102d68693c87 -rc73feffa73c7fe073a7a7581144f5806dfc91beb --- sources/gui/GuiView.h (.../GuiView.h) (revision 9c7a790376d07de7ddaa67e39d47102d68693c87) +++ sources/gui/GuiView.h (.../GuiView.h) (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) @@ -80,7 +80,11 @@ READONLY(bool , dryDemoMode , gEnableDryDemo ) READONLY(bool , manufactSetup , gEnableManufacturing ) + READONLY(bool , manufactMode , false ) + TRIGGER (bool , postPass , false ) + + public: explicit GuiView(QObject *parent = nullptr); @@ -101,6 +105,7 @@ void onSDCardSpaceTooLow(quint8 vAvailablePercent); void onSDCardSpaceChange(bool vReady, qint64 vTotal, qint64 vAvailable, quint8 vPercent); + void onPOSTPass (bool vPass); public slots: // is public since will be used in the UI and is in the same thread. void doActionTransmit(GuiActionType vAction, const QVariantList &vData); // UI => HD/DG Index: sources/gui/qml/pages/UserConfirmation.qml =================================================================== diff -u -rbba70435ebe0bbbc9bf5b4282f7d0906a8b49b1a -rc73feffa73c7fe073a7a7581144f5806dfc91beb --- sources/gui/qml/pages/UserConfirmation.qml (.../UserConfirmation.qml) (revision bba70435ebe0bbbc9bf5b4282f7d0906a8b49b1a) +++ sources/gui/qml/pages/UserConfirmation.qml (.../UserConfirmation.qml) (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) @@ -58,7 +58,7 @@ PasswordEntry { id: _passwordCurrent label.text : ! passwordChangeMode ? "" : qsTr("Current") - label.width : ! passwordChangeMode ? 0 : label.width + label.width : ! passwordChangeMode ? 0 : labelWidth nextInput : _passwordUpdated anchors { top : parent.top @@ -87,12 +87,13 @@ } } component PasswordEntry : Item { - property alias textInput: _passwordEntry.textInput - property alias nextInput: _passwordEntry.nextInput - property alias label : _passwordEntry.label + property alias textInput : _passwordEntry.textInput + property alias nextInput : _passwordEntry.nextInput + property alias label : _passwordEntry.label + property int labelWidth : 150 height : 70 - label.width : 150 + label.width : labelWidth TextEntry { id: _passwordEntry clip : true Index: sources/gui/qml/pages/settings/SettingsServicePassword.qml =================================================================== diff -u -rdc7757a4c3c6e2c9dab1e84a5a1fb04d95d74c9f -rc73feffa73c7fe073a7a7581144f5806dfc91beb --- sources/gui/qml/pages/settings/SettingsServicePassword.qml (.../SettingsServicePassword.qml) (revision dc7757a4c3c6e2c9dab1e84a5a1fb04d95d74c9f) +++ sources/gui/qml/pages/settings/SettingsServicePassword.qml (.../SettingsServicePassword.qml) (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) @@ -27,13 +27,13 @@ UserConfirmation{ id: _root itemIndex : SettingsStack.ServicePassword - property bool isPassword_Accepted : false - property bool isDefaultPasswordSet : vSettings.isPasswordSet + property bool isPassword_Accepted : false + readonly property bool isDefaultServicePassword : vSettings.isDefaultServicePassword - backVisible : ! _GuiView.manufactSetup - title : isDefaultPasswordSet ? qsTr("Service Password") : qsTr("Set Service Password") isPassword : true - passwordChangeMode : ! isDefaultPasswordSet && _GuiView.manufactSetup + backVisible : ! _GuiView.manufactSetup + passwordChangeMode : isDefaultServicePassword && _GuiView.manufactSetup + title : passwordChangeMode ? qsTr("Set Service Password") : qsTr("Service Password") onBackClicked : { clearPasswords() @@ -48,7 +48,7 @@ if ( ! isPassword_Accepted ) return // of accepted save the password - if ( passwordChangeMode ) vSettings.updatePassword(passwordUpdated) + if ( passwordChangeMode ) vSettings.updateServicePassword(passwordUpdated) // ask HD to go to service mode vAdjustmentServiceMode.doAdjustment() @@ -65,13 +65,13 @@ } function checkPassword() { - if ( ! vSettings.isPasswordMatch(passwordCurrent ) ) { _root.notificationText = qsTr("Incorrect password" ); return false } + if ( ! vSettings.isServicePasswordMatch( passwordCurrent ) ) { _root.notificationText = qsTr("Incorrect password" ); return false } - if ( ! passwordChangeMode ) { _root.notificationText = "" ; return true } + if ( ! passwordChangeMode ) { _root.notificationText = "" ; return true } - if ( passwordConfirm != passwordUpdated ) { _root.notificationText = qsTr("Mismatch Passwords" ); return false } - if ( ! vSettings.isPasswordValid(passwordUpdated ) ) { _root.notificationText = qsTr("Invalid Password" ); return false } + if ( passwordConfirm != passwordUpdated ) { _root.notificationText = qsTr("Mismatch Passwords" ); return false } + if ( ! vSettings.isPasswordValid(passwordUpdated ) ) { _root.notificationText = qsTr("Invalid Password" ); return false } - _root.notificationText = "" ; return true + _root.notificationText = "" ; return true } } Index: sources/gui/qml/pages/settings/SettingsStack.qml =================================================================== diff -u -r0e122c98700951af539d9f47c5578e26d640fcc7 -rc73feffa73c7fe073a7a7581144f5806dfc91beb --- sources/gui/qml/pages/settings/SettingsStack.qml (.../SettingsStack.qml) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) +++ sources/gui/qml/pages/settings/SettingsStack.qml (.../SettingsStack.qml) (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) @@ -35,7 +35,7 @@ StackItem { id : _root objectName: "_SettingsStack" - stackView.initialItem : _GuiView.manufactSetup ? _servicePassword : _settingsHome + stackView.initialItem : null property bool serviceMode : false @@ -68,44 +68,44 @@ qsTr("Water Input Mode" ), // RoInput qsTr("Set Language" ), // Language qsTr("Calibration " ), // Calibration - qsTr("Device Configuration" ), // Manufacturing Setup + qsTr("Device Configuration" ), // Device Configuration qsTr("Device Registration" ), // DeviceRegistration qsTr("Software Update" ), // SWUpdate qsTr("Factory Reset" ), // FactoryReset ] property var itemsEnabled : [ - true , // Information - true , // VolumeBrightness - true , // WiFi - true , // Bluetooth - true , // DGSettings - true , // ServicePassword - true , // SetDateTime - true , // ExportLogs - true , // RoInput - false , // Language - false , // Calibration - _GuiView.manufactSetup , // Manufacturing Setup - true , // DeviceRegistration - false , // SWUpdate - serviceMode , // FactoryReset + true , // Information + true , // VolumeBrightness + true , // WiFi + true , // Bluetooth + true , // DGSettings + true , // ServicePassword + true , // SetDateTime + true , // ExportLogs + true , // RoInput + false , // Language + false , // Calibration + _GuiView.manufactMode , // Device Configuration + true , // DeviceRegistration + false , // SWUpdate + serviceMode , // FactoryReset ] property var itemsVisible : [ - true , // Information - true , // VolumeBrightness - true , // WiFi - true , // Bluetooth - ! _GuiView.manufactSetup , // DGSettings - ! serviceMode , // ServicePassword - serviceMode , // SetDateTime - ! _GuiView.manufactSetup , // ExportLogs - ! _GuiView.manufactSetup , // RoInput - false /* serviceMode phase 1 */ , // Language - false /* serviceMode phase 1 */ , // Calibration - _GuiView.manufactSetup && serviceMode, // Manufacturing Setup // && serviceMode added to make sure the service mode is confirmed by HD - _GuiView.manufactSetup && serviceMode, // DeviceRegistration // && serviceMode added to make sure the service mode is confirmed by HD - false /* serviceMode phase 1 */ , // SWUpdate - serviceMode , // FactoryReset + true , // Information + true , // VolumeBrightness + true , // WiFi + true , // Bluetooth + ! _GuiView.manufactSetup , // DGSettings + ! serviceMode && ! _GuiView.manufactSetup , // ServicePassword + serviceMode , // SetDateTime + true , // ExportLogs + ! _GuiView.manufactSetup , // RoInput + false /* serviceMode phase 1 */ , // Language + false /* serviceMode phase 1 */ , // Calibration + _GuiView.manufactMode && serviceMode , // Device Configuration // && serviceMode added to make sure the service mode is confirmed by HD + _GuiView.manufactMode && serviceMode , // DeviceRegistration // && serviceMode added to make sure the service mode is confirmed by HD + false /* serviceMode phase 1 */ , // SWUpdate + serviceMode , // FactoryReset ] SettingsHome { id : _settingsHome @@ -214,6 +214,24 @@ function onStandbyWaitDisinfectChanged ( vValue ) { page( _settingsHome , vValue )} } + Connections { target: _GuiView + function onManufactModeChanged( vPass ) { + if ( _GuiView.manufactMode ) { + vSettings.checkServicePasswordSet() + stackView.initialItem = _servicePassword + } + else { + stackView.initialItem = _settingsHome + } + push(stackView.initialItem) + + //DEBUG console.log (" ----------",_GuiView.manufactMode, _GuiView.manufactSetup, vPass, stackView.initialItem, stackView.currentItem, stackView.depth) + if ( _GuiView.manufactSetup ) { + _settingsHome.notificationText = vPass ? "" : qsTr("Application POST Failed") + } + } + } + onVisibleChanged: { if (visible) { _mainMenu.hidden = serviceMode || _GuiView.manufactSetup Index: sources/utility/encryption.cpp =================================================================== diff -u --- sources/utility/encryption.cpp (revision 0) +++ sources/utility/encryption.cpp (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) @@ -0,0 +1,130 @@ +#include "encryption.h" + +// Linux + +// Qt +#include +#include + +// Project +#include "DeviceController.h" + +QString encryption::__salt__ = ""; + +// Additional + +int encryption::cryptOpen(const QString vDevice, const QString vFolder) +{ + qDebug() << vDevice << vFolder; + return 0; +} + +int encryption::cryptFormat(const QString vDevice) +{ + qDebug() << vDevice; + return 0; +} + +int encryption::cryptClose(const QString vFolder) +{ + qDebug() << vFolder; + return 0; +} + +int encryption::mkfsExt4(const QString vDevice) +{ + qDebug() << vDevice; + return 0; +} + +void encryption::varSalt(const QString &vSalt) { + __salt__ = vSalt; +} + +QString encryption::fixSalt() { + /// 83 hr 0 u 2 N 3 m ^+ i P 0 ur + /// 83hr0u2N3m^+iP0ur + QString s = "83hr0u2N3m^+iP0ur"; + return s; +} + +/*! + * \brief encryption::hashedString + * \details encrypts the string vString with an algorithm + * \param vString - the string to be encrypted. + * \param vSalt - the encryption salt. + * \return encrypted string + */ +QString encryption::hashedString(const QString &vString, bool &ok, bool vAddMoreSalt) { + int iter = 1000; + int len = 16; + + ok = vAddMoreSalt ? ! __salt__.isEmpty() : true; + auto shuffle = [](const QString &vString) -> QByteArray { + auto reverse = [](const QString &vString) -> QString { + if ( vString.trimmed().isEmpty() ) return QString(); + + QString mReverse; + int end = vString.size() - 1; + int mid = end / 2; + + for(int i = mid; i >= 0; i-- ) { + mReverse += vString.at(i); + } + + for(int i = end; i > mid; i-- ) { + mReverse += vString.at(i); + } + return mReverse; + }; + + if ( vString.trimmed().isEmpty() ) return QByteArray(); + //DEBUG: qDebug()<<"string" << vString; + QString reversed = reverse(vString); + //DEBUG: qDebug()<<"reversed" << reversed; + QByteArray hexed = reversed.toUtf8().toHex(); + //DEBUG: qDebug()<<"hexed" << hexed; + return hexed; + }; + + QCryptographicHash::Algorithm algorithm = QCryptographicHash::Sha512; + QString salt = fixSalt() + (vAddMoreSalt ? __salt__ : ""); + //DEBUG: qDebug() << "salt:" << salt; + QByteArray hashed = QPasswordDigestor::deriveKeyPbkdf2(algorithm, vString.toUtf8(), shuffle( salt ), iter, len).toHex(); + //DEBUG: qDebug() << "hashed:" << vString << hashed; + return hashed; + + //TODO: This seemed too much and I removed it for now. + // QString shuffled = shuffle(hashed); + // qDebug() << "shuffled:" << shuffled; + // return shuffled; +} + +/*! + * \brief encryption::isDefaultServicePassword + * \details Checks if the current service password is the default password + * \note It is being used to force the user/manufacturer to set the service password. + * \param vPassword - the service pasword entered by user. + * \return true if the service password is the default. + */ +bool encryption::isDefaultServicePassword(const QString &vPassword, bool &ok) +{ + //DEBUG qDebug() << __FUNCTION__ << vPassword; + return vPassword == defaultServicePassword(ok); +} + +/*! + * \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. + */ +QString encryption::defaultServicePassword(bool &ok) +{ + QString _A1 = "tal"; + QString _S1 = QString("%1").arg(_A1 ).prepend("A" ); + QString _S2 = QString("%1").arg(_A1 ).prepend("Ma" ); + QString _S3 = QString("%1").arg(10*2+2 ).append ("leh" ); + QString hashed = hashedString(( QStringList() << _S1 << _S2 << _S3 ).join('.'), ok, false); + //DEBUG qDebug() << __FUNCTION__ << hashed; + return hashed; +} Index: sources/utility/encryption.h =================================================================== diff -u --- sources/utility/encryption.h (revision 0) +++ sources/utility/encryption.h (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) @@ -0,0 +1,43 @@ +/*! + * + * Copyright (c) 2019-2023 Diality Inc. - All Rights Reserved. + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file encryption.h + * \author (last) Behrouz NematiPour + * \date (last) 15-May-2023 + * \author (original) Behrouz NematiPour + * \date (original) 15-May-2023 + * + */ + +#pragma once + +// Qt +#include + +class encryption +{ + static QString __salt__; + +public: + encryption() = delete; + ~encryption() = delete; + + // cryptsetup - placeholder + static int cryptOpen (const QString vDevice, const QString vFolder); + static int cryptFormat (const QString vDevice ); + static int cryptClose ( const QString vFolder); + static int mkfsExt4 (const QString vDevice ); + + // service password + static void varSalt (const QString &vSalt ); + static QString fixSalt ( ); + static QString hashedString (const QString &vString , bool &ok, bool vAddMoreSalt = true); + + static bool isDefaultServicePassword (const QString &vPassword, bool &ok); + static QString defaultServicePassword ( bool &ok); +}; + Index: sources/view/settings/VAdjustmentVersions.cpp =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -rc73feffa73c7fe073a7a7581144f5806dfc91beb --- sources/view/settings/VAdjustmentVersions.cpp (.../VAdjustmentVersions.cpp) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ sources/view/settings/VAdjustmentVersions.cpp (.../VAdjustmentVersions.cpp) (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) @@ -16,6 +16,7 @@ // Project #include "GuiController.h" +#include "encryption.h" VIEW_DEF_CLASS_ADJUSTMENT(VAdjustmentVersions) @@ -102,6 +103,7 @@ void VAdjustmentVersions::onActionReceive(const AdjustSerialNumberHDResponseData &vData) { + encryption::varSalt(vData.mSerialNumber); hdSerial( vData.mSerialNumber ); } Index: sources/view/settings/VSettings.cpp =================================================================== diff -u -r7ec98d237f871e5d1206809d309da6d57a086d28 -rc73feffa73c7fe073a7a7581144f5806dfc91beb --- sources/view/settings/VSettings.cpp (.../VSettings.cpp) (revision 7ec98d237f871e5d1206809d309da6d57a086d28) +++ sources/view/settings/VSettings.cpp (.../VSettings.cpp) (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) @@ -22,6 +22,7 @@ #include "GuiController.h" #include "MSettings.h" #include "Settings.h" +#include VIEW_DEF_CLASS(VSettings) @@ -126,8 +127,6 @@ roWaterMode ( _roWaterMode ); // noCANBus ( _noCANBus ); // This line has been put here to remind developers that it is intentionally removed, to not to add a default value. - isPasswordSet ( ! isPasswordDefault() ); - adjustment(true); } @@ -268,70 +267,41 @@ return ok; } -#include - -/*! - * \brief VSettings::encryptString - * \details encrypts the string vString with an algorithm - * \param vString - the string to be encrypted. - * \return encrypted string - */ -QString VSettings::encryptString(const QString &vString) { - // FIXME: Move this to the utility, storage or settings controller class for more general use. - QString salt = "DVT-HD0004"; // FIXME: Use the actual HD serial number - int iter = 1000; - int len = 16; - auto shuffle = [](const QString &vString) { - // FIXME: Implement this, and make this a function and move this to the utility or storage class for more general use. - QString shuffled = vString; - return shuffled.toUtf8().toHex(); - }; - QCryptographicHash::Algorithm algorithm = QCryptographicHash::Sha512; - QByteArray hashed = QPasswordDigestor::deriveKeyPbkdf2(algorithm, vString.toUtf8(), shuffle(salt), iter, len); - return hashed.toHex(); +QString View::VSettings::hashedPassword(const QString &vPassword, bool vIsService) +{ + bool ok; + QString hashed = encryption::hashedString(vPassword, ok, ! vIsService); + encryptionPass(ok); + return ok ? hashed : ""; } /*! - * \brief View::VSettings::isPasswordMatch + * \brief View::VSettings::isServicePasswordMatch * \details matches the given password string, vPassword, with the service password. * \param vPassword - the given password string * \return true if it matches. */ -bool View::VSettings::isPasswordMatch(const QString &vPassword) { - return _servicePass == encryptString(vPassword); +bool View::VSettings::isServicePasswordMatch(const QString &vPassword) { + + qDebug() << __FUNCTION__ << hashedPassword(vPassword, true); + return _servicePass == hashedPassword(vPassword, true); } /*! - * \brief View::VSettings::updatePassword + * \brief View::VSettings::updateServicePassword * \details Updatest the service password with the given password. * \param vPassword - the password to be saved as the service password. */ -void View::VSettings::updatePassword(const QString &vPassword) +void View::VSettings::updateServicePassword(const QString &vPassword) { - servicePass(encryptString(vPassword)); + servicePass(hashedPassword(vPassword, true)); } -/*! - * \brief View::VSettings::isPasswordDefault - * \details Checks if the current service password is the default password - * \note It is being used to force the user/manufacturer to set the service password. - * \return true if the service password is the default. - */ -bool View::VSettings::isPasswordDefault() +void View::VSettings::checkServicePasswordSet() { - return servicePass() == defaultPassword(); + bool ok; + isDefaultServicePassword(encryption::isDefaultServicePassword(servicePass(), ok)); + qDebug() << __FUNCTION__ << ok; + encryptionPass(ok); } -/*! - * \brief View::VSettings::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. - */ -QString View::VSettings::defaultPassword() -{ - QString _A1 = "tal"; - QString _S1 = QString("%1").arg(_A1 ).prepend("A" ); - QString _S2 = QString("%1").arg(_A1 ).prepend("Ma" ); - QString _S3 = QString("%1").arg(10*2+2 ).append ("leh" ); - return encryptString(( QStringList() << _S1 << _S2 << _S3 ).join('.')); -} Index: sources/view/settings/VSettings.h =================================================================== diff -u -r7ec98d237f871e5d1206809d309da6d57a086d28 -rc73feffa73c7fe073a7a7581144f5806dfc91beb --- sources/view/settings/VSettings.h (.../VSettings.h) (revision 7ec98d237f871e5d1206809d309da6d57a086d28) +++ sources/view/settings/VSettings.h (.../VSettings.h) (revision c73feffa73c7fe073a7a7581144f5806dfc91beb) @@ -63,29 +63,33 @@ PROPERTY(QStringList , categorys , {} ) PROPERTY(QVariantMap , instructions , {} ) - PROPERTY(bool , isPasswordSet , false ) + PROPERTY(bool , isDefaultServicePassword , false ) SETTINGS(QString , servicePass , "" , Storage::Settings_Category_SettingsSystem , "Service" , "Password" ) SETTINGS(quint8 , alarmVolume , 5 , Storage::Settings_Category_SettingsSystem , "Alarm" , "Volume" ) SETTINGS(bool , roWaterMode , false , Storage::Settings_Category_SettingsSystem , "RoWaterMode" , "RoWaterMode" ) SETTINGS(bool , noCANBus , false , Storage::Settings_Category_NoCANBus , "Navigation" , "Create Treatment To Patient ID" ) + TRIGGER (bool , encryptionPass, false ) + VIEW_DEC(VSettings, SettingsData) private: TKeysList updateReplacements ( const QString &vGroup, const QStringList &vKeys ); void updateInstructions ( const QString &vGroup, const TKeysList &vKeysList, const QVariantList &vValues ); void updateInstructions ( const QString &vGroup ); - QString encryptString (const QString &vString ); QString defaultPassword (); bool isPasswordDefault (); + QString hashedPassword (const QString &vPassword, bool vIsService); public slots: - bool isPasswordValid (const QString &vPassword); - bool isPasswordMatch (const QString &vPassword); - void updatePassword (const QString &vPassword); + bool isPasswordValid (const QString &vPassword); + bool isServicePasswordMatch (const QString &vPassword); + void updateServicePassword (const QString &vPassword); + void checkServicePasswordSet (); + private slots: void onActionReceive (GuiActionType vAction, const QVariantList &vData);