Index: sources/cloudsync/CloudSyncController.cpp =================================================================== diff -u -r0552e825eebff72cbfd7f4f2fbb74b46c80f1e21 -r6531fd93584d910ce4313638b868d5fd20e77b68 --- sources/cloudsync/CloudSyncController.cpp (.../CloudSyncController.cpp) (revision 0552e825eebff72cbfd7f4f2fbb74b46c80f1e21) +++ sources/cloudsync/CloudSyncController.cpp (.../CloudSyncController.cpp) (revision 6531fd93584d910ce4313638b868d5fd20e77b68) @@ -551,13 +551,14 @@ bool CloudSyncController::sendMessage(const qint32 vAction) { bool ok = false; + // this function is used int sendUIResponse, therefore the message IDs which are responses should be implemented here. switch (vAction) { - case eMessageID_DeviceRegister : break; + case eMessageID_DeviceRegister : /* No Request/Response */ break; case eMessageID_DeviceInfo : ok = sendDeviceInfo(); break; case eMessageID_SaveCredentials : break; case eMessageID_SendCredentials : break; - case eMessageID_ResetFactory : break; + case eMessageID_ResetFactory : ok = sendResetFactory(); break; case eMessageID_DeviceState : ok = sendDeviceState(); break; case eMessageID_TxReport : break; @@ -567,8 +568,8 @@ } /*! - * \brief CloudSyncController::sendDeviceState - * \return + * \brief CloudSyncController::sendDeviceState + * \return Sends the last received device state from history to CloudSync */ bool CloudSyncController::sendDeviceState() { @@ -578,6 +579,57 @@ } /*! + * \brief CloudSyncController::doResetFactory + * \details does the reset factory + * \return true on successful reset + */ +bool CloudSyncController::doResetFactory() +{ + // reset factory has not been implemented yet. + bool ok = true; + LOG_DEBUG("CloudSync Reset factory request has not been implemented yet."); + return ok; +} + +/*! + * \brief CloudSyncController::sendResetFactory + * \details sends the factory reset response to CloudSync + * \return true on successful send. + */ +bool CloudSyncController::sendResetFactory() +{ + bool ok = false; + ok = doResetFactory(); + // if ( ! ok ) { } /* Not defined */ + qint32 messageID = UI2CS(eMessageID_ResetFactory); + ok = sendUIBuff(QString("%1,0,0").arg( messageID )); + return ok; +} + +/*! + * \brief CloudSyncController::sendDeviceRegister + * \details sends the device registration request + * \return true on successful send. + */ +bool CloudSyncController::sendDeviceRegister() +{ + bool ok = false; + ok = sendUIHistory(eMessageID_DeviceRegister); + return ok; +} + +/*! + * \brief CloudSyncController::testDeviceRegister + * \details checks if the device needs registration. + * \return true if registration required. + */ +bool CloudSyncController::testDeviceRegister() +{ + // the device registration request condition needs to be discussed. + return false; +} + +/*! * \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. @@ -625,8 +677,13 @@ { bool ok = false; if ( _deviceInfoUI.isEmpty() ) { _deviceInfoUI = qApp->applicationVersion(); } - ok = saveUIHistory(eMessageID_DeviceInfo , { _deviceInfoHD, _deviceInfoDG, _deviceInfoUI } ) && + ok = 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. sendDeviceInfo(); + + if ( testDeviceRegister() ) + sendDeviceRegister(); + if ( ok ) stopDeviceInfoWait(); return ok; } Index: sources/cloudsync/CloudSyncController.h =================================================================== diff -u -r0552e825eebff72cbfd7f4f2fbb74b46c80f1e21 -r6531fd93584d910ce4313638b868d5fd20e77b68 --- sources/cloudsync/CloudSyncController.h (.../CloudSyncController.h) (revision 0552e825eebff72cbfd7f4f2fbb74b46c80f1e21) +++ sources/cloudsync/CloudSyncController.h (.../CloudSyncController.h) (revision 6531fd93584d910ce4313638b868d5fd20e77b68) @@ -202,22 +202,30 @@ qint32 UI2CS (MessageID_Enum vID) { return vID + eUI; } qint32 CS2UI (MessageID_Enum vID) { return vID - eCS; } + // error bool sendError (); // eMessageID_Error + // device information bool saveDeviceInfo (GuiActionType vAction, const QVariantList &vData); // eMessageID_DeviceInfo bool saveDeviceInfoTimeOut (); // eMessageID_DeviceInfo bool sendDeviceInfo (); // eMessageID_DeviceInfo void testDeviceInfoWait (); void stopDeviceInfoWait (); void initDeviceInfoWait (); + // device registration request + bool sendDeviceRegister (); // eMessageID_DeviceRegister + bool testDeviceRegister (); // eMessageID_DeviceRegister - + // device state report bool sendDeviceState (); // eMessageID_DeviceState - bool sendDeviceRegister (); // eMessageID_DeviceRegister + + // reset Factory + bool doResetFactory (); // eMessageID_ResetFactory + bool sendResetFactory (); // eMessageID_ResetFactory + bool sendSaveCredentials (); // eMessageID_SaveCredentials bool sendSendCredentials (); // eMessageID_SendCredentials - bool sendResetFactory (); // eMessageID_ResetFactory bool sendTxReport (); // eMessageID_TxReport };