2007-07-25 20:21:06 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 by Dominik Riebeling
|
2007-07-26 19:52:08 +00:00
|
|
|
* $Id$
|
2007-07-25 20:21:06 +00:00
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2010-01-20 22:18:36 +00:00
|
|
|
#include "installwindow.h"
|
2010-02-16 18:30:24 +00:00
|
|
|
#include "ui_installwindowfrm.h"
|
2008-05-10 17:53:15 +00:00
|
|
|
#include "rbzip.h"
|
2009-08-10 19:46:51 +00:00
|
|
|
#include "system.h"
|
2009-05-09 16:59:14 +00:00
|
|
|
#include "rbsettings.h"
|
2010-01-24 21:12:11 +00:00
|
|
|
#include "serverinfo.h"
|
|
|
|
#include "systeminfo.h"
|
2009-08-10 19:20:53 +00:00
|
|
|
#include "utils.h"
|
2007-07-25 20:21:06 +00:00
|
|
|
|
2010-01-20 22:18:36 +00:00
|
|
|
InstallWindow::InstallWindow(QWidget *parent) : QDialog(parent)
|
2007-07-25 20:21:06 +00:00
|
|
|
{
|
|
|
|
ui.setupUi(this);
|
|
|
|
|
|
|
|
connect(ui.radioStable, SIGNAL(toggled(bool)), this, SLOT(setDetailsStable(bool)));
|
|
|
|
connect(ui.radioCurrent, SIGNAL(toggled(bool)), this, SLOT(setDetailsCurrent(bool)));
|
|
|
|
connect(ui.radioArchived, SIGNAL(toggled(bool)), this, SLOT(setDetailsArchived(bool)));
|
2009-01-23 22:03:46 +00:00
|
|
|
connect(ui.changeBackup, SIGNAL(pressed()), this, SLOT(changeBackupPath()));
|
|
|
|
connect(ui.backup, SIGNAL(stateChanged(int)), this, SLOT(backupCheckboxChanged(int)));
|
2008-12-19 22:18:07 +00:00
|
|
|
|
2008-05-11 18:22:42 +00:00
|
|
|
//! check if rockbox is already installed
|
2009-08-10 19:20:53 +00:00
|
|
|
RockboxInfo rbinfo(RbSettings::value(RbSettings::Mountpoint).toString());
|
|
|
|
QString version = rbinfo.version();
|
2008-12-19 22:18:07 +00:00
|
|
|
|
2008-05-11 18:22:42 +00:00
|
|
|
if(version != "")
|
|
|
|
{
|
|
|
|
ui.Backupgroup->show();
|
2009-05-09 16:59:14 +00:00
|
|
|
m_backupName = RbSettings::value(RbSettings::Mountpoint).toString();
|
2008-05-12 17:29:03 +00:00
|
|
|
if(!m_backupName.endsWith("/")) m_backupName += "/";
|
|
|
|
m_backupName += ".backup/rockbox-backup-"+version+".zip";
|
2009-01-23 22:03:46 +00:00
|
|
|
// for some reason the label doesn't return its final size yet.
|
|
|
|
// Delay filling ui.backupLocation until the checkbox is changed.
|
2008-05-11 18:22:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui.Backupgroup->hide();
|
2008-12-19 22:18:07 +00:00
|
|
|
}
|
2008-05-11 18:53:24 +00:00
|
|
|
backupCheckboxChanged(Qt::Unchecked);
|
2010-01-20 22:18:36 +00:00
|
|
|
|
|
|
|
|
2010-01-24 21:12:11 +00:00
|
|
|
if(ServerInfo::value(ServerInfo::DailyRevision).toString().isEmpty()) {
|
2010-01-20 22:18:36 +00:00
|
|
|
ui.radioArchived->setEnabled(false);
|
|
|
|
qDebug() << "[Install] no information about archived version available!";
|
|
|
|
}
|
2010-01-24 21:12:11 +00:00
|
|
|
if(ServerInfo::value(ServerInfo::CurReleaseVersion).toString().isEmpty()) {
|
2010-01-20 22:18:36 +00:00
|
|
|
ui.radioStable->setEnabled(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
// try to use the old selection first. If no selection has been made
|
|
|
|
// in the past, use a preselection based on released status.
|
|
|
|
if(RbSettings::value(RbSettings::Build).toString() == "stable"
|
2010-01-24 21:12:11 +00:00
|
|
|
&& !ServerInfo::value(ServerInfo::CurReleaseVersion).toString().isEmpty())
|
2010-01-20 22:18:36 +00:00
|
|
|
ui.radioStable->setChecked(true);
|
|
|
|
else if(RbSettings::value(RbSettings::Build).toString() == "archived")
|
|
|
|
ui.radioArchived->setChecked(true);
|
|
|
|
else if(RbSettings::value(RbSettings::Build).toString() == "current")
|
|
|
|
ui.radioCurrent->setChecked(true);
|
2010-01-24 21:12:11 +00:00
|
|
|
else if(!ServerInfo::value(ServerInfo::CurReleaseVersion).toString().isEmpty()) {
|
2010-01-20 22:18:36 +00:00
|
|
|
ui.radioStable->setChecked(true);
|
|
|
|
ui.radioStable->setEnabled(true);
|
|
|
|
QFont font;
|
|
|
|
font.setBold(true);
|
|
|
|
ui.radioStable->setFont(font);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ui.radioCurrent->setChecked(true);
|
|
|
|
ui.radioStable->setEnabled(false);
|
|
|
|
ui.radioStable->setChecked(false);
|
|
|
|
QFont font;
|
|
|
|
font.setBold(true);
|
|
|
|
ui.radioCurrent->setFont(font);
|
|
|
|
}
|
|
|
|
|
2008-05-11 18:53:24 +00:00
|
|
|
}
|
|
|
|
|
2009-01-23 22:03:46 +00:00
|
|
|
|
2010-01-20 22:18:36 +00:00
|
|
|
void InstallWindow::resizeEvent(QResizeEvent *e)
|
2009-01-23 22:03:46 +00:00
|
|
|
{
|
|
|
|
(void)e;
|
|
|
|
|
|
|
|
// recalculate width of elided text.
|
|
|
|
updateBackupLocation();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-20 22:18:36 +00:00
|
|
|
void InstallWindow::updateBackupLocation(void)
|
2009-01-23 22:03:46 +00:00
|
|
|
{
|
|
|
|
ui.backupLocation->setText(QDir::toNativeSeparators(
|
|
|
|
fontMetrics().elidedText(tr("Backup to %1").arg(m_backupName),
|
|
|
|
Qt::ElideMiddle, ui.backupLocation->size().width())));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-20 22:18:36 +00:00
|
|
|
void InstallWindow::backupCheckboxChanged(int state)
|
2008-05-11 18:53:24 +00:00
|
|
|
{
|
|
|
|
if(state == Qt::Checked)
|
|
|
|
{
|
|
|
|
ui.backupLocation->show();
|
|
|
|
ui.changeBackup->show();
|
2009-01-23 22:03:46 +00:00
|
|
|
// update backup location display.
|
|
|
|
updateBackupLocation();
|
2008-05-11 18:53:24 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui.backupLocation->hide();
|
|
|
|
ui.changeBackup->hide();
|
|
|
|
}
|
2007-07-25 20:21:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-20 22:18:36 +00:00
|
|
|
void InstallWindow::accept()
|
2007-07-25 20:21:06 +00:00
|
|
|
{
|
2007-07-29 18:07:31 +00:00
|
|
|
logger = new ProgressLoggerGui(this);
|
|
|
|
logger->show();
|
2009-05-09 16:59:14 +00:00
|
|
|
QString mountPoint = RbSettings::value(RbSettings::Mountpoint).toString();
|
2009-06-16 18:45:20 +00:00
|
|
|
qDebug() << "[Install] mountpoint:" << RbSettings::value(RbSettings::Mountpoint).toString();
|
2007-07-25 20:21:06 +00:00
|
|
|
// show dialog with error if mount point is wrong
|
2007-08-02 22:27:51 +00:00
|
|
|
if(!QFileInfo(mountPoint).isDir()) {
|
2007-07-31 19:11:44 +00:00
|
|
|
logger->addItem(tr("Mount point is wrong!"),LOGERROR);
|
2009-05-02 18:40:04 +00:00
|
|
|
logger->setFinished();
|
2007-07-25 20:21:06 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-08-26 16:03:56 +00:00
|
|
|
QString myversion;
|
2010-01-24 21:12:11 +00:00
|
|
|
QString buildname = SystemInfo::value(SystemInfo::CurBuildserverModel).toString();
|
2007-07-25 20:21:06 +00:00
|
|
|
if(ui.radioStable->isChecked()) {
|
2010-01-24 21:12:11 +00:00
|
|
|
file = SystemInfo::value(SystemInfo::ReleaseUrl).toString();
|
2009-05-09 16:59:14 +00:00
|
|
|
RbSettings::setValue(RbSettings::Build, "stable");
|
2010-01-24 21:12:11 +00:00
|
|
|
myversion = ServerInfo::value(ServerInfo::CurReleaseVersion).toString();
|
2007-07-25 20:21:06 +00:00
|
|
|
}
|
|
|
|
else if(ui.radioArchived->isChecked()) {
|
2010-01-24 21:12:11 +00:00
|
|
|
file = SystemInfo::value(SystemInfo::DailyUrl).toString();
|
2009-05-09 16:59:14 +00:00
|
|
|
RbSettings::setValue(RbSettings::Build, "archived");
|
2010-02-16 18:30:24 +00:00
|
|
|
myversion = "r" + ServerInfo::value(ServerInfo::DailyRevision).toString()
|
|
|
|
+ "-" + ServerInfo::value(ServerInfo::DailyDate).toString();
|
2007-07-25 20:21:06 +00:00
|
|
|
}
|
|
|
|
else if(ui.radioCurrent->isChecked()) {
|
2010-01-24 21:12:11 +00:00
|
|
|
file = SystemInfo::value(SystemInfo::BleedingUrl).toString();
|
2009-05-09 16:59:14 +00:00
|
|
|
RbSettings::setValue(RbSettings::Build, "current");
|
2010-01-24 21:12:11 +00:00
|
|
|
myversion = "r" + ServerInfo::value(ServerInfo::BleedingRevision).toString();
|
2007-07-25 20:21:06 +00:00
|
|
|
}
|
|
|
|
else {
|
2009-06-16 18:45:20 +00:00
|
|
|
qDebug() << "[Install] no build selected -- this shouldn't happen";
|
2007-07-25 20:21:06 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-08-08 00:02:33 +00:00
|
|
|
file.replace("%MODEL%", buildname);
|
2010-01-24 21:12:11 +00:00
|
|
|
file.replace("%RELVERSION%", ServerInfo::value(ServerInfo::CurReleaseVersion).toString());
|
|
|
|
file.replace("%REVISION%", ServerInfo::value(ServerInfo::DailyRevision).toString());
|
|
|
|
file.replace("%DATE%", ServerInfo::value(ServerInfo::DailyDate).toString());
|
2009-08-08 00:02:33 +00:00
|
|
|
|
2009-05-09 16:59:14 +00:00
|
|
|
RbSettings::sync();
|
2008-10-24 22:31:07 +00:00
|
|
|
|
2009-08-10 19:46:51 +00:00
|
|
|
QString warning = check(false);
|
2008-10-24 22:31:07 +00:00
|
|
|
if(!warning.isEmpty())
|
2008-06-23 20:31:44 +00:00
|
|
|
{
|
2008-10-24 22:31:07 +00:00
|
|
|
if(QMessageBox::warning(this, tr("Really continue?"), warning,
|
|
|
|
QMessageBox::Ok | QMessageBox::Abort, QMessageBox::Abort)
|
|
|
|
== QMessageBox::Abort)
|
|
|
|
{
|
|
|
|
logger->addItem(tr("Aborted!"),LOGERROR);
|
2009-05-02 18:40:04 +00:00
|
|
|
logger->setFinished();
|
2008-10-24 22:31:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-11 18:22:42 +00:00
|
|
|
//! check if we should backup
|
|
|
|
if(ui.backup->isChecked())
|
2008-05-10 17:53:15 +00:00
|
|
|
{
|
2008-05-11 18:22:42 +00:00
|
|
|
logger->addItem(tr("Beginning Backup..."),LOGINFO);
|
2008-10-24 22:31:07 +00:00
|
|
|
|
2008-05-11 18:22:42 +00:00
|
|
|
//! create dir, if it doesnt exist
|
2008-05-12 17:29:03 +00:00
|
|
|
QFileInfo backupFile(m_backupName);
|
2008-05-11 18:22:42 +00:00
|
|
|
if(!QDir(backupFile.path()).exists())
|
|
|
|
{
|
|
|
|
QDir a;
|
|
|
|
a.mkpath(backupFile.path());
|
|
|
|
}
|
2008-10-24 22:31:07 +00:00
|
|
|
|
2008-05-11 18:22:42 +00:00
|
|
|
//! create backup
|
|
|
|
RbZip backup;
|
2008-06-03 20:08:25 +00:00
|
|
|
connect(&backup,SIGNAL(zipProgress(int,int)),logger,SLOT(setProgress(int,int)));
|
2009-04-29 20:58:47 +00:00
|
|
|
if(backup.createZip(m_backupName,
|
2009-05-09 16:59:14 +00:00
|
|
|
RbSettings::value(RbSettings::Mountpoint).toString() + "/.rockbox") == Zip::Ok)
|
2008-05-11 18:22:42 +00:00
|
|
|
{
|
2008-07-25 22:29:59 +00:00
|
|
|
logger->addItem(tr("Backup successful"),LOGOK);
|
2008-05-11 18:22:42 +00:00
|
|
|
}
|
|
|
|
else
|
2008-05-10 17:53:15 +00:00
|
|
|
{
|
2008-05-11 18:22:42 +00:00
|
|
|
logger->addItem(tr("Backup failed!"),LOGERROR);
|
2009-05-02 18:40:04 +00:00
|
|
|
logger->setFinished();
|
2008-05-11 18:22:42 +00:00
|
|
|
return;
|
2008-05-10 17:53:15 +00:00
|
|
|
}
|
|
|
|
}
|
2008-10-24 22:31:07 +00:00
|
|
|
|
2008-05-10 17:53:15 +00:00
|
|
|
//! install build
|
2007-07-27 17:42:49 +00:00
|
|
|
installer = new ZipInstaller(this);
|
|
|
|
installer->setUrl(file);
|
2007-08-28 13:07:25 +00:00
|
|
|
installer->setLogSection("Rockbox (Base)");
|
2009-05-09 16:59:14 +00:00
|
|
|
if(!RbSettings::value(RbSettings::CacheDisabled).toBool()
|
2007-08-27 18:05:16 +00:00
|
|
|
&& !ui.checkBoxCache->isChecked())
|
2008-05-11 20:20:19 +00:00
|
|
|
{
|
|
|
|
installer->setCache(true);
|
|
|
|
}
|
2007-08-26 16:03:56 +00:00
|
|
|
installer->setLogVersion(myversion);
|
2007-07-27 17:42:49 +00:00
|
|
|
installer->setMountPoint(mountPoint);
|
2008-12-19 22:18:07 +00:00
|
|
|
|
2007-08-02 22:27:51 +00:00
|
|
|
connect(installer, SIGNAL(done(bool)), this, SLOT(done(bool)));
|
2008-12-19 22:18:07 +00:00
|
|
|
|
2009-05-02 18:50:31 +00:00
|
|
|
connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
|
|
|
|
connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
|
|
|
|
connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
|
|
|
|
connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
|
|
|
|
installer->install();
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2007-07-25 20:21:06 +00:00
|
|
|
}
|
|
|
|
|
2010-01-20 22:18:36 +00:00
|
|
|
void InstallWindow::changeBackupPath()
|
2008-05-11 18:22:42 +00:00
|
|
|
{
|
2009-01-23 22:03:46 +00:00
|
|
|
QString backupString = QFileDialog::getSaveFileName(this,
|
|
|
|
tr("Select Backup Filename"), m_backupName, "*.zip");
|
2008-05-12 17:29:03 +00:00
|
|
|
// only update if a filename was entered, ignore if cancelled
|
|
|
|
if(!backupString.isEmpty()) {
|
|
|
|
m_backupName = backupString;
|
2009-01-23 22:03:46 +00:00
|
|
|
updateBackupLocation();
|
2008-05-12 17:29:03 +00:00
|
|
|
}
|
2008-05-11 18:22:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-07-29 18:07:31 +00:00
|
|
|
// Zip installer has finished
|
2010-01-20 22:18:36 +00:00
|
|
|
void InstallWindow::done(bool error)
|
2007-07-25 20:21:06 +00:00
|
|
|
{
|
2009-06-16 18:45:20 +00:00
|
|
|
qDebug() << "[Install] done, error:" << error;
|
2007-07-25 20:21:06 +00:00
|
|
|
|
2007-07-26 21:04:55 +00:00
|
|
|
if(error)
|
|
|
|
{
|
2009-05-02 18:40:04 +00:00
|
|
|
logger->setFinished();
|
2007-07-25 20:21:06 +00:00
|
|
|
return;
|
|
|
|
}
|
2007-07-29 17:55:46 +00:00
|
|
|
|
2007-07-29 18:07:31 +00:00
|
|
|
// no error, close the window, when the logger is closed
|
2007-08-30 19:08:25 +00:00
|
|
|
connect(logger,SIGNAL(closed()),this,SLOT(close()));
|
|
|
|
// add platform info to log file for later detection
|
2009-05-09 16:59:14 +00:00
|
|
|
QSettings installlog(RbSettings::value(RbSettings::Mountpoint).toString()
|
2007-08-30 19:08:25 +00:00
|
|
|
+ "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
|
2009-05-09 16:59:14 +00:00
|
|
|
installlog.setValue("platform", RbSettings::value(RbSettings::Platform).toString());
|
2007-08-30 19:08:25 +00:00
|
|
|
installlog.sync();
|
2007-07-25 20:21:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-20 22:18:36 +00:00
|
|
|
void InstallWindow::setDetailsCurrent(bool show)
|
2007-07-25 20:21:06 +00:00
|
|
|
{
|
|
|
|
if(show) {
|
|
|
|
ui.labelDetails->setText(tr("This is the absolute up to the minute "
|
|
|
|
"Rockbox built. A current build will get updated every time "
|
2007-08-26 16:03:56 +00:00
|
|
|
"a change is made. Latest version is r%1 (%2).")
|
2010-02-16 18:30:24 +00:00
|
|
|
.arg(ServerInfo::value(ServerInfo::BleedingRevision).toString(),
|
|
|
|
ServerInfo::value(ServerInfo::BleedingDate).toString()));
|
2010-01-24 21:12:11 +00:00
|
|
|
if(ServerInfo::value(ServerInfo::CurReleaseVersion).toString().isEmpty())
|
2009-01-25 18:43:01 +00:00
|
|
|
ui.labelNote->setText(tr("<b>This is the recommended version.</b>"));
|
2009-04-10 15:11:53 +00:00
|
|
|
else
|
|
|
|
ui.labelNote->setText("");
|
2007-07-25 20:21:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-20 22:18:36 +00:00
|
|
|
void InstallWindow::setDetailsStable(bool show)
|
2007-07-25 20:21:06 +00:00
|
|
|
{
|
|
|
|
if(show) {
|
|
|
|
ui.labelDetails->setText(
|
|
|
|
tr("This is the last released version of Rockbox."));
|
|
|
|
|
2010-01-24 21:12:11 +00:00
|
|
|
if(!ServerInfo::value(ServerInfo::CurReleaseVersion).toString().isEmpty())
|
2009-04-10 15:11:53 +00:00
|
|
|
ui.labelNote->setText(tr("<b>Note:</b> "
|
2007-07-25 20:21:06 +00:00
|
|
|
"The lastest released version is %1. "
|
2007-08-26 16:03:56 +00:00
|
|
|
"<b>This is the recommended version.</b>")
|
2010-01-24 21:12:11 +00:00
|
|
|
.arg(ServerInfo::value(ServerInfo::CurReleaseVersion).toString()));
|
2007-07-25 20:21:06 +00:00
|
|
|
else ui.labelNote->setText("");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-20 22:18:36 +00:00
|
|
|
void InstallWindow::setDetailsArchived(bool show)
|
2007-07-25 20:21:06 +00:00
|
|
|
{
|
|
|
|
if(show) {
|
|
|
|
ui.labelDetails->setText(tr("These are automatically built each day "
|
|
|
|
"from the current development source code. This generally has more "
|
2007-10-19 22:49:06 +00:00
|
|
|
"features than the last stable release but may be much less stable. "
|
2007-07-25 20:21:06 +00:00
|
|
|
"Features may change regularly."));
|
2007-08-26 16:03:56 +00:00
|
|
|
ui.labelNote->setText(tr("<b>Note:</b> archived version is r%1 (%2).")
|
2010-02-16 18:30:24 +00:00
|
|
|
.arg(ServerInfo::value(ServerInfo::DailyRevision).toString(),
|
|
|
|
ServerInfo::value(ServerInfo::DailyDate).toString()));
|
2007-07-25 20:21:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|