1 |
|
---|
2 | /* $Id: GuestFileImpl.h 44863 2013-02-28 12:18:17Z vboxsync $ */
|
---|
3 | /** @file
|
---|
4 | * VirtualBox Main - Guest file handling.
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2012-2013 Oracle Corporation
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | */
|
---|
18 |
|
---|
19 | #ifndef ____H_GUESTFILEIMPL
|
---|
20 | #define ____H_GUESTFILEIMPL
|
---|
21 |
|
---|
22 | #include "VirtualBoxBase.h"
|
---|
23 |
|
---|
24 | #include "GuestFsObjInfoImpl.h"
|
---|
25 | #include "GuestCtrlImplPrivate.h"
|
---|
26 |
|
---|
27 | class Console;
|
---|
28 | class GuestSession;
|
---|
29 | class GuestProcess;
|
---|
30 |
|
---|
31 | /**
|
---|
32 | * TODO
|
---|
33 | */
|
---|
34 | class ATL_NO_VTABLE GuestFile :
|
---|
35 | public VirtualBoxBase,
|
---|
36 | public GuestObject,
|
---|
37 | VBOX_SCRIPTABLE_IMPL(IGuestFile)
|
---|
38 | {
|
---|
39 | public:
|
---|
40 | /** @name COM and internal init/term/mapping cruft.
|
---|
41 | * @{ */
|
---|
42 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(GuestFile, IGuestFile)
|
---|
43 | DECLARE_NOT_AGGREGATABLE(GuestFile)
|
---|
44 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
45 | BEGIN_COM_MAP(GuestFile)
|
---|
46 | VBOX_DEFAULT_INTERFACE_ENTRIES(IGuestFile)
|
---|
47 | COM_INTERFACE_ENTRY(IFile)
|
---|
48 | END_COM_MAP()
|
---|
49 | DECLARE_EMPTY_CTOR_DTOR(GuestFile)
|
---|
50 |
|
---|
51 | int init(Console *pConsole, GuestSession *pSession, ULONG uFileID, const GuestFileOpenInfo &openInfo);
|
---|
52 | void uninit(void);
|
---|
53 | HRESULT FinalConstruct(void);
|
---|
54 | void FinalRelease(void);
|
---|
55 | /** @} */
|
---|
56 |
|
---|
57 | /** @name IFile interface.
|
---|
58 | * @{ */
|
---|
59 | STDMETHOD(COMGETTER(CreationMode))(ULONG *aCreationMode);
|
---|
60 | STDMETHOD(COMGETTER(Disposition))(ULONG *aDisposition);
|
---|
61 | STDMETHOD(COMGETTER(FileName))(BSTR *aFileName);
|
---|
62 | STDMETHOD(COMGETTER(InitialSize))(LONG64 *aInitialSize);
|
---|
63 | STDMETHOD(COMGETTER(Offset))(LONG64 *aOffset);
|
---|
64 | STDMETHOD(COMGETTER(OpenMode))(ULONG *aOpenMode);
|
---|
65 |
|
---|
66 | STDMETHOD(Close)(void);
|
---|
67 | STDMETHOD(QueryInfo)(IFsObjInfo **aInfo);
|
---|
68 | STDMETHOD(Read)(ULONG aToRead, ULONG aTimeoutMS, ComSafeArrayOut(BYTE, aData));
|
---|
69 | STDMETHOD(ReadAt)(LONG64 aOffset, ULONG aToRead, ULONG aTimeoutMS, ComSafeArrayOut(BYTE, aData));
|
---|
70 | STDMETHOD(Seek)(LONG64 aOffset, FileSeekType_T aType);
|
---|
71 | STDMETHOD(SetACL)(IN_BSTR aACL);
|
---|
72 | STDMETHOD(Write)(ComSafeArrayIn(BYTE, aData), ULONG aTimeoutMS, ULONG *aWritten);
|
---|
73 | STDMETHOD(WriteAt)(LONG64 aOffset, ComSafeArrayIn(BYTE, aData), ULONG aTimeoutMS, ULONG *aWritten);
|
---|
74 | /** @} */
|
---|
75 |
|
---|
76 | public:
|
---|
77 | /** @name Public internal methods.
|
---|
78 | * @{ */
|
---|
79 | int callbackDispatcher(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
|
---|
80 | static uint32_t getDispositionFromString(const Utf8Str &strDisposition);
|
---|
81 | static uint32_t getOpenModeFromString(const Utf8Str &strOpenMode);
|
---|
82 | int onFileNotify(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, GuestCtrlCallback *pCallback, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData);
|
---|
83 | int onGuestDisconnected(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, GuestCtrlCallback *pCallback, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData);
|
---|
84 | int openFile(int *pGuestRc);
|
---|
85 | /** @} */
|
---|
86 |
|
---|
87 | private:
|
---|
88 |
|
---|
89 | struct Data
|
---|
90 | {
|
---|
91 | /** The internal console object. */
|
---|
92 | Console *mConsole;
|
---|
93 | /** The associate session this file belongs to. */
|
---|
94 | GuestSession *mSession;
|
---|
95 | /** All related callbacks to this file. */
|
---|
96 | GuestCtrlCallbacks mCallbacks;
|
---|
97 | /** The file's open info. */
|
---|
98 | GuestFileOpenInfo mOpenInfo;
|
---|
99 | /** The file's initial size on open. */
|
---|
100 | uint64_t mInitialSize;
|
---|
101 | /** The file's current offset. */
|
---|
102 | uint64_t mOffCurrent;
|
---|
103 | } mData;
|
---|
104 | };
|
---|
105 |
|
---|
106 | #endif /* !____H_GUESTFILEIMPL */
|
---|
107 |
|
---|