VirtualBox

Changeset 815 in vbox for trunk


Ignore:
Timestamp:
Feb 9, 2007 4:21:36 PM (18 years ago)
Author:
vboxsync
Message:

Main:

  • Return E_NOTIMPL for global USB filters and all other stuff when no VBOX_WITH_USB is defined (as in OSE).
  • Moved the USB Proxy Service check to Host to make it reusable both for global-related USB methods and for VM-related methods.

FE/Qt:

  • Don't show Global USB UI when USB is not available.
  • Show the "USB Proxy Service is unavailable" message box when opening both global and VM settings.
Location:
trunk/src/VBox
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxProblemReporter.h

    r779 r815  
    102102    void cannotSaveGlobalConfig (const CVirtualBox &vbox);
    103103    void cannotSetSystemProperties (const CSystemProperties &props);
     104    void cannotAccessUSB (const COMBase &obj);
    104105
    105106    void cannotCreateMachine (const CVirtualBox &vbox,
     
    113114                                    bool strict = true,
    114115                                    QWidget *parent = 0);
    115     void cannotGetUSBController (const CMachine &machine);
    116116
    117117    void cannotStartMachine (const CConsole &console);
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp

    r806 r815  
    491491}
    492492
     493void VBoxProblemReporter::cannotAccessUSB (const COMBase &obj)
     494{
     495    /* if there is no error info available, it should mean that
     496     * IMachine::GetUSBController(), IHost::GetUSBDevices() etc. just returned
     497     * E_NOTIMPL, as for the OSE version. Don't show the error message in this
     498     * case since it's normal. */
     499    COMErrorInfo errInfo = obj.errorInfo();
     500    if (obj.lastRC() == E_NOTIMPL && !errInfo.isBasicAvailable())
     501        return;
     502
     503    message (mainWindowShown(), Error,
     504             tr ("Failed to access the USB subsystem."),
     505             formatErrorInfo (errInfo),
     506             "cannotAccessUSB");
     507}
     508
    493509void VBoxProblemReporter::cannotCreateMachine (const CVirtualBox &vbox,
    494510                                               QWidget *parent /* = 0 */)
     
    555571                 .arg (machine.GetName()),
    556572             formatErrorInfo (errInfo));
    557 }
    558 
    559 void VBoxProblemReporter::cannotGetUSBController (const CMachine &machine)
    560 {
    561     /* if there is no error info available, it should mean that
    562      * IMachine::GetUSBController returned just E_NOTIMPL, as for the OSE
    563      * version. Don't show the error message in this case since it's normal. */
    564     COMErrorInfo errInfo = machine.errorInfo();
    565     if (machine.lastRC() == E_NOTIMPL && !errInfo.isBasicAvailable())
    566         return;
    567 
    568     message (mainWindowShown(), Error,
    569              tr ("Failed to access the USB controller of the virtual "
    570                  "machine <b>%1</b>.")
    571                  .arg (machine.GetName()),
    572              formatErrorInfo (errInfo),
    573              "cannotGetUSBController");
    574573}
    575574
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxGlobalSettingsDlg.ui

    r711 r815  
    10221022    <include location="local" impldecl="in implementation">VBoxUtils.h</include>
    10231023    <include location="local" impldecl="in implementation">VBoxGlobal.h</include>
     1024    <include location="local" impldecl="in implementation">VBoxProblemReporter.h</include>
    10241025    <include location="local" impldecl="in implementation">VBoxUSBFilterSettings.h</include>
    10251026</includes>
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxGlobalSettingsDlg.ui.h

    r711 r815  
    126126                                     6 /* seems that RichText adds some margin */ +
    127127                                     whatsThisLabel->fontMetrics().width ('m') * 40);
    128    
     128
    129129    /*
    130130     *  create and layout non-standard widgets
     
    215215    if (!object->isWidgetType())
    216216        return QDialog::eventFilter (object, event);
    217    
     217
    218218    QWidget *widget = static_cast <QWidget *> (object);
    219219    if (widget->topLevelWidget() != this)
     
    332332
    333333    CHost host = vboxGlobal().virtualBox().GetHost();
    334     CHostUSBDeviceFilterEnumerator en = host.GetUSBDeviceFilters().Enumerate();
    335     while (en.HasMore())
    336     {
    337         CHostUSBDeviceFilter hostFilter = en.GetNext();
    338         CUSBDeviceFilter filter = CUnknown (hostFilter);
    339         addUSBFilter (filter, false);
    340     }
    341     lvUSBFilters->setCurrentItem (lvUSBFilters->firstChild());
    342     lvUSBFilters_currentChanged (lvUSBFilters->firstChild());
    343 
    344 //    wvalXXXX->revalidate();
     334    CHostUSBDeviceFilterCollection coll = host.GetUSBDeviceFilters();
     335    if (coll.isNull())
     336    {
     337        /* disable the USB host filters category if the USB is
     338         * not available (i.e. in VirtualBox OSE) */
     339
     340        QListViewItem *usbItem = listView->findItem ("#usb", listView_Link);
     341        Assert (usbItem);
     342        usbItem->setVisible (false);
     343
     344        /* disable validators if any */
     345        pageUSB->setEnabled (false);
     346       
     347        /* Show an error message (if there is any).
     348         * This message box may be suppressed if the user wishes so. */
     349        vboxProblem().cannotAccessUSB (host);
     350    }
     351    else
     352    {
     353        CHostUSBDeviceFilterEnumerator en = coll.Enumerate();
     354        while (en.HasMore())
     355        {
     356            CHostUSBDeviceFilter hostFilter = en.GetNext();
     357            CUSBDeviceFilter filter = CUnknown (hostFilter);
     358            addUSBFilter (filter, false);
     359        }
     360        lvUSBFilters->setCurrentItem (lvUSBFilters->firstChild());
     361        lvUSBFilters_currentChanged (lvUSBFilters->firstChild());
     362    }
    345363}
    346364
     
    440458    if (!warning.isEmpty())
    441459        warningString = QString ("<font color=red>%1</font>").arg (warning);
    442    
     460
    443461    if (!warningString.isEmpty())
    444462        whatsThisLabel->setText (warningString);
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui.h

    r780 r815  
    12421242            pageUSB->setEnabled (false);
    12431243
    1244             /* If machine has something to say, show the message.
     1244            /* Show an error message (if there is any).
    12451245             * Note that we don't use the generic cannotLoadMachineSettings()
    12461246             * call here because we want this message to be suppressable. */
    1247             vboxProblem().cannotGetUSBController (machine);
     1247            vboxProblem().cannotAccessUSB (machine);
    12481248        }
    12491249        else
  • trunk/src/VBox/Main/HostImpl.cpp

    r606 r815  
    458458STDMETHODIMP Host::COMGETTER(USBDevices)(IHostUSBDeviceCollection **aUSBDevices)
    459459{
     460#ifdef VBOX_WITH_USB
    460461    if (!aUSBDevices)
    461462        return E_POINTER;
     
    463464    AutoLock alock (this);
    464465    CHECK_READY();
     466
     467    HRESULT rc = checkUSBProxyService();
     468    CheckComRCReturnRC (rc);
    465469
    466470    ComObjPtr <HostUSBDeviceCollection> collection;
     
    469473    collection.queryInterfaceTo (aUSBDevices);
    470474    return S_OK;
     475#else
     476    /* Note: The GUI depends on this method returning E_NOTIMPL with no
     477     * extended error info to indicate that USB is simply not available
     478     * (w/o treting it as a failure), for example, as in OSE */
     479    return E_NOTIMPL;
     480#endif
    471481}
    472482
    473483STDMETHODIMP Host::COMGETTER(USBDeviceFilters) (IHostUSBDeviceFilterCollection ** aUSBDeviceFilters)
    474484{
     485#ifdef VBOX_WITH_USB
    475486    if (!aUSBDeviceFilters)
    476487        return E_POINTER;
     
    478489    AutoLock alock (this);
    479490    CHECK_READY();
     491
     492    HRESULT rc = checkUSBProxyService();
     493    CheckComRCReturnRC (rc);
    480494
    481495    ComObjPtr <HostUSBDeviceFilterCollection> collection;
     
    484498    collection.queryInterfaceTo (aUSBDeviceFilters);
    485499    return S_OK;
     500#else
     501    /* Note: The GUI depends on this method returning E_NOTIMPL with no
     502     * extended error info to indicate that USB is simply not available
     503     * (w/o treting it as a failure), for example, as in OSE */
     504    return E_NOTIMPL;
     505#endif
    486506}
    487507
     
    762782STDMETHODIMP Host::CreateUSBDeviceFilter (INPTR BSTR aName, IHostUSBDeviceFilter **aFilter)
    763783{
     784#ifdef VBOX_WITH_USB
    764785    if (!aFilter)
    765786        return E_POINTER;
     
    771792    CHECK_READY();
    772793
     794    HRESULT rc = checkUSBProxyService();
     795    CheckComRCReturnRC (rc);
     796
    773797    ComObjPtr <HostUSBDeviceFilter> filter;
    774798    filter.createObject();
    775     HRESULT rc = filter->init (this, aName);
     799    rc = filter->init (this, aName);
    776800    ComAssertComRCRet (rc, rc);
    777801    rc = filter.queryInterfaceTo (aFilter);
    778802    AssertComRCReturn (rc, rc);
    779803    return S_OK;
     804#else
     805    /* Note: The GUI depends on this method returning E_NOTIMPL with no
     806     * extended error info to indicate that USB is simply not available
     807     * (w/o treting it as a failure), for example, as in OSE */
     808    return E_NOTIMPL;
     809#endif
    780810}
    781811
    782812STDMETHODIMP Host::InsertUSBDeviceFilter (ULONG aPosition, IHostUSBDeviceFilter *aFilter)
    783813{
     814#ifdef VBOX_WITH_USB
    784815    if (!aFilter)
    785816        return E_INVALIDARG;
     
    787818    AutoLock alock (this);
    788819    CHECK_READY();
     820
     821    HRESULT rc = checkUSBProxyService();
     822    CheckComRCReturnRC (rc);
    789823
    790824    ComObjPtr <HostUSBDeviceFilter> filter = getDependentChild (aFilter);
     
    798832            tr ("The given USB device filter is already in the list"));
    799833
    800     // iterate to the position...
     834    /* iterate to the position... */
    801835    USBDeviceFilterList::iterator it = mUSBDeviceFilters.begin();
    802836    std::advance (it, aPosition);
    803     // ...and insert
     837    /* ...and insert */
    804838    mUSBDeviceFilters.insert (it, filter);
    805839    filter->mInList = true;
    806840
    807     // notify the proxy (only when the filter is active)
     841    /* notify the proxy (only when the filter is active) */
    808842    if (filter->data().mActive)
    809843    {
     
    813847    }
    814848
    815     // save the global settings
     849    /* save the global settings */
    816850    alock.unlock();
    817851    return mParent->saveSettings();
     852#else
     853    /* Note: The GUI depends on this method returning E_NOTIMPL with no
     854     * extended error info to indicate that USB is simply not available
     855     * (w/o treting it as a failure), for example, as in OSE */
     856    return E_NOTIMPL;
     857#endif
    818858}
    819859
    820860STDMETHODIMP Host::RemoveUSBDeviceFilter (ULONG aPosition, IHostUSBDeviceFilter **aFilter)
    821861{
     862#ifdef VBOX_WITH_USB
    822863    if (!aFilter)
    823864        return E_POINTER;
     
    825866    AutoLock alock (this);
    826867    CHECK_READY();
     868
     869    HRESULT rc = checkUSBProxyService();
     870    CheckComRCReturnRC (rc);
    827871
    828872    if (!mUSBDeviceFilters.size())
     
    837881    ComObjPtr <HostUSBDeviceFilter> filter;
    838882    {
    839         // iterate to the position...
     883        /* iterate to the position... */
    840884        USBDeviceFilterList::iterator it = mUSBDeviceFilters.begin();
    841885        std::advance (it, aPosition);
    842         // ...get an element from there...
     886        /* ...get an element from there... */
    843887        filter = *it;
    844         // ...and remove
     888        /* ...and remove */
    845889        filter->mInList = false;
    846890        mUSBDeviceFilters.erase (it);
     
    849893    filter.queryInterfaceTo (aFilter);
    850894
    851     // notify the proxy (only when the filter is active)
     895    /* notify the proxy (only when the filter is active) */
    852896    if (filter->data().mActive)
    853897    {
     
    857901    }
    858902
    859     // save the global settings
     903    /* save the global settings */
    860904    alock.unlock();
    861905    return mParent->saveSettings();
     906#else
     907    /* Note: The GUI depends on this method returning E_NOTIMPL with no
     908     * extended error info to indicate that USB is simply not available
     909     * (w/o treting it as a failure), for example, as in OSE */
     910    return E_NOTIMPL;
     911#endif
    862912}
    863913
     
    15681618}
    15691619
     1620/**
     1621 *  Checks for the presense and status of the USB Proxy Service.
     1622 *  Returns S_OK when the Proxy is present and OK, or E_FAIL and a
     1623 *  corresponding error message otherwise. Intended to be used by methods
     1624 *  that rely on the Proxy Service availability.
     1625 *
     1626 *  @note Locks this object for reading.
     1627 */
     1628HRESULT Host::checkUSBProxyService()
     1629{
     1630#ifdef VBOX_WITH_USB
     1631    AutoLock lock (this);
     1632    CHECK_READY();
     1633
     1634    AssertReturn (mUSBProxyService, E_FAIL);
     1635    if (!mUSBProxyService->isActive())
     1636    {
     1637        /* disable the USB controller completely to avoid assertions if the
     1638         * USB proxy service could not start. */
     1639
     1640        Assert (VBOX_FAILURE (mUSBProxyService->getLastError()));
     1641        if (mUSBProxyService->getLastError() == VERR_FILE_NOT_FOUND)
     1642            return setError (E_FAIL,
     1643                tr ("Could not load the Host USB Proxy Service (%Vrc)."
     1644                    "The service might be not installed on the host computer"),
     1645                mUSBProxyService->getLastError());
     1646        else
     1647            return setError (E_FAIL,
     1648                tr ("Could not load the Host USB Proxy service (%Vrc)"),
     1649                mUSBProxyService->getLastError());
     1650    }
     1651
     1652    return S_OK;
     1653#else
     1654    return E_NOTIMPL;
     1655#endif
     1656}
     1657
    15701658#ifdef __WIN__
    15711659
  • trunk/src/VBox/Main/MachineImpl.cpp

    r779 r815  
    11201120    CheckComRCReturnRC (autoCaller.rc());
    11211121
     1122    HRESULT rc = mParent->host()->checkUSBProxyService();
     1123    CheckComRCReturnRC (rc);
     1124
    11221125    AutoReaderLock alock (this);
    1123 
    1124     USBProxyService *usbProxyService = mParent->host()->usbProxyService();
    1125     AssertReturn (usbProxyService, E_FAIL);
    1126     if (!usbProxyService->isActive())
    1127     {
    1128         /* disable the USB controller completely to avoid assertions if the
    1129          * USB proxy service could not start. */
    1130 
    1131         Assert (VBOX_FAILURE (usbProxyService->getLastError()));
    1132         if (usbProxyService->getLastError() == VERR_FILE_NOT_FOUND)
    1133             return setError (E_FAIL,
    1134                 tr ("Could not load the USB proxy service (%Vrc), "
    1135                     "the virtual USB Controller is not available."
    1136                     "The service may not be installed on the host computer"),
    1137                 usbProxyService->getLastError());
    1138         else
    1139             return setError (E_FAIL,
    1140                 tr ("Could not load the USB proxy service (%Vrc), "
    1141                     "the virtual USB Controller is not available"),
    1142                 usbProxyService->getLastError());
    1143     }
    11441126
    11451127    mUSBController.queryInterfaceTo (a_ppUSBController);
  • trunk/src/VBox/Main/include/HostImpl.h

    r1 r815  
    115115    void onUSBDeviceStateChanged (HostUSBDevice *aDevice);
    116116
     117    HRESULT checkUSBProxyService();
     118   
     119    /* must be called from under this object's lock */
    117120    USBProxyService *usbProxyService() { return mUSBProxyService; }
    118121
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