Index: denali.pro =================================================================== diff -u -r9a61db88ccc5454001d4759e6ee5402695fda993 -r380136967ba230affe91f614a9805319688eb05b --- denali.pro (.../denali.pro) (revision 9a61db88ccc5454001d4759e6ee5402695fda993) +++ denali.pro (.../denali.pro) (revision 380136967ba230affe91f614a9805319688eb05b) @@ -283,6 +283,7 @@ sources/view/settings/VAdjustmentServiceMode.h \ sources/view/settings/VAdjustmentServiceDates.h \ sources/view/settings/VDuetRoWaterDG.h \ + sources/view/settings/VCloudSync.h \ \ # ---------- Views - Alarm sources/view/hd/alarm/VAlarmStatus.h \ sources/view/hd/alarm/VAlarmActiveList.h \ @@ -543,6 +544,7 @@ sources/view/settings/VAdjustmentServiceMode.cpp \ sources/view/settings/VAdjustmentServiceDates.cpp \ sources/view/settings/VDuetRoWaterDG.cpp \ + sources/view/settings/VCloudSync.cpp \ \ # ---------- Views - HD - Adjustment sources/view/VAdjustmentResponseBase.cpp \ \ # ---------- Views - HD - Adjustment - common Index: sources/cloudsync/CloudSyncController.cpp =================================================================== diff -u -raf8d98b36b427e2b5f4d6659fcf3b58ee79eab6a -r380136967ba230affe91f614a9805319688eb05b --- sources/cloudsync/CloudSyncController.cpp (.../CloudSyncController.cpp) (revision af8d98b36b427e2b5f4d6659fcf3b58ee79eab6a) +++ sources/cloudsync/CloudSyncController.cpp (.../CloudSyncController.cpp) (revision 380136967ba230affe91f614a9805319688eb05b) @@ -91,6 +91,9 @@ SINGLETON_DISABLE_CONNECT(didPOSTCloudSync) } + connect(&_ApplicationController , SIGNAL(didPOSTCloudSync(bool)), + this , SLOT( onPOSTCloudSync(bool))); + connect(&_DeviceController , SIGNAL(didWatchFileChange (const QString &)), this , SLOT( onWatchFileChange (const QString &))); connect(&_MessageDispatcher , SIGNAL(didActionReceive (GuiActionType , const QVariantList &)), @@ -165,14 +168,26 @@ } /*! - * \brief CloudSyncController::onInitComplete - * \details The slot to be called when the CloudSync initialization is complete, to call the testDeviceRegister. + * \brief CloudSyncController::onInitComplete + * \details The slot to be called when the CloudSync initialization is complete + * Does nothing for now */ void CloudSyncController::onInitComplete() { - testDeviceRegister(); + // Nothing for now } /*! + * \brief CloudSyncController::onPOSTCloudSync + * \details This the handler for the ApplicationController::didPOSTCloudSync(bool) + * \param vPass - will be true if the POST test of CloudSync passed and it is running. + */ +void CloudSyncController::onPOSTCloudSync(bool vPass) +{ + _postPass = vPass; + testReady(); +} + +/*! * \brief CloudSyncController::onWatchFileChange * \details This slot will be called when the Device Controller identifies any changes in the watched files. * \param vFile - watched file @@ -638,10 +653,19 @@ void CloudSyncController::onTxPending(const QString &vFileName) { - // if (! isRegistered() ) return; + bool ok = true; Q_UNUSED(ok); + QVariantList args ; + Errors_Enum error = eError_Unknown; qint32 messageID = UI2CS(static_cast( eMessageID_TxReport )); + + if ( ! isRegistered() ) { error = eError_NotRegistered ; args = { vFileName }; ok = false; goto lErr; } + sendCredentialsSend(); // TODO: This has to be removed later, it is a workaround for Cloud issue, during our talk with KBM. sendUIBuff(makeUIBuff( messageID , { vFileName } )); + + return; +lErr: + toLog(error, args); } /*! @@ -764,6 +788,8 @@ lOut: if ( ok ) sendCredentialsResponse(); + emit didRegisterDone(ok); + testReady(); return ok; } @@ -784,6 +810,7 @@ ok = sendUIBuff({QString("%1").arg( messageID ), "1", destination}); lOut: + emit didRegisterStart(ok); return ok; } @@ -849,21 +876,6 @@ } /*! - * \brief CloudSyncController::testDeviceRegister - * \details checks if the device needs registration. - * \return true if registration required. - */ -bool CloudSyncController::testDeviceRegister() -{ - toLog(eError_CredentialEmpty,{}); // It is intentional that the vault folder path has not been sent to the log. - if( ! isRegistered() ) { - sendDeviceRegister(); - } - - return true; // for now always true. -} - -/*! * \brief CloudSyncController::isRegistered * \details checks if the device is registered by looking for existing credentials. * \return true if device has been registered. @@ -876,6 +888,16 @@ } /*! + * \brief CloudSyncController::testReady + * \details Checks if the CloudSync POST was passed and the device registration is complete. + */ +void CloudSyncController::testReady() +{ + bool ok = _postPass && isRegistered(); + emit didCloudSyncStatus( ok ); +} + +/*! * \brief CloudSyncController::saveDeviceInfo * \details keeps the received device information and set a flag to wait for the next message. * \param vAction - the action enum which identifies information source of HD or DG. @@ -926,7 +948,6 @@ saveUIHistory(eMessageID_DeviceInfo , { _deviceInfoHD, _deviceInfoDG, _deviceInfoUI } ); saveUIHistory(eMessageID_DeviceRegister , { _deviceInfoHD, _deviceInfoDG, _deviceInfoUI } ); // the device registration request format is the same as Device info with different message id. - testDeviceRegister (); // it is expected on the CloudSync App to get the sendDeviceInfo (); // this one may need to be removed and only will be sent on the request stopDeviceInfoWait(); Index: sources/cloudsync/CloudSyncController.h =================================================================== diff -u -raf8d98b36b427e2b5f4d6659fcf3b58ee79eab6a -r380136967ba230affe91f614a9805319688eb05b --- sources/cloudsync/CloudSyncController.h (.../CloudSyncController.h) (revision af8d98b36b427e2b5f4d6659fcf3b58ee79eab6a) +++ sources/cloudsync/CloudSyncController.h (.../CloudSyncController.h) (revision 380136967ba230affe91f614a9805319688eb05b) @@ -75,6 +75,7 @@ QString _deviceInfoDG = ""; QString _deviceInfoUI = ""; + bool _postPass = false; enum Errors_Enum { // CS : 900 - 949 @@ -201,10 +202,14 @@ void onActionReceive (GuiActionType vAction, const QVariantList &vData); void onTxPending (const QString &vFileName ); void onInitComplete (); + void onPOSTCloudSync (bool vPass ); signals: void didInitComplete (); void didTxCodeReceive (const QString &vTxCode); + void didRegisterStart (bool vOK ); + void didRegisterDone (bool vOK ); + void didCloudSyncStatus (bool vReady ); private: void initConnections(); @@ -253,8 +258,8 @@ // device registration request bool sendDeviceRegister (); // eMessageID_DeviceRegister - bool testDeviceRegister (); // eMessageID_DeviceRegister bool isRegistered (); + void testReady(); // device state report bool saveDeviceState (const QVariantList &vData); Index: sources/gui/GuiGlobals.cpp =================================================================== diff -u -rd949be21f2a9badd0978dddaaf436f6805de28dc -r380136967ba230affe91f614a9805319688eb05b --- sources/gui/GuiGlobals.cpp (.../GuiGlobals.cpp) (revision d949be21f2a9badd0978dddaaf436f6805de28dc) +++ sources/gui/GuiGlobals.cpp (.../GuiGlobals.cpp) (revision 380136967ba230affe91f614a9805319688eb05b) @@ -48,6 +48,7 @@ #include "VAdjustmentAlarmVolume.h" #include "VBluetooth.h" #include "VDuetRoWaterDG.h" +#include "VCloudSync.h" // states data #include "VHDOperationModeData.h" #include "VPreTreatmentStatesData.h" Index: sources/gui/qml/pages/settings/SettingsDeviceRegistration.qml =================================================================== diff -u -r559dc64d12cf7647ec8c29ccbf4ca90f90e5e3a2 -r380136967ba230affe91f614a9805319688eb05b --- sources/gui/qml/pages/settings/SettingsDeviceRegistration.qml (.../SettingsDeviceRegistration.qml) (revision 559dc64d12cf7647ec8c29ccbf4ca90f90e5e3a2) +++ sources/gui/qml/pages/settings/SettingsDeviceRegistration.qml (.../SettingsDeviceRegistration.qml) (revision 380136967ba230affe91f614a9805319688eb05b) @@ -43,7 +43,8 @@ readonly property int separatorGap : 40 readonly property string separatorText : ":" - property var ipValidator: RegExpValidator { + property alias isRegistered : _checkListView.completeVisible + property var ipValidator : RegExpValidator { regExp:/^(([01]?[0-9]?[0-9]|2([0-4][0-9]|5[0-5]))\.){3}([01]?[0-9]?[0-9]|2([0-4][0-9]|5[0-5]))$/ } @@ -56,7 +57,7 @@ TextEntry { id : _version_UI textInput.clip : true hasCursor : false - textInput.text : Qt .application.version + textInput.text : Qt .application.version textInput.horizontalAlignment: Text.AlignLeft label.text : qsTr("UI Version") separator.text : _root.separatorText @@ -121,13 +122,13 @@ anchors.right : parent.right anchors.rightMargin : _root.rightMargin - completeVisible : true completeText : qsTr("Registration complete") stepNames : [ qsTr("Cloud Service is running" ), qsTr("Registering the device" ) ] } + TouchRect { id : _scanButton anchors.bottom : parent.bottom anchors.bottomMargin : Variables.mainMenuHeight * 2 + Variables.minVGap * 2 Index: sources/storage/TreatmentLog.cpp =================================================================== diff -u -ra6586ea871f21a08e7d50552983360fb5e344b3a -r380136967ba230affe91f614a9805319688eb05b --- sources/storage/TreatmentLog.cpp (.../TreatmentLog.cpp) (revision a6586ea871f21a08e7d50552983360fb5e344b3a) +++ sources/storage/TreatmentLog.cpp (.../TreatmentLog.cpp) (revision 380136967ba230affe91f614a9805319688eb05b) @@ -43,7 +43,6 @@ TreatmentLog::TreatmentLog(QObject *parent) : QObject(parent) { initConnections(); logPath(Logger::eLogTrtmt, _Logger.logPath(Logger::eLogTrtmt)); - startTimer(_interval); } @@ -60,6 +59,9 @@ connect(&_saveWatcher , SIGNAL(finished()), this , SLOT(onSave ())); + connect(&_CloudSyncController , SIGNAL(didCloudSyncStatus(bool)), + this , SLOT( onCloudSyncStatus(bool))); + connect(&_CloudSyncController , SIGNAL(didTxCodeReceive(const QString &)), this , SLOT( onTxCodeReceive(const QString &))); @@ -416,6 +418,24 @@ } /*! + * \brief TreatmentLog::onCloudSyncStatus + * \details This is the handler to the slot CloudSyncController::didCloudSyncStatus, + * which will be emitted when the Cloud is running and the device is registered, with vReady as true. + * Therefore pending Treatment logs can be sent. + * or with ready as false if CloudSync stops or for any error can't communicate to send the logs. + */ +void TreatmentLog::onCloudSyncStatus(bool vReady) +{ + static int id; + if ( vReady ) { + id = startTimer(_interval); + } + else { + killTimer(id); + } +} + +/*! * \brief TreatmentLog::onTxCodeReceive * \details this slot will update the treatment code sent by CS. * \param vTxCode - The treatment code sent by CS. Index: sources/storage/TreatmentLog.h =================================================================== diff -u -raf8d98b36b427e2b5f4d6659fcf3b58ee79eab6a -r380136967ba230affe91f614a9805319688eb05b --- sources/storage/TreatmentLog.h (.../TreatmentLog.h) (revision af8d98b36b427e2b5f4d6659fcf3b58ee79eab6a) +++ sources/storage/TreatmentLog.h (.../TreatmentLog.h) (revision 380136967ba230affe91f614a9805319688eb05b) @@ -249,7 +249,8 @@ void onLogPathSet(Logger::LogType vLogType, const QString &vLogPath); void onSave (); void onExport (); - void onTxCodeReceive(const QString &vTxCode); + void onTxCodeReceive (const QString &vTxCode); + void onCloudSyncStatus ( bool vReady ); public slots: void doSave (); Index: sources/view/VView.h =================================================================== diff -u -rd949be21f2a9badd0978dddaaf436f6805de28dc -r380136967ba230affe91f614a9805319688eb05b --- sources/view/VView.h (.../VView.h) (revision d949be21f2a9badd0978dddaaf436f6805de28dc) +++ sources/view/VView.h (.../VView.h) (revision 380136967ba230affe91f614a9805319688eb05b) @@ -119,6 +119,7 @@ REGISTER_TYPE( VAdjustmentAlarmVolume ) \ REGISTER_TYPE( VBluetooth ) \ REGISTER_TYPE( VDuetRoWaterDG ) \ + REGISTER_TYPE( VCloudSync ) \ /* Alarm */ \ REGISTER_TYPE( VAlarmStatus ) \ REGISTER_TYPE( VAlarmActiveList ) \ Index: sources/view/settings/VCloudSync.cpp =================================================================== diff -u --- sources/view/settings/VCloudSync.cpp (revision 0) +++ sources/view/settings/VCloudSync.cpp (revision 380136967ba230affe91f614a9805319688eb05b) @@ -0,0 +1,40 @@ +/*! + * + * Copyright (c) 2021-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 VCloudSync.cpp + * \author (last) Behrouz NematiPour + * \date (last) 07-Apr-2023 + * \author (original) Behrouz NematiPour + * \date (original) 07-Apr-2023 + * + */ +#include "VCloudSync.h" + +// Qt + +// Project +// #include "GuiController.h" +#include "ApplicationController.h" +#include "CloudSyncController.h" + +using namespace View; + +VIEW_DEF_CLASS(VCloudSync) + +void VCloudSync::initConnections() { + connect(&_ApplicationController , &ApplicationController::didPOSTCloudSync, + this , [this](bool vPass) { isRunning (vPass); }); + + connect(&_CloudSyncController , &CloudSyncController ::didCloudSyncStatus, + this , [this](bool vPass) { isReady (vPass); }); + + connect(&_CloudSyncController , &CloudSyncController ::didRegisterStart, + this , [this](bool vPass) { isRegisterStart (vPass); }); + + connect(&_CloudSyncController , &CloudSyncController ::didRegisterDone, + this , [this](bool vPass) { isRegisterDone (vPass); }); +} Index: sources/view/settings/VCloudSync.h =================================================================== diff -u --- sources/view/settings/VCloudSync.h (revision 0) +++ sources/view/settings/VCloudSync.h (revision 380136967ba230affe91f614a9805319688eb05b) @@ -0,0 +1,52 @@ +/*! + * + * Copyright (c) 2021-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 VDateTime.h + * \author (last) Behrouz NematiPour + * \date (last) 07-Apr-2023 + * \author (original) Behrouz NematiPour + * \date (original) 07-Apr-2023 + * + */ +#pragma once + +// Qt +#include +// Project +#include "main.h" // Doxygen : do not remove +#include + +// forward declarations +class tst_views; + +namespace View { + +/*! + * \brief The VCloudSync class + * \details View for handling the CloudSync + * + */ +class VCloudSync : public QObject +{ + Q_OBJECT + + // friends + friend class ::tst_views; + + STATE(bool , isRunning , false) + STATE(bool , isReady , false) + STATE(bool , isRegisterStart , false) + STATE(bool , isRegisterDone , false) + + VIEW_DEC_CLASS(VCloudSync) + +private slots: +public: +signals: +}; + +}