Index: sources/cloudsync/CloudSyncController.cpp =================================================================== diff -u -r9d5e23f6277a0b3c8c643413e6ff0257695420d3 -rb043c5b9919a9a435e50907772ec8346823b05d6 --- sources/cloudsync/CloudSyncController.cpp (.../CloudSyncController.cpp) (revision 9d5e23f6277a0b3c8c643413e6ff0257695420d3) +++ sources/cloudsync/CloudSyncController.cpp (.../CloudSyncController.cpp) (revision b043c5b9919a9a435e50907772ec8346823b05d6) @@ -106,6 +106,8 @@ connect(&_DeviceController , SIGNAL(didCryptSetupMount(bool)), this , SLOT( onCryptSetupMount(bool))); + connect(&_DeviceController , SIGNAL(didPendingLog (const QString &, const QString &)), + this , SLOT( onPendingLog (const QString &, const QString &))); connect(&_DeviceController , SIGNAL(didWatchFileChange (const QString &)), this , SLOT( onWatchFileChange (const QString &))); @@ -415,6 +417,8 @@ case eError_CredentialEmpty : text = tr( "CS The credentials folder is empty." ) ; break; case eError_TxCodeNoParam : text = tr( "CS No Treatment Code provided." ) ; break; case eError_TxCodeEmpty : text = tr( "CS The provided Treatment Code is empty." ) ; break; + case eError_LogNameNoParam : text = tr( "CS No Log Name provided." ) ; break; + case eError_LogNameEmpty : text = tr( "CS The provided Log Name is empty." ) ; break; case eError_NotRegistered : text = tr( "CS Not Sent, Device not registered." ) ; break; } @@ -472,6 +476,8 @@ case eError_CredentialEmpty : info = QString( "[%1:%2]" ).arg( vErrorID ).arg( item(0) ) ; break; case eError_TxCodeNoParam : info = QString( "[%1:%2]" ).arg( vErrorID ).arg( item(0) ) ; break; case eError_TxCodeEmpty : info = QString( "[%1:%2]" ).arg( vErrorID ).arg( item(0) ) ; break; + case eError_LogNameNoParam : info = QString( "[%1:%2]" ).arg( vErrorID ).arg( item(0) ) ; break; + case eError_LogNameEmpty : info = QString( "[%1:%2]" ).arg( vErrorID ).arg( item(0) ) ; break; case eError_NotRegistered : info = QString( "[%1:%2]" ).arg( vErrorID ).arg( item(0) ) ; break; } return info; @@ -759,7 +765,51 @@ sendPendingTxr(vFileName); } +// ------------------------------------------------------------------------ TODO: Improve : fucntion description +void CloudSyncController::onPendingLog(const QString &vFileName, const QString vChecksum) +{ + sendPendingLog(vFileName, vChecksum); +} + +// ------------------------------------------------------------------------ TODO: Improve : fucntion description +void CloudSyncController::sendPendingLog(const QString &vFileName, const QString vChecksum) +{ + bool ok = true; Q_UNUSED(ok) + QVariantList args ; + Errors_Enum error = eError_Unknown; + qint32 messageID = UI2CS(static_cast( eMessageID_SendLogUpload )); + // DEBUG ok = false; // using the ok bool which is true as the debug flag to bypass the registration on debug testing. + if ( ok && ! isRegistered() ) { error = eError_NotRegistered ; args = { vFileName }; ok = false; goto lErr; } + sendUIBuff(makeUIBuff( messageID , { vFileName, vChecksum } )); + + return; +lErr: + toLog(error, args); +} + /*! + * \brief CloudSyncController::rcvdPendingLog + * \details reads the received Log Name from CloudSync app and notifies with a signal. + * \param vMessage : message containing the uploaded Log name. + * \return true on successful extracting the Log Name. + */ +bool CloudSyncController::rcvdPendingLog(const Message &vMessage) +{ + bool ok = true; + QString mLogName; + // although it has been checked in the interpreter, we won't risk the crash and check the list empty. + if ( vMessage.params.isEmpty() ) { toLog(eError_LogNameNoParam , {}); ok = false; goto lOut; } + mLogName = vMessage.params[0].trimmed(); + if ( mLogName.isEmpty() ) { toLog(eError_LogNameEmpty , {}); ok = false; goto lOut; } + //DEBUG + qDebug() << " ---------- " << mLogName; + emit didLogUpload( mLogName ); + + lOut: + return ok; +} + +/*! * \brief CloudSyncController::sendMessage * \details Makes and Sends the appropriate message for the vAction. * Some messages are sent out upon request form the last received on the history and will not be asked from FW. @@ -778,6 +828,7 @@ case eMessageID_DeviceState : ok = sendDeviceState ( ); break; case eMessageID_TxCodeDisplay : ok = sendTxCodeDisplay ( vMessage ); break; + case eMessageID_SendLogUpload : ok = rcvdPendingLog ( vMessage ); break; case eMessageID_TxReport : /* No Req/Rsp, it is event based */ break; // This message doesn't have the response since there is no request. UI will send when the data ready by HD. @@ -997,9 +1048,13 @@ */ bool CloudSyncController::isRegistered() { +#ifdef BUILD_FOR_DESKTOP + return true; +#else QString source = QString(Storage::CloudSync_Base_Path_Name) + Storage::CloudSync_Credentials_Folder_Name; QFileInfoList fileInfos = QDir(source).entryInfoList(QDir::NoDotAndDotDot|QDir::Files); return !fileInfos.isEmpty(); +#endif } /*!