MCPcopy Create free account
hub / github.com/bumptop/BumpTop / finishedReply

Method finishedReply

trunk/win/Source/BT_FileTransferManager.cpp:331–416  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

329}
330
331bool FileTransferWrapper::finishedReply(QNetworkReply * reply)
332{
333 assert(reply == _reply);
334 bool hasError = false;
335 bool succeeded = false;
336
337 if (_aborted)
338 return false;
339
340 // handle any redirects
341 QUrl redirectUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
342 QString redirectUrlStr = redirectUrl.toString();
343 if (getMaxNumberOfRedirects() > 0 && !redirectUrl.isEmpty())
344 {
345 FileTransfer transfer = _ft;
346 transfer.setUrl(redirectUrl.toString());
347 deleteLater();
348 return ftManager->addTransfer(transfer, isBlocking(), getMaxNumberOfRedirects()-1);
349 }
350
351 // if the reply has not finished, mark as error
352 if (!reply->isFinished())
353 hasError = true;
354
355 // set the transfer data functions
356 QByteArray data = reply->readAll();
357 switch (_ft.getType())
358 {
359 case FileTransfer::Upload:
360 // save the upload reply to the temporary string
361 if (!_ft.shouldSaveToFile())
362 {
363 QString *outBuffer = _ft.openTemporaryString();
364 outBuffer->append(data);
365
366 if (verbose) consoleWrite("POST " + _ft.getTemporaryString() + "\n\n");
367 }
368 break;
369
370 case FileTransfer::Download:
371 // save the file to disk
372 if (_ft.shouldSaveToFile())
373 {
374 QFile file(_ft.getLocalPath());
375 if (!file.open(QIODevice::WriteOnly))
376 hasError = true;
377 if (file.write(data) == -1)
378 hasError = true;
379 file.close();
380 }
381 // save the file to the temporary string
382 else
383 {
384 QString * outBuffer = _ft.openTemporaryString();
385 outBuffer->append(data);
386
387 if (verbose) consoleWrite("POST " + _ft.getTemporaryString() + "\n\n");
388 }

Callers 2

addTransferMethod · 0.80
addPostTransferMethod · 0.80

Calls 15

assertClass · 0.85
consoleWriteFunction · 0.85
attributeMethod · 0.80
addTransferMethod · 0.80
shouldSaveToFileMethod · 0.80
openTemporaryStringMethod · 0.80
getTemporaryStringMethod · 0.80
getLocalPathMethod · 0.80
getHandlerMethod · 0.80
removeIncompleteFileMethod · 0.80
runtime_errorClass · 0.50
toStringMethod · 0.45

Tested by

no test coverage detected