Index: sources/cloudsync/CloudSyncController.cpp =================================================================== diff -u -r265ce7409a0ea99a4ae059f5ce7978c9cdb10631 -r86d9540191c87953287abc9c9a5efc9ea16433e7 --- sources/cloudsync/CloudSyncController.cpp (.../CloudSyncController.cpp) (revision 265ce7409a0ea99a4ae059f5ce7978c9cdb10631) +++ sources/cloudsync/CloudSyncController.cpp (.../CloudSyncController.cpp) (revision 86d9540191c87953287abc9c9a5efc9ea16433e7) @@ -333,6 +333,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; } @@ -374,6 +375,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; } @@ -553,8 +555,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)); @@ -821,18 +825,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.