Index: sources/view/settings/VDateTime.cpp =================================================================== diff -u -r36c82a88dbd6b4fb71528465684d51c6fbff584f -r6e18f1d24b8cc3d84d26f46f36f73deb34e54371 --- sources/view/settings/VDateTime.cpp (.../VDateTime.cpp) (revision 36c82a88dbd6b4fb71528465684d51c6fbff584f) +++ sources/view/settings/VDateTime.cpp (.../VDateTime.cpp) (revision 6e18f1d24b8cc3d84d26f46f36f73deb34e54371) @@ -34,27 +34,9 @@ ACTION_VIEW_CONNECTION(HDRTCEpochData); ADJUST_VIEW_CONNECTION( AdjustTDDateTimeRequestData); ADJUST_VIEW_CONNECTION( AdjustDDDateTimeRequestData); - - connect(&_process, SIGNAL( finished(int)), - this, SLOT(onSetDateUIFinished(int))); - - connect(&_process, SIGNAL( errorOccurred(QProcess::ProcessError)), - this, SLOT(onSetDateUIErrored(QProcess::ProcessError))); } /*! - * \brief VDateTime::onSetDateUIErrored - * The slot for when the set datetime script errors, log the error - */ -void VDateTime::onSetDateUIErrored(QProcess::ProcessError error){ - QString mScript = Storage::Scripts_Path_Name(); - mScript += Storage::Date_Time_Set_Sh; - QString errorString = QString("%1 errored. Error %2").arg(mScript).arg(error); - LOG_DEBUG(errorString); - status(errorString); -} - -/*! * \brief VDateTime::doCurrentTime * Reads and displays the current date and time */ @@ -89,7 +71,7 @@ const QString &vDay , const QString &vHour , const QString &vMinute , - const bool &vNTP ) + bool vNTP ) { year ( vYear ); month ( vMonth ); @@ -100,58 +82,38 @@ _acceptTD = NOT_SET; _acceptDD = NOT_SET; - _acceptUI = NOT_SET; + _acceptUI = SUCCEED; // will get here if UI script succeeds + updateStatus(); const QDateTime currentDateTimeLocal ( QDate(_year .toInt() , _month .toInt() , _day .toInt()) , QTime(_hour .toInt() , _minute .toInt())); - const QString dateTimeLocalStr = currentDateTimeLocal.toString(_updateFormat); // sudo date -s requires this format // Get the current UTC datetime const quint32 epochUTC_sec = getEpochUTC(currentDateTimeLocal); - LOG_DEBUG(tr("SetDateTime %1").arg(dateTimeLocalStr)); status("Setting date and time ..."); - dateTimeUI(dateTimeLocalStr, vNTP ); - // only send here if NTP is not set and sending manual time. // DateTime will be sent to FW on script response of current time if ( ! vNTP ) { dateTimeTD(epochUTC_sec ); dateTimeDD(epochUTC_sec ); } -} - -/*! - * \brief VDateTime::onFinishedSetDateUI - * Called when the process that sets the UI date and time has finished. - * \param vExitCode - (int) the exit code of the process - */ -void VDateTime::onSetDateUIFinished(const int &vExitCode) -{ - if ( vExitCode ) { - _acceptUI = FAILED; - LOG_DEBUG(QString("SetDataTime[%1]").arg(vExitCode)); - } else { - _acceptUI = SUCCEED; - LOG_DEBUG("SetDateTime Succeed"); - } - updateStatus(); - - // If UI date time is set using ntp then update UI fields - // Need a short delay to wait for system clock to update first - if ( _ntp ) { + // If UI date time is set using ntp then update UI fields + // Need a short delay to wait for system clock to update first QTimer::singleShot(2000, [this]() { // Get the current UTC datetime - QDateTime currentDateTime = QDateTime::currentDateTime(); - const quint32 epochUTC_sec = getEpochUTC(currentDateTime); + const quint32 epochUTC_sec = getEpochUTC(); dateTimeTD(epochUTC_sec ); dateTimeDD(epochUTC_sec ); + + // TBD this will be updated and most likely removed in LDT-2909 when we start broadcasting the date/time + QDateTime currentDateTime = QDateTime::currentDateTime(); year ( currentDateTime.toString("yyyy") ); month ( currentDateTime.toString("MM") ); day ( currentDateTime.toString("dd") ); @@ -225,20 +187,6 @@ } /*! - * \brief VDateTime::dateTimeUI - * \details starts the shell script in a process defined in Storage::Date_Time_Set_Sh to update the device date/time - */ -void VDateTime::dateTimeUI(const QString &vDateTime, const bool &vNTP) -{ - if ( _process.state() != QProcess::NotRunning ) { return; } - QString mScript = Storage::Scripts_Path_Name(); - mScript += Storage::Date_Time_Set_Sh; - QStringList arguments; - arguments << vDateTime << (vNTP ? "true" : "false"); - _process.start(mScript, arguments); -} - -/*! * \brief VDateTime::status * \details Returns the appropriate string for the date/time adjustment status * \param vStatus - the status of the adjustment @@ -320,8 +268,7 @@ QDateTime hdRTCTime_localZone; // Default timespec is Qt::localTime / local time zoned hdRTCTime_localZone.setSecsSinceEpoch(vData.mEpoch); - const QString newDateTimeString = hdRTCTime_localZone.toString(_Settings.getDatetimeFormat()); - dateTimeUI(newDateTimeString, false); +// const QString newDateTimeString = hdRTCTime_localZone.toString(_Settings.getDatetimeFormat()); _hasDoneHDSyncRTC = true; // indicate HD-UI RTC sync'd