Changeset 15140 in vbox for trunk/src/VBox/Main/MachineImpl.cpp
- Timestamp:
- Dec 9, 2008 8:41:26 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/MachineImpl.cpp
r15051 r15140 2284 2284 STDMETHODIMP Machine::GetSerialPort (ULONG slot, ISerialPort **port) 2285 2285 { 2286 if (!port) 2287 return E_POINTER; 2288 if (slot >= RT_ELEMENTS (mSerialPorts)) 2289 return setError (E_INVALIDARG, tr ("Invalid slot number: %d"), slot); 2286 CheckComArgOutPointerValid(port); 2287 CheckComArgExpr(slot, slot < RT_ELEMENTS (mSerialPorts)); 2290 2288 2291 2289 AutoCaller autoCaller (this); … … 2301 2299 STDMETHODIMP Machine::GetParallelPort (ULONG slot, IParallelPort **port) 2302 2300 { 2303 if (!port) 2304 return E_POINTER; 2305 if (slot >= RT_ELEMENTS (mParallelPorts)) 2306 return setError (E_INVALIDARG, tr ("Invalid slot number: %d"), slot); 2301 CheckComArgOutPointerValid(port); 2302 CheckComArgExpr(slot, slot < RT_ELEMENTS (mParallelPorts)); 2307 2303 2308 2304 AutoCaller autoCaller (this); … … 2318 2314 STDMETHODIMP Machine::GetNetworkAdapter (ULONG slot, INetworkAdapter **adapter) 2319 2315 { 2320 if (!adapter) 2321 return E_POINTER; 2322 if (slot >= RT_ELEMENTS (mNetworkAdapters)) 2323 return setError (E_INVALIDARG, tr ("Invalid slot number: %d"), slot); 2316 CheckComArgOutPointerValid(adapter); 2317 CheckComArgExpr(slot, slot < RT_ELEMENTS (mNetworkAdapters)); 2324 2318 2325 2319 AutoCaller autoCaller (this); … … 2419 2413 2420 2414 /* Here we are when a) there are no items at all or b) there are items 2421 * but none of them equals t o the requested non-NULL key. b) is an2415 * but none of them equals the requested non-NULL key. b) is an 2422 2416 * error as well as a) if the key is non-NULL. When the key is NULL 2423 2417 * (which is the case only when there are no items), we just fall … … 2425 2419 2426 2420 if (aKey != NULL) 2427 return setError ( E_FAIL,2421 return setError (VBOX_E_OBJECT_NOT_FOUND, 2428 2422 tr ("Could not find the extra data key '%ls'"), aKey); 2429 2423 } … … 2712 2706 2713 2707 if (mData->mRegistered) 2714 return setError ( E_FAIL,2708 return setError (VBOX_E_INVALID_VM_STATE, 2715 2709 tr ("Cannot delete settings of a registered machine")); 2716 2710 … … 2721 2715 int vrc = RTFileDelete (Utf8Str (mData->mConfigFileFull)); 2722 2716 if (RT_FAILURE (vrc)) 2723 return setError ( E_FAIL,2717 return setError (VBOX_E_IPRT_ERROR, 2724 2718 tr ("Could not delete the settings file '%ls' (%Rrc)"), 2725 2719 mData->mConfigFileFull.raw(), vrc); … … 2834 2828 rc = findSharedFolder (aName, sharedFolder, false /* aSetError */); 2835 2829 if (SUCCEEDED (rc)) 2836 return setError ( E_FAIL,2830 return setError (VBOX_E_OBJECT_IN_USE, 2837 2831 tr ("Shared folder named '%ls' already exists"), aName); 2838 2832 … … 2846 2840 2847 2841 if (!accessible) 2848 return setWarning ( E_FAIL,2842 return setWarning (VBOX_E_FILE_ERROR, 2849 2843 tr ("Shared folder host path '%ls' is not accessible"), aHostPath); 2850 2844 … … 2894 2888 AutoCaller autoCaller (this); 2895 2889 AssertComRCReturnRC (autoCaller.rc()); 2890 2891 ComPtr <IInternalSessionControl> directControl; 2892 { 2893 AutoReadLock alock (this); 2894 2895 if (mData->mSession.mState != SessionState_Open) 2896 return setError (VBOX_E_INVALID_VM_STATE, 2897 tr ("Machine session is not open (session state: %d)"), 2898 mData->mSession.mState); 2899 2900 directControl = mData->mSession.mDirectControl; 2901 } 2902 2903 /* ignore calls made after #OnSessionEnd() is called */ 2904 if (!directControl) 2905 return S_OK; 2906 2907 ULONG64 dummy; 2908 return directControl->OnShowWindow (TRUE /* aCheck */, aCanShow, &dummy); 2909 } 2910 2911 STDMETHODIMP Machine::ShowConsoleWindow (ULONG64 *aWinId) 2912 { 2913 CheckComArgOutPointerValid(aWinId); 2914 2915 AutoCaller autoCaller (this); 2916 AssertComRCReturn (autoCaller.rc(), autoCaller.rc()); 2896 2917 2897 2918 ComPtr <IInternalSessionControl> directControl; … … 2911 2932 return S_OK; 2912 2933 2913 ULONG64 dummy;2914 return directControl->OnShowWindow (TRUE /* aCheck */, aCanShow, &dummy);2915 }2916 2917 STDMETHODIMP Machine::ShowConsoleWindow (ULONG64 *aWinId)2918 {2919 CheckComArgOutPointerValid(aWinId);2920 2921 AutoCaller autoCaller (this);2922 AssertComRCReturn (autoCaller.rc(), autoCaller.rc());2923 2924 ComPtr <IInternalSessionControl> directControl;2925 {2926 AutoReadLock alock (this);2927 2928 if (mData->mSession.mState != SessionState_Open)2929 return setError (E_FAIL,2930 tr ("Machine session is not open (session state: %d)"),2931 mData->mSession.mState);2932 2933 directControl = mData->mSession.mDirectControl;2934 }2935 2936 /* ignore calls made after #OnSessionEnd() is called */2937 if (!directControl)2938 return S_OK;2939 2940 2934 BOOL dummy; 2941 2935 return directControl->OnShowWindow (FALSE /* aCheck */, &dummy, aWinId); … … 2947 2941 ReturnComNotImplemented(); 2948 2942 #else 2949 if (!VALID_PTR (aName)) 2950 return E_INVALIDARG; 2951 if (!VALID_PTR (aValue)) 2952 return E_POINTER; 2953 if (!VALID_PTR (aTimestamp)) 2954 return E_POINTER; 2955 if (!VALID_PTR (aFlags)) 2956 return E_POINTER; 2943 CheckComArgNotNull(aName); 2944 CheckComArgOutPointerValid(aValue); 2945 CheckComArgOutPointerValid(aTimestamp); 2946 CheckComArgOutPointerValid(aFlags); 2957 2947 2958 2948 AutoCaller autoCaller (this); … … 3019 3009 using namespace guestProp; 3020 3010 3021 if (!VALID_PTR (aName)) 3022 return E_INVALIDARG; 3011 CheckComArgNotNull(aName); 3023 3012 if ((aValue != NULL) && !VALID_PTR (aValue)) 3024 3013 return E_INVALIDARG; … … 3060 3049 property.mFlags = NILFLAG; 3061 3050 if (fFlags & TRANSIENT) 3062 rc = setError ( E_INVALIDARG, tr ("Cannot set a transient property when the machine is not running"));3051 rc = setError (VBOX_E_INVALID_OBJECT_STATE, tr ("Cannot set a transient property when the machine is not running")); 3063 3052 if (SUCCEEDED (rc)) 3064 3053 { … … 3143 3132 if (!VALID_PTR (aPatterns) && (aPatterns != NULL)) 3144 3133 return E_POINTER; 3145 if (ComSafeArrayOutIsNull (aNames)) 3146 return E_POINTER; 3147 if (ComSafeArrayOutIsNull (aValues)) 3148 return E_POINTER; 3149 if (ComSafeArrayOutIsNull (aTimestamps)) 3150 return E_POINTER; 3151 if (ComSafeArrayOutIsNull (aFlags)) 3152 return E_POINTER; 3134 CheckComArgSafeArrayNotNull(aNames); 3135 CheckComArgSafeArrayNotNull(aValues); 3136 CheckComArgSafeArrayNotNull(aTimestamps); 3137 CheckComArgSafeArrayNotNull(aFlags); 3153 3138 3154 3139 AutoCaller autoCaller (this); … … 4303 4288 mData->mMachineState > MachineState_Paused || 4304 4289 mData->mMachineState == MachineState_Saved)) 4305 return setError ( E_ACCESSDENIED,4290 return setError (VBOX_E_INVALID_VM_STATE, 4306 4291 tr ("The machine is not mutable (state is %d)"), 4307 4292 mData->mMachineState); … … 4313 4298 (mType != IsSessionMachine || 4314 4299 mData->mMachineState > MachineState_Paused)) 4315 return setError ( E_ACCESSDENIED,4300 return setError (VBOX_E_INVALID_VM_STATE, 4316 4301 tr ("The machine is not mutable (state is %d)"), 4317 4302 mData->mMachineState); … … 4621 4606 * not found 4622 4607 * @return 4623 * S_OK when found or E_INVALIDARGwhen not found4608 * S_OK when found or VBOX_E_OBJECT_NOT_FOUND when not found 4624 4609 * 4625 4610 * @note … … 4641 4626 } 4642 4627 4643 HRESULT rc = found ? S_OK : E_INVALIDARG;4628 HRESULT rc = found ? S_OK : VBOX_E_OBJECT_NOT_FOUND; 4644 4629 4645 4630 if (aSetError && !found) … … 5518 5503 { 5519 5504 if (aSetError) 5520 return setError ( E_FAIL,5505 return setError (VBOX_E_OBJECT_NOT_FOUND, 5521 5506 tr ("This machine does not have any snapshots")); 5522 return E_FAIL;5507 return VBOX_E_OBJECT_NOT_FOUND; 5523 5508 } 5524 5509 … … 5528 5513 { 5529 5514 if (aSetError) 5530 return setError ( E_FAIL,5515 return setError (VBOX_E_OBJECT_NOT_FOUND, 5531 5516 tr ("Could not find a snapshot named '%ls'"), aName); 5532 return E_FAIL;5517 return VBOX_E_OBJECT_NOT_FOUND; 5533 5518 } 5534 5519
Note:
See TracChangeset
for help on using the changeset viewer.