GuestDirectoryImpl.cpp revision 0d49a2fbc9857ad8dd29542de7fb37202f1a283f
/* $Id$ */
/** @file
* VirtualBox Main - Guest directory handling.
*/
/*
* Copyright (C) 2012-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 "GuestDirectoryImpl.h"
#include "GuestSessionImpl.h"
#include "GuestCtrlImplPrivate.h"
#include "Global.h"
#include "AutoCaller.h"
#ifdef LOG_GROUP
#endif
#define LOG_GROUP LOG_GROUP_GUEST_CONTROL
// constructor / destructor
/////////////////////////////////////////////////////////////////////////////
{
LogFlowThisFunc(("\n"));
return BaseFinalConstruct();
}
void GuestDirectory::FinalRelease(void)
{
uninit();
}
// public initializer/uninitializer for internal purposes only
/////////////////////////////////////////////////////////////////////////////
{
LogFlowThisFunc(("pConsole=%p, pSession=%p, uDirID=%RU32, strPath=%s, strFilter=%s, uFlags=%x\n",
/* Enclose the state transition NotReady->InInit->Ready. */
AutoInitSpan autoInitSpan(this);
#ifndef VBOX_WITH_GUEST_CONTROL
return VINF_SUCCESS;
#else
if (RT_SUCCESS(vrc))
{
}
if (RT_SUCCESS(vrc))
{
/* Start the directory process on the guest. */
/* We want the long output format which contains all the object details. */
#if 0 /* Flags are not supported yet. */
#endif
/** @todo Recursion support? */
/*
* Start the process asynchronously and keep it around so that we can use
* it later in subsequent read() calls.
* Note: No guest rc available because operation is asynchronous.
*/
}
if (RT_SUCCESS(vrc))
{
/* Confirm a successful initialization when it's the case. */
return vrc;
}
else
return vrc;
#endif /* VBOX_WITH_GUEST_CONTROL */
}
/**
* Uninitializes the instance.
* Called from FinalRelease().
*/
void GuestDirectory::uninit(void)
{
/* Enclose the state transition Ready->InUninit->NotReady. */
AutoUninitSpan autoUninitSpan(this);
if (autoUninitSpan.uninitDone())
return;
}
/////////////////////////////////////////////////////////////////////////////
{
AutoCaller autoCaller(this);
return S_OK;
}
{
AutoCaller autoCaller(this);
return S_OK;
}
// private methods
/////////////////////////////////////////////////////////////////////////////
int GuestDirectory::callbackDispatcher(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb)
{
LogFlowThisFunc(("strPath=%s, uContextID=%RU32, uFunction=%RU32, pSvcCb=%p\n",
int vrc;
{
case GUEST_DIR_NOTIFY:
{
/* pSvcCb->mpaParms[0] always contains the context ID. */
LogFlowFunc(("uType=%RU32, guestRc=%Rrc\n",
{
/* Nothing here yet, nothing to dispatch further. */
default:
break;
}
break;
}
default:
/* Silently ignore not implemented functions. */
break;
}
#ifdef DEBUG
#endif
return vrc;
}
/* static */
{
/** @todo pData->u32Flags: int vs. uint32 -- IPRT errors are *negative* !!! */
switch (guestRc)
{
case VERR_DIR_NOT_EMPTY:
break;
default:
break;
}
return strError;
}
/**
* Called by IGuestSession right before this directory gets
* removed from the public directory list.
*/
int GuestDirectory::onRemove(void)
{
int vrc = VINF_SUCCESS;
return vrc;
}
/* static */
{
return pInterface->setError(VBOX_E_IPRT_ERROR, GuestDirectory::guestErrorToString(guestRc).c_str());
}
// implementation of public methods
/////////////////////////////////////////////////////////////////////////////
{
#ifndef VBOX_WITH_GUEST_CONTROL
#else
AutoCaller autoCaller(this);
int guestRc;
if (RT_FAILURE(rc))
{
switch (rc)
{
case VERR_GSTCTL_GUEST_ERROR:
break;
case VERR_NOT_SUPPORTED:
/* Silently skip old Guest Additions which do not support killing the
* the guest directory handling process. */
break;
default:
tr("Terminating open guest directory \"%s\" failed: %Rrc"),
break;
}
}
if (RT_SUCCESS(rc))
return hr;
#endif /* VBOX_WITH_GUEST_CONTROL */
}
{
#ifndef VBOX_WITH_GUEST_CONTROL
#else
AutoCaller autoCaller(this);
int guestRc;
/*
* Note: The guest process can still be around to serve the next
* upcoming stream block next time.
*/
if ( RT_SUCCESS(rc)
{
if (rc == VERR_NOT_EQUAL)
}
if (RT_SUCCESS(rc))
{
{
if (RT_FAILURE(rc))
if (RT_SUCCESS(rc))
{
/* Create the object. */
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
{
/* Return info object to the caller. */
}
}
}
else
{
/* Nothing to read anymore. Tell the caller. */
}
}
{
switch (rc)
{
case VERR_GSTCTL_GUEST_ERROR:
break;
case VERR_ACCESS_DENIED:
hr = setError(VBOX_E_IPRT_ERROR, tr("Reading directory \"%s\" failed: Unable to read / access denied"),
break;
case VERR_PATH_NOT_FOUND:
break;
case VERR_NO_MORE_FILES:
/* See SDK reference. */
break;
default:
break;
}
}
return hr;
#endif /* VBOX_WITH_GUEST_CONTROL */
}