Changeset 85735 in vbox
- Timestamp:
- Aug 12, 2020 8:48:55 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 139883
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/HostUpdateImpl.h
r85730 r85735 23 23 24 24 #include "HostUpdateWrap.h" 25 #include <iprt/http.h> /* RTHTTP */ 25 26 26 27 … … 52 53 HRESULT i_updateCheckTask(UpdateCheckTask *pTask); 53 54 HRESULT i_checkForVBoxUpdate(); 55 HRESULT i_checkForVBoxUpdateInner(RTHTTP hHttp, com::Utf8Str const &strUrl, com::Utf8Str const &strUserAgent, 56 ComPtr<ISystemProperties> const &ptrSystemProperties); 54 57 55 58 /** @name Data members. -
trunk/src/VBox/Main/src-server/HostUpdateImpl.cpp
r85734 r85735 285 285 286 286 // acquire the System Properties interface 287 ComPtr<ISystemProperties> p SystemProperties;288 rc = mVirtualBox->COMGETTER(SystemProperties)(p SystemProperties.asOutParam());287 ComPtr<ISystemProperties> ptrSystemProperties; 288 rc = mVirtualBox->COMGETTER(SystemProperties)(ptrSystemProperties.asOutParam()); 289 289 if (FAILED(rc)) 290 290 return setErrorVrc(rc, tr("%s: IVirtualBox::systemProperties() failed: %Rrc"), __FUNCTION__, rc); … … 297 297 RTTimeToString(RTTimeExplode(&Time, RTTimeNow(&TimeNow)), szTimeStr, sizeof(szTimeStr)); 298 298 LogRelFunc(("VBox updating UpdateDate with TimeString = %s\n", szTimeStr)); 299 rc = p SystemProperties->COMSETTER(VBoxUpdateLastCheckDate)(Bstr(szTimeStr).raw());299 rc = ptrSystemProperties->COMSETTER(VBoxUpdateLastCheckDate)(Bstr(szTimeStr).raw()); 300 300 if (FAILED(rc)) 301 301 return rc; // ISystemProperties::setLastCheckDate calls setError() on failure … … 303 303 // Update the queryURL and the VBoxUpdate setting 'VBoxUpdateCount' 304 304 ULONG cVBoxUpdateCount = 0; 305 rc = p SystemProperties->COMGETTER(VBoxUpdateCount)(&cVBoxUpdateCount);305 rc = ptrSystemProperties->COMGETTER(VBoxUpdateCount)(&cVBoxUpdateCount); 306 306 if (FAILED(rc)) 307 307 return setErrorVrc(rc, tr("%s: retrieving ISystemProperties::VBoxUpdateCount failed: %Rrc"), __FUNCTION__, rc); … … 309 309 cVBoxUpdateCount++; 310 310 311 rc = p SystemProperties->COMSETTER(VBoxUpdateCount)(cVBoxUpdateCount);311 rc = ptrSystemProperties->COMSETTER(VBoxUpdateCount)(cVBoxUpdateCount); 312 312 if (FAILED(rc)) 313 313 return rc; // ISystemProperties::setVBoxUpdateCount calls setError() on failure … … 316 316 // Update the query URL and the VBoxUpdate settings (if necessary) with the 'Target' information. 317 317 VBoxUpdateTarget_T enmTarget = VBoxUpdateTarget_Stable; // default branch is 'stable' 318 rc = p SystemProperties->COMGETTER(VBoxUpdateTarget)(&enmTarget);318 rc = ptrSystemProperties->COMGETTER(VBoxUpdateTarget)(&enmTarget); 319 319 if (FAILED(rc)) 320 320 return setErrorVrc(rc, tr("%s: retrieving ISystemProperties::Target failed: %Rrc"), __FUNCTION__, rc); … … 334 334 } 335 335 336 rc = p SystemProperties->COMSETTER(VBoxUpdateTarget)(enmTarget);336 rc = ptrSystemProperties->COMSETTER(VBoxUpdateTarget)(enmTarget); 337 337 if (FAILED(rc)) 338 338 return rc; // ISystemProperties::setTarget calls setError() on failure … … 341 341 342 342 /* 343 * Setup the User-Agent headers for the GET request343 * Compose the User-Agent header for the GET request. 344 344 */ 345 345 Bstr version; … … 351 351 LogRelFunc(("userAgent = %s\n", strUserAgent.c_str())); 352 352 353 /* 354 * Create the HTTP client instance and pass it to a inner worker method to 355 * ensure proper cleanup. 356 */ 353 357 RTHTTP hHttp = NIL_RTHTTP; 354 358 int vrc = RTHttpCreate(&hHttp); 355 if (RT_FAILURE(vrc)) 356 return setErrorVrc(vrc, tr("%s: RTHttpCreate() failed: %Rrc"), __FUNCTION__, vrc); 357 359 if (RT_SUCCESS(vrc)) 360 { 361 try 362 { 363 rc = i_checkForVBoxUpdateInner(hHttp, strUrl, strUserAgent, ptrSystemProperties); 364 } 365 catch (...) 366 { 367 AssertFailed(); 368 rc = E_UNEXPECTED; 369 } 370 RTHttpDestroy(hHttp); 371 } 372 else 373 rc = setErrorVrc(vrc, tr("%s: RTHttpCreate() failed: %Rrc"), __FUNCTION__, vrc); 374 return S_OK; 375 } 376 377 HRESULT HostUpdate::i_checkForVBoxUpdateInner(RTHTTP hHttp, Utf8Str const &strUrl, Utf8Str const &strUserAgent, 378 ComPtr<ISystemProperties> const &ptrSystemProperties) 379 { 358 380 /// @todo Are there any other headers needed to be added first via RTHttpSetHeaders()? 359 vrc = RTHttpAddHeader(hHttp, "User-Agent", strUserAgent.c_str(), strUserAgent.length(), RTHTTPADDHDR_F_BACK);381 int vrc = RTHttpAddHeader(hHttp, "User-Agent", strUserAgent.c_str(), strUserAgent.length(), RTHTTPADDHDR_F_BACK); 360 382 if (RT_FAILURE(vrc)) 361 383 return setErrorVrc(vrc, tr("%s: RTHttpAddHeader() failed: %Rrc (on User-Agent)"), __FUNCTION__, vrc); … … 365 387 */ 366 388 ProxyMode_T enmProxyMode; 367 rc = pSystemProperties->COMGETTER(ProxyMode)(&enmProxyMode);368 if (FAILED(rc)) 369 return setError Vrc(rc, tr("%s: ISystemProperties::proxyMode() failed: %Rrc"), __FUNCTION__, rc);389 HRESULT rc = ptrSystemProperties->COMGETTER(ProxyMode)(&enmProxyMode); 390 if (FAILED(rc)) 391 return setError(rc, tr("%s: ISystemProperties::proxyMode() failed: %Rrc"), __FUNCTION__, rc); 370 392 371 393 if (enmProxyMode == ProxyMode_Manual) 372 394 { 373 395 Bstr strProxyURL; 374 rc = p SystemProperties->COMGETTER(ProxyURL)(strProxyURL.asOutParam());396 rc = ptrSystemProperties->COMGETTER(ProxyURL)(strProxyURL.asOutParam()); 375 397 if (FAILED(rc)) 376 return setError Vrc(rc, tr("%s: ISystemProperties::proxyURL() failed: %Rrc"), __FUNCTION__, rc);398 return setError(rc, tr("%s: ISystemProperties::proxyURL() failed: %Rrc"), __FUNCTION__, rc); 377 399 vrc = RTHttpSetProxyByUrl(hHttp, Utf8Str(strProxyURL).c_str()); 378 400 if (RT_FAILURE(vrc)) … … 385 407 return setErrorVrc(vrc, tr("%s: RTHttpUseSystemProxySettings() failed: %Rrc"), __FUNCTION__, vrc); 386 408 } 409 else 410 Assert(enmProxyMode == ProxyMode_NoProxy); 387 411 388 412 /* … … 395 419 return setErrorVrc(vrc, tr("%s: RTHttpGetBinary() failed: %Rrc"), __FUNCTION__, vrc); 396 420 421 /** @todo this may throw and leak. */ 397 422 RTCList<RTCString> lstHttpReply = RTCString((char *)pvResponse, (size_t)cbResponse).split(" ", RTCString::RemoveEmptyParts); 398 423 RTHttpFreeResponse(pvResponse); … … 414 439 LogRelFunc(("HTTP server reply = %s %s\n", lstHttpReply.at(0).c_str(), lstHttpReply.at(1).c_str())); 415 440 } 416 417 // clean-up HTTP request paperwork418 /** @todo r=bird: There is no chance that this would be NIL here unless419 * you've got stack corruption. Besides, RTHttpDestruct ignores NIL. */420 if (hHttp != NIL_RTHTTP)421 RTHttpDestroy(hHttp);422 441 423 442 return S_OK;
Note:
See TracChangeset
for help on using the changeset viewer.