Changeset 10233 in vbox for trunk/src/VBox/Main/MachineImpl.cpp
- Timestamp:
- Jul 4, 2008 3:45:38 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/MachineImpl.cpp
r10007 r10233 2680 2680 /** 2681 2681 * Read a value from the host/guest property store. If a session is 2682 * currently open for the guest then query the consoleobject for the value,2682 * currently open for the guest then query the session object for the value, 2683 2683 * since the current values of the property store will be held in RAM in the 2684 2684 * session. Otherwise read the value from machine extra data, where it is 2685 * stored between sessions. 2686 * 2687 * @note since the way this method is implemented depends on whether or not 2688 * a session is currently open, we grab a write lock on the object, in 2689 * order to ensure that the session state does not change during the 2690 * call, and to force us to block if it is currently changing (either 2691 * way) between open and closed. 2685 * stored between sessions. Returns E_FAIL if we are currently transitioning 2686 * between states. 2692 2687 */ 2693 2688 STDMETHODIMP Machine::GetGuestProperty (INPTR BSTR aKey, BSTR *aValue) 2694 2689 { 2695 if (!VALID_PTR(aValue))2696 return E_POINTER;2697 2698 2690 #ifndef VBOX_WITH_INFO_SVC 2699 2691 HRESULT hrc = E_NOTIMPL; 2700 2692 #else 2693 if (!VALID_PTR(aKey)) 2694 return E_POINTER; 2695 if (!VALID_PTR(aValue)) 2696 return E_POINTER; 2697 2698 AutoCaller autoCaller (this); 2699 CheckComRCReturnRC (autoCaller.rc()); 2700 2701 2701 using namespace svcInfo; 2702 2703 if (NULL == aKey)2704 return setError (E_INVALIDARG, tr ("Called with a NULL key argument"));2705 2702 HRESULT hrc = E_FAIL; 2706 AutoWriteLock alock (this); 2703 2707 2704 switch (mData->mSession.mState) 2708 2705 { 2709 2706 case SessionState_Closed: 2710 2707 { 2708 AutoReadLock alock (this); 2709 2711 2710 /* The "+ 1" in the length is the null terminator. */ 2712 2711 Bstr strKey(Bstr(aKey).length() + VBOX_SHARED_INFO_PREFIX_LEN + 1); … … 2726 2725 case SessionState_Open: 2727 2726 { 2728 /* 2729 * Get the console from the direct session (note that we don't leave the 2730 * lock here because GetRemoteConsole must not call us back). 2731 */ 2732 ComPtr <IConsole> console; 2733 hrc = mData->mSession.mDirectControl->GetRemoteConsole (console.asOutParam()); 2734 if (!SUCCEEDED (hrc)) 2735 /* The failure may w/o any error info (from RPC), so provide one */ 2736 hrc = setError (hrc, tr ("Failed to get a console object from the direct session")); 2737 else 2727 ComPtr <IInternalSessionControl> directControl; 2738 2728 { 2739 ComAssertRet (!console.isNull(), E_FAIL); 2740 hrc = console->GetGuestProperty (aKey, aValue); 2729 AutoReadLock alock (this); 2730 2731 if (mData->mSession.mState != SessionState_Open) 2732 return setError (E_FAIL, 2733 tr ("Machine session is not open (session state: %d) - please retry."), 2734 mData->mSession.mState); 2735 2736 directControl = mData->mSession.mDirectControl; 2741 2737 } 2738 2739 hrc = directControl->AccessGuestProperty (aKey, NULL, 2740 false /* isSetter */, 2741 aValue); 2742 2742 break; 2743 2743 } 2744 2744 default: 2745 /* If we get here then I have misunderstood the semantics. Quite possible. */ 2746 AssertLogRel(false); 2747 hrc = E_UNEXPECTED; 2745 hrc = setError (E_FAIL, tr ("Machine session is currently transitioning (session state: %d) - please retry."), 2746 mData->mSession.mState); 2748 2747 } 2749 2748 #endif /* VBOX_WITH_INFO_SVC not defined */ … … 2753 2752 /** 2754 2753 * Write a value to the host/guest property store. If a session is 2755 * currently open for the guest then query the consoleobject for the value,2754 * currently open for the guest then query the session object for the value, 2756 2755 * since the current values of the property store will be held in RAM in the 2757 2756 * session. Otherwise read the value from machine extra data, where it is 2758 * stored between sessions. 2759 * 2760 * @note since the way this method is implemented depends on whether or not 2761 * a session is currently open, we grab a write lock on the object, in 2762 * order to ensure that the session state does not change during the 2763 * call, and to force us to block if it is currently changing (either 2764 * way) between open and closed. 2757 * stored between sessions. Returns E_FAIL if we are currently transitioning 2758 * between states. 2765 2759 */ 2766 2760 STDMETHODIMP Machine::SetGuestProperty (INPTR BSTR aKey, INPTR BSTR aValue) … … 2769 2763 HRESULT hrc = E_NOTIMPL; 2770 2764 #else 2765 if (!VALID_PTR(aKey)) 2766 return E_POINTER; 2767 if ((aValue != NULL) && !VALID_PTR(aValue)) 2768 return E_POINTER; 2769 2770 AutoCaller autoCaller (this); 2771 CheckComRCReturnRC (autoCaller.rc()); 2772 2771 2773 using namespace svcInfo; 2772 2773 if (NULL == aKey)2774 return setError (E_INVALIDARG, tr ("Called with a NULL key argument"));2775 2774 HRESULT hrc = E_FAIL; 2776 AutoWriteLock alock (this); 2775 2777 2776 switch (mData->mSession.mState) 2778 2777 { 2779 2778 case SessionState_Closed: 2780 2779 { 2780 AutoWriteLock alock (this); 2781 2781 2782 /* The "+ 1" in the length is the null terminator. */ 2782 2783 Bstr strKey(Bstr(aKey).length() + VBOX_SHARED_INFO_PREFIX_LEN + 1); … … 2796 2797 case SessionState_Open: 2797 2798 { 2798 /* 2799 * Get the console from the direct session (note that we don't leave the 2800 * lock here because GetRemoteConsole must not call us back). 2801 */ 2802 ComPtr <IConsole> console; 2803 hrc = mData->mSession.mDirectControl->GetRemoteConsole (console.asOutParam()); 2804 if (!SUCCEEDED (hrc)) 2805 /* The failure may w/o any error info (from RPC), so provide one */ 2806 hrc = setError (hrc, tr ("Failed to get a console object from the direct session")); 2807 else 2799 ComPtr <IInternalSessionControl> directControl; 2808 2800 { 2809 ComAssertRet (!console.isNull(), E_FAIL); 2810 hrc = console->SetGuestProperty (aKey, aValue); 2801 AutoReadLock alock (this); 2802 2803 if (mData->mSession.mState != SessionState_Open) 2804 return setError (E_FAIL, 2805 tr ("Machine session is not open (session state: %d) - please retry."), 2806 mData->mSession.mState); 2807 2808 directControl = mData->mSession.mDirectControl; 2811 2809 } 2810 2811 BSTR dummy; 2812 hrc = directControl->AccessGuestProperty (aKey, aValue, 2813 true /* isSetter */, 2814 &dummy); 2812 2815 break; 2813 2816 } 2814 2817 default: 2815 /* If we get here then I have misunderstood the semantics. Quite possible. */ 2816 AssertLogRel(false); 2817 hrc = E_UNEXPECTED; 2818 hrc = setError (E_FAIL, tr ("Machine session is currently transitioning (session state: %d) - please retry."), 2819 mData->mSession.mState); 2818 2820 } 2819 2821 #endif /* VBOX_WITH_INFO_SVC not defined */
Note:
See TracChangeset
for help on using the changeset viewer.