Index: sources/cloudsync/CloudSyncController.h =================================================================== diff -u -r44550c670a421059754a70e2ce517e81f29c2e5d -r6c6f1f5d466badd9b4fd67be7c907234c342b2a2 --- sources/cloudsync/CloudSyncController.h (.../CloudSyncController.h) (revision 44550c670a421059754a70e2ce517e81f29c2e5d) +++ sources/cloudsync/CloudSyncController.h (.../CloudSyncController.h) (revision 6c6f1f5d466badd9b4fd67be7c907234c342b2a2) @@ -1,13 +1,13 @@ /*! * - * Copyright (c) 2021-2022 Diality Inc. - All Rights Reserved. + * 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 CloudSyncController.h * \author (last) Behrouz NematiPour - * \date (last) 01-Jul-2022 + * \date (last) 07-Apr-2023 * \author (original) Behrouz NematiPour * \date (original) 14-Oct-2021 * @@ -16,7 +16,6 @@ // Qt #include -#include #include // Project @@ -75,37 +74,48 @@ QString _deviceInfoDG = ""; QString _deviceInfoUI = ""; + bool _postPass = false; + enum Errors_Enum { - eError_Unknown = 500, // Unknown error, initial error before error check + // CS : 900 - 949 + // UI : 950 - 999 + eError_Unknown = 900, // Unknown error, initial error before error check - eError_HeaderCount = 501, - eError_Timestamp = 502, - eError_Sequence = 503, - eError_CRC = 504, - eError_MessageID = 505, - eError_InvalidID = 506, - eError_ParamCount = 507, - eError_ParamMismatch = 508, - eError_ParamMissing = 509, - eError_NoHistory = 510, - eError_Duplicate = 511, + // CS to UI Error start + eError_Registration = 901, + eError_TxReport = 902, - eError_LogFolder = 512, - eError_LogFileInp = 513, - eError_CredentialMake = 514, // the UI vault folder for cloudsync credentials can't be created. - eError_CredentialFile = 515, // the credential files sent to UI can't be find or read or doesn't exist.. - eError_CredentialCopy = 516, // the credential files sent to UI can't be copied to UI vault. - eError_CredentialRemove = 517, // the credential files sent to UI can't be removed. - eError_CredentialEmpty = 518, // the UI folder doesn't have credential files. + // UI to CS Error start + // eError_UI_Base = 950, // No Used + eError_HeaderCount = 951, + eError_Timestamp = 952, + eError_Sequence = 953, + eError_CRC = 954, + eError_MessageID = 955, + eError_InvalidID = 956, + eError_ParamCount = 957, + eError_ParamMismatch = 958, + eError_ParamMissing = 959, - eError_TxCodeNoParam = 519, // the received Tx Code not provided - eError_TxCodeEmpty = 520, // the received Tx Code is empty + eError_NoHistory = 960, + eError_Duplicate = 961, - eError_OutFileEmpty = 521, // Out file has changed from CS2UI but the content is empty. + eError_LogFolder = 962, + eError_LogFileInp = 963, - eError_NotRegistered = 522, // avoid sending any message other than the device regitration, when device is not registered. + eError_CredentialPath = 964, // the UI vault folder for cloudsync credentials is not what is expected. + eError_CredentialFile = 965, // the credential files sent to UI can't be find or read or doesn't exist.. + eError_CredentialCount = 966, // No credential file sent to UI in the message. + eError_CredentialEmpty = 967, // the UI folder doesn't have credential files. + + eError_TxCodeNoParam = 969, // the received Tx Code not provided + eError_TxCodeEmpty = 970, // the received Tx Code is empty + + eError_OutFileEmpty = 971, // Out file has changed from CS2UI but the content is empty. + + eError_NotRegistered = 972, // avoid sending any message other than the device registration, when device is not registered. }; typedef QHash MessageList; @@ -138,13 +148,11 @@ enum MessageID_Enum { eMessageID_Start = 0, // // [ #1( ID ) <-> #2( ID ) ] Description ( #1 Requests and #2 responses ) - // Manufacturing - eMessageID_Error = 0, // [ CS(2000) <-> UI(1000) ] Error Report eMessageID_DeviceRegister = 1, // [ UI(1001) -> CS( ) ] Device Registration Request eMessageID_DeviceInfo = 2, // [ CS(2002) <-> UI(1002) ] Device information Request - eMessageID_CredentialsSave = 3, // [ CS(2003) -> UI( ) ] Save Credentials Request - eMessageID_CredentialsSend = 4, // [ CS(2004) <-> UI(1004) ] Send Credentials Request + eMessageID_CredentialsSave = 3, // [ CS(2003) <-> UI(1003) ] Save Credentials Request/Response + // Removed CredentialsSend = 4, // [ CS(2004) <-> UI(1004) ] Send Credentials Request eMessageID_ResetFactory = 5, // [ CS(2005) <-> UI(1005) ] Reset Factory Request // Deployment eMessageID_DeviceState = 6, // [ CS(2006) <-> UI(1006) ] Device State Request @@ -160,12 +168,15 @@ // eMessageID_DeviceReport = 204, // [No CS req defined] UI sends the device report // eMessageID_HeartBeat = 900, // CS sends the periodic Hb and UI can set the interval + eMessageID_Error = 999, // [ CS(2000) <-> UI(1000) ] Error Report + eMessageID_Count }; QHash paramCount { { eMessageID_CredentialsSave , 3 }, { eMessageID_TxCodeDisplay , 1 }, + { eMessageID_Error , 4 }, }; enum DeviceInfo_Enum { @@ -184,45 +195,53 @@ bool init(QThread &vThread); void quit(); + void doRegister (); + private slots: void onWatchFileChange (const QString &vFile); void onActionReceive (GuiActionType vAction, const QVariantList &vData); - void onTreatmentLogSave(const QString &vDeviceID , const QString &vPatientID , const QString &vFileName ); + void onTxPending (const QString &vFileName ); void onInitComplete (); + void onPOSTCloudSync (bool vPass ); + void onCryptSetupMount (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(); void initThread(QThread &vThread); void quitThread(); - quint8 generateCRC () { return 0; } // has not been implemented/decided yet + quint8 generateCRC (quint64 vSecSinceEpoch, quint64 vSeq, const QStringList &vDataList); bool validateCRC () { return true; } // has not been implemented/decided yet void testWatchBuffDate (); bool interpret (const QString &vContent, Message &vMessage); bool addCSBuffWatch (); - QString makeUIBuff (const qint32 vMessageID ); + QStringList makeUIBuff (const qint32 vMessageID , const QStringList &vPrm = {}); - bool isDuplicate (const qint32 vMessageID , const QStringList &vData); + bool isDuplicate (const qint32 vMessageID , const QStringList &vData); - bool sendUIResponse (const QString &vContent ); - bool sendUIBuff (const QString &vData ); - bool saveUIHistory (const qint32 vAction , const QVariantList &vData); - bool sendUIHistory (const qint32 vAction ); - bool sendMessage (const Message &vMessage ); + bool sendUIResponse (const QString &vContent ); + bool sendUIBuff (const QStringList &vData ); + bool saveUIHistory (const qint32 vAction , const QVariantList &vData); + bool sendUIHistory (const qint32 vAction ); + bool sendMessage (const Message &vMessage ); - bool writeInpFile (const QString &vInpBuff ); + bool writeInpFile (const QString &vInpBuff ); QString toText (Errors_Enum vErrorID); QString toInfo (Errors_Enum vErrorID, const QVariantList &vInfoItems); void toLog (Errors_Enum vErrorID, const QVariantList &vInfoItems); + void errorOut (Errors_Enum vErrorID, const QVariantList &vInfoItems); qint32 UI2CS (qint32 vID) { return vID + eUI ; } qint32 CS2UI (qint32 vID) { return abs(vID - eCS); } @@ -240,8 +259,8 @@ // device registration request bool sendDeviceRegister (); // eMessageID_DeviceRegister - bool testDeviceRegister (); // eMessageID_DeviceRegister bool isRegistered (); + void testReady(); // device state report bool saveDeviceState (const QVariantList &vData); @@ -252,9 +271,9 @@ bool sendResetFactory (); // eMessageID_ResetFactory bool sendCredentialsSave (const Message &vMessage); // eMessageID_SaveCredentials - bool sendCredentialsSend (); // eMessageID_SendCredentials bool sendCredentialsResponse(); bool sendTxCodeDisplay (const Message &vMessage); // eMessageID_TxCodeDisplay + bool errorHandler (const Message &vMessage); // eMessageID_Error };