void PropagateUploadFileQNAM::slotComputeTransmissionChecksum(const QByteArray& contentChecksumType, const QByteArray& contentChecksum) { _item->_contentChecksum = contentChecksum; _item->_contentChecksumType = contentChecksumType; _stopWatch.addLapTime(QLatin1String("ContentChecksum")); _stopWatch.start(); // Reuse the content checksum as the transmission checksum if possible const auto supportedTransmissionChecksums = _propagator->account()->capabilities().supportedChecksumTypes(); if (supportedTransmissionChecksums.contains(contentChecksumType)) { slotStartUpload(contentChecksumType, contentChecksum); return; } // Compute the transmission checksum. auto computeChecksum = new ComputeChecksum(this); if (uploadChecksumEnabled()) { computeChecksum->setChecksumType(_propagator->account()->capabilities().uploadChecksumType()); } else { computeChecksum->setChecksumType(QByteArray()); } connect(computeChecksum, SIGNAL(done(QByteArray,QByteArray)), SLOT(slotStartUpload(QByteArray,QByteArray))); const QString filePath = _propagator->getFilePath(_item->_file); computeChecksum->start(filePath); }
void PropagateUploadFileQNAM::slotComputeContentChecksum() { if (_propagator->_abortRequested.fetchAndAddRelaxed(0)) { return; } const QString filePath = _propagator->getFilePath(_item->_file); // remember the modtime before checksumming to be able to detect a file // change during the checksum calculation _item->_modtime = FileSystem::getModTime(filePath); _stopWatch.start(); QByteArray checksumType = contentChecksumType(); // Maybe the discovery already computed the checksum? if (_item->_contentChecksumType == checksumType && !_item->_contentChecksum.isEmpty()) { slotComputeTransmissionChecksum(checksumType, _item->_contentChecksum); return; } // Compute the content checksum. auto computeChecksum = new ComputeChecksum(this); computeChecksum->setChecksumType(checksumType); connect(computeChecksum, SIGNAL(done(QByteArray,QByteArray)), SLOT(slotComputeTransmissionChecksum(QByteArray,QByteArray))); computeChecksum->start(filePath); }
void ValidateChecksumHeader::start(const QString& filePath, const QByteArray& checksumHeader) { // If the incoming header is empty no validation can happen. Just continue. if( checksumHeader.isEmpty() ) { emit validated(QByteArray(), QByteArray()); return; } if( !parseChecksumHeader(checksumHeader, &_expectedChecksumType, &_expectedChecksum) ) { qDebug() << "Checksum header malformed:" << checksumHeader; emit validationFailed(tr("The checksum header is malformed.")); return; } auto calculator = new ComputeChecksum(this); calculator->setChecksumType(_expectedChecksumType); connect(calculator, SIGNAL(done(QByteArray,QByteArray)), SLOT(slotChecksumCalculated(QByteArray,QByteArray))); calculator->start(filePath); }
void PropagateUploadFileQNAM::slotComputeContentChecksum() { if (_propagator->_abortRequested.fetchAndAddRelaxed(0)) { return; } _propagator->_activeJobList.removeOne(this); const QString filePath = _propagator->getFilePath(_item->_file); // remember the modtime before checksumming to be able to detect a file // change during the checksum calculation _item->_modtime = FileSystem::getModTime(filePath); _stopWatch.start(); QByteArray contentChecksumType; // We currently only do content checksums for the particular .eml case // This should be done more generally in the future! if (filePath.endsWith(QLatin1String(".eml"), Qt::CaseInsensitive)) { contentChecksumType = "MD5"; } // Maybe the discovery already computed the checksum? if (_item->_contentChecksumType == contentChecksumType && !_item->_contentChecksum.isEmpty()) { slotComputeTransmissionChecksum(contentChecksumType, _item->_contentChecksum); return; } // Compute the content checksum. auto computeChecksum = new ComputeChecksum(this); computeChecksum->setChecksumType(contentChecksumType); connect(computeChecksum, SIGNAL(done(QByteArray,QByteArray)), SLOT(slotComputeTransmissionChecksum(QByteArray,QByteArray))); computeChecksum->start(filePath); }