UpdateInfoPlugin::~UpdateInfoPlugin()
{
    stopCheckForUpdates();
    if (!d->m_maintenanceTool.isEmpty())
        saveSettings();

    delete d;
}
void UpdateInfoPlugin::startCheckForUpdates()
{
    stopCheckForUpdates();

    d->m_checkUpdatesCommand = new ShellCommand(QString(), QProcessEnvironment());
    connect(d->m_checkUpdatesCommand, &ShellCommand::stdOutText, this, &UpdateInfoPlugin::collectCheckForUpdatesOutput);
    connect(d->m_checkUpdatesCommand, &ShellCommand::finished, this, &UpdateInfoPlugin::checkForUpdatesFinished);
    d->m_checkUpdatesCommand->addJob(Utils::FileName(QFileInfo(d->m_maintenanceTool)), QStringList(QLatin1String("--checkupdates")));
    d->m_checkUpdatesCommand->execute();
    emit checkForUpdatesRunningChanged(true);
}
Esempio n. 3
0
void UpdateInfoPlugin::startCheckForUpdates()
{
    stopCheckForUpdates();

    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    env.insert(QLatin1String("QT_LOGGING_RULES"), QLatin1String("*=false"));
    d->m_checkUpdatesCommand = new ShellCommand(QString(), env);
    connect(d->m_checkUpdatesCommand, &ShellCommand::stdOutText, this, &UpdateInfoPlugin::collectCheckForUpdatesOutput);
    connect(d->m_checkUpdatesCommand, &ShellCommand::finished, this, &UpdateInfoPlugin::checkForUpdatesFinished);
    d->m_checkUpdatesCommand->addJob(Utils::FileName(QFileInfo(d->m_maintenanceTool)), QStringList(QLatin1String("--checkupdates")),
                                     /*workingDirectory=*/QString(),
                                     [](int /*exitCode*/) { return Utils::SynchronousProcessResponse::Finished; });
    d->m_checkUpdatesCommand->execute();
    emit checkForUpdatesRunningChanged(true);
}
void UpdateInfoPlugin::checkForUpdatesFinished()
{
    setLastCheckDate(QDate::currentDate());

    QDomDocument document;
    document.setContent(d->m_collectedOutput);

    stopCheckForUpdates();

    if (!document.isNull() && document.firstChildElement().hasChildNodes()) {
        emit newUpdatesAvailable(true);
        if (QMessageBox::question(0, tr("Updater"),
                                  tr("New updates are available. Do you want to start update?"))
                == QMessageBox::Yes)
            startUpdater();
    } else {
        emit newUpdatesAvailable(false);
    }
}