- Timestamp:
- Jul 17, 2012 2:58:32 PM (12 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/idl/VirtualBox.xidl
r42178 r42194 9154 9154 <interface 9155 9155 name="IGuestSession" extends="$unknown" 9156 uuid=" 158aff3c-5258-4994-88cb-6fd679c7e3ed"9156 uuid="530aef35-6a48-455c-960c-aac5792abc38" 9157 9157 wsmap="managed" 9158 9158 > … … 9454 9454 </result> 9455 9455 </desc> 9456 </method> 9457 9458 <method name="EnvironmentGet"> 9459 <desc> 9460 TODO 9461 9462 <result name="VBOX_E_NOT_SUPPORTED"> 9463 TODO 9464 </result> 9465 </desc> 9466 <param name="name" type="wstring" dir="in"> 9467 <desc>TODO</desc> 9468 </param> 9469 <param name="value" type="wstring" dir="return"> 9470 <desc>TODO</desc> 9471 </param> 9456 9472 </method> 9457 9473 -
trunk/src/VBox/Main/include/GuestCtrlImplPrivate.h
r42171 r42194 122 122 static void FreeEnvironmentBlock(void *pvEnv); 123 123 124 Utf8Str Get(const Utf8Str &strKey); 125 124 126 Utf8Str Get(size_t nPos); 125 127 -
trunk/src/VBox/Main/include/GuestSessionImpl.h
r42171 r42194 82 82 STDMETHOD(DirectorySetACL)(IN_BSTR aPath, IN_BSTR aACL); 83 83 STDMETHOD(EnvironmentClear)(void); 84 STDMETHOD(EnvironmentGet)(IN_BSTR aName, BSTR *aValue); 84 85 STDMETHOD(EnvironmentSet)(IN_BSTR aName, IN_BSTR aValue); 85 86 STDMETHOD(EnvironmentSetArray)(ComSafeArrayIn(IN_BSTR, aValues)); -
trunk/src/VBox/Main/src-client/GuestCtrlImpl.cpp
r42171 r42194 2689 2689 2690 2690 int rc = VERR_MAX_PROCS_REACHED; 2691 ComObjPtr<GuestSession> pGuestSession;2692 2691 try 2693 2692 { … … 2699 2698 { 2700 2699 /* Is the context ID already used? Try next ID ... */ 2701 if (!sessionExists(uNewSessionID++)) 2702 { 2703 /* Callback with context ID was not found. This means 2704 * we can use this context ID for our new callback we want 2705 * to add below. */ 2700 if (!sessionExists(++uNewSessionID)) 2701 { 2706 2702 rc = VINF_SUCCESS; 2707 2703 break; … … 2714 2710 2715 2711 /* Create the session object. */ 2712 ComObjPtr<GuestSession> pGuestSession; 2716 2713 HRESULT hr = pGuestSession.createObject(); 2717 2714 if (FAILED(hr)) throw VERR_COM_UNEXPECTED; … … 2719 2716 rc = pGuestSession->init(this, uNewSessionID, 2720 2717 strUser, strPassword, strDomain, strSessionName); 2721 if (RT_FAILURE(rc)) throw VBOX_E_IPRT_ERROR; 2722 2723 mData.mGuestSessions[uNewSessionID] = pGuestSession; 2718 if (RT_FAILURE(rc)) throw rc; 2724 2719 2725 2720 /* Return guest session to the caller. */ 2726 2721 hr = pGuestSession.queryInterfaceTo(aGuestSession); 2727 2722 if (FAILED(hr)) throw VERR_COM_OBJECT_NOT_FOUND; 2723 2724 mData.mGuestSessions[uNewSessionID] = pGuestSession; 2728 2725 } 2729 2726 catch (int rc2) -
trunk/src/VBox/Main/src-client/GuestCtrlPrivate.cpp
r42171 r42194 21 21 ******************************************************************************/ 22 22 #include "GuestCtrlImplPrivate.h" 23 24 #include <iprt/ctype.h> 23 25 #ifdef DEBUG 24 26 # include "Logging.h" … … 210 212 std::map<Utf8Str, Utf8Str>::const_iterator it = mEnvironment.begin(); 211 213 for (; it != mEnvironment.end() && curPos < nPos; 212 ++it ) { }214 ++it, ++curPos) { } 213 215 214 216 if (it != mEnvironment.end()) … … 218 220 } 219 221 222 Utf8Str GuestEnvironment::Get(const Utf8Str &strKey) 223 { 224 std::map <Utf8Str, Utf8Str>::const_iterator itEnv = mEnvironment.find(strKey); 225 Utf8Str strRet; 226 if (itEnv != mEnvironment.end()) 227 strRet = itEnv->second; 228 return strRet; 229 } 230 220 231 bool GuestEnvironment::Has(const Utf8Str &strKey) 221 232 { … … 226 237 int GuestEnvironment::Set(const Utf8Str &strKey, const Utf8Str &strValue) 227 238 { 228 mEnvironment[strValue] = strValue; 229 return VINF_SUCCESS; 239 /** @todo Do some validation using regex. */ 240 if (strKey.isEmpty()) 241 return VERR_INVALID_PARAMETER; 242 243 int rc = VINF_SUCCESS; 244 const char *pszString = strKey.c_str(); 245 while (*pszString != '\0' && RT_SUCCESS(rc)) 246 { 247 if (!RT_C_IS_ALNUM(*pszString++)) 248 rc = VERR_INVALID_PARAMETER; 249 } 250 251 if (RT_SUCCESS(rc)) 252 mEnvironment[strKey] = strValue; 253 254 return rc; 230 255 } 231 256 … … 233 258 { 234 259 RTCList<RTCString> listPair = strPair.split("=", RTCString::KeepEmptyParts); 260 /* Skip completely empty pairs. Note that we still need pairs with a valid 261 * (set) key and an empty value. */ 262 if (listPair.size() <= 1) 263 return VINF_SUCCESS; 264 265 int rc = VINF_SUCCESS; 235 266 size_t p = 0; 236 while(p < listPair.size() )267 while(p < listPair.size() && RT_SUCCESS(rc)) 237 268 { 238 269 Utf8Str strKey = listPair.at(p++); 239 if ( strKey.isEmpty()) /* Skip pairs with empty keys (e.g. "=FOO"). */240 {241 p++;242 continue;270 if ( strKey.isEmpty() 271 || strKey.equals("=")) /* Skip pairs with empty keys (e.g. "=FOO"). */ 272 { 273 break; 243 274 } 244 275 Utf8Str strValue; 245 if (p < listPair.size()) 276 if (p < listPair.size()) /* Does the list also contain a value? */ 246 277 strValue = listPair.at(p++); 247 mEnvironment[strKey] = strValue; 248 } 249 250 return VINF_SUCCESS; 278 279 rc = Set(strKey, strValue); 280 } 281 282 return rc; 251 283 } 252 284 -
trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp
r42171 r42194 58 58 Utf8Str aUser, Utf8Str aPassword, Utf8Str aDomain, Utf8Str aName) 59 59 { 60 LogFlowThisFuncEnter(); 61 60 62 AssertPtrReturn(aGuest, VERR_INVALID_POINTER); 63 AssertReturn(aSessionID, VERR_INVALID_PARAMETER); 61 64 62 65 /* Enclose the state transition NotReady->InInit->Ready. */ … … 75 78 autoInitSpan.setSucceeded(); 76 79 80 LogFlowFuncLeaveRC(VINF_SUCCESS); 77 81 return VINF_SUCCESS; 78 82 } … … 84 88 void GuestSession::uninit(void) 85 89 { 86 LogFlowThisFunc (("\n"));90 LogFlowThisFuncEnter(); 87 91 88 92 /* Enclose the state transition Ready->InUninit->NotReady. */ … … 117 121 118 122 mData.mParent->sessionClose(this); 123 124 LogFlowThisFuncLeave(); 119 125 #endif 120 126 } … … 128 134 ReturnComNotImplemented(); 129 135 #else 136 LogFlowThisFuncEnter(); 137 130 138 CheckComArgOutPointerValid(aUser); 131 139 … … 137 145 mData.mCredentials.mUser.cloneTo(aUser); 138 146 147 LogFlowFuncLeaveRC(S_OK); 139 148 return S_OK; 140 149 #endif /* VBOX_WITH_GUEST_CONTROL */ … … 146 155 ReturnComNotImplemented(); 147 156 #else 157 LogFlowThisFuncEnter(); 158 148 159 CheckComArgOutPointerValid(aDomain); 149 160 … … 155 166 mData.mCredentials.mDomain.cloneTo(aDomain); 156 167 168 LogFlowFuncLeaveRC(S_OK); 157 169 return S_OK; 158 170 #endif /* VBOX_WITH_GUEST_CONTROL */ … … 164 176 ReturnComNotImplemented(); 165 177 #else 178 LogFlowThisFuncEnter(); 179 166 180 CheckComArgOutPointerValid(aName); 167 181 … … 173 187 mData.mName.cloneTo(aName); 174 188 189 LogFlowFuncLeaveRC(S_OK); 175 190 return S_OK; 176 191 #endif /* VBOX_WITH_GUEST_CONTROL */ … … 182 197 ReturnComNotImplemented(); 183 198 #else 199 LogFlowThisFuncEnter(); 200 184 201 CheckComArgOutPointerValid(aId); 185 202 … … 191 208 *aId = mData.mId; 192 209 210 LogFlowFuncLeaveRC(S_OK); 193 211 return S_OK; 194 212 #endif /* VBOX_WITH_GUEST_CONTROL */ … … 200 218 ReturnComNotImplemented(); 201 219 #else 220 LogFlowThisFuncEnter(); 221 202 222 CheckComArgOutPointerValid(aTimeout); 203 223 … … 209 229 *aTimeout = mData.mTimeout; 210 230 231 LogFlowFuncLeaveRC(S_OK); 211 232 return S_OK; 212 233 #endif /* VBOX_WITH_GUEST_CONTROL */ … … 218 239 ReturnComNotImplemented(); 219 240 #else 241 LogFlowThisFuncEnter(); 242 220 243 CheckComArgOutSafeArrayPointerValid(aEnvironment); 221 244 … … 225 248 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 226 249 227 com::SafeArray<BSTR> arguments(mData.mEnvironment.Size()); 228 for (size_t i = 0; i < arguments.size(); i++) 229 arguments[i] = Bstr(mData.mEnvironment.Get(i)).raw(); 230 arguments.detachTo(ComSafeArrayOutArg(aEnvironment)); 231 250 size_t cEnvVars = mData.mEnvironment.Size(); 251 LogFlowThisFunc(("%s cEnvVars=%RU32\n", mData.mName.c_str(), cEnvVars)); 252 com::SafeArray<BSTR> environment(cEnvVars); 253 254 for (size_t i = 0; i < cEnvVars; i++) 255 { 256 Bstr strEnv(mData.mEnvironment.Get(i)); 257 strEnv.cloneTo(&environment[i]); 258 } 259 environment.detachTo(ComSafeArrayOutArg(aEnvironment)); 260 261 LogFlowFuncLeaveRC(S_OK); 232 262 return S_OK; 233 263 #endif /* VBOX_WITH_GUEST_CONTROL */ … … 239 269 ReturnComNotImplemented(); 240 270 #else 271 LogFlowThisFuncEnter(); 272 241 273 CheckComArgOutSafeArrayPointerValid(aProcesses); 242 274 … … 249 281 collection.detachTo(ComSafeArrayOutArg(aProcesses)); 250 282 283 LogFlowFuncLeaveRC(S_OK); 251 284 return S_OK; 252 285 #endif /* VBOX_WITH_GUEST_CONTROL */ … … 258 291 ReturnComNotImplemented(); 259 292 #else 293 LogFlowThisFuncEnter(); 294 260 295 CheckComArgOutSafeArrayPointerValid(aDirectories); 261 296 … … 268 303 collection.detachTo(ComSafeArrayOutArg(aDirectories)); 269 304 305 LogFlowFuncLeaveRC(S_OK); 270 306 return S_OK; 271 307 #endif /* VBOX_WITH_GUEST_CONTROL */ … … 277 313 ReturnComNotImplemented(); 278 314 #else 315 LogFlowThisFuncEnter(); 316 279 317 CheckComArgOutSafeArrayPointerValid(aFiles); 280 318 … … 287 325 collection.detachTo(ComSafeArrayOutArg(aFiles)); 288 326 327 LogFlowFuncLeaveRC(S_OK); 289 328 return S_OK; 290 329 #endif /* VBOX_WITH_GUEST_CONTROL */ … … 444 483 ReturnComNotImplemented(); 445 484 #else 485 LogFlowThisFuncEnter(); 486 446 487 uninit(); 447 488 489 LogFlowFuncLeaveRC(S_OK); 448 490 return S_OK; 449 491 #endif /* VBOX_WITH_GUEST_CONTROL */ … … 455 497 ReturnComNotImplemented(); 456 498 #else 499 LogFlowThisFuncEnter(); 500 457 501 AutoCaller autoCaller(this); 458 502 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 467 511 ReturnComNotImplemented(); 468 512 #else 513 LogFlowThisFuncEnter(); 514 469 515 AutoCaller autoCaller(this); 470 516 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 479 525 ReturnComNotImplemented(); 480 526 #else 527 LogFlowThisFuncEnter(); 528 481 529 AutoCaller autoCaller(this); 482 530 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 491 539 ReturnComNotImplemented(); 492 540 #else 541 LogFlowThisFuncEnter(); 542 493 543 AutoCaller autoCaller(this); 494 544 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 503 553 ReturnComNotImplemented(); 504 554 #else 555 LogFlowThisFuncEnter(); 556 505 557 AutoCaller autoCaller(this); 506 558 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 515 567 ReturnComNotImplemented(); 516 568 #else 569 LogFlowThisFuncEnter(); 570 517 571 AutoCaller autoCaller(this); 518 572 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 527 581 ReturnComNotImplemented(); 528 582 #else 583 LogFlowThisFuncEnter(); 584 529 585 AutoCaller autoCaller(this); 530 586 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 539 595 ReturnComNotImplemented(); 540 596 #else 597 LogFlowThisFuncEnter(); 598 541 599 AutoCaller autoCaller(this); 542 600 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 551 609 ReturnComNotImplemented(); 552 610 #else 611 LogFlowThisFuncEnter(); 612 553 613 AutoCaller autoCaller(this); 554 614 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 563 623 ReturnComNotImplemented(); 564 624 #else 625 LogFlowThisFuncEnter(); 626 565 627 AutoCaller autoCaller(this); 566 628 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 575 637 ReturnComNotImplemented(); 576 638 #else 639 LogFlowThisFuncEnter(); 640 577 641 AutoCaller autoCaller(this); 578 642 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 587 651 ReturnComNotImplemented(); 588 652 #else 653 LogFlowThisFuncEnter(); 654 589 655 AutoCaller autoCaller(this); 590 656 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 594 660 mData.mEnvironment.Clear(); 595 661 662 LogFlowFuncLeaveRC(S_OK); 663 return S_OK; 664 #endif /* VBOX_WITH_GUEST_CONTROL */ 665 } 666 667 STDMETHODIMP GuestSession::EnvironmentGet(IN_BSTR aName, BSTR *aValue) 668 { 669 #ifndef VBOX_WITH_GUEST_CONTROL 670 ReturnComNotImplemented(); 671 #else 672 LogFlowThisFuncEnter(); 673 674 if (RT_UNLIKELY((aName) == NULL || *(aName) == '\0')) 675 return setError(E_INVALIDARG, tr("No value name specified")); 676 677 CheckComArgOutPointerValid(aValue); 678 679 AutoCaller autoCaller(this); 680 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 681 682 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 683 684 Bstr strValue(mData.mEnvironment.Get(Utf8Str(aName))); 685 strValue.cloneTo(aValue); 686 687 LogFlowFuncLeaveRC(S_OK); 596 688 return S_OK; 597 689 #endif /* VBOX_WITH_GUEST_CONTROL */ … … 603 695 ReturnComNotImplemented(); 604 696 #else 697 LogFlowThisFuncEnter(); 698 699 if (RT_UNLIKELY((aName) == NULL || *(aName) == '\0')) 700 return setError(E_INVALIDARG, tr("No value name specified")); 701 605 702 AutoCaller autoCaller(this); 606 703 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 608 705 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 609 706 610 mData.mEnvironment.Set(Utf8Str(aName), Utf8Str(aValue)); 611 612 return S_OK; 707 int rc = mData.mEnvironment.Set(Utf8Str(aName), Utf8Str(aValue)); 708 709 HRESULT hr = RT_SUCCESS(rc) ? S_OK : VBOX_E_IPRT_ERROR; 710 LogFlowFuncLeaveRC(hr); 711 return hr; 613 712 #endif /* VBOX_WITH_GUEST_CONTROL */ 614 713 } … … 619 718 ReturnComNotImplemented(); 620 719 #else 720 LogFlowThisFuncEnter(); 721 621 722 AutoCaller autoCaller(this); 622 723 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 628 729 int rc = VINF_SUCCESS; 629 730 for (size_t i = 0; i < environment.size() && RT_SUCCESS(rc); i++) 630 rc = mData.mEnvironment.Set(Utf8Str(environment[i])); 631 632 return RT_SUCCESS(rc) ? S_OK : VBOX_E_IPRT_ERROR; 731 { 732 Utf8Str strEnv(environment[i]); 733 if (!strEnv.isEmpty()) /* Silently skip empty entries. */ 734 rc = mData.mEnvironment.Set(strEnv); 735 } 736 737 HRESULT hr = RT_SUCCESS(rc) ? S_OK : VBOX_E_IPRT_ERROR; 738 LogFlowFuncLeaveRC(hr); 739 return hr; 633 740 #endif /* VBOX_WITH_GUEST_CONTROL */ 634 741 } … … 639 746 ReturnComNotImplemented(); 640 747 #else 748 LogFlowThisFuncEnter(); 749 641 750 AutoCaller autoCaller(this); 642 751 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 646 755 mData.mEnvironment.Unset(Utf8Str(aName)); 647 756 757 LogFlowFuncLeaveRC(S_OK); 648 758 return S_OK; 649 759 #endif /* VBOX_WITH_GUEST_CONTROL */ … … 655 765 ReturnComNotImplemented(); 656 766 #else 767 LogFlowThisFuncEnter(); 768 657 769 AutoCaller autoCaller(this); 658 770 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 667 779 ReturnComNotImplemented(); 668 780 #else 781 LogFlowThisFuncEnter(); 782 669 783 AutoCaller autoCaller(this); 670 784 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 679 793 ReturnComNotImplemented(); 680 794 #else 795 LogFlowThisFuncEnter(); 796 681 797 AutoCaller autoCaller(this); 682 798 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 691 807 ReturnComNotImplemented(); 692 808 #else 809 LogFlowThisFuncEnter(); 810 693 811 AutoCaller autoCaller(this); 694 812 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 703 821 ReturnComNotImplemented(); 704 822 #else 823 LogFlowThisFuncEnter(); 824 705 825 AutoCaller autoCaller(this); 706 826 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 715 835 ReturnComNotImplemented(); 716 836 #else 837 LogFlowThisFuncEnter(); 838 717 839 AutoCaller autoCaller(this); 718 840 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 727 849 ReturnComNotImplemented(); 728 850 #else 851 LogFlowThisFuncEnter(); 852 729 853 AutoCaller autoCaller(this); 730 854 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 739 863 ReturnComNotImplemented(); 740 864 #else 865 LogFlowThisFuncEnter(); 866 741 867 AutoCaller autoCaller(this); 742 868 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 752 878 ReturnComNotImplemented(); 753 879 #else 880 LogFlowThisFuncEnter(); 754 881 755 882 com::SafeArray<LONG> affinity; … … 768 895 ReturnComNotImplemented(); 769 896 #else 897 LogFlowThisFuncEnter(); 898 770 899 AutoCaller autoCaller(this); 771 900 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 812 941 rc = processCreateExInteral(procInfo, aProcess); 813 942 } 814 return RT_SUCCESS(rc) ? S_OK : VBOX_E_IPRT_ERROR; 943 944 HRESULT hr = RT_SUCCESS(rc) ? S_OK : VBOX_E_IPRT_ERROR; 945 LogFlowFuncLeaveRC(hr); 946 return hr; 815 947 #endif /* VBOX_WITH_GUEST_CONTROL */ 816 948 } … … 821 953 ReturnComNotImplemented(); 822 954 #else 955 LogFlowThisFuncEnter(); 956 823 957 AutoCaller autoCaller(this); 824 958 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 833 967 ReturnComNotImplemented(); 834 968 #else 969 LogFlowThisFuncEnter(); 970 835 971 AutoCaller autoCaller(this); 836 972 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 845 981 ReturnComNotImplemented(); 846 982 #else 983 LogFlowThisFuncEnter(); 984 847 985 AutoCaller autoCaller(this); 848 986 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 857 995 ReturnComNotImplemented(); 858 996 #else 997 LogFlowThisFuncEnter(); 998 859 999 AutoCaller autoCaller(this); 860 1000 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 869 1009 ReturnComNotImplemented(); 870 1010 #else 1011 LogFlowThisFuncEnter(); 1012 871 1013 AutoCaller autoCaller(this); 872 1014 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 881 1023 ReturnComNotImplemented(); 882 1024 #else 1025 LogFlowThisFuncEnter(); 1026 883 1027 AutoCaller autoCaller(this); 884 1028 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 893 1037 ReturnComNotImplemented(); 894 1038 #else 895 AutoCaller autoCaller(this); 896 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 897 898 ReturnComNotImplemented(); 899 #endif /* VBOX_WITH_GUEST_CONTROL */ 900 } 901 1039 LogFlowThisFuncEnter(); 1040 1041 AutoCaller autoCaller(this); 1042 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1043 1044 ReturnComNotImplemented(); 1045 #endif /* VBOX_WITH_GUEST_CONTROL */ 1046 } 1047
Note:
See TracChangeset
for help on using the changeset viewer.