VirtualBox

source: vbox/trunk/src/VBox/Main/include/SharedFolderImpl.h@ 3330

Last change on this file since 3330 was 2981, checked in by vboxsync, 17 years ago

InnoTek -> innotek: all the headers and comments.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
Line 
1/** @file
2 *
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2007 innotek GmbH
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * If you received this file as part of a commercial VirtualBox
18 * distribution, then only the terms of your commercial VirtualBox
19 * license agreement apply instead of the previous paragraph.
20 */
21
22#ifndef ____H_SHAREDFOLDERIMPL
23#define ____H_SHAREDFOLDERIMPL
24
25#include "VirtualBoxBase.h"
26#include "Collection.h"
27#include <VBox/shflsvc.h>
28
29class Machine;
30class Console;
31class VirtualBox;
32
33class ATL_NO_VTABLE SharedFolder :
34 public VirtualBoxSupportErrorInfoImpl <SharedFolder, ISharedFolder>,
35 public VirtualBoxSupportTranslation <SharedFolder>,
36 public VirtualBoxBase,
37 public ISharedFolder
38{
39public:
40
41 // to satisfy the ComObjPtr template (we have const members)
42 SharedFolder() {}
43
44 DECLARE_NOT_AGGREGATABLE(SharedFolder)
45
46 DECLARE_PROTECT_FINAL_CONSTRUCT()
47
48 BEGIN_COM_MAP(SharedFolder)
49 COM_INTERFACE_ENTRY(ISupportErrorInfo)
50 COM_INTERFACE_ENTRY(ISharedFolder)
51 END_COM_MAP()
52
53 NS_DECL_ISUPPORTS
54
55 HRESULT FinalConstruct();
56 void FinalRelease();
57
58 // public initializer/uninitializer for internal purposes only
59 HRESULT init (Machine *aMachine, const BSTR aName, const BSTR aHostPath);
60 HRESULT initCopy (Machine *aMachine, SharedFolder *aThat);
61 HRESULT init (Console *aConsole, const BSTR aName, const BSTR aHostPath);
62 HRESULT init (VirtualBox *aVirtualBox, const BSTR aName, const BSTR aHostPath);
63 void uninit();
64
65 // ISharedFolder properties
66 STDMETHOD(COMGETTER(Name)) (BSTR *aName);
67 STDMETHOD(COMGETTER(HostPath)) (BSTR *aHostPath);
68 STDMETHOD(COMGETTER(Accessible)) (BOOL *aAccessible);
69
70 // public methods for internal purposes only
71
72 const Bstr &name() const { return mName; }
73 const Bstr &hostPath() const { return mHostPath; }
74
75 // for VirtualBoxSupportErrorInfoImpl
76 static const wchar_t *getComponentName() { return L"SharedFolder"; }
77
78protected:
79
80 HRESULT protectedInit (VirtualBoxBaseWithChildren *aParent,
81 const BSTR aName, const BSTR aHostPath);
82
83private:
84
85 VirtualBoxBaseWithChildren *mParent;
86
87 /* weak parents (only one of them is not null) */
88 ComObjPtr <Machine, ComWeakRef> mMachine;
89 ComObjPtr <Console, ComWeakRef> mConsole;
90 ComObjPtr <VirtualBox, ComWeakRef> mVirtualBox;
91
92 const Bstr mName;
93 const Bstr mHostPath;
94};
95
96COM_DECL_READONLY_ENUM_AND_COLLECTION_BEGIN (SharedFolder)
97
98 STDMETHOD(FindByName) (INPTR BSTR aName, ISharedFolder **aSharedFolder)
99 {
100 if (!aName)
101 return E_INVALIDARG;
102 if (!aSharedFolder)
103 return E_POINTER;
104
105 *aSharedFolder = NULL;
106 Vector::value_type found;
107 Vector::iterator it = vec.begin();
108 while (it != vec.end() && !found)
109 {
110 Bstr name;
111 (*it)->COMGETTER(Name) (name.asOutParam());
112 if (name == aName)
113 found = *it;
114 ++ it;
115 }
116
117 if (!found)
118 return setError (E_INVALIDARG, SharedFolderCollection::tr (
119 "Shared folder named '%ls' could not be found"), aName);
120
121 return found.queryInterfaceTo (aSharedFolder);
122 }
123
124COM_DECL_READONLY_ENUM_AND_COLLECTION_END (SharedFolder)
125
126#endif // ____H_SHAREDFOLDERIMPL
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