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();