Index: sources/cloudsync/CloudSyncController.cpp =================================================================== diff -u -rf68b226e67eb500758ee94fe015df48931240013 -r44550c670a421059754a70e2ce517e81f29c2e5d --- sources/cloudsync/CloudSyncController.cpp (.../CloudSyncController.cpp) (revision f68b226e67eb500758ee94fe015df48931240013) +++ sources/cloudsync/CloudSyncController.cpp (.../CloudSyncController.cpp) (revision 44550c670a421059754a70e2ce517e81f29c2e5d) @@ -328,6 +328,7 @@ 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_NotRegistered : text = tr( "CS Not Sent, Device not registered." ) ; break; } return text; } @@ -369,6 +370,7 @@ 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_NotRegistered : info = QString( "[%1:%2]" ).arg( vErrorID ).arg( item(0) ) ; break; } return info; } @@ -548,8 +550,10 @@ QVariantList args ; Errors_Enum error = eError_Unknown; + // only sends messages if device has been registered qint32 messageID = UI2CS(static_cast(vAction)); - if ( ! _uiHistory.contains( messageID ) ) { error = eError_NoHistory; args = { messageID }; ok = false; goto lErr; } + if ( ! isRegistered() && vAction != eMessageID_DeviceRegister ) { error = eError_NotRegistered ; args = { messageID }; ok = false; goto lErr; } + if ( ! _uiHistory.contains( messageID ) ) { error = eError_NoHistory ; args = { messageID }; ok = false; goto lErr; } sendUIBuff(makeUIBuff(messageID)); @@ -816,18 +820,28 @@ */ bool CloudSyncController::testDeviceRegister() { - QString source = QString(Storage::CloudSync_Base_Path_Name) + Storage::CloudSync_Credentials_Folder_Name; - qDebug() << source; - QFileInfoList fileInfos = QDir(source).entryInfoList(QDir::NoDotAndDotDot|QDir::Files); - if( fileInfos.isEmpty() ) { 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. + */ +bool CloudSyncController::isRegistered() +{ + QString source = QString(Storage::CloudSync_Base_Path_Name) + Storage::CloudSync_Credentials_Folder_Name; + qDebug() << source; + QFileInfoList fileInfos = QDir(source).entryInfoList(QDir::NoDotAndDotDot|QDir::Files); + return !fileInfos.isEmpty(); +} + +/*! * \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.