Index: sources/device/DeviceController.cpp =================================================================== diff -u -re7adb742d7dd362b2deb795259694b223eea3bc0 -r86df7ff03ea32f9cd8a18bbbc7b2e01de64c783f --- sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision e7adb742d7dd362b2deb795259694b223eea3bc0) +++ sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision 86df7ff03ea32f9cd8a18bbbc7b2e01de64c783f) @@ -1018,7 +1018,6 @@ // ----- run the process int timeout_ms = 10000; TimedProcess *timedProcess = new TimedProcess(&_processWifiList, script, timeout_ms, {}); - //DEBUG qDebug() << script << timeout_ms; timedProcess->start(); MDeviceWifiListResponse model; @@ -1251,3 +1250,125 @@ model._data.clear(); } } + +////////////////////////////////////////////////////////////////////////////////////////////////// DeviceDecommission +void DeviceController::onAttributeRequest(const DeviceDecommissionRequestData &vData) +{ + decommissionRequest(vData); +} + +/*! + * \brief DeviceController::decommissionRequest + * \details Calls the decommission script + * \note This function is created to be able to call independently if needed in this class. + */ +void DeviceController::decommissionRequest(const DeviceDecommissionRequestData &vData) +{ + // ----- check that script exists. + QString script; + if ( checkError( DeviceError::checkScript(script, Scripts_Device_Decommission), _deviceDecommissionResponse, script) ) + return; + + // ----- check if the process is not running + if ( _processDecommission.state() != QProcess::NotRunning ) { + checkError(DeviceError::eDevice_Scripts_Error_IsRunning, _deviceDecommissionResponse); + return; + } + + QStringList params; + params << vData.mPassword; + + // ----- run the process + int timeout_ms = 10000; + TimedProcess *timedProcess = new TimedProcess(&_processDecommission, script, timeout_ms, params); + timedProcess->start(); + + MDeviceDecommissionResponse model; + model._data.mCompleted = false; + model._data.mAccepted = false; + model._data.mMessage = tr("Decommission started."); + emit didAttributeResponse(model.data()); +} + +/*! + * \brief DeviceController::processDecommissionResponse + * \param vExitCode + * \param vStatus + */ +void DeviceController::processDecommissionResponse(int vExitCode, QProcess::ExitStatus vStatus, QProcess::ProcessChannel vChannel) +{ + static MDeviceDecommissionResponse model; + if ( vExitCode < 0 ) { + emit didAttributeResponse(model.data()); + switch (vChannel) { + case QProcess::StandardOutput : processDecommissionReadyOut(model); break; + case QProcess::StandardError : processDecommissionReadyErr(model); break; + } + } + else { + processDecommissionComplete(model, vExitCode, vStatus); + emit didAttributeResponse(model.data()); + model._data.clear(); + } +} + +////////////////////////////////////////////////////////////////////////////////////////////////// DeviceRootSSHAccess +void DeviceController::onAttributeRequest(const DeviceRootSSHAccessRequestData &vData) +{ + rootSSHAccessRequest(vData); +} + +/*! + * \brief DeviceController::rootSSHAccessRequest + * \details Calls the RootSSHAccess script + * \note This function is created to be able to call independently if needed in this class. + */ +void DeviceController::rootSSHAccessRequest(const DeviceRootSSHAccessRequestData &vData) +{ + // ----- check that script exists. + QString script; + if ( checkError( DeviceError::checkScript(script, Scripts_Ssh_Access), _deviceRootSSHAccessResponse, script) ) + return; + + // ----- check if the process is not running + if ( _processRootSSHAccess.state() != QProcess::NotRunning ) { + checkError(DeviceError::eDevice_Scripts_Error_IsRunning, _deviceRootSSHAccessResponse); + return; + } + + QStringList params; + params << QString::number(static_cast(vData.mRootSSHAccess)); + + // ----- run the process + int timeout_ms = 10000; + TimedProcess *timedProcess = new TimedProcess(&_processRootSSHAccess, script, timeout_ms, params); + timedProcess->start(); + + MDeviceRootSSHAccessResponse model; + model._data.mCompleted = false; + model._data.mAccepted = false; + model._data.mMessage = tr("RootSSHAccess started."); + emit didAttributeResponse(model.data()); +} + +/*! + * \brief DeviceController::processRootSSHAccessResponse + * \param vExitCode + * \param vStatus + */ +void DeviceController::processRootSSHAccessResponse(int vExitCode, QProcess::ExitStatus vStatus, QProcess::ProcessChannel vChannel) +{ + static MDeviceRootSSHAccessResponse model; + if ( vExitCode < 0 ) { + emit didAttributeResponse(model.data()); + switch (vChannel) { + case QProcess::StandardOutput : processRootSSHAccessReadyOut(model); break; + case QProcess::StandardError : processRootSSHAccessReadyErr(model); break; + } + } + else { + processRootSSHAccessComplete(model, vExitCode, vStatus); + emit didAttributeResponse(model.data()); + model._data.clear(); + } +} Index: sources/device/DeviceController.h =================================================================== diff -u -re7adb742d7dd362b2deb795259694b223eea3bc0 -r86df7ff03ea32f9cd8a18bbbc7b2e01de64c783f --- sources/device/DeviceController.h (.../DeviceController.h) (revision e7adb742d7dd362b2deb795259694b223eea3bc0) +++ sources/device/DeviceController.h (.../DeviceController.h) (revision 86df7ff03ea32f9cd8a18bbbc7b2e01de64c783f) @@ -373,7 +373,6 @@ void didSettingsPartitionStateChange(bool vIsReady, bool vIsReadOnly); void didActionReceive( const DeviceBrightnessResponseData &vBrightness ); - void didActionReceive( const DeviceRootSSHAccessResponseData &vRootSSHAccess); void didWatchFileChange(const QString &vFile); @@ -465,6 +464,12 @@ // ----- Factory Reset void factoryResetRequest(); + // ----- Decommission + void decommissionRequest(const DeviceDecommissionRequestData &vData); + + // ----- RootSSHAccess + void rootSSHAccessRequest(const DeviceRootSSHAccessRequestData &vData); + SAFE_CALL_EX2(doAddWatch, const QString &, bool) }; } Index: sources/device/DeviceError.cpp =================================================================== diff -u -rb8d06ba1f3e380f321ad075815ec254f379e15e2 -r86df7ff03ea32f9cd8a18bbbc7b2e01de64c783f --- sources/device/DeviceError.cpp (.../DeviceError.cpp) (revision b8d06ba1f3e380f321ad075815ec254f379e15e2) +++ sources/device/DeviceError.cpp (.../DeviceError.cpp) (revision 86df7ff03ea32f9cd8a18bbbc7b2e01de64c783f) @@ -53,6 +53,7 @@ QT_TR_NOOP("The Encrypted Partition error." ), // eDevice_CryptSetup_Error QT_TR_NOOP("The Factory Reset failed." ), // eDevice_FactoryReset_Error QT_TR_NOOP("The Decommissioning failed." ), // eDevice_Decommission_Error + QT_TR_NOOP("The RootSSHAcess failed." ), // eDevice_RootSSHAccess_Error QT_TR_NOOP("The Brightness failed." ), // eDevice_Brightness_Error QT_TR_NOOP("The WiFi scan failed." ), // eDevice_WifiList_Error QT_TR_NOOP("The WiFi info failed." ), // eDevice_WifiInfo_Error Index: sources/device/DeviceError.h =================================================================== diff -u -ra2a273600d25e863214833ead3324a63fb4759f1 -r86df7ff03ea32f9cd8a18bbbc7b2e01de64c783f --- sources/device/DeviceError.h (.../DeviceError.h) (revision a2a273600d25e863214833ead3324a63fb4759f1) +++ sources/device/DeviceError.h (.../DeviceError.h) (revision 86df7ff03ea32f9cd8a18bbbc7b2e01de64c783f) @@ -71,6 +71,7 @@ eDevice_CryptSetup_Error , eDevice_FactoryReset_Error , eDevice_Decommission_Error , + eDevice_RootSSHAccess_Error , eDevice_Brightness_Error , eDevice_WifiList_Error , eDevice_WifiInfo_Error , Index: sources/device/DeviceGlobals.h =================================================================== diff -u -re7adb742d7dd362b2deb795259694b223eea3bc0 -r86df7ff03ea32f9cd8a18bbbc7b2e01de64c783f --- sources/device/DeviceGlobals.h (.../DeviceGlobals.h) (revision e7adb742d7dd362b2deb795259694b223eea3bc0) +++ sources/device/DeviceGlobals.h (.../DeviceGlobals.h) (revision 86df7ff03ea32f9cd8a18bbbc7b2e01de64c783f) @@ -102,7 +102,7 @@ * \param vExitCode - the returned exit code \ * \param vStatus - the status of the process \ */ \ -void process##vATTRIBUTEFLC##Response(int vExitCode, QProcess::ExitStatus vStatus, \ + void process##vATTRIBUTEFLC##Response(int vExitCode, QProcess::ExitStatus vStatus, \ QProcess::ProcessChannel vChannel ); \ void process##vATTRIBUTEFLC##ReadyOut( M##Device##vATTRIBUTEFLC##Response &); \ void process##vATTRIBUTEFLC##ReadyErr( M##Device##vATTRIBUTEFLC##Response &); \ @@ -114,23 +114,23 @@ vModel._data.mCompleted = false; \ vModel._data.mAccepted = false; \ vModel._data.mMessage = _process##vATTRIBUTEFLC.readAllStandardOutput(); \ -} \ + } \ void DeviceController::process##vATTRIBUTEFLC##ReadyErr(M##Device##vATTRIBUTEFLC##Response &vModel) { \ vModel._data.mCompleted = false; \ vModel._data.mAccepted = false; \ vModel._data.mMessage = "Err:" +_process##vATTRIBUTEFLC.readAllStandardError(); \ -} \ + } \ void DeviceController::process##vATTRIBUTEFLC##Complete(M##Device##vATTRIBUTEFLC##Response &vModel, \ int vExitCode, QProcess::ExitStatus vStatus) { \ vModel._data.mCompleted = true; \ vModel._data.mAccepted = false; \ if (vStatus) vExitCode = Device::DeviceError::eDevice_Scripts_Error_Status; /* CrashExit */ \ vModel.fromByteArray( vModel._data.mMessage.toLatin1(), &vExitCode ); \ -} \ + } \ #define DEVICE_DEV_INIT_CONNECTIONS( vATTRIBUTEFLC ) \ -/* App -> Dev //TODO: Add the error LOG connection */ \ + /* App -> Dev //TODO: Add the error LOG connection */ \ connect(&_ApplicationController , SIGNAL(didAttributeRequest(const Device##vATTRIBUTEFLC##RequestData &)), \ this , SLOT( onAttributeRequest(const Device##vATTRIBUTEFLC##RequestData &))); \ connect(&_process##vATTRIBUTEFLC, QOverload::of(&QProcess::finished), \ @@ -152,12 +152,12 @@ private Q_SLOTS : void onAttributeRequest (const Device##vATTRIBUTEFLC##RequestData &vData) { \ /* this is a bridge only if it is required later can be removed and implemented */ \ emit didAttributeRequest(vData); /* Gui -> App */ \ -} \ + } \ Q_SIGNALS : void didAttributeResponse(const Device##vATTRIBUTEFLC##ResponseData &); \ private Q_SLOTS : void onAttributeResponse(const Device##vATTRIBUTEFLC##ResponseData &vData) { \ /* this is a bridge only if it is required later can be removed and implemented */ \ emit didAttributeResponse(vData); /* Gui <- App */ \ -} \ + } \ private : #define DEVICE_APP_INIT_CONNECTIONS( vATTRIBUTEFLC ) \ @@ -170,16 +170,16 @@ /* ---------------------------- GUI */ #define DEVICE_GUI_BRIDGE_DEFINITION( vATTRIBUTEFLC ) \ -Q_SIGNALS : void didAttributeRequest (const Device##vATTRIBUTEFLC##RequestData &); \ + Q_SIGNALS : void didAttributeRequest (const Device##vATTRIBUTEFLC##RequestData &); \ public Q_SLOTS : void doAttributeRequest (const Device##vATTRIBUTEFLC##RequestData &vData) { \ /* this is a bridge only if it is required later can be removed and implemented */ \ emit didAttributeRequest(vData); /* Gui -> App */ \ -} \ + } \ Q_SIGNALS : void didAttributeResponse(const Device##vATTRIBUTEFLC##ResponseData &); \ public Q_SLOTS : void onAttributeResponse(const Device##vATTRIBUTEFLC##ResponseData &vData) { \ /* this is a bridge only if it is required later can be removed and implemented */ \ emit didAttributeResponse(vData); /* Gui <- App */ \ -} \ + } \ private : #define DEVICE_GUI_INIT_CONNECTIONS( vATTRIBUTEFLC ) \ @@ -189,7 +189,7 @@ /* ---------------------------- VIEW */ #define DEVICE_VIEW_INIT_CONNECTIONS( vATTRIBUTEFLC ) \ -/* to convert the value to the model and emit the signal to go to the controller (Qml -> View) */ \ + /* to convert the value to the model and emit the signal to go to the controller (Qml -> View) */ \ connect(this , SIGNAL(didAttributeRequest (const Device##vATTRIBUTEFLC##RequestData &)), \ &_GuiController , SLOT( doAttributeRequest (const Device##vATTRIBUTEFLC##RequestData &))); \ /* View <- Gui */ \ @@ -201,18 +201,19 @@ /* ---------------------------- DEV */ // All the device attributes need to be listed here to be re-parented. #define DEVICE_DEV_PARENT_LIST \ -DEVICE_DEV_PARENT ( Brightness ) \ + DEVICE_DEV_PARENT ( Brightness ) \ DEVICE_DEV_PARENT ( USBMount ) \ DEVICE_DEV_PARENT ( WifiList ) \ DEVICE_DEV_PARENT ( WifiInfo ) \ DEVICE_DEV_PARENT ( WifiConnect ) \ DEVICE_DEV_PARENT ( FactoryReset ) \ + DEVICE_DEV_PARENT ( RootSSHAccess ) \ + DEVICE_DEV_PARENT ( Decommission ) \ /* DEVICE_DEV_PARENT ( BluetoothPairedReset ) \ DEVICE_DEV_PARENT ( BluetoothPairedQuery ) \ DEVICE_DEV_PARENT ( CryptSetup ) \ - DEVICE_DEV_PARENT ( RootSSHAccess ) \ - DEVICE_DEV_PARENT ( Decommission ) \ + */ // All the device attributes need to be listed here to be connected to the signal slots. @@ -223,12 +224,13 @@ DEVICE_DEV_INIT_CONNECTIONS ( WifiInfo ) \ DEVICE_DEV_INIT_CONNECTIONS ( WifiConnect ) \ DEVICE_DEV_INIT_CONNECTIONS ( FactoryReset ) \ + DEVICE_DEV_INIT_CONNECTIONS ( RootSSHAccess ) \ + DEVICE_DEV_INIT_CONNECTIONS ( Decommission ) \ /* DEVICE_DEV_INIT_CONNECTIONS ( BluetoothPairedReset ) \ DEVICE_DEV_INIT_CONNECTIONS ( BluetoothPairedQuery ) \ DEVICE_DEV_INIT_CONNECTIONS ( CryptSetup ) \ - DEVICE_DEV_INIT_CONNECTIONS ( RootSSHAccess ) \ - DEVICE_DEV_INIT_CONNECTIONS ( Decommission ) \ + */ // All the device attributes need to be listed here to be defined with needed signal, slots, values, ... . @@ -239,13 +241,12 @@ DEVICE_DEV_DEFINITION ( WifiInfo ) \ DEVICE_DEV_DEFINITION ( WifiConnect ) \ DEVICE_DEV_DEFINITION ( FactoryReset ) \ - + DEVICE_DEV_DEFINITION ( RootSSHAccess ) \ + DEVICE_DEV_DEFINITION ( Decommission ) \ /* DEVICE_DEV_DEFINITION ( BluetoothPairedReset ) \ DEVICE_DEV_DEFINITION ( BluetoothPairedQuery ) \ DEVICE_DEV_DEFINITION ( CryptSetup ) \ - DEVICE_DEV_DEFINITION ( RootSSHAccess ) \ - DEVICE_DEV_DEFINITION ( Decommission ) \ */ // All the device attributes need to be listed here to be defined with needed signal, slots, values, ... . @@ -256,13 +257,12 @@ DEVICE_DEV_DECLARATION ( WifiInfo ) \ DEVICE_DEV_DECLARATION ( WifiConnect ) \ DEVICE_DEV_DECLARATION ( FactoryReset ) \ - + DEVICE_DEV_DECLARATION ( RootSSHAccess ) \ + DEVICE_DEV_DECLARATION ( Decommission ) \ /* DEVICE_DEV_DECLARATION ( BluetoothPairedReset ) \ DEVICE_DEV_DECLARATION ( BluetoothPairedQuery ) \ DEVICE_DEV_DECLARATION ( CryptSetup ) \ - DEVICE_DEV_DECLARATION ( RootSSHAccess ) \ - DEVICE_DEV_DECLARATION ( Decommission ) \ */ /* ---------------------------- APP */ @@ -274,13 +274,12 @@ DEVICE_APP_INIT_CONNECTIONS ( WifiInfo ) \ DEVICE_APP_INIT_CONNECTIONS ( WifiConnect ) \ DEVICE_APP_INIT_CONNECTIONS ( FactoryReset ) \ - + DEVICE_APP_INIT_CONNECTIONS ( RootSSHAccess ) \ + DEVICE_APP_INIT_CONNECTIONS ( Decommission ) \ /* DEVICE_APP_INIT_CONNECTIONS ( BluetoothPairedReset ) \ DEVICE_APP_INIT_CONNECTIONS ( BluetoothPairedQuery ) \ DEVICE_APP_INIT_CONNECTIONS ( CryptSetup ) \ - DEVICE_APP_INIT_CONNECTIONS ( RootSSHAccess ) \ - DEVICE_APP_INIT_CONNECTIONS ( Decommission ) \ */ #define DEVICE_APP_BRIDGE_DEFINITION_LIST \ @@ -290,13 +289,12 @@ DEVICE_APP_BRIDGE_DEFINITION( WifiInfo ) \ DEVICE_APP_BRIDGE_DEFINITION( WifiConnect ) \ DEVICE_APP_BRIDGE_DEFINITION( FactoryReset ) \ - + DEVICE_APP_BRIDGE_DEFINITION( RootSSHAccess ) \ + DEVICE_APP_BRIDGE_DEFINITION( Decommission ) \ /* DEVICE_APP_BRIDGE_DEFINITION( BluetoothPairedReset ) \ DEVICE_APP_BRIDGE_DEFINITION( BluetoothPairedQuery ) \ DEVICE_APP_BRIDGE_DEFINITION( CryptSetup ) \ - DEVICE_APP_BRIDGE_DEFINITION( RootSSHAccess ) \ - DEVICE_APP_BRIDGE_DEFINITION( Decommission ) \ */ /* ---------------------------- GUI */ @@ -308,13 +306,12 @@ DEVICE_GUI_INIT_CONNECTIONS ( WifiInfo ) \ DEVICE_GUI_INIT_CONNECTIONS ( WifiConnect ) \ DEVICE_GUI_INIT_CONNECTIONS ( FactoryReset ) \ - + DEVICE_GUI_INIT_CONNECTIONS ( RootSSHAccess ) \ + DEVICE_GUI_INIT_CONNECTIONS ( Decommission ) \ /* DEVICE_GUI_INIT_CONNECTIONS ( BluetoothPairedReset ) \ DEVICE_GUI_INIT_CONNECTIONS ( BluetoothPairedQuery ) \ DEVICE_GUI_INIT_CONNECTIONS ( CryptSetup ) \ - DEVICE_GUI_INIT_CONNECTIONS ( RootSSHAccess ) \ - DEVICE_GUI_INIT_CONNECTIONS ( Decommission ) \ */ #define DEVICE_GUI_BRIDGE_DEFINITION_LIST \ @@ -323,13 +320,12 @@ DEVICE_GUI_BRIDGE_DEFINITION( WifiInfo ) \ DEVICE_GUI_BRIDGE_DEFINITION( WifiConnect ) \ DEVICE_GUI_BRIDGE_DEFINITION( FactoryReset ) \ - + DEVICE_GUI_BRIDGE_DEFINITION( RootSSHAccess ) \ + DEVICE_GUI_BRIDGE_DEFINITION( Decommission ) \ /* DEVICE_GUI_BRIDGE_DEFINITION( BluetoothPairedReset ) \ DEVICE_GUI_BRIDGE_DEFINITION( BluetoothPairedQuery ) \ DEVICE_GUI_BRIDGE_DEFINITION( CryptSetup ) \ - DEVICE_GUI_BRIDGE_DEFINITION( RootSSHAccess ) \ - DEVICE_GUI_BRIDGE_DEFINITION( Decommission ) \ */ /* ---------------------------- VIEW */ @@ -341,12 +337,11 @@ DEVICE_VIEW_INIT_CONNECTIONS( WifiInfo ) \ DEVICE_VIEW_INIT_CONNECTIONS( WifiConnect ) \ DEVICE_VIEW_INIT_CONNECTIONS( FactoryReset ) \ - + DEVICE_VIEW_INIT_CONNECTIONS( RootSSHAccess ) \ + DEVICE_VIEW_INIT_CONNECTIONS( Decommission ) \ /* DEVICE_VIEW_INIT_CONNECTIONS( BluetoothPairedReset ) \ DEVICE_VIEW_INIT_CONNECTIONS( BluetoothPairedQuery ) \ DEVICE_VIEW_INIT_CONNECTIONS( CryptSetup ) \ - DEVICE_VIEW_INIT_CONNECTIONS( RootSSHAccess ) \ - DEVICE_VIEW_INIT_CONNECTIONS( Decommission ) \ */ Index: sources/device/DeviceModels.cpp =================================================================== diff -u -ra2a273600d25e863214833ead3324a63fb4759f1 -r86df7ff03ea32f9cd8a18bbbc7b2e01de64c783f --- sources/device/DeviceModels.cpp (.../DeviceModels.cpp) (revision a2a273600d25e863214833ead3324a63fb4759f1) +++ sources/device/DeviceModels.cpp (.../DeviceModels.cpp) (revision 86df7ff03ea32f9cd8a18bbbc7b2e01de64c783f) @@ -193,7 +193,7 @@ _data.mAccepted = false; // check if the vExitCode passed and it has a value other than zero - if ( vExitCode && *vExitCode ){ _data.mReason = Device::DeviceError::eDevice_FactoryReset_Error; error = *vExitCode; } + if ( vExitCode && *vExitCode ){ _data.mReason = Device::DeviceError::eDevice_Decommission_Error; error = *vExitCode; } else _data.mReason = Device::DeviceError::eDevice_OK; // if vExitCode is not zero go to error since the data is no longer valid @@ -211,6 +211,48 @@ } /*! + * \brief MDeviceRootSSHAccessResponse::fromByteArray + * \details Checks the response and sets up the model data. + * \param vExitCode - Passed script exit code + * \return true if passed. + */ +bool MDeviceRootSSHAccessResponse::fromByteArray(const QByteArray &vByteArray, int *vExitCode) +{ + // initialize data + bool ok = false; + int error = 0; + _data.mAccepted = false; + _data.mReason = Device::DeviceError::eDevice_OK; + + // set as default if the val is invalid. + _data.mRootSSHAccess = Qt::Unchecked; + + // get the value + QString val = vByteArray; + ok = ! val.isNull() && val.isSimpleText(); + + // check if the vExitCode passed and it has a value other than zero + if ( ! ok ){ _data.mReason = Device::DeviceError::eDevice_Scripts_Error_Incorrect_Rsp_Type ; goto lError; } // there is not a valid value + if ( vExitCode && *vExitCode ){ _data.mReason = Device::DeviceError::eDevice_RootSSHAccess_Error ; goto lApply; } + + // Now everything is good to extract the data + _data.mAccepted = true; + _data.mMessage = QObject::tr("The RootSSHAccess Command Complete."); goto lApply; // normal return + +lApply: + _data.mRootSSHAccess = static_cast(val.toInt()); + goto lOut; + + // immediate exit on fail exitcode and invalid returned value. +lError: + if ( vExitCode ) error = *vExitCode; + _data.mMessage = Device::DeviceError::deviceErrorText(static_cast(_data.mReason), error) + "\n" + vByteArray; + +lOut: + return _data.mAccepted; +} + +/*! * \brief MDeviceWifiListResponse::fromByteArray * \details Checks the response and sets up the model data. * \param vExitCode - Passed script exit code Index: sources/device/DeviceView.cpp =================================================================== diff -u -re7adb742d7dd362b2deb795259694b223eea3bc0 -r86df7ff03ea32f9cd8a18bbbc7b2e01de64c783f --- sources/device/DeviceView.cpp (.../DeviceView.cpp) (revision e7adb742d7dd362b2deb795259694b223eea3bc0) +++ sources/device/DeviceView.cpp (.../DeviceView.cpp) (revision 86df7ff03ea32f9cd8a18bbbc7b2e01de64c783f) @@ -167,14 +167,12 @@ // ================================================= RootSSHAccess void VDevice::doInitRootSSHAccess() { - // DEBUG : qDebug() << "HERE Request" << vValue; DeviceRootSSHAccessRequestData data; data.mIsGet = true; emit didAttributeRequest(data); } void VDevice::rootSSHAccessRequest(const Qt::CheckState &vValue) { - // DEBUG : qDebug() << "HERE Request" << vValue; DeviceRootSSHAccessRequestData data; data.mIsGet = false; data.mRootSSHAccess = vValue; @@ -229,10 +227,7 @@ // Nothing for now. } -void VDevice::decommissionRequest(const QString &vCommand) { - Q_UNUSED(vCommand) - // DEBUG : qDebug() << "HERE Request" << vCommand; - +void VDevice::decommissionRequest(const QString &) { decommissionEnabled(true); DeviceDecommissionRequestData data; @@ -248,7 +243,6 @@ } void VDevice::onAttributeResponse(const DeviceDecommissionResponseData &vData) { - //QDEBUG : qDebug() << "HERE Response " << Q_FUNC_INFO << " accepted: "<< vData.mAccepted << vData.mReason; // this has to be called to let Gui to set to old value that device controller provided. status(vData.mMessage); Index: sources/gui/qml/components/TextEntry.qml =================================================================== diff -u -r3738eb975493a36efae6b1a060624abab72c6871 -r86df7ff03ea32f9cd8a18bbbc7b2e01de64c783f --- sources/gui/qml/components/TextEntry.qml (.../TextEntry.qml) (revision 3738eb975493a36efae6b1a060624abab72c6871) +++ sources/gui/qml/components/TextEntry.qml (.../TextEntry.qml) (revision 86df7ff03ea32f9cd8a18bbbc7b2e01de64c783f) @@ -102,10 +102,11 @@ width : TextEntry.InputWidth text : "" font.pixelSize : Fonts.fontPixelTextRectExtra - color : acceptableInput ? _root.showDisabledColor && - enabled ? - Colors.textMain : Colors.borderDisableButton : - Colors.red + color : acceptableInput && enabled ? Colors.textMain : + _root.showDisabledColor && + ! enabled ? + Colors.borderDisableButton : + Colors.red selectionColor : Colors.borderButtonHalfDarker selectedTextColor : acceptableInput ? Colors.textMain : Colors.red anchors.left : _separator.right Index: sources/gui/qml/pages/settings/SettingsDateTime.qml =================================================================== diff -u -r3738eb975493a36efae6b1a060624abab72c6871 -r86df7ff03ea32f9cd8a18bbbc7b2e01de64c783f --- sources/gui/qml/pages/settings/SettingsDateTime.qml (.../SettingsDateTime.qml) (revision 3738eb975493a36efae6b1a060624abab72c6871) +++ sources/gui/qml/pages/settings/SettingsDateTime.qml (.../SettingsDateTime.qml) (revision 86df7ff03ea32f9cd8a18bbbc7b2e01de64c783f) @@ -84,11 +84,10 @@ width : Variables.adjustmentLabelUnitContainerWidth height : Variables.adjustmentLabelUnitContainerHeight text : qsTr("Time") - unitText : qsTr("HH:MM") + unitText : vDateTime.timeFormat enabled : ! _ntpSwitch.checked contentItem: Row { // time - spacing : 10 anchors.centerIn: parent TextEntry { id: _hours @@ -130,11 +129,10 @@ width : Variables.adjustmentLabelUnitContainerWidth height : Variables.adjustmentLabelUnitContainerHeight text : qsTr("Date") - unitText : qsTr("MM/DD/YYYY") + unitText : vDateTime.dateFormat enabled : ! _ntpSwitch.checked contentItem: Row { // time - spacing : 10 anchors.centerIn: parent TextEntry { id: _month @@ -151,7 +149,7 @@ } Label { id : _slashMonthDay - text : qsTr(":") + text : qsTr("/") color : _root.entryTextColor width : 5 } @@ -170,7 +168,7 @@ } Label { id : _slashDayYear - text : qsTr(":") + text : qsTr("/") color : _root.entryTextColor width : 5 } Index: sources/gui/qml/pages/settings/SettingsDecommission.qml =================================================================== diff -u -r88a09dc4b26cfdd5fd111d20adfb9cb60697186c -r86df7ff03ea32f9cd8a18bbbc7b2e01de64c783f --- sources/gui/qml/pages/settings/SettingsDecommission.qml (.../SettingsDecommission.qml) (revision 88a09dc4b26cfdd5fd111d20adfb9cb60697186c) +++ sources/gui/qml/pages/settings/SettingsDecommission.qml (.../SettingsDecommission.qml) (revision 86df7ff03ea32f9cd8a18bbbc7b2e01de64c783f) @@ -43,7 +43,7 @@ } Connections { target: _confirmDialog function onAccepted() { - if ( _confirmDialog.titleText === _headerBar.titleText ) { // use the title as the indication of what has been confirmed and if that is related to this function. + if ( currentItem === SettingsStack.Decommission ) { vDevice.decommission = "" // Need to set to something (ie: emtpy string) to trigger CPP code } } Index: sources/gui/qml/pages/settings/SettingsFactoryReset.qml =================================================================== diff -u -r88a09dc4b26cfdd5fd111d20adfb9cb60697186c -r86df7ff03ea32f9cd8a18bbbc7b2e01de64c783f --- sources/gui/qml/pages/settings/SettingsFactoryReset.qml (.../SettingsFactoryReset.qml) (revision 88a09dc4b26cfdd5fd111d20adfb9cb60697186c) +++ sources/gui/qml/pages/settings/SettingsFactoryReset.qml (.../SettingsFactoryReset.qml) (revision 86df7ff03ea32f9cd8a18bbbc7b2e01de64c783f) @@ -43,7 +43,7 @@ } Connections { target: _confirmDialog function onAccepted() { - if ( _confirmDialog.titleText === _headerBar.titleText ) { // use the title as the indication of what has been confirmed and if that is related to this function. + if ( currentItem === SettingsStack.FactoryReset ) { vDevice.factoryReset = "" // Need to set to something (ie: emtpy string) to trigger CPP code } } Index: sources/gui/qml/pages/settings/SettingsStack.qml =================================================================== diff -u -re7adb742d7dd362b2deb795259694b223eea3bc0 -r86df7ff03ea32f9cd8a18bbbc7b2e01de64c783f --- sources/gui/qml/pages/settings/SettingsStack.qml (.../SettingsStack.qml) (revision e7adb742d7dd362b2deb795259694b223eea3bc0) +++ sources/gui/qml/pages/settings/SettingsStack.qml (.../SettingsStack.qml) (revision 86df7ff03ea32f9cd8a18bbbc7b2e01de64c783f) @@ -38,6 +38,7 @@ stackView.initialItem : _settingsHome property bool serviceMode : false + property int currentItem : -1 readonly property bool normalMode : ! ( _GuiView.manufactSetup || _GuiView.updateSetup ) readonly property bool setupMode : _GuiView.manufactSetup || _GuiView.updateSetup @@ -161,6 +162,7 @@ itemsText : _root.itemsText itemsVisible : _root.itemsVisible onItemClicked : { + _root.currentItem = vIndex vDevice.status = "" _headerBar.titleText = itemsText[vIndex] switch (vIndex) { Index: sources/view/settings/VDateTime.cpp =================================================================== diff -u -r3738eb975493a36efae6b1a060624abab72c6871 -r86df7ff03ea32f9cd8a18bbbc7b2e01de64c783f --- sources/view/settings/VDateTime.cpp (.../VDateTime.cpp) (revision 3738eb975493a36efae6b1a060624abab72c6871) +++ sources/view/settings/VDateTime.cpp (.../VDateTime.cpp) (revision 86df7ff03ea32f9cd8a18bbbc7b2e01de64c783f) @@ -70,6 +70,9 @@ month (_currentTime.toString("MM" )); year (_currentTime.toString("yyyy" )); + timeFormat (_Settings.timeFormat()); + dateFormat (_Settings.dateFormat()); + timezone(QTimeZone::systemTimeZone().abbreviation(_currentTime)); status(""); @@ -99,7 +102,7 @@ _day .toInt()) , QTime(_hour .toInt() , _minute .toInt())); - const QString dateTimeLocalStr = currentDateTimeLocal.toString("yyyy-MM-dd HH:mm:ss"); // sudo date -s requires this format + const QString dateTimeLocalStr = currentDateTimeLocal.toString(_updateFormat); // sudo date -s requires this format // Get the current UTC datetime const QDateTime currentDateTimeUTC = currentDateTimeLocal.toUTC(); @@ -192,7 +195,6 @@ mScript += Storage::Date_Time_Set_Sh; QStringList arguments; arguments << vDateTime << (vNTP ? "true" : "false"); - _process.start(mScript, arguments); } Index: sources/view/settings/VDateTime.h =================================================================== diff -u -r3738eb975493a36efae6b1a060624abab72c6871 -r86df7ff03ea32f9cd8a18bbbc7b2e01de64c783f --- sources/view/settings/VDateTime.h (.../VDateTime.h) (revision 3738eb975493a36efae6b1a060624abab72c6871) +++ sources/view/settings/VDateTime.h (.../VDateTime.h) (revision 86df7ff03ea32f9cd8a18bbbc7b2e01de64c783f) @@ -67,6 +67,7 @@ QDateTime _currentDateTime ; int _timerInterval = 1000; // ms QProcess _process ; + QString _updateFormat = "yyyy-MM-dd HH:mm:ss"; // format only used for changing system date/ time DateTimeSetStatus _acceptHD = NOT_SET; DateTimeSetStatus _acceptDG = NOT_SET; @@ -99,6 +100,9 @@ PROPERTY(QString, date , "" ) + PROPERTY(QString, timeFormat, "" ) + PROPERTY(QString, dateFormat, "" ) + PROPERTY(QString, timezone , "" ) VIEW_DEC_CLASS(VDateTime)