VirtualBox

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


Ignore:
Timestamp:
Aug 10, 2012 9:33:34 AM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
79963
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/src-server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 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.

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