void UpdaterDialog::initUpdate(void)
{
	//Clean up files from previous attempt
	if(!m_binaries.isEmpty())
	{
		cleanFiles();
	}

	//Check binary files
	QString wgetBin, gpgvBin;
	if(!checkBinaries(wgetBin, gpgvBin))
	{
		ui->buttonCancel->setEnabled(true);
		const QString message = QString("%1<br><br><nobr><a href=\"%2\">%3</a></nobr><br>").arg(tr("At least one file required by the web-update tool is missing or corrupted.<br>Please re-install this application and then try again!"), QString::fromLatin1(m_updateUrl), QString::fromLatin1(m_updateUrl).replace("-", "&minus;"));
		if(QMessageBox::critical(this, tr("File Error"), message, tr("Download Latest Version"), tr("Discard")) == 0)
		{
			QDesktopServices::openUrl(QUrl(QString::fromLatin1(m_updateUrl)));
		}
		close(); return;
	}

	//Make sure user does have admin access
	if(!MUtils::OS::user_is_admin())
	{
		qWarning("User is not in the \"admin\" group, cannot update!");
		QString message;
		message += QString("<nobr>%1</nobr><br>").arg(tr("Sorry, but only users in the \"Administrators\" group can install updates."));
		message += QString("<nobr>%1</nobr>").arg(tr("Please start application from an administrator account and try again!"));
		if(QMessageBox::critical(this, this->windowTitle(), message, tr("Discard"), tr("Ignore")) != 1)
		{
			ui->buttonCancel->setEnabled(true);
			close(); return;
		}
	}
	
	//Create and setup thread
	if(!m_thread)
	{
		m_thread.reset(new MUtils::UpdateChecker(m_binaries.value("wget.exe"), m_binaries.value("gpgv.exe"), m_binaries.value("gpgv.gpg"), "Simple x264 Launcher", x264_version_build(), false));
		connect(m_thread.data(), SIGNAL(statusChanged(int)), this, SLOT(threadStatusChanged(int)));
		connect(m_thread.data(), SIGNAL(finished()), this, SLOT(threadFinished()));
		connect(m_thread.data(), SIGNAL(terminated()), this, SLOT(threadFinished()));
		connect(m_thread.data(), SIGNAL(messageLogged(QString)), this, SLOT(threadMessageLogged(QString)));
	}
Exemplo n.º 2
0
void UpdateDialog::showEvent(QShowEvent *event)
{
    QDialog::showEvent(event);

    if(m_firstShow)
    {
        if(!m_thread)
        {
            m_thread = new UpdateCheckThread(m_binaryWGet, m_binaryGnuPG, m_binaryKeys, m_betaUpdates);
            connect(m_thread, SIGNAL(statusChanged(int)), this, SLOT(threadStatusChanged(int)));
            connect(m_thread, SIGNAL(progressChanged(int)), this, SLOT(threadProgressChanged(int)));
            connect(m_thread, SIGNAL(messageLogged(QString)), this, SLOT(threadMessageLogged(QString)));
            connect(m_thread, SIGNAL(finished()), this, SLOT(threadFinished()));
            connect(m_thread, SIGNAL(terminated()), this, SLOT(threadFinished()));
        }

        threadStatusChanged(m_thread->getUpdateStatus());
        ui->labelVersionInstalled->setText(QString("%1 %2 (%3)").arg(tr("Build"), QString::number(lamexp_version_build()), lamexp_version_date().toString(Qt::ISODate)));
        ui->labelVersionLatest->setText(QString("(%1)").arg(tr("Unknown")));

        ui->installButton->setEnabled(false);
        ui->closeButton->setEnabled(false);
        ui->retryButton->setEnabled(false);
        ui->logButton->setEnabled(false);
        ui->retryButton->hide();
        ui->logButton->hide();
        ui->infoLabel->hide();
        ui->hintLabel->hide();
        ui->hintIcon->hide();
        ui->frameAnimation->hide();

        ui->progressBar->setMaximum(m_thread->getMaximumProgress());
        ui->progressBar->setValue(0);

        m_updaterProcess = NULL;

        QTimer::singleShot(0, this, SLOT(updateInit()));
        m_firstShow = false;
    }