[42084] | 1 | /* $Id: GuestDirectoryImpl.h 99085 2023-03-21 12:15:00Z vboxsync $ */
|
---|
| 2 | /** @file
|
---|
[51321] | 3 | * VirtualBox Main - Guest directory handling implementation.
|
---|
[42084] | 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[98103] | 7 | * Copyright (C) 2012-2023 Oracle and/or its affiliates.
|
---|
[42084] | 8 | *
|
---|
[96407] | 9 | * This file is part of VirtualBox base platform packages, as
|
---|
| 10 | * available from https://www.virtualbox.org.
|
---|
| 11 | *
|
---|
| 12 | * This program is free software; you can redistribute it and/or
|
---|
| 13 | * modify it under the terms of the GNU General Public License
|
---|
| 14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
| 15 | * License.
|
---|
| 16 | *
|
---|
| 17 | * This program is distributed in the hope that it will be useful, but
|
---|
| 18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 20 | * General Public License for more details.
|
---|
| 21 | *
|
---|
| 22 | * You should have received a copy of the GNU General Public License
|
---|
| 23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
| 24 | *
|
---|
| 25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
[42084] | 26 | */
|
---|
| 27 |
|
---|
[76562] | 28 | #ifndef MAIN_INCLUDED_GuestDirectoryImpl_h
|
---|
| 29 | #define MAIN_INCLUDED_GuestDirectoryImpl_h
|
---|
[76487] | 30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 31 | # pragma once
|
---|
| 32 | #endif
|
---|
[42084] | 33 |
|
---|
[71250] | 34 | #include "GuestDirectoryWrap.h"
|
---|
| 35 | #include "GuestFsObjInfoImpl.h"
|
---|
[43162] | 36 | #include "GuestProcessImpl.h"
|
---|
[42084] | 37 |
|
---|
[42525] | 38 | class GuestSession;
|
---|
| 39 |
|
---|
[42084] | 40 | /**
|
---|
| 41 | * TODO
|
---|
| 42 | */
|
---|
| 43 | class ATL_NO_VTABLE GuestDirectory :
|
---|
[50559] | 44 | public GuestDirectoryWrap,
|
---|
| 45 | public GuestObject
|
---|
[42084] | 46 | {
|
---|
| 47 | public:
|
---|
| 48 | /** @name COM and internal init/term/mapping cruft.
|
---|
| 49 | * @{ */
|
---|
[90828] | 50 | DECLARE_COMMON_CLASS_METHODS(GuestDirectory)
|
---|
[42084] | 51 |
|
---|
[71406] | 52 | int init(Console *pConsole, GuestSession *pSession, ULONG aObjectID, const GuestDirectoryOpenInfo &openInfo);
|
---|
[42084] | 53 | void uninit(void);
|
---|
[50559] | 54 |
|
---|
[42084] | 55 | HRESULT FinalConstruct(void);
|
---|
| 56 | void FinalRelease(void);
|
---|
| 57 | /** @} */
|
---|
| 58 |
|
---|
| 59 | public:
|
---|
[77587] | 60 | /** @name Implemented virtual methods from GuestObject.
|
---|
[42084] | 61 | * @{ */
|
---|
[50618] | 62 | int i_callbackDispatcher(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
|
---|
[77587] | 63 | int i_onUnregister(void);
|
---|
| 64 | int i_onSessionStatusChange(GuestSessionStatus_T enmSessionStatus);
|
---|
| 65 | /** @} */
|
---|
[50559] | 66 |
|
---|
[77587] | 67 | public:
|
---|
| 68 | /** @name Public internal methods.
|
---|
| 69 | * @{ */
|
---|
[98526] | 70 | int i_open(int *pvrcGuest);
|
---|
| 71 | int i_close(int *pvrcGuest);
|
---|
| 72 | EventSource *i_getEventSource(void) { return mEventSource; }
|
---|
| 73 | int i_onDirNotify(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData);
|
---|
[99085] | 74 | int i_listInternal(uint32_t cMaxEntries, uint32_t fFlags, std::vector<GuestFsObjData> &vecObjData, int *pvrcGuest);
|
---|
| 75 | int i_listEx(uint32_t cMaxEntries, uint32_t fFlags, std::vector<ComObjPtr<GuestFsObjInfo>> &vecObjInfo, int *pvrcGuest);
|
---|
| 76 | int i_list(uint32_t cMaxEntries, std::vector<ComObjPtr<GuestFsObjInfo>> &vecObjInfo, int *pvrcGuest);
|
---|
[98272] | 77 | int i_read(ComObjPtr<GuestFsObjInfo> &fsObjInfo, int *pvrcGuest);
|
---|
[98526] | 78 | int i_readInternal(GuestFsObjData &objData, int *pvrcGuest);
|
---|
| 79 | int i_rewind(uint32_t uTimeoutMS, int *pvrcGuest);
|
---|
| 80 | int i_setStatus(DirectoryStatus_T enmStatus, int vrcDir);
|
---|
[98709] | 81 | int i_waitForStatusChange(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, DirectoryStatus_T *penmStatus, int *prcGuest);
|
---|
[71250] | 82 | /** @} */
|
---|
| 83 |
|
---|
[98526] | 84 | #ifdef VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT
|
---|
| 85 | int i_openViaToolbox(int *pvrcGuest);
|
---|
| 86 | int i_closeViaToolbox(int *pvrcGuest);
|
---|
| 87 | int i_readInternalViaToolbox(GuestFsObjData &objData, int *pvrcGuest);
|
---|
| 88 | #endif /* VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT */
|
---|
| 89 |
|
---|
[71250] | 90 | public:
|
---|
| 91 | /** @name Public static internal methods.
|
---|
| 92 | * @{ */
|
---|
[98272] | 93 | static Utf8Str i_guestErrorToString(int vrcGuest, const char *pcszWhat);
|
---|
[99085] | 94 | static void i_dirNotifyDataDestroy(PCALLBACKDATA_DIR_NOTIFY pDirNotify);
|
---|
[42084] | 95 | /** @} */
|
---|
| 96 |
|
---|
| 97 | private:
|
---|
| 98 |
|
---|
[71250] | 99 | /** Wrapped @name IGuestDirectory properties
|
---|
[42673] | 100 | * @{ */
|
---|
[50559] | 101 | HRESULT getDirectoryName(com::Utf8Str &aDirectoryName);
|
---|
| 102 | HRESULT getFilter(com::Utf8Str &aFilter);
|
---|
[71250] | 103 | /** @} */
|
---|
[42673] | 104 |
|
---|
[71250] | 105 | /** Wrapped @name IGuestDirectory methods.
|
---|
[50559] | 106 | * @{ */
|
---|
[51556] | 107 | HRESULT close();
|
---|
[98526] | 108 | HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
|
---|
| 109 | HRESULT getId(ULONG *aId);
|
---|
| 110 | HRESULT getStatus(DirectoryStatus_T *aStatus);
|
---|
[99085] | 111 | HRESULT list(ULONG aMaxEntries, std::vector<ComPtr<IFsObjInfo> > &aObjInfos);
|
---|
[51556] | 112 | HRESULT read(ComPtr<IFsObjInfo> &aObjInfo);
|
---|
[98526] | 113 | HRESULT rewind(void);
|
---|
[71250] | 114 | /** @} */
|
---|
[50559] | 115 |
|
---|
[98526] | 116 | /** This can safely be used without holding any locks.
|
---|
| 117 | * An AutoCaller suffices to prevent it being destroy while in use and
|
---|
| 118 | * internally there is a lock providing the necessary serialization. */
|
---|
| 119 | const ComObjPtr<EventSource> mEventSource;
|
---|
| 120 |
|
---|
[42084] | 121 | struct Data
|
---|
| 122 | {
|
---|
[49349] | 123 | /** The directory's open info. */
|
---|
| 124 | GuestDirectoryOpenInfo mOpenInfo;
|
---|
[98526] | 125 | /** The current directory status. */
|
---|
| 126 | DirectoryStatus_T mStatus;
|
---|
| 127 | /** The last returned directory error returned from the guest side. */
|
---|
| 128 | int mLastError;
|
---|
| 129 | # ifdef VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT
|
---|
[60622] | 130 | /** The process tool instance to use. */
|
---|
[98526] | 131 | GuestProcessToolbox mProcessTool;
|
---|
| 132 | # endif
|
---|
[83489] | 133 | /** Object data cache.
|
---|
| 134 | * Its mName attribute acts as a beacon if the cache is valid or not. */
|
---|
| 135 | GuestFsObjData mObjData;
|
---|
[42084] | 136 | } mData;
|
---|
| 137 | };
|
---|
| 138 |
|
---|
[76562] | 139 | #endif /* !MAIN_INCLUDED_GuestDirectoryImpl_h */
|
---|
[42084] | 140 |
|
---|