VirtualBox

Changeset 42748 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Aug 10, 2012 9:33:34 AM (12 years ago)
Author:
vboxsync
Message:

Main/VirtualBox: add new method for querying normalized version (numeric version plus prerelease tag, but without publisher)
Main/SystemProperties: add new attribute for getting the default additions iso (setter is not implemented as the saving of the value is missing)
Frontends/VirtualBox: adjust accordingly
Frontends/VBoxManage: show the default additions iso name, and move the listing of most information into separate functions to make the code easier to read.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r42739 r42748  
    14241424  <interface
    14251425    name="IVirtualBox" extends="$unknown"
    1426     uuid="3b90eded-f061-432f-9e0f-4b53cc7b6fa0"
     1426    uuid="5c8814a1-2a35-402d-8680-68e5cb4e72aa"
    14271427    wsmap="managed"
    14281428    >
     
    14521452        publisher tag, at the end.  The publisher tag starts with an underscore
    14531453        just like the prerelease build type tag.
     1454      </desc>
     1455    </attribute>
     1456
     1457    <attribute name="versionNormalized" type="wstring" readonly="yes">
     1458      <desc>
     1459        A string representing the version number of the product,
     1460        without the publisher information (but still with other tags).
     1461        See <link to="#version" />.
    14541462      </desc>
    14551463    </attribute>
     
    81938201    name="ISystemProperties"
    81948202    extends="$unknown"
    8195     uuid="20fc263c-e1e9-4e86-b9b0-835950790d13"
     8203    uuid="1d7aca29-97f0-4287-9874-a60ec4f80ea6"
    81968204    wsmap="managed"
    81978205    >
     
    84478455        The path to the autostart database. Depending on the host this might
    84488456        be a filesystem path or something else.
     8457      </desc>
     8458    </attribute>
     8459
     8460    <attribute name="defaultAdditionsISO" type="wstring">
     8461      <desc>
     8462        The path to the default Guest Additions ISO image. Can be empty if
     8463        the location is not known in this installation.
    84498464      </desc>
    84508465    </attribute>
  • trunk/src/VBox/Main/include/SystemPropertiesImpl.h

    r42178 r42748  
    77
    88/*
    9  * Copyright (C) 2006-2010 Oracle Corporation
     9 * Copyright (C) 2006-2012 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4646
    4747    BEGIN_COM_MAP(SystemProperties)
    48         VBOX_DEFAULT_INTERFACE_ENTRIES (ISystemProperties)
     48        VBOX_DEFAULT_INTERFACE_ENTRIES(ISystemProperties)
    4949    END_COM_MAP()
    5050
     
    9494    STDMETHOD(COMGETTER(AutostartDatabasePath))(BSTR *aAutostartDbPath);
    9595    STDMETHOD(COMSETTER(AutostartDatabasePath))(IN_BSTR aAutostartDbPath);
     96    STDMETHOD(COMGETTER(DefaultAdditionsISO))(BSTR *aDefaultAdditionsISO);
     97    STDMETHOD(COMSETTER(DefaultAdditionsISO))(IN_BSTR aDefaultAdditionsISO);
    9698
    9799    STDMETHOD(GetMaxNetworkAdapters)(ChipsetType_T aChipset, ULONG *aMaxInstances);
     
    127129    HRESULT setDefaultVRDEExtPack(const Utf8Str &aPath);
    128130    HRESULT setAutostartDatabasePath(const Utf8Str &aPath);
     131    HRESULT setDefaultAdditionsISO(const Utf8Str &aPath);
    129132
    130133    VirtualBox * const  mParent;
  • trunk/src/VBox/Main/include/VirtualBoxImpl.h

    r42569 r42748  
    103103    /* IVirtualBox properties */
    104104    STDMETHOD(COMGETTER(Version))(BSTR *aVersion);
     105    STDMETHOD(COMGETTER(VersionNormalized))(BSTR *aVersionNormalized);
    105106    STDMETHOD(COMGETTER(Revision))(ULONG *aRevision);
    106107    STDMETHOD(COMGETTER(PackageType))(BSTR *aPackageType);
     
    246247                            GuestOSType*& pGuestOSType);
    247248
    248     const Guid& getGlobalRegistryId() const;
     249    const Guid &getGlobalRegistryId() const;
    249250
    250251    const ComObjPtr<Host>& host() const;
     
    284285    void markRegistryModified(const Guid &uuid);
    285286    void saveModifiedRegistries();
     287
     288    static const Bstr &getVersionNormalized();
    286289
    287290    static HRESULT ensureFilePathExists(const Utf8Str &strFileName, bool fCreate);
     
    329332    /* static variables (defined in VirtualBoxImpl.cpp) */
    330333    static Bstr sVersion;
     334    static Bstr sVersionNormalized;
    331335    static ULONG sRevision;
    332336    static Bstr sPackageType;
  • trunk/src/VBox/Main/src-server/SystemPropertiesImpl.cpp

    r42391 r42748  
    55
    66/*
    7  * Copyright (C) 2006-2011 Oracle Corporation
     7 * Copyright (C) 2006-2012 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    951951}
    952952
     953STDMETHODIMP SystemProperties::COMGETTER(DefaultAdditionsISO)(BSTR *aDefaultAdditionsISO)
     954{
     955    CheckComArgOutPointerValid(aDefaultAdditionsISO);
     956
     957    AutoCaller autoCaller(this);
     958    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     959
     960    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     961
     962    if (m->strDefaultAdditionsISO.isEmpty())
     963    {
     964        /* no guest additions, check if it showed up in the mean time */
     965        alock.release();
     966        {
     967            AutoWriteLock wlock(this COMMA_LOCKVAL_SRC_POS);
     968            ErrorInfoKeeper eik;
     969            (void)setDefaultAdditionsISO("");
     970        }
     971        alock.acquire();
     972    }
     973    m->strDefaultAdditionsISO.cloneTo(aDefaultAdditionsISO);
     974
     975    return S_OK;
     976}
     977
     978STDMETHODIMP SystemProperties::COMSETTER(DefaultAdditionsISO)(IN_BSTR aDefaultAdditionsISO)
     979{
     980    AutoCaller autoCaller(this);
     981    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     982
     983    /** @todo not yet implemented, settings handling is missing */
     984    ReturnComNotImplemented();
     985
     986    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     987    HRESULT rc = setDefaultAdditionsISO(aDefaultAdditionsISO);
     988    alock.release();
     989
     990    if (SUCCEEDED(rc))
     991    {
     992        // VirtualBox::saveSettings() needs vbox write lock
     993        AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
     994        rc = mParent->saveSettings();
     995    }
     996
     997    return rc;
     998}
     999
    9531000// public methods only for internal purposes
    9541001/////////////////////////////////////////////////////////////////////////////
     
    9821029    rc = setAutostartDatabasePath(data.strAutostartDatabasePath);
    9831030    if (FAILED(rc)) return rc;
     1031
     1032    {
     1033        /* must ignore errors signalled here, because the guest additions
     1034         * file may not exist, and in this case keep the empty string */
     1035        ErrorInfoKeeper eik;
     1036        (void)setDefaultAdditionsISO(data.strDefaultAdditionsISO);
     1037    }
    9841038
    9851039    return S_OK;
     
    11901244    return rc;
    11911245}
     1246
     1247HRESULT SystemProperties::setDefaultAdditionsISO(const Utf8Str &aPath)
     1248{
     1249    Utf8Str path(aPath);
     1250    if (path.isEmpty())
     1251    {
     1252        char strTemp[RTPATH_MAX];
     1253        int vrc = RTPathAppPrivateNoArch(strTemp, sizeof(strTemp));
     1254        AssertRC(vrc);
     1255        Utf8Str strSrc1 = Utf8Str(strTemp).append("/VBoxGuestAdditions.iso");
     1256
     1257        vrc = RTPathExecDir(strTemp, sizeof(strTemp));
     1258        AssertRC(vrc);
     1259        Utf8Str strSrc2 = Utf8Str(strTemp).append("/additions/VBoxGuestAdditions.iso");
     1260
     1261        vrc = RTPathUserHome(strTemp, sizeof(strTemp));
     1262        AssertRC(vrc);
     1263        Utf8Str strSrc3 = Utf8StrFmt("%s/VBoxGuestAdditions_%ls.iso", strTemp, VirtualBox::getVersionNormalized().raw());
     1264
     1265        /* Check the standard image locations */
     1266        if (RTFileExists(strSrc1.c_str()))
     1267            path = strSrc1;
     1268        else if (RTFileExists(strSrc2.c_str()))
     1269            path = strSrc2;
     1270        else if (RTFileExists(strSrc3.c_str()))
     1271            path = strSrc3;
     1272        else
     1273            return setError(E_FAIL,
     1274                            tr("Cannot determine default Guest Additions ISO location. Most likely they are not available"));
     1275    }
     1276
     1277    if (!RTPathStartsWithRoot(path.c_str()))
     1278        return setError(E_INVALIDARG,
     1279                        tr("Given default machine Guest Additions ISO file '%s' is not fully qualified"),
     1280                        path.c_str());
     1281
     1282    if (!RTFileExists(path.c_str()))
     1283        return setError(E_INVALIDARG,
     1284                        tr("Given default machine Guest Additions ISO file '%s' does not exist"),
     1285                        path.c_str());
     1286
     1287    m->strDefaultAdditionsISO = path;
     1288
     1289    return S_OK;
     1290}
  • trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp

    r42569 r42748  
    4040#include <VBox/param.h>
    4141#include <VBox/settings.h>
     42#include <VBox/version.h>
    4243
    4344#include <package-generated.h>
    44 #include <version-generated.h>
    4545
    4646#include <algorithm>
     
    9898// static
    9999Bstr VirtualBox::sVersion;
     100
     101// static
     102Bstr VirtualBox::sVersionNormalized;
    100103
    101104// static
     
    371374    if (sVersion.isEmpty())
    372375        sVersion = RTBldCfgVersion();
     376    if (sVersionNormalized.isEmpty())
     377    {
     378        Utf8Str tmp(RTBldCfgVersion());
     379        if (tmp.endsWith(VBOX_BUILD_PUBLISHER))
     380            tmp = tmp.substr(0, tmp.length() - strlen(VBOX_BUILD_PUBLISHER));
     381        sVersionNormalized = tmp;
     382    }
    373383    sRevision = RTBldCfgRevision();
    374384    if (sPackageType.isEmpty())
     
    857867
    858868    sVersion.cloneTo(aVersion);
     869    return S_OK;
     870}
     871
     872STDMETHODIMP VirtualBox::COMGETTER(VersionNormalized)(BSTR *aVersionNormalized)
     873{
     874    CheckComArgNotNull(aVersionNormalized);
     875
     876    AutoCaller autoCaller(this);
     877    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     878
     879    sVersionNormalized.cloneTo(aVersionNormalized);
    859880    return S_OK;
    860881}
     
    44664487    }
    44674488    NOREF(rc); /* XXX */
     4489}
     4490
     4491
     4492/* static */
     4493const Bstr &VirtualBox::getVersionNormalized()
     4494{
     4495    return sVersionNormalized;
    44684496}
    44694497
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