VirtualBox

Changeset 44324 in vbox


Ignore:
Timestamp:
Jan 21, 2013 3:47:33 PM (12 years ago)
Author:
vboxsync
Message:

VbglR3/VBoxControl: Added "guestproperty delete" + VbglR3GuestPropDelete.

Location:
trunk
Files:
4 edited

Legend:

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

    r44130 r44324  
    527527                                            char const **ppszFlags);
    528528VBGLR3DECL(void)    VbglR3GuestPropEnumFree(PVBGLR3GUESTPROPENUM pHandle);
     529VBGLR3DECL(int)     VbglR3GuestPropDelete(uint32_t u32ClientId, const char *pszName);
    529530VBGLR3DECL(int)     VbglR3GuestPropDelSet(uint32_t u32ClientId, char const * const *papszPatterns, uint32_t cPatterns);
    530531VBGLR3DECL(int)     VbglR3GuestPropWait(uint32_t u32ClientId, const char *pszPatterns, void *pvBuf, uint32_t cbBuf, uint64_t u64Timestamp, uint32_t cMillies, char ** ppszName, char **ppszValue, uint64_t *pu64Timestamp, char **ppszFlags, uint32_t *pcbBufActual);
  • trunk/src/VBox/Additions/common/VBoxControl/VBoxControl.cpp

    r41972 r44324  
    55
    66/*
    7  * Copyright (C) 2008-2010 Oracle Corporation
     7 * Copyright (C) 2008-2013 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    122122        doUsage("get <property> [--verbose]", g_pszProgName, "guestproperty");
    123123        doUsage("set <property> [<value> [--flags <flags>]]", g_pszProgName, "guestproperty");
     124        doUsage("delete <property>", g_pszProgName, "guestproperty");
    124125        doUsage("enumerate [--patterns <patterns>]", g_pszProgName, "guestproperty");
    125126        doUsage("wait <patterns>", g_pszProgName, "guestproperty");
     
    10931094
    10941095/**
     1096 * Deletes a guest property from the guest property store.
     1097 * This is accessed through the "VBoxGuestPropSvc" HGCM service.
     1098 *
     1099 * @returns Command exit code.
     1100 * @note see the command line API description for parameters
     1101 */
     1102static RTEXITCODE deleteGuestProperty(int argc, char *argv[])
     1103{
     1104    /*
     1105     * Check the syntax.  We can deduce the correct syntax from the number of
     1106     * arguments.
     1107     */
     1108    bool usageOK = true;
     1109    const char *pszName = NULL;
     1110    if (argc < 1)
     1111        usageOK = false;
     1112    if (!usageOK)
     1113    {
     1114        usage(GUEST_PROP);
     1115        return RTEXITCODE_FAILURE;
     1116    }
     1117    /* This is always needed. */
     1118    pszName = argv[0];
     1119
     1120    /*
     1121     * Do the actual setting.
     1122     */
     1123    uint32_t u32ClientId = 0;
     1124    int rc = VbglR3GuestPropConnect(&u32ClientId);
     1125    if (!RT_SUCCESS(rc))
     1126        VBoxControlError("Failed to connect to the guest property service, error %Rrc\n", rc);
     1127    if (RT_SUCCESS(rc))
     1128    {
     1129        rc = VbglR3GuestPropDelete(u32ClientId, pszName);
     1130        if (!RT_SUCCESS(rc))
     1131            VBoxControlError("Failed to delete the property value, error %Rrc\n", rc);
     1132    }
     1133
     1134    if (u32ClientId != 0)
     1135        VbglR3GuestPropDisconnect(u32ClientId);
     1136    return RT_SUCCESS(rc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;
     1137}
     1138
     1139
     1140/**
    10951141 * Enumerates the properties in the guest property store.
    10961142 * This is accessed through the "VBoxGuestPropSvc" HGCM service.
     
    13121358    else if (!strcmp(argv[0], "set"))
    13131359        return setGuestProperty(argc - 1, argv + 1);
     1360    else if (!strcmp(argv[0], "delete"))
     1361        return deleteGuestProperty(argc - 1, argv + 1);
    13141362    else if (!strcmp(argv[0], "enumerate"))
    13151363        return enumGuestProperty(argc - 1, argv + 1);
  • trunk/src/VBox/Additions/common/VBoxControl/testcase/tstVBoxControl.cpp

    r32705 r44324  
    55
    66/*
    7  * Copyright (C) 2007 Oracle Corporation
     7 * Copyright (C) 2007-2013 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    9898}
    9999
     100VBGLR3DECL(int)     VbglR3GuestPropDelete(uint32_t u32ClientId,
     101                                          const char *pszName)
     102{
     103    RTPrintf("Called DEL_PROP, client %d, name %s...\n",
     104             u32ClientId, pszName);
     105    return VINF_SUCCESS;
     106}
     107
    100108struct VBGLR3GUESTPROPENUM
    101109{
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibGuestProp.cpp

    r36638 r44324  
    55
    66/*
    7  * Copyright (C) 2007 Oracle Corporation
     7 * Copyright (C) 2007-2013 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    780780    RTMemFree(pHandle->pchBuf);
    781781    RTMemFree(pHandle);
     782}
     783
     784
     785/**
     786 * Deletes a guest property.
     787 *
     788 * @returns VBox status code.
     789 * @param   u32ClientId     The client id returned by VbglR3InvsSvcConnect().
     790 * @param   pszName         The property to delete.  Utf8
     791 */
     792VBGLR3DECL(int) VbglR3GuestPropDelete(uint32_t u32ClientId, const char *pszName)
     793{
     794    AssertPtrReturn(pszName,  VERR_INVALID_POINTER);
     795
     796    DelProperty Msg;
     797
     798    Msg.hdr.result = VERR_WRONG_ORDER;
     799    Msg.hdr.u32ClientID = u32ClientId;
     800    Msg.hdr.u32Function = DEL_PROP;
     801    Msg.hdr.cParms = 1;
     802    VbglHGCMParmPtrSetString(&Msg.name, pszName);
     803    int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
     804    if (RT_SUCCESS(rc))
     805        rc = Msg.hdr.result;
     806
     807    return rc;
    782808}
    783809
Note: See TracChangeset for help on using the changeset viewer.

© 2023 Oracle
ContactPrivacy policyTerms of Use