VirtualBox

Changeset 42129 in vbox


Ignore:
Timestamp:
Jul 12, 2012 5:32:31 PM (13 years ago)
Author:
vboxsync
Message:

Main/VirtualBox+Machine: add support for VM groups (incomplete, saving of settings is not implemented), remaining code adjusted accordingly, use better parameter checking macros, make XSLT generators process setter attributes using safearrays correctly, various cleanups and warning fixes
Frontends/VBoxManage: first traces of groups support

Location:
trunk
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/settings.h

    r41914 r42129  
    1818
    1919/*
    20  * Copyright (C) 2007-2011 Oracle Corporation
     20 * Copyright (C) 2007-2012 Oracle Corporation
    2121 *
    2222 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    100100
    101101typedef std::map<com::Utf8Str, com::Utf8Str> StringsMap;
     102typedef std::list<com::Utf8Str> StringsList;
    102103
    103104// ExtraDataItem (used by both VirtualBox.xml and machines XML)
     
    10151016          uFaultToleranceInterval(0),
    10161017          fRTCUseUTC(false)
    1017     { }
     1018    {
     1019        llGroups.push_back("/");
     1020    }
    10181021
    10191022    bool operator==(const MachineUserData &c) const
     
    10391042    bool                    fNameSync;
    10401043    com::Utf8Str            strDescription;
     1044    StringsList             llGroups;
    10411045    com::Utf8Str            strOsType;
    10421046    com::Utf8Str            strSnapshotFolder;
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp

    r42125 r42129  
    815815    if (rc == VERR_GETOPT_UNKNOWN_OPTION)
    816816        return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Unknown option: %s", pValueUnion->psz);
     817    if (rc == VERR_GETOPT_INVALID_ARGUMENT_FORMAT)
     818        return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid argument format: %s", pValueUnion->psz);
    817819    if (pValueUnion->pDef)
    818820        return RTMsgErrorExit(RTEXITCODE_SYNTAX, "%s: %Rrs", pValueUnion->pDef->pszLong, rc);
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp

    r41915 r42129  
    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
     
    382382    } while (0)
    383383
     384#define SHOW_STRINGARRAY_PROP(a_pObj, a_Prop, a_szMachine, a_szHuman) \
     385    do \
     386    { \
     387        SafeArray<BSTR> array; \
     388        CHECK_ERROR2_RET(a_pObj, COMGETTER(a_Prop)(ComSafeArrayAsOutParam(array)), hrcCheck); \
     389        Utf8Str str; \
     390        for (size_t i = 0; i < array.size(); i++) \
     391        { \
     392            if (i != 0) \
     393                str.append(","); \
     394            str.append(Utf8Str(array[i]).c_str()); \
     395        } \
     396        Bstr bstr(str); \
     397        if (details == VMINFO_MACHINEREADABLE) \
     398            outputMachineReadableString(a_szMachine, &bstr); \
     399        else \
     400            RTPrintf("%-16s %ls\n", a_szHuman ":", bstr.raw()); \
     401    } while (0)
     402
    384403#define SHOW_UUID_PROP(a_pObj, a_Prop, a_szMachine, a_szHuman) \
    385404    SHOW_STRING_PROP(a_pObj, a_Prop, a_szMachine, a_szHuman)
     
    470489    ComPtr<IGuestOSType> osType;
    471490    CHECK_ERROR2_RET(virtualBox, GetGuestOSType(osTypeId.raw(), osType.asOutParam()), hrcCheck);
     491    SHOW_STRINGARRAY_PROP( machine, Groups,                     "groups",               "Groups");
    472492    SHOW_STRING_PROP(       osType, Description,                "ostype",               "Guest OS");
    473493    SHOW_UUID_PROP(        machine, Id,                         "UUID",                 "UUID");
     
    13201340            {
    13211341                ULONG ulIRQ, ulIOBase;
    1322                 PortMode_T HostMode;
    13231342                Bstr path;
    1324                 BOOL fServer;
    13251343                lpt->COMGETTER(IRQ)(&ulIRQ);
    13261344                lpt->COMGETTER(IOBase)(&ulIOBase);
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp

    r39888 r42129  
    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
     
    171171}
    172172
     173static const RTGETOPTDEF g_aCreateVMOptions[] =
     174{
     175    { "--name",           'n', RTGETOPT_REQ_STRING },
     176    { "-name",            'n', RTGETOPT_REQ_STRING },
     177    { "--groups",         'g', RTGETOPT_REQ_STRING },
     178    { "--basefolder",     'p', RTGETOPT_REQ_STRING },
     179    { "-basefolder",      'p', RTGETOPT_REQ_STRING },
     180    { "--ostype",         'o', RTGETOPT_REQ_STRING },
     181    { "-ostype",          'o', RTGETOPT_REQ_STRING },
     182    { "--uuid",           'u', RTGETOPT_REQ_UUID },
     183    { "-uuid",            'u', RTGETOPT_REQ_UUID },
     184    { "--register",       'r', RTGETOPT_REQ_NOTHING },
     185    { "-register",        'r', RTGETOPT_REQ_NOTHING },
     186};
     187
    173188int handleCreateVM(HandlerArg *a)
    174189{
    175190    HRESULT rc;
    176     Bstr baseFolder;
    177     Bstr name;
    178     Bstr osTypeId;
    179     RTUUID id;
     191    Bstr bstrBaseFolder;
     192    Bstr bstrName;
     193    Bstr bstrGroups;
     194    Bstr bstrOsTypeId;
     195    Bstr bstrUuid;
    180196    bool fRegister = false;
    181197
    182     RTUuidClear(&id);
    183     for (int i = 0; i < a->argc; i++)
    184     {
    185         if (   !strcmp(a->argv[i], "--basefolder")
    186             || !strcmp(a->argv[i], "-basefolder"))
    187         {
    188             if (a->argc <= i + 1)
    189                 return errorArgument("Missing argument to '%s'", a->argv[i]);
    190             i++;
    191             baseFolder = a->argv[i];
    192         }
    193         else if (   !strcmp(a->argv[i], "--name")
    194                  || !strcmp(a->argv[i], "-name"))
    195         {
    196             if (a->argc <= i + 1)
    197                 return errorArgument("Missing argument to '%s'", a->argv[i]);
    198             i++;
    199             name = a->argv[i];
    200         }
    201         else if (   !strcmp(a->argv[i], "--ostype")
    202                  || !strcmp(a->argv[i], "-ostype"))
    203         {
    204             if (a->argc <= i + 1)
    205                 return errorArgument("Missing argument to '%s'", a->argv[i]);
    206             i++;
    207             osTypeId = a->argv[i];
    208         }
    209         else if (   !strcmp(a->argv[i], "--uuid")
    210                  || !strcmp(a->argv[i], "-uuid"))
    211         {
    212             if (a->argc <= i + 1)
    213                 return errorArgument("Missing argument to '%s'", a->argv[i]);
    214             i++;
    215             if (RT_FAILURE(RTUuidFromStr(&id, a->argv[i])))
    216                 return errorArgument("Invalid UUID format %s\n", a->argv[i]);
    217         }
    218         else if (   !strcmp(a->argv[i], "--register")
    219                  || !strcmp(a->argv[i], "-register"))
    220         {
    221             fRegister = true;
    222         }
    223         else
    224             return errorSyntax(USAGE_CREATEVM, "Invalid parameter '%s'", Utf8Str(a->argv[i]).c_str());
     198    int c;
     199    RTGETOPTUNION ValueUnion;
     200    RTGETOPTSTATE GetState;
     201    // start at 0 because main() has hacked both the argc and argv given to us
     202    RTGetOptInit(&GetState, a->argc, a->argv, g_aCreateVMOptions, RT_ELEMENTS(g_aCreateVMOptions),
     203                 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
     204    while ((c = RTGetOpt(&GetState, &ValueUnion)))
     205    {
     206        switch (c)
     207        {
     208            case 'n':   // --name
     209                bstrName = ValueUnion.psz;
     210                break;
     211
     212            case 'g':   // --groups
     213                bstrGroups = ValueUnion.psz;
     214                /// @todo implement group string parsing to safearray
     215                break;
     216
     217            case 'p':   // --basefolder
     218                bstrBaseFolder = ValueUnion.psz;
     219                break;
     220
     221            case 'o':   // --ostype
     222                bstrOsTypeId = ValueUnion.psz;
     223                break;
     224
     225            case 'u':   // --uuid
     226                bstrUuid = Guid(ValueUnion.Uuid).toUtf16().raw();
     227                break;
     228
     229            case 'r':   // --register
     230                fRegister = true;
     231                break;
     232
     233            default:
     234                return errorGetOpt(USAGE_CREATEVM, c, &ValueUnion);
     235        }
    225236    }
    226237
    227238    /* check for required options */
    228     if (name.isEmpty())
     239    if (bstrName.isEmpty())
    229240        return errorSyntax(USAGE_CREATEVM, "Parameter --name is required");
    230241
     
    233244        Bstr bstrSettingsFile;
    234245        CHECK_ERROR_BREAK(a->virtualBox,
    235                           ComposeMachineFilename(name.raw(),
    236                                                  baseFolder.raw(),
     246                          ComposeMachineFilename(bstrName.raw(),
     247                                                 NULL /* aGroup */,
     248                                                 bstrBaseFolder.raw(),
    237249                                                 bstrSettingsFile.asOutParam()));
    238250        ComPtr<IMachine> machine;
    239251        CHECK_ERROR_BREAK(a->virtualBox,
    240252                          CreateMachine(bstrSettingsFile.raw(),
    241                                         name.raw(),
    242                                         osTypeId.raw(),
    243                                         Guid(id).toUtf16().raw(),
     253                                        bstrName.raw(),
     254                                        NULL /* aGroups */,
     255                                        bstrOsTypeId.raw(),
     256                                        bstrUuid.raw(),
    244257                                        FALSE /* forceOverwrite */,
    245258                                        machine.asOutParam()));
     
    257270                 "UUID: %s\n"
    258271                 "Settings file: '%ls'\n",
    259                  name.raw(), fRegister ? " and registered" : "",
     272                 bstrName.raw(), fRegister ? " and registered" : "",
    260273                 Utf8Str(uuid).c_str(), settingsFile.raw());
    261274    }
     
    269282    { "--snapshot",       's', RTGETOPT_REQ_STRING },
    270283    { "--name",           'n', RTGETOPT_REQ_STRING },
     284    { "--groups",         'g', RTGETOPT_REQ_STRING },
    271285    { "--mode",           'm', RTGETOPT_REQ_STRING },
    272286    { "--options",        'o', RTGETOPT_REQ_STRING },
    273287    { "--register",       'r', RTGETOPT_REQ_NOTHING },
    274288    { "--basefolder",     'p', RTGETOPT_REQ_STRING },
    275     { "--uuid",           'u', RTGETOPT_REQ_STRING },
     289    { "--uuid",           'u', RTGETOPT_REQ_UUID },
    276290};
    277291
     
    332346    com::SafeArray<CloneOptions_T> options;
    333347    const char                    *pszTrgName       = NULL;
     348    const char                    *pszTrgGroups     = NULL;
    334349    const char                    *pszTrgBaseFolder = NULL;
    335350    bool                           fRegister        = false;
     
    350365                break;
    351366
     367            case 'n':   // --name
     368                pszTrgName = ValueUnion.psz;
     369                break;
     370
     371            case 'g':   // --groups
     372                pszTrgGroups = ValueUnion.psz;
     373                /// @todo implement group string parsing to safearray
     374                break;
     375
     376            case 'p':   // --basefolder
     377                pszTrgBaseFolder = ValueUnion.psz;
     378                break;
     379
    352380            case 'm':   // --mode
    353381                if (RT_FAILURE(parseCloneMode(ValueUnion.psz, &mode)))
     
    360388                break;
    361389
    362             case 'n':   // --name
    363                 pszTrgName = ValueUnion.psz;
    364                 break;
    365 
    366             case 'p':   // --basefolder
    367                 pszTrgBaseFolder = ValueUnion.psz;
    368                 break;
    369 
    370390            case 'u':   // --uuid
    371                 RTUUID trgUuid;
    372                 if (RT_FAILURE(RTUuidFromStr(&trgUuid, ValueUnion.psz)))
    373                     return errorArgument("Invalid UUID format %s\n", ValueUnion.psz);
    374                 else
    375                     bstrUuid = Guid(trgUuid).toUtf16().raw();
     391                bstrUuid = Guid(ValueUnion.Uuid).toUtf16().raw();
    376392                break;
    377393
     
    421437    CHECK_ERROR_RET(a->virtualBox,
    422438                    ComposeMachineFilename(Bstr(pszTrgName).raw(),
     439                                           NULL /* aGroup */,
    423440                                           Bstr(pszTrgBaseFolder).raw(),
    424441                                           bstrSettingsFile.asOutParam()),
     
    428445    CHECK_ERROR_RET(a->virtualBox, CreateMachine(bstrSettingsFile.raw(),
    429446                                                 Bstr(pszTrgName).raw(),
     447                                                 NULL /* aGroups */,
    430448                                                 NULL,
    431449                                                 bstrUuid.raw(),
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVM.cpp

    r41591 r42129  
    113113
    114114    /* Create a new machine object. */
    115     const QString &strSettingsFile = vbox.ComposeMachineFilename(strName, QString::null);
    116     CMachine cloneMachine = vbox.CreateMachine(strSettingsFile, strName, QString::null, QString::null, false);
     115    const QString &strSettingsFile = vbox.ComposeMachineFilename(strName, QString::null /**< @todo group support */, QString::null);
     116    CMachine cloneMachine = vbox.CreateMachine(strSettingsFile, strName, QVector<QString>(), QString::null, QString::null, false);
    117117    if (!vbox.isOk())
    118118    {
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.cpp

    r41689 r42129  
    6262    if (m_machine.isNull())
    6363    {
    64         m_machine = vbox.CreateMachine(QString(), field("name").toString(), strTypeId, QString(), false);
     64        m_machine = vbox.CreateMachine(QString(), field("name").toString(), QVector<QString>() /**< @todo group support */, strTypeId, QString(), false);
    6565        if (!vbox.isOk())
    6666        {
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic1.cpp

    r41587 r42129  
    183183    QString strDefaultMachinesFolder = vbox.GetSystemProperties().GetDefaultMachineFolder();
    184184    /* Compose machine filename: */
    185     QString strMachineFilename = vbox.ComposeMachineFilename(m_pNameAndSystemEditor->name(), strDefaultMachinesFolder);
     185    QString strMachineFilename = vbox.ComposeMachineFilename(m_pNameAndSystemEditor->name(), QString::null /**< @todo group support */, strDefaultMachinesFolder);
    186186    /* Compose machine folder/basename: */
    187187    QFileInfo fileInfo(strMachineFilename);
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r42125 r42129  
    13981398  <interface
    13991399    name="IVirtualBox" extends="$unknown"
    1400     uuid="867664ba-41ce-4099-a10d-b7a8e34057c7"
     1400    uuid="53789455-fad2-425a-94c8-eb6dc4ceaa05"
    14011401    wsmap="managed"
    14021402    >
     
    14951495    </attribute>
    14961496
     1497    <attribute name="machineGroups" type="wstring" readonly="yes" safearray="yes">
     1498      <desc>
     1499        Array of all machine group names which are used by the machines which
     1500        are accessible. Each group is only listed once, however they are listed
     1501        in no particular order and there is no guarantee that there are no gaps
     1502        in the group hierarchy (i.e. "/", "/group/subgroup" is a valid result).
     1503      </desc>
     1504    </attribute>
     1505
    14971506    <attribute name="hardDisks" type="IMedium" readonly="yes" safearray="yes">
    14981507      <desc>
     
    15821591
    15831592        <ul>
    1584           <li>It gets called by <link to="#createMachine" /> if NULL is specified
    1585           for the @a settingsFile argument there, which means that API should use
    1586           a recommended default file name.</li>
     1593          <li>It gets called by <link to="#createMachine" /> if @c null or
     1594            empty string (which is recommended) is specified for the
     1595            @a settingsFile argument there, which means that API should use
     1596            a recommended default file name.</li>
    15871597
    15881598          <li>It can be called manually by a client software before creating a machine,
     
    15971607        details about the machine name.
    15981608
     1609        @a groupName defines which additional subdirectory levels should be
     1610        included. It must be either a valid group name or @c null or empty
     1611        string which designates that the machine will not be related to a
     1612        machine group.
     1613
    15991614        If @a baseFolder is a @c null or empty string (which is recommended), the
    16001615        default machine settings folder
     
    16051620
    16061621        This method does not access the host disks. In particular, it does not check
    1607         for whether a machine of this name already exists.
     1622        for whether a machine with this name already exists.
    16081623      </desc>
    16091624      <param name="name" type="wstring" dir="in">
    16101625        <desc>Suggested machine name.</desc>
     1626      </param>
     1627      <param name="group" type="wstring" dir="in">
     1628        <desc>Machine group name for the new machine or machine group. It is
     1629        used to determine the right subdirectory.</desc>
    16111630      </param>
    16121631      <param name="baseFolder" type="wstring" dir="in">
     
    16271646        and machine files can be created at arbitrary locations.
    16281647
    1629         However, it is is recommended that machines be created in the default
     1648        However, it is recommended that machines are created in the default
    16301649        machine folder (e.g. "/home/user/VirtualBox VMs/name/name.vbox"; see
    16311650        <link to="ISystemProperties::defaultMachineFolder" />). If you specify
    1632         NULL for the @a settingsFile argument, <link to="#composeMachineFilename" />
    1633         is called automatically to have such a recommended name composed based
    1634         on the machine name given in the @a name argument.
     1651        @c null or empty string (which is recommended) for the @a settingsFile
     1652        argument, <link to="#composeMachineFilename" /> is called automatically
     1653        to have such a recommended name composed based on the machine name
     1654        given in the @a name argument and the primary group.
    16351655
    16361656        If the resulting settings file already exists, this method will fail,
     
    16931713      <param name="settingsFile" type="wstring" dir="in">
    16941714        <desc>Fully qualified path where the settings file should be created,
    1695         or NULL for a default folder and file based on the @a name argument
     1715          empty string or @c null for a default folder and file based on the
     1716          @a name argument and the primary group.
    16961717        (see <link to="#composeMachineFilename" />).</desc>
    16971718      </param>
    16981719      <param name="name" type="wstring" dir="in">
    16991720        <desc>Machine name.</desc>
     1721      </param>
     1722      <param name="groups" type="wstring" safearray="yes" dir="in">
     1723        <desc>Array of group names. @c null or an empty array have the same
     1724          meaning as an array with just the empty string or "/", i.e. create a
     1725          machine without group association.</desc>
    17001726      </param>
    17011727      <param name="osTypeId" type="wstring" dir="in">
     
    37113737  <interface
    37123738    name="IMachine" extends="$unknown"
    3713     uuid="019d7a7b-1e2d-4008-b954-4b5d72d103b8"
     3739    uuid="1d03031a-ce63-4641-9d67-3a16e03778d5"
    37143740    wsmap="managed"
    37153741    >
     
    38653891    </attribute>
    38663892
     3893    <attribute name="groups" type="wstring" safearray="yes">
     3894      <desc>
     3895        Array of machine group names of which this machine is a member. "" and
     3896        "/" are synonyms for the toplevel group. Each group is only listed
     3897        once, however they are listed in no particular order and there is no
     3898        guarantee that there are no gaps in the group hierarchy
     3899        (i.e. "/group", "/group/subgroup/subsubgroup" is a valid result).
     3900      </desc>
     3901    </attribute>
     3902
    38673903    <attribute name="OSTypeId" type="wstring">
    38683904      <desc>
     
    38883924        properties.  For most VMs this is the same as the @a id, but for VMs
    38893925        which have been cloned or teleported it may be the same as the source
    3890         VM.  This latter is because the guest shouldn't notice that it was
     3926        VM. The latter is because the guest shouldn't notice that it was
    38913927        cloned or teleported.
    38923928      </desc>
     
    43544390        Enables tracepoints in PDM devices and drivers to use the VMCPU or VM
    43554391        structures when firing off trace points.  This is especially useful
    4356         with DTrace tracepoints, as it allow you to use the VMCPU or VM pointer
    4357         to obtail useful information such as guest register state.
     4392        with DTrace tracepoints, as it allows you to use the VMCPU or VM
     4393        pointer to obtain useful information such as guest register state.
    43584394
    43594395        This is disabled by default because devices and drivers normally has no
     
    45744610            <li><tt>"emergencystop"</tt>: reserved value, used for aborting
    45754611              the currently running VM or session owner. In this case the
    4576               @a session parameter may be @c NULL (if it is non-null it isn't
     4612              @a session parameter may be @c null (if it is non-null it isn't
    45774613              used in any way), and the @a progress return value will be always
    4578               NULL. The operation completes immediately.</li>
     4614              @c null. The operation completes immediately.</li>
    45794615          </ul>
    45804616        </desc>
     
    47454781      </param>
    47464782      <param name="medium" type="IMedium" dir="in">
    4747         <desc>Medium to mount or NULL for an empty drive.</desc>
     4783        <desc>Medium to mount or @c null for an empty drive.</desc>
    47484784      </param>
    47494785    </method>
     
    49755011      </param>
    49765012      <param name="bandwidthGroup" type="IBandwidthGroup" dir="in">
    4977         <desc>New value for the bandwidth group or NULL for no group.</desc>
     5013        <desc>New value for the bandwidth group or @c null for no group.</desc>
    49785014      </param>
    49795015    </method>
     
    50255061      </param>
    50265062      <param name="medium" type="IMedium" dir="in">
    5027         <desc>Medium to mount or NULL for an empty drive.</desc>
     5063        <desc>Medium to mount or @c null for an empty drive.</desc>
    50285064      </param>
    50295065      <param name="force" type="boolean" dir="in">
     
    70637099        Paused virtual machine. When the machine is PoweredOff, an
    70647100        offline snapshot is created. When the machine is Running a live
    7065         snapshot is created, and an online snapshot is is created when Paused.
     7101        snapshot is created, and an online snapshot is created when Paused.
    70667102
    70677103        The taken snapshot is always based on the
     
    1153111567
    1153211568              When deleting the current snapshot, the <link to="IMachine::currentSnapshot" />
    11533               attribute is set to the current snapshot's parent or NULL if it
     11569              attribute is set to the current snapshot's parent or @c null if it
    1153411570              has no parent. Otherwise the attribute is unchanged.
    1153511571          </li>
     
    1173611772    <const name="MultiAttach"       value="5">
    1173711773      <desc>
    11738         A medium which is is indirectly attached, so that one base medium can
     11774        A medium which is indirectly attached, so that one base medium can
    1173911775        be used for several VMs which have their own differencing medium to
    1174011776        store their modifications. In some sense a variant of Immutable
  • trunk/src/VBox/Main/idl/midl.xsl

    r35913 r42129  
    66 *  from the generic interface definition expressed in XML.
    77
    8      Copyright (C) 2006-2010 Oracle Corporation
     8     Copyright (C) 2006-2012 Oracle Corporation
    99
    1010     This file is part of VirtualBox Open Source Edition (OSE), as
     
    288288      <xsl:with-param name="str" select="@name"/>
    289289    </xsl:call-template>
    290     <xsl:text> ([in</xsl:text>
    291     <xsl:if test="@safearray='yes'">
    292       <!-- VB supports only [in, out], [out] and [out, retval] arrays -->
    293       <xsl:text>, out</xsl:text>
    294     </xsl:if>
    295     <xsl:text>] </xsl:text>
     290    <xsl:text> ([in] </xsl:text>
    296291    <xsl:if test="@safearray='yes'">
    297292      <xsl:text>SAFEARRAY(</xsl:text>
     
    299294    <xsl:apply-templates select="@type"/>
    300295    <xsl:if test="@safearray='yes'">
    301       <xsl:text>) *</xsl:text>
     296      <xsl:text>)</xsl:text>
    302297    </xsl:if>
    303298    <xsl:text> a</xsl:text>
  • trunk/src/VBox/Main/include/MachineImpl.h

    r41925 r42129  
    342342                 const Utf8Str &strConfigFile,
    343343                 const Utf8Str &strName,
     344                 const StringsList &llGroups,
    344345                 GuestOSType *aOsType,
    345346                 const Guid &aId,
     
    381382    STDMETHOD(COMSETTER(Description))(IN_BSTR aDescription);
    382383    STDMETHOD(COMGETTER(Id))(BSTR *aId);
     384    STDMETHOD(COMGETTER(Groups))(ComSafeArrayOut(BSTR, aGroups));
     385    STDMETHOD(COMSETTER(Groups))(ComSafeArrayIn(IN_BSTR, aGroups));
    383386    STDMETHOD(COMGETTER(OSTypeId))(BSTR *aOSTypeId);
    384387    STDMETHOD(COMSETTER(OSTypeId))(IN_BSTR aOSTypeId);
  • trunk/src/VBox/Main/include/VirtualBoxBase.h

    r41214 r42129  
    5252class Medium;
    5353class Host;
    54 typedef std::list< ComObjPtr<Medium> > MediaList;
     54typedef std::list<ComObjPtr<Medium> > MediaList;
     55typedef std::list<Utf8Str> StringsList;
    5556
    5657////////////////////////////////////////////////////////////////////////////////
  • trunk/src/VBox/Main/include/VirtualBoxImpl.h

    r42125 r42129  
    4545class AutostartDb;
    4646
    47 typedef std::list< ComObjPtr<SessionMachine> > SessionMachinesList;
     47typedef std::list<ComObjPtr<SessionMachine> > SessionMachinesList;
    4848
    4949#ifdef RT_OS_WINDOWS
     
    6868public:
    6969
    70     typedef std::list< ComPtr<IInternalSessionControl> > InternalControlList;
     70    typedef std::list<ComPtr<IInternalSessionControl> > InternalControlList;
    7171
    7272    class CallbackEvent;
     
    111111    STDMETHOD(COMGETTER(SystemProperties))(ISystemProperties **aSystemProperties);
    112112    STDMETHOD(COMGETTER(Machines))(ComSafeArrayOut(IMachine *, aMachines));
     113    STDMETHOD(COMGETTER(MachineGroups))(ComSafeArrayOut(BSTR, aMachineGroups));
    113114    STDMETHOD(COMGETTER(HardDisks))(ComSafeArrayOut(IMedium *, aHardDisks));
    114115    STDMETHOD(COMGETTER(DVDImages))(ComSafeArrayOut(IMedium *, aDVDImages));
     
    125126
    126127    /* IVirtualBox methods */
    127     STDMETHOD(ComposeMachineFilename)(IN_BSTR aName, IN_BSTR aBaseFolder, BSTR *aFilename);
     128    STDMETHOD(ComposeMachineFilename)(IN_BSTR aName, IN_BSTR aGroup, IN_BSTR aBaseFolder, BSTR *aFilename);
    128129    STDMETHOD(CreateMachine)(IN_BSTR aSettingsFile,
    129130                             IN_BSTR aName,
     131                             ComSafeArrayIn(IN_BSTR, aGroups),
    130132                             IN_BSTR aOsTypeId,
    131133                             IN_BSTR aId,
     
    219221                        bool aSetError,
    220222                        ComObjPtr<Machine> *machine = NULL);
     223
     224    HRESULT convertMachineGroups(ComSafeArrayIn(IN_BSTR, aMachineGroups), StringsList *pllMachineGroups);
    221225
    222226    HRESULT findHardDiskById(const Guid &id,
  • trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp

    r42038 r42129  
    205205            Bstr bstrMachineFilename;
    206206            rc = mVirtualBox->ComposeMachineFilename(Bstr(nameVBox).raw(),
    207                                                      NULL,
     207                                                     NULL /* aGroup */,
     208                                                     NULL /* aBaseFolder */,
    208209                                                     bstrMachineFilename.asOutParam());
    209210            if (FAILED(rc)) throw rc;
     
    19501951    rc = mVirtualBox->CreateMachine(NULL, /* machine name: use default */
    19511952                                    Bstr(stack.strNameVBox).raw(),
     1953                                    NULL, /* no groups */
    19521954                                    Bstr(stack.strOsTypeVBox).raw(),
    19531955                                    NULL, /* uuid */
     
    28642866        Bstr bstrMachineFilename;
    28652867        rc = mVirtualBox->ComposeMachineFilename(Bstr(stack.strNameVBox).raw(),
    2866                                                  NULL,
     2868                                                 NULL /* aGroup */,
     2869                                                 NULL /* aBaseFolder */,
    28672870                                                 bstrMachineFilename.asOutParam());
    28682871        if (FAILED(rc)) throw rc;
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r42123 r42129  
    271271 *                      be relative to the VirtualBox config directory).
    272272 *  @param strName      name for the machine
     273 *  @param llGroups     list of groups for the machine
     274 *  @param aOsType      OS Type of this machine or NULL.
    273275 *  @param aId          UUID for the new machine.
    274  *  @param aOsType      OS Type of this machine or NULL.
    275276 *  @param fForceOverwrite Whether to overwrite an existing machine settings file.
    276277 *
     
    280281                      const Utf8Str &strConfigFile,
    281282                      const Utf8Str &strName,
     283                      const StringsList &llGroups,
    282284                      GuestOSType *aOsType,
    283285                      const Guid &aId,
     
    313315
    314316        mUserData->s.strName = strName;
     317       
     318        mUserData->s.llGroups = llGroups;
    315319
    316320        // the "name sync" flag determines whether the machine directory gets renamed along
     
    10481052}
    10491053
     1054STDMETHODIMP Machine::COMGETTER(Groups)(ComSafeArrayOut(BSTR, aGroups))
     1055{
     1056    CheckComArgOutSafeArrayPointerValid(aGroups);
     1057
     1058    AutoCaller autoCaller(this);
     1059    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     1060
     1061    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     1062    SafeArray<BSTR> groups(mUserData->s.llGroups.size());
     1063    size_t i = 0;
     1064    for (StringsList::const_iterator it = mUserData->s.llGroups.begin();
     1065         it != mUserData->s.llGroups.end();
     1066         ++it, i++)
     1067    {
     1068        Bstr tmp = *it;
     1069        tmp.cloneTo(&groups[i]);
     1070    }
     1071    groups.detachTo(ComSafeArrayOutArg(aGroups));
     1072
     1073    return S_OK;
     1074}
     1075
     1076STDMETHODIMP Machine::COMSETTER(Groups)(ComSafeArrayIn(IN_BSTR, aGroups))
     1077{
     1078    AutoCaller autoCaller(this);
     1079    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     1080
     1081    StringsList llGroups;
     1082    HRESULT rc = mParent->convertMachineGroups(ComSafeArrayInArg(aGroups), &llGroups);
     1083    if (FAILED(rc))
     1084        return rc;
     1085
     1086    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     1087
     1088    rc = checkStateDependency(MutableStateDep);
     1089    if (FAILED(rc)) return rc;
     1090
     1091    setModified(IsModified_MachineData);
     1092    mUserData.backup();
     1093    mUserData->s.llGroups = llGroups;
     1094
     1095    return S_OK;
     1096}
     1097
    10501098STDMETHODIMP Machine::COMGETTER(OSTypeId)(BSTR *aOSTypeId)
    10511099{
     
    11131161    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    11141162
    1115     int rc = checkStateDependency(MutableStateDep);
     1163    HRESULT rc = checkStateDependency(MutableStateDep);
    11161164    if (FAILED(rc)) return rc;
    11171165
     
    11431191    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    11441192
    1145     int rc = checkStateDependency(MutableStateDep);
     1193    HRESULT rc = checkStateDependency(MutableStateDep);
    11461194    if (FAILED(rc)) return rc;
    11471195
     
    11731221    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    11741222
    1175     int rc = checkStateDependency(MutableStateDep);
     1223    HRESULT rc = checkStateDependency(MutableStateDep);
    11761224    if (FAILED(rc)) return rc;
    11771225
     
    12031251    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    12041252
    1205     int rc = checkStateDependency(MutableStateDep);
     1253    HRESULT rc = checkStateDependency(MutableStateDep);
    12061254    if (FAILED(rc)) return rc;
    12071255
     
    12331281STDMETHODIMP Machine::COMGETTER(HardwareVersion)(BSTR *aHWVersion)
    12341282{
    1235     if (!aHWVersion)
    1236         return E_POINTER;
     1283    CheckComArgOutPointerValid(aHWVersion);
    12371284
    12381285    AutoCaller autoCaller(this);
     
    13131360STDMETHODIMP Machine::COMGETTER(MemorySize)(ULONG *memorySize)
    13141361{
    1315     if (!memorySize)
    1316         return E_POINTER;
     1362    CheckComArgOutPointerValid(memorySize);
    13171363
    13181364    AutoCaller autoCaller(this);
     
    13531399STDMETHODIMP Machine::COMGETTER(CPUCount)(ULONG *CPUCount)
    13541400{
    1355     if (!CPUCount)
    1356         return E_POINTER;
     1401    CheckComArgOutPointerValid(CPUCount);
    13571402
    13581403    AutoCaller autoCaller(this);
     
    14061451STDMETHODIMP Machine::COMGETTER(CPUExecutionCap)(ULONG *aExecutionCap)
    14071452{
    1408     if (!aExecutionCap)
    1409         return E_POINTER;
     1453    CheckComArgOutPointerValid(aExecutionCap);
    14101454
    14111455    AutoCaller autoCaller(this);
     
    14551499STDMETHODIMP Machine::COMGETTER(CPUHotPlugEnabled)(BOOL *enabled)
    14561500{
    1457     if (!enabled)
    1458         return E_POINTER;
     1501    CheckComArgOutPointerValid(enabled);
    14591502
    14601503    AutoCaller autoCaller(this);
     
    15521595    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    15531596
    1554     int rc = checkStateDependency(MutableStateDep);
     1597    HRESULT rc = checkStateDependency(MutableStateDep);
    15551598    if (FAILED(rc)) return rc;
    15561599
     
    16121655STDMETHODIMP Machine::COMGETTER(VRAMSize)(ULONG *memorySize)
    16131656{
    1614     if (!memorySize)
    1615         return E_POINTER;
     1657    CheckComArgOutPointerValid(memorySize);
    16161658
    16171659    AutoCaller autoCaller(this);
     
    16521694STDMETHODIMP Machine::COMGETTER(MemoryBalloonSize)(ULONG *memoryBalloonSize)
    16531695{
    1654     if (!memoryBalloonSize)
    1655         return E_POINTER;
     1696    CheckComArgOutPointerValid(memoryBalloonSize);
    16561697
    16571698    AutoCaller autoCaller(this);
     
    16991740STDMETHODIMP Machine::COMGETTER(PageFusionEnabled) (BOOL *enabled)
    17001741{
    1701     if (!enabled)
    1702         return E_POINTER;
     1742    CheckComArgOutPointerValid(enabled);
    17031743
    17041744    AutoCaller autoCaller(this);
     
    17321772STDMETHODIMP Machine::COMGETTER(Accelerate3DEnabled)(BOOL *enabled)
    17331773{
    1734     if (!enabled)
    1735         return E_POINTER;
     1774    CheckComArgOutPointerValid(enabled);
    17361775
    17371776    AutoCaller autoCaller(this);
     
    17671806STDMETHODIMP Machine::COMGETTER(Accelerate2DVideoEnabled)(BOOL *enabled)
    17681807{
    1769     if (!enabled)
    1770         return E_POINTER;
     1808    CheckComArgOutPointerValid(enabled);
    17711809
    17721810    AutoCaller autoCaller(this);
     
    18011839STDMETHODIMP Machine::COMGETTER(MonitorCount)(ULONG *monitorCount)
    18021840{
    1803     if (!monitorCount)
    1804         return E_POINTER;
     1841    CheckComArgOutPointerValid(monitorCount);
    18051842
    18061843    AutoCaller autoCaller(this);
     
    18391876STDMETHODIMP Machine::COMGETTER(BIOSSettings)(IBIOSSettings **biosSettings)
    18401877{
    1841     if (!biosSettings)
    1842         return E_POINTER;
     1878    CheckComArgOutPointerValid(biosSettings);
    18431879
    18441880    AutoCaller autoCaller(this);
     
    18531889STDMETHODIMP Machine::GetCPUProperty(CPUPropertyType_T property, BOOL *aVal)
    18541890{
    1855     if (!aVal)
    1856         return E_POINTER;
     1891    CheckComArgOutPointerValid(aVal);
    18571892
    18581893    AutoCaller autoCaller(this);
     
    21112146STDMETHODIMP Machine::GetHWVirtExProperty(HWVirtExPropertyType_T property, BOOL *aVal)
    21122147{
    2113     if (!aVal)
    2114         return E_POINTER;
     2148    CheckComArgOutPointerValid(aVal);
    21152149
    21162150    AutoCaller autoCaller(this);
     
    22692303STDMETHODIMP Machine::COMGETTER(MediumAttachments)(ComSafeArrayOut(IMediumAttachment*, aAttachments))
    22702304{
    2271     if (ComSafeArrayOutIsNull(aAttachments))
    2272         return E_POINTER;
     2305    CheckComArgOutSafeArrayPointerValid(aAttachments);
    22732306
    22742307    AutoCaller autoCaller(this);
     
    22852318STDMETHODIMP Machine::COMGETTER(VRDEServer)(IVRDEServer **vrdeServer)
    22862319{
    2287     if (!vrdeServer)
    2288         return E_POINTER;
     2320    CheckComArgOutPointerValid(vrdeServer);
    22892321
    22902322    AutoCaller autoCaller(this);
     
    23012333STDMETHODIMP Machine::COMGETTER(AudioAdapter)(IAudioAdapter **audioAdapter)
    23022334{
    2303     if (!audioAdapter)
    2304         return E_POINTER;
     2335    CheckComArgOutPointerValid(audioAdapter);
    23052336
    23062337    AutoCaller autoCaller(this);
     
    24192450STDMETHODIMP Machine::COMGETTER(State)(MachineState_T *machineState)
    24202451{
    2421     if (!machineState)
    2422         return E_POINTER;
     2452    CheckComArgOutPointerValid(machineState);
    24232453
    24242454    AutoCaller autoCaller(this);
     
    44814511STDMETHODIMP Machine::GetExtraDataKeys(ComSafeArrayOut(BSTR, aKeys))
    44824512{
    4483     if (ComSafeArrayOutIsNull(aKeys))
    4484         return E_POINTER;
     4513    CheckComArgOutSafeArrayPointerValid(aKeys);
    44854514
    44864515    AutoCaller autoCaller(this);
     
    48034832{
    48044833    ComObjPtr<Machine>          pMachine;
    4805     RTCList< ComPtr<IMedium> >  llMediums;
    4806     std::list<Utf8Str>          llFilesToDelete;
     4834    RTCList<ComPtr<IMedium> >   llMediums;
     4835    StringsList                 llFilesToDelete;
    48074836    ComObjPtr<Progress>         pProgress;
    48084837};
     
    49694998        // medium storage files from the IMedium list passed in, and the
    49704999        // machine XML file)
    4971         std::list<Utf8Str>::const_iterator it = task.llFilesToDelete.begin();
     5000        StringsList::const_iterator it = task.llFilesToDelete.begin();
    49725001        while (it != task.llFilesToDelete.end())
    49735002        {
     
    65896618        hrc = checkStateDependency(MutableStateDep);
    65906619        if (   SUCCEEDED(hrc)
    6591             && mHWData->mAutostart.fAutostartEnabled != fEnabled)
     6620            && mHWData->mAutostart.fAutostartEnabled != !!fEnabled)
    65926621        {
    65936622            AutostartDb *autostartDb = mParent->getAutostartDb();
     
    89078936
    89088937    bool fSettingsFileIsNew = !mData->pMachineConfigFile->fileExists();
     8938
     8939    /// @todo need to handle primary group change, too
    89098940
    89108941    /* attempt to rename the settings file if machine name is changed */
     
    1222812259    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    1222912260
    12230     AssertReturn(!ComSafeArrayOutIsNull(aNames), E_POINTER);
    12231     AssertReturn(!ComSafeArrayOutIsNull(aValues), E_POINTER);
    12232     AssertReturn(!ComSafeArrayOutIsNull(aTimestamps), E_POINTER);
    12233     AssertReturn(!ComSafeArrayOutIsNull(aFlags), E_POINTER);
     12261    CheckComArgOutSafeArrayPointerValid(aNames);
     12262    CheckComArgOutSafeArrayPointerValid(aValues);
     12263    CheckComArgOutSafeArrayPointerValid(aTimestamps);
     12264    CheckComArgOutSafeArrayPointerValid(aFlags);
    1223412265
    1223512266    size_t cEntries = mHWData->mGuestProperties.size();
     
    1259612627     */
    1259712628
    12598     mParent->onNatRedirectChange(getId(), ulSlot, RT_BOOL(aNatRuleRemove), aRuleName, aProto, aHostIp, aHostPort, aGuestIp, aGuestPort);
     12629    mParent->onNatRedirectChange(getId(), ulSlot, RT_BOOL(aNatRuleRemove), aRuleName, aProto, aHostIp, (uint16_t)aHostPort, aGuestIp, (uint16_t)aGuestPort);
    1259912630    return S_OK;
    1260012631}
  • trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp

    r42125 r42129  
    930930VirtualBox::COMGETTER(Machines)(ComSafeArrayOut(IMachine *, aMachines))
    931931{
    932     if (ComSafeArrayOutIsNull(aMachines))
    933         return E_POINTER;
     932    CheckComArgOutSafeArrayPointerValid(aMachines);
    934933
    935934    AutoCaller autoCaller(this);
     
    943942}
    944943
     944STDMETHODIMP
     945VirtualBox::COMGETTER(MachineGroups)(ComSafeArrayOut(BSTR, aMachineGroups))
     946{
     947    CheckComArgOutSafeArrayPointerValid(aMachineGroups);
     948
     949    AutoCaller autoCaller(this);
     950    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     951
     952    std::list<Bstr> allGroups;
     953
     954    /* get copy of all machine references, to avoid holding the list lock */
     955    MachinesOList::MyList allMachines;
     956    {
     957        AutoReadLock al(m->allMachines.getLockHandle() COMMA_LOCKVAL_SRC_POS);
     958        allMachines = m->allMachines.getList();
     959    }
     960    for (MachinesOList::MyList::const_iterator it = allMachines.begin();
     961         it != allMachines.end();
     962         ++it)
     963    {
     964        const ComObjPtr<Machine> &pMachine = *it;
     965        AutoCaller autoMachineCaller(pMachine);
     966        if (FAILED(autoMachineCaller.rc()))
     967            continue;
     968        AutoReadLock mlock(pMachine COMMA_LOCKVAL_SRC_POS);
     969
     970        if (pMachine->isAccessible())
     971        {
     972            SafeArray<BSTR> thisGroups;
     973            HRESULT rc = pMachine->COMGETTER(Groups)(ComSafeArrayAsOutParam(thisGroups));
     974            if (FAILED(rc))
     975                continue;
     976
     977            for (size_t i = 0; i < thisGroups.size(); i++)
     978                allGroups.push_back(thisGroups[i]);
     979        }
     980    }
     981
     982    /* throw out any duplicates */
     983    allGroups.sort();
     984    allGroups.unique();
     985    com::SafeArray<BSTR> machineGroups(allGroups.size());
     986    size_t i = 0;
     987    for (std::list<Bstr>::const_iterator it = allGroups.begin();
     988         it != allGroups.end();
     989         ++it, i++)
     990    {
     991        const Bstr &tmp = *it;
     992        tmp.cloneTo(&machineGroups[i]);
     993    }
     994    machineGroups.detachTo(ComSafeArrayOutArg(aMachineGroups));
     995
     996    return S_OK;
     997}
     998
    945999STDMETHODIMP VirtualBox::COMGETTER(HardDisks)(ComSafeArrayOut(IMedium *, aHardDisks))
    9461000{
    947     if (ComSafeArrayOutIsNull(aHardDisks))
    948         return E_POINTER;
     1001    CheckComArgOutSafeArrayPointerValid(aHardDisks);
    9491002
    9501003    AutoCaller autoCaller(this);
     
    9601013STDMETHODIMP VirtualBox::COMGETTER(DVDImages)(ComSafeArrayOut(IMedium *, aDVDImages))
    9611014{
    962     if (ComSafeArrayOutIsNull(aDVDImages))
    963         return E_POINTER;
     1015    CheckComArgOutSafeArrayPointerValid(aDVDImages);
    9641016
    9651017    AutoCaller autoCaller(this);
     
    9751027STDMETHODIMP VirtualBox::COMGETTER(FloppyImages)(ComSafeArrayOut(IMedium *, aFloppyImages))
    9761028{
    977     if (ComSafeArrayOutIsNull(aFloppyImages))
    978         return E_POINTER;
     1029    CheckComArgOutSafeArrayPointerValid(aFloppyImages);
    9791030
    9801031    AutoCaller autoCaller(this);
     
    10521103VirtualBox::COMGETTER(DHCPServers)(ComSafeArrayOut(IDHCPServer *, aDHCPServers))
    10531104{
    1054     if (ComSafeArrayOutIsNull(aDHCPServers))
    1055         return E_POINTER;
     1105    CheckComArgOutSafeArrayPointerValid(aDHCPServers);
    10561106
    10571107    AutoCaller autoCaller(this);
     
    11011151STDMETHODIMP VirtualBox::COMGETTER(InternalNetworks)(ComSafeArrayOut(BSTR, aInternalNetworks))
    11021152{
    1103     if (ComSafeArrayOutIsNull(aInternalNetworks))
    1104         return E_POINTER;
     1153    CheckComArgOutSafeArrayPointerValid(aInternalNetworks);
    11051154
    11061155    AutoCaller autoCaller(this);
     
    11631212STDMETHODIMP VirtualBox::COMGETTER(GenericNetworkDrivers)(ComSafeArrayOut(BSTR, aGenericNetworkDrivers))
    11641213{
    1165     if (ComSafeArrayOutIsNull(aGenericNetworkDrivers))
    1166         return E_POINTER;
     1214    CheckComArgOutSafeArrayPointerValid(aGenericNetworkDrivers);
    11671215
    11681216    AutoCaller autoCaller(this);
     
    13231371
    13241372STDMETHODIMP VirtualBox::ComposeMachineFilename(IN_BSTR aName,
     1373                                                IN_BSTR aGroup,
    13251374                                                IN_BSTR aBaseFolder,
    13261375                                                BSTR *aFilename)
    13271376{
     1377    /// @todo implement aGroup
     1378    NOREF(aGroup);
    13281379    LogFlowThisFuncEnter();
    13291380    LogFlowThisFunc(("aName=\"%ls\",aBaseFolder=\"%ls\"\n", aName, aBaseFolder));
     
    14651516STDMETHODIMP VirtualBox::CreateMachine(IN_BSTR aSettingsFile,
    14661517                                       IN_BSTR aName,
     1518                                       ComSafeArrayIn(IN_BSTR, aGroups),
    14671519                                       IN_BSTR aOsTypeId,
    14681520                                       IN_BSTR aId,
     
    14801532    if (FAILED(autoCaller.rc())) return autoCaller.rc();
    14811533
     1534    StringsList llGroups;
     1535    HRESULT rc = convertMachineGroups(ComSafeArrayInArg(aGroups), &llGroups);
     1536    if (FAILED(rc))
     1537        return rc;
     1538
    14821539    /* NULL settings file means compose automatically */
    1483     HRESULT rc;
    14841540    Bstr bstrSettingsFile(aSettingsFile);
    14851541    if (bstrSettingsFile.isEmpty())
    14861542    {
    14871543        rc = ComposeMachineFilename(aName,
    1488                                     NULL,
     1544                                    Bstr(llGroups.front()).raw(),
     1545                                    NULL /* aBaseFolder */,
    14891546                                    bstrSettingsFile.asOutParam());
    14901547        if (FAILED(rc)) return rc;
     
    15091566                       Utf8Str(bstrSettingsFile),
    15101567                       Utf8Str(aName),
     1568                       llGroups,
    15111569                       osType,
    15121570                       id,
     
    18501908    using namespace settings;
    18511909
    1852     if (ComSafeArrayOutIsNull(aKeys))
    1853         return E_POINTER;
     1910    CheckComArgOutSafeArrayPointerValid(aKeys);
    18541911
    18551912    AutoCaller autoCaller(this);
     
    29633020
    29643021    return rc;
     3022}
     3023
     3024/**
     3025 * Takes a list of machine groups, and sanitizes/validates it.
     3026 *
     3027 * @param aMachineGroups    Safearray with the machine groups.
     3028 * @param pllMachineGroups  Pointer to list of strings for the result.
     3029 *
     3030 * @return S_OK or E_INVALIDARG
     3031 */
     3032
     3033HRESULT VirtualBox::convertMachineGroups(ComSafeArrayIn(IN_BSTR, aMachineGroups), StringsList *pllMachineGroups)
     3034{
     3035    pllMachineGroups->clear();
     3036    if (aMachineGroups)
     3037    {
     3038        com::SafeArray<BSTR> machineGroups(ComSafeArrayInArg(aMachineGroups));
     3039        for (size_t i = 0; i < machineGroups.size(); i++)
     3040            pllMachineGroups->push_back(machineGroups[i]);
     3041        pllMachineGroups->sort();
     3042        pllMachineGroups->unique();
     3043        if (pllMachineGroups->size() > 0)
     3044            pllMachineGroups->push_back("/");
     3045        else if (pllMachineGroups->front().equals(""))
     3046        {
     3047            pllMachineGroups->pop_front();
     3048            if (pllMachineGroups->size() == 0 || !pllMachineGroups->front().equals("/"))
     3049                pllMachineGroups->push_front("/");
     3050        }
     3051    }
     3052    else
     3053        pllMachineGroups->push_back("/");
     3054
     3055    for (StringsList::const_iterator it = pllMachineGroups->begin();
     3056         it != pllMachineGroups->end();
     3057         ++it)
     3058    {
     3059        const Utf8Str &str = *it;
     3060        /* no empty strings (shouldn't happen after the translation above) */
     3061        if (str.length() == 0)
     3062            return E_INVALIDARG;
     3063        /* must start with a slash */
     3064        if (str.c_str()[0] != '/')
     3065            return E_INVALIDARG;
     3066        /* must not end with a slash */
     3067        if (str.c_str()[str.length() - 1] != '/')
     3068            return E_INVALIDARG;
     3069
     3070        /** @todo validate each component of the group hierarchy */
     3071    }
     3072
     3073    return S_OK;
    29653074}
    29663075
  • trunk/src/VBox/Main/webservice/websrv-cpp.xsl

    r41040 r42129  
    534534  <xsl:param name="safearray" />
    535535
    536   <xsl:value-of select="concat('        // convert input arg ', $name)" />
     536  <xsl:value-of select="concat('        // convert input arg ', $name, '(safearray: ', $safearray, ')')" />
    537537  <xsl:call-template name="emitNewlineIndent8" />
    538538
     
    709709
    710710<!--
     711    emitInParam:
     712-->
     713<xsl:template name="emitInParam">
     714  <xsl:param name="name" />
     715  <xsl:param name="type" />
     716  <xsl:param name="safearray" />
     717  <xsl:param name="varprefix" />      <!-- only with nested set-attribute calls -->
     718
     719  <xsl:variable name="varname" select="concat('comcall_', $varprefix, $name)" />
     720
     721  <xsl:choose>
     722    <xsl:when test="@safearray='yes'">
     723      <xsl:value-of select="concat('ComSafeArrayAsInParam(', $varname, ')')" />
     724    </xsl:when>
     725    <xsl:otherwise>
     726      <xsl:value-of select="$varname" />
     727      <xsl:if test="@type='wstring' or @type='uuid'">
     728        <xsl:text>.raw()</xsl:text>
     729      </xsl:if>
     730    </xsl:otherwise>
     731  </xsl:choose>
     732</xsl:template>
     733
     734<!--
    711735    emitOutParam:
    712736-->
     
    768792    <xsl:choose>
    769793      <xsl:when test="$attrdir='in'">
    770         <xsl:value-of select="concat('comcall_', $varprefix, @name)" />
    771         <xsl:if test="$attrtype='wstring' or $attrtype='uuid'">
    772           <xsl:text>.raw()</xsl:text>
    773         </xsl:if>
     794        <xsl:call-template name="emitInParam">
     795          <xsl:with-param name="name" select="$attrname" />
     796          <xsl:with-param name="type" select="$attrtype" />
     797          <xsl:with-param name="safearray" select="$attrsafearray" />
     798          <xsl:with-param name="varprefix" select="$varprefix" />
     799        </xsl:call-template>
    774800      </xsl:when>
    775801      <xsl:when test="$attrdir='return'">
     
    794820    <xsl:choose>
    795821      <xsl:when test="@dir='in'">
    796         <xsl:choose>
    797           <xsl:when test="@safearray='yes'">
    798             <xsl:value-of select="concat('ComSafeArrayAsInParam(comcall_', $varprefix, @name, ')')" />
    799           </xsl:when>
    800           <xsl:otherwise>
    801             <xsl:value-of select="concat('comcall_', $varprefix, @name)" />
    802             <xsl:if test="@type='wstring' or @type='uuid'">
    803               <xsl:text>.raw()</xsl:text>
    804             </xsl:if>
    805           </xsl:otherwise>
    806         </xsl:choose>
     822        <xsl:call-template name="emitInParam">
     823          <xsl:with-param name="name" select="@name" />
     824          <xsl:with-param name="type" select="@type" />
     825          <xsl:with-param name="safearray" select="@safearray" />
     826          <xsl:with-param name="varprefix" select="$varprefix" />
     827        </xsl:call-template>
    807828      </xsl:when>
    808829      <xsl:when test="@dir='out'">
     
    12041225  <xsl:param name="attrtype" select="$attrtype" />
    12051226  <xsl:param name="attrreadonly" select="$attrreadonly" />
     1227  <xsl:param name="attrsafearray" select="$attrsafearray" />
    12061228
    12071229  <xsl:variable name="settername"><xsl:call-template name="makeSetterName"><xsl:with-param name="attrname" select="$attrname" /></xsl:call-template></xsl:variable>
     
    12441266        <xsl:with-param name="attrname"><xsl:value-of select="$attrname" /></xsl:with-param>
    12451267        <xsl:with-param name="attrtype"><xsl:value-of select="$attrtype" /></xsl:with-param>
     1268        <xsl:with-param name="attrsafearray"><xsl:value-of select="$attrsafearray" /></xsl:with-param>
    12461269      </xsl:call-template>
    12471270    <!-- </xsl:otherwise>
     
    13161339              <xsl:with-param name="attrtype" select="$attrtype" />
    13171340              <xsl:with-param name="attrreadonly" select="$attrreadonly" />
     1341              <xsl:with-param name="attrsafearray" select="$attrsafearray" />
    13181342            </xsl:call-template>
    13191343          </xsl:if>
  • trunk/src/VBox/Runtime/common/misc/getopt.cpp

    r40598 r42129  
    791791    else if (ch == VERR_GETOPT_UNKNOWN_OPTION)
    792792        RTMsgError("Unknown option: '%s'", pValueUnion->psz);
     793    else if (ch == VERR_GETOPT_INVALID_ARGUMENT_FORMAT)
     794        /** @todo r=klaus not really ideal, as the option isn't available */
     795        RTMsgError("Invalid argument format: '%s'", pValueUnion->psz);
    793796    else if (pValueUnion->pDef)
    794797        RTMsgError("%s: %Rrs\n", pValueUnion->pDef->pszLong, ch);
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