Changeset 79287 in vbox for trunk/src/VBox/Main
- Timestamp:
- Jun 22, 2019 12:05:44 AM (6 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/idl/VirtualBox.xidl
r79216 r79287 23672 23672 </desc> 23673 23673 </const> 23674 <const name="OnGuestFileSizeChanged" value="103"> 23675 <desc> 23676 See <link to="IGuestFileSizeChangedEvent">IGuestFileSizeChangedEvent</link>. 23677 </desc> 23678 </const> 23674 23679 <!-- End event marker --> 23675 23680 <!-- @todo rename to 'End' as it is exclusive (we use 'last' to be inclusive). --> 23676 <const name="Last" value="10 3">23681 <const name="Last" value="104"> 23677 23682 <desc> 23678 23683 Must be last event, used for iterations and structures relying on numerical event values. … … 24953 24958 > 24954 24959 <desc> 24955 Notification when a guest file changed its current offset .24960 Notification when a guest file changed its current offset via <link to="IFile::seek" />. 24956 24961 </desc> 24957 24962 24958 24963 <attribute name="midlDoesNotLikeEmptyInterfaces" readonly="yes" type="boolean"/> 24959 24964 </interface> 24965 24966 <interface 24967 name="IGuestFileSizeChangedEvent" extends="IGuestFileEvent" 24968 uuid="d78374e9-486e-472f-481b-969746af2480" 24969 wsmap="managed" autogen="VBoxEvent" id="OnGuestFileSizeChanged" 24970 > 24971 <desc> 24972 Notification when a guest file changed its size via <link to="IFile::setSize" />. 24973 </desc> 24974 24975 <attribute name="newSize" readonly="yes" type="long long"/> 24976 </interface> 24977 24960 24978 24961 24979 <interface -
trunk/src/VBox/Main/src-client/GuestFileImpl.cpp
r79285 r79287 41 41 #include <VBox/com/array.h> 42 42 #include <VBox/com/listeners.h> 43 #include <VBox/AssertGuest.h> 43 44 44 45 … … 584 585 } 585 586 587 case GUEST_FILE_NOTIFYTYPE_SET_SIZE: 588 ASSERT_GUEST_MSG_STMT_BREAK(pSvcCbData->mParms == 4, ("mParms=%u\n", pSvcCbData->mParms), 589 rc = VERR_WRONG_PARAMETER_COUNT); 590 ASSERT_GUEST_MSG_STMT_BREAK(pSvcCbData->mpaParms[idx].type == VBOX_HGCM_SVC_PARM_64BIT, 591 ("type=%u\n", pSvcCbData->mpaParms[idx].type), 592 rc = VERR_WRONG_PARAMETER_TYPE); 593 dataCb.u.SetSize.cbSize = pSvcCbData->mpaParms[idx].u.uint64; 594 Log3ThisFunc(("cbSize=%RU64\n", dataCb.u.SetSize.cbSize)); 595 596 fireGuestFileSizeChangedEvent(mEventSource, mSession, this, dataCb.u.SetSize.cbSize); 597 rc = VINF_SUCCESS; 598 break; 599 586 600 default: 587 601 break; … … 1518 1532 HRESULT GuestFile::setSize(LONG64 aSize) 1519 1533 { 1520 RT_NOREF(aSize); 1521 ReturnComNotImplemented(); 1534 LogFlowThisFuncEnter(); 1535 1536 /* 1537 * Validate. 1538 */ 1539 if (aSize < 0) 1540 return setError(E_INVALIDARG, tr("The size (%RI64) cannot be a negative value"), aSize); 1541 1542 /* 1543 * Register event callbacks. 1544 */ 1545 int vrc; 1546 GuestWaitEvent *pWaitEvent = NULL; 1547 GuestEventTypes lstEventTypes; 1548 try 1549 { 1550 lstEventTypes.push_back(VBoxEventType_OnGuestFileStateChanged); 1551 lstEventTypes.push_back(VBoxEventType_OnGuestFileSizeChanged); 1552 } 1553 catch (std::bad_alloc &) 1554 { 1555 return E_OUTOFMEMORY; 1556 } 1557 1558 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 1559 1560 vrc = registerWaitEvent(lstEventTypes, &pWaitEvent); 1561 if (RT_SUCCESS(vrc)) 1562 { 1563 /* 1564 * Send of the HGCM message. 1565 */ 1566 VBOXHGCMSVCPARM aParms[3]; 1567 HGCMSvcSetU32(&aParms[0], pWaitEvent->ContextID()); 1568 HGCMSvcSetU32(&aParms[1], mObjectID /* File handle */); 1569 HGCMSvcSetU64(&aParms[2], aSize); 1570 1571 alock.release(); /* Drop write lock before sending. */ 1572 1573 vrc = sendMessage(HOST_MSG_FILE_SET_SIZE, RT_ELEMENTS(aParms), aParms); 1574 if (RT_SUCCESS(vrc)) 1575 { 1576 /* 1577 * Wait for the event. 1578 */ 1579 VBoxEventType_T enmEvtType; 1580 ComPtr<IEvent> pIEvent; 1581 vrc = waitForEvent(pWaitEvent, RT_MS_1MIN / 2, &enmEvtType, pIEvent.asOutParam()); 1582 if (RT_SUCCESS(vrc)) 1583 { 1584 if (enmEvtType == VBoxEventType_OnGuestFileSizeChanged) 1585 vrc = VINF_SUCCESS; 1586 else 1587 vrc = VWRN_GSTCTL_OBJECTSTATE_CHANGED; 1588 } 1589 if (RT_FAILURE(vrc) && pWaitEvent->HasGuestError()) /* Return guest rc if available. */ 1590 vrc = pWaitEvent->GetGuestError(); 1591 } 1592 1593 /* 1594 * Unregister the wait event and deal with error reporting if needed. 1595 */ 1596 unregisterWaitEvent(pWaitEvent); 1597 } 1598 HRESULT hrc; 1599 if (RT_SUCCESS(vrc)) 1600 hrc = S_OK; 1601 else 1602 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Setting the file size of '%s' to %RU64 (%#RX64) bytes failed: %Rrc"), 1603 mData.mOpenInfo.mFilename.c_str(), aSize, aSize, vrc); 1604 LogFlowFuncLeaveRC(vrc); 1605 return hrc; 1522 1606 } 1523 1607
Note:
See TracChangeset
for help on using the changeset viewer.