void EntryBase::UpdateEntityTime () { const auto& now = QDateTime::currentDateTime (); if (LastEntityTimeRequest_.isValid () && LastEntityTimeRequest_.secsTo (now) < 60) return; connect (Account_->GetClientConnection ()->GetEntityTimeManager (), SIGNAL (timeReceived (QXmppEntityTimeIq)), this, SLOT (handleTimeReceived (QXmppEntityTimeIq)), Qt::UniqueConnection); LastEntityTimeRequest_ = now; auto jid = GetJID (); auto timeMgr = Account_->GetClientConnection ()->GetEntityTimeManager (); if (jid.contains ('/')) { timeMgr->requestTime (jid); return; } for (const auto& variant : Variants ()) if (!variant.isEmpty ()) timeMgr->requestTime (jid + '/' + variant); }
NtpClient::NtpClient(String reqServer, int reqIntervalSeconds, NtpTimeResultDelegate delegateFunction /* = NULL */) { // init timer but do not start, correct interval set later below. autoUpdateTimer.initializeMs(NTP_DEFAULT_QUERY_INTERVAL_SECONDS * 1000, TimerDelegate(&NtpClient::requestTime, this)); timeoutTimer.initializeMs(NTP_RESPONSE_TIMEOUT_MS, TimerDelegate(&NtpClient::requestTime, this)); this->server = reqServer; this->delegateCompleted = delegateFunction; if (!delegateFunction) { autoUpdateSystemClock = true; } if (reqIntervalSeconds == 0) { setAutoQuery(false); } else { setAutoQueryInterval(reqIntervalSeconds); setAutoQuery(true); requestTime(); } }
NtpClient::NtpClient(String reqServer, int reqIntervalSeconds, NtpTimeResultCallback onTimeReceivedCb) // : NtpClient(reqServer, reqIntervalSeconds, NtpClientResultCallback (onTimeReceivedCb)) { autoUpdateTimer.initializeMs(NTP_DEFAULT_AUTO_UPDATE_INTERVAL, Delegate<void()>(&NtpClient::requestTime, this)); this->server = reqServer; this->onCompleted = onTimeReceivedCb; if (!onTimeReceivedCb) { autoUpdateSystemClock = true; } if (reqIntervalSeconds == 0) { setAutoQuery(false); } else { setAutoQueryInterval(reqIntervalSeconds); setAutoQuery(true); requestTime(); } }
NtpClient::NtpClient(String reqServer, int reqIntervalSeconds, NtpClientResultCallback delegateFunction /* = NULL */) { autoUpdateTimer.initializeMs(NTP_DEFAULT_AUTO_UPDATE_INTERVAL, Delegate<void()>(&NtpClient::requestTime, this)); this->server = reqServer; this->delegateCompleted = delegateFunction; if (!delegateFunction) { autoUpdateSystemClock = true; } if (reqIntervalSeconds == 0) { setAutoQuery(false); } else { setAutoQueryInterval(reqIntervalSeconds); setAutoQuery(true); requestTime(); } }
NtpClient::NtpClient() { autoUpdateTimer.initializeMs(NTP_DEFAULT_AUTO_UPDATE_INTERVAL, Delegate<void()>(&NtpClient::requestTime, this)); setAutoQuery(true); requestTime(); }