VirtualBox

source: vbox/trunk/src/VBox/Main/include/FloppyDriveImpl.h@ 16560

Last change on this file since 16560 was 15991, checked in by vboxsync, 15 years ago

Main: Fixed: CD/DVD and Floppy not locked for reading when manually attached at VM runtime (#3504).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
Line 
1/* $Id: FloppyDriveImpl.h 15991 2009-01-16 14:02:20Z vboxsync $ */
2
3/** @file
4 *
5 * VirtualBox COM class implementation
6 */
7
8/*
9 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.virtualbox.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
20 * Clara, CA 95054 USA or visit http://www.sun.com if you need
21 * additional information or have any questions.
22 */
23
24#ifndef ____H_FLOPPYDRIVEIMPL
25#define ____H_FLOPPYDRIVEIMPL
26
27#include "VirtualBoxBase.h"
28
29#include "MediumImpl.h"
30
31class Machine;
32
33class ATL_NO_VTABLE FloppyDrive :
34 public VirtualBoxBaseNEXT,
35 public VirtualBoxSupportErrorInfoImpl <FloppyDrive, IFloppyDrive>,
36 public VirtualBoxSupportTranslation <FloppyDrive>,
37 public IFloppyDrive
38{
39public:
40
41 struct Data
42 {
43 Data()
44 {
45 enabled = true;
46 state = DriveState_NotMounted;
47 }
48
49 bool operator== (const Data &that) const
50 {
51 return this == &that ||
52 (state == that.state &&
53 image.equalsTo (that.image) &&
54 hostDrive.equalsTo (that.hostDrive));
55 }
56
57 BOOL enabled;
58 ComObjPtr <FloppyImage2> image;
59 ComPtr <IHostFloppyDrive> hostDrive;
60 DriveState_T state;
61 };
62
63 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (FloppyDrive)
64
65 DECLARE_NOT_AGGREGATABLE(FloppyDrive)
66
67 DECLARE_PROTECT_FINAL_CONSTRUCT()
68
69 BEGIN_COM_MAP(FloppyDrive)
70 COM_INTERFACE_ENTRY(ISupportErrorInfo)
71 COM_INTERFACE_ENTRY(IFloppyDrive)
72 END_COM_MAP()
73
74 NS_DECL_ISUPPORTS
75
76 DECLARE_EMPTY_CTOR_DTOR (FloppyDrive)
77
78 HRESULT FinalConstruct();
79 void FinalRelease();
80
81 // public initializer/uninitializer for internal purposes only
82 HRESULT init (Machine *aParent);
83 HRESULT init (Machine *aParent, FloppyDrive *aThat);
84 HRESULT initCopy (Machine *parent, FloppyDrive *aThat);
85 void uninit();
86
87 // IFloppyDrive properties
88 STDMETHOD(COMGETTER(Enabled)) (BOOL *aEnabled);
89 STDMETHOD(COMSETTER(Enabled)) (BOOL aEnabled);
90 STDMETHOD(COMGETTER(State)) (DriveState_T *aState);
91
92 // IFloppyDrive methods
93 STDMETHOD(MountImage) (IN_GUID aImageId);
94 STDMETHOD(CaptureHostDrive) (IHostFloppyDrive *aHostFloppyDrive);
95 STDMETHOD(Unmount)();
96 STDMETHOD(GetImage) (IFloppyImage2 **aFloppyImage);
97 STDMETHOD(GetHostDrive) (IHostFloppyDrive **aHostFloppyDrive);
98
99 // public methods only for internal purposes
100
101 HRESULT loadSettings (const settings::Key &aMachineNode);
102 HRESULT saveSettings (settings::Key &aMachineNode);
103
104 bool isModified() { AutoWriteLock alock (this); return m.isBackedUp(); }
105 bool isReallyModified() { AutoWriteLock alock (this); return m.hasActualChanges(); }
106 bool rollback();
107 void commit();
108 void copyFrom (FloppyDrive *aThat);
109
110 HRESULT unmount();
111
112 // public methods for internal purposes only
113 // (ensure there is a caller and a read lock before calling them!)
114
115 Backupable <Data> &data() { return m; }
116
117 // for VirtualBoxSupportErrorInfoImpl
118 static const wchar_t *getComponentName() { return L"FloppyDrive"; }
119
120private:
121
122 const ComObjPtr <Machine, ComWeakRef> mParent;
123 const ComObjPtr <FloppyDrive> mPeer;
124
125 Backupable <Data> m;
126};
127
128#endif // ____H_FLOPPYDRIVEIMPL
129/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use