1 | /* $Id: NetworkAdapterImpl.h 26171 2010-02-02 20:37:36Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | *
|
---|
5 | * VirtualBox COM class implementation
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2006-2009 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_NETWORKADAPTER
|
---|
25 | #define ____H_NETWORKADAPTER
|
---|
26 |
|
---|
27 | #include "VirtualBoxBase.h"
|
---|
28 |
|
---|
29 | class GuestOSType;
|
---|
30 |
|
---|
31 | namespace settings
|
---|
32 | {
|
---|
33 | struct NetworkAdapter;
|
---|
34 | }
|
---|
35 |
|
---|
36 | class ATL_NO_VTABLE NetworkAdapter :
|
---|
37 | public VirtualBoxBase,
|
---|
38 | public VirtualBoxSupportErrorInfoImpl<NetworkAdapter, INetworkAdapter>,
|
---|
39 | public VirtualBoxSupportTranslation<NetworkAdapter>,
|
---|
40 | VBOX_SCRIPTABLE_IMPL(INetworkAdapter)
|
---|
41 | {
|
---|
42 | public:
|
---|
43 |
|
---|
44 | struct Data
|
---|
45 | {
|
---|
46 | Data() : mSlot(0), mEnabled(FALSE),
|
---|
47 | mAttachmentType(NetworkAttachmentType_Null),
|
---|
48 | mCableConnected(TRUE), mLineSpeed(0), mTraceEnabled(FALSE),
|
---|
49 | mHostInterface("") /* cannot be null */,
|
---|
50 | mNATNetwork("") /* cannot be null */
|
---|
51 | {}
|
---|
52 |
|
---|
53 | NetworkAdapterType_T mAdapterType;
|
---|
54 | ULONG mSlot;
|
---|
55 | BOOL mEnabled;
|
---|
56 | Bstr mMACAddress;
|
---|
57 | NetworkAttachmentType_T mAttachmentType;
|
---|
58 | BOOL mCableConnected;
|
---|
59 | ULONG mLineSpeed;
|
---|
60 | BOOL mTraceEnabled;
|
---|
61 | Bstr mTraceFile;
|
---|
62 | Bstr mHostInterface;
|
---|
63 | Bstr mInternalNetwork;
|
---|
64 | Bstr mNATNetwork;
|
---|
65 | };
|
---|
66 |
|
---|
67 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (NetworkAdapter)
|
---|
68 |
|
---|
69 | DECLARE_NOT_AGGREGATABLE(NetworkAdapter)
|
---|
70 |
|
---|
71 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
72 |
|
---|
73 | BEGIN_COM_MAP(NetworkAdapter)
|
---|
74 | COM_INTERFACE_ENTRY (ISupportErrorInfo)
|
---|
75 | COM_INTERFACE_ENTRY (INetworkAdapter)
|
---|
76 | COM_INTERFACE_ENTRY2 (IDispatch, INetworkAdapter)
|
---|
77 | END_COM_MAP()
|
---|
78 |
|
---|
79 | DECLARE_EMPTY_CTOR_DTOR (NetworkAdapter)
|
---|
80 |
|
---|
81 | HRESULT FinalConstruct();
|
---|
82 | void FinalRelease();
|
---|
83 |
|
---|
84 | // public initializer/uninitializer for internal purposes only
|
---|
85 | HRESULT init (Machine *aParent, ULONG aSlot);
|
---|
86 | HRESULT init (Machine *aParent, NetworkAdapter *aThat);
|
---|
87 | HRESULT initCopy (Machine *aParent, NetworkAdapter *aThat);
|
---|
88 | void uninit();
|
---|
89 |
|
---|
90 | // INetworkAdapter properties
|
---|
91 | STDMETHOD(COMGETTER(AdapterType))(NetworkAdapterType_T *aAdapterType);
|
---|
92 | STDMETHOD(COMSETTER(AdapterType))(NetworkAdapterType_T aAdapterType);
|
---|
93 | STDMETHOD(COMGETTER(Slot)) (ULONG *aSlot);
|
---|
94 | STDMETHOD(COMGETTER(Enabled)) (BOOL *aEnabled);
|
---|
95 | STDMETHOD(COMSETTER(Enabled)) (BOOL aEnabled);
|
---|
96 | STDMETHOD(COMGETTER(MACAddress)) (BSTR *aMACAddress);
|
---|
97 | STDMETHOD(COMSETTER(MACAddress)) (IN_BSTR aMACAddress);
|
---|
98 | STDMETHOD(COMGETTER(AttachmentType)) (NetworkAttachmentType_T *aAttachmentType);
|
---|
99 | STDMETHOD(COMGETTER(HostInterface)) (BSTR *aHostInterface);
|
---|
100 | STDMETHOD(COMSETTER(HostInterface)) (IN_BSTR aHostInterface);
|
---|
101 | STDMETHOD(COMGETTER(InternalNetwork)) (BSTR *aInternalNetwork);
|
---|
102 | STDMETHOD(COMSETTER(InternalNetwork)) (IN_BSTR aInternalNetwork);
|
---|
103 | STDMETHOD(COMGETTER(NATNetwork)) (BSTR *aNATNetwork);
|
---|
104 | STDMETHOD(COMSETTER(NATNetwork)) (IN_BSTR aNATNetwork);
|
---|
105 | STDMETHOD(COMGETTER(CableConnected)) (BOOL *aConnected);
|
---|
106 | STDMETHOD(COMSETTER(CableConnected)) (BOOL aConnected);
|
---|
107 | STDMETHOD(COMGETTER(TraceEnabled)) (BOOL *aEnabled);
|
---|
108 | STDMETHOD(COMSETTER(TraceEnabled)) (BOOL aEnabled);
|
---|
109 | STDMETHOD(COMGETTER(LineSpeed)) (ULONG *aSpeed);
|
---|
110 | STDMETHOD(COMSETTER(LineSpeed)) (ULONG aSpeed);
|
---|
111 | STDMETHOD(COMGETTER(TraceFile)) (BSTR *aTraceFile);
|
---|
112 | STDMETHOD(COMSETTER(TraceFile)) (IN_BSTR aTraceFile);
|
---|
113 |
|
---|
114 | // INetworkAdapter methods
|
---|
115 | STDMETHOD(AttachToNAT)();
|
---|
116 | STDMETHOD(AttachToBridgedInterface)();
|
---|
117 | STDMETHOD(AttachToInternalNetwork)();
|
---|
118 | STDMETHOD(AttachToHostOnlyInterface)();
|
---|
119 | STDMETHOD(Detach)();
|
---|
120 |
|
---|
121 | // public methods only for internal purposes
|
---|
122 |
|
---|
123 | HRESULT loadSettings(const settings::NetworkAdapter &data);
|
---|
124 | HRESULT saveSettings(settings::NetworkAdapter &data);
|
---|
125 |
|
---|
126 | bool isModified();
|
---|
127 | void rollback();
|
---|
128 | void commit();
|
---|
129 | void copyFrom (NetworkAdapter *aThat);
|
---|
130 | void applyDefaults (GuestOSType *aOsType);
|
---|
131 |
|
---|
132 | // for VirtualBoxSupportErrorInfoImpl
|
---|
133 | static const wchar_t *getComponentName() { return L"NetworkAdapter"; }
|
---|
134 |
|
---|
135 | private:
|
---|
136 |
|
---|
137 | void detach();
|
---|
138 | void generateMACAddress();
|
---|
139 |
|
---|
140 | const ComObjPtr<Machine, ComWeakRef> mParent;
|
---|
141 | const ComObjPtr<NetworkAdapter> mPeer;
|
---|
142 |
|
---|
143 | bool m_fModified;
|
---|
144 | Backupable<Data> mData;
|
---|
145 | };
|
---|
146 |
|
---|
147 | #endif // ____H_NETWORKADAPTER
|
---|
148 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|