VirtualBox

Changeset 16216 in vbox


Ignore:
Timestamp:
Jan 24, 2009 4:30:43 PM (16 years ago)
Author:
vboxsync
Message:

Main: Perform case-insensitive Guest OS type ID comparisons and support old (pre-2.1) type ID values (#3549).

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/MachineImpl.cpp

    r16174 r16216  
    902902    CheckComRCReturnRC (rc);
    903903
     904    /* when setting, always use the "etalon" value for consistency -- lookup
     905     * by ID is case-insensitive and the input value may have different case */
     906    Bstr osTypeId;
     907    rc = guestOSType->COMGETTER(Id) (osTypeId.asOutParam());
     908    CheckComRCReturnRC (rc);
     909
    904910    AutoWriteLock alock (this);
    905911
     
    908914
    909915    mUserData.backup();
    910     mUserData->mOSTypeId = aOSTypeId;
     916    mUserData->mOSTypeId = osTypeId;
    911917
    912918    return S_OK;
  • trunk/src/VBox/Main/VirtualBoxImpl.cpp

    r16040 r16216  
    13041304STDMETHODIMP VirtualBox::GetGuestOSType (IN_BSTR aId, IGuestOSType **aType)
    13051305{
    1306     CheckComArgNotNull(aType);
    1307 
    1308     AutoCaller autoCaller (this);
    1309     CheckComRCReturnRC (autoCaller.rc());
     1306    /* Old ID to new ID conversion table. See r39691 for a source */
     1307    static const wchar_t *kOldNewIDs[] =
     1308    {
     1309        L"unknown", L"Other",
     1310        L"win31", L"Windows31",
     1311        L"win95", L"Windows95",
     1312        L"win98", L"Windows98",
     1313        L"winme", L"WindowsMe",
     1314        L"winnt4", L"WindowsNT4",
     1315        L"win2k", L"Windows2000",
     1316        L"winxp", L"WindowsXP",
     1317        L"win2k3", L"Windows2003",
     1318        L"winvista", L"WindowsVista",
     1319        L"win2k8", L"Windows2008",
     1320        L"ecs", L"OS2eCS",
     1321        L"fedoracore", L"Fedora",
     1322        /* the rest is covered by the case-insensitive comparison */
     1323    };
     1324
     1325    CheckComArgNotNull (aType);
     1326
     1327    AutoCaller autoCaller (this);
     1328    CheckComRCReturnRC (autoCaller.rc());
     1329
     1330    /* first, look for a substitution */
     1331    Bstr id = aId;
     1332    for (size_t i = 0; i < RT_ELEMENTS (kOldNewIDs) / 2; i += 2)
     1333    {
     1334        if (id == kOldNewIDs [i])
     1335        {
     1336            id = kOldNewIDs [i + 1];
     1337            break;
     1338        }
     1339    }
    13101340
    13111341    *aType = NULL;
     
    13191349        const Bstr &typeId = (*it)->id();
    13201350        AssertMsg (!!typeId, ("ID must not be NULL"));
    1321         if (typeId == aId)
     1351        if (typeId.compareIgnoreCase (id) == 0)
    13221352        {
    13231353            (*it).queryInterfaceTo (aType);
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