bool PhotoPlugin::receivePacket(const NetworkPacket &np)
{
if (np.get(QStringLiteral("cancel"))) {
requestedFiles.takeFirst();
}
if (requestedFiles.isEmpty() || !np.hasPayload()) {
return true;
}
const QString url = requestedFiles.takeFirst();
FileTransferJob *job = np.createPayloadTransferJob(QUrl(url));
connect(job, &FileTransferJob::result, this, [this, url] {
Q_EMIT photoReceived(url);
});
job->start();
return true;
}
This creates a FileTransferJob object and connects it to the network packet. It returns true if the packet should be cancelled, or the packet is already in progress.