ImageProcessing::ImageProcessing(QWidget *parent) : QMainWindow(parent) {
	iImageIndex = 0;
	m_NetTimeout = 0;
	m_ImageTimeout = 0;

	lbImage = new QLabel(this);
    bTurnOff = false;
    m_notRunning = true;
	setWindowState(Qt::WindowFullScreen);

	player = new QMediaPlayer(this);
    playlist = new QMediaPlaylist();
    player->setPlaylist(playlist);

    m_contentList = new FileDownload(this);
    m_imageFile = new FileDownload(this);

	pNextImage = new QTimer();

	connect(pNextImage, SIGNAL(timeout()), this, SLOT(timeout()));
    connect(m_contentList, SIGNAL(downloaded()), this, SLOT(contentListDownloadComplete()));
    connect(m_contentList, SIGNAL(downloadError(QNetworkReply::NetworkError)), this, SLOT(fileDownloadError(QNetworkReply::NetworkError)));
    connect(m_imageFile, SIGNAL(downloaded()), this, SLOT(fileDownloadComplete()));
    connect(m_imageFile, SIGNAL(downloadError(QNetworkReply::NetworkError)), this, SLOT(fileDownloadError(QNetworkReply::NetworkError)));
    connect(player, SIGNAL(durationChanged(qint64)), this, SLOT(durationChanged(qint64)));
    connect(player, SIGNAL(positionChanged(qint64)), this, SLOT(positionChanged(qint64)));
    connect(player, SIGNAL(metaDataChanged()), this, SLOT(metaDataChanged()));
    connect(player, SIGNAL(error(QMediaPlayer::Error)), this, SLOT(displayErrorMessage()));
    connect(this, SIGNAL(fileDownloadsComplete()), this, SLOT(unlockShowEvent()));

    videoWidget = new QVideoWidget(this);
    player->setVideoOutput(videoWidget);
    videoWidget->hide();
}
void AdBlockDownloader::onDownloadError(QNetworkReply::NetworkError)
{
    this->_tempfile.close();
    this->_tempfile.remove();

    emit downloadError(this->_downloadreply->errorString());
}
Beispiel #3
0
void CacheDownload::start()
{
    if (!m_entry->stale)
    {
        emit succeeded(index_within_job);
        return;
    }
    m_output_file.setFileName(m_target_path);
    // if there already is a file and md5 checking is in effect and it can be opened
    if (!ensureFilePathExists(m_target_path))
    {
        emit failed(index_within_job);
        return;
    }
    QLOG_INFO() << "Downloading " << m_url.toString();
    QNetworkRequest request(m_url);
    if (m_entry->remote_changed_timestamp.size())
        request.setRawHeader(QString("If-Modified-Since").toLatin1(),
                             m_entry->remote_changed_timestamp.toLatin1());
    if (m_entry->etag.size())
        request.setRawHeader(QString("If-None-Match").toLatin1(), m_entry->etag.toLatin1());

    request.setHeader(QNetworkRequest::UserAgentHeader, "MultiMC/5.0 (Cached)");

    auto worker = MMC->qnam();
    QNetworkReply *rep = worker->get(request);

    m_reply = std::shared_ptr<QNetworkReply>(rep);
    connect(rep, SIGNAL(downloadProgress(qint64, qint64)),
            SLOT(downloadProgress(qint64, qint64)));
    connect(rep, SIGNAL(finished()), SLOT(downloadFinished()));
    connect(rep, SIGNAL(error(QNetworkReply::NetworkError)),
            SLOT(downloadError(QNetworkReply::NetworkError)));
    connect(rep, SIGNAL(readyRead()), SLOT(downloadReadyRead()));
}
void DownloadManagerImpl::slotDownloadSslErrors(int downloadId, const QList<QSslError> &errors)
{
    Q_UNUSED(errors);
    emit downloadError(downloadId, DownloadManager::SslHandshakeFailedError);
    removeAndUpdateDownload(downloadId, DownloadManager::Error);
    qDebug() << __PRETTY_FUNCTION__ << " Emitted downloadError SslHandshakeFailedError signal" << ", downloadId = " << downloadId;
}
void CDownload::startDownload(QNetworkAccessManager* netManager)
{
    if (mState == EDownloadNotStarted)
    {
        mState = EDownloadFailed;
        if (netManager)
        {
            QNetworkAccessManager::NetworkAccessibility access = netManager->networkAccessible();
            if (access != QNetworkAccessManager::NotAccessible)
            {
                mNetReply = netManager->get(QNetworkRequest(QUrl(mUrlName)));
                if (mNetReply)
                {
                    connect(
                        mNetReply, SIGNAL(finished()),
                        this, SLOT(downloadFinished()));

                    connect(
                        mNetReply, SIGNAL(error(QNetworkReply::NetworkError)),
                        this, SLOT(downloadError(QNetworkReply::NetworkError)));
                    //connect(
                    //    mNetReply, SIGNAL(downloadProgress(qint64, qint64)),
                    //    this, SLOT(downloadProgress(qint64, qint64)));
                    mState = EDownloadStarted;
                }
            }
        }
    }
}
void DownloadManager::downloadRequested(const QNetworkRequest& request) {
    std::cout << "DownloadManager::DownloadRequested()\n";
    QString src = request.url().toString();
    QString dest = request.attribute(QNetworkRequest::User, "~").toString();

    QFile* fileDestination = new QFile(dest);
    fileDestination->open(QIODevice::ReadWrite);
    QNetworkReply* reply = mNetworkAccess.get(request);
    reply->setReadBufferSize(0);
    mActiveDownloads.insert(reply, fileDestination);

    connect(reply, SIGNAL(finished()), this, SLOT(downloadFinished()));
    connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(downloadError(QNetworkReply::NetworkError)));
    connect(reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(downloadProgress(qint64, qint64)));
    connect(reply, SIGNAL(readyRead()), this, SLOT(downloadReadyRead()));

    DownloadData* data = new DownloadData();
    data->mRemotePath = src;
    data->mLocalPath = dest;

    connect(reply, SIGNAL(finished()), data, SLOT(finished()));

    connect(reply, SIGNAL(downloadProgress(qint64, qint64)), data, SLOT(catchProgress(qint64, qint64)));
    connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), data, SIGNAL(error(QNetworkReply::NetworkError)));
    connect(data, SIGNAL(stopMe()), this, SLOT(stopDownload()));
    connect(data, SIGNAL(removeMe()), this, SLOT(removeDownload()));
    //connect(data, SIGNAL(reloadMe()), this, SLOT(reloadDownload()));

    emit downloadStarted(data);
    emit controller_showSystemTrayMessage("", "Download Started: " + data->localName());
    mModel.addDownload(data);
    mDownloads.insert(data, reply);
}
static void debugDownloadError(WRT::Download * download)
{
    int num = intAttribute(download, WRT::LastError);

    const char * error = downloadError(static_cast<QNetworkReply::NetworkError>(num));

    debugDownloadAttribute(download, "DownloadError", error);
}
Beispiel #8
0
void Downloader::replyError(QNetworkReply::NetworkError){
    QString errorString = "NetworkError!";
    if(reply){
        errorString = reply->errorString();
    }
    qDebug() << "Network error: " << errorString;
    emit downloadError(errorString);
}
void UpdaterComponent::downloadUpdate(const QVariantMap& updateInfo)
{
  if (isDownloading())
    return;

  QLOG_INFO() << updateInfo;

  if (!updateInfo.contains("version") ||
      !updateInfo.contains("manifestURL") || !updateInfo.contains("manifestHash") ||
      !updateInfo.contains("fileURL") || !updateInfo.contains("fileHash") || !updateInfo.contains("fileName"))
  {
    QLOG_ERROR() << "updateInfo was missing fields required to carry out this action.";
    return;
  }

  m_version = updateInfo["version"].toString();

  m_manifest = new Update(updateInfo["manifestURL"].toString(),
                          UpdateManager::GetPath("manifest.xml.bz2", m_version, false),
                          updateInfo["manifestHash"].toString(), this);

  // determine if we have a manifest (some distros don't like OE)
  m_hasManifest = ((!m_manifest->m_url.isEmpty()) && (!m_manifest->m_hash.isEmpty()));

  m_file = new Update(updateInfo["fileURL"].toString(),
                      UpdateManager::GetPath(updateInfo["fileName"].toString(), m_version, true),
                      updateInfo["fileHash"].toString(), this);


  if (m_hasManifest)
    connect(m_manifest, &Update::fileDone, this, &UpdaterComponent::fileComplete);

  connect(m_file, &Update::fileDone, this, &UpdaterComponent::fileComplete);

  // create directories we need
  QDir dr(QFileInfo(m_file->m_localPath).dir());
  if (!dr.exists())
  {
    if (!dr.mkpath("."))
    {
      QLOG_ERROR() << "Failed to create update directory:" << dr.absolutePath();
      emit downloadError("Failed to create download directory");
      return;
    }
  }

  // this will first check if the files are done
  // and in that case emit the done signal.
  if (fileComplete(NULL))
    return;

  if (!m_manifest->isReady() && m_hasManifest)
    downloadFile(m_manifest);

  if (!m_file->isReady())
    downloadFile(m_file);
}
Beispiel #10
0
void SongDownloader::slotError(QNetworkReply::NetworkError error) {
    Q_UNUSED(error);
    qDebug() << "SongDownloader: Network error while trying to download a plugin.";

    //Delete partial file
    m_pDownloadedFile->remove();

    emit(downloadError());
}
Beispiel #11
0
PrintDefault::PrintDefault(QObject* parent) :
    QObject(parent),
    report(0),
    printer(0)
{
    downloader = new DownloadFile(this);
    connect(downloader, SIGNAL(completed(QString)), this, SLOT(downloadFinished(QString)));
    connect(downloader, SIGNAL(error(QUrl,QString)), this, SLOT(downloadError(QUrl,QString)));
}
Beispiel #12
0
DlgUpdate::DlgUpdate(QWidget *parent) : QDialog(parent) {

    //Handle layout
    statusLabel = new QLabel(this);
    statusLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
    statusLabel->setWordWrap(true);
    descriptionLabel = new QLabel(tr("Current release channel") + QString(": %1").arg(tr(settingsCache->getUpdateReleaseChannel()->getName().toUtf8())), this);
    progress = new QProgressBar(this);

    buttonBox = new QDialogButtonBox(this);
    buttonBox->setFixedWidth(350);

    ok = new QPushButton("Close", this);
    manualDownload = new QPushButton(tr("Reinstall"), this);
    stopDownload = new QPushButton(tr("Cancel Download"), this);
    gotoDownload = new QPushButton(tr("Open Download Page"), this);

    addStopDownloadAndRemoveOthers(false); // Add all buttons to box
    enableUpdateButton(false); //Unless we know there's an update available, you can't install
    buttonBox->addButton(ok, QDialogButtonBox::AcceptRole);

    connect(gotoDownload, SIGNAL(clicked()), this, SLOT(gotoDownloadPage()));
    connect(manualDownload, SIGNAL(clicked()), this, SLOT(downloadUpdate()));
    connect(stopDownload, SIGNAL(clicked()), this, SLOT(cancelDownload()));
    connect(ok, SIGNAL(clicked()), this, SLOT(closeDialog()));

    QVBoxLayout *parentLayout = new QVBoxLayout(this);
    parentLayout->addWidget(descriptionLabel);
    parentLayout->addWidget(statusLabel);
    parentLayout->addWidget(progress);
    parentLayout->addWidget(buttonBox);

    setLayout(parentLayout);

    //Check for SSL (this probably isn't necessary)
    if (!QSslSocket::supportsSsl()) {
        enableUpdateButton(false);
        QMessageBox::critical(this, tr("Error"),
            tr("Cockatrice was not built with SSL support, therefore you cannot download updates automatically! \nPlease visit the download page to update manually."));
    }

    //Initialize the checker and downloader class
    uDownloader = new UpdateDownloader(this);
    connect(uDownloader, SIGNAL(downloadSuccessful(QUrl)), this, SLOT(downloadSuccessful(QUrl)));
    connect(uDownloader, SIGNAL(progressMade(qint64, qint64)), this, SLOT(downloadProgressMade(qint64, qint64)));
    connect(uDownloader, SIGNAL(error(QString)), this, SLOT(downloadError(QString)));

    ReleaseChannel * channel = settingsCache->getUpdateReleaseChannel();
    connect(channel, SIGNAL(finishedCheck(bool, bool, Release *)), this, SLOT(finishedUpdateCheck(bool, bool, Release *)));
    connect(channel, SIGNAL(error(QString)), this, SLOT(updateCheckError(QString)));

    //Check for updates
    beginUpdateCheck();
}
void SearchResultsPreviewCatcher::downloadNextPreview()
{
	// has previews to download or an image to download?
	if (!previews->isEmpty())
	{
		emit startedDownloadPreview(previews->first());
		int httpResult = http->download(QUrl(previews->first()->getImageUrl()), QDir::tempPath(), previews->first()->getPreviewFileName(), false);
		// error?
		if (httpResult != EnumHTTP::NO_HTTP_ERROR)
			downloadError(httpResult);
	}
}
DlgUpdate::DlgUpdate(QWidget *parent) : QDialog(parent) {

    //Handle layout
    statusLabel = new QLabel(this);
    descriptionLabel = new QLabel(tr("Current release channel:") + " " + tr(settingsCache->getUpdateReleaseChannel()->getName().toUtf8()), this);
    progress = new QProgressBar(this);

    QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
    ok = new QPushButton("Ok", this);
    manualDownload = new QPushButton(tr("Update Anyway"), this);
    enableUpdateButton(false); //Unless we know there's an update available, you can't install
    gotoDownload = new QPushButton(tr("Open Download Page"), this);
    buttonBox->addButton(manualDownload, QDialogButtonBox::ActionRole);
    buttonBox->addButton(gotoDownload, QDialogButtonBox::ActionRole);
    buttonBox->addButton(ok, QDialogButtonBox::AcceptRole);

    connect(gotoDownload, SIGNAL(clicked()), this, SLOT(gotoDownloadPage()));
    connect(manualDownload, SIGNAL(clicked()), this, SLOT(downloadUpdate()));
    connect(ok, SIGNAL(clicked()), this, SLOT(closeDialog()));

    QVBoxLayout *parentLayout = new QVBoxLayout(this);
    parentLayout->addWidget(descriptionLabel);
    parentLayout->addWidget(statusLabel);
    parentLayout->addWidget(progress);
    parentLayout->addWidget(buttonBox);

    setLayout(parentLayout);

    //Check for SSL (this probably isn't necessary)
    if (!QSslSocket::supportsSsl()) {
        enableUpdateButton(false);
        QMessageBox::critical(this, tr("Error"),
            tr("Cockatrice was not built with SSL support, so you cannot download updates automatically! "
            "Please visit the download page to update manually."));
    }

    //Initialize the checker and downloader class
    uDownloader = new UpdateDownloader(this);
    connect(uDownloader, SIGNAL(downloadSuccessful(QUrl)), this, SLOT(downloadSuccessful(QUrl)));
    connect(uDownloader, SIGNAL(progressMade(qint64, qint64)),
            this, SLOT(downloadProgressMade(qint64, qint64)));
    connect(uDownloader, SIGNAL(error(QString)),
            this, SLOT(downloadError(QString)));

    ReleaseChannel * channel = settingsCache->getUpdateReleaseChannel();
    connect(channel, SIGNAL(finishedCheck(bool, bool, Release * )),
            this, SLOT(finishedUpdateCheck(bool, bool, Release * )));
    connect(channel, SIGNAL(error(QString)),
            this, SLOT(updateCheckError(QString)));

    //Check for updates
    beginUpdateCheck();
}
Beispiel #15
0
void QgsFileDownloader::error( QStringList errorMessages )
{
  for ( auto end = errorMessages.size(), i = 0; i != end; ++i )
  {
    mErrors << errorMessages[i];
  }
  // Show error
  if ( mGuiNotificationsEnabled )
  {
    QMessageBox::warning( nullptr, tr( "Download failed" ), mErrors.join( "<br>" ) );
  }
  emit downloadError( mErrors );
}
Beispiel #16
0
void Utils::downloadFinished()
{
    //qDebug() << "downloadFinished";
    isFinished = true;
    if (cur_reply->error() == QNetworkReply::NoError)
    {
        int httpStatus = cur_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
        //qDebug() << "status: " << httpStatus;

        if(httpStatus<300) {
            QByteArray bytes = cur_reply->readAll();
            QString filepath = cur_folder + "/" + cur_filename;
            QFile file(filepath);
            file.open(QIODevice::WriteOnly);
            int len = bytes.length();
            QDataStream out(&file);
            out.writeRawData(bytes.constData(),len);
            file.close();
            emit fileDownloaded(cur_filename);
        } else {
            qDebug() << "download error";
            emit downloadError(cur_filename);
        }
    }
    else if (cur_reply->error() == QNetworkReply::OperationCanceledError)
    {
        emit operationCanceled(cur_filename);
    }
    else
    {
        //qDebug() << "download error";
        emit downloadError(cur_filename);
    }

    cur_reply->close();
    cur_reply->deleteLater();

    start();
}
BeurerScaleManager::BeurerScaleManager(QWidget* parent, Qt::WindowFlags f)
    : QWidget(parent, f)
    , usb(new Usb::UsbDownloader(this))
    , usb_data(new Usb::UsbData(this))
{
    setWindowTitle("Beurer Scale Manager");

    ui = new Ui::BeurerScaleManager();
    ui->setupUi(this);

    connect(usb, SIGNAL(progress(int)), ui->progressDownload, SLOT(setValue(int)));
    connect(usb, SIGNAL(completed(QByteArray)), this, SLOT(downloadCompleted(QByteArray)));
    connect(usb, SIGNAL(error()), this, SLOT(downloadError()));
}
void UpdaterDialog::buttonUpdate()
{
	if(httpGet)delete httpGet;
	httpGet=new QHttp;
	connect(httpGet,SIGNAL(done(bool)),this,SLOT(httpDone(bool)));
	connect(httpGet,SIGNAL(dataReadProgress(int,int)),this,SLOT(dataReadProgress(int,int)));
	QStringList tempList=updateLink.split("//");
	if(tempList.count()!=2){downloadError();return;}
	QString protocol=tempList.first();
	tempList=tempList.last().split("/");
	if(tempList.count()==0){downloadError();return;}
	QString domain=tempList.first();
	int removeLength=domain.length()+protocol.length()+2;
	if(updateLink.length()<=removeLength){downloadError();return;}
	updateLink.remove(0,removeLength);
	if(protocol.startsWith("https"))
	{
		httpGet->setSocket(new QSslSocket(httpGet));
		httpGet->setHost(domain, QHttp::ConnectionModeHttps,443);
	}
	else httpGet->setHost(domain,80);
	httpGet->get(updateLink);
}
void URLDownloader::error(QNetworkReply::NetworkError error)
{
   // ignore cancelled error (since it came from timeout)
   if (error == QNetworkReply::OperationCanceledError)
      return;

   if (pRequestTimeoutTimer_->isActive())
      pRequestTimeoutTimer_->stop();

   QNetworkReply* pReply = qobject_cast<QNetworkReply*>(sender());

   downloadError(pReply->errorString());

   deleteLater();
}
Beispiel #20
0
void CopyPhotosDialog::downloadNextPhoto()
{
    if (currentPhoto==photos.count()){
        currentPhoto = 0;
        plog(tr("All photos cached! Start uploading..."));
        uploadNextPhoto();
        return;
    }

    VKAlbumPhoto photo = photos.at(currentPhoto);

    QFile photoFile(photo.cacheFileName);
    if (photoFile.exists()){
        downloadError();
        //plog(tr("Alredy exists..."));
        return;
    }

    plog(tr("Download %1").arg(photo.src_big));
    QNetworkAccessManager *nam   = new QNetworkAccessManager( this );
    currentReply = nam->get( QNetworkRequest( QUrl( photo.src_big ) ) );
    connect(currentReply,SIGNAL(finished()),this,SLOT(downloadFinished()));
    connect(currentReply,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(downloadError()));
}
CDownload::~CDownload()
{
    if (mNetReply)
    {
        disconnect(
            mNetReply, SIGNAL(finished()),
            this, SLOT(downloadFinished()));

        disconnect(
            mNetReply, SIGNAL(error(QNetworkReply::NetworkError)),
            this, SLOT(downloadError(QNetworkReply::NetworkError)));
        mNetReply->abort();
        delete mNetReply;
        mNetReply = 0;
    }
}
void FileDownloader::downloadFile(const QUrl &url)
{
    if (downloadInProgress())
        return;

    m_downloadInProgress = true;

    QNetworkRequest request(url);
    QNetworkReply *reply = m_nam.get(request);

    connect(reply, QOverload<QNetworkReply::NetworkError>::of(&QNetworkReply::error), this, [this, reply] {
        emit downloadError(reply->errorString());
    });

    emit downloadInProgressChanged(m_downloadInProgress);
}
void ByteArrayDownload::start()
{
	QLOG_INFO() << "Downloading " << m_url.toString();
	QNetworkRequest request(m_url);
	request.setHeader(QNetworkRequest::UserAgentHeader, "MultiMC/5.0 (Uncached)");
	auto worker = MMC->qnam();
	QNetworkReply *rep = worker->get(request);

	m_reply = std::shared_ptr<QNetworkReply>(rep);
	connect(rep, SIGNAL(downloadProgress(qint64, qint64)),
			SLOT(downloadProgress(qint64, qint64)));
	connect(rep, SIGNAL(finished()), SLOT(downloadFinished()));
	connect(rep, SIGNAL(error(QNetworkReply::NetworkError)),
			SLOT(downloadError(QNetworkReply::NetworkError)));
	connect(rep, SIGNAL(readyRead()), SLOT(downloadReadyRead()));
}
Beispiel #24
0
void ImageViewer::loadImageFromURL()
{
    QUrl saveURL = QUrl::fromLocalFile(file.fileName() );

    if (!saveURL.isValid())
        qDebug()<<"tempfile-URL is malformed\n";

    //downloadJob = KIO::copy (m_ImageUrl, saveURL);	// starts the download asynchron
    //connect (downloadJob, SIGNAL (result (KJob *)), SLOT (downloadReady (KJob *)));

    QApplication::setOverrideCursor(Qt::WaitCursor);

    connect(&downloadJob, SIGNAL(downloaded()), this, SLOT(downloadReady()));
    connect(&downloadJob, SIGNAL(error(QString)), this, SLOT(downloadError(QString)));

    downloadJob.get(m_ImageUrl);
}
Beispiel #25
0
void MainWindow::load(const QString& fileName)
{
    if (fileName != "")
    {
	statusBar()->showMessage(tr("Loading %1...").arg(fileName));

	DownloadFile* download = new DownloadFile(this);
	connect(download, SIGNAL(completed(QString)), this, SLOT(downloadFinished(QString)));
	connect(download, SIGNAL(error(QUrl,QString)), this, SLOT(downloadError(QUrl,QString)));
	connect(download, SIGNAL(finished()), download, SLOT(deleteLater()));
	download->download(fileName);
	currentFileName = fileName;

	recentFiles.removeAll(currentFileName);
	recentFiles.prepend(currentFileName);
	updateRecentFileActions();
    }
}
Beispiel #26
0
void DownloadManager::doDownloadToPath(const QUrl &url, const QString& filename)
{
    if(url.isEmpty() || !url.isValid())
    {
        qDebug() << "Error: Invalid/Empty Url";
        emit downloadError(url);
        return;
    }

    QNetworkRequest request(url);
    QByteArray userAgent = QString(QCoreApplication::applicationName() + "/" + STR_VERSION_NET).toLatin1();
    request.setRawHeader("User-Agent",userAgent);
    QNetworkReply *reply = manager.get(request);

    connect(reply, SIGNAL(finished()),
            SLOT(downloadFinished()));

    destinationPaths.insert(url, filename);
    currentDownloads.append(reply);
}
Beispiel #27
0
void PasteUpload::executeTask()
{
	QNetworkRequest request(QUrl("http://paste.ee/api"));
	request.setHeader(QNetworkRequest::UserAgentHeader, "MultiMC/5.0 (Uncached)");
	QByteArray content(
		"key=public&description=MultiMC5+Log+File&language=plain&format=json&expire=2592000&paste=" +
		m_text.toUtf8());
	request.setRawHeader("Content-Type", "application/x-www-form-urlencoded");
	request.setRawHeader("Content-Length", QByteArray::number(content.size()));

	auto worker = MMC->qnam();
	QNetworkReply *rep = worker->post(request, content);

	m_reply = std::shared_ptr<QNetworkReply>(rep);
	connect(rep, &QNetworkReply::downloadProgress, [&](qint64 value, qint64 max)
	{ setProgress(value / qMax((qint64)1, max) * 100); });
	connect(rep, SIGNAL(error(QNetworkReply::NetworkError)), this,
			SLOT(downloadError(QNetworkReply::NetworkError)));
	connect(rep, SIGNAL(finished()), this, SLOT(downloadFinished()));
}
void UpdaterComponent::dlComplete(QNetworkReply* reply)
{
  QLOG_DEBUG() << "Hello, dlComplete";
  if (reply->error() == QNetworkReply::NoError)
  {
    QUrl redirectURL = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
    QLOG_DEBUG() << "Redirect:" << redirectURL.toString();
    if (!redirectURL.isEmpty())
    {
      // redirection, check that we get redirected to something we expect.
      if (redirectURL.toString().startsWith("https://nightlies.plex.tv") ||
          redirectURL.toString().startsWith("https://downloads.plex.tv"))
      {
        QNetworkReply* redirReply = m_netManager.get(QNetworkRequest(redirectURL));
        if (m_manifest->m_reply == reply)
          m_manifest->setReply(redirReply);
        else if (m_file->m_reply == reply)
        {
          m_file->setReply(redirReply);
          //connect(redirReply, &QNetworkReply::downloadProgress, this, &UpdaterComponent::downloadProgress);
        }

        QLOG_DEBUG() << "Redirecting to:" << redirectURL.toString();

        return;
      }
    }
  }
  else
  {
    QLOG_ERROR() << "Error downloading:" << reply->url() << "-" << reply->errorString();
    emit downloadError(reply->errorString());

    if (m_hasManifest)
      m_manifest->abort();

    m_file->abort();
  }
}
Beispiel #29
0
MainDlg::MainDlg(QWidget *parent) : QDialog(parent), ui(new Ui::MainDlg) {
    ui->setupUi(this);



    this->setWindowFlags(Qt::FramelessWindowHint);
    this->setWindowOpacity(0.95);
    this->setFixedSize(this->geometry().size());

    //prepare system tray icon
    trayIcon = new QSystemTrayIcon(this);
    trayIcon->setIcon(QIcon(":/rsc/package.png"));
    trayIcon->setVisible(true);
    connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));

    //prepare nice wait layer
    waitLayer = new QLabel(this);
    waitLayer->setGraphicsEffect(new QGraphicsBlurEffect());
    waitLayer->setPixmap(this->grab());
    waitLayer->hide();

    //connect minimize and close signals
    connect(ui->titleBar, SIGNAL(closeApp()), this, SLOT(closeApp()));
    connect(ui->titleBar, SIGNAL(minimizeApp()), this, SLOT(minimizeApp()));
    connect(ui->titleBar, SIGNAL(aboutApp()), this, SLOT(about()));

    //show waitLayer while working
    showWaitLayer(true);

    //retrieve once-for-all tmpPath
    tmpDir = FileTools::getInstance()->getTmpPath();

    //retrieve and parse list.xml
    dfh = new DownloadFileHandler(listDotZipPath, tmpDir, false);
    qDebug()<<tmpDir;
    connect(dfh, SIGNAL(fileDownloadFinished()), this, SLOT(parseListDotXml()));
    connect(dfh, SIGNAL(fileDownloadError(QString)), this, SLOT(downloadError(QString)));
    dfh->beginDownload();
}
Beispiel #30
0
void Downloader::download(const QUrl url)
{
    QNetworkReply *r = net->get(QNetworkRequest(url));
    connect(r,SIGNAL(finished()),this,SLOT(loadFinished()));
    connect(r,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(downloadError(QNetworkReply::NetworkError)));
}