Index: sources/cloudsync/CloudSyncController.cpp =================================================================== diff -u -raf8d98b36b427e2b5f4d6659fcf3b58ee79eab6a -rc296d233f68d978d924697f424425ee58493b435 --- sources/cloudsync/CloudSyncController.cpp (.../CloudSyncController.cpp) (revision af8d98b36b427e2b5f4d6659fcf3b58ee79eab6a) +++ sources/cloudsync/CloudSyncController.cpp (.../CloudSyncController.cpp) (revision c296d233f68d978d924697f424425ee58493b435) @@ -81,6 +81,15 @@ // disabled coco end /*! + * \brief CloudSyncController::doRegister + * \details Send the register device command. + */ +void CloudSyncController::doRegister() +{ + sendDeviceRegister(); +} + +/*! * \brief CloudSyncController::initConnections * \details Initializes the required signal/slot connection between this class and other objects * to be able to communicate. @@ -91,6 +100,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 +177,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 @@ -465,7 +489,7 @@ int count = vPrm.count(); QStringList prm = count ? vPrm : _uiHistory[ vMessageID ]; QString msg = QString::number(vMessageID); - QString len = QString::number(count ); + QString len = QString::number(prm.count()); QStringList dataList; dataList += msg; @@ -638,10 +662,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 +797,8 @@ lOut: if ( ok ) sendCredentialsResponse(); + emit didRegisterDone(ok); + testReady(); return ok; } @@ -784,6 +819,7 @@ ok = sendUIBuff({QString("%1").arg( messageID ), "1", destination}); lOut: + emit didRegisterStart(ok); return ok; } @@ -849,21 +885,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 +897,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 +957,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();