VBoxServicePropCache.cpp revision 4c0046c5896bbe0fbff893996b7886284e0b3afd
/* $Id$ */
/** @file
* VBoxServicePropCache - Guest property cache.
*/
/*
* Copyright (C) 2010 Oracle Corporation
*
* 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.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <VBox/VBoxGuestLib.h>
#include "VBoxServiceInternal.h"
#include "VBoxServiceUtils.h"
#include "VBoxServicePropCache.h"
#ifdef VBOX_WITH_GUEST_PROPS
/** @todo Docs */
{
return VINF_SUCCESS;
}
/** @todo Docs */
PVBOXSERVICEVEPROPCACHEENTRY VBoxServicePropCacheFind(PVBOXSERVICEVEPROPCACHE pCache, const char *pszName, uint32_t uFlags)
{
/* This is a O(n) lookup, maybe improve this later to O(1) using a map. */
{
return pNode;
}
return NULL;
}
/** @todo Docs */
{
{
if (pszValueReset)
{
if (pszValueReset)
}
return VINF_SUCCESS;
}
return VERR_NOT_FOUND;
}
/**
* Updates the local guest property cache and writes it to HGCM if outdated.
*
* @returns VBox status code. Errors will be logged.
*
* @param u32ClientId The HGCM client ID for the guest property session.
* @param pszName The property name.
* @param pszValueFormat The property format string. If this is NULL then
* the property will be deleted (if possible).
* @param ... Format arguments.
*/
int VBoxServicePropCacheUpdate(PVBOXSERVICEVEPROPCACHE pCache, const char *pszName, const char *pszValueFormat, ...)
{
int rc;
if (pszValueFormat)
{
}
rc = VBoxServicePropCacheUpdateEx(pCache, pszName, 0 /* Not used */, NULL /* Not used */, pszValue);
if (pszValue)
return rc;
}
/**
* Updates the local guest property cache and writes it to HGCM if outdated.
*
* @returns VBox status code. Errors will be logged.
*
* @param u32ClientId The HGCM client ID for the guest property session.
* @param pszName The property name.
* @param pszValueFormat The property format string. If this is NULL then
* the property will be deleted (if possible).
* @param ... Format arguments.
*/
int VBoxServicePropCacheUpdateEx(PVBOXSERVICEVEPROPCACHE pCache, const char *pszName, uint32_t u32Flags, const char *pszValueReset, const char *pszValueFormat, ...)
{
if (pszValueFormat)
{
}
{
}
int rc;
if (pszValue) /* Do we have a value to check for? */
{
bool fUpdate = false;
/* Always update this property, no matter what? */
fUpdate = true;
/* Did the value change so we have to update? */
fUpdate = true;
/* No value stored at the moment but we have a value now? */
fUpdate = true;
if (fUpdate)
{
/* Write the update. */
}
else
}
else
{
/* No value specified. Deletion (or no action required). */
{
/* Delete property (but do not remove from cache) if not deleted yet. */
}
else
}
/* Update rest of the fields. */
if (pszValueReset)
{
if (pNode->pszValueReset)
}
if (u32Flags)
/* Delete temp stuff. */
if (pszValue)
return rc;
}
/** @todo Docs */
{
{
{
{
}
else /* Delete value. */
}
if (pNode->pszValueReset)
}
while (pNode)
{
PVBOXSERVICEVEPROPCACHEENTRY pNext = RTListNodeGetNext(&pNode->Node, VBOXSERVICEVEPROPCACHEENTRY, Node);
break;
}
}
#endif /* VBOX_WITH_GUEST_PROPS */