VirtualBox

Ignore:
Timestamp:
Apr 1, 2013 10:06:23 AM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: Message-center cleanup (part 7): Moving some code into appropriate place.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp

    r45266 r45267  
    327327}
    328328
     329#ifdef RT_OS_LINUX
     330void UIMessageCenter::warnAboutWrongUSBMounted()
     331{
     332    message(mainWindowShown(), MessageType_Warning,
     333            tr("You seem to have the USBFS filesystem mounted at /sys/bus/usb/drivers. "
     334               "We strongly recommend that you change this, as it is a severe mis-configuration of "
     335               "your system which could cause USB devices to fail in unexpected ways."),
     336            "checkForMountedWrongUSB");
     337}
     338#endif /* RT_OS_LINUX */
     339
     340void UIMessageCenter::cannotRunInSelectorMode()
     341{
     342    message(mainWindowShown(), MessageType_Critical,
     343        tr("<p>Cannot run VirtualBox in <i>VM Selector</i> "
     344           "mode due to local restrictions.</p>"
     345           "<p>The application will now terminate.</p>"));
     346}
     347
    329348void UIMessageCenter::showBETAWarning()
    330349{
     
    342361             "This version is not suitable for production use."));
    343362}
    344 
    345 void UIMessageCenter::cannotRunInSelectorMode()
    346 {
    347     message(mainWindowShown(), MessageType_Critical,
    348         tr("<p>Cannot run VirtualBox in <i>VM Selector</i> "
    349            "mode due to local restrictions.</p>"
    350            "<p>The application will now terminate.</p>"));
    351 }
    352 
    353 #ifdef RT_OS_LINUX
    354 void UIMessageCenter::checkForMountedWrongUSB()
    355 {
    356     QFile file("/proc/mounts");
    357     if (file.exists() && file.open(QIODevice::ReadOnly | QIODevice::Text))
    358     {
    359         QStringList contents;
    360         for (;;)
    361         {
    362             QByteArray line = file.readLine();
    363             if (line.isEmpty())
    364                 break;
    365             contents << line;
    366         }
    367         QStringList grep1(contents.filter("/sys/bus/usb/drivers"));
    368         QStringList grep2(grep1.filter("usbfs"));
    369         if (!grep2.isEmpty())
    370             message(mainWindowShown(), MessageType_Warning,
    371                      tr("You seem to have the USBFS filesystem mounted at /sys/bus/usb/drivers. "
    372                          "We strongly recommend that you change this, as it is a severe mis-configuration of "
    373                          "your system which could cause USB devices to fail in unexpected ways."),
    374                      "checkForMountedWrongUSB");
    375     }
    376 }
    377 #endif /* RT_OS_LINUX */
    378363
    379364void UIMessageCenter::cannotInitCOM(HRESULT rc)
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r45266 r45267  
    190190    bool askForOverridingFilesIfExists(const QVector<QString>& strPaths, QWidget *pParent = NULL);
    191191
    192     /* API: Beta warnings: */
     192    /* API: Main (startup) warnings: */
     193#ifdef RT_OS_LINUX
     194    void warnAboutWrongUSBMounted();
     195#endif /* RT_OS_LINUX */
     196    void cannotRunInSelectorMode();
    193197    void showBETAWarning();
    194198    void showBEBWarning();
    195 
    196     /* API: Common startup warnings: */
    197     void cannotRunInSelectorMode();
    198 #ifdef RT_OS_LINUX
    199     void checkForMountedWrongUSB();
    200 #endif /* RT_OS_LINUX */
    201199
    202200    /* API: COM startup warnings: */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r45193 r45267  
    39463946    return !isApprovedByExtraData(machine, GUI_HideDetails);
    39473947}
     3948
     3949#ifdef RT_OS_LINUX
     3950/* static */
     3951void VBoxGlobal::checkForWrongUSBMounted()
     3952{
     3953    /* Make sure '/proc/mounts' exists and can be opened: */
     3954    QFile file("/proc/mounts");
     3955    if (!file.exists() || !file.open(QIODevice::ReadOnly | QIODevice::Text))
     3956        return;
     3957
     3958    /* Fetch contents: */
     3959    QStringList contents;
     3960    for (;;)
     3961    {
     3962        QByteArray line = file.readLine();
     3963        if (line.isEmpty())
     3964            break;
     3965        contents << line;
     3966    }
     3967    /* Grep contents for usbfs presence: */
     3968    QStringList grep1(contents.filter("/sys/bus/usb/drivers"));
     3969    QStringList grep2(grep1.filter("usbfs"));
     3970    if (grep2.isEmpty())
     3971        return;
     3972
     3973    /* Show corresponding warning: */
     3974    msgCenter().warnAboutWrongUSBMounted();
     3975}
     3976#endif /* RT_OS_LINUX */
    39483977
    39493978// Public slots
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r45192 r45267  
    396396    static bool shouldWeShowDetails(CMachine &machine,
    397397                                    bool fIncludingMachineGeneralCheck = false);
     398
     399#ifdef RT_OS_LINUX
     400    static void checkForWrongUSBMounted();
     401#endif /* RT_OS_LINUX */
    398402
    399403signals:
  • trunk/src/VBox/Frontends/VirtualBox/src/main.cpp

    r45233 r45267  
    473473
    474474#ifdef RT_OS_LINUX
    475             msgCenter().checkForMountedWrongUSB();
     475            /* Make sure no wrong USB mounted: */
     476            VBoxGlobal::checkForWrongUSBMounted();
    476477#endif /* RT_OS_LINUX */
    477478
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