GuestSessionImpl.h revision e378dfdadd62aadc0a012c9953322d979d7606e6
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync/* $Id$ */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync/** @file
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * VirtualBox Main - XXX.
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync/*
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * Copyright (C) 2012 Oracle Corporation
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync *
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * available from http://www.virtualbox.org. This file is free software;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * you can redistribute it and/or modify it under the terms of the GNU
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * General Public License (GPL) as published by the Free Software
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef ____H_GUESTSESSIONIMPL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#define ____H_GUESTSESSIONIMPL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#include "VirtualBoxBase.h"
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync#include "GuestCtrlImplPrivate.h"
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#include "GuestProcessImpl.h"
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#include "GuestDirectoryImpl.h"
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#include "GuestFileImpl.h"
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync#include "GuestFsObjInfoImpl.h"
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsyncclass Guest;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync/**
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * TODO
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncclass ATL_NO_VTABLE GuestSession :
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync public VirtualBoxBase,
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync VBOX_SCRIPTABLE_IMPL(IGuestSession)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncpublic:
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync /** @name COM and internal init/term/mapping cruft.
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * @{ */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(GuestSession, IGuestSession)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync DECLARE_NOT_AGGREGATABLE(GuestSession)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync DECLARE_PROTECT_FINAL_CONSTRUCT()
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync BEGIN_COM_MAP(GuestSession)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync VBOX_DEFAULT_INTERFACE_ENTRIES(IGuestSession)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync END_COM_MAP()
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync DECLARE_EMPTY_CTOR_DTOR(GuestSession)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync int init(Guest *aGuest, ULONG aSessionID, Utf8Str aUser, Utf8Str aPassword, Utf8Str aDomain, Utf8Str aName);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync void uninit(void);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync HRESULT FinalConstruct(void);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync void FinalRelease(void);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync /** @} */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync /** @name IGuestSession properties.
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * @{ */
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsync STDMETHOD(COMGETTER(User))(BSTR *aName);
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsync STDMETHOD(COMGETTER(Domain))(BSTR *aDomain);
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsync STDMETHOD(COMGETTER(Name))(BSTR *aName);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync STDMETHOD(COMGETTER(Id))(ULONG *aId);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync STDMETHOD(COMGETTER(Timeout))(ULONG *aTimeout);
7e8ef90d3160234df0f254131b87af4243d79476vboxsync STDMETHOD(COMSETTER(Timeout))(ULONG aTimeout);
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsync STDMETHOD(COMGETTER(Environment))(ComSafeArrayOut(BSTR, aEnvironment));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync STDMETHOD(COMGETTER(Processes))(ComSafeArrayOut(IGuestProcess *, aProcesses));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync STDMETHOD(COMGETTER(Directories))(ComSafeArrayOut(IGuestDirectory *, aDirectories));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync STDMETHOD(COMGETTER(Files))(ComSafeArrayOut(IGuestFile *, aFiles));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync /** @} */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync /** @name IGuestSession methods.
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * @{ */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync STDMETHOD(Close)(void);
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync STDMETHOD(CopyFrom)(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(ULONG, aFlags), IProgress **aProgress);
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync STDMETHOD(CopyTo)(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(ULONG, aFlags), IProgress **aProgress);
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync STDMETHOD(DirectoryCreate)(IN_BSTR aPath, ULONG aMode, ComSafeArrayIn(DirectoryCreateFlag_T, aFlags), IGuestDirectory **aDirectory);
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync STDMETHOD(DirectoryCreateTemp)(IN_BSTR aTemplate, ULONG aMode, IN_BSTR aName, IGuestDirectory **aDirectory);
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync STDMETHOD(DirectoryExists)(IN_BSTR aPath, BOOL *aExists);
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync STDMETHOD(DirectoryOpen)(IN_BSTR aPath, IN_BSTR aFilter, IN_BSTR aFlags, IGuestDirectory **aDirectory);
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync STDMETHOD(DirectoryQueryInfo)(IN_BSTR aPath, IGuestFsObjInfo **aInfo);
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync STDMETHOD(DirectoryRemove)(IN_BSTR aPath);
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsync STDMETHOD(DirectoryRemoveRecursive)(IN_BSTR aPath, ComSafeArrayIn(DirectoryRemoveRecFlag_T, aFlags), IProgress **aProgress);
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsync STDMETHOD(DirectoryRename)(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(PathRenameFlag_T, aFlags));
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync STDMETHOD(DirectorySetACL)(IN_BSTR aPath, IN_BSTR aACL);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync STDMETHOD(EnvironmentClear)(void);
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync STDMETHOD(EnvironmentGet)(IN_BSTR aName, BSTR *aValue);
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync STDMETHOD(EnvironmentSet)(IN_BSTR aName, IN_BSTR aValue);
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync STDMETHOD(EnvironmentSetArray)(ComSafeArrayIn(IN_BSTR, aValues));
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync STDMETHOD(EnvironmentUnset)(IN_BSTR aName);
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync STDMETHOD(FileCreateTemp)(IN_BSTR aTemplate, ULONG aMode, IN_BSTR aName, IGuestFile **aFile);
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync STDMETHOD(FileExists)(IN_BSTR aPath, BOOL *aExists);
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync STDMETHOD(FileOpen)(IN_BSTR aPath, IN_BSTR aOpenMode, IN_BSTR aDisposition, ULONG aCreationMode, LONG64 aOffset, IGuestFile **aFile);
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync STDMETHOD(FileQueryInfo)(IN_BSTR aPath, IGuestFsObjInfo **aInfo);
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync STDMETHOD(FileQuerySize)(IN_BSTR aPath, LONG64 *aSize);
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync STDMETHOD(FileRemove)(IN_BSTR aPath);
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsync STDMETHOD(FileRename)(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(PathRenameFlag_T, aFlags));
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync STDMETHOD(FileSetACL)(IN_BSTR aPath, IN_BSTR aACL);
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync STDMETHOD(ProcessCreate)(IN_BSTR aCommand, ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync ComSafeArrayIn(ProcessCreateFlag_T, aFlags), ULONG aTimeoutMS, IGuestProcess **aProcess);
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync STDMETHOD(ProcessCreateEx)(IN_BSTR aCommand, ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsync ComSafeArrayIn(ProcessCreateFlag_T, aFlags), ULONG aTimeoutMS,
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsync ProcessPriority_T aPriority, ComSafeArrayIn(LONG, aAffinity),
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync IGuestProcess **aProcess);
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync STDMETHOD(ProcessGet)(ULONG aPID, IGuestProcess **aProcess);
a937991834fc0b6218eab7f473c139c326d4cebdvboxsync#if 0
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync STDMETHOD(SetTimeout)(ULONG aTimeoutMS);
a937991834fc0b6218eab7f473c139c326d4cebdvboxsync#endif
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsync STDMETHOD(SymlinkCreate)(IN_BSTR aSource, IN_BSTR aTarget, SymlinkType_T aType);
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync STDMETHOD(SymlinkExists)(IN_BSTR aSymlink, BOOL *aExists);
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsync STDMETHOD(SymlinkRead)(IN_BSTR aSymlink, ComSafeArrayIn(SymlinkReadFlag_T, aFlags), BSTR *aTarget);
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync STDMETHOD(SymlinkRemoveDirectory)(IN_BSTR aPath);
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync STDMETHOD(SymlinkRemoveFile)(IN_BSTR aFile);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync /** @} */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsyncprivate:
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync typedef std::vector <ComObjPtr<GuestDirectory> > SessionDirectories;
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync typedef std::vector <ComObjPtr<GuestFile> > SessionFiles;
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync /** Map of guest processes. The key specifies the internal process number.
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync * To retrieve the process' guest PID use the Id() method of the IProcess interface. */
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync typedef std::map <uint32_t, ComObjPtr<GuestProcess> > SessionProcesses;
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncpublic:
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync /** @name Public internal methods.
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * @{ */
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync int directoryClose(ComObjPtr<GuestDirectory> pDirectory);
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync int directoryCreateInternal(const Utf8Str &strPath, uint32_t uMode, uint32_t uFlags, ComObjPtr<GuestDirectory> &pDirectory);
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync int dispatchToProcess(uint32_t uContextID, uint32_t uFunction, void *pvData, size_t cbData);
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync int fileClose(ComObjPtr<GuestFile> pFile);
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync int fileQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData);
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync int fileQuerySizeInternal(const Utf8Str &strPath, int64_t *pllSize);
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync const GuestCredentials &getCredentials(void);
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync const GuestEnvironment &getEnvironment(void);
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync uint32_t getProtocolVersion(void) { return mData.mProtocolVersion; }
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync int processClose(ComObjPtr<GuestProcess> pProcess);
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync int processCreateExInteral(GuestProcessInfo &procInfo, ComObjPtr<GuestProcess> &pProgress);
24ef2ade0f53030e73f5b4e43f52892b03f7915dvboxsync inline bool processExists(uint32_t uProcessID, ComObjPtr<GuestProcess> *pProcess);
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync inline int processGetByPID(ULONG uPID, ComObjPtr<GuestProcess> *pProcess);
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync int queryInfo(void);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync /** @} */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncprivate:
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync struct Data
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync {
02f7c106d33c45f99ec412a5fe0adde868f700fcvboxsync /** Guest control protocol version to be used.
02f7c106d33c45f99ec412a5fe0adde868f700fcvboxsync * Guest Additions < VBox 4.2 have version 1,
02f7c106d33c45f99ec412a5fe0adde868f700fcvboxsync * any newer version will have version 2. */
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync uint32_t mProtocolVersion;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync /** Flag indicating if this is an internal session
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync * or not. Internal session are not accessible by clients. */
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync bool fInternal;
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync /** Pointer to the parent (Guest). */
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync Guest *mParent;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync /** The session credentials. */
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync GuestCredentials mCredentials;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync /** The (optional) session name. */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync Utf8Str mName;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync /** The session ID. */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ULONG mId;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync /** The session timeout. Default is 30s. */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ULONG mTimeout;
02f7c106d33c45f99ec412a5fe0adde868f700fcvboxsync /** The next process ID for assignment. */
02f7c106d33c45f99ec412a5fe0adde868f700fcvboxsync ULONG mNextProcessID;
02f7c106d33c45f99ec412a5fe0adde868f700fcvboxsync /** The session's environment block. Can be
02f7c106d33c45f99ec412a5fe0adde868f700fcvboxsync * overwritten/extended by ProcessCreate(Ex). */
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync GuestEnvironment mEnvironment;
02f7c106d33c45f99ec412a5fe0adde868f700fcvboxsync /** Directory objects bound to this session. */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync SessionDirectories mDirectories;
02f7c106d33c45f99ec412a5fe0adde868f700fcvboxsync /** File objects bound to this session. */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync SessionFiles mFiles;
02f7c106d33c45f99ec412a5fe0adde868f700fcvboxsync /** Process objects bound to this session. */
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync SessionProcesses mProcesses;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync } mData;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync};
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* !____H_GUESTSESSIONIMPL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync