Changeset 34172 in vbox
- Timestamp:
- Nov 18, 2010 1:41:41 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 67896
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/GuestImpl.cpp
r34155 r34172 158 158 159 159 HRESULT rc = S_OK; 160 BOOL fCompleted; 161 BOOL fCanceled; 160 162 161 163 try … … 164 166 AssertPtr(pGuest); 165 167 166 if (aTask->progress) 167 aTask->progress->SetCurrentOperationProgress(10); 168 aTask->progress->SetCurrentOperationProgress(10); 168 169 169 170 bool fIsWindows = false; … … 233 234 { 234 235 /* Okay, we're ready to start our copy routine on the guest! */ 235 if (aTask->progress)236 aTask->progress->SetCurrentOperationProgress(15);237 238 236 LogRel(("Automatic update of Guest Additions started\n")); 237 aTask->progress->SetCurrentOperationProgress(15); 239 238 240 239 /* Prepare command line args. */ … … 248 247 if (SUCCEEDED(rc)) 249 248 { 250 ComPtr<IProgress> progressC opy;249 ComPtr<IProgress> progressCat; 251 250 ULONG uPID; 252 251 … … 263 262 Bstr("").raw() /* Password */, 264 263 5 * 1000 /* Wait 5s for getting the process started. */, 265 &uPID, progressCopy.asOutParam(), &vrc); 266 if (RT_FAILURE(vrc)) 264 &uPID, progressCat.asOutParam(), &vrc); 265 if ( RT_FAILURE(vrc) 266 || FAILED(rc)) 267 267 { 268 268 switch (vrc) … … 271 271 * (< 4.0) which does not support automatic updating and/or has not the internal tool "vbox_cat". */ 272 272 case VERR_INVALID_PARAMETER: 273 rc = setError(VBOX_E_ NOT_SUPPORTED,273 rc = setError(VBOX_E_IPRT_ERROR, 274 274 tr("Currently installed Guest Additions don't support automatic updating, please update them manually")); 275 275 break; … … 277 277 * no Guest Additions (on a supported automatic updating OS) are installed at all. */ 278 278 case VERR_TIMEOUT: 279 rc = setError(VBOX_E_ NOT_SUPPORTED,279 rc = setError(VBOX_E_IPRT_ERROR, 280 280 tr("Guest Additions seem not to be installed on the guest or are not responding, please update them manually")); 281 281 break; 282 282 283 283 default: 284 rc = setError(E_FAIL, 285 tr("Error copying Guest Additions installer (%Rrc)"), vrc); 284 286 break; 285 287 } … … 288 290 { 289 291 LogRel(("Copying Guest Additions installer to guest ...\n")); 290 291 if (aTask->progress) 292 aTask->progress->SetCurrentOperationProgress(20); 292 aTask->progress->SetCurrentOperationProgress(20); 293 293 294 294 /* Wait for process to exit ... */ 295 BOOL fCompleted = FALSE;296 BOOL fCanceled = FALSE;297 298 size_t cbRead;299 size_t cbToRead;300 295 SafeArray<BYTE> aInputData(_64K); 301 while ( SUCCEEDED(progressC opy->COMGETTER(Completed(&fCompleted)))296 while ( SUCCEEDED(progressCat->COMGETTER(Completed(&fCompleted))) 302 297 && !fCompleted) 303 298 { 299 size_t cbRead; 304 300 /* cbLength contains remaining bytes of our installer file 305 301 * opened above to read. */ 306 cbToRead = RT_MIN(cbLength, _64K);302 size_t cbToRead = RT_MIN(cbLength, _64K); 307 303 if (cbToRead) 308 304 { … … 321 317 } 322 318 319 /* 320 * Task canceled by caller? 321 * Then let the started process (cat) know by specifying end-of-file 322 * for the netxt input event that hopefully leads to a graceful exit ... 323 */ 324 if ( SUCCEEDED(aTask->progress->COMGETTER(Canceled(&fCanceled))) 325 && fCanceled) 326 { 327 uFlags |= ProcessInputFlag_EndOfFile; 328 } 329 323 330 /* Transfer the current chunk ... */ 331 #ifdef DEBUG_andy 332 LogRel(("Copying Guest Additions (%u bytes left) ...\n", cbLength)); 333 #endif 324 334 ULONG uBytesWritten; 325 rc = SetProcessInput(uPID, uFlags,326 ComSafeArrayAsInParam(aInputData), &uBytesWritten);335 rc = pGuest->SetProcessInput(uPID, uFlags, 336 ComSafeArrayAsInParam(aInputData), &uBytesWritten); 327 337 if (FAILED(rc)) 328 338 break; 329 339 340 /* If task was canceled above also cancel the process execution. */ 341 if (fCanceled) 342 progressCat->Cancel(); 343 344 #ifdef DEBUG_andy 345 LogRel(("Copying Guest Additions (%u bytes written) ...\n", uBytesWritten)); 346 #endif 330 347 Assert(cbLength >= uBytesWritten); 331 348 cbLength -= uBytesWritten; 332 333 /* Progress canceled by Main API? */334 if ( SUCCEEDED(progressCopy->COMGETTER(Canceled(&fCanceled)))335 && fCanceled)336 {337 break;338 }339 if (aTask->progress)340 {341 if (SUCCEEDED(aTask->progress->COMGETTER(Canceled(&fCanceled)))342 && fCanceled)343 break;344 }345 349 } 350 } 351 352 /* Internal progress canceled? */ 353 if ( SUCCEEDED(progressCat->COMGETTER(Canceled(&fCanceled))) 354 && fCanceled) 355 { 356 aTask->progress->Cancel(); 357 break; 346 358 } 347 359 } … … 351 363 RTIsoFsClose(&iso); 352 364 353 if (SUCCEEDED(rc)) 365 if ( SUCCEEDED(rc) 366 && ( SUCCEEDED(aTask->progress->COMGETTER(Canceled(&fCanceled))) 367 && !fCanceled 368 ) 369 ) 354 370 { 355 371 /* … … 357 373 * (with system rights). 358 374 */ 359 if (aTask->progress)360 375 LogRel(("Preparing to execute Guest Additions update ...\n")); 376 aTask->progress->SetCurrentOperationProgress(66); 361 377 362 378 /* Prepare command line args for installer. */ … … 400 416 } 401 417 } 402 catch (HRESULT aRC)418 catch (HRESULT aRC) 403 419 { 404 420 rc = aRC; … … 406 422 407 423 /* Clean up */ 408 if (aTask->progress)409 aTask->progress->SetCurrentOperationProgress(99);410 411 /* Assign data. */412 if (rc == S_OK)413 {414 }415 416 424 aTask->rc = rc; 417 418 if (!aTask->progress.isNull()) 425 aTask->progress->SetCurrentOperationProgress(99); 426 427 if ( SUCCEEDED(aTask->progress->COMGETTER(Canceled(&fCanceled))) 428 && !fCanceled) 429 { 430 /* Task completed, regardless whether successful/failed. */ 431 432 /* Assign data. */ 433 if (rc == S_OK) 434 { 435 /* No data to assign yet. */ 436 } 437 419 438 aTask->progress->notifyComplete(rc); 439 } 440 else /* The task was canceled, set error code to prevent assertions. */ 441 { 442 LogRel(("Automatic Guest Additions update was canceled\n")); 443 aTask->progress->notifyComplete(VBOX_E_IPRT_ERROR, 444 COM_IIDOF(IGuest), 445 Guest::getStaticComponentName(), 446 "Automatic Guest Additions update was canceled"); 447 } 420 448 421 449 LogFlowFunc(("rc=%Rhrc\n", rc)); … … 2577 2605 2578 2606 /* Initialize our worker task. */ 2579 std::auto_ptr<TaskGuest> task(new TaskGuest(TaskGuest::UpdateGuestAdditions, this, progress)); 2607 TaskGuest *pTask = new TaskGuest(TaskGuest::UpdateGuestAdditions, this, progress); 2608 AssertPtr(pTask); 2609 std::auto_ptr<TaskGuest> task(pTask); 2580 2610 2581 2611 /* Assign data - in that case aSource is the full path
Note:
See TracChangeset
for help on using the changeset viewer.