GuestSessionImpl.cpp revision 388b6b190a5407548753b7fde12fa58134ec3563
831b4c533723665e3a004ca13c9f413f4221ffbbvboxsync * VirtualBox Main - XXX.
831b4c533723665e3a004ca13c9f413f4221ffbbvboxsync * Copyright (C) 2012 Oracle Corporation
831b4c533723665e3a004ca13c9f413f4221ffbbvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
831b4c533723665e3a004ca13c9f413f4221ffbbvboxsync * available from http://www.virtualbox.org. This file is free software;
831b4c533723665e3a004ca13c9f413f4221ffbbvboxsync * you can redistribute it and/or modify it under the terms of the GNU
831b4c533723665e3a004ca13c9f413f4221ffbbvboxsync * General Public License (GPL) as published by the Free Software
831b4c533723665e3a004ca13c9f413f4221ffbbvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
831b4c533723665e3a004ca13c9f413f4221ffbbvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
831b4c533723665e3a004ca13c9f413f4221ffbbvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
831b4c533723665e3a004ca13c9f413f4221ffbbvboxsync/*******************************************************************************
831b4c533723665e3a004ca13c9f413f4221ffbbvboxsync* Header Files *
831b4c533723665e3a004ca13c9f413f4221ffbbvboxsync*******************************************************************************/
831b4c533723665e3a004ca13c9f413f4221ffbbvboxsync// constructor / destructor
831b4c533723665e3a004ca13c9f413f4221ffbbvboxsync/////////////////////////////////////////////////////////////////////////////
831b4c533723665e3a004ca13c9f413f4221ffbbvboxsync// session task classes
831b4c533723665e3a004ca13c9f413f4221ffbbvboxsync/////////////////////////////////////////////////////////////////////////////
831b4c533723665e3a004ca13c9f413f4221ffbbvboxsyncGuestSessionTask::GuestSessionTask(GuestSession *pSession, Progress *pProgress)
831b4c533723665e3a004ca13c9f413f4221ffbbvboxsyncint GuestSessionTask::setProgress(unsigned uPercent)
&& !fCanceled
&& !fCompleted)
return VINF_SUCCESS;
&& !fCanceled
&& !fCompleted)
return VERR_COM_UNEXPECTED;
return VINF_SUCCESS;
int rc;
procInfo.mName = Utf8StrFmt(GuestSession::tr("Copying file \"%s\" to the guest to \"%s\" (%RU64 bytes)"),
procInfo.mArguments.push_back(Utf8StrFmt("--output=%s", mDest.c_str())); /** @todo Do we need path conversion? */
&& fCanceled)
if (fCanceled)
if (cbToRead == 0)
if ( !fCanceled
if ( cbFileSize > 0
&& cbWrittenTotal == 0)
catch (int rc2)
return rc;
return rc;
return rc;
// public initializer/uninitializer for internal purposes only
return VINF_SUCCESS;
#ifdef VBOX_WITH_GUEST_CONTROL
#ifndef VBOX_WITH_GUEST_CONTROL
return S_OK;
#ifndef VBOX_WITH_GUEST_CONTROL
return S_OK;
#ifndef VBOX_WITH_GUEST_CONTROL
return S_OK;
#ifndef VBOX_WITH_GUEST_CONTROL
return S_OK;
#ifndef VBOX_WITH_GUEST_CONTROL
return S_OK;
#ifndef VBOX_WITH_GUEST_CONTROL
return S_OK;
#ifndef VBOX_WITH_GUEST_CONTROL
return S_OK;
#ifndef VBOX_WITH_GUEST_CONTROL
return hr;
#ifndef VBOX_WITH_GUEST_CONTROL
return S_OK;
#ifndef VBOX_WITH_GUEST_CONTROL
return S_OK;
#ifndef VBOX_WITH_GUEST_CONTROL
return S_OK;
return VINF_SUCCESS;
return VERR_NOT_FOUND;
int GuestSession::directoryCreateInternal(const Utf8Str &strPath, uint32_t uMode, uint32_t uFlags, ComObjPtr<GuestDirectory> &pDirectory)
procInfo.mArguments.push_back(Utf8Str("--parents")); /* We also want to create the parent directories. */
if (uMode)
if (lExitCode != 0)
return VERR_CANT_CREATE;
return rc;
catch (int rc2)
return rc;
int GuestSession::dispatchToProcess(uint32_t uContextID, uint32_t uFunction, void *pvData, size_t cbData)
#ifdef DEBUG
int rc;
return rc;
return VINF_SUCCESS;
return VERR_NOT_FOUND;
&cbRead);
return rc;
return rc;
return VINF_SUCCESS;
return VERR_NOT_FOUND;
int GuestSession::processCreateExInteral(GuestProcessInfo &procInfo, ComObjPtr<GuestProcess> &pProcess)
return VERR_INVALID_PARAMETER;
return rc;
catch (int rc2)
return rc;
if (pProcess)
return VERR_COM_INVALID_OBJECT_STATE;
if (pProcess)
return VINF_SUCCESS;
return VERR_NOT_FOUND;
int rc;
catch (int rc2)
return rc;
static short s_gctrlLegacyWarning = 0;
LogRel((tr("Warning: Guest Additions are older (%ld.%ld) than host capabilities for guest control, please upgrade them. Using protocol version %ld now\n"),
VBOX_FULL_VERSION_GET_MAJOR(uVerAdditions), VBOX_FULL_VERSION_GET_MINOR(uVerAdditions), mData.mProtocolVersion));
return VINF_SUCCESS;
#ifndef VBOX_WITH_GUEST_CONTROL
uninit();
return S_OK;
STDMETHODIMP GuestSession::CopyFrom(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(CopyFileFlag_T, aFlags), IProgress **aProgress)
#ifndef VBOX_WITH_GUEST_CONTROL
if (aFlags)
int rc = startTaskAsync(Utf8StrFmt(tr("Copying \"%ls\" from guest to \"%ls\" on the host"), aSource, aDest),
return hr;
STDMETHODIMP GuestSession::CopyTo(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(CopyFileFlag_T, aFlags), IProgress **aProgress)
#ifndef VBOX_WITH_GUEST_CONTROL
if (aFlags)
int rc = startTaskAsync(Utf8StrFmt(tr("Copying \"%ls\" from host to \"%ls\" on the guest"), aSource, aDest),
return hr;
#ifndef VBOX_WITH_GUEST_CONTROL
if (aFlags)
if (aDirectory)
switch (rc)
case VERR_INVALID_PARAMETER:
case VERR_BROKEN_PIPE:
case VERR_CANT_CREATE:
return hr;
STDMETHODIMP GuestSession::DirectoryCreateTemp(IN_BSTR aTemplate, ULONG aMode, IN_BSTR aName, IGuestDirectory **aDirectory)
#ifndef VBOX_WITH_GUEST_CONTROL
#ifndef VBOX_WITH_GUEST_CONTROL
switch (rc)
return hr;
STDMETHODIMP GuestSession::DirectoryOpen(IN_BSTR aPath, IN_BSTR aFilter, IN_BSTR aFlags, IGuestDirectory **aDirectory)
#ifndef VBOX_WITH_GUEST_CONTROL
#ifndef VBOX_WITH_GUEST_CONTROL
#ifndef VBOX_WITH_GUEST_CONTROL
STDMETHODIMP GuestSession::DirectoryRemoveRecursive(IN_BSTR aPath, ComSafeArrayIn(DirectoryRemoveRecFlag_T, aFlags), IProgress **aProgress)
#ifndef VBOX_WITH_GUEST_CONTROL
STDMETHODIMP GuestSession::DirectoryRename(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(PathRenameFlag_T, aFlags))
#ifndef VBOX_WITH_GUEST_CONTROL
#ifndef VBOX_WITH_GUEST_CONTROL
#ifndef VBOX_WITH_GUEST_CONTROL
return S_OK;
#ifndef VBOX_WITH_GUEST_CONTROL
return S_OK;
#ifndef VBOX_WITH_GUEST_CONTROL
return hr;
#ifndef VBOX_WITH_GUEST_CONTROL
return S_OK;
STDMETHODIMP GuestSession::FileCreateTemp(IN_BSTR aTemplate, ULONG aMode, IN_BSTR aName, IGuestFile **aFile)
#ifndef VBOX_WITH_GUEST_CONTROL
#ifndef VBOX_WITH_GUEST_CONTROL
switch (rc)
return hr;
STDMETHODIMP GuestSession::FileOpen(IN_BSTR aPath, IN_BSTR aOpenMode, IN_BSTR aDisposition, ULONG aCreationMode, LONG64 aOffset, IGuestFile **aFile)
#ifndef VBOX_WITH_GUEST_CONTROL
#ifndef VBOX_WITH_GUEST_CONTROL
#ifndef VBOX_WITH_GUEST_CONTROL
switch (rc)
return hr;
#ifndef VBOX_WITH_GUEST_CONTROL
STDMETHODIMP GuestSession::FileRename(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(PathRenameFlag_T, aFlags))
#ifndef VBOX_WITH_GUEST_CONTROL
#ifndef VBOX_WITH_GUEST_CONTROL
STDMETHODIMP GuestSession::ProcessCreate(IN_BSTR aCommand, ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
#ifndef VBOX_WITH_GUEST_CONTROL
HRESULT hr = ProcessCreateEx(aCommand, ComSafeArrayInArg(aArguments), ComSafeArrayInArg(aEnvironment),
ComSafeArrayInArg(aFlags), aTimeoutMS, ProcessPriority_Default, ComSafeArrayAsInParam(affinity), aProcess);
return hr;
STDMETHODIMP GuestSession::ProcessCreateEx(IN_BSTR aCommand, ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
#ifndef VBOX_WITH_GUEST_CONTROL
if (aArguments)
* have the chance of overwriting/deleting session entries.
if (aEnvironment)
if (aFlags)
if (aAffinity)
switch (rc)
case VERR_MAX_PROCS_REACHED:
return hr;
#ifndef VBOX_WITH_GUEST_CONTROL
if (aPID == 0)
return hr;
#ifndef VBOX_WITH_GUEST_CONTROL
#ifndef VBOX_WITH_GUEST_CONTROL
STDMETHODIMP GuestSession::SymlinkRead(IN_BSTR aSymlink, ComSafeArrayIn(SymlinkReadFlag_T, aFlags), BSTR *aTarget)
#ifndef VBOX_WITH_GUEST_CONTROL
#ifndef VBOX_WITH_GUEST_CONTROL
#ifndef VBOX_WITH_GUEST_CONTROL