VirtualBox

Changeset 10003 in vbox for trunk


Ignore:
Timestamp:
Jun 27, 2008 9:26:27 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
32460
Message:

HostServices/SharedInfoServices: added a request to remove a guest property

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/HostServices/VBoxInfoSvc.h

    r9882 r10003  
    3838    SET_CFGM_NODE = 1,
    3939    /**
    40      * Get the value attached to an extra data key in the machine XML file.
     40     * Get the value attached to a configuration property key
    4141     * The parameter format matches that of GET_CONFIG_KEY.
    4242     */
    4343    GET_CONFIG_KEY_HOST = 2,
    4444    /**
    45      * Set the value attached to an extra data key in the machine XML file.
     45     * Set the value attached to a configuration property key
    4646     * The parameter format matches that of SET_CONFIG_KEY.
    4747     */
    48     SET_CONFIG_KEY_HOST = 3
     48    SET_CONFIG_KEY_HOST = 3,
     49    /**
     50     * Remove the value attached to a configuration property key
     51     * The parameter format matches that of DEL_CONFIG_KEY.
     52     */
     53    DEL_CONFIG_KEY_HOST = 4
    4954};
    5055
     
    5560enum eGuestFn
    5661{
    57     /** Get the value attached to an extra data key in the machine XML file */
     62    /** Get the value attached to a configuration property key */
    5863    GET_CONFIG_KEY = 1,
    59     /** Set the value attached to an extra data key in the machine XML file */
    60     SET_CONFIG_KEY = 2
     64    /** Set the value attached to a configuration property key */
     65    SET_CONFIG_KEY = 2,
     66    /** Remove the value attached to a configuration property key */
     67    DEL_CONFIG_KEY = 3
    6168};
    6269
     
    125132    HGCMFunctionParameter value;
    126133} SetConfigKey;
     134
     135/** The guest is requesting to remove a configuration key */
     136typedef struct _DelConfigKey
     137{
     138    VBoxGuestHGCMCallInfo hdr;
     139
     140    /**
     141     * The key to change up.  This must fit to a number of criteria, namely
     142     *  - Only ASCII characters with no spaces
     143     *  - Less than or equal to VBOX_SHARED_INFO_KEY_MAX_LEN bytes in length
     144     *  - Zero terminated
     145     */
     146    HGCMFunctionParameter key;
     147} DelConfigKey;
    127148#pragma pack ()
    128149
  • trunk/src/VBox/HostServices/SharedInfoServices/service.cpp

    r9995 r10003  
    2323/**
    2424 * An HGCM service for passing requests which do not need any persistant state
    25  * to handle.  We currently only support two types of request - set guest
    26  * configuration key (SET_CONFIG_KEY and SET_CONFIG_KEY_HOST) and get
    27  * configuration key (GET_CONFIG_KEY and GET_CONFIG_KEY_HOST).  These may be
    28  * used to read and to write configuration information which is available to
     25 * to handle.  We currently only support three types of request - set guest
     26 * property (SET_CONFIG_KEY and SET_CONFIG_KEY_HOST), get guest property
     27 * (GET_CONFIG_KEY and GET_CONFIG_KEY_HOST) and remove guest property
     28 * (DEL_CONFIG_KEY and DEL_CONFIG_KEY_HOST).  These may be used to read, to
     29 * write and to remove configuration information which is available to
    2930 * both guest and host.  This configuration information is stored in a CFGM
    3031 * node using the CFGM APIs.  It is the responsibility of whoever creates the
     
    157158    int getKey(uint32_t cParms, VBOXHGCMSVCPARM paParms[]);
    158159    int setKey(uint32_t cParms, VBOXHGCMSVCPARM paParms[]);
     160    int delKey(uint32_t cParms, VBOXHGCMSVCPARM paParms[]);
    159161    void call (VBOXHGCMCALLHANDLE callHandle, uint32_t u32ClientID,
    160162               void *pvClient, uint32_t eFunction, uint32_t cParms,
     
    336338
    337339/**
     340 * Remove a value in the guest registry by key, checking the validity
     341 * of the arguments passed.
     342 *
     343 * @returns iprt status value
     344 * @param   cParms  the number of HGCM parameters supplied
     345 * @param   paParms the array of HGCM parameters
     346 * @thread  HGCM
     347 */
     348int Service::delKey(uint32_t cParms, VBOXHGCMSVCPARM paParms[])
     349{
     350    int rc = VINF_SUCCESS;
     351    char *pszKey, *pszValue;
     352    uint32_t cbKey, cbValue;
     353
     354    LogFlowThisFunc(("\n"));
     355    if (   (cParms != 1)  /* Hardcoded value as the next lines depend on it. */
     356        || (paParms[0].type != VBOX_HGCM_SVC_PARM_PTR)   /* key */
     357       )
     358        rc = VERR_INVALID_PARAMETER;
     359    if (RT_SUCCESS(rc))
     360        rc = VBoxHGCMParmPtrGet(&paParms[0], (void **) &pszKey, &cbKey);
     361    if (RT_SUCCESS(rc))
     362        rc = validateKey(pszKey, cbKey);
     363    if (RT_SUCCESS(rc))
     364        CFGMR3RemoveValue(mpNode, pszKey);
     365    LogFlowThisFunc(("rc = %Rrc\n", rc));
     366    return rc;
     367}
     368
     369
     370/**
    338371 * Handle an HGCM service call.
    339372 * @copydoc VBOXHGCMSVCFNTABLE::pfnCall
     
    367400            if (RT_SUCCESS(rc))
    368401                rc = setKey(cParms, paParms);
     402            break;
     403
     404        /* The guest wishes to remove a configuration value */
     405        case DEL_CONFIG_KEY:
     406            LogFlowFunc(("DEL_CONFIG_KEY\n"));
     407            if (RT_SUCCESS(rc))
     408                rc = delKey(cParms, paParms);
    369409            break;
    370410
     
    430470            if (RT_SUCCESS(rc))
    431471                rc = setKey(cParms, paParms);
     472            break;
     473
     474        /* The host wishes to remove a configuration value */
     475        case DEL_CONFIG_KEY_HOST:
     476            LogFlowFunc(("DEL_CONFIG_KEY_HOST\n"));
     477            if (RT_SUCCESS(rc))
     478                rc = delKey(cParms, paParms);
    432479            break;
    433480
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