VirtualBox

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


Ignore:
Timestamp:
Feb 3, 2022 1:52:21 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
149717
Message:

Main/Unattended: Extract the languages from the XML too. bugref:9781

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/UnattendedImpl.cpp

    r93580 r93581  
    197197const Utf8Str &WIMImage::formatName(Utf8Str &r_strName) const
    198198{
    199     if (mVersion.isEmpty() && mArch.isEmpty())
     199    if (mVersion.isEmpty() && mArch.isEmpty() && mDefaultLanguage.isEmpty() && mLanguages.size() == 0)
    200200        return mName;
    201201
     
    212212        fFirst = false;
    213213    }
     214    if (mDefaultLanguage.isNotEmpty())
     215    {
     216        r_strName.appendPrintf(fFirst ? " (%s" : " / %s", mDefaultLanguage.c_str());
     217        fFirst = false;
     218    }
     219    else
     220        for (size_t i = 0; i < mLanguages.size(); i++)
     221        {
     222            r_strName.appendPrintf(fFirst ? " (%s" : " / %s", mLanguages[i].c_str());
     223            fFirst = false;
     224        }
    214225    r_strName.append(")");
    215226    return r_strName;
     
    444455
    445456/**
     457 * Tries to parse a LANGUAGES element, with the following structure.
     458 * @verbatim
     459 * <LANGUAGES>
     460 *     <LANGUAGE>
     461 *         en-US
     462 *     </LANGUAGE>
     463 *     <DEFAULT>
     464 *         en-US
     465 *     </DEFAULT>
     466 * </LANGUAGES>
     467 * @endverbatim
     468 *
     469 * Will set mLanguages and mDefaultLanguage success.
     470 *
     471 * @param   pElmLanguages   Points to the LANGUAGES XML node.
     472 * @param   rImage          Out reference to an WIMImage instance.
     473 */
     474static void parseLangaguesElement(const xml::ElementNode *pElmLanguages, WIMImage &rImage)
     475{
     476    /*
     477     * The languages.
     478     */
     479    ElementNodesList children;
     480    int cChildren = pElmLanguages->getChildElements(children, "LANGUAGE");
     481    if (cChildren == 0)
     482        cChildren = pElmLanguages->getChildElements(children, "language");
     483    if (cChildren == 0)
     484        cChildren = pElmLanguages->getChildElements(children, "Language");
     485    for (ElementNodesList::iterator iterator = children.begin(); iterator != children.end(); ++iterator)
     486    {
     487        const ElementNode * const pElmLanguage = *(iterator);
     488        if (pElmLanguage)
     489        {
     490            const char *pszValue = pElmLanguage->getValue();
     491            if (pszValue && *pszValue != '\0')
     492                rImage.mLanguages.append(pszValue);
     493        }
     494    }
     495
     496    /*
     497     * Default language.
     498     */
     499    const xml::ElementNode *pElmDefault;
     500    if (   (pElmDefault = pElmLanguages->findChildElement("DEFAULT")) != NULL
     501        || (pElmDefault = pElmLanguages->findChildElement("default")) != NULL
     502        || (pElmDefault = pElmLanguages->findChildElement("Default")) != NULL)
     503        rImage.mDefaultLanguage = pElmDefault->getValue();
     504}
     505
     506
     507/**
    446508 * Tries to set the image architecture.
    447509 *
     
    454516 * Will set mArch and update mOSType on success.
    455517 *
    456  * @param   pElmArch    Points to the vesion XML node,
     518 * @param   pElmArch    Points to the ARCH XML node.
    457519 * @param   rImage      Out reference to an WIMImage instance.
    458520 */
     
    670732                || (pElmArch = pElmWindows->findChildElement("Arch")) != NULL)
    671733                parseArchElement(pElmArch, newImage);
     734
     735            /* Extract languages and default language: */
     736            const ElementNode *pElmLang;
     737            if (   (pElmLang = pElmWindows->findChildElement("LANGUAGES")) != NULL
     738                || (pElmLang = pElmWindows->findChildElement("languages")) != NULL
     739                || (pElmLang = pElmWindows->findChildElement("Languages")) != NULL)
     740                parseLangaguesElement(pElmLang, newImage);
    672741        }
    673742
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