Changeset 85732 in vbox for trunk/src/VBox/Main/src-server
- Timestamp:
- Aug 12, 2020 8:27:43 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/HostUpdateImpl.cpp
r85731 r85732 74 74 /** Smart pointer to the progress object for this job. */ 75 75 ComObjPtr<Progress> m_ptrProgress; 76 HRESULT m_rc; /**< Not really used for anything outside i_updateCheckTask, at the moment. */76 HRESULT m_rc; /**< Not really used for anything, at the moment. */ 77 77 78 78 friend class HostUpdate; // allow member functions access to private data … … 403 403 else 404 404 { 405 /** @todo r=bird: trusting the server reply too much here! */406 405 m_updateNeeded = TRUE; 407 406 m_updateVersion = lstHttpReply.at(0).c_str(); … … 420 419 { 421 420 LogFlowFuncEnter(); 421 422 422 AutoCaller autoCaller(this); 423 HRESULT hrc = autoCaller.rc(); 424 if (SUCCEEDED(hrc)) 425 { 426 try 427 { 428 switch (pTask->m_checkType) 429 { 430 case UpdateCheckType_VirtualBox: 431 hrc = i_checkForVBoxUpdate(); 432 break; 423 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 424 425 if (pTask->m_checkType == UpdateCheckType_VirtualBox) 426 pTask->m_rc = i_checkForVBoxUpdate(); 427 433 428 #if 0 434 case UpdateCheckType_ExtensionPack: 435 hrc = i_checkForExtPackUpdate(); 436 break; 437 438 case UpdateCheckType_GuestAdditions: 439 hrc = i_checkForGuestAdditionsUpdate(); 440 break; 429 else if (pTask->m_checkType == UpdateCheckType_ExtensionPack) 430 ; 431 else if (pTask->m_checkType == UpdateCheckType_GuestAdditions) 432 ; 433 else 434 assert(); 441 435 #endif 442 default:443 hrc = setError(E_FAIL, tr("Update check type %d is not implemented"), pTask->m_checkType);444 break;445 }446 }447 catch (...)448 {449 AssertFailed();450 hrc = E_UNEXPECTED;451 }452 }453 436 454 437 if (!pTask->m_ptrProgress.isNull()) 455 pTask->m_ptrProgress->i_notifyComplete( hrc);456 457 LogFlowFunc(("rc=%Rhrc\n", hrc));438 pTask->m_ptrProgress->i_notifyComplete(pTask->m_rc); 439 440 LogFlowFunc(("rc=%Rhrc\n", pTask->m_rc)); 458 441 LogFlowFuncLeave(); 459 return pTask->m_rc = hrc; 442 443 return pTask->m_rc; 460 444 } 461 445 … … 511 495 ComPtr<IProgress> &aProgress) 512 496 { 513 /* Validate input */ 514 switch (aCheckType) 515 { 516 case UpdateCheckType_VirtualBox: 517 break; 518 case UpdateCheckType_ExtensionPack: 519 return setError(E_NOTIMPL, tr("UpdateCheckType::ExtensionPack is not implemented")); 520 case UpdateCheckType_GuestAdditions: 521 return setError(E_NOTIMPL, tr("UpdateCheckType::GuestAdditions is not implemented")); 522 default: 523 return setError(E_INVALIDARG, tr("Invalid aCheckType value %d"), aCheckType); 524 } 497 HRESULT rc; 525 498 526 499 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); … … 528 501 // Check whether VirtualBox updates have been disabled before spawning the task thread. 529 502 ComPtr<ISystemProperties> pSystemProperties; 530 HRESULTrc = mVirtualBox->COMGETTER(SystemProperties)(pSystemProperties.asOutParam());503 rc = mVirtualBox->COMGETTER(SystemProperties)(pSystemProperties.asOutParam()); 531 504 if (FAILED(rc)) 532 505 return setErrorVrc(rc, tr("%s: IVirtualBox::systemProperties() failed: %Rrc"), __FUNCTION__, rc); … … 537 510 return setErrorVrc(rc, tr("%s: retrieving ISystemProperties::VBoxUpdateEnabled failed: %Rrc"), __FUNCTION__, rc); 538 511 539 /** @todo r=bird: Not sure if this makes sense, it should at least have a540 * better status code and a proper error message. Also, isn't this really541 * something the caller should check? Presumably the caller already check542 * whther this was a good time to perform an update check (i.e. the configured543 * time has elapsed since last check) ...544 *545 * It would make sense to allow performing a one-off update check even if the546 * automatic update checking is disabled, wouldn't it? */547 512 if (!fVBoxUpdateEnabled) 548 513 return E_NOTIMPL; … … 551 516 rc = pProgress.createObject(); 552 517 if (FAILED(rc)) 518 { 553 519 return rc; 520 } 554 521 555 522 rc = pProgress->init(mVirtualBox, … … 558 525 TRUE /* aCancelable */); 559 526 if (FAILED(rc)) 527 { 560 528 return rc; 529 } 561 530 562 531 /* initialize the worker task */ … … 565 534 pTask = NULL; 566 535 if (FAILED(rc)) 536 { 567 537 return rc; 538 } 568 539 569 540 rc = pProgress.queryInterfaceTo(aProgress.asOutParam()); … … 576 547 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 577 548 578 aUpdateVersion = m_updateVersion; 549 if (m_updateVersion.isNotEmpty()) 550 { 551 aUpdateVersion = m_updateVersion; 552 } 579 553 580 554 return S_OK; … … 585 559 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 586 560 587 aUpdateURL = m_updateURL; 561 if (m_updateURL.isNotEmpty()) 562 { 563 aUpdateURL = m_updateURL; 564 } 588 565 589 566 return S_OK; … … 609 586 return rc; 610 587 611 /*612 * Is update checking enabled?613 */614 588 BOOL fVBoxUpdateEnabled; 615 589 rc = pSystemProperties->COMGETTER(VBoxUpdateEnabled)(&fVBoxUpdateEnabled); … … 623 597 } 624 598 625 /*626 * When was the last update?627 */628 599 Bstr strVBoxUpdateLastCheckDate; 629 600 rc = pSystemProperties->COMGETTER(VBoxUpdateLastCheckDate)(strVBoxUpdateLastCheckDate.asOutParam()); … … 646 617 } 647 618 648 /*649 * Compare last update with how often we are supposed to check for updates.650 */651 619 ULONG uVBoxUpdateFrequency = 0; // value in days 652 620 rc = pSystemProperties->COMGETTER(VBoxUpdateFrequency)(&uVBoxUpdateFrequency); … … 656 624 if (!uVBoxUpdateFrequency) 657 625 { 658 /* Consider config (enable, 0 day interval) as checking once but never again.659 We've already check since we've got a date. */660 626 *aUpdateCheckNeeded = false; 661 627 return S_OK; 662 628 } 663 uint64_t const cSecsInXDays = uVBoxUpdateFrequency * RT_SEC_1DAY_64; 664 665 RTTIMESPEC TimeDiff; 666 RTTimeSpecSub(RTTimeNow(&TimeDiff), &LastCheckTime); 667 668 LogRelFunc(("Checking if seconds since last check (%lld) >= Number of seconds in %lu day%s (%lld)\n", 669 RTTimeSpecGetSeconds(&TimeDiff), uVBoxUpdateFrequency, uVBoxUpdateFrequency > 1 ? "s" : "", cSecsInXDays)); 670 671 if (RTTimeSpecGetSeconds(&TimeDiff) >= (int64_t)cSecsInXDays) 629 630 ULONG ulSecondsInXDays = uVBoxUpdateFrequency /* in days */ * 24 /* hours */ * 60 /* minutes */ * 60 /* seconds */; 631 RTTIMESPEC TimeNow; 632 (void) RTTimeNow(&TimeNow); 633 PRTTIMESPEC TimeDiff = RTTimeSpecSub(&TimeNow, &LastCheckTime); 634 635 LogRelFunc(("Checking if seconds since last check (%ld) >= Number of seconds in %lu day%s (%ld)\n", 636 RTTimeSpecGetSeconds(TimeDiff), uVBoxUpdateFrequency, uVBoxUpdateFrequency > 1 ? "s" : "", ulSecondsInXDays)); 637 638 if (RTTimeSpecGetSeconds(TimeDiff) >= ulSecondsInXDays) 672 639 *aUpdateCheckNeeded = true; 673 640
Note:
See TracChangeset
for help on using the changeset viewer.