Changeset 94700 in vbox for trunk/src/VBox/Main
- Timestamp:
- Apr 25, 2022 7:53:34 AM (3 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/idl/VirtualBox.xidl
r94684 r94700 11345 11345 <interface 11346 11346 name="IUpdateAgent" extends="$unknown" 11347 uuid=" ca37acc8-420f-4c17-8131-04f07e5834c5"11347 uuid="d6c683f2-489e-4701-aa6a-d490f7bc0d7e" 11348 11348 wsmap="managed" 11349 11349 reservedMethods="2" reservedAttributes="4" … … 11528 11528 </desc> 11529 11529 </attribute> 11530 11531 <attribute name="isCheckNeeded" type="boolean" readonly="yes"> 11532 <desc> 11533 Returns @c TRUE if an update check is needed, or @c FALSE if not. 11534 11535 <note>Compares the system's current date with the last 11536 update check date and currently set check frequency.</note> 11537 </desc> 11538 </attribute> 11539 11530 11540 </interface> 11531 11541 -
trunk/src/VBox/Main/include/UpdateAgentImpl.h
r94685 r94700 165 165 HRESULT setProxyURL(const com::Utf8Str &aAddress); 166 166 HRESULT getLastCheckDate(com::Utf8Str &aData); 167 HRESULT getIsCheckNeeded(BOOL *aCheckNeeded); 167 168 /** @} */ 168 169 }; -
trunk/src/VBox/Main/src-server/UpdateAgentImpl.cpp
r94686 r94700 370 370 371 371 aDate = m->strLastCheckDate; 372 373 return S_OK; 374 } 375 376 HRESULT UpdateAgent::getIsCheckNeeded(BOOL *aCheckNeeded) 377 { 378 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 379 380 /* 381 * Is update checking enabled at all? 382 */ 383 if (!m->fEnabled) 384 { 385 *aCheckNeeded = FALSE; 386 return S_OK; 387 } 388 389 /* 390 * When was the last update? 391 */ 392 if (m->strLastCheckDate.isEmpty()) /* No prior update check performed -- do so now. */ 393 { 394 *aCheckNeeded = TRUE; 395 return S_OK; 396 } 397 398 RTTIMESPEC LastCheckTime; 399 if (!RTTimeSpecFromString(&LastCheckTime, Utf8Str(m->strLastCheckDate).c_str())) 400 { 401 *aCheckNeeded = TRUE; /* Invalid date set or error? Perform check. */ 402 return S_OK; 403 } 404 405 /* 406 * Compare last update with how often we are supposed to check for updates. 407 */ 408 if ( !m->uCheckFreqSeconds /* Paranoia */ 409 || m->uCheckFreqSeconds < RT_SEC_1DAY) /* This is the minimum we currently allow. */ 410 { 411 /* Consider config (enable, 0 day interval) as checking once but never again. 412 We've already check since we've got a date. */ 413 *aCheckNeeded = FALSE; 414 return S_OK; 415 } 416 417 uint64_t const cCheckFreqDays = m->uCheckFreqSeconds / RT_SEC_1DAY_64; 418 419 RTTIMESPEC TimeDiff; 420 RTTimeSpecSub(RTTimeNow(&TimeDiff), &LastCheckTime); 421 422 int64_t const diffLastCheckSecs = RTTimeSpecGetSeconds(&TimeDiff); 423 int64_t const diffLastCheckDays = diffLastCheckSecs / RT_SEC_1DAY_64; 424 425 /* Be as accurate as possible. */ 426 *aCheckNeeded = diffLastCheckSecs >= (int64_t)m->uCheckFreqSeconds ? TRUE : FALSE; 427 428 LogRel2(("Update agent (%s): Last update %RU64 days (%RU64 seconds) ago, check frequency is every %RU64 days (%RU64 seconds) -> Check %s\n", 429 mData.m_strName.c_str(), diffLastCheckDays, diffLastCheckSecs, cCheckFreqDays, m->uCheckFreqSeconds, 430 *aCheckNeeded ? "needed" : "not needed")); 372 431 373 432 return S_OK; … … 613 672 } 614 673 615 #if 0616 HRESULT UpdateAgent::getUpdateCheckNeeded(BOOL *aUpdateCheckNeeded)617 {618 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);619 620 HRESULT rc;621 ComPtr<ISystemProperties> pSystemProperties;622 rc = m_VirtualBox->COMGETTER(SystemProperties)(pSystemProperties.asOutParam());623 if (FAILED(rc))624 return rc;625 626 /*627 * Is update checking enabled?628 */629 BOOL fVBoxUpdateEnabled;630 rc = pSystemProperties->COMGETTER(VBoxUpdateEnabled)(&fVBoxUpdateEnabled);631 if (FAILED(rc))632 return rc;633 634 if (!fVBoxUpdateEnabled)635 {636 *aUpdateCheckNeeded = false;637 return S_OK;638 }639 640 /*641 * When was the last update?642 */643 Bstr strVBoxUpdateLastCheckDate;644 rc = pSystemProperties->COMGETTER(VBoxUpdateLastCheckDate)(strVBoxUpdateLastCheckDate.asOutParam());645 if (FAILED(rc))646 return rc;647 648 // No prior update check performed so do so now649 if (strVBoxUpdateLastCheckDate.isEmpty())650 {651 *aUpdateCheckNeeded = true;652 return S_OK;653 }654 655 // convert stored timestamp to time spec656 RTTIMESPEC LastCheckTime;657 if (!RTTimeSpecFromString(&LastCheckTime, Utf8Str(strVBoxUpdateLastCheckDate).c_str()))658 {659 *aUpdateCheckNeeded = true;660 return S_OK;661 }662 663 /*664 * Compare last update with how often we are supposed to check for updates.665 */666 ULONG uVBoxUpdateFrequency = 0; // value in days667 rc = pSystemProperties->COMGETTER(VBoxUpdateFrequency)(&uVBoxUpdateFrequency);668 if (FAILED(rc))669 return rc;670 671 if (!uVBoxUpdateFrequency)672 {673 /* Consider config (enable, 0 day interval) as checking once but never again.674 We've already check since we've got a date. */675 *aUpdateCheckNeeded = false;676 return S_OK;677 }678 uint64_t const cSecsInXDays = uVBoxUpdateFrequency * RT_SEC_1DAY_64;679 680 RTTIMESPEC TimeDiff;681 RTTimeSpecSub(RTTimeNow(&TimeDiff), &LastCheckTime);682 683 LogRelFunc(("Checking if seconds since last check (%lld) >= Number of seconds in %lu day%s (%lld)\n",684 RTTimeSpecGetSeconds(&TimeDiff), uVBoxUpdateFrequency, uVBoxUpdateFrequency > 1 ? "s" : "", cSecsInXDays));685 686 if (RTTimeSpecGetSeconds(&TimeDiff) >= (int64_t)cSecsInXDays)687 *aUpdateCheckNeeded = true;688 689 return S_OK;690 }691 #endif692 693 674 694 675 /*********************************************************************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.