1 | /* $Id: ParallelPortImpl.cpp 26167 2010-02-02 19:59:09Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox COM class implementation
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
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 (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
18 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
19 | * additional information or have any questions.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #include "ParallelPortImpl.h"
|
---|
23 | #include "MachineImpl.h"
|
---|
24 | #include "VirtualBoxImpl.h"
|
---|
25 |
|
---|
26 | #include <iprt/string.h>
|
---|
27 | #include <iprt/cpp/utils.h>
|
---|
28 |
|
---|
29 | #include <VBox/settings.h>
|
---|
30 |
|
---|
31 | #include "AutoStateDep.h"
|
---|
32 | #include "AutoCaller.h"
|
---|
33 | #include "Logging.h"
|
---|
34 |
|
---|
35 | ////////////////////////////////////////////////////////////////////////////////
|
---|
36 | //
|
---|
37 | // ParallelPort private data definition
|
---|
38 | //
|
---|
39 | ////////////////////////////////////////////////////////////////////////////////
|
---|
40 |
|
---|
41 | struct ParallelPort::Data
|
---|
42 | {
|
---|
43 | Data()
|
---|
44 | : fModified(false)
|
---|
45 | { }
|
---|
46 |
|
---|
47 | bool fModified;
|
---|
48 |
|
---|
49 | const ComObjPtr<Machine, ComWeakRef> pMachine;
|
---|
50 | const ComObjPtr<ParallelPort> pPeer;
|
---|
51 |
|
---|
52 | Backupable<settings::ParallelPort> bd;
|
---|
53 | };
|
---|
54 |
|
---|
55 | // constructor / destructor
|
---|
56 | /////////////////////////////////////////////////////////////////////////////
|
---|
57 |
|
---|
58 | HRESULT ParallelPort::FinalConstruct()
|
---|
59 | {
|
---|
60 | return S_OK;
|
---|
61 | }
|
---|
62 |
|
---|
63 | void ParallelPort::FinalRelease()
|
---|
64 | {
|
---|
65 | uninit();
|
---|
66 | }
|
---|
67 |
|
---|
68 | // public initializer/uninitializer for internal purposes only
|
---|
69 | /////////////////////////////////////////////////////////////////////////////
|
---|
70 |
|
---|
71 | /**
|
---|
72 | * Initializes the Parallel Port object.
|
---|
73 | *
|
---|
74 | * @param aParent Handle of the parent object.
|
---|
75 | */
|
---|
76 | HRESULT ParallelPort::init(Machine *aParent, ULONG aSlot)
|
---|
77 | {
|
---|
78 | LogFlowThisFunc(("aParent=%p, aSlot=%d\n", aParent, aSlot));
|
---|
79 |
|
---|
80 | ComAssertRet (aParent, E_INVALIDARG);
|
---|
81 |
|
---|
82 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
83 | AutoInitSpan autoInitSpan(this);
|
---|
84 | AssertReturn(autoInitSpan.isOk(), E_FAIL);
|
---|
85 |
|
---|
86 | m = new Data;
|
---|
87 |
|
---|
88 | unconst(m->pMachine) = aParent;
|
---|
89 | /* m->pPeer is left null */
|
---|
90 |
|
---|
91 | m->bd.allocate();
|
---|
92 |
|
---|
93 | /* initialize data */
|
---|
94 | m->bd->ulSlot = aSlot;
|
---|
95 |
|
---|
96 | /* Confirm a successful initialization */
|
---|
97 | autoInitSpan.setSucceeded();
|
---|
98 |
|
---|
99 | return S_OK;
|
---|
100 | }
|
---|
101 |
|
---|
102 | /**
|
---|
103 | * Initializes the Parallel Port object given another serial port object
|
---|
104 | * (a kind of copy constructor). This object shares data with
|
---|
105 | * the object passed as an argument.
|
---|
106 | *
|
---|
107 | * @note This object must be destroyed before the original object
|
---|
108 | * it shares data with is destroyed.
|
---|
109 | *
|
---|
110 | * @note Locks @a aThat object for reading.
|
---|
111 | */
|
---|
112 | HRESULT ParallelPort::init(Machine *aParent, ParallelPort *aThat)
|
---|
113 | {
|
---|
114 | LogFlowThisFunc(("aParent=%p, aThat=%p\n", aParent, aThat));
|
---|
115 |
|
---|
116 | ComAssertRet (aParent && aThat, E_INVALIDARG);
|
---|
117 |
|
---|
118 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
119 | AutoInitSpan autoInitSpan(this);
|
---|
120 | AssertReturn(autoInitSpan.isOk(), E_FAIL);
|
---|
121 |
|
---|
122 | m = new Data;
|
---|
123 |
|
---|
124 | unconst(m->pMachine) = aParent;
|
---|
125 | unconst(m->pPeer) = aThat;
|
---|
126 |
|
---|
127 | AutoCaller thatCaller (aThat);
|
---|
128 | AssertComRCReturnRC(thatCaller.rc());
|
---|
129 |
|
---|
130 | AutoReadLock thatLock(aThat COMMA_LOCKVAL_SRC_POS);
|
---|
131 | m->bd.share(aThat->m->bd);
|
---|
132 |
|
---|
133 | /* Confirm a successful initialization */
|
---|
134 | autoInitSpan.setSucceeded();
|
---|
135 |
|
---|
136 | return S_OK;
|
---|
137 | }
|
---|
138 |
|
---|
139 | /**
|
---|
140 | * Initializes the guest object given another guest object
|
---|
141 | * (a kind of copy constructor). This object makes a private copy of data
|
---|
142 | * of the original object passed as an argument.
|
---|
143 | *
|
---|
144 | * @note Locks @a aThat object for reading.
|
---|
145 | */
|
---|
146 | HRESULT ParallelPort::initCopy(Machine *aParent, ParallelPort *aThat)
|
---|
147 | {
|
---|
148 | LogFlowThisFunc(("aParent=%p, aThat=%p\n", aParent, aThat));
|
---|
149 |
|
---|
150 | ComAssertRet (aParent && aThat, E_INVALIDARG);
|
---|
151 |
|
---|
152 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
153 | AutoInitSpan autoInitSpan(this);
|
---|
154 | AssertReturn(autoInitSpan.isOk(), E_FAIL);
|
---|
155 |
|
---|
156 | m = new Data;
|
---|
157 |
|
---|
158 | unconst(m->pMachine) = aParent;
|
---|
159 | /* m->pPeer is left null */
|
---|
160 |
|
---|
161 | AutoCaller thatCaller(aThat);
|
---|
162 | AssertComRCReturnRC(thatCaller.rc());
|
---|
163 |
|
---|
164 | AutoReadLock thatLock(aThat COMMA_LOCKVAL_SRC_POS);
|
---|
165 | m->bd.attachCopy(aThat->m->bd);
|
---|
166 |
|
---|
167 | /* Confirm a successful initialization */
|
---|
168 | autoInitSpan.setSucceeded();
|
---|
169 |
|
---|
170 | return S_OK;
|
---|
171 | }
|
---|
172 |
|
---|
173 | /**
|
---|
174 | * Uninitializes the instance and sets the ready flag to FALSE.
|
---|
175 | * Called either from FinalRelease() or by the parent when it gets destroyed.
|
---|
176 | */
|
---|
177 | void ParallelPort::uninit()
|
---|
178 | {
|
---|
179 | LogFlowThisFunc(("\n"));
|
---|
180 |
|
---|
181 | /* Enclose the state transition Ready->InUninit->NotReady */
|
---|
182 | AutoUninitSpan autoUninitSpan(this);
|
---|
183 | if (autoUninitSpan.uninitDone())
|
---|
184 | return;
|
---|
185 |
|
---|
186 | m->bd.free();
|
---|
187 |
|
---|
188 | unconst(m->pPeer).setNull();
|
---|
189 | unconst(m->pMachine).setNull();
|
---|
190 |
|
---|
191 | delete m;
|
---|
192 | m = NULL;
|
---|
193 | }
|
---|
194 |
|
---|
195 | // IParallelPort properties
|
---|
196 | /////////////////////////////////////////////////////////////////////////////
|
---|
197 |
|
---|
198 | STDMETHODIMP ParallelPort::COMGETTER(Enabled) (BOOL *aEnabled)
|
---|
199 | {
|
---|
200 | CheckComArgOutPointerValid(aEnabled);
|
---|
201 |
|
---|
202 | AutoCaller autoCaller(this);
|
---|
203 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
204 |
|
---|
205 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
206 |
|
---|
207 | *aEnabled = m->bd->fEnabled;
|
---|
208 |
|
---|
209 | return S_OK;
|
---|
210 | }
|
---|
211 |
|
---|
212 | STDMETHODIMP ParallelPort::COMSETTER(Enabled) (BOOL aEnabled)
|
---|
213 | {
|
---|
214 | LogFlowThisFunc(("aEnabled=%RTbool\n", aEnabled));
|
---|
215 |
|
---|
216 | AutoCaller autoCaller(this);
|
---|
217 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
218 |
|
---|
219 | /* the machine needs to be mutable */
|
---|
220 | AutoMutableStateDependency adep(m->pMachine);
|
---|
221 | if (FAILED(adep.rc())) return adep.rc();
|
---|
222 |
|
---|
223 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
224 |
|
---|
225 | if (m->bd->fEnabled != aEnabled)
|
---|
226 | {
|
---|
227 | if (aEnabled &&
|
---|
228 | m->bd->strPath.isEmpty())
|
---|
229 | return setError (E_INVALIDARG,
|
---|
230 | tr ("Cannot enable the parallel port %d "
|
---|
231 | "because the port path is empty or null"),
|
---|
232 | m->bd->ulSlot);
|
---|
233 |
|
---|
234 | m->bd.backup();
|
---|
235 | m->bd->fEnabled = aEnabled;
|
---|
236 |
|
---|
237 | m->fModified = true;
|
---|
238 | // leave the lock before informing callbacks
|
---|
239 | alock.release();
|
---|
240 |
|
---|
241 | AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
|
---|
242 | m->pMachine->setModified(Machine::IsModified_ParallelPorts);
|
---|
243 | mlock.release();
|
---|
244 |
|
---|
245 | m->pMachine->onParallelPortChange(this);
|
---|
246 | }
|
---|
247 |
|
---|
248 | return S_OK;
|
---|
249 | }
|
---|
250 |
|
---|
251 | STDMETHODIMP ParallelPort::COMGETTER(Slot) (ULONG *aSlot)
|
---|
252 | {
|
---|
253 | CheckComArgOutPointerValid(aSlot);
|
---|
254 |
|
---|
255 | AutoCaller autoCaller(this);
|
---|
256 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
257 |
|
---|
258 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
259 |
|
---|
260 | *aSlot = m->bd->ulSlot;
|
---|
261 |
|
---|
262 | return S_OK;
|
---|
263 | }
|
---|
264 |
|
---|
265 | STDMETHODIMP ParallelPort::COMGETTER(IRQ) (ULONG *aIRQ)
|
---|
266 | {
|
---|
267 | CheckComArgOutPointerValid(aIRQ);
|
---|
268 |
|
---|
269 | AutoCaller autoCaller(this);
|
---|
270 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
271 |
|
---|
272 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
273 |
|
---|
274 | *aIRQ = m->bd->ulIRQ;
|
---|
275 |
|
---|
276 | return S_OK;
|
---|
277 | }
|
---|
278 |
|
---|
279 | STDMETHODIMP ParallelPort::COMSETTER(IRQ)(ULONG aIRQ)
|
---|
280 | {
|
---|
281 | /* check IRQ limits
|
---|
282 | * (when changing this, make sure it corresponds to XML schema */
|
---|
283 | if (aIRQ > 255)
|
---|
284 | return setError (E_INVALIDARG,
|
---|
285 | tr ("Invalid IRQ number of the parallel port %d: "
|
---|
286 | "%lu (must be in range [0, %lu])"),
|
---|
287 | m->bd->ulSlot, aIRQ, 255);
|
---|
288 |
|
---|
289 | AutoCaller autoCaller(this);
|
---|
290 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
291 |
|
---|
292 | /* the machine needs to be mutable */
|
---|
293 | AutoMutableStateDependency adep(m->pMachine);
|
---|
294 | if (FAILED(adep.rc())) return adep.rc();
|
---|
295 |
|
---|
296 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
297 |
|
---|
298 | if (m->bd->ulIRQ != aIRQ)
|
---|
299 | {
|
---|
300 | m->bd.backup();
|
---|
301 | m->bd->ulIRQ = aIRQ;
|
---|
302 |
|
---|
303 | m->fModified = true;
|
---|
304 | // leave the lock before informing callbacks
|
---|
305 | alock.release();
|
---|
306 |
|
---|
307 | AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
|
---|
308 | m->pMachine->setModified(Machine::IsModified_ParallelPorts);
|
---|
309 | mlock.release();
|
---|
310 |
|
---|
311 | m->pMachine->onParallelPortChange(this);
|
---|
312 | }
|
---|
313 |
|
---|
314 | return S_OK;
|
---|
315 | }
|
---|
316 |
|
---|
317 | STDMETHODIMP ParallelPort::COMGETTER(IOBase) (ULONG *aIOBase)
|
---|
318 | {
|
---|
319 | CheckComArgOutPointerValid(aIOBase);
|
---|
320 |
|
---|
321 | AutoCaller autoCaller(this);
|
---|
322 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
323 |
|
---|
324 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
325 |
|
---|
326 | *aIOBase = m->bd->ulIOBase;
|
---|
327 |
|
---|
328 | return S_OK;
|
---|
329 | }
|
---|
330 |
|
---|
331 | STDMETHODIMP ParallelPort::COMSETTER(IOBase)(ULONG aIOBase)
|
---|
332 | {
|
---|
333 | /* check IOBase limits
|
---|
334 | * (when changing this, make sure it corresponds to XML schema */
|
---|
335 | if (aIOBase > 0xFFFF)
|
---|
336 | return setError (E_INVALIDARG,
|
---|
337 | tr ("Invalid I/O port base address of the parallel port %d: "
|
---|
338 | "%lu (must be in range [0, 0x%X])"),
|
---|
339 | m->bd->ulSlot, aIOBase, 0, 0xFFFF);
|
---|
340 |
|
---|
341 | AutoCaller autoCaller(this);
|
---|
342 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
343 |
|
---|
344 | /* the machine needs to be mutable */
|
---|
345 | AutoMutableStateDependency adep(m->pMachine);
|
---|
346 | if (FAILED(adep.rc())) return adep.rc();
|
---|
347 |
|
---|
348 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
349 |
|
---|
350 | if (m->bd->ulIOBase != aIOBase)
|
---|
351 | {
|
---|
352 | m->bd.backup();
|
---|
353 | m->bd->ulIOBase = aIOBase;
|
---|
354 |
|
---|
355 | m->fModified = true;
|
---|
356 | // leave the lock before informing callbacks
|
---|
357 | alock.release();
|
---|
358 |
|
---|
359 | AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
|
---|
360 | m->pMachine->setModified(Machine::IsModified_ParallelPorts);
|
---|
361 | mlock.release();
|
---|
362 |
|
---|
363 | m->pMachine->onParallelPortChange(this);
|
---|
364 | }
|
---|
365 |
|
---|
366 | return S_OK;
|
---|
367 | }
|
---|
368 |
|
---|
369 | STDMETHODIMP ParallelPort::COMGETTER(Path) (BSTR *aPath)
|
---|
370 | {
|
---|
371 | CheckComArgOutPointerValid(aPath);
|
---|
372 |
|
---|
373 | AutoCaller autoCaller(this);
|
---|
374 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
375 |
|
---|
376 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
377 |
|
---|
378 | m->bd->strPath.cloneTo(aPath);
|
---|
379 |
|
---|
380 | return S_OK;
|
---|
381 | }
|
---|
382 |
|
---|
383 | STDMETHODIMP ParallelPort::COMSETTER(Path) (IN_BSTR aPath)
|
---|
384 | {
|
---|
385 | AutoCaller autoCaller(this);
|
---|
386 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
387 |
|
---|
388 | /* the machine needs to be mutable */
|
---|
389 | AutoMutableStateDependency adep(m->pMachine);
|
---|
390 | if (FAILED(adep.rc())) return adep.rc();
|
---|
391 |
|
---|
392 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
393 |
|
---|
394 | Utf8Str str(aPath);
|
---|
395 | if (str != m->bd->strPath)
|
---|
396 | {
|
---|
397 | HRESULT rc = checkSetPath(str);
|
---|
398 | if (FAILED(rc)) return rc;
|
---|
399 |
|
---|
400 | m->bd.backup();
|
---|
401 | m->bd->strPath = str;
|
---|
402 |
|
---|
403 | m->fModified = true;
|
---|
404 | // leave the lock before informing callbacks
|
---|
405 | alock.release();
|
---|
406 |
|
---|
407 | AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
|
---|
408 | m->pMachine->setModified(Machine::IsModified_ParallelPorts);
|
---|
409 | mlock.release();
|
---|
410 |
|
---|
411 | return m->pMachine->onParallelPortChange(this);
|
---|
412 | }
|
---|
413 |
|
---|
414 | return S_OK;
|
---|
415 | }
|
---|
416 |
|
---|
417 | // public methods only for internal purposes
|
---|
418 | ////////////////////////////////////////////////////////////////////////////////
|
---|
419 |
|
---|
420 | /**
|
---|
421 | * Loads settings from the given port node.
|
---|
422 | * May be called once right after this object creation.
|
---|
423 | *
|
---|
424 | * @param aPortNode <Port> node.
|
---|
425 | *
|
---|
426 | * @note Locks this object for writing.
|
---|
427 | */
|
---|
428 | HRESULT ParallelPort::loadSettings(const settings::ParallelPort &data)
|
---|
429 | {
|
---|
430 | AutoCaller autoCaller(this);
|
---|
431 | AssertComRCReturnRC(autoCaller.rc());
|
---|
432 |
|
---|
433 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
434 |
|
---|
435 | // simply copy
|
---|
436 | *m->bd.data() = data;
|
---|
437 |
|
---|
438 | return S_OK;
|
---|
439 | }
|
---|
440 |
|
---|
441 | /**
|
---|
442 | * Saves settings to the given port node.
|
---|
443 | *
|
---|
444 | * Note that the given Port node is comletely empty on input.
|
---|
445 | *
|
---|
446 | * @param aPortNode <Port> node.
|
---|
447 | *
|
---|
448 | * @note Locks this object for reading.
|
---|
449 | */
|
---|
450 | HRESULT ParallelPort::saveSettings(settings::ParallelPort &data)
|
---|
451 | {
|
---|
452 | AutoCaller autoCaller(this);
|
---|
453 | AssertComRCReturnRC(autoCaller.rc());
|
---|
454 |
|
---|
455 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
456 |
|
---|
457 | // simply copy
|
---|
458 | data = *m->bd.data();
|
---|
459 |
|
---|
460 | return S_OK;
|
---|
461 | }
|
---|
462 |
|
---|
463 | /**
|
---|
464 | * @note Locks this object for writing.
|
---|
465 | */
|
---|
466 | bool ParallelPort::rollback()
|
---|
467 | {
|
---|
468 | /* sanity */
|
---|
469 | AutoCaller autoCaller(this);
|
---|
470 | AssertComRCReturn (autoCaller.rc(), false);
|
---|
471 |
|
---|
472 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
473 |
|
---|
474 | bool changed = false;
|
---|
475 |
|
---|
476 | if (m->bd.isBackedUp())
|
---|
477 | {
|
---|
478 | /* we need to check all data to see whether anything will be changed
|
---|
479 | * after rollback */
|
---|
480 | changed = m->bd.hasActualChanges();
|
---|
481 | m->bd.rollback();
|
---|
482 | }
|
---|
483 |
|
---|
484 | return changed;
|
---|
485 | }
|
---|
486 |
|
---|
487 | /**
|
---|
488 | * @note Locks this object for writing, together with the peer object (also
|
---|
489 | * for writing) if there is one.
|
---|
490 | */
|
---|
491 | void ParallelPort::commit()
|
---|
492 | {
|
---|
493 | /* sanity */
|
---|
494 | AutoCaller autoCaller(this);
|
---|
495 | AssertComRCReturnVoid (autoCaller.rc());
|
---|
496 |
|
---|
497 | /* sanity too */
|
---|
498 | AutoCaller peerCaller (m->pPeer);
|
---|
499 | AssertComRCReturnVoid (peerCaller.rc());
|
---|
500 |
|
---|
501 | /* lock both for writing since we modify both (m->pPeer is "master" so locked
|
---|
502 | * first) */
|
---|
503 | AutoMultiWriteLock2 alock(m->pPeer, this COMMA_LOCKVAL_SRC_POS);
|
---|
504 |
|
---|
505 | if (m->bd.isBackedUp())
|
---|
506 | {
|
---|
507 | m->bd.commit();
|
---|
508 | if (m->pPeer)
|
---|
509 | {
|
---|
510 | /* attach new data to the peer and reshare it */
|
---|
511 | m->pPeer->m->bd.attach(m->bd);
|
---|
512 | }
|
---|
513 | }
|
---|
514 | }
|
---|
515 |
|
---|
516 | /**
|
---|
517 | * @note Locks this object for writing, together with the peer object
|
---|
518 | * represented by @a aThat (locked for reading).
|
---|
519 | */
|
---|
520 | void ParallelPort::copyFrom(ParallelPort *aThat)
|
---|
521 | {
|
---|
522 | AssertReturnVoid (aThat != NULL);
|
---|
523 |
|
---|
524 | /* sanity */
|
---|
525 | AutoCaller autoCaller(this);
|
---|
526 | AssertComRCReturnVoid (autoCaller.rc());
|
---|
527 |
|
---|
528 | /* sanity too */
|
---|
529 | AutoCaller thatCaller (aThat);
|
---|
530 | AssertComRCReturnVoid (thatCaller.rc());
|
---|
531 |
|
---|
532 | /* peer is not modified, lock it for reading (aThat is "master" so locked
|
---|
533 | * first) */
|
---|
534 | AutoReadLock rl(aThat COMMA_LOCKVAL_SRC_POS);
|
---|
535 | AutoWriteLock wl(this COMMA_LOCKVAL_SRC_POS);
|
---|
536 |
|
---|
537 | /* this will back up current data */
|
---|
538 | m->bd.assignCopy(aThat->m->bd);
|
---|
539 | }
|
---|
540 |
|
---|
541 | /**
|
---|
542 | * Validates COMSETTER(Path) arguments.
|
---|
543 | */
|
---|
544 | HRESULT ParallelPort::checkSetPath(const Utf8Str &str)
|
---|
545 | {
|
---|
546 | AssertReturn(isWriteLockOnCurrentThread(), E_FAIL);
|
---|
547 |
|
---|
548 | if ( m->bd->fEnabled
|
---|
549 | && str.isEmpty()
|
---|
550 | )
|
---|
551 | return setError(E_INVALIDARG,
|
---|
552 | tr("Path of the parallel port %d may not be empty or null "
|
---|
553 | "when the port is enabled"),
|
---|
554 | m->bd->ulSlot);
|
---|
555 |
|
---|
556 | return S_OK;
|
---|
557 | }
|
---|
558 |
|
---|
559 |
|
---|
560 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|