GuestSessionImpl.cpp revision 417151ebeb99c3e17c4d44060556bfc75adea46e
/* $Id$ */
/** @file
* VirtualBox Main - XXX.
*/
/*
* Copyright (C) 2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* you can redistribute it and/or modify it under the terms of the GNU
* 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 "GuestImpl.h"
#include "GuestSessionImpl.h"
#include "Global.h"
#include "AutoCaller.h"
#include "Logging.h"
#include <VBox/com/array.h>
// constructor / destructor
/////////////////////////////////////////////////////////////////////////////
DEFINE_EMPTY_CTOR_DTOR(GuestSession)
HRESULT GuestSession::FinalConstruct(void)
{
LogFlowThisFunc(("\n"));
return BaseFinalConstruct();
}
void GuestSession::FinalRelease(void)
{
LogFlowThisFuncEnter();
uninit();
BaseFinalRelease();
LogFlowThisFuncLeave();
}
// public initializer/uninitializer for internal purposes only
/////////////////////////////////////////////////////////////////////////////
int GuestSession::init(Guest *aGuest,
Utf8Str aUser, Utf8Str aPassword, Utf8Str aDomain, Utf8Str aName)
{
/* Enclose the state transition NotReady->InInit->Ready. */
AutoInitSpan autoInitSpan(this);
AssertReturn(autoInitSpan.isOk(), VERR_OBJECT_DESTROYED);
mData.mParent = aGuest;
mData.mUser = aUser;
mData.mPassword = aPassword;
mData.mDomain = aDomain;
mData.mName = aName;
/* Confirm a successful initialization when it's the case. */
autoInitSpan.setSucceeded();
return VINF_SUCCESS;
}
/**
* Uninitializes the instance.
* Called from FinalRelease().
*/
void GuestSession::uninit(void)
{
LogFlowThisFunc(("\n"));
/* Enclose the state transition Ready->InUninit->NotReady. */
AutoUninitSpan autoUninitSpan(this);
if (autoUninitSpan.uninitDone())
return;
#ifdef VBOX_WITH_GUEST_CONTROL
for (SessionDirectories::iterator itDirs = mData.mDirectories.begin();
itDirs != mData.mDirectories.end(); ++itDirs)
{
(*itDirs)->uninit();
(*itDirs).setNull();
}
mData.mDirectories.clear();
for (SessionFiles::iterator itFiles = mData.mFiles.begin();
itFiles != mData.mFiles.end(); ++itFiles)
{
(*itFiles)->uninit();
(*itFiles).setNull();
}
mData.mFiles.clear();
for (SessionProcesses::iterator itProcs = mData.mProcesses.begin();
itProcs != mData.mProcesses.end(); ++itProcs)
{
(*itProcs)->uninit();
(*itProcs).setNull();
}
mData.mProcesses.clear();
mData.mParent->sessionClose(this);
#endif
}
// implementation of public getters/setters for attributes
/////////////////////////////////////////////////////////////////////////////
STDMETHODIMP GuestSession::COMGETTER(User)(BSTR *aUser)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
CheckComArgOutPointerValid(aUser);
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
mData.mUser.cloneTo(aUser);
return S_OK;
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::COMGETTER(Domain)(BSTR *aDomain)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
CheckComArgOutPointerValid(aDomain);
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
mData.mDomain.cloneTo(aDomain);
return S_OK;
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::COMGETTER(Name)(BSTR *aName)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
CheckComArgOutPointerValid(aName);
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
mData.mName.cloneTo(aName);
return S_OK;
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::COMGETTER(Id)(ULONG *aId)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
CheckComArgOutPointerValid(aId);
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
*aId = mData.mId;
return S_OK;
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::COMGETTER(Timeout)(ULONG *aTimeout)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
CheckComArgOutPointerValid(aTimeout);
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
*aTimeout = mData.mTimeout;
return S_OK;
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::COMGETTER(Environment)(ComSafeArrayOut(BSTR, aEnvironment))
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
CheckComArgOutSafeArrayPointerValid(aEnvironment);
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
com::SafeArray<BSTR> collection(mData.mEnvironment.size());
size_t s = 0;
for (SessionEnvironment::const_iterator it = mData.mEnvironment.begin();
it != mData.mEnvironment.end();
++it, ++s)
{
/** @todo */
}
collection.detachTo(ComSafeArrayOutArg(aEnvironment));
return S_OK;
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::COMGETTER(Processes)(ComSafeArrayOut(IGuestProcess *, aProcesses))
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
CheckComArgOutSafeArrayPointerValid(aProcesses);
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
SafeIfaceArray<IGuestProcess> collection(mData.mProcesses);
collection.detachTo(ComSafeArrayOutArg(aProcesses));
return S_OK;
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::COMGETTER(Directories)(ComSafeArrayOut(IGuestDirectory *, aDirectories))
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
CheckComArgOutSafeArrayPointerValid(aDirectories);
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
SafeIfaceArray<IGuestDirectory> collection(mData.mDirectories);
collection.detachTo(ComSafeArrayOutArg(aDirectories));
return S_OK;
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::COMGETTER(Files)(ComSafeArrayOut(IGuestFile *, aFiles))
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
CheckComArgOutSafeArrayPointerValid(aFiles);
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
SafeIfaceArray<IGuestFile> collection(mData.mFiles);
collection.detachTo(ComSafeArrayOutArg(aFiles));
return S_OK;
#endif /* VBOX_WITH_GUEST_CONTROL */
}
// private methods
/////////////////////////////////////////////////////////////////////////////
int GuestSession::directoryClose(ComObjPtr<GuestDirectory> pDirectory)
{
AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
for (SessionDirectories::iterator itDirs = mData.mDirectories.begin();
itDirs != mData.mDirectories.end(); ++itDirs)
{
if (pDirectory == (*itDirs))
{
mData.mDirectories.remove((*itDirs));
return VINF_SUCCESS;
}
}
return VERR_NOT_FOUND;
}
int GuestSession::fileClose(ComObjPtr<GuestFile> pFile)
{
AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
for (SessionFiles::iterator itFiles = mData.mFiles.begin();
itFiles != mData.mFiles.end(); ++itFiles)
{
if (pFile == (*itFiles))
{
mData.mFiles.remove((*itFiles));
return VINF_SUCCESS;
}
}
return VERR_NOT_FOUND;
}
int GuestSession::processClose(ComObjPtr<GuestProcess> pProcess)
{
AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
for (SessionProcesses::iterator itProcs = mData.mProcesses.begin();
itProcs != mData.mProcesses.end(); ++itProcs)
{
if (pProcess == (*itProcs))
{
mData.mProcesses.remove((*itProcs));
return VINF_SUCCESS;
}
}
return VERR_NOT_FOUND;
}
int GuestSession::processCreateExInteral(const Utf8Str &aCommand, ComSafeArrayIn(Utf8Str, aArguments), ComSafeArrayIn(Utf8Str, aEnvironment),
ComSafeArrayIn(ProcessCreateFlag_T, aFlags), ULONG aTimeoutMS,
ProcessPriority_T aPriority, ComSafeArrayIn(LONG, aAffinity),
IGuestProcess **aProcess)
{
AssertPtrReturn(aProcess, VERR_INVALID_POINTER);
/* Validate flags. */
com::SafeArray<ProcessCreateFlag_T> arrFlags(ComSafeArrayInArg(aFlags));
for (size_t i = 0; i < arrFlags.size(); i++)
{
if (arrFlags[i] == ExecuteProcessFlag_None)
continue;
if ( !(arrFlags[i] & ExecuteProcessFlag_IgnoreOrphanedProcesses)
&& !(arrFlags[i] & ExecuteProcessFlag_WaitForProcessStartOnly)
&& !(arrFlags[i] & ExecuteProcessFlag_Hidden)
&& !(arrFlags[i] & ExecuteProcessFlag_NoProfile))
{
return VERR_INVALID_PARAMETER;
}
}
/* Adjust timeout. If set to 0, we define
* an infinite timeout. */
if (aTimeoutMS == 0)
aTimeoutMS = UINT32_MAX;
/** @tood Implement process priority + affinity. */
int rc;
ComObjPtr<GuestProcess> pGuestProcess;
try
{
/* Create the session object. */
HRESULT hr = pGuestProcess.createObject();
if (FAILED(hr)) throw VERR_COM_UNEXPECTED;
rc = pGuestProcess->init(this,
aCommand, ComSafeArrayInArg(aArguments), ComSafeArrayInArg(aEnvironment),
ComSafeArrayInArg(aFlags), aTimeoutMS,
aPriority, ComSafeArrayInArg(aAffinity));
if (RT_FAILURE(rc)) throw rc;
mData.mProcesses.push_back(pGuestProcess);
/* Return guest session to the caller. */
hr = pGuestProcess.queryInterfaceTo(aProcess);
if (FAILED(hr)) throw VERR_COM_OBJECT_NOT_FOUND;
}
catch (int rc2)
{
rc = rc2;
}
return rc;
#if 0
int rc = VINF_SUCCESS;
char **papszArgv = NULL;
try
{
/* Prepare arguments. */
uint32_t uNumArgs = 0;
if (aArguments)
{
com::SafeArray<IN_BSTR> args(ComSafeArrayInArg(aArguments));
uNumArgs = args.size();
papszArgv = (char**)RTMemAlloc(sizeof(char*) * (uNumArgs + 1));
AssertReturn(papszArgv, VERR_NO_MEMORY);
for (unsigned i = 0; RT_SUCCESS(rc) && i < uNumArgs; i++)
rc = RTUtf16ToUtf8(args[i], &papszArgv[i]);
papszArgv[uNumArgs] = NULL;
if (RT_FAILURE(rc))
return rc;
}
char *pszArgs = NULL;
if (uNumArgs)
{
rc = RTGetOptArgvToString(&pszArgs, papszArgv, RTGETOPTARGV_CNV_QUOTE_MS_CRT);
if (RT_FAILURE(rc)) throw rc;
}
/* Get number of arguments. */
uint32_t cbArgs = pszArgs ? strlen(pszArgs) + 1 : 0; /* Include terminating zero. */
/* Prepare environment. */
void *pvEnv = NULL;
uint32_t uNumEnv = 0;
uint32_t cbEnv = 0;
if (aEnvironment)
{
com::SafeArray<IN_BSTR> env(ComSafeArrayInArg(aEnvironment));
for (unsigned i = 0; RT_SUCCESS(rc) && i < env.size(); i++)
rc = prepareExecuteEnv(Utf8Str(env[i]).c_str(), &pvEnv, &cbEnv, &uNumEnv);
}
}
catch (int eRc)
{
rc = exRc;
}
for (unsigned i = 0; i < uNumArgs; i++)
RTMemFree(papszArgv[i]);
RTMemFree(papszArgv);
#endif
return rc;
}
// implementation of public methods
/////////////////////////////////////////////////////////////////////////////
STDMETHODIMP GuestSession::Close(void)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
uninit();
return S_OK;
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::CopyFrom(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(ULONG, aFlags), IProgress **aProgress)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
ReturnComNotImplemented();
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::CopyTo(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(ULONG, aFlags), IProgress **aProgress)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
ReturnComNotImplemented();
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::DirectoryCreate(IN_BSTR aPath, ULONG aMode, ULONG aFlags, IGuestDirectory **aProgress)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
ReturnComNotImplemented();
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::DirectoryCreateTemp(IN_BSTR aTemplate, ULONG aMode, IN_BSTR aName, IGuestDirectory **aDirectory)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
ReturnComNotImplemented();
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::DirectoryExists(IN_BSTR aPath, BOOL *aExists)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
ReturnComNotImplemented();
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::DirectoryOpen(IN_BSTR aPath, IN_BSTR aFilter, IN_BSTR aFlags, IGuestDirectory **aDirectory)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
ReturnComNotImplemented();
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::DirectoryQueryInfo(IN_BSTR aPath, IGuestFsObjInfo **aInfo)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
ReturnComNotImplemented();
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::DirectoryRemove(IN_BSTR aPath)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
ReturnComNotImplemented();
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::DirectoryRemoveRecursive(IN_BSTR aPath, ComSafeArrayIn(DirectoryRemoveRecFlag_T, aFlags), IProgress **aProgress)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
ReturnComNotImplemented();
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::DirectoryRename(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(PathRenameFlag_T, aFlags))
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
ReturnComNotImplemented();
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::DirectorySetACL(IN_BSTR aPath, IN_BSTR aACL)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
ReturnComNotImplemented();
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::EnvironmentClear(void)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
ReturnComNotImplemented();
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::EnvironmentSet(IN_BSTR aName, IN_BSTR aValue)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
ReturnComNotImplemented();
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::EnvironmentSetArray(ComSafeArrayIn(IN_BSTR, aValues))
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
ReturnComNotImplemented();
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::EnvironmentUnset(IN_BSTR aName)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
ReturnComNotImplemented();
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::FileCreateTemp(IN_BSTR aTemplate, ULONG aMode, IN_BSTR aName, IGuestFile **aFile)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
ReturnComNotImplemented();
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::FileExists(IN_BSTR aPath, BOOL *aExists)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
ReturnComNotImplemented();
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::FileOpen(IN_BSTR aPath, IN_BSTR aOpenMode, IN_BSTR aDisposition, ULONG aCreationMode, LONG64 aOffset, IGuestFile **aFile)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
ReturnComNotImplemented();
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::FileQueryInfo(IN_BSTR aPath, IGuestFsObjInfo **aInfo)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
ReturnComNotImplemented();
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::FileQuerySize(IN_BSTR aPath, LONG64 *aSize)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
ReturnComNotImplemented();
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::FileRemove(IN_BSTR aPath)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
ReturnComNotImplemented();
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::FileRename(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(PathRenameFlag_T, aFlags))
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
ReturnComNotImplemented();
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::FileSetACL(IN_BSTR aPath, IN_BSTR aACL)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
ReturnComNotImplemented();
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::ProcessCreate(IN_BSTR aCommand, ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
ComSafeArrayIn(ProcessCreateFlag_T, aFlags), ULONG aTimeoutMS, IGuestProcess **aProcess)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
CheckComArgOutPointerValid(aProcess);
com::SafeArray<LONG> affinity; /** @todo Process affinity, not used yet. */
com::SafeArray<IN_BSTR> arguments(ComSafeArrayInArg(aArguments));
com::SafeArray<Utf8Str> argumentsUtf8(arguments.size());
for (size_t i = 0; i < arguments.size(); i++)
argumentsUtf8[i] = Bstr(arguments[i]);
com::SafeArray<IN_BSTR> environment(ComSafeArrayInArg(aEnvironment));
com::SafeArray<Utf8Str> environmentUtf8(environment.size());
for (size_t i = 0; i < environment.size(); i++)
environmentUtf8[i] = Bstr(environment[i]);
int rc = processCreateExInteral(Utf8Str(aCommand), ComSafeArrayAsInParam(argumentsUtf8), ComSafeArrayAsInParam(environmentUtf8),
ComSafeArrayInArg(aFlags), aTimeoutMS,
ProcessPriority_Default, ComSafeArrayAsInParam(affinity), aProcess);
return RT_SUCCESS(rc) ? S_OK : VBOX_E_IPRT_ERROR;
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::ProcessCreateEx(IN_BSTR aCommand, ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
ComSafeArrayIn(ProcessCreateFlag_T, aFlags), ULONG aTimeoutMS,
ProcessPriority_T aPriority, ComSafeArrayIn(LONG, aAffinity),
IGuestProcess **aProcess)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
CheckComArgOutPointerValid(aProcess);
com::SafeArray<IN_BSTR> arguments(ComSafeArrayInArg(aArguments));
com::SafeArray<Utf8Str> argumentsUtf8(arguments.size());
for (size_t i = 0; i < arguments.size(); i++)
argumentsUtf8[i] = Bstr(arguments[i]);
com::SafeArray<IN_BSTR> environment(ComSafeArrayInArg(aEnvironment));
com::SafeArray<Utf8Str> environmentUtf8(environment.size());
for (size_t i = 0; i < environment.size(); i++)
environmentUtf8[i] = Bstr(environment[i]);
int rc = processCreateExInteral(Utf8Str(aCommand), ComSafeArrayAsInParam(argumentsUtf8), ComSafeArrayAsInParam(environmentUtf8),
ComSafeArrayInArg(aFlags), aTimeoutMS,
aPriority, ComSafeArrayInArg(aAffinity), aProcess);
return RT_SUCCESS(rc) ? S_OK : VBOX_E_IPRT_ERROR;
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::ProcessGet(ULONG aPID, IGuestProcess **aProcess)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
ReturnComNotImplemented();
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::SetTimeout(ULONG aTimeoutMS)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
ReturnComNotImplemented();
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::SymlinkCreate(IN_BSTR aSource, IN_BSTR aTarget, SymlinkType_T aType)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
ReturnComNotImplemented();
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::SymlinkExists(IN_BSTR aSymlink, BOOL *aExists)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
ReturnComNotImplemented();
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::SymlinkRead(IN_BSTR aSymlink, ComSafeArrayIn(SymlinkReadFlag_T, aFlags), BSTR *aTarget)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
ReturnComNotImplemented();
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::SymlinkRemoveDirectory(IN_BSTR aPath)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
ReturnComNotImplemented();
#endif /* VBOX_WITH_GUEST_CONTROL */
}
STDMETHODIMP GuestSession::SymlinkRemoveFile(IN_BSTR aFile)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
ReturnComNotImplemented();
#endif /* VBOX_WITH_GUEST_CONTROL */
}