Changeset 5806 in vbox for trunk/src/VBox
- Timestamp:
- Nov 20, 2007 6:20:00 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 26217
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ParallelPortImpl.cpp
r5659 r5806 275 275 } 276 276 277 /** 278 * Saves the port settings to the given <Port> node. 279 * 280 * Note that the given node is always empty so it is not necessary to delete 281 * old values. 282 * 283 * @param aNode Node to save the settings to. 284 * 285 * @return 286 */ 277 287 HRESULT ParallelPort::saveSettings (CFGNODE aNode) 278 288 { … … 292 302 CFGLDRSetUInt32Ex (portNode, "IOBase", mData->mIOBase, 16); 293 303 CFGLDRSetUInt32 (portNode, "IRQ", mData->mIRQ); 294 CFGLDRSetBSTR (portNode, "path", mData->mPath); 304 305 /* 'path' is optional in XML */ 306 if (!mData->mPath.isEmpty()) 307 CFGLDRSetBSTR (portNode, "path", mData->mPath); 295 308 296 309 return S_OK; … … 378 391 if (aIRQ > 255) 379 392 return setError (E_INVALIDARG, 380 tr ("Invalid IRQ number: %lu (must be in range [0, %lu])"), 381 aIRQ, 255); 393 tr ("Invalid IRQ number of the parallel port %d: " 394 "%lu (must be in range [0, %lu])"), 395 mData->mSlot, aIRQ, 255); 382 396 383 397 AutoCaller autoCaller (this); … … 432 446 if (aIOBase > 0xFFFF) 433 447 return setError (E_INVALIDARG, 434 tr ("Invalid I/O port base address: %lu (must be in range [0, 0x%X])"), 435 aIOBase, 0, 0xFFFF); 448 tr ("Invalid I/O port base address of the parallel port %d: " 449 "%lu (must be in range [0, 0x%X])"), 450 mData->mSlot, aIOBase, 0, 0xFFFF); 436 451 437 452 AutoCaller autoCaller (this); … … 487 502 if (!*aPath) 488 503 return setError (E_INVALIDARG, 489 tr ("Parallel port path cannot be empty")); 504 tr ("Path of the parallel port %d may not be empty"), 505 mData->mSlot); 490 506 491 507 AutoCaller autoCaller (this); -
trunk/src/VBox/Main/SerialPortImpl.cpp
r5659 r5806 245 245 246 246 AutoLock alock (this); 247 248 HRESULT rc = S_OK; 247 249 248 250 CFGNODE portNode = NULL; … … 273 275 /* pipe/device path */ 274 276 Bstr path; 275 CFGLDRQueryBSTR (portNode, "path", path.asOutParam());277 CFGLDRQueryBSTR (portNode, "path", path.asOutParam()); 276 278 /* server mode */ 277 279 bool fServer = true; … … 282 284 mData->mIOBase = uIOBase; 283 285 mData->mIRQ = uIRQ; 286 287 rc = checkSetPath (path); 288 CheckComRCReturnRC (rc); 289 284 290 mData->mPath = path; 285 291 mData->mServer = fServer; 286 292 287 return S_OK; 288 } 289 293 return rc; 294 } 295 296 /** 297 * Saves the port settings to the given <Port> node. 298 * 299 * Note that the given node is always empty so it is not necessary to delete 300 * old values. 301 * 302 * @param aNode Node to save the settings to. 303 * 304 * @return 305 */ 290 306 HRESULT SerialPort::saveSettings (CFGNODE aNode) 291 307 { … … 320 336 CFGLDRSetUInt32 (portNode, "IRQ", mData->mIRQ); 321 337 CFGLDRSetString (portNode, "hostMode", mode); 322 if (mData->mHostMode != PortMode_DisconnectedPort) 323 { 324 CFGLDRSetBSTR (portNode, "path", mData->mPath); 325 if (mData->mHostMode == PortMode_HostPipePort) 326 CFGLDRSetBool (portNode, "server", !!mData->mServer); 327 } 338 339 /* Always save non-null mPath and mServer to preserve the user values for 340 * later use. Note that 'server' is false by default in XML so we don't 341 * save it when it's false. */ 342 if (!mData->mPath.isEmpty()) 343 CFGLDRSetBSTR (portNode, "path", mData->mPath); 344 if (mData->mServer) 345 CFGLDRSetBool (portNode, "server", !!mData->mServer); 328 346 329 347 return S_OK; … … 406 424 if (mData->mHostMode != aHostMode) 407 425 { 426 switch (aHostMode) 427 { 428 case PortMode_HostPipePort: 429 if (mData->mPath.isEmpty()) 430 return setError (E_INVALIDARG, 431 tr ("Cannot set the host pipe mode of the serial port %d " 432 "because the pipe path is empty or null"), 433 mData->mSlot); 434 break; 435 case PortMode_HostDevicePort: 436 if (mData->mPath.isEmpty()) 437 return setError (E_INVALIDARG, 438 tr ("Cannot set the host device mode of the serial port %d " 439 "because the device path is empty or null"), 440 mData->mSlot); 441 break; 442 case PortMode_DisconnectedPort: 443 break; 444 } 445 408 446 mData.backup(); 409 447 mData->mHostMode = aHostMode; 410 if (aHostMode == PortMode_DisconnectedPort) 411 { 412 mData->mPath.setNull(); 413 mData->mServer = false; 414 } 448 415 449 emitChangeEvent = true; 416 450 } … … 463 497 if (aIRQ > 255) 464 498 return setError (E_INVALIDARG, 465 tr ("Invalid IRQ number: %lu (must be in range [0, %lu])"), 466 aIRQ, 255); 499 tr ("Invalid IRQ number of the serial port %d: " 500 "%lu (must be in range [0, %lu])"), 501 mData->mSlot, aIRQ, 255); 467 502 468 503 AutoCaller autoCaller (this); … … 517 552 if (aIOBase > 0xFFFF) 518 553 return setError (E_INVALIDARG, 519 tr ("Invalid I/O port base address: %lu (must be in range [0, 0x%X])"), 520 aIOBase, 0, 0xFFFF); 554 tr ("Invalid I/O port base address of the serial port %d: " 555 "%lu (must be in range [0, 0x%X])"), 556 mData->mSlot, aIOBase, 0, 0xFFFF); 521 557 522 558 AutoCaller autoCaller (this); … … 565 601 } 566 602 603 /** 604 * Validates COMSETTER(Path) arguments. 605 */ 606 HRESULT SerialPort::checkSetPath (BSTR aPath) 607 { 608 AssertReturn (isLockedOnCurrentThread(), E_FAIL); 609 610 if ((mData->mHostMode == PortMode_HostDevicePort || 611 mData->mHostMode == PortMode_HostPipePort) && 612 (aPath == NULL || *aPath == '\0')) 613 return setError (E_INVALIDARG, 614 tr ("Path of the serial port %d may not be empty or null in " 615 "host pipe or host device mode"), 616 mData->mSlot); 617 618 return S_OK; 619 } 620 567 621 STDMETHODIMP SerialPort::COMSETTER(Path) (INPTR BSTR aPath) 568 622 { 569 623 if (!aPath) 570 624 return E_POINTER; 571 572 if (!*aPath)573 return setError (E_INVALIDARG,574 tr ("Serial port path cannot be empty"));575 576 625 577 626 AutoCaller autoCaller (this); … … 586 635 if (mData->mPath != aPath) 587 636 { 637 HRESULT rc = checkSetPath (aPath); 638 CheckComRCReturnRC (rc); 639 588 640 mData.backup(); 589 641 mData->mPath = aPath; -
trunk/src/VBox/Main/include/SerialPortImpl.h
r4324 r5806 122 122 private: 123 123 124 HRESULT checkSetPath (BSTR aPath); 125 124 126 const ComObjPtr <Machine, ComWeakRef> mParent; 125 127 const ComObjPtr <SerialPort> mPeer;
Note:
See TracChangeset
for help on using the changeset viewer.