/* Uploader handles uploading a binary image to a board. It reads the board profile for the currently selected board to determine which uploader to use. Then it fires up a QProcess and runs the uploader with flags determined by settings in Preferences. It prints output from the upload process back to the console output in the MainWindow. */ Uploader::Uploader(MainWindow *mainWindow) : QProcess( ) { this->mainWindow = mainWindow; uploaderProgress = new QProgressDialog( ); connect(uploaderProgress, SIGNAL(canceled()), this, SLOT(kill())); connect(uploaderProgress, SIGNAL(finished(int)), this, SLOT(onProgressDialogFinished(int))); connect(this, SIGNAL(readyReadStandardOutput()), this, SLOT(filterOutput())); connect(this, SIGNAL(readyReadStandardError()), this, SLOT(filterError())); connect(this, SIGNAL(started()), this, SLOT(uploadStarted())); connect(this, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(uploadFinished(int, QProcess::ExitStatus))); connect(this, SIGNAL(error(QProcess::ProcessError)), this, SLOT(onError(QProcess::ProcessError))); }
void MainWindow::downloadFiles(const QString & path, const QVector<mtp::ObjectId> &objects) { qDebug() << "downloading to " << path; ProgressDialog progressDialog(this); progressDialog.show(); connect(_uploader, SIGNAL(uploadProgress(float)), &progressDialog, SLOT(setValue(float))); connect(_uploader, SIGNAL(uploadSpeed(qint64)), &progressDialog, SLOT(setSpeed(qint64))); connect(_uploader, SIGNAL(uploadStarted(QString)), &progressDialog, SLOT(setFilename(QString))); connect(_uploader, SIGNAL(finished()), &progressDialog, SLOT(accept())); connect(&progressDialog, SIGNAL(abort()), _uploader, SLOT(abort())); _uploader->download(path, objects); progressDialog.exec(); }
ArtworkUploader::ArtworkUploader(int maxParallelUploads) : ArtworksProcessor(), m_IncludeVector(false), m_Percent(0) { m_UploadCoordinator = new Helpers::UploadCoordinator(maxParallelUploads); QObject::connect(m_UploadCoordinator, SIGNAL(uploadStarted()), this, SLOT(onUploadStarted())); QObject::connect(m_UploadCoordinator, SIGNAL(uploadFinished(bool)), this, SLOT(allFinished(bool))); QObject::connect(m_UploadCoordinator, SIGNAL(itemFinished(bool)), this, SLOT(artworkUploaded(bool))); QObject::connect(m_UploadCoordinator, SIGNAL(percentChanged(double)), this, SLOT(uploaderPercentChanged(double))); m_TestingCredentialWatcher = new QFutureWatcher<Helpers::TestConnectionResult>(this); connect(m_TestingCredentialWatcher, SIGNAL(finished()), SLOT(credentialsTestingFinished())); }
ArtworkUploader::ArtworkUploader(Conectivity::IFtpCoordinator *ftpCoordinator, QObject *parent): ArtworksProcessor(parent), m_FtpCoordinator(ftpCoordinator), m_Percent(0) { Conectivity::FtpCoordinator *coordinator = dynamic_cast<Conectivity::FtpCoordinator *>(ftpCoordinator); QObject::connect(coordinator, SIGNAL(uploadStarted()), this, SLOT(onUploadStarted())); QObject::connect(coordinator, SIGNAL(uploadFinished(bool)), this, SLOT(allFinished(bool))); QObject::connect(coordinator, SIGNAL(overallProgressChanged(double)), this, SLOT(uploaderPercentChanged(double))); m_TestingCredentialWatcher = new QFutureWatcher<Conectivity::ContextValidationResult>(this); QObject::connect(m_TestingCredentialWatcher, SIGNAL(finished()), SLOT(credentialsTestingFinished())); QObject::connect(coordinator, SIGNAL(transferFailed(QString, QString)), &m_UploadWatcher, SLOT(reportUploadErrorHandler(QString, QString))); QObject::connect(&m_StocksFtpList, SIGNAL(stocksListUpdated()), this, SLOT(stocksListUpdated())); }
void MainWindow::uploadFiles(const QStringList &files) { if (files.isEmpty()) return; qDebug() << "uploadFiles " << files; _uploadAnswer = 0; _proxyModel->setSourceModel(NULL); ProgressDialog progressDialog(this); progressDialog.setModal(true); progressDialog.setValue(0); connect(_uploader, SIGNAL(uploadProgress(float)), &progressDialog, SLOT(setValue(float))); connect(_uploader, SIGNAL(uploadSpeed(qint64)), &progressDialog, SLOT(setSpeed(qint64))); connect(_uploader, SIGNAL(uploadStarted(QString)), &progressDialog, SLOT(setFilename(QString))); connect(_uploader, SIGNAL(finished()), &progressDialog, SLOT(accept())); connect(&progressDialog, SIGNAL(abort()), _uploader, SLOT(abort())); _uploader->upload(files); progressDialog.exec(); _objectModel->moveToThread(QApplication::instance()->thread()); _proxyModel->setSourceModel(_objectModel); }
/** Sends a firmware to the device */ void deviceWidget::uploadFirmware() { myDevice->updateButton->setEnabled(false); if (!m_dfu->devices[deviceID].Writable) { status("Device not writable!", STATUSICON_FAIL); myDevice->updateButton->setEnabled(true); return; } bool verify = false; /* TODO: does not work properly on current Bootloader! if (m_dfu->devices[deviceID].Readable) verify = true; */ QByteArray desc = loadedFW.right(100); if (desc.startsWith("OpFw")) { descriptionArray = desc; // Now do sanity checking: // - Check whether board type matches firmware: int board = m_dfu->devices[deviceID].ID; int firmwareBoard = ((desc.at(12)&0xff)<<8) + (desc.at(13)&0xff); if((board == 0x401 && firmwareBoard == 0x402) || (board == 0x901 && firmwareBoard == 0x902) || // L3GD20 revo supports Revolution firmware (board == 0x902 && firmwareBoard == 0x903)) // RevoMini1 supporetd by RevoMini2 firmware { // These firmwares are designed to be backwards compatible } else if (firmwareBoard != board) { status("Error: firmware does not match board", STATUSICON_FAIL); myDevice->updateButton->setEnabled(true); return; } // Check the firmware embedded in the file: QByteArray firmwareHash = desc.mid(40,20); QByteArray fileHash = QCryptographicHash::hash(loadedFW.left(loadedFW.length()-100), QCryptographicHash::Sha1); if (firmwareHash != fileHash) { status("Error: firmware file corrupt", STATUSICON_FAIL); myDevice->updateButton->setEnabled(true); return; } } else { // The firmware is not packaged, just upload the text in the description field // if it is there. descriptionArray.clear(); } status("Starting firmware upload", STATUSICON_RUNNING); // We don't know which device was used previously, so we // are cautious and reenter DFU for this deviceID: emit uploadStarted(); if(!m_dfu->enterDFU(deviceID)) { status("Error:Could not enter DFU mode", STATUSICON_FAIL); myDevice->updateButton->setEnabled(true); emit uploadEnded(false); return; } OP_DFU::Status ret=m_dfu->StatusRequest(); qDebug() << m_dfu->StatusToString(ret); m_dfu->AbortOperation(); // Necessary, otherwise I get random failures. connect(m_dfu, SIGNAL(progressUpdated(int)), this, SLOT(setProgress(int))); connect(m_dfu, SIGNAL(operationProgress(QString)), this, SLOT(dfuStatus(QString))); connect(m_dfu, SIGNAL(uploadFinished(OP_DFU::Status)), this, SLOT(uploadFinished(OP_DFU::Status))); bool retstatus = m_dfu->UploadFirmware(filename,verify, deviceID); if(!retstatus ) { status("Could not start upload", STATUSICON_FAIL); myDevice->updateButton->setEnabled(true); emit uploadEnded(false); return; } status("Uploading, please wait...", STATUSICON_RUNNING); }
void Utils::start() { if(quee.isEmpty()) { //qDebug() << "quee.isEmpty"; return; } RequestData data = quee.takeFirst(); QUrl url(data.url); QNetworkRequest req(url); //qDebug() << "Authorization: " << data.auth; //qDebug() << "Url: " << url.toEncoded(); req.setRawHeader("Authorization", data.auth.toAscii()); if(data.isDownload) { QNetworkReply* reply = _nam->get(req); connect(reply,SIGNAL(finished()),this,SLOT(downloadFinished())); connect(reply,SIGNAL(downloadProgress(qint64,qint64)),this,SLOT(downloadProgress(qint64,qint64))); connect(reply,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(error(QNetworkReply::NetworkError))); cur_reply = reply; cur_folder = data.folder; cur_filename = data.filename; cur_size = data.size; isFinished = false; emit downloadStarted(data.filename); //qDebug() << "startDownload, filename: " << cur_filename; } else { QString filepath = data.folder + "/" + data.filename; //qDebug() << "filapath: " << filepath; cur_file = new QFile(filepath); if(cur_file->open(QIODevice::ReadOnly)) { QNetworkReply* reply = _nam->put(req,cur_file); connect(reply,SIGNAL(finished()),this,SLOT(uploadFinished())); connect(reply,SIGNAL(uploadProgress(qint64,qint64)),this,SLOT(uploadProgress(qint64,qint64))); connect(reply,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(error(QNetworkReply::NetworkError))); cur_reply = reply; cur_folder = data.folder; cur_filename = data.filename; cur_size = cur_file->size(); isFinished = false; emit uploadStarted(data.filename); //qDebug() << "size:" << cur_file->size(); } else { qDebug() << "error: file not open!"; } } }
void FileUploader::onStarted(const QString &file) { emit uploadStarted(file); }