Changeset 49349 in vbox for trunk/src/VBox/Main/include
- Timestamp:
- Oct 31, 2013 4:40:46 PM (11 years ago)
- Location:
- trunk/src/VBox/Main/include
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/GuestCtrlImplPrivate.h
r47817 r49349 101 101 102 102 std::map <Utf8Str, Utf8Str> mEnvironment; 103 }; 104 105 106 /** 107 * Structure for keeping all the relevant guest directory 108 * information around. 109 */ 110 struct GuestDirectoryOpenInfo 111 { 112 /** The directory path. */ 113 Utf8Str mPath; 114 /** Then open filter. */ 115 Utf8Str mFilter; 116 /** Opening flags. */ 117 uint32_t mFlags; 103 118 }; 104 119 … … 313 328 #endif 314 329 315 uint32_t GetOffset() ;316 317 uint32_t GetSize();330 uint32_t GetOffset() { return m_cbOffset; } 331 332 size_t GetSize() { return m_cbSize; } 318 333 319 334 int ParseBlock(GuestProcessStreamBlock &streamBlock); … … 324 339 uint32_t m_cbAllocated; 325 340 /** Currently used size of allocated internal stream buffer. */ 326 uint32_t m_cbSize;341 size_t m_cbSize; 327 342 /** Current offset within the internal stream buffer. */ 328 343 uint32_t m_cbOffset; … … 378 393 }; 379 394 380 class GuestWaitEvent 381 { 382 383 public: 384 385 GuestWaitEvent(uint32_t mCID, const std::list<VBoxEventType_T> &lstEvents); 386 virtual ~GuestWaitEvent(void); 387 388 public: 389 390 uint32_t ContextID(void) { return mCID; }; 391 const ComPtr<IEvent> Event(void) { return mEvent; }; 392 const std::list<VBoxEventType_T> Types(void) { return mEventTypes; }; 393 size_t TypeCount(void) { return mEventTypes.size(); } 394 virtual int Signal(IEvent *pEvent); 395 int Wait(RTMSINTERVAL uTimeoutMS); 395 class GuestWaitEventPayload 396 { 397 398 public: 399 400 GuestWaitEventPayload(void) 401 : uType(0), 402 cbData(0), 403 pvData(NULL) { } 404 405 GuestWaitEventPayload(uint32_t uTypePayload, 406 const void *pvPayload, uint32_t cbPayload) 407 { 408 if (cbPayload) 409 { 410 pvData = RTMemAlloc(cbPayload); 411 if (pvData) 412 { 413 uType = uTypePayload; 414 415 memcpy(pvData, pvPayload, cbPayload); 416 cbData = cbPayload; 417 } 418 else /* Throw IPRT error. */ 419 throw VERR_NO_MEMORY; 420 } 421 else 422 { 423 uType = uTypePayload; 424 425 pvData = NULL; 426 cbData = 0; 427 } 428 } 429 430 virtual ~GuestWaitEventPayload(void) 431 { 432 Clear(); 433 } 434 435 GuestWaitEventPayload& operator=(const GuestWaitEventPayload &that) 436 { 437 CopyFromDeep(that); 438 return *this; 439 } 440 441 public: 442 443 void Clear(void) 444 { 445 if (pvData) 446 { 447 RTMemFree(pvData); 448 cbData = 0; 449 } 450 uType = 0; 451 } 452 453 int CopyFromDeep(const GuestWaitEventPayload &payload) 454 { 455 Clear(); 456 457 int rc; 458 if (payload.cbData) 459 { 460 Assert(payload.cbData); 461 pvData = RTMemAlloc(payload.cbData); 462 if (pvData) 463 { 464 memcpy(pvData, payload.pvData, payload.cbData); 465 cbData = payload.cbData; 466 uType = payload.uType; 467 } 468 else 469 rc = VERR_NO_MEMORY; 470 } 471 else 472 rc = VINF_SUCCESS; 473 474 return rc; 475 } 476 477 const void* Raw(void) const { return pvData; } 478 479 size_t Size(void) const { return cbData; } 480 481 uint32_t Type(void) const { return uType; } 482 483 void* MutableRaw(void) { return pvData; } 484 485 protected: 486 487 /** Type of payload. */ 488 uint32_t uType; 489 /** Size (in bytes) of payload. */ 490 uint32_t cbData; 491 /** Pointer to actual payload data. */ 492 void *pvData; 493 }; 494 495 class GuestWaitEventBase 496 { 497 498 protected: 499 500 GuestWaitEventBase(void); 501 virtual ~GuestWaitEventBase(void); 502 503 public: 504 505 uint32_t ContextID(void) { return mCID; }; 506 int GuestResult(void) { return mGuestRc; } 507 int Result(void) { return mRc; } 508 GuestWaitEventPayload & Payload(void) { return mPayload; } 509 int SignalInternal(int rc, int guestRc, const GuestWaitEventPayload *pPayload); 510 int Wait(RTMSINTERVAL uTimeoutMS); 511 512 protected: 513 514 int Init(uint32_t uCID); 396 515 397 516 protected: 398 517 399 518 /* Shutdown indicator. */ 400 bool fAborted;519 bool mfAborted; 401 520 /* Associated context ID (CID). */ 402 521 uint32_t mCID; 403 /** List of event types this event should404 * be signalled on. */405 std::list<VBoxEventType_T> mEventTypes;406 522 /** The event semaphore for triggering 407 523 * the actual event. */ 408 524 RTSEMEVENT mEventSem; 409 /** Pointer to the actual event. */ 525 /** The event's overall result. If 526 * set to VERR_GSTCTL_GUEST_ERROR, 527 * mGuestRc will contain the actual 528 * error code from the guest side. */ 529 int mRc; 530 /** The event'S overall result from the 531 * guest side. If used, mRc must be 532 * set to VERR_GSTCTL_GUEST_ERROR. */ 533 int mGuestRc; 534 /** The event's payload data. Optional. */ 535 GuestWaitEventPayload mPayload; 536 }; 537 538 /** List of public guest event types. */ 539 typedef std::list < VBoxEventType_T > GuestEventTypes; 540 541 class GuestWaitEvent : public GuestWaitEventBase 542 { 543 544 public: 545 546 GuestWaitEvent(uint32_t uCID); 547 GuestWaitEvent(uint32_t uCID, const GuestEventTypes &lstEvents); 548 virtual ~GuestWaitEvent(void); 549 550 public: 551 552 int Cancel(void); 553 const ComPtr<IEvent> Event(void) { return mEvent; } 554 int SignalExternal(IEvent *pEvent); 555 const GuestEventTypes Types(void) { return mEventTypes; } 556 size_t TypeCount(void) { return mEventTypes.size(); } 557 558 protected: 559 560 int Init(uint32_t uCID); 561 562 protected: 563 564 /** List of public event types this event should 565 * be signalled on. Optional. */ 566 GuestEventTypes mEventTypes; 567 /** Pointer to the actual public event, if any. */ 410 568 ComPtr<IEvent> mEvent; 411 569 }; 412 typedef std::list < GuestWaitEvent* > GuestWaitEvents; 413 typedef std::map < VBoxEventType_T, GuestWaitEvents > GuestWaitEventTypes; 570 /** Map of pointers to guest events. The primary key 571 * contains the context ID. */ 572 typedef std::map < uint32_t, GuestWaitEvent* > GuestWaitEvents; 573 /** Map of wait events per public guest event. Nice for 574 * faster lookups when signalling a whole event group. */ 575 typedef std::map < VBoxEventType_T, GuestWaitEvents > GuestEventGroup; 414 576 415 577 class GuestBase … … 423 585 public: 424 586 425 /** For external event listeners. */ 426 int signalWaitEvents(VBoxEventType_T aType, IEvent *aEvent); 427 587 /** Signals a wait event using a public guest event; also used for 588 * for external event listeners. */ 589 int signalWaitEvent(VBoxEventType_T aType, IEvent *aEvent); 590 /** Signals a wait event using a guest rc. */ 591 int signalWaitEventInternal(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, int guestRc, const GuestWaitEventPayload *pPayload); 592 /** Signals a wait event without letting public guest events know, 593 * extended director's cut version. */ 594 int signalWaitEventInternalEx(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, int rc, int guestRc, const GuestWaitEventPayload *pPayload); 428 595 public: 429 596 … … 431 598 void baseUninit(void); 432 599 int cancelWaitEvents(void); 600 int dispatchGeneric(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb); 433 601 int generateContextID(uint32_t uSessionID, uint32_t uObjectID, uint32_t *puContextID); 434 int registerWaitEvent(uint32_t uSessionID, uint32_t uObjectID, const std::list<VBoxEventType_T> &lstEvents, GuestWaitEvent **ppEvent); 602 int registerWaitEvent(uint32_t uSessionID, uint32_t uObjectID, GuestWaitEvent **ppEvent); 603 int registerWaitEvent(uint32_t uSessionID, uint32_t uObjectID, const GuestEventTypes &lstEvents, GuestWaitEvent **ppEvent); 435 604 void unregisterWaitEvent(GuestWaitEvent *pEvent); 436 605 int waitForEvent(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, VBoxEventType_T *pType, IEvent **ppEvent); … … 448 617 /** Critical section for wait events access. */ 449 618 RTCRITSECT mWaitEventCritSect; 450 /** Map of internal events to wait for. */ 451 GuestWaitEventTypes mWaitEvents; 619 /** Map of registered wait events per event group. */ 620 GuestEventGroup mWaitEventGroups; 621 /** Map of registered wait events. */ 622 GuestWaitEvents mWaitEvents; 452 623 }; 453 624 … … 476 647 477 648 int bindToSession(Console *pConsole, GuestSession *pSession, uint32_t uObjectID); 478 int registerWaitEvent(const std::list<VBoxEventType_T>&lstEvents, GuestWaitEvent **ppEvent);649 int registerWaitEvent(const GuestEventTypes &lstEvents, GuestWaitEvent **ppEvent); 479 650 int sendCommand(uint32_t uFunction, uint32_t uParms, PVBOXHGCMSVCPARM paParms); 480 651 -
trunk/src/VBox/Main/include/GuestDirectoryImpl.h
r43162 r49349 30 30 class ATL_NO_VTABLE GuestDirectory : 31 31 public VirtualBoxBase, 32 public GuestObject, 32 33 VBOX_SCRIPTABLE_IMPL(IGuestDirectory) 33 34 { … … 44 45 DECLARE_EMPTY_CTOR_DTOR(GuestDirectory) 45 46 46 int init( GuestSession *aSession, const Utf8Str &strPath, const Utf8Str &strFilter, uint32_t uFlags);47 int init(Console *pConsole, GuestSession *pSession, ULONG uDirID, const GuestDirectoryOpenInfo &openInfo); 47 48 void uninit(void); 48 49 HRESULT FinalConstruct(void); … … 61 62 /** @name Public internal methods. 62 63 * @{ */ 64 int callbackDispatcher(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb); 65 static Utf8Str guestErrorToString(int guestRc); 66 static HRESULT setErrorExternal(VirtualBoxBase *pInterface, int guestRc); 63 67 /** @} */ 64 68 … … 71 75 struct Data 72 76 { 73 GuestSession *mSession;74 Utf8Str mName;75 Utf8Str mFilter;76 uint32_t m Flags;77 /** The directory's open info. */ 78 GuestDirectoryOpenInfo mOpenInfo; 79 /** The directory's ID. */ 80 uint32_t mID; 77 81 GuestProcessTool mProcessTool; 78 82 } mData; -
trunk/src/VBox/Main/include/GuestProcessImpl.h
r47817 r49349 82 82 int startProcessAsync(void); 83 83 int terminateProcess(uint32_t uTimeoutMS, int *pGuestRc); 84 static ProcessWaitResult_T waitFlagsToResultEx(uint32_t fWaitFlags, ProcessStatus_T procStatus, uint32_t uProcFlags, uint32_t uProtocol);84 static ProcessWaitResult_T waitFlagsToResultEx(uint32_t fWaitFlags, ProcessStatus_T oldStatus, ProcessStatus_T newStatus, uint32_t uProcFlags, uint32_t uProtocol); 85 85 ProcessWaitResult_T waitFlagsToResult(uint32_t fWaitFlags); 86 86 int waitFor(uint32_t fWaitFlags, ULONG uTimeoutMS, ProcessWaitResult_T &waitResult, int *pGuestRc); … … 135 135 * Guest process tool flags. 136 136 */ 137 /** No flags specified. */ 137 /** No flags specified; wait until process terminates. 138 * The maximum waiting time is set in the process' startup 139 * info. */ 138 140 #define GUESTPROCESSTOOL_FLAG_NONE 0 139 /** Rununtil next stream block from stdout has been141 /** Wait until next stream block from stdout has been 140 142 * read in completely, then return. 141 143 */ … … 169 171 bool IsRunning(void); 170 172 173 static int Run(GuestSession *pGuestSession, const GuestProcessStartupInfo &startupInfo, int *pGuestRc); 174 175 static int RunEx(GuestSession *pGuestSession, const GuestProcessStartupInfo &startupInfo, GuestCtrlStreamObjects *pStrmOutObjects, 176 uint32_t cStrmOutObjects, int *pGuestRc); 177 171 178 int TerminatedOk(LONG *pExitCode); 172 179 … … 175 182 protected: 176 183 177 GuestSession *pSession;184 ComObjPtr<GuestSession> pSession; 178 185 ComObjPtr<GuestProcess> pProcess; 179 186 GuestProcessStartupInfo mStartupInfo; -
trunk/src/VBox/Main/include/GuestSessionImpl.h
r47817 r49349 327 327 private: 328 328 329 typedef std::vector <ComObjPtr<GuestDirectory> > SessionDirectories; 329 /** Map of guest directories. The key specifies the internal directory ID. */ 330 typedef std::map <uint32_t, ComObjPtr<GuestDirectory> > SessionDirectories; 330 331 /** Map of guest files. The key specifies the internal file ID. */ 331 332 typedef std::map <uint32_t, ComObjPtr<GuestFile> > SessionFiles; … … 338 339 * @{ */ 339 340 int closeSession(uint32_t uFlags, uint32_t uTimeoutMS, int *pGuestRc); 341 inline bool directoryExists(uint32_t uDirID, ComObjPtr<GuestDirectory> *pDir); 340 342 int directoryRemoveFromList(GuestDirectory *pDirectory); 343 int directoryRemoveInternal(const Utf8Str &strPath, uint32_t uFlags, int *pGuestRc); 341 344 int directoryCreateInternal(const Utf8Str &strPath, uint32_t uMode, uint32_t uFlags, int *pGuestRc); 342 345 int objectCreateTempInternal(const Utf8Str &strTemplate, const Utf8Str &strPath, bool fDirectory, const Utf8Str &strName, int *pGuestRc); 343 int directoryOpenInternal(const Utf8Str &strPath, const Utf8Str &strFilter, uint32_t uFlags, ComObjPtr<GuestDirectory> &pDirectory);346 int directoryOpenInternal(const GuestDirectoryOpenInfo &openInfo, ComObjPtr<GuestDirectory> &pDirectory, int *pGuestRc); 344 347 int directoryQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData, int *pGuestRc); 348 int dispatchToDirectory(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb); 345 349 int dispatchToFile(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb); 350 int dispatchToObject(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb); 346 351 int dispatchToProcess(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb); 347 352 int dispatchToThis(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb); … … 367 372 Guest *getParent(void) { return mParent; } 368 373 uint32_t getProtocolVersion(void) { return mData.mProtocolVersion; } 374 int pathRenameInternal(const Utf8Str &strSource, const Utf8Str &strDest, uint32_t uFlags, int *pGuestRc); 369 375 int processRemoveFromList(GuestProcess *pProcess); 370 376 int processCreateExInteral(GuestProcessStartupInfo &procInfo, ComObjPtr<GuestProcess> &pProgress);
Note:
See TracChangeset
for help on using the changeset viewer.