VBoxGuestR3LibGuestProp.cpp revision a2d53f020c57ede4a469a06d8ef8f735c7a46596
/* $Id$ */
/** @file
* VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions,
* guest properties.
*/
/*
* Copyright (C) 2007 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "VBGLR3Internal.h"
using namespace guestProp;
/**
* Connects to the guest property service.
*
* @returns VBox status code
* @param pu32ClientId Where to put the client id on success. The client id
* must be passed to all the other calls to the service.
*/
{
Info.result = (uint32_t)VERR_WRONG_ORDER; /** @todo drop the cast when the result type has been fixed! */
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
}
return rc;
}
/**
* Disconnect from the guest property service.
*
* @returns VBox status code.
* @param u32ClientId The client id returned by VbglR3InfoSvcConnect().
*/
{
Info.result = (uint32_t)VERR_WRONG_ORDER; /** @todo drop the cast when the result type has been fixed! */
if (RT_SUCCESS(rc))
return rc;
}
/**
* Write a property value.
*
* @returns VBox status code.
* @param u32ClientId The client id returned by VbglR3InvsSvcConnect().
* @param pszName The property to save to. Utf8
* @param pszValue The value to store. Utf8. If this is NULL then
* the property will be removed.
* @param pszFlags The flags for the property
*/
VBGLR3DECL(int) VbglR3GuestPropWrite(uint32_t u32ClientId, const char *pszName, const char *pszValue, const char *pszFlags)
{
int rc;
{
Msg.hdr.result = (uint32_t)VERR_WRONG_ORDER; /** @todo drop the cast when the result type has been fixed! */
if (RT_SUCCESS(rc))
}
else
{
Msg.hdr.result = (uint32_t)VERR_WRONG_ORDER; /** @todo drop the cast when the result type has been fixed! */
if (RT_SUCCESS(rc))
}
return rc;
}
/**
* Write a property value.
*
* @returns VBox status code.
*
* @param u32ClientId The client id returned by VbglR3InvsSvcConnect().
* @param pszName The property to save to. Must be valid UTF-8.
* @param pszValue The value to store. Must be valid UTF-8.
* If this is NULL then the property will be removed.
*
* @note if the property already exists and pszValue is not NULL then the
* property's flags field will be left unchanged
*/
VBGLR3DECL(int) VbglR3GuestPropWriteValue(uint32_t u32ClientId, const char *pszName, const char *pszValue)
{
int rc;
{
Msg.hdr.result = (uint32_t)VERR_WRONG_ORDER; /** @todo drop the cast when the result type has been fixed! */
if (RT_SUCCESS(rc))
}
else
{
Msg.hdr.result = (uint32_t)VERR_WRONG_ORDER; /** @todo drop the cast when the result type has been fixed! */
if (RT_SUCCESS(rc))
}
return rc;
}
/**
* Write a property value where the value is in RTStrPrintfV fashion.
*
* @returns The same as VbglR3GuestPropWriteValue with the addition of VERR_NO_STR_MEMORY.
*
* @param u32ClientId The client ID returned by VbglR3InvsSvcConnect().
* @param pszName The property to save to. Must be valid UTF-8.
* @param pszValueFormat The value format. This must be valid UTF-8 when fully formatted.
* @param va The format arguments.
*/
VBGLR3DECL(int) VbglR3GuestPropWriteValueV(uint32_t u32ClientId, const char *pszName, const char *pszValueFormat, va_list va)
{
/*
* Format the value and pass it on to the setter.
*/
int rc = VERR_NO_STR_MEMORY;
char *pszValue;
{
}
return rc;
}
/**
* Write a property value where the value is in RTStrPrintf fashion.
*
* @returns The same as VbglR3GuestPropWriteValue with the addition of VERR_NO_STR_MEMORY.
*
* @param u32ClientId The client ID returned by VbglR3InvsSvcConnect().
* @param pszName The property to save to. Must be valid UTF-8.
* @param pszValueFormat The value format. This must be valid UTF-8 when fully formatted.
* @param ... The format arguments.
*/
VBGLR3DECL(int) VbglR3GuestPropWriteValueF(uint32_t u32ClientId, const char *pszName, const char *pszValueFormat, ...)
{
return rc;
}
/**
* Retrieve a property.
*
* @returns VBox status code.
* @retval VINF_SUCCESS on success, pszValue, pu64Timestamp and pszFlags
* containing valid data.
* @retval VERR_BUFFER_OVERFLOW if the scratch buffer @a pcBuf is not large
* enough. In this case the size needed will be placed in
* @a pcbBufActual if it is not NULL.
* @retval VERR_NOT_FOUND if the key wasn't found.
*
* @param u32ClientId The client id returned by VbglR3ClipboardConnect().
* @param pszName The value to read. Utf8
* @param pcBuf A scratch buffer to store the data retrieved into.
* The returned data is only valid for it's lifetime.
* @param cbBuf The size of @a pcBuf
* @param pszValue Where to store the pointer to the value retrieved.
* @param pu64Timestamp Where to store the timestamp. Optional.
* @param pszFlags Where to store the pointer to the flags. Optional.
* @param pcbBufActual If @a pcBuf is not large enough, the size needed.
* Optional.
*/
char **ppszFlags,
{
Msg.hdr.result = (uint32_t)VERR_WRONG_ORDER; /** @todo drop the cast when the result type has been fixed! */
if (RT_SUCCESS(rc))
{
if (!RT_SUCCESS(rc2))
}
if (RT_SUCCESS(rc))
{
if (pszEos)
else
}
return rc;
}
/**
* Retrieve a property value, allocating space for it.
*
* @returns VBox status code.
* @retval VINF_SUCCESS on success, *ppszValue containing valid data.
* @retval VERR_NOT_FOUND if the key wasn't found.
* @retval VERR_TOO_MUCH_DATA if we were unable to determine the right size
* to allocate for the buffer. This can happen as the result of a
* race between our allocating space and the host changing the
* property value.
*
* @param u32ClientId The client id returned by VbglR3ClipboardConnect().
* @param pszName The value to read. Must be valid UTF-8.
* @param ppszValue Where to store the pointer to the value returned.
* This is always set to NULL or to the result, even
* on failure.
*/
const char *pszName,
char **ppszValue)
{
/*
* Quick input validation.
*/
/*
* There is a race here between our reading the property size and the
* host changing the value before we read it. Try up to ten times and
* report the problem if that fails.
*/
int rc = VERR_BUFFER_OVERFLOW;
{
/* We leave a bit of space here in case the maximum value is raised. */
cchBuf += 1024;
if (pvTmpBuf)
{
}
else
rc = VERR_NO_MEMORY;
}
if (RT_SUCCESS(rc))
{
}
else
{
if (rc == VERR_BUFFER_OVERFLOW)
/* VERR_BUFFER_OVERFLOW has a different meaning here as a
* return code, but we need to report the race. */
}
return rc;
}
/**
* Free the memory used by VbglR3GuestPropReadValueAlloc for returning a
* value.
*
* @param pszValue the memory to be freed. NULL pointers will be ignored.
*/
{
}
/**
* Retrieve a property value, using a user-provided buffer to store it.
*
* @returns VBox status code.
* @retval VINF_SUCCESS on success, pszValue containing valid data.
* @retval VERR_BUFFER_OVERFLOW and the size needed in pcchValueActual if the
* buffer provided was too small
* @retval VERR_NOT_FOUND if the key wasn't found.
*
* @note There is a race here between obtaining the size of the buffer
* needed to hold the value and the value being updated.
*
* @param u32ClientId The client id returned by VbglR3ClipboardConnect().
* @param pszName The value to read. Utf8
* @param pszValue Where to store the value retrieved.
* @param cchValue The size of the buffer pointed to by @a pszValue
* @param pcchValueActual Where to store the size of the buffer needed if
* the buffer supplied is too small. Optional.
*/
{
if (RT_SUCCESS(rc))
{
if (cchValueActual > cchValue)
{
if (pcchValueActual != NULL)
}
if (RT_SUCCESS(rc))
}
return rc;
}