/* $Id$ */
/** @file
* VBoxManage - Implementation of guestproperty command.
*/
/*
* Copyright (C) 2006-2013 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 "VBoxManage.h"
#ifndef VBOX_ONLY_DOCS
#ifdef USE_XPCOM_QUEUE
# include <errno.h>
#endif
#ifdef RT_OS_DARWIN
# include <CoreFoundation/CFRunLoop.h>
#endif
using namespace com;
#endif /* !VBOX_ONLY_DOCS */
{
"%s guestproperty %s get <uuid|vmname>\n"
" <property> [--verbose]\n"
"%s guestproperty %s set <uuid|vmname>\n"
" <property> [<value> [--flags <flags>]]\n"
"%s guestproperty %s delete|unset <uuid|vmname>\n"
" <property>\n"
"%s guestproperty %s enumerate <uuid|vmname>\n"
" [--patterns <patterns>]\n"
"%s guestproperty %s wait <uuid|vmname> <patterns>\n"
" [--timeout <msec>] [--fail-on-timeout]\n"
}
#ifndef VBOX_ONLY_DOCS
{
bool verbose = false;
if ( a->argc == 3
verbose = true;
else if (a->argc != 2)
machine.asOutParam()));
if (machine)
{
/* open a session for the VM - new or existing */
/* get the mutable session machine */
value.asOutParam(),
RTPrintf("No value set!\n");
else
{
}
}
}
{
/*
* Check the syntax. We can deduce the correct syntax from the number of
* arguments.
*/
bool usageOK = true;
if (a->argc == 3)
else if (a->argc == 4)
usageOK = false;
else if (a->argc == 5)
{
usageOK = false;
}
else if (a->argc != 2)
usageOK = false;
if (!usageOK)
/* This is always needed. */
machine.asOutParam()));
if (machine)
{
/* open a session for the VM - new or existing */
/* get the mutable session machine */
if (!pszFlags)
else
a->session->UnlockMachine();
}
}
{
/*
* Check the syntax. We can deduce the correct syntax from the number of
* arguments.
*/
bool usageOK = true;
if (a->argc != 2)
usageOK = false;
if (!usageOK)
/* This is always needed. */
machine.asOutParam()));
if (machine)
{
/* open a session for the VM - new or existing */
/* get the mutable session machine */
a->session->UnlockMachine();
}
}
/**
* Enumerates the properties in the guest property store.
*
* @returns 0 on success, 1 on failure
* @note see the command line API description for parameters
*/
{
/*
* Check the syntax. We can deduce the correct syntax from the number of
* arguments.
*/
if ( a->argc < 1
|| a->argc == 2
|| ( a->argc > 3
/*
* Pack the patterns
*/
for (int i = 3; i < a->argc; ++i)
/*
* Make the actual call to Main.
*/
machine.asOutParam()));
if (machine)
{
/* open a session for the VM - new or existing */
/* get the mutable session machine */
{
RTPrintf("No properties found.\n");
RTPrintf("Name: %ls, value: %ls, timestamp: %lld, flags: %ls\n",
}
}
}
/**
* Enumerates the properties in the guest property store.
*
* @returns 0 on success, 1 on failure
* @note see the command line API description for parameters
*/
{
/*
* Handle arguments
*/
bool fFailOnTimeout = false;
bool usageOK = true;
if (a->argc < 2)
usageOK = false;
else
machine.asOutParam()));
if (!machine)
usageOK = false;
{
{
if ( i + 1 >= a->argc
usageOK = false;
else
++i;
}
fFailOnTimeout = true;
else
usageOK = false;
}
if (!usageOK)
/*
* Set up the event listener and wait until found match or timeout.
*/
bool fSignalled = false;
do
{
unsigned cMsWait;
if (cMsTimeout == RT_INDEFINITE_WAIT)
cMsWait = 1000;
else
{
if (cMsElapsed >= cMsTimeout)
break; /* timed out */
}
if (ev)
{
switch (aType)
{
{
continue;
{
RTPrintf("Name: %ls, value: %ls, flags: %ls\n",
fSignalled = true;
}
break;
}
default:
AssertFailed();
}
}
} while (!fSignalled);
int rcRet = 0;
if (!fSignalled)
{
RTMsgError("Time out or interruption while waiting for a notification.");
if (fFailOnTimeout)
rcRet = 2;
}
return rcRet;
}
/**
* Access the guest property store.
*
* @returns 0 on success, 1 on failure
* @note see the command line API description for parameters
*/
{
/** @todo This command does not follow the syntax where the <uuid|vmname>
* comes between the command and subcommand. The commands controlvm,
* snapshot and debugvm puts it between.
*/
if (a->argc == 0)
/* switch (cmd) */
return handleGetGuestProperty(&arg);
return handleSetGuestProperty(&arg);
return handleDeleteGuestProperty(&arg);
return handleEnumGuestProperty(&arg);
return handleWaitGuestProperty(&arg);
/* default: */
}
#endif /* !VBOX_ONLY_DOCS */