Exemplo n.º 1
1
void DownloadsManager::downloadFile(QString token, QString id, QString fileName)
{
    if (!downloadDir.exists(fileName)) {
        FileDownloader* t = new FileDownloader(fileName, this);
        connect(t, SIGNAL(fileDownloaded()), this, SLOT(fileDownloaded()));
        t->startDownload(token, id);
    }
    else fileDownloaded();
}
Exemplo n.º 2
0
void DkImageContainerT::downloadFile(const QUrl& url) {

	if (!mFileDownloader) {
		mFileDownloader = QSharedPointer<FileDownloader>(new FileDownloader(url, this));
		connect(mFileDownloader.data(), SIGNAL(downloaded()), this, SLOT(fileDownloaded()), Qt::UniqueConnection);
		qDebug() << "trying to download: " << url;
	}
	else
		mFileDownloader->downloadFile(url);
}
Exemplo n.º 3
0
void FileDownloader::onFileDownloaded(QNetworkReply *reply)
{
    m_downloadInProgress = false;

    QByteArray contents = reply->readAll();
    reply->deleteLater();

    if (!contents.isEmpty())
        emit fileDownloaded(contents);

    emit downloadInProgressChanged(m_downloadInProgress);
}
Exemplo n.º 4
0
void DownloadsManager::executeDownloads(QString token)
{
    numDownloads = downloads.size();
    downloadsDone = 0;
    if (numDownloads==0) {
        numDownloads++;
        emit fileDownloaded();
    }
    else
        for (;!downloads.empty();downloads.pop_back()) {
            qDebug() << downloads.last().second;
            downloadFile(token, downloads.last().first, downloads.last().second);
       }
}
Exemplo n.º 5
0
Arquivo: utils.cpp Projeto: mkiol/Ubi
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();
}
Exemplo n.º 6
0
	void FileSharingWidget::connectFileDownloadSignals(const bool isConnected)
	{
		connectCoreSignal(
			SIGNAL(fileSharingFileDownloaded(qint64, QString, QString)),
			SLOT(fileDownloaded(qint64, QString, QString)),
			isConnected);

		connectCoreSignal(
			SIGNAL(fileSharingFileDownloading(qint64, QString, qint64)),
			SLOT(fileDownloading(qint64, QString, qint64)),
			isConnected);

		connectCoreSignal(
			SIGNAL(fileSharingDownloadError(qint64, QString, qint32)),
			SLOT(fileDownloadError(qint64, QString, qint32)),
			isConnected);

		connectCoreSignal(
			SIGNAL(fileSharingLocalCopyCheckCompleted(qint64, bool, QString)),
			SLOT(fileLocalCopyChecked(qint64, bool, QString)),
			isConnected);
	}