Changeset 52251 in vbox
- Timestamp:
- Aug 1, 2014 6:07:28 AM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 95340
- Location:
- trunk/src/VBox/Main
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/src/VBox/Main/idl/VirtualBox.xidl ¶
r52200 r52251 17744 17744 <interface 17745 17745 name="IInternalSessionControl" extends="$unknown" 17746 uuid=" 2d2124a7-0f62-4907-ae21-eee5a559bdde"17746 uuid="b7c71040-2761-42c4-a44a-4e2c2d7e2820" 17747 17747 internal="yes" 17748 17748 wsmap="suppress" … … 18151 18151 <param name="value" type="wstring" dir="in"/> 18152 18152 <param name="flags" type="wstring" dir="in"/> 18153 <param name="isSetter" type="boolean" dir="in"/> 18153 <param name="accessMode" type="unsigned long" dir="in"> 18154 <desc>0 = get, 1 = set, 2 = delete.</desc> 18155 </param> 18154 18156 <param name="retValue" type="wstring" dir="out"/> 18155 18157 <param name="retTimestamp" type="long long" dir="out"/> -
TabularUnified trunk/src/VBox/Main/include/ConsoleImpl.h ¶
r52019 r52251 174 174 HRESULT i_onExtraDataChange(IN_BSTR aMachineId, IN_BSTR aKey, IN_BSTR aVal); 175 175 176 HRESULT i_getGuestProperty(IN_BSTR aKey, BSTR *aValue, LONG64 *aTimestamp, BSTR *aFlags); 177 HRESULT i_setGuestProperty(IN_BSTR aKey, IN_BSTR aValue, IN_BSTR aFlags); 176 HRESULT i_getGuestProperty(const Utf8Str &aName, Utf8Str *aValue, LONG64 *aTimestamp, Utf8Str *aFlags); 177 HRESULT i_setGuestProperty(const Utf8Str &aName, const Utf8Str &aValue, const Utf8Str &aFlags); 178 HRESULT i_deleteGuestProperty(const Utf8Str &aName); 178 179 HRESULT i_enumerateGuestProperties(IN_BSTR aPatterns, 179 180 ComSafeArrayOut(BSTR, aNames), -
TabularUnified trunk/src/VBox/Main/include/MachineImpl.h ¶
r52171 r52251 718 718 LONG64 *aTimestamp, com::Utf8Str &aFlags) const; 719 719 HRESULT i_setGuestPropertyToService(const com::Utf8Str &aName, const com::Utf8Str &aValue, 720 const com::Utf8Str &aFlags );720 const com::Utf8Str &aFlags, bool fDelete); 721 721 HRESULT i_getGuestPropertyFromVM(const com::Utf8Str &aName, com::Utf8Str &aValue, 722 722 LONG64 *aTimestamp, com::Utf8Str &aFlags) const; 723 723 HRESULT i_setGuestPropertyToVM(const com::Utf8Str &aName, const com::Utf8Str &aValue, 724 const com::Utf8Str &aFlags );724 const com::Utf8Str &aFlags, bool fDelete); 725 725 HRESULT i_enumerateGuestPropertiesInService(const com::Utf8Str &aPatterns, 726 726 std::vector<com::Utf8Str> &aNames, -
TabularUnified trunk/src/VBox/Main/include/SessionImpl.h ¶
r52248 r52251 107 107 const com::Utf8Str &aValue, 108 108 const com::Utf8Str &aFlags, 109 BOOL aIsSetter,109 ULONG aAccessMode, 110 110 com::Utf8Str &aRetValue, 111 111 LONG64 *aRetTimestamp, -
TabularUnified trunk/src/VBox/Main/src-client/ConsoleImpl.cpp ¶
r52107 r52251 1283 1283 { 1284 1284 /* Provide credentials only if there are no logged in users. */ 1285 Bstr noLoggedInUsersValue;1285 Utf8Str noLoggedInUsersValue; 1286 1286 LONG64 ul64Timestamp = 0; 1287 Bstr flags;1288 1289 hrc = i_getGuestProperty( Bstr("/VirtualBox/GuestInfo/OS/NoLoggedInUsers").raw(),1290 noLoggedInUsersValue.asOutParam(), &ul64Timestamp, flags.asOutParam());1291 1292 if (SUCCEEDED(hrc) && noLoggedInUsersValue != Bstr("false"))1287 Utf8Str flags; 1288 1289 hrc = i_getGuestProperty("/VirtualBox/GuestInfo/OS/NoLoggedInUsers", 1290 &noLoggedInUsersValue, &ul64Timestamp, &flags); 1291 1292 if (SUCCEEDED(hrc) && noLoggedInUsersValue != "false") 1293 1293 { 1294 1294 /* And only if there are no connected clients. */ … … 5567 5567 * @note Temporarily locks this object for writing. 5568 5568 */ 5569 HRESULT Console::i_getGuestProperty( IN_BSTR aName, BSTR *aValue, LONG64 *aTimestamp, BSTR*aFlags)5569 HRESULT Console::i_getGuestProperty(const Utf8Str &aName, Utf8Str *aValue, LONG64 *aTimestamp, Utf8Str *aFlags) 5570 5570 { 5571 5571 #ifndef VBOX_WITH_GUEST_PROPS 5572 5572 ReturnComNotImplemented(); 5573 5573 #else /* VBOX_WITH_GUEST_PROPS */ 5574 if (! VALID_PTR(aName))5575 return E_INVALIDARG;5576 if ( !VALID_PTR(aValue))5574 if (!RT_VALID_PTR(aValue)) 5575 return E_POINTER; 5576 if (aTimestamp != NULL && !RT_VALID_PTR(aTimestamp)) 5577 5577 return E_POINTER; 5578 if ((aTimestamp != NULL) && !VALID_PTR(aTimestamp)) 5579 return E_POINTER; 5580 if ((aFlags != NULL) && !VALID_PTR(aFlags)) 5578 if (aFlags != NULL && !RT_VALID_PTR(aFlags)) 5581 5579 return E_POINTER; 5582 5580 … … 5598 5596 { 5599 5597 VBOXHGCMSVCPARM parm[4]; 5600 Utf8Str Utf8Name = aName;5601 5598 char szBuffer[MAX_VALUE_LEN + MAX_FLAGS_LEN]; 5602 5599 5603 5600 parm[0].type = VBOX_HGCM_SVC_PARM_PTR; 5604 parm[0].u.pointer.addr = (void*) Utf8Name.c_str();5605 /* The + 1 is the null terminator */5606 parm[0].u.pointer.size = (uint32_t)Utf8Name.length() + 1; 5601 parm[0].u.pointer.addr = (void*)aName.c_str(); 5602 parm[0].u.pointer.size = (uint32_t)aName.length() + 1; /* The + 1 is the null terminator */ 5603 5607 5604 parm[1].type = VBOX_HGCM_SVC_PARM_PTR; 5608 5605 parm[1].u.pointer.addr = szBuffer; 5609 5606 parm[1].u.pointer.size = sizeof(szBuffer); 5607 5608 parm[2].type = VBOX_HGCM_SVC_PARM_64BIT; 5609 parm[2].u.uint64 = 0; 5610 5611 parm[3].type = VBOX_HGCM_SVC_PARM_32BIT; 5612 parm[3].u.uint32 = 0; 5613 5610 5614 int vrc = m_pVMMDev->hgcmHostCall("VBoxGuestPropSvc", GET_PROP_HOST, 5611 5615 4, &parm[0]); 5612 5616 /* The returned string should never be able to be greater than our buffer */ 5613 5617 AssertLogRel(vrc != VERR_BUFFER_OVERFLOW); 5614 AssertLogRel(RT_FAILURE(vrc) || VBOX_HGCM_SVC_PARM_64BIT == parm[2].type); 5615 if (RT_SUCCESS(vrc) || (VERR_NOT_FOUND == vrc)) 5616 { 5618 AssertLogRel(RT_FAILURE(vrc) || parm[2].type == VBOX_HGCM_SVC_PARM_64BIT); 5619 if (RT_SUCCESS(vrc)) 5620 { 5621 *aValue = szBuffer; 5622 5623 if (aTimestamp) 5624 *aTimestamp = parm[2].u.uint64; 5625 5626 if (aFlags) 5627 *aFlags = &szBuffer[strlen(szBuffer) + 1]; 5628 5617 5629 rc = S_OK; 5618 if (vrc != VERR_NOT_FOUND) 5619 { 5620 Utf8Str strBuffer(szBuffer); 5621 strBuffer.cloneTo(aValue); 5622 5623 if (aTimestamp) 5624 *aTimestamp = parm[2].u.uint64; 5625 5626 if (aFlags) 5627 { 5628 size_t iFlags = strBuffer.length() + 1; 5629 Utf8Str(szBuffer + iFlags).cloneTo(aFlags); 5630 } 5631 } 5632 else 5633 aValue = NULL; 5630 } 5631 else if (vrc == VERR_NOT_FOUND) 5632 { 5633 *aValue = ""; 5634 rc = S_OK; 5634 5635 } 5635 5636 else 5636 rc = setError( E_UNEXPECTED,5637 tr("Theservice call failed with the error %Rrc"),5638 vrc);5637 rc = setError(VBOX_E_IPRT_ERROR, 5638 tr("The VBoxGuestPropSvc service call failed with the error %Rrc"), 5639 vrc); 5639 5640 } 5640 5641 catch(std::bad_alloc & /*e*/) … … 5642 5643 rc = E_OUTOFMEMORY; 5643 5644 } 5645 5644 5646 return rc; 5645 5647 #endif /* VBOX_WITH_GUEST_PROPS */ … … 5649 5651 * @note Temporarily locks this object for writing. 5650 5652 */ 5651 HRESULT Console::i_setGuestProperty( IN_BSTR aName, IN_BSTR aValue, IN_BSTRaFlags)5653 HRESULT Console::i_setGuestProperty(const Utf8Str &aName, const Utf8Str &aValue, const Utf8Str &aFlags) 5652 5654 { 5653 5655 #ifndef VBOX_WITH_GUEST_PROPS 5654 5656 ReturnComNotImplemented(); 5655 5657 #else /* VBOX_WITH_GUEST_PROPS */ 5656 if (!RT_VALID_PTR(aName))5657 return setError(E_INVALIDARG, tr("Name cannot be NULL or an invalid pointer"));5658 if (aValue != NULL && !RT_VALID_PTR(aValue))5659 return setError(E_INVALIDARG, tr("Invalid value pointer"));5660 if (aFlags != NULL && !RT_VALID_PTR(aFlags))5661 return setError(E_INVALIDARG, tr("Invalid flags pointer"));5662 5658 5663 5659 AutoCaller autoCaller(this); … … 5676 5672 VBOXHGCMSVCPARM parm[3]; 5677 5673 5678 Utf8Str Utf8Name = aName;5679 5674 parm[0].type = VBOX_HGCM_SVC_PARM_PTR; 5680 parm[0].u.pointer.addr = (void*)Utf8Name.c_str(); 5681 /* The + 1 is the null terminator */ 5682 parm[0].u.pointer.size = (uint32_t)Utf8Name.length() + 1; 5683 5684 Utf8Str Utf8Value; 5685 if (aValue != NULL) 5686 { 5687 Utf8Value = aValue; 5688 parm[1].type = VBOX_HGCM_SVC_PARM_PTR; 5689 parm[1].u.pointer.addr = (void *)Utf8Value.c_str(); 5690 /* The + 1 is the null terminator */ 5691 parm[1].u.pointer.size = (uint32_t)Utf8Value.length() + 1; 5692 } 5693 5694 Utf8Str Utf8Flags; 5695 if (aFlags != NULL) 5696 { 5697 Utf8Flags = aFlags; 5675 parm[0].u.pointer.addr = (void*)aName.c_str(); 5676 parm[0].u.pointer.size = (uint32_t)aName.length() + 1; /* The + 1 is the null terminator */ 5677 5678 parm[1].type = VBOX_HGCM_SVC_PARM_PTR; 5679 parm[1].u.pointer.addr = (void *)aValue.c_str(); 5680 parm[1].u.pointer.size = (uint32_t)aValue.length() + 1; /* The + 1 is the null terminator */ 5681 5682 int vrc; 5683 if (aFlags.isEmpty()) 5684 { 5685 vrc = m_pVMMDev->hgcmHostCall("VBoxGuestPropSvc", SET_PROP_VALUE_HOST, 5686 2, &parm[0]); 5687 } 5688 else 5689 { 5698 5690 parm[2].type = VBOX_HGCM_SVC_PARM_PTR; 5699 parm[2].u.pointer.addr = (void*)Utf8Flags.c_str(); 5700 /* The + 1 is the null terminator */ 5701 parm[2].u.pointer.size = (uint32_t)Utf8Flags.length() + 1; 5702 } 5703 5704 int vrc; 5705 if (aValue != NULL && aFlags != NULL) 5691 parm[2].u.pointer.addr = (void*)aFlags.c_str(); 5692 parm[2].u.pointer.size = (uint32_t)aFlags.length() + 1; /* The + 1 is the null terminator */ 5693 5706 5694 vrc = m_pVMMDev->hgcmHostCall("VBoxGuestPropSvc", SET_PROP_HOST, 5707 5695 3, &parm[0]); 5708 else if (aValue != NULL) 5709 vrc = m_pVMMDev->hgcmHostCall("VBoxGuestPropSvc", SET_PROP_VALUE_HOST, 5710 2, &parm[0]); 5711 else 5712 vrc = m_pVMMDev->hgcmHostCall("VBoxGuestPropSvc", DEL_PROP_HOST, 5713 1, &parm[0]); 5714 HRESULT hrc; 5715 if (RT_SUCCESS(vrc)) 5716 hrc = S_OK; 5717 else 5718 hrc = setError(E_UNEXPECTED, tr("The service call failed with the error %Rrc"), vrc); 5696 } 5697 5698 HRESULT hrc = S_OK; 5699 if (RT_FAILURE(vrc)) 5700 hrc = setError(VBOX_E_IPRT_ERROR, tr("The VBoxGuestPropSvc service call failed with the error %Rrc"), vrc); 5719 5701 return hrc; 5720 5702 #endif /* VBOX_WITH_GUEST_PROPS */ 5721 5703 } 5722 5704 5705 HRESULT Console::i_deleteGuestProperty(const Utf8Str &aName) 5706 { 5707 #ifndef VBOX_WITH_GUEST_PROPS 5708 ReturnComNotImplemented(); 5709 #else /* VBOX_WITH_GUEST_PROPS */ 5710 5711 AutoCaller autoCaller(this); 5712 AssertComRCReturnRC(autoCaller.rc()); 5713 5714 /* protect mpUVM (if not NULL) */ 5715 SafeVMPtrQuiet ptrVM(this); 5716 if (FAILED(ptrVM.rc())) 5717 return ptrVM.rc(); 5718 5719 /* Note: validity of mVMMDev which is bound to uninit() is guaranteed by 5720 * ptrVM, so there is no need to hold a lock of this */ 5721 5722 using namespace guestProp; 5723 5724 VBOXHGCMSVCPARM parm[1]; 5725 5726 parm[0].type = VBOX_HGCM_SVC_PARM_PTR; 5727 parm[0].u.pointer.addr = (void*)aName.c_str(); 5728 parm[0].u.pointer.size = (uint32_t)aName.length() + 1; /* The + 1 is the null terminator */ 5729 5730 int vrc = m_pVMMDev->hgcmHostCall("VBoxGuestPropSvc", DEL_PROP_HOST, 5731 1, &parm[0]); 5732 5733 HRESULT hrc = S_OK; 5734 if (RT_FAILURE(vrc)) 5735 hrc = setError(VBOX_E_IPRT_ERROR, tr("The VBoxGuestPropSvc service call failed with the error %Rrc"), vrc); 5736 return hrc; 5737 #endif /* VBOX_WITH_GUEST_PROPS */ 5738 } 5723 5739 5724 5740 /** -
TabularUnified trunk/src/VBox/Main/src-client/SessionImpl.cpp ¶
r52248 r52251 823 823 824 824 HRESULT Session::accessGuestProperty(const com::Utf8Str &aName, const com::Utf8Str &aValue, const com::Utf8Str &aFlags, 825 BOOL aIsSetter, com::Utf8Str &aRetValue, LONG64 *aRetTimestamp, com::Utf8Str &aRetFlags)825 ULONG aAccessMode, com::Utf8Str &aRetValue, LONG64 *aRetTimestamp, com::Utf8Str &aRetFlags) 826 826 { 827 827 #ifdef VBOX_WITH_GUEST_PROPS … … 834 834 if (aName.isEmpty()) 835 835 return E_INVALIDARG; 836 if ( !aIsSetter && !VALID_PTR(aRetTimestamp))836 if (aAccessMode == 0 && !RT_VALID_PTR(aRetTimestamp)) 837 837 return E_POINTER; 838 838 … … 842 842 return E_ACCESSDENIED; 843 843 844 if (!aIsSetter) 845 { 846 Bstr bstrRetValue; 847 Bstr bstrRetFlags; 848 HRESULT hr = mConsole->i_getGuestProperty(Bstr(aName).raw(), 849 bstrRetValue.asOutParam(), aRetTimestamp, bstrRetFlags.asOutParam()); 850 if (SUCCEEDED(hr)) 851 { 852 aRetValue = bstrRetValue; 853 aRetFlags = bstrRetFlags; 854 } 855 return hr; 856 } 844 HRESULT hr; 845 if (aAccessMode == 2) 846 hr = mConsole->i_deleteGuestProperty(aName); 847 else if (aAccessMode == 1) 848 hr = mConsole->i_setGuestProperty(aName, aValue, aFlags); 849 else if (aAccessMode == 0) 850 hr = mConsole->i_getGuestProperty(aName, &aRetValue, aRetTimestamp, &aRetFlags); 857 851 else 858 return mConsole->i_setGuestProperty(Bstr(aName).raw(), Bstr(aValue).raw(), Bstr(aFlags).raw()); 859 852 hr = E_INVALIDARG; 853 854 return hr; 860 855 # else /* VBOX_COM_INPROC_API_CLIENT */ 861 856 /** @todo This is nonsense, non-VM API users shouldn't need to deal with this -
TabularUnified trunk/src/VBox/Main/src-server/MachineImpl.cpp ¶
r52175 r52251 5493 5493 rc = E_ACCESSDENIED; 5494 5494 else 5495 rc = directControl->AccessGuestProperty(Bstr(aName).raw(), NULL, NULL,5496 false /* isSetter*/,5495 rc = directControl->AccessGuestProperty(Bstr(aName).raw(), Bstr("").raw(), Bstr("").raw(), 5496 0 /* accessMode */, 5497 5497 &bValue, aTimestamp, &bFlags); 5498 5498 … … 5543 5543 */ 5544 5544 HRESULT Machine::i_setGuestPropertyToService(const com::Utf8Str &aName, const com::Utf8Str &aValue, 5545 const com::Utf8Str &aFlags )5545 const com::Utf8Str &aFlags, bool fDelete) 5546 5546 { 5547 5547 using namespace guestProp; … … 5559 5559 return setError(E_INVALIDARG, tr("Invalid guest property flag values: '%s'"), aFlags.c_str()); 5560 5560 5561 bool fDelete = aValue.isEmpty();5562 5561 HWData::GuestPropertyMap::iterator it = mHWData->mGuestProperties.find(aName); 5563 5562 if (it == mHWData->mGuestProperties.end()) … … 5637 5636 */ 5638 5637 HRESULT Machine::i_setGuestPropertyToVM(const com::Utf8Str &aName, const com::Utf8Str &aValue, 5639 const com::Utf8Str &aFlags )5638 const com::Utf8Str &aFlags, bool fDelete) 5640 5639 { 5641 5640 HRESULT rc; … … 5652 5651 /** @todo Fix when adding DeleteGuestProperty(), see defect. */ 5653 5652 rc = directControl->AccessGuestProperty(Bstr(aName).raw(), Bstr(aValue).raw(), Bstr(aFlags).raw(), 5654 true /* isSetter*/,5653 fDelete? 2: 1 /* accessMode */, 5655 5654 &dummy, &dummy64, &dummy); 5656 5655 } … … 5670 5669 ReturnComNotImplemented(); 5671 5670 #else // VBOX_WITH_GUEST_PROPS 5672 HRESULT rc = i_setGuestPropertyToVM(aProperty, aValue, aFlags );5671 HRESULT rc = i_setGuestPropertyToVM(aProperty, aValue, aFlags, /* fDelete = */ false); 5673 5672 if (rc == E_ACCESSDENIED) 5674 5673 /* The VM is not running or the service is not (yet) accessible */ 5675 rc = i_setGuestPropertyToService(aProperty, aValue, aFlags );5674 rc = i_setGuestPropertyToService(aProperty, aValue, aFlags, /* fDelete = */ false); 5676 5675 return rc; 5677 5676 #endif // VBOX_WITH_GUEST_PROPS … … 5685 5684 HRESULT Machine::deleteGuestProperty(const com::Utf8Str &aName) 5686 5685 { 5687 return setGuestProperty(aName, "", ""); 5686 #ifndef VBOX_WITH_GUEST_PROPS 5687 ReturnComNotImplemented(); 5688 #else // VBOX_WITH_GUEST_PROPS 5689 HRESULT rc = i_setGuestPropertyToVM(aName, "", "", /* fDelete = */ true); 5690 if (rc == E_ACCESSDENIED) 5691 /* The VM is not running or the service is not (yet) accessible */ 5692 rc = i_setGuestPropertyToService(aName, "", "", /* fDelete = */ true); 5693 return rc; 5694 #endif // VBOX_WITH_GUEST_PROPS 5688 5695 } 5689 5696
Note:
See TracChangeset
for help on using the changeset viewer.