QString WebUpdater::downloadUpdate_p (const ProductVersion &version, const QString &dir)
{
	outputFile_.setFileName (outputFileName (dir, version.productUrl ()));

	if (outputFile_.exists()
			&& isFileCorrect (outputFile_.fileName(), version.productMd5sum())) {
		qDebug () << "File alredy downloaded";
		emit downloadFinished ();
		return outputFile_.fileName();
	}

	if (!outputFile_.open (QIODevice::WriteOnly | QIODevice::Truncate)) {
		qDebug () << "Error open file " << outputFile_.fileName ();
		return outputFile_.fileName();
	}

	qDebug () << version.productUrl () << outputFile_.fileName();

	const QUrl url (version.productUrl ());

	const QNetworkRequest request (url);

	QNetworkReply *reply_ = manager_->get (request);
	replyList.push_back (reply_);

	connect (reply_, SIGNAL (downloadProgress (qint64, qint64)),
			 this, SIGNAL (downloadProgress (qint64, qint64)));
	connect (reply_, SIGNAL (readyRead()),
			 this, SLOT (readyRead()));
	connect (reply_, SIGNAL (finished()),
			 this, SLOT (updateDownloaded()));
	connect (reply_, SIGNAL (finished()),
			 this, SLOT (replyFinished()));

	return outputFile_.fileName();
}
Example #2
0
void Commands::CommandManager::connectEntitiesSignalsSlots() const {
    if (m_SecretsManager != NULL && m_UploadInfoRepository != NULL) {
        QObject::connect(m_SecretsManager, SIGNAL(beforeMasterPasswordChange(QString, QString)),
                         m_UploadInfoRepository, SLOT(onBeforeMasterPasswordChanged(QString, QString)));

        QObject::connect(m_SecretsManager, SIGNAL(afterMasterPasswordReset()),
                         m_UploadInfoRepository, SLOT(onAfterMasterPasswordReset()));
    }

    if (m_ArtItemsModel != NULL && m_FilteredItemsModel != NULL) {
        QObject::connect(m_ArtItemsModel, SIGNAL(selectedArtworksRemoved(int)),
                         m_FilteredItemsModel, SLOT(onSelectedArtworksRemoved(int)));
    }

    if (m_SettingsModel != NULL && m_TelemetryService != NULL) {
        QObject::connect(m_SettingsModel, SIGNAL(userStatisticsChanged(bool)),
                         m_TelemetryService, SLOT(changeReporting(bool)));
    }

    if (m_SpellCheckerService != NULL && m_FilteredItemsModel != NULL) {
        QObject::connect(m_SpellCheckerService, SIGNAL(serviceAvailable(bool)),
                         m_FilteredItemsModel, SLOT(onSpellCheckerAvailable(bool)));
    }

    if (m_ArtworksRepository != NULL && m_ArtItemsModel != NULL) {
        QObject::connect(m_ArtworksRepository, SIGNAL(filesUnavailable()),
                         m_ArtItemsModel, SLOT(onFilesUnavailableHandler()));
    }

    if (m_ArtItemsModel != NULL && m_UndoRedoManager != NULL) {
        QObject::connect(m_UndoRedoManager, SIGNAL(undoStackEmpty()),
                         m_ArtItemsModel, SLOT(onUndoStackEmpty()));
    }

    if (m_LanguagesModel != NULL && m_KeywordsSuggestor != NULL) {
        QObject::connect(m_LanguagesModel, SIGNAL(languageChanged()),
                         m_KeywordsSuggestor, SLOT(onLanguageChanged()));
    }

    if (m_SpellCheckerService != NULL && m_ArtItemsModel != NULL) {
        QObject::connect(m_SpellCheckerService, SIGNAL(userDictUpdate(QStringList)),
                         m_ArtItemsModel, SLOT(userDictUpdateHandler(QStringList)));
        QObject::connect(m_SpellCheckerService, SIGNAL(userDictCleared()),
                         m_ArtItemsModel, SLOT(userDictClearedHandler()));
    }

    if (m_SpellCheckerService != NULL && m_CombinedArtworksModel != NULL) {
        QObject::connect(m_SpellCheckerService, SIGNAL(userDictUpdate(QStringList)),
                         m_CombinedArtworksModel, SLOT(userDictUpdateHandler(QStringList)));
        QObject::connect(m_SpellCheckerService, SIGNAL(userDictCleared()),
                         m_CombinedArtworksModel, SLOT(userDictClearedHandler()));
    }

    if (m_HelpersQmlWrapper != NULL && m_UpdateService != NULL) {
        QObject::connect(m_UpdateService, SIGNAL(updateAvailable(QString)),
                         m_HelpersQmlWrapper, SIGNAL(updateAvailable(QString)));

        QObject::connect(m_UpdateService, SIGNAL(updateDownloaded(QString)),
                         m_HelpersQmlWrapper, SLOT(updateIsDownloaded(QString)));
    }
}
Example #3
0
    //Create a new downloader
    Downloader *downloader = new Downloader(this);
    downloader->setLocalFileName(fileName);
    downloader->setLocalDirectory(DownDir);
    downloader->setThreadNum(threadNUM);

    // Setup the downlader connections
    connect(downloader, SIGNAL(stateChanged(QString)),
            this, SLOT(updateState(QString)));
    connect(downloader, SIGNAL(set_GuiProgressBarValue(int)),
            this, SLOT(updateProgress(int)));
    connect(downloader, SIGNAL(set_GuiLabelSpeed(QString)),
            this, SLOT(updateDownloadRate(QString)));
    connect(downloader, SIGNAL(set_GuiLabelDownloaded(QString)),
            this, SLOT(updateDownloaded(QString)));
    connect(downloader, SIGNAL(set_GuiLabelRemainingTime(QString)),
            this, SLOT(updateRemainingTime(QString)));


    // Add the downloader to the list of downloading jobs.
    Job job;
    job.downloader = downloader;
    job.fileName = fileName;
    job.destinationDir = DownDir;
    jobs << job;

    // Create and add a row in the job view for this download.
    QTreeWidgetItem *item = new QTreeWidgetItem(jobView);

    QString baseFileName = QFileInfo(fileName).baseName();