VirtualBox

Changeset 7341 in vbox


Ignore:
Timestamp:
Mar 6, 2008 6:05:00 PM (17 years ago)
Author:
vboxsync
Message:

Main/Settings: Implemented support for settings file auto-conversion at VBoxSVC startup (#2705).

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

Legend:

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

    r7340 r7341  
    8585    "<!-- innotek VirtualBox Machine Configuration -->" RTFILE_LINEFEED
    8686    "<VirtualBox xmlns=\"" VBOX_XML_NAMESPACE "\" "
    87         "version=\"" VBOX_XML_VERSION "-" VBOX_XML_PLATFORM "\">" RTFILE_LINEFEED
     87        "version=\"" VBOX_XML_VERSION_FULL "\">" RTFILE_LINEFEED
    8888    "</VirtualBox>" RTFILE_LINEFEED
    8989};
     
    12961296
    12971297    mData->mConfigFileFull.cloneTo (aFilePath);
     1298    return S_OK;
     1299}
     1300
     1301STDMETHODIMP Machine::
     1302COMGETTER(SettingsFileVersion) (BSTR *aSettingsFileVersion)
     1303{
     1304    if (!aSettingsFileVersion)
     1305        return E_INVALIDARG;
     1306
     1307    AutoCaller autoCaller (this);
     1308    CheckComRCReturnRC (autoCaller.rc());
     1309
     1310    AutoReaderLock alock (this);
     1311
     1312    mData->mSettingsFileVersion.cloneTo (aSettingsFileVersion);
    12981313    return S_OK;
    12991314}
     
    21982213
    21992214            /* save settings on success */
    2200             rc = VirtualBox::saveSettingsTree (tree, file);
     2215            rc = VirtualBox::saveSettingsTree (tree, file,
     2216                                               mData->mSettingsFileVersion);
    22012217            CheckComRCReturnRC (rc);
    22022218        }
     
    38563872        XmlTreeBackend tree;
    38573873
    3858         rc = VirtualBox::loadSettingsTree_FirstTime (tree, file);
     3874        rc = VirtualBox::loadSettingsTree_FirstTime (tree, file,
     3875                                                     mData->mSettingsFileVersion);
    38593876        CheckComRCThrowRC (rc);
    38603877
     
    51495166
    51505167        /* save the settings on success */
    5151         rc = VirtualBox::saveSettingsTree (tree, file);
     5168        rc = VirtualBox::saveSettingsTree (tree, file,
     5169                                          mData->mSettingsFileVersion);
    51525170        CheckComRCThrowRC (rc);
    51535171    }
     
    52285246
    52295247        /* save settings on success */
    5230         rc = VirtualBox::saveSettingsTree (tree, file);
     5248        rc = VirtualBox::saveSettingsTree (tree, file,
     5249                                           mData->mSettingsFileVersion);
    52315250        CheckComRCReturnRC (rc);
    52325251    }
     
    58375856
    58385857        /* save settings on success */
    5839         rc = VirtualBox::saveSettingsTree (tree, file);
     5858        rc = VirtualBox::saveSettingsTree (tree, file,
     5859                                           mData->mSettingsFileVersion);
    58405860        CheckComRCReturnRC (rc);
    58415861    }
  • trunk/src/VBox/Main/VirtualBoxImpl.cpp

    r7233 r7341  
    7878    "<!-- innotek VirtualBox Global Configuration -->" RTFILE_LINEFEED
    7979    "<VirtualBox xmlns=\"" VBOX_XML_NAMESPACE "\" "
    80         "version=\"" VBOX_XML_VERSION "-" VBOX_XML_PLATFORM "\">" RTFILE_LINEFEED
     80        "version=\"" VBOX_XML_VERSION_FULL "\">" RTFILE_LINEFEED
    8181    "  <Global>"RTFILE_LINEFEED
    8282    "    <MachineRegistry/>"RTFILE_LINEFEED
     
    9191Bstr VirtualBox::sVersion;
    9292
     93// static
     94Bstr VirtualBox::sSettingsFormatVersion;
     95
    9396// constructor / destructor
    9497/////////////////////////////////////////////////////////////////////////////
     
    139142        sVersion = VBOX_VERSION_STRING;
    140143    LogFlowThisFunc (("Version: %ls\n", sVersion.raw()));
     144
     145    if (sSettingsFormatVersion.isNull())
     146        sSettingsFormatVersion = VBOX_XML_VERSION_FULL;
     147    LogFlowThisFunc (("Settings Format Version: %ls\n",
     148                      sSettingsFormatVersion.raw()));
    141149
    142150    /* Get the VirtualBox home directory. */
     
    201209            XmlTreeBackend tree;
    202210
    203             rc = VirtualBox::loadSettingsTree_FirstTime (tree, file);
     211            rc = VirtualBox::loadSettingsTree_FirstTime (tree, file,
     212                                                         mData.mSettingsFileVersion);
    204213            CheckComRCThrowRC (rc);
    205214
     
    452461    CheckComRCReturnRC (autoCaller.rc());
    453462
     463    /* mHomeDir is const and doesn't need a lock */
    454464    mData.mHomeDir.cloneTo (aHomeFolder);
     465    return S_OK;
     466}
     467
     468STDMETHODIMP VirtualBox::COMGETTER(SettingsFilePath) (BSTR *aSettingsFilePath)
     469{
     470    if (!aSettingsFilePath)
     471        return E_INVALIDARG;
     472
     473    AutoCaller autoCaller (this);
     474    CheckComRCReturnRC (autoCaller.rc());
     475
     476    /* mCfgFile.mName is const and doesn't need a lock */
     477    mData.mCfgFile.mName.cloneTo (aSettingsFilePath);
     478    return S_OK;
     479}
     480
     481STDMETHODIMP VirtualBox::
     482COMGETTER(SettingsFileVersion) (BSTR *aSettingsFileVersion)
     483{
     484    if (!aSettingsFileVersion)
     485        return E_INVALIDARG;
     486
     487    AutoCaller autoCaller (this);
     488    CheckComRCReturnRC (autoCaller.rc());
     489
     490    AutoReaderLock alock (this);
     491
     492    mData.mSettingsFileVersion.cloneTo (aSettingsFileVersion);
     493    return S_OK;
     494}
     495
     496STDMETHODIMP VirtualBox::
     497COMGETTER(SettingsFormatVersion) (BSTR *aSettingsFormatVersion)
     498{
     499    if (!aSettingsFormatVersion)
     500        return E_INVALIDARG;
     501
     502    AutoCaller autoCaller (this);
     503    CheckComRCReturnRC (autoCaller.rc());
     504
     505    sSettingsFormatVersion.cloneTo (aSettingsFormatVersion);
    455506    return S_OK;
    456507}
     
    18801931
    18811932            /* save settings on success */
    1882             rc = VirtualBox::saveSettingsTree (tree, file);
     1933            rc = VirtualBox::saveSettingsTree (tree, file,
     1934                                               mData.mSettingsFileVersion);
    18831935            CheckComRCReturnRC (rc);
    18841936        }
     
    20892141{
    20902142    return E_NOTIMPL;
     2143}
     2144
     2145STDMETHODIMP VirtualBox::SaveSettings()
     2146{
     2147    return saveSettings();
    20912148}
    20922149
     
    37203777
    37213778        /* save the settings on success */
    3722         rc = VirtualBox::saveSettingsTree (tree, file);
     3779        rc = VirtualBox::saveSettingsTree (tree, file,
     3780                                           mData.mSettingsFileVersion);
    37233781        CheckComRCThrowRC (rc);
    37243782    }
     
    41084166 *                          values for for missing attributes that have
    41094167 *                          defaults in the XML schema.
     4168 * @param aFormatVersion    Where to store the current format version of the
     4169 *                          loaded settings tree (optional, may be NULL).
    41104170 */
    41114171/* static */
     
    41144174                                      bool aValidate,
    41154175                                      bool aCatchLoadErrors,
    4116                                       bool aAddDefaults)
     4176                                      bool aAddDefaults,
     4177                                      Utf8Str *aFormatVersion /* = NULL */)
    41174178{
    41184179    using namespace settings;
     
    41204181    try
    41214182    {
    4122         SettingsInputResolver resolver = SettingsInputResolver();
    4123 
    4124         aTree.setInputResolver (resolver);
     4183        SettingsTreeHelper helper = SettingsTreeHelper();
     4184
     4185        aTree.setInputResolver (helper);
     4186        aTree.setAutoConverter (helper);
     4187
    41254188        aTree.read (aFile, aValidate ? VBOX_XML_SCHEMA : NULL,
    41264189                    aAddDefaults ? XmlTreeBackend::Read_AddDefaults : 0);
     4190
     4191        aTree.resetAutoConverter();
    41274192        aTree.resetInputResolver();
     4193
     4194        /* on success, memorize the current settings file version or set it to
     4195         * the most recent version if no settings conversion took place. Note
     4196         * that it's not necessary to do it every time we load the settings file
     4197         * (i.e. only loadSettingsTree_FirstTime() passes a non-NULL
     4198         * aFormatVersion value) because currently we keep the settings
     4199         * files locked so that the only legal way to change the format version
     4200         * while VirtualBox is running is saveSettingsTree(). */
     4201        if (aFormatVersion != NULL)
     4202        {
     4203            *aFormatVersion = aTree.oldVersion();
     4204            if (aFormatVersion->isNull())
     4205                *aFormatVersion = VBOX_XML_VERSION_FULL;
     4206        }
    41284207    }
    41294208    catch (const EIPRTFailure &err)
     
    41594238 * throw something.
    41604239 *
    4161  * @param aTree Tree to save.
    4162  * @param aFile File to save the tree to.
     4240 * @param aTree             Tree to save.
     4241 * @param aFile             File to save the tree to.
     4242 * @param aFormatVersion    Where to store the (recent) format version of the
     4243 *                          saved settings tree on success.
    41634244 */
    41644245/* static */
    41654246HRESULT VirtualBox::saveSettingsTree (settings::TreeBackend &aTree,
    4166                                              settings::File &aFile)
     4247                                      settings::File &aFile,
     4248                                      Utf8Str &aFormatVersion)
    41674249{
    41684250    using namespace settings;
     
    41714253    {
    41724254        aTree.write (aFile);
     4255
     4256        /* set the current settings file version to the most recent version on
     4257         * success. See also VirtualBox::loadSettingsTree(). */
     4258        if (aFormatVersion != VBOX_XML_VERSION_FULL)
     4259            aFormatVersion = VBOX_XML_VERSION_FULL;
    41734260    }
    41744261    catch (const EIPRTFailure &err)
  • trunk/src/VBox/Main/VirtualBoxImplExtra.cpp

    r6124 r7341  
    3131#include "xml_SettingsConverter_xsl.h"
    3232
    33 /** 
     33/**
    3434 * Resolves external entities while parting and validating XML settings files.
    35  * 
     35 *
    3636 * @param aURI  URI of the external entity.
    3737 * @param aID   ID of the external entity (may be NULL).
    38  * 
     38 *
    3939 * @return      Input stream created using @c new or NULL to indicate
    4040 *              a wrong URI/ID pair.
    4141 */
    4242settings::Input *
    43 VirtualBox::SettingsInputResolver::resolveEntity (const char *aURI, const char *aID)
     43VirtualBox::SettingsTreeHelper::resolveEntity (const char *aURI, const char *aID)
    4444{
    4545    if (strcmp (aURI, VBOX_XML_SCHEMA_COMMON) == 0)
     
    5757    }
    5858
     59    if (strcmp (aURI, VBOX_XML_SETTINGS_CONVERTER) == 0)
     60    {
     61        return new settings::
     62            MemoryBuf ((const char *) g_ab_xml_SettingsConverter_xsl,
     63                       g_cb_xml_SettingsConverter_xsl, aURI);
     64    }
     65
    5966    AssertMsgFailed (("Unexpected entity: '%s' - knows: '%s' and '%s'\n", aURI,
    6067                      VBOX_XML_SCHEMA_COMMON, VBOX_XML_SCHEMA));
    6168    return NULL;
    6269}
     70
     71/**
     72 * Returns @true if the given tree needs to be converted using the XSLT
     73 * template identified by #templateUri(), or @false if no conversion is
     74 * required.
     75 *
     76 * The implementation normally checks for the "version" value of the
     77 * root key to determine if the conversion is necessary. The
     78 * implementation must return a string representing the old version
     79 * (before conversion) in the @c aOldVersion argument -- this string is
     80 * used by XmlTreeBackend::oldVersion() and must be non-NULL to indicate
     81 * that the conversion has been performed on the tree. The returned
     82 * string must be allocated using RTStrDup or such.
     83 *
     84 * @param aRoot                 Root settings key.
     85 * @param aOldVersionString     Old version string (allocated by
     86 *                              RTStrDup or such).
     87 */
     88bool VirtualBox::SettingsTreeHelper::
     89needsConversion (const settings::Key &aRoot, char *&aOldVersion) const
     90{
     91    if (strcmp (aRoot.name(), "VirtualBox") == 0)
     92    {
     93        const char *version = aRoot.stringValue ("version");
     94        const char *dash = strchr (version, '-');
     95        if (dash != NULL && strcmp (dash + 1, VBOX_XML_PLATFORM) == 0)
     96        {
     97            if (strcmp (version, VBOX_XML_VERSION_FULL) != 0)
     98            {
     99                /* version mismatch */
     100                aOldVersion = RTStrDup (version);
     101                return true;
     102            }
     103        }
     104    }
     105
     106    /* either the tree is invalid, or it's the other platform, or it's the same
     107     * version */
     108    return false;
     109}
     110
     111/**
     112 * Returns the URI of the XSLT template to perform the conversion.
     113 * This template will be applied to the tree if #needsConversion()
     114 * returns @c true for this tree.
     115 */
     116const char *VirtualBox::SettingsTreeHelper::templateUri() const
     117{
     118    return VBOX_XML_SETTINGS_CONVERTER;
     119}
     120
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r7283 r7341  
    877877  <interface
    878878    name="IVirtualBox" extends="$dispatched"
    879     uuid="64f652cb-7fdf-482d-ae19-4dbb289a5ca0"
     879    uuid="3d835db8-0d0b-4d3e-a83e-ed1dea86c4f5"
    880880    wsmap="managed"
    881881  >
     
    916916        places where relative paths are allowed (unless otherwise
    917917        expressly indicated).
     918      </desc>
     919    </attribute>
     920
     921                <attribute name="settingsFilePath" type="wstring" readonly="yes">
     922                        <desc>
     923                                Full name of the global settings file.
     924                                The value of this property corresponds to the value of
     925                                <link to="#homeFolder"/> plus <tt>/VirtualBox.xml</tt>.
     926                        </desc>
     927                </attribute>
     928
     929    <attribute name="settingsFileVersion" type="wstring" readonly="yes">
     930      <desc>
     931        Current version of the format of the global VirtualBox settings file
     932        (<tt>VirtualBox.xml</tt>).
     933
     934                          The version string has the following format:
     935                                <pre>x.y-platform</pre>
     936                                where <tt>x</tt> and <tt>y</tt> are the major and the minor format
     937                                versions, and <tt>platform</tt> is the platform identifier.
     938
     939        The current version usually matches the value of the
     940        <link to="#settingsFormatVersion"/> attribute unless the
     941                                settings file was created by an older version of VirtualBox and there
     942        was a change of the settings file format since then.
     943
     944        Note that VirtualBox automatically converts settings files from older
     945        versions to the most recent version when reading them (usually at
     946        VirtualBox startup) but it doesn't save the changes back until
     947                                you call a method that implicitly saves settings (such as
     948                                <link to="#setExtraData()"/>) or call <link to="#saveSettings()"/>
     949                                explicitly. Therefore, if the value of this attribute differs from the
     950                                value of <link to="#settingsFormatVersion"/>, then it
     951                                means that the settings file was converted but the result of the
     952                                conversion is not yet saved to disk.
     953
     954                                The above feature may be used by interactive front-ends to inform users
     955                                about the settings file format change and offer them to explicitly save
     956                                all converted settings files (the global and VM-specific ones),
     957                                optionally create bacup copies of the old settings files before saving,
     958                                etc.
     959
     960        <see>settingsFormatVersion</see>
     961      </desc>
     962    </attribute>
     963
     964    <attribute name="settingsFormatVersion" type="wstring" readonly="yes">
     965      <desc>
     966        Most recent version of the settings file format.
     967
     968                          The version string has the following format:
     969                                <pre>x.y-platform</pre>
     970                                where <tt>x</tt> and <tt>y</tt> are the major and the minor format
     971                                versions, and <tt>platform</tt> is the platform identifier.
     972
     973                                VirtualBox uses this version of the format when saving settings files
     974                                (either as a result of method calls that require to save settings or as
     975                                a result of an explicit call to <link to="#saveSettings()"/>).
     976
     977                                <see>settingsFileVersion</see>
    918978      </desc>
    919979    </attribute>
     
    20292089    </method>
    20302090
     2091                <method name="saveSettings">
     2092                        <desc>
     2093                                Saves the global settings to the global settings file
     2094                                (<link to="#settingsFilePath"/>).
     2095
     2096                                This method is only useful for explicitly saving the global settings
     2097                                file after it has been auto-converted from the old format to the most
     2098                                recent format (see <link to="#settingsFileVersion"/> for details).
     2099                                Normally, the global settings file is implicitly saved when a global
     2100                                setting is changed.
     2101                        </desc>
     2102                </method>
     2103
    20312104  </interface>
    20322105
     
    23572430  <interface
    23582431     name="IMachine" extends="$unknown"
    2359      uuid="2830ce8c-be5b-4660-b8d5-65d913005b4f"
     2432     uuid="c929abcc-5373-4ed9-9b56-201430b37868"
    23602433     wsmap="managed"
    23612434     >
     
    26542727    </attribute>
    26552728
     2729                <attribute name="settingsFileVersion" type="wstring" readonly="yes">
     2730                        <desc>
     2731                                Current version of the format of the settings file of this machine
     2732                                (<link to="#settingsFilePath"/>).
     2733
     2734                                The version string has the following format:
     2735                                <pre>x.y-platform</pre>
     2736                                where <tt>x</tt> and <tt>y</tt> are the major and the minor format
     2737                                versions, and <tt>platform</tt> is the platform identifier.
     2738
     2739                                The current version usually matches the value of the
     2740                                <link to="IVirtualBox::settingsFormatVersion"/> attribute unless the
     2741                                settings file was created by an older version of VirtualBox and there
     2742                                was a change of the settings file format since then.
     2743
     2744                                Note that VirtualBox automatically converts settings files from older
     2745                                versions to the most recent version when reading them (usually at
     2746                                VirtualBox startup) but it doesn't save the changes back until
     2747                                you call a method that implicitly saves settings (such as
     2748                                <link to="#setExtraData()"/>) or call <link to="#saveSettings()"/>
     2749                                explicitly. Therefore, if the value of this attribute differs from the
     2750                                value of <link to="IVirtualBox::settingsFormatVersion"/>, then it
     2751                                means that the settings file was converted but the result of the
     2752                                conversion is not yet saved to disk.
     2753
     2754                                The above feature may be used by interactive front-ends to inform users
     2755                                about the settings file format change and offer them to explicitly save
     2756                                all converted settings files (the global and VM-specific ones),
     2757                                optionally create bacup copies of the old settings files before saving,
     2758                                etc.
     2759
     2760                                <see>IVirtualBox::settingsFormatVersion</see>
     2761                        </desc>
     2762                </attribute>
     2763
    26562764    <attribute name="settingsModified" type="boolean" readonly="yes">
    26572765      <desc>
  • trunk/src/VBox/Main/include/MachineImpl.h

    r7207 r7341  
    137137        Bstr mConfigFile;
    138138        Bstr mConfigFileFull;
     139
     140        Utf8Str mSettingsFileVersion;
    139141
    140142        BOOL mAccessible;
     
    465467    STDMETHOD(COMGETTER(USBController)) (IUSBController * *aUSBController);
    466468    STDMETHOD(COMGETTER(SettingsFilePath)) (BSTR *aFilePath);
     469    STDMETHOD(COMGETTER(SettingsFileVersion)) (BSTR *aSettingsFileVersion);
    467470    STDMETHOD(COMGETTER(SettingsModified)) (BOOL *aModified);
    468471    STDMETHOD(COMGETTER(SessionState)) (SessionState_T *aSessionState);
  • trunk/src/VBox/Main/include/VirtualBoxImpl.h

    r6909 r7341  
    109109    STDMETHOD(COMGETTER(Version)) (BSTR *aVersion);
    110110    STDMETHOD(COMGETTER(HomeFolder)) (BSTR *aHomeFolder);
     111    STDMETHOD(COMGETTER(SettingsFilePath)) (BSTR *aSettingsFilePath);
     112    STDMETHOD(COMGETTER(SettingsFileVersion)) (BSTR *aSettingsFileVersion);
     113    STDMETHOD(COMGETTER(SettingsFormatVersion)) (BSTR *aSettingsFormatVersion);
    111114    STDMETHOD(COMGETTER(Host)) (IHost **aHost);
    112115    STDMETHOD(COMGETTER(SystemProperties)) (ISystemProperties **aSystemProperties);
     
    179182                                      BSTR *aChanged, BSTR *aValues);
    180183
     184    STDMETHOD(SaveSettings)();
     185
    181186    /* public methods only for internal purposes */
    182187
     
    257262    const Bstr &settingsFileName() { return mData.mCfgFile.mName; }
    258263
    259     class SettingsInputResolver : public settings::XmlTreeBackend::InputResolver
     264    class SettingsTreeHelper : public settings::XmlTreeBackend::InputResolver
     265                             , public settings::XmlTreeBackend::AutoConverter
    260266    {
    261267    public:
    262268
     269        // InputResolver interface
    263270        settings::Input *resolveEntity (const char *aURI, const char *aID);
     271
     272        // AutoConverter interface
     273        bool needsConversion (const settings::Key &aRoot, char *&aOldVersion) const;
     274        const char *templateUri() const;
    264275    };
    265276
     
    268279                                     bool aValidate,
    269280                                     bool aCatchLoadErrors,
    270                                      bool aAddDefaults);
     281                                     bool aAddDefaults,
     282                                     Utf8Str *aFormatVersion = NULL);
    271283
    272284    /**
     
    275287     * Used when the settings file is to be loaded for the first time for the
    276288     * given object in order to recreate it from the stored settings.
     289     *
     290     * @param aFormatVersion Where to store the current format version of the
     291     *                       loaded settings tree.
    277292     */
    278293    static HRESULT loadSettingsTree_FirstTime (settings::XmlTreeBackend &aTree,
    279                                                settings::File &aFile)
    280     {
    281         return loadSettingsTree (aTree, aFile, true, true, true);
     294                                               settings::File &aFile,
     295                                               Utf8Str &aFormatVersion)
     296    {
     297        return loadSettingsTree (aTree, aFile, true, true, true,
     298                                 &aFormatVersion);
    282299    }
    283300
     
    310327
    311328    static HRESULT saveSettingsTree (settings::TreeBackend &aTree,
    312                                      settings::File &aFile);
     329                                     settings::File &aFile,
     330                                     Utf8Str &aFormatVersion);
    313331
    314332    static HRESULT handleUnexpectedExceptions (RT_SRC_POS_DECL);
     
    389407
    390408        CfgFile mCfgFile;
     409
     410        Utf8Str mSettingsFileVersion;
    391411
    392412        MachineList mMachines;
     
    445465
    446466    static Bstr sVersion;
     467    static Bstr sSettingsFormatVersion;
    447468
    448469    static DECLCALLBACK(int) ClientWatcher (RTTHREAD thread, void *pvUser);
  • trunk/src/VBox/Main/include/VirtualBoxXMLUtil.h

    r6076 r7341  
    2424#define VBOX_XML_NAMESPACE      "http://www.innotek.de/VirtualBox-settings"
    2525
     26/** VirtualBox XML settings version number substring ("x.y")  */
    2627#define VBOX_XML_VERSION "1.2"
    2728
    28 /** VirtualBox XML settings version string */
     29/** VirtualBox XML settings version platform substring */
    2930#if defined (RT_OS_DARWIN)
    3031#   define VBOX_XML_PLATFORM     "macosx"
     
    4748#endif
    4849
     50/** VirtualBox XML settings full version string ("x.y-platform") */
     51#define VBOX_XML_VERSION_FULL   VBOX_XML_VERSION "-" VBOX_XML_PLATFORM
     52
    4953/** VirtualBox XML common settings version string */
    5054#define VBOX_XML_PLATFORM_COMMON  "common"
     
    5458#define VBOX_XML_SCHEMA_COMMON  "VirtualBox-settings-" VBOX_XML_PLATFORM_COMMON ".xsd"
    5559
     60/** VirtualBox XML settings converter file */
     61#define VBOX_XML_SETTINGS_CONVERTER "SettingsConverter.xsl"
     62
    5663#endif /* ____H_VIRTUALBOXXMLUTIL */
  • trunk/src/VBox/Main/xml/SettingsConverter.xsl

    r5999 r7341  
    77 *  Template to convert old VirtualBox settings files to the most recent format.
    88
    9      Copyright (C) 2006-2007 innotek GmbH
    10    
     9     Copyright (C) 2006-2008 innotek GmbH
     10
    1111     This file is part of VirtualBox Open Source Edition (OSE), as
    1212     available from http://www.virtualbox.org. This file is free software;
     
    3030<xsl:variable name="recentVer" select="1.2"/>
    3131
    32 <xsl:variable name="curVer" select="substring-before(/VirtualBox/@version, '-')"/>
    33 <xsl:variable name="curVerPlat" select="substring-after(/VirtualBox/@version, '-')"/>
    34 <xsl:variable name="curVerFull" select="/VirtualBox/@version"/>
     32<xsl:variable name="curVer" select="substring-before(/vb:VirtualBox/@version, '-')"/>
     33<xsl:variable name="curVerPlat" select="substring-after(/vb:VirtualBox/@version, '-')"/>
     34<xsl:variable name="curVerFull" select="/vb:VirtualBox/@version"/>
    3535
    3636<xsl:template match="/">
    37   <xsl:text>&#x0A;</xsl:text>
    38   <xsl:comment> Automatically converted from version <xsl:value-of select="$curVerFull"/> to version <xsl:value-of select="$recentVer"/> </xsl:comment>
    39   <xsl:text>&#x0A;</xsl:text>
     37  <xsl:comment> Automatically converted from version '<xsl:value-of select="$curVerFull"/>' to version '<xsl:value-of select="concat($recentVer,'-',$curVerPlat)"/>' </xsl:comment>
    4038  <xsl:copy>
    4139    <xsl:apply-templates select="@*|node()"/>
     
    4846<xsl:template match="/comment()">
    4947  <xsl:copy-of select="."/>
    50   <xsl:text>&#x0A;</xsl:text>
    5148</xsl:template>
    5249
     
    6259
    6360<!--
    64  *  Forbid unsupported VirtualBox settings versions
     61 *  Forbid all unsupported VirtualBox settings versions
    6562-->
    6663
    67 <xsl:template match="/VirtualBox">
     64<xsl:template match="/vb:VirtualBox">
    6865  <xsl:if test="@version=concat($recentVer,'-',$curVerPlat)">
    69   <xsl:message terminate="yes">
    70 Cannot convert from version <xsl:value-of select="@version"/> to version <xsl:value-of select="$recentVer"/>!
     66    <xsl:message terminate="yes">
     67Cannot convert settings from version '<xsl:value-of select="@version"/>' to version '<xsl:value-of select="concat($recentVer,'-',$curVerPlat)"/>'.
    7168The source is already at the most recent version.
    72   </xsl:message>
     69    </xsl:message>
    7370  </xsl:if>
    7471  <xsl:message terminate="yes">
    75 Cannot convert from version <xsl:value-of select="@version"/> to version <xsl:value-of select="$recentVer"/>!
     72Cannot convert settings from version '<xsl:value-of select="@version"/>' to version '<xsl:value-of select="concat($recentVer,'-',$curVerPlat)"/>'.
    7673The source version is not supported.
    7774  </xsl:message>
     
    7976
    8077<!--
    81  *  Accept supported settings versions
     78 *  Accept supported settings versions (source setting filess to convert)
    8279-->
    83 <xsl:template match="/VirtualBox[@version='1.1-windows' or
    84                                  @version='1.1-linux']">
     80
     81<!-- @todo temporary -->
     82<xsl:template match="/vb:VirtualBox[substring-before(@version,'-')='1.999']">
     83  <xsl:copy>
     84    <xsl:attribute name="version"><xsl:value-of select="concat($recentVer,'-',$curVerPlat)"/></xsl:attribute>
     85    <xsl:apply-templates select="node()"/>
     86  </xsl:copy>
     87</xsl:template>
     88
     89<xsl:template match="/vb:VirtualBox[substring-before(@version,'-')='1.1']">
    8590  <xsl:copy>
    8691    <xsl:attribute name="version"><xsl:value-of select="concat($recentVer,'-',$curVerPlat)"/></xsl:attribute>
     
    9196<!--
    9297 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    93  *  Individual convertions
     98 *  Individual conversions
    9499 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    95100-->
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