VirtualBox

source: vbox/trunk/src/VBox/Main/include/GuestDirectoryImpl.h@ 99085

Last change on this file since 99085 was 99085, checked in by vboxsync, 21 months ago

Guest Control: Added directory listing support via IDirectory::list(). Added (randomized) testcase support for it. bugref:9783

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.1 KB
Line 
1/* $Id: GuestDirectoryImpl.h 99085 2023-03-21 12:15:00Z vboxsync $ */
2/** @file
3 * VirtualBox Main - Guest directory handling implementation.
4 */
5
6/*
7 * Copyright (C) 2012-2023 Oracle and/or its affiliates.
8 *
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
26 */
27
28#ifndef MAIN_INCLUDED_GuestDirectoryImpl_h
29#define MAIN_INCLUDED_GuestDirectoryImpl_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34#include "GuestDirectoryWrap.h"
35#include "GuestFsObjInfoImpl.h"
36#include "GuestProcessImpl.h"
37
38class GuestSession;
39
40/**
41 * TODO
42 */
43class ATL_NO_VTABLE GuestDirectory :
44 public GuestDirectoryWrap,
45 public GuestObject
46{
47public:
48 /** @name COM and internal init/term/mapping cruft.
49 * @{ */
50 DECLARE_COMMON_CLASS_METHODS(GuestDirectory)
51
52 int init(Console *pConsole, GuestSession *pSession, ULONG aObjectID, const GuestDirectoryOpenInfo &openInfo);
53 void uninit(void);
54
55 HRESULT FinalConstruct(void);
56 void FinalRelease(void);
57 /** @} */
58
59public:
60 /** @name Implemented virtual methods from GuestObject.
61 * @{ */
62 int i_callbackDispatcher(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
63 int i_onUnregister(void);
64 int i_onSessionStatusChange(GuestSessionStatus_T enmSessionStatus);
65 /** @} */
66
67public:
68 /** @name Public internal methods.
69 * @{ */
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);
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);
77 int i_read(ComObjPtr<GuestFsObjInfo> &fsObjInfo, int *pvrcGuest);
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);
81 int i_waitForStatusChange(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, DirectoryStatus_T *penmStatus, int *prcGuest);
82 /** @} */
83
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
90public:
91 /** @name Public static internal methods.
92 * @{ */
93 static Utf8Str i_guestErrorToString(int vrcGuest, const char *pcszWhat);
94 static void i_dirNotifyDataDestroy(PCALLBACKDATA_DIR_NOTIFY pDirNotify);
95 /** @} */
96
97private:
98
99 /** Wrapped @name IGuestDirectory properties
100 * @{ */
101 HRESULT getDirectoryName(com::Utf8Str &aDirectoryName);
102 HRESULT getFilter(com::Utf8Str &aFilter);
103 /** @} */
104
105 /** Wrapped @name IGuestDirectory methods.
106 * @{ */
107 HRESULT close();
108 HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
109 HRESULT getId(ULONG *aId);
110 HRESULT getStatus(DirectoryStatus_T *aStatus);
111 HRESULT list(ULONG aMaxEntries, std::vector<ComPtr<IFsObjInfo> > &aObjInfos);
112 HRESULT read(ComPtr<IFsObjInfo> &aObjInfo);
113 HRESULT rewind(void);
114 /** @} */
115
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
121 struct Data
122 {
123 /** The directory's open info. */
124 GuestDirectoryOpenInfo mOpenInfo;
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
130 /** The process tool instance to use. */
131 GuestProcessToolbox mProcessTool;
132# endif
133 /** Object data cache.
134 * Its mName attribute acts as a beacon if the cache is valid or not. */
135 GuestFsObjData mObjData;
136 } mData;
137};
138
139#endif /* !MAIN_INCLUDED_GuestDirectoryImpl_h */
140
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette