Changeset 85731 in vbox for trunk/src/VBox/Main
- Timestamp:
- Aug 12, 2020 8:26:52 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/HostUpdateImpl.cpp
r85730 r85731 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 , at the moment. */76 HRESULT m_rc; /**< Not really used for anything outside i_updateCheckTask, 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! */ 405 406 m_updateNeeded = TRUE; 406 407 m_updateVersion = lstHttpReply.at(0).c_str(); … … 419 420 { 420 421 LogFlowFuncEnter(); 421 422 422 AutoCaller autoCaller(this); 423 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 424 425 if (pTask->m_checkType == UpdateCheckType_VirtualBox) 426 pTask->m_rc = i_checkForVBoxUpdate(); 427 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; 428 433 #if 0 429 else if (pTask->m_checkType == UpdateCheckType_ExtensionPack) 430 ; 431 else if (pTask->m_checkType == UpdateCheckType_GuestAdditions) 432 ; 433 else 434 assert(); 434 case UpdateCheckType_ExtensionPack: 435 hrc = i_checkForExtPackUpdate(); 436 break; 437 438 case UpdateCheckType_GuestAdditions: 439 hrc = i_checkForGuestAdditionsUpdate(); 440 break; 435 441 #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 } 436 453 437 454 if (!pTask->m_ptrProgress.isNull()) 438 pTask->m_ptrProgress->i_notifyComplete( pTask->m_rc);439 440 LogFlowFunc(("rc=%Rhrc\n", pTask->m_rc));455 pTask->m_ptrProgress->i_notifyComplete(hrc); 456 457 LogFlowFunc(("rc=%Rhrc\n", hrc)); 441 458 LogFlowFuncLeave(); 442 443 return pTask->m_rc; 459 return pTask->m_rc = hrc; 444 460 } 445 461 … … 495 511 ComPtr<IProgress> &aProgress) 496 512 { 497 HRESULT rc; 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 } 498 525 499 526 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); … … 501 528 // Check whether VirtualBox updates have been disabled before spawning the task thread. 502 529 ComPtr<ISystemProperties> pSystemProperties; 503 rc = mVirtualBox->COMGETTER(SystemProperties)(pSystemProperties.asOutParam());530 HRESULT rc = mVirtualBox->COMGETTER(SystemProperties)(pSystemProperties.asOutParam()); 504 531 if (FAILED(rc)) 505 532 return setErrorVrc(rc, tr("%s: IVirtualBox::systemProperties() failed: %Rrc"), __FUNCTION__, rc); … … 510 537 return setErrorVrc(rc, tr("%s: retrieving ISystemProperties::VBoxUpdateEnabled failed: %Rrc"), __FUNCTION__, rc); 511 538 539 /** @todo r=bird: Not sure if this makes sense, it should at least have a 540 * better status code and a proper error message. Also, isn't this really 541 * something the caller should check? Presumably the caller already check 542 * whther this was a good time to perform an update check (i.e. the configured 543 * time has elapsed since last check) ... 544 * 545 * It would make sense to allow performing a one-off update check even if the 546 * automatic update checking is disabled, wouldn't it? */ 512 547 if (!fVBoxUpdateEnabled) 513 548 return E_NOTIMPL; … … 516 551 rc = pProgress.createObject(); 517 552 if (FAILED(rc)) 518 {519 553 return rc; 520 }521 554 522 555 rc = pProgress->init(mVirtualBox, … … 525 558 TRUE /* aCancelable */); 526 559 if (FAILED(rc)) 527 {528 560 return rc; 529 }530 561 531 562 /* initialize the worker task */ … … 534 565 pTask = NULL; 535 566 if (FAILED(rc)) 536 {537 567 return rc; 538 }539 568 540 569 rc = pProgress.queryInterfaceTo(aProgress.asOutParam()); … … 547 576 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 548 577 549 if (m_updateVersion.isNotEmpty()) 550 { 551 aUpdateVersion = m_updateVersion; 552 } 578 aUpdateVersion = m_updateVersion; 553 579 554 580 return S_OK; … … 559 585 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 560 586 561 if (m_updateURL.isNotEmpty()) 562 { 563 aUpdateURL = m_updateURL; 564 } 587 aUpdateURL = m_updateURL; 565 588 566 589 return S_OK; … … 586 609 return rc; 587 610 611 /* 612 * Is update checking enabled? 613 */ 588 614 BOOL fVBoxUpdateEnabled; 589 615 rc = pSystemProperties->COMGETTER(VBoxUpdateEnabled)(&fVBoxUpdateEnabled); … … 597 623 } 598 624 625 /* 626 * When was the last update? 627 */ 599 628 Bstr strVBoxUpdateLastCheckDate; 600 629 rc = pSystemProperties->COMGETTER(VBoxUpdateLastCheckDate)(strVBoxUpdateLastCheckDate.asOutParam()); … … 617 646 } 618 647 648 /* 649 * Compare last update with how often we are supposed to check for updates. 650 */ 619 651 ULONG uVBoxUpdateFrequency = 0; // value in days 620 652 rc = pSystemProperties->COMGETTER(VBoxUpdateFrequency)(&uVBoxUpdateFrequency); … … 624 656 if (!uVBoxUpdateFrequency) 625 657 { 658 /* Consider config (enable, 0 day interval) as checking once but never again. 659 We've already check since we've got a date. */ 626 660 *aUpdateCheckNeeded = false; 627 661 return S_OK; 628 662 } 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) 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) 639 672 *aUpdateCheckNeeded = true; 640 673
Note:
See TracChangeset
for help on using the changeset viewer.