VBoxServicePropCache.cpp revision b2b3dd040e6419db8733be1dca655675d3c60e04
/* $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 = VBoxServicePropCacheUpdate(pCache, pszName, 0 /* Not used */, NULL /* Not used */, pszValueFormat, va);
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, ...)
{
int rc = VINF_SUCCESS;
if (pszValueFormat)
{
}
{
if (pszValue)
{
bool fUpdate = false;
fUpdate = true;
fUpdate = true;
if (fUpdate)
{
/* Write the update. */
if (pszValueReset)
{
if (pNode->pszValueReset)
}
if (u32Flags)
}
else
}
{
/* Delete property (but do not remove from cache) if not deleted yet. */
}
}
else /* Node not found; add it and update HGCM service. */
{
PVBOXSERVICEVEPROPCACHEENTRY pNewNode = (PVBOXSERVICEVEPROPCACHEENTRY)RTMemAlloc(sizeof(VBOXSERVICEVEPROPCACHEENTRY));
if (pszValue)
else
if (pszValueReset)
else
if (RT_SUCCESS(rc))
rc = VERR_NOT_FOUND;
}
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 */