VirtualBox

Changeset 85732 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
Aug 12, 2020 8:27:43 PM (4 years ago)
Author:
vboxsync
Message:

Reverting 139878 to correct commit msg.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/HostUpdateImpl.cpp

    r85731 r85732  
    7474    /** Smart pointer to the progress object for this job. */
    7575    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. */
    7777
    7878    friend class HostUpdate;  // allow member functions access to private data
     
    403403    else
    404404    {
    405         /** @todo r=bird: trusting the server reply too much here! */
    406405        m_updateNeeded = TRUE;
    407406        m_updateVersion = lstHttpReply.at(0).c_str();
     
    420419{
    421420    LogFlowFuncEnter();
     421
    422422    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
    433428#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();
    441435#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     }
    453436
    454437    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));
    458441    LogFlowFuncLeave();
    459     return pTask->m_rc = hrc;
     442
     443    return pTask->m_rc;
    460444}
    461445
     
    511495                                ComPtr<IProgress> &aProgress)
    512496{
    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;
    525498
    526499    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     
    528501    // Check whether VirtualBox updates have been disabled before spawning the task thread.
    529502    ComPtr<ISystemProperties> pSystemProperties;
    530     HRESULT rc = mVirtualBox->COMGETTER(SystemProperties)(pSystemProperties.asOutParam());
     503    rc = mVirtualBox->COMGETTER(SystemProperties)(pSystemProperties.asOutParam());
    531504    if (FAILED(rc))
    532505        return setErrorVrc(rc, tr("%s: IVirtualBox::systemProperties() failed: %Rrc"), __FUNCTION__, rc);
     
    537510        return setErrorVrc(rc, tr("%s: retrieving ISystemProperties::VBoxUpdateEnabled failed: %Rrc"), __FUNCTION__, rc);
    538511
    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? */
    547512    if (!fVBoxUpdateEnabled)
    548513        return E_NOTIMPL;
     
    551516    rc = pProgress.createObject();
    552517    if (FAILED(rc))
     518    {
    553519        return rc;
     520    }
    554521
    555522    rc = pProgress->init(mVirtualBox,
     
    558525                         TRUE /* aCancelable */);
    559526    if (FAILED(rc))
     527    {
    560528        return rc;
     529    }
    561530
    562531    /* initialize the worker task */
     
    565534    pTask = NULL;
    566535    if (FAILED(rc))
     536    {
    567537        return rc;
     538    }
    568539
    569540    rc = pProgress.queryInterfaceTo(aProgress.asOutParam());
     
    576547    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    577548
    578     aUpdateVersion = m_updateVersion;
     549    if (m_updateVersion.isNotEmpty())
     550    {
     551        aUpdateVersion = m_updateVersion;
     552    }
    579553
    580554    return S_OK;
     
    585559    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    586560
    587     aUpdateURL = m_updateURL;
     561    if (m_updateURL.isNotEmpty())
     562    {
     563        aUpdateURL = m_updateURL;
     564    }
    588565
    589566    return S_OK;
     
    609586        return rc;
    610587
    611     /*
    612      * Is update checking enabled?
    613      */
    614588    BOOL fVBoxUpdateEnabled;
    615589    rc = pSystemProperties->COMGETTER(VBoxUpdateEnabled)(&fVBoxUpdateEnabled);
     
    623597    }
    624598
    625     /*
    626      * When was the last update?
    627      */
    628599    Bstr strVBoxUpdateLastCheckDate;
    629600    rc = pSystemProperties->COMGETTER(VBoxUpdateLastCheckDate)(strVBoxUpdateLastCheckDate.asOutParam());
     
    646617    }
    647618
    648     /*
    649      * Compare last update with how often we are supposed to check for updates.
    650      */
    651619    ULONG uVBoxUpdateFrequency = 0;  // value in days
    652620    rc = pSystemProperties->COMGETTER(VBoxUpdateFrequency)(&uVBoxUpdateFrequency);
     
    656624    if (!uVBoxUpdateFrequency)
    657625    {
    658         /* Consider config (enable, 0 day interval) as checking once but never again.
    659            We've already check since we've got a date. */
    660626        *aUpdateCheckNeeded = false;
    661627        return S_OK;
    662628    }
    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)
    672639        *aUpdateCheckNeeded = true;
    673640
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette