frmUpload::frmUpload(QWidget * parent, Qt::WindowFlags f) : QDialog(parent, f) { ui.setupUi(this); setAttribute(Qt::WA_QuitOnClose, false); connect(ui.pbSelectDirectory, SIGNAL(clicked()), this, SLOT(selectDirectory())); connect(ui.leSelectDirectory, SIGNAL(textChanged(QString)), this, SLOT(leSelectDirectoryChanged())); connect(ui.pbScan, SIGNAL(clicked()), this, SLOT(pbScanClicked())); connect(&scanThread, SIGNAL(scanFinished(bool)), this, SLOT(scanFinished(bool))); connect(&scanThread, SIGNAL(folderChange(QString)), this, SLOT(folderChange(QString))); connect(ui.pbUpload, SIGNAL(clicked()), this, SLOT(pbUploadClicked())); connect(&uploadThread, SIGNAL(finished()), this, SLOT(uploadFinished())); connect(&uploadThread, SIGNAL(progressChange(int)), ui.pbProgress, SLOT(setValue(int))); connect(&uploadThread, SIGNAL(fileNameChange(QString)), this, SLOT(fileNameChange(QString))); connect(&uploadThread, SIGNAL(checkingUserPass()), this, SLOT(checkingUserPass())); connect(&uploadThread, SIGNAL(invalidUserPass()), this, SLOT(invalidUserPass())); if(QFileInfo(GlobalConfig().previousDialogPath()).isDir()) ui.leSelectDirectory->setText(GlobalConfig().previousDialogPath()); // workaround dla compiza? move((QApplication::desktop()->width() - width()) / 2, (QApplication::desktop()->height() - height()) / 2); }
void imgUploader::onUploadFinished() { //qDebug() << "c:upload finished"; Uploading = false; currentUpload->deleteLater(); emit uploadFinished(); }
void YouTube::resumeVideoUpload() { uploadRetries--; QByteArray rangeHeader = uploadReply->rawHeader("Range"); QByteArray startByte = rangeHeader.split('-').last(); QByteArray locationHeader = uploadReply->rawHeader("Location"); //qDebug() << rangeHeader << startByte << locationHeader; if (locationHeader.length() > 0) { uploadUrl = QUrl(locationHeader); } fileToBeUploaded->open(QIODevice::ReadOnly); int fs = fileToBeUploaded->size(); QByteArray fileSize = QByteArray::number(fs); QByteArray endByte = QByteArray::number(fs - 1); QByteArray range(startByte + '-' + endByte + '/' + fileSize); QNetworkRequest request(uploadUrl); request.setRawHeader("Host", "uploads.gdata.youtube.com"); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/octet-stream"); request.setHeader(QNetworkRequest::ContentLengthHeader, fs - startByte.toInt()); request.setRawHeader("Content-Range", range); uploadReply = nam->put(request, fileToBeUploaded); connect(uploadReply, SIGNAL(uploadProgress(qint64,qint64)), this, SIGNAL(updateUploadProgress(qint64,qint64))); connect(uploadReply, SIGNAL(finished()), this, SLOT(uploadFinished())); emit uploadStatusChanged("started"); }
frmNapiProjektUpload::frmNapiProjektUpload(QWidget * parent, Qt::WindowFlags f) : QDialog(parent, f) { ui.setupUi(this); setAttribute(Qt::WA_QuitOnClose, false); connect(ui.pbSelectDirectory, SIGNAL(clicked()), this, SLOT(selectDirectory())); connect(ui.leSelectDirectory, SIGNAL(textChanged(QString)), this, SLOT(leSelectDirectoryChanged())); connect(ui.pbScan, SIGNAL(clicked()), this, SLOT(pbScanClicked())); connect(&scanThread, SIGNAL(scanFinished(bool)), this, SLOT(scanFinished(bool))); connect(&scanThread, SIGNAL(folderChange(QString)), this, SLOT(folderChange(QString))); connect(ui.pbUpload, SIGNAL(clicked()), this, SLOT(pbUploadClicked())); connect(&uploadThread, SIGNAL(finished()), this, SLOT(uploadFinished())); connect(&uploadThread, SIGNAL(progressChange(int)), ui.pbProgress, SLOT(setValue(int))); connect(&uploadThread, SIGNAL(fileNameChange(QString)), this, SLOT(fileNameChange(QString))); connect(&uploadThread, SIGNAL(checkingUserPass()), this, SLOT(checkingUserPass())); connect(&uploadThread, SIGNAL(invalidUserPass()), this, SLOT(invalidUserPass())); if(QFileInfo(GlobalConfig().previousDialogPath()).isDir()) ui.leSelectDirectory->setText(GlobalConfig().previousDialogPath()); QRect position = frameGeometry(); position.moveCenter(QDesktopWidget().availableGeometry().center()); move(position.topLeft()); }
void Plugin::Upload (const QString& localPath, const QString& to, const QString& relPath) { QString target = to; if (!target.endsWith ('/') && !relPath.startsWith ('/')) target += '/'; target += relPath; const QString& dirPath = relPath.left (relPath.lastIndexOf ('/')); if (!QDir (to).mkpath (dirPath)) { emit uploadFinished (localPath, QFile::PermissionsError, tr ("Unable to create the directory path %1 on target device %2.") .arg (dirPath) .arg (to)); return; } auto watcher = new QFutureWatcher<QFile_ptr> (this); connect (watcher, SIGNAL (finished ()), this, SLOT (handleCopyFinished ())); std::function<QFile_ptr (void)> copier = [target, localPath] () { QFile_ptr file (new QFile (localPath)); file->copy (target); return file; }; const auto& future = QtConcurrent::run (copier); watcher->setFuture (future); }
void TwitPicDialog::accept() { m_progressBar->reset(); m_errorMsgLabel->hide(); m_progressBar->show(); QUrl url("http://twitpic.com/api/upload"); QNetworkRequest post(url); QByteArray boundary = "------------------------------7251e57fe7ed"; // "--------dlf-maximum"; post.setHeader(QNetworkRequest::ContentTypeHeader, "multipart/form-data; boundary=" + boundary); post.setRawHeader("Host", "twitpic.com"); QByteArray ba; ba.append("--" + boundary + "\r\n"); ba.append("Content-Disposition: form-data; name=\"media\"; filename=\"1.jpg\"\r\n"); ba.append("Content-Type: image/" + QImageReader::imageFormat(m_fileName) + "\r\n\r\n"); QFile file(m_fileName); file.open(QIODevice::ReadOnly); ba.append(file.readAll()); ba.append("\r\n"); ba.append("--" + boundary + "\r\n"); ba.append("Content-Disposition: form-data; name=\"username\"\r\n\r\n"); ba.append(m_username + "\r\n"); ba.append("--" + boundary + "\r\n"); ba.append("Content-Disposition: form-data; name=\"password\"\r\n\r\n"); ba.append(m_password + "\r\n"); ba.append("--" + boundary + "--" + "\r\n"); post.setHeader(QNetworkRequest::ContentLengthHeader, ba.count()); QNetworkAccessManager *manager = new QNetworkAccessManager(this); m_reply = manager->post(post, ba); connect(m_reply, SIGNAL(uploadProgress(qint64, qint64)), this, SLOT(updateProgressBar(qint64,qint64))); connect(m_reply, SIGNAL(finished()), this, SLOT(uploadFinished())); m_postButton->setEnabled(false); }
void RGhostUploader::uploadRequestFinished() { qDebug() << "RGhost uploader::" << "upload reply" //<< "\nheaders:" << reply->rawHeaderList() << "\nStatus:" << reply->rawHeader("Status") //<< "\ncookie:" << reply->rawHeader("Set-Cookie") << "\n\n response:" << reply->readAll().data(); emit uploadFinished(); }
CloudUploader::CloudUploader (ICloudStoragePlugin *cloud, QObject *parent) : QObject (parent) , Cloud_ (cloud) { connect (Cloud_->GetQObject (), SIGNAL (uploadFinished (QString, LeechCraft::LMP::CloudStorageError, QString)), this, SLOT (handleUploadFinished (QString, LeechCraft::LMP::CloudStorageError, QString)), Qt::UniqueConnection); }
/** Callback for the firmware upload result */ void DeviceWidget::uploadFinished(OP_DFU::Status retstatus) { disconnect(m_dfu, SIGNAL(uploadFinished(OP_DFU::Status)), this, SLOT(uploadFinished(OP_DFU::Status))); disconnect(m_dfu, SIGNAL(progressUpdated(int)), this, SLOT(setProgress(int))); disconnect(m_dfu, SIGNAL(operationProgress(QString)), this, SLOT(dfuStatus(QString))); if (retstatus != OP_DFU::Last_operation_Success) { emit uploadEnded(false); status(QString("Upload failed with code: ") + m_dfu->StatusToString(retstatus).toLatin1().data(), STATUSICON_FAIL); updateButtons(true); return; } else if (!descriptionArray.isEmpty()) { // We have a structured array to save status(QString("Updating description"), STATUSICON_RUNNING); repaint(); // Make sure the text above shows right away retstatus = m_dfu->UploadDescription(descriptionArray); if (retstatus != OP_DFU::Last_operation_Success) { emit uploadEnded(false); status(QString("Upload failed with code: ") + m_dfu->StatusToString(retstatus).toLatin1().data(), STATUSICON_FAIL); updateButtons(true); return; } } else if (!myDevice->description->text().isEmpty()) { // Fallback: we save the description field: status(QString("Updating description"), STATUSICON_RUNNING); repaint(); // Make sure the text above shows right away retstatus = m_dfu->UploadDescription(myDevice->description->text()); if (retstatus != OP_DFU::Last_operation_Success) { emit uploadEnded(false); status(QString("Upload failed with code: ") + m_dfu->StatusToString(retstatus).toLatin1().data(), STATUSICON_FAIL); updateButtons(true); return; } } populate(); emit uploadEnded(true); status("Upload successful", STATUSICON_OK); updateButtons(true); }
void FtpUpload::commandDone(bool){ qDebug() << "FtpUpload::commandDone << " << m_pFTPConnection->currentId(); if (m_IDUpload != 0){ m_IDUpload = 0; emit uploadFinished(m_strCurrentFile); } else if (m_IDLogin != 0){ m_IDLogin = 0; emit connectedToServer(); } }
void YouTube::performVideoUpload() { uploadRetries = 3; fileToBeUploaded->open(QIODevice::ReadOnly); QNetworkRequest request(uploadUrl); request.setRawHeader("Host", "uploads.gdata.youtube.com"); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/octet-stream"); request.setHeader(QNetworkRequest::ContentLengthHeader, fileToBeUploaded->size()); uploadReply = nam->put(request, fileToBeUploaded); connect(uploadReply, SIGNAL(uploadProgress(qint64,qint64)), this, SLOT(updateUploadProgress(qint64,qint64))); connect(uploadReply, SIGNAL(finished()), this, SLOT(uploadFinished())); emit uploadStatusChanged("started"); uploadTime.start(); }
void Plugin::handleCopyFinished () { auto watcher = dynamic_cast<QFutureWatcher<QFile_ptr>*> (sender ()); if (!watcher) return; const auto& file = watcher->result (); qDebug () << Q_FUNC_INFO << file->error (); if (file->error () != QFile::NoError) qWarning () << Q_FUNC_INFO << file->errorString (); emit uploadFinished (file->fileName (), file->error (), file->errorString ()); }
void Plugin::Upload (const QString& localPath, const QString& origPath, const QByteArray& devId, const QByteArray& storageId) { qDebug () << Q_FUNC_INFO << IsPolling_ << localPath << devId; if (IsPolling_) { UploadQueue_.append ({ localPath, origPath, devId, storageId }); return; } if (!DevicesCache_.contains (devId)) { qDebug () << "device not in cache, opening..."; bool found = false; LIBMTP_raw_device_t *rawDevices; int numRawDevices = 0; LIBMTP_Detect_Raw_Devices (&rawDevices, &numRawDevices); for (int i = 0; i < numRawDevices; ++i) { std::shared_ptr<LIBMTP_mtpdevice_t> device (LIBMTP_Open_Raw_Device (&rawDevices [i]), LIBMTP_Release_Device); if (!device) continue; const auto& serial = LIBMTP_Get_Serialnumber (device.get ()); qDebug () << "matching against" << serial; if (serial == devId) { DevicesCache_ [devId] = DeviceCacheEntry { std::move (device) }; found = true; break; } } free (rawDevices); if (!found) { qWarning () << Q_FUNC_INFO << "unable to find device" << devId; emit uploadFinished (localPath, QFile::ResourceError, tr ("Unable to find the requested device.")); return; } } const auto& entry = DevicesCache_ [devId]; UploadTo (entry.Device_.get (), storageId, localPath, origPath); }
void FtpCoordinator::workerFinished(bool anyErrors) { LOG_DEBUG << "anyErrors =" << anyErrors; if (anyErrors) { m_AnyFailed = true; } int workersDone = m_FinishedWorkersCount.fetchAndAddOrdered(1) + 1; if ((size_t)workersDone == m_AllWorkersCount) { finalizeUpload(); emit uploadFinished(m_AnyFailed); emit overallProgressChanged(100.0); } }
void CrashReporter::run() { QByteArray qbaDumpContents; QFile qfCrashDump(QDesktopServices::storageLocation(QDesktopServices::DataLocation) + QLatin1String("/mdvc.dmp")); if (! qfCrashDump.exists()) return; qfCrashDump.open(QIODevice::ReadOnly); if (qfCrashDump.peek(4) != "MDMP") return; qbaDumpContents = qfCrashDump.readAll(); if (qbaDumpContents.isEmpty()) { qWarning("CrashReporter: Empty crash dump file, not reporting."); return; } qpdProgress = new QProgressDialog(tr("Uploading crash report"), tr("Abort upload"), 0, 100, this); qpdProgress->setMinimumDuration(500); qpdProgress->setValue(0); connect(qpdProgress, SIGNAL(canceled()), qelLoop, SLOT(quit())); QString boundary = QString::fromLatin1("---------------------------%1").arg(QDateTime::currentDateTime().toTime_t()); QString ver = QString::fromLatin1("--%1\r\nContent-Disposition: form-data; name=\"ver\"\r\nContent-Transfer-Encoding: 8bit\r\n\r\n%2\r\n").arg(boundary, QLatin1String(MDVC_VERSION)); QString head = QString::fromLatin1("--%1\r\nContent-Disposition: form-data; name=\"dump\"; filename=\"mdvc.dmp\"\r\nContent-Type: binary/octet-stream\r\n\r\n").arg(boundary); QString end = QString::fromLatin1("\r\n--%1--\r\n").arg(boundary); QByteArray post = ver.toUtf8() + head.toUtf8() + qbaDumpContents + end.toUtf8(); QUrl url(QLatin1String("https://mix.hive.no/~xeno/mdcrash/crashreport.php")); QNetworkRequest req(url); req.setHeader(QNetworkRequest::ContentTypeHeader, QString::fromLatin1("multipart/form-data; boundary=%1").arg(boundary)); req.setHeader(QNetworkRequest::ContentLengthHeader, QString::number(post.size())); QNetworkAccessManager *nam = new QNetworkAccessManager(this); qnrReply = nam->post(req, post); connect(qnrReply, SIGNAL(finished()), this, SLOT(uploadFinished())); connect(qnrReply, SIGNAL(uploadProgress(qint64, qint64)), this, SLOT(uploadProgress(qint64, qint64))); qelLoop->exec(QEventLoop::DialogExec); if (! qfCrashDump.remove()) qWarning("CrashReporeter: Unable to remove crash file."); }
void AbstractMaemoUploadAndInstallStep::finishInitialization(const QString &displayName, AbstractMaemoPackageInstaller *installer) { setDefaultDisplayName(displayName); m_installer = installer; m_extendedState = Inactive; m_uploader = new MaemoPackageUploader(this); connect(m_uploader, SIGNAL(progress(QString)), SLOT(handleProgressReport(QString))); connect(m_uploader, SIGNAL(uploadFinished(QString)), SLOT(handleUploadFinished(QString))); connect(m_installer, SIGNAL(stdoutData(QString)), SLOT(handleRemoteStdout(QString))); connect(m_installer, SIGNAL(stderrData(QString)), SLOT(handleRemoteStderr(QString))); connect(m_installer, SIGNAL(finished(QString)), SLOT(handleInstallationFinished(QString))); }
void Plugin::handleUploadFinished () { auto watcher = dynamic_cast<QFutureWatcher<UploadInfo>*> (sender ()); watcher->deleteLater (); const auto& info = watcher->result (); qDebug () << "send result:" << info.Res_; if (info.Res_) { LIBMTP_Dump_Errorstack (info.Device_); LIBMTP_Clear_Errorstack (info.Device_); } AppendAlbum (info.Device_, info.Track_, info.Info_); LIBMTP_destroy_track_t (info.Track_); emit uploadFinished (info.LocalPath_, QFile::NoError, {}); }
OnlineAstrometryParser::OnlineAstrometryParser() : AstrometryParser() { job_retries=0; solver_retries=0; networkManager = new QNetworkAccessManager(this); connect(this, SIGNAL(authenticateFinished()), this, SLOT(uploadFile())); connect(this, SIGNAL(uploadFinished()), this, SLOT(getJobID())); connect(this, SIGNAL(jobIDFinished()), this, SLOT(checkJobs())); connect(this, SIGNAL(jobFinished()), this, SLOT(checkJobCalibration())); // Reset parity on solver failure connect(this, &OnlineAstrometryParser::solverFailed, this, [&]() { parity = -1;}); connect(this, SIGNAL(solverFailed()), this, SLOT(resetSolver())); connect(this, SIGNAL(solverFinished(double,double,double, double)), this, SLOT(resetSolver())); downsample_factor = 0; isGenerated = true; }
void TabDeckStorage::actUpload() { QModelIndex curLeft = localDirView->selectionModel()->currentIndex(); if (localDirModel->isDir(curLeft)) return; QString filePath = localDirModel->filePath(curLeft); QFile deckFile(filePath); QFileInfo deckFileInfo(deckFile); DeckLoader deck; if (!deck.loadFromFile(filePath, DeckLoader::CockatriceFormat)) return; if (deck.getName().isEmpty()) { bool ok; QString deckName = QInputDialog::getText(this, tr("Enter deck name"), tr("This decklist does not have a name.\nPlease enter a name:"), QLineEdit::Normal, deckFileInfo.completeBaseName(), &ok); if (!ok) return; if (deckName.isEmpty()) deckName = tr("Unnamed deck"); deck.setName(deckName); } QString targetPath; RemoteDeckList_TreeModel::Node *curRight = serverDirView->getCurrentItem(); if (!curRight) return; if (!dynamic_cast<RemoteDeckList_TreeModel::DirectoryNode *>(curRight)) curRight = curRight->getParent(); targetPath = dynamic_cast<RemoteDeckList_TreeModel::DirectoryNode *>(curRight)->getPath(); Command_DeckUpload cmd; cmd.set_path(targetPath.toStdString()); cmd.set_deck_list(deck.writeToString_Native().toStdString()); PendingCommand *pend = client->prepareSessionCommand(cmd); connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(uploadFinished(Response, CommandContainer))); client->sendCommand(pend); }
void YouTubeProvider::parserFinished(Joschy::AbstractJob *job) { JOSCHY_DEBUG() << "parser finsihed...."; Joschy::ResponseParser *parser = static_cast<Joschy::ResponseParser*>(job); const QString id = parser->id(); const ResponseParser::Type type = m_actions.take(id); const QString errorString = parser->errorString(); const Plugin::ErrorType errorType = parser->errorType(); const bool hasError = parser->error(); if (hasError) { emit error(id, errorType, errorString); } else { switch (type) { case ResponseParser::AuthenticationType: { m_tokens.insert(parser->login(), parser->token()); emit authenticated(id); break; } case ResponseParser::UploadType: { emit uploadFinished(id, parser->getVideo()); break; } case ResponseParser::SearchType: { QList<Joschy::Video> videos = parser->getVideos(); emit searchFinished(id, videos); break; } case ResponseParser::UpdateThumbnailType: { const QString thumbnail = m_thumbnails.take(id); QFile file(thumbnail); if (!file.open(QIODevice::WriteOnly)) { JOSCHY_DEBUG() << "open failed:" << thumbnail << file.errorString(); emit error(id, Plugin::CannotOpenError, file.errorString()); } else { if (file.write(parser->image()) == -1) { file.close(); JOSCHY_DEBUG() << file.error() << file.errorString(); emit error(id, Plugin::UnknownError, file.errorString()); } else { file.close(); emit thumbnailUpdated(id); } } break; } case ResponseParser::UpdateCategorysType: { m_categorys = parser->getCategorys(); QHash<QString, QVariant> hash; QHashIterator<QString, QString> it(m_categorys); while (it.hasNext()) { it.next(); hash[it.key()] = it.value(); } save("YouTube-Categorys", QVariant(hash)); save("YouTube-CategoryDate", QVariant(QDateTime::currentDateTime())); emit categorysChanged(categorys()); break; } default: break; } } m_parser.removeAll(parser); delete parser; layer()->freeId(id); }
void OnlineAstrometryParser::onResult(QNetworkReply* reply) { bool ok; QJsonParseError parseError; QString status; QList<QVariant> jsonArray; int elapsed; if (workflowStage == NO_STAGE) { reply->abort(); return; } if (reply->error() != QNetworkReply::NoError) { align->appendLogText(reply->errorString()); emit solverFailed(); return; } QString json = (QString) reply->readAll(); QJsonDocument json_doc = QJsonDocument::fromJson(json.toUtf8(), &parseError); if (parseError.error != QJsonParseError::NoError) { align->appendLogText(i18n("JSon error during parsing (%1).", parseError.errorString())); emit solverFailed(); return; } QVariant json_result = json_doc.toVariant(); QVariantMap result = json_result.toMap(); if (Options::solverVerbose()) align->appendLogText(json_doc.toJson(QJsonDocument::Compact)); switch (workflowStage) { case AUTH_STAGE: status = result["status"].toString(); if (status != "success") { align->appendLogText(i18n("Astrometry.net authentication failed. Check the validity of the Astrometry.net API Key.")); emit solverFailed(); return; } sessionKey = result["session"].toString(); if (Options::solverVerbose()) align->appendLogText(i18n("Authentication to astrometry.net is successful. Session: %1", sessionKey)); emit authenticateFinished(); break; case UPLOAD_STAGE: status = result["status"].toString(); if (status != "success") { align->appendLogText(i18n("Upload failed.")); emit solverFailed(); return; } subID = result["subid"].toInt(&ok); if (ok == false) { align->appendLogText(i18n("Parsing submission ID failed.")); emit solverFailed(); return; } align->appendLogText(i18n("Upload complete. Waiting for astrometry.net solver to complete...")); emit uploadFinished(); if (isGenerated) QFile::remove(filename); break; case JOB_ID_STAGE: jsonArray = result["jobs"].toList(); if (jsonArray.isEmpty()) jobID = 0; else jobID = jsonArray.first().toInt(&ok); if (jobID == 0 || !ok) { if (job_retries++ < JOB_RETRY_ATTEMPTS) { QTimer::singleShot(JOB_RETRY_DURATION, this, SLOT(getJobID())); return; } else { align->appendLogText(i18n("Failed to retrieve job ID.")); emit solverFailed(); return; } } job_retries=0; emit jobIDFinished(); break; case JOB_STATUS_STAGE: status = result["status"].toString(); if (status == "success") emit jobFinished(); else if (status == "solving") { if (status == "solving" && solver_retries++ < SOLVER_RETRY_ATTEMPTS) { QTimer::singleShot(SOLVER_RETRY_DURATION, this, SLOT(checkJobs())); return; } else { align->appendLogText(i18n("Solver timed out.")); solver_retries=0; emit solverFailed(); return; } } else if (status == "failure") { elapsed = (int) round(solverTimer.elapsed()/1000.0); align->appendLogText(i18np("Solver failed after %1 second.", "Solver failed after %1 seconds.", elapsed)); emit solverFailed(); return; } break; case JOB_CALIBRATION_STAGE: parity = result["parity"].toInt(&ok); if (ok == false) { align->appendLogText(i18n("Error parsing parity.")); emit solverFailed(); return; } orientation = result["orientation"].toDouble(&ok); if (ok == false) { align->appendLogText(i18n("Error parsing orientation.")); emit solverFailed(); return; } orientation *= parity; ra = result["ra"].toDouble(&ok); if (ok == false) { align->appendLogText(i18n("Error parsing RA.")); emit solverFailed(); return; } dec = result["dec"].toDouble(&ok); if (ok == false) { align->appendLogText(i18n("Error parsing DEC.")); emit solverFailed(); return; } pixscale = result["pixscale"].toDouble(&ok); if (ok == false) { align->appendLogText(i18n("Error parsing DEC.")); emit solverFailed(); return; } elapsed = (int) round(solverTimer.elapsed()/1000.0); align->appendLogText(i18np("Solver completed in %1 second.", "Solver completed in %1 seconds.", elapsed)); emit solverFinished(orientation, ra, dec, pixscale); break; default: break; } }
void RemoteDatabase::gotReply(QNetworkReply* reply) { // Check if request was successful if(reply->error() != QNetworkReply::NoError) { QMessageBox::warning(nullptr, qApp->applicationName(), tr("Error when connecting to %1.\n%2").arg(reply->url().toString()).arg(reply->errorString())); reply->deleteLater(); return; } // Check for redirect QString redirectUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toString(); if(!redirectUrl.isEmpty()) { // Avoid redirect loop if(reply->url() == redirectUrl) { reply->deleteLater(); return; } fetch(redirectUrl, static_cast<RequestType>(reply->property("type").toInt()), reply->property("certfile").toString(), reply->property("userdata")); reply->deleteLater(); return; } // What type of data is this? RequestType type = static_cast<RequestType>(reply->property("type").toInt()); // Hide progress dialog before opening a file dialog to make sure the progress dialog doesn't interfer with the file dialog if(type == RequestTypeDatabase || type == RequestTypePush) m_progress->reset(); // Handle the reply data switch(type) { case RequestTypeDatabase: { // It's a database file. // Add cloned database to list of local databases QString saveFileAs = localAdd(reply->url().fileName(), reply->property("certfile").toString(), reply->url(), QUrlQuery(reply->url()).queryItemValue("commit").toStdString()); // Save the downloaded data under the generated file name QFile file(saveFileAs); file.open(QIODevice::WriteOnly); file.write(reply->readAll()); // Set last modified data of the new file to the one provided by the server // Before version 5.10, Qt didn't offer any option to set this attribute, so we're not setting it at the moment #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) QString last_modified = reply->rawHeader("Content-Disposition"); QRegExp regex("^.*modification-date=\"(.+)\";.*$"); regex.setMinimal(true); // Set to non-greedy matching if(regex.indexIn(last_modified) != -1) { last_modified = regex.cap(1); bool success = file.setFileTime(QDateTime::fromString(last_modified, Qt::ISODate), QFileDevice::FileModificationTime); if(!success) qWarning() << file.errorString(); } #endif file.close(); // Tell the application to open this file emit openFile(saveFileAs); } break; case RequestTypeDirectory: emit gotDirList(reply->readAll(), reply->property("userdata")); break; case RequestTypeNewVersionCheck: { QString version = reply->readLine().trimmed(); QString url = reply->readLine().trimmed(); emit gotCurrentVersion(version, url); break; } case RequestTypeLicenceList: { // Read and check results json obj = json::parse(reply->readAll(), nullptr, false); if(obj.is_discarded() || !obj.is_object()) break; // Parse data and build ordered licence map: order -> (short name, long name) std::map<int, std::pair<std::string, std::string>> licences; for(auto it=obj.cbegin();it!=obj.cend();++it) licences.insert({it.value()["order"], {it.key(), it.value()["full_name"]}}); // Convert the map into an ordered vector and send it to anyone who's interested std::vector<std::pair<std::string, std::string>> licence_list; std::transform(licences.begin(), licences.end(), std::back_inserter(licence_list), [](const std::pair<int, std::pair<std::string, std::string>>& it) { return it.second; }); emit gotLicenceList(licence_list); break; } case RequestTypeBranchList: { // Read and check results json obj = json::parse(reply->readAll(), nullptr, false); if(obj.is_discarded() || !obj.is_object()) break; json obj_branches = obj["branches"]; // Parse data and assemble branch list std::vector<std::string> branches; for(auto it=obj_branches.cbegin();it!=obj_branches.cend();++it) branches.push_back(it.key()); // Get default branch std::string default_branch = (obj.contains("default_branch") && !obj["default_branch"].empty()) ? obj["default_branch"] : "master"; // Send branch list to anyone who is interested emit gotBranchList(branches, default_branch); break; } case RequestTypePush: { // Read and check results json obj = json::parse(reply->readAll(), nullptr, false); if(obj.is_discarded() || !obj.is_object()) break; // Create or update the record in our local checkout database QString saveFileAs = localAdd(reply->url().fileName(), reply->property("certfile").toString(), QString::fromStdString(obj["url"]), obj["commit_id"]); // If the name of the source file and the name we're saving as differ, we're doing an initial push. In this case, copy the source file to // the destination path to avoid redownloading it when it's first used. if(saveFileAs != reply->property("source_file").toString()) QFile::copy(reply->property("source_file").toString(), saveFileAs); emit uploadFinished(obj["url"]); break; } } // Delete reply later, i.e. after returning from this slot function reply->deleteLater(); }
void Plugin::UploadTo (LIBMTP_mtpdevice_t *device, const QByteArray& storageId, const QString& localPath, const QString& origPath) { if (!device->storage) LIBMTP_Get_Storage (device, 0); auto storage = device->storage; while (storage) { qDebug () << "st" << storage->id; if (QByteArray::number (storage->id) == storageId) break; storage = storage->next; } if (!storage) { qWarning () << Q_FUNC_INFO << "could not find storage" << storageId; emit uploadFinished (localPath, QFile::ResourceError, tr ("Unable to find the requested storage.")); return; } const auto id = storage->id; const auto& info = OrigInfos_.take (origPath); qDebug () << "uploading" << localPath << "of type" << GetFileType (info.FileFormat_) << "to" << storage->id; auto track = LIBMTP_new_track_t (); track->storage_id = id; auto getStr = [] (const QString& str) { return strdup (str.toUtf8 ().constData ()); }; track->filename = getStr (QFileInfo (localPath).fileName ()); track->album = getStr (info.Album_); track->title = getStr (info.TrackTitle_); track->genre = getStr (info.Genres_.join ("; ")); track->artist = getStr (info.Artist_); track->tracknumber = info.TrackNumber_; track->filetype = GetFileType (info.FileFormat_); track->filesize = QFileInfo (localPath).size (); track->date = getStr (QString::number (info.AlbumYear_) + "0101T0000.0"); auto watcher = new QFutureWatcher<UploadInfo> (); connect (watcher, SIGNAL (finished ()), this, SLOT (handleUploadFinished ())); const auto future = QtConcurrent::run ([=] () -> UploadInfo { const auto cbData = new CallbackData { this, 0 }; const auto res = LIBMTP_Send_Track_From_File (device, localPath.toUtf8 ().constData (), track, TransferCallback, cbData); delete cbData; return { res, device, localPath, track, info }; }); watcher->setFuture (future); }
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!"; } } }
// delete photoUploader; delete window; //delete fbui2; //delete fbui3; } //this class is a sample of how to use the facebook APIs SampleApp::SampleApp(){ connect(&networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(parseNetworkReply(QNetworkReply*))); QString ELC_Application_ID="112189648850879"; face= new Facebook (ELC_Application_ID); // photoUploader= new PhotoUploader(ROOT_URL); connect(face, SIGNAL(logInFinished()), this, SLOT(publishPhoto())); connect(face, SIGNAL(photoUploadFinished()), this, SLOT(uploadFinished())); //face->logIn(); doStuff(); } void SampleApp::doStuff(){ window= new UIFBmain(); fbui2 = new UIFBUser(); fbui3 = new UIFBUser(); fbui2->setUserName("pretend name 1"); fbui2->setUserLocation("location 1"); //fbui2->resize(200,200);
/** 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); }