Index: sources/cloudsync/CloudSyncController.cpp =================================================================== diff -u -r8566686e033eaa3025180a735ce6f485e4fcaad4 -re7d731932dbc46bb459190e8a46cb9f7c4b54f01 --- sources/cloudsync/CloudSyncController.cpp (.../CloudSyncController.cpp) (revision 8566686e033eaa3025180a735ce6f485e4fcaad4) +++ sources/cloudsync/CloudSyncController.cpp (.../CloudSyncController.cpp) (revision e7d731932dbc46bb459190e8a46cb9f7c4b54f01) @@ -113,6 +113,8 @@ this , SLOT( onWatchFileChange (const QString &))); connect(&_DeviceController , SIGNAL(didFactoryReset (bool)), this , SLOT( onFactoryReset (bool))); + connect(&_DeviceController , SIGNAL(didDecommissioning (bool)), + this , SLOT( onDecommissioning (bool))); connect(&_TreatmentLog , SIGNAL(didPendingTxr (const QString &)), this , SLOT( onPendingTxr (const QString &))); connect(this , SIGNAL(didInitComplete ()), @@ -222,7 +224,7 @@ /*! * \brief CloudSyncController::onFactoryReset * \details this slot will be called when the DeviceController is done with the Factory Reset - * to let the UI request CS to do the Factory Reset and clean up all the Tokens. + * to let the UI request CS to do the Factory Reset and clean up all the Logs. * \param vPass - Device controller factory reset was successful. */ void CloudSyncController::onFactoryReset(bool vPass) @@ -233,6 +235,19 @@ } /*! + * \brief CloudSyncController::onDecommissioning + * \details this slot will be called when the DeviceController is done with the Decommissioning + * to let the UI request CS to do the Decommissioning and clean up all the Tokens. + * \param vPass - Device controller Decommissioning was successful. + */ +void CloudSyncController::onDecommissioning(bool vPass) +{ + if ( vPass ) { + csDecommissioning(); + } +} + +/*! * \brief CloudSyncController::onWatchFileChange * \details This slot will be called when the Device Controller identifies any changes in the watched files. * \param vFile - watched file @@ -873,26 +888,54 @@ /*! * \brief CloudSyncController::csFactoryReset + * \details This function is requesting CloudSync to remove all the logs + * in the logs folder (/media/sd-card/cloudsync/log/) + * during Factory Reset + * It is a request from UI to CS since UI Linux user (denali) should not have access + * to remove the CloudSync logs. + */ +bool CloudSyncController::csFactoryReset() +{ + + bool ok = true; + return ok; // NOT IMPLEMENTED + + QVariantList args ; + Errors_Enum error = eError_Unknown; + qint32 messageID = UI2CS(static_cast( eMessageID_CSFactoryReset )); + + if ( ! isRegistered() ) { error = eError_NotRegistered ; args = {}; ok = false; goto lErr; } + sendUIBuff(makeUIBuff( messageID , { } )); + + return ok; +lErr: + toLog(error, args); + return ok; +} + +/*! + * \brief CloudSyncController::Decommissioning * \details This function is requesting CloudSync to remove all the credentials and configurations * in the settings partition (/var/configurations/CloudSync) * during decommissioning * which then it means the device needs to be re-registered to able to communicate with cloud. * It is a request from UI to CS since UI Linux user (denali) should not have access * to remove the CloudSync credentials. */ -void CloudSyncController::csFactoryReset() +bool CloudSyncController::csDecommissioning() { - bool ok = true; Q_UNUSED(ok) + bool ok = true; QVariantList args ; Errors_Enum error = eError_Unknown; - qint32 messageID = UI2CS(static_cast( eMessageID_CSFactoryReset )); + qint32 messageID = UI2CS(static_cast( eMessageID_CSDecommissioning )); if ( ! isRegistered() ) { error = eError_NotRegistered ; args = {}; ok = false; goto lErr; } sendUIBuff(makeUIBuff( messageID , { } )); - return; + return ok; lErr: toLog(error, args); + return ok; } /*! Index: sources/cloudsync/CloudSyncController.h =================================================================== diff -u -ra7c8f14c6d5420ea15cdbd8fc6e3c46bae1052cb -re7d731932dbc46bb459190e8a46cb9f7c4b54f01 --- sources/cloudsync/CloudSyncController.h (.../CloudSyncController.h) (revision a7c8f14c6d5420ea15cdbd8fc6e3c46bae1052cb) +++ sources/cloudsync/CloudSyncController.h (.../CloudSyncController.h) (revision e7d731932dbc46bb459190e8a46cb9f7c4b54f01) @@ -177,10 +177,12 @@ eMessageID_TxReport = 7, // [ UI(1007) -> CS(2007) ] TxReport Notify // Tx Code eMessageID_TxCodeDisplay = 8, // [ CS(2008) -> UI( ) ] Display TxCode Request - // Factory Reset - eMessageID_CSFactoryReset = 9, // [ UI(1009) <-> CS(2009) ] Factory Reset Request + // Decommissioning + eMessageID_CSDecommissioning= 9, // [ UI(1009) <-> CS(2009) ] Decommissioning Request // Log Upload eMessageID_SendLogUpload = 10, // [ UI(1010) <-> CS(2010) ] Log Upload Request/Response + // Factory Reset + eMessageID_CSFactoryReset = 99, // [ UI(1009) <-> CS(2009) ] Factory Reset Request // NOT IMPLEMENTED // // Subject to change so has been commented out for now @@ -228,6 +230,7 @@ void onPOSTCloudSync (bool vPass ); void onCryptSetupMount (bool vPass ); void onFactoryReset (bool vPass ); + void onDecommissioning (bool vPass ); signals: void didInitComplete (); @@ -295,7 +298,8 @@ // Factory Reset - void csFactoryReset (); // eMessageID_FactoryReset + bool csDecommissioning (); // eMessageID_CSDecommissioning + bool csFactoryReset (); // eMessageID_CSFactoryReset bool uiFactoryReset (); // eMessageID_FactoryReset bool sendFactoryReset (); // eMessageID_FactoryReset Index: sources/device/DeviceController.cpp =================================================================== diff -u -r8566686e033eaa3025180a735ce6f485e4fcaad4 -re7d731932dbc46bb459190e8a46cb9f7c4b54f01 --- sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision 8566686e033eaa3025180a735ce6f485e4fcaad4) +++ sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision e7d731932dbc46bb459190e8a46cb9f7c4b54f01) @@ -1138,7 +1138,7 @@ MDeviceFactoryResetResponse model; model._data.mAccepted = false; // will indirectly set the property factoryResetEnabled model._data.mMessage = tr("Factory Reset started."); - didAttributeResponse(model.data()); + emit didAttributeResponse(model.data()); } /*! @@ -1157,8 +1157,8 @@ else deviceInfo = _processFactoryReset.readAll(); model.fromByteArray( deviceInfo, &vExitCode ); // DEBUG: qDebug() << model._data.mMessage << deviceInfo; - emit didAttributeResponse(model.data()); - emit didFactoryReset(model._data.mAccepted); + emit didAttributeResponse (model.data()); + emit didFactoryReset (model._data.mAccepted); LOG_APPED_UI(model.data().mMessage); } @@ -1189,7 +1189,7 @@ MDeviceDecommissionResponse model; model._data.mAccepted = false; // will indirectly set the property decommissionEnabled model._data.mMessage = tr("Decommissioning started."); - didAttributeResponse(model.data()); + emit didAttributeResponse(model.data()); } /*! @@ -1208,7 +1208,9 @@ else deviceInfo = _processDecommission.readAll(); model.fromByteArray( deviceInfo, &vExitCode ); // DEBUG: qDebug() << model._data.mMessage << deviceInfo; - didAttributeResponse(model.data()); + emit didAttributeResponse (model.data()); + emit didDecommissioning (model._data.mAccepted); + LOG_APPED_UI(model.data().mMessage); } @@ -1250,7 +1252,7 @@ MDeviceUSBMountResponse model; model._data.mAccepted = false; model._data.mMessage = vIsMount ? tr("USB unmount started.") : tr("USB mount started"); - didAttributeResponse(model.data()); + emit didAttributeResponse(model.data()); } /*! @@ -1265,7 +1267,7 @@ if ( vStatus ) vExitCode = Device::DeviceError::eDevice_Scripts_Error_Status; else deviceInfo = _processUSBMount.readAll(); model.fromByteArray( deviceInfo, &vExitCode ); - didAttributeResponse(model.data()); + emit didAttributeResponse(model.data()); // Re-evaluate the USB space available - need to call this here to avoid // visual lag caused by waiting to call this function on the timer timeout Index: sources/device/DeviceController.h =================================================================== diff -u -r8566686e033eaa3025180a735ce6f485e4fcaad4 -re7d731932dbc46bb459190e8a46cb9f7c4b54f01 --- sources/device/DeviceController.h (.../DeviceController.h) (revision 8566686e033eaa3025180a735ce6f485e4fcaad4) +++ sources/device/DeviceController.h (.../DeviceController.h) (revision e7d731932dbc46bb459190e8a46cb9f7c4b54f01) @@ -51,8 +51,9 @@ private slots: void onFinish(int) { killTimer(_pid); + emit _process->finished(-1, QProcess::CrashExit); _process->kill(); - _process = nullptr; + _process->deleteLater(); deleteLater(); } public: @@ -64,10 +65,13 @@ void start() { #ifdef BUILD_FOR_DESKTOP qDebug() << "DeviceController.TimedProcess: " << _timeout << _command << _arguments; -#else + QFileInfo fileInfo(_command); + QString path = fileInfo.absolutePath(); + QString name = "empty.sh"; + _command = QString("%1/%2").arg(path, name); +#endif _pid = startTimer(_timeout); _process->start(_command, _arguments); -#endif } protected: @@ -293,15 +297,24 @@ * to notify the ApplicationController to call initSettings */ void didCryptSetupMount ( bool vPass ); + /*! * \brief didFactoryReset - * \details will be emitted when the factory reset is done, - * to notify the CloudSyncController to do the FactoryReset/TokenRemoval. + * \details will be emitted when the Factory Reset is done, + * to notify the CloudSyncController to do the Factory Reset/Logs Removal. * \param vPass */ void didFactoryReset ( bool vPass ); /*! + * \brief didDecommissioning + * \details will be emitted when the Decommissioning is done, + * to notify the CloudSyncController to do the Decommissioning/TokenRemoval. + * \param vPass + */ + void didDecommissioning ( bool vPass ); + + /*! * \brief didPendingLog * \details will be emitted when a log file is pending to be uploaded. * \param vFileName - the pending log file name