Esempio n. 1
0
Updater::Updater( QWidget *parent ) :
    QDialog( parent ),
    net( this ),
    busy( false )
{
    setWindowTitle( tr( "Aktualizacje programu QMPlay2" ) );
    infoFile.setFileName( QDir::tempPath() + "/QMPlay2_download_info." + QString::number( qrand() ) );
    updateFile.setFileName( QMPlay2Core.getSettingsDir() + "QMPlay2Installer" );
#ifdef Q_OS_WIN
    updateFile.setFileName( updateFile.fileName() + ".exe" );
#endif

    infoL = new QLabel( windowTitle() );
    progressB = new QProgressBar;
    downloadUpdateB = new QPushButton( tr( "Pobierz aktualizacje" ) );
    installB = new QPushButton( tr( "Zastosuj aktualizację" ) );
    connect( downloadUpdateB, SIGNAL( clicked() ), this, SLOT( downloadUpdate() ) );
    connect( installB, SIGNAL( clicked() ), this, SLOT( applyUpdate() ) );

    QVBoxLayout *layout = new QVBoxLayout( this );
    layout->setMargin( 2 );
    layout->addWidget( infoL );
    layout->addWidget( downloadUpdateB );
    layout->addWidget( progressB );
    layout->addWidget( installB );

    progressB->hide();
    installB->hide();

    resize( 350, 0 );
}
Esempio n. 2
0
void UpdateDialog::accept()
{
	#if defined(Q_OS_WIN)
		downloadUpdate();
	#else
		QDesktopServices::openUrl(m_updater.latestUrl());
		close();
	#endif
}
Esempio n. 3
0
void AutoUpdater::checkUpdatesAsyncInteractiveWorker()
{
    if (!isUpdateAvailable())
        return;

    if (Widget::getInstance()->askMsgboxQuestion(QObject::tr("Update", "The title of a message box"),
        QObject::tr("An update is available, do you want to download it now?\nIt will be installed when qTox restarts.")))
    {
        downloadUpdate();
    }
}
Esempio n. 4
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();
}
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();
}
Esempio n. 6
0
void UpdateWindow::resolveUpdate()
{
    static QString updatesFile = "_updates.xml";
    QDomDocument doc(updatesFile);

    QFile file(updatesFile);
    if (!file.open(QIODevice::ReadOnly))
    {
        QMessageBox::critical(this, tr("Error"), tr("Can't open file %1").arg(updatesFile));
        return;
    }

    if (!doc.setContent(&file))
    {
        file.close();
        QMessageBox::critical(this, tr("Error"), tr("Can't parse file %1").arg(updatesFile));
        return;
    }
    file.close();

    QDomElement root = doc.documentElement();

    if (root.tagName() != "updates")
    {
        QMessageBox::critical(this, tr("Error"), tr("File %1 is invalid").arg(updatesFile));
        return;
    }

    // iterate all available updates and find for current version
    QDomElement update = root.firstChildElement("update");
    while (!update.isNull())
    {
        if (update.attribute("from") == mCurrentVersion)
        {
            mUpdatePath = update.firstChild().nodeValue();
            break;
        }

        update = update.nextSiblingElement("update");
    }

    // start downloading of update
    if (mUpdatePath.isEmpty())
    {
        QMessageBox::critical(this, tr("Error"), tr("There are no suitable update for version %1").arg(mCurrentVersion));
        return;
    }

    downloadUpdate();
}
Esempio n. 7
0
void AutoUpdater::checkUpdatesAsyncInteractiveWorker()
{
    if (!isUpdateAvailable())
        return;

    // If there's already an update dir, resume updating, otherwise ask the user
    QString updateDirStr = Settings::getInstance().getSettingsDirPath() + "/update/";
    QDir updateDir(updateDirStr);



    if (updateDir.exists() && QFile(updateDirStr+"flist").exists())
    {
        setProgressVersion(getUpdateVersion().versionString);
        downloadUpdate();
        return;
    }

    VersionInfo newVersion = getUpdateVersion();
    QString contentText = QObject::tr("An update is available, do you want to download it now?\n"
                                      "It will be installed when qTox restarts.");
    if (!newVersion.versionString.isEmpty())
        contentText += "\n\n" + QObject::tr("Version %1, %2").arg(newVersion.versionString,
                                QDateTime::fromMSecsSinceEpoch(newVersion.timestamp*1000).toString());


    if (abortFlag)
        return;

    if (GUI::askQuestion(QObject::tr("Update", "The title of a message box"),
                              contentText, true, false))
    {
        setProgressVersion(newVersion.versionString);
        GUI::showUpdateDownloadProgress();
        downloadUpdate();
    }
}
Esempio n. 8
0
void AutoUpdater::checkUpdatesAsyncInteractiveWorker()
{
    if (!isUpdateAvailable())
        return;

    // If there's already an update dir, resume updating, otherwise ask the user
    QString updateDirStr = Settings::getInstance().getSettingsDirPath() + "/update/";
    QDir updateDir(updateDirStr);

    if ((updateDir.exists() && QFile(updateDirStr+"flist").exists())
            || GUI::askQuestion(QObject::tr("Update", "The title of a message box"),
        QObject::tr("An update is available, do you want to download it now?\nIt will be installed when qTox restarts."), true, false))
    {
        downloadUpdate();
    }
}
Esempio n. 9
0
void DlgUpdate::finishedUpdateCheck(bool needToUpdate, bool isCompatible, Release *release) {

    QString publishDate, versionName;

    //Update the UI to say we've finished
    progress->setMaximum(100);
    setLabel(tr("Finished checking for updates"));

    //If there are no available builds, then they can't auto update.
    enableUpdateButton(isCompatible);

    //Give the user the appropriate message
    if (!needToUpdate) {
        //If there's no need to update, tell them that. However we still allow them to run the
        //downloader themselves if there's a compatible build
        QMessageBox::information(this, tr("No Update Available"),
                 tr("Cockatrice is up to date!") + "<br><br>"
                 + tr("You are already running the latest version available in the chosen release channel.") + "<br>"
                 + "<b>" + tr("Current version") + QString(":</b> %1<br>").arg(VERSION_STRING)
                 + "<b>" + tr("Selected release channel") + QString(":</b> %1").arg(tr(settingsCache->getUpdateReleaseChannel()->getName().toUtf8())));
        return;
    }

    publishDate = release->getPublishDate().toString(Qt::DefaultLocaleLongDate);
    if (isCompatible) {
        //If there is an update, save its URL and work out its name
        updateUrl = release->getDownloadUrl();

        int reply;
        reply = QMessageBox::question(this, tr("Update Available"),
            tr("A new version of Cockatrice is available!") + "<br><br>"
            + "<b>" + tr("New version") + QString(":</b> %1<br>").arg(release->getName())
            + "<b>" + tr("Released") + QString(":</b> %1 <a href=\"%2\">(").arg(publishDate, release->getDescriptionUrl()) + tr("Changelog") + ")</a><br><br>"
            + tr("Do you want to update now?"),
            QMessageBox::Yes | QMessageBox::No);

        if (reply == QMessageBox::Yes)
            downloadUpdate();
    } else {
        QMessageBox::information(this, tr("Update Available"),
            tr("A new version of Cockatrice is available!") + "<br><br>"
            + "<b>" + tr("New version") + QString(":</b> %1<br>").arg(release->getName())
            + "<b>" + tr("Released") + QString(":</b> %1 <a href=\"%2\">(").arg(publishDate, release->getDescriptionUrl()) + tr("Changelog") + ")</a><br><br>"
            + tr("Unfortunately there are no download packages available for your operating system. \nYou may have to build from source yourself.") + "<br><br>"
            + tr("Please check the download page manually and visit the wiki for instructions on compiling."));
    }
}
Esempio n. 10
0
void DlgUpdate::finishedUpdateCheck(bool needToUpdate, bool isCompatible, QVariantMap *build) {

    QString commitHash, commitDate;

    //Update the UI to say we've finished
    progress->setMaximum(100);
    setLabel(tr("Finished checking for updates."));

    //If there are no available builds, then they can't auto update.
    enableUpdateButton(isCompatible);

    //If there is an update, save its URL and work out its name
    if (isCompatible) {
        QString endUrl = (*build)["path"].toString();
        updateUrl = API_DOWNLOAD_BASE_URL + endUrl;
        commitHash = (*build)["sha1"].toString().left(SHORT_SHA1_HASH_LENGTH);
        commitDate = (*build)["created"].toString().remove(DATE_LENGTH, MAX_DATE_LENGTH);
    }

    //Give the user the appropriate message
    if (needToUpdate) {
        if (isCompatible) {

            QMessageBox::StandardButton reply;
            reply = QMessageBox::question(this, "Update Available",
                                          "A new build (commit " + commitHash + ") from " + commitDate +
                                          " is available. Download?",
                                          QMessageBox::Yes | QMessageBox::No);
            if (reply == QMessageBox::Yes)
                downloadUpdate();
        }
        else
        {
            QMessageBox::information(this, tr("Cockatrice Update"),
                                     tr("Your version of Cockatrice is out of date, but there are no packages"
                                                " available for your operating system. You may have to use a developer build or build from source"
                                                " yourself. Please visit the download page."));
        }
    }
    else {
        //If there's no need to update, tell them that. However we still allow them to run the
        //downloader themselves if there's a compatible build
        QMessageBox::information(this, tr("Cockatrice Update"), tr("Your version of Cockatrice is up to date."));
    }

}
Esempio n. 11
0
void Updater::processUpdateReading()
{
    m_progressTimer.stop();// Those avoid the checkupdateprogress to be shown if we're reading the update really fast
    m_checkUpdateProgressDialog->close();//  ^

    if(m_netReply->bytesAvailable() != 0)
    {
        m_newAppVersion = m_netReply->readAll();
        if(m_newAppVersion != m_currentAppVersion) //Needs to update
        {
            QMessageBox box (nullptr);
            box.setWindowTitle(tr("Mise à jour disponible ! "));
            box.setText(tr("La mise à jour %1 pour %2 est disponible.\n"
                           "Version actuelle : %3\n"
                           "Voulez-vous télécharger la mise à jour ?")
                        .arg(m_newAppVersion)
                        .arg(m_appName)
                        .arg(m_currentAppVersion));
            box.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
            box.setDefaultButton(QMessageBox::No);
            box.setButtonText(QMessageBox::No, tr("Pas maintenant"));
            box.setButtonText(QMessageBox::Yes, tr("Oui"));
            int reply = box.exec();
            if (reply == QMessageBox::Yes)
            {
                //Reporting back from the original app process that we're downloading, so it closes itself
                std::cout << "downloading" << std::endl;
                downloadUpdate();
            }
            else
                exit(0);
        }
        else //Up to date, we're good to exit now
        {
            if(m_showIfNoUpdate)
                QMessageBox::information(nullptr, tr("Aucune mise à jour disponible"),
                                         tr("Aucune mise à jour n'est disponible pour %1").arg(m_appName));
            exit(0);
        }

    }
    else
        qDebug () << "no reply";
}
void DownloadUpdateTask::doTask()
{
	try
	{
		downloadUpdate();
		m_bCompleted = true;
	}
	catch (gcException &except)
	{
		Warning(gcString("Failed to download " PRODUCT_NAME " Update: {0}.\n", except));
	}

	if (!m_bStopped)
	{
		uint32 prog = 0;
		onDownloadProgressEvent(prog);		
	}

	onDownloadCompleteEvent.reset();
	onDownloadStartEvent.reset();
}
Esempio n. 13
0
void DlgUpdate::finishedUpdateCheck(bool needToUpdate, bool isCompatible, Release *release) {

    QString publishDate, versionName;

    //Update the UI to say we've finished
    progress->setMaximum(100);
    setLabel(tr("Finished checking for updates."));

    //If there are no available builds, then they can't auto update.
    enableUpdateButton(isCompatible);

    //Give the user the appropriate message
    if (!needToUpdate) {
        //If there's no need to update, tell them that. However we still allow them to run the
        //downloader themselves if there's a compatible build
        QMessageBox::information(this, tr("Cockatrice Update"), tr("Your version of Cockatrice is up to date."));
    }

    if (isCompatible) {
        //If there is an update, save its URL and work out its name
        updateUrl = release->getDownloadUrl();
        publishDate = release->getPublishDate().toString(Qt::DefaultLocaleLongDate);

        QMessageBox::StandardButton reply;
        reply = QMessageBox::question(this, "Update Available",
            tr("A new version is available:<br/>%1<br/>published on %2 ."
            "<br/>More informations are available on the <a href=\"%3\">release changelog</a>"
            "<br/>Do you want to update now?").arg(release->getName(), publishDate, release->getDescriptionUrl()),
            QMessageBox::Yes | QMessageBox::No);

        if (reply == QMessageBox::Yes)
            downloadUpdate();
    } else {
        QMessageBox::information(this, tr("Cockatrice Update"),
            tr("A new version is available:<br/>%1<br/>published on %2 ."
            "<br/>More informations are available on the <a href=\"%3\">release changelog</a>"
            "<br/>Unfortunately there are no packages available for your operating system. "
            "You may have to use a developer build or build from source yourself. Please visit the download page.").arg(release->getName(), publishDate, release->getDescriptionUrl()));
    }
}
Esempio n. 14
0
void Updater::run() {
    downloadUpdate();
    executeUpdate();

    emit finishedSuccesufull(updateInfo);
}