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.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "install.h"
|
|
|
|
#include "ui_installfrm.h"
|
2008-05-10 17:53:15 +00:00
|
|
|
#include "rbzip.h"
|
2008-05-11 18:22:42 +00:00
|
|
|
#include "utils.h"
|
2007-07-25 20:21:06 +00:00
|
|
|
|
2008-05-11 18:22:42 +00:00
|
|
|
Install::Install(RbSettings *sett,QWidget *parent) : QDialog(parent)
|
2007-07-25 20:21:06 +00:00
|
|
|
{
|
2008-05-11 18:22:42 +00:00
|
|
|
settings = sett;
|
2007-07-25 20:21:06 +00:00
|
|
|
ui.setupUi(this);
|
|
|
|
|
|
|
|
connect(ui.radioCurrent, SIGNAL(toggled(bool)), this, SLOT(setCached(bool)));
|
|
|
|
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)));
|
2008-05-11 18:22:42 +00:00
|
|
|
connect(ui.changeBackup,SIGNAL(pressed()),this,SLOT(changeBackupPath()));
|
2008-05-11 18:53:24 +00:00
|
|
|
connect(ui.backup,SIGNAL(stateChanged(int)),this,SLOT(backupCheckboxChanged(int)));
|
2008-05-11 18:22:42 +00:00
|
|
|
|
|
|
|
//! check if rockbox is already installed
|
|
|
|
QString version = installedVersion(settings->mountpoint());
|
|
|
|
|
|
|
|
if(version != "")
|
|
|
|
{
|
|
|
|
ui.Backupgroup->show();
|
2008-05-12 17:29:03 +00:00
|
|
|
m_backupName = settings->mountpoint();
|
|
|
|
if(!m_backupName.endsWith("/")) m_backupName += "/";
|
|
|
|
m_backupName += ".backup/rockbox-backup-"+version+".zip";
|
|
|
|
ui.backupLocation->setText(QDir::toNativeSeparators(fontMetrics().elidedText(m_backupName,Qt::ElideMiddle,200)));
|
2008-05-11 18:22:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui.Backupgroup->hide();
|
|
|
|
}
|
2008-05-11 18:53:24 +00:00
|
|
|
backupCheckboxChanged(Qt::Unchecked);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Install::backupCheckboxChanged(int state)
|
|
|
|
{
|
|
|
|
if(state == Qt::Checked)
|
|
|
|
{
|
|
|
|
ui.backupLabel->show();
|
|
|
|
ui.backupLocation->show();
|
|
|
|
ui.changeBackup->show();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui.backupLabel->hide();
|
|
|
|
ui.backupLocation->hide();
|
|
|
|
ui.changeBackup->hide();
|
|
|
|
}
|
2007-07-25 20:21:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Install::setCached(bool cache)
|
|
|
|
{
|
|
|
|
ui.checkBoxCache->setEnabled(!cache);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Install::accept()
|
|
|
|
{
|
2007-07-29 18:07:31 +00:00
|
|
|
logger = new ProgressLoggerGui(this);
|
|
|
|
logger->show();
|
2008-01-25 00:12:25 +00:00
|
|
|
QString mountPoint = settings->mountpoint();
|
|
|
|
qDebug() << "mountpoint:" << settings->mountpoint();
|
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);
|
2007-07-29 18:07:31 +00:00
|
|
|
logger->abort();
|
2007-07-25 20:21:06 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-08-26 16:03:56 +00:00
|
|
|
QString myversion;
|
2008-02-13 18:25:01 +00:00
|
|
|
QString buildname = settings->curPlatformName();
|
2007-07-25 20:21:06 +00:00
|
|
|
if(ui.radioStable->isChecked()) {
|
2007-08-26 11:34:32 +00:00
|
|
|
file = QString("%1/rockbox-%2-%3.zip")
|
2008-01-25 00:12:25 +00:00
|
|
|
.arg(settings->downloadUrl(),
|
|
|
|
settings->lastRelease(), buildname);
|
2007-08-26 11:34:32 +00:00
|
|
|
fileName = QString("rockbox-%1-%2.zip")
|
2008-01-25 00:12:25 +00:00
|
|
|
.arg(settings->lastRelease(), buildname);
|
|
|
|
settings->setBuild("stable");
|
2007-08-26 16:03:56 +00:00
|
|
|
myversion = version.value("rel_rev");
|
2007-07-25 20:21:06 +00:00
|
|
|
}
|
|
|
|
else if(ui.radioArchived->isChecked()) {
|
|
|
|
file = QString("%1%2/rockbox-%3-%4.zip")
|
2008-01-25 00:12:25 +00:00
|
|
|
.arg(settings->dailyUrl(),
|
2007-08-30 19:20:10 +00:00
|
|
|
buildname, buildname, version.value("arch_date"));
|
2007-07-25 20:21:06 +00:00
|
|
|
fileName = QString("rockbox-%1-%2.zip")
|
2007-08-30 19:20:10 +00:00
|
|
|
.arg(buildname, version.value("arch_date"));
|
2008-01-25 00:12:25 +00:00
|
|
|
settings->setBuild("archived");
|
2007-08-26 16:03:56 +00:00
|
|
|
myversion = "r" + version.value("arch_rev") + "-" + version.value("arch_date");
|
2007-07-25 20:21:06 +00:00
|
|
|
}
|
|
|
|
else if(ui.radioCurrent->isChecked()) {
|
|
|
|
file = QString("%1%2/rockbox.zip")
|
2008-01-25 00:12:25 +00:00
|
|
|
.arg(settings->bleedingUrl(), buildname);
|
2007-07-25 20:21:06 +00:00
|
|
|
fileName = QString("rockbox.zip");
|
2008-01-25 00:12:25 +00:00
|
|
|
settings->setBuild("current");
|
2007-08-26 16:03:56 +00:00
|
|
|
myversion = "r" + version.value("bleed_rev");
|
2007-07-25 20:21:06 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
qDebug() << "no build selected -- this shouldn't happen";
|
|
|
|
return;
|
|
|
|
}
|
2008-01-25 00:12:25 +00:00
|
|
|
settings->sync();
|
2008-05-10 17:53:15 +00:00
|
|
|
|
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);
|
|
|
|
|
|
|
|
//! 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());
|
|
|
|
}
|
|
|
|
|
|
|
|
//! create backup
|
|
|
|
RbZip backup;
|
|
|
|
connect(&backup,SIGNAL(zipProgress(int,int)),this,SLOT(updateDataReadProgress(int,int)));
|
2008-05-12 17:29:03 +00:00
|
|
|
if(backup.createZip(m_backupName,settings->mountpoint() + "/.rockbox") == Zip::Ok)
|
2008-05-11 18:22:42 +00:00
|
|
|
{
|
|
|
|
logger->addItem(tr("Backup successfull"),LOGOK);
|
|
|
|
}
|
|
|
|
else
|
2008-05-10 17:53:15 +00:00
|
|
|
{
|
2008-05-11 18:22:42 +00:00
|
|
|
logger->addItem(tr("Backup failed!"),LOGERROR);
|
|
|
|
logger->abort();
|
|
|
|
return;
|
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)");
|
2008-01-25 00:12:25 +00:00
|
|
|
if(!settings->cacheDisabled()
|
2007-08-27 18:05:16 +00:00
|
|
|
&& !ui.radioCurrent->isChecked()
|
|
|
|
&& !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-04-06 19:50:38 +00:00
|
|
|
|
2007-08-02 22:27:51 +00:00
|
|
|
connect(installer, SIGNAL(done(bool)), this, SLOT(done(bool)));
|
2008-04-06 19:50:38 +00:00
|
|
|
|
|
|
|
installer->install(logger);
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2007-07-25 20:21:06 +00:00
|
|
|
}
|
|
|
|
|
2008-05-11 18:22:42 +00:00
|
|
|
void Install::changeBackupPath()
|
|
|
|
{
|
2008-05-12 17:29:03 +00:00
|
|
|
QString backupString = QFileDialog::getSaveFileName(this,"Select Backup Filename",m_backupName, "*.zip");
|
|
|
|
// only update if a filename was entered, ignore if cancelled
|
|
|
|
if(!backupString.isEmpty()) {
|
2008-05-12 21:21:12 +00:00
|
|
|
ui.backupLocation->setText(QDir::toNativeSeparators(fontMetrics().elidedText(backupString,Qt::ElideMiddle,200)));
|
2008-05-12 17:29:03 +00:00
|
|
|
m_backupName = backupString;
|
|
|
|
}
|
2008-05-11 18:22:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Install::updateDataReadProgress(int read, int total)
|
|
|
|
{
|
|
|
|
logger->setProgressMax(total);
|
|
|
|
logger->setProgressValue(read);
|
|
|
|
//qDebug() << "progress:" << read << "/" << total;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-07-29 18:07:31 +00:00
|
|
|
// Zip installer has finished
|
2007-07-26 21:04:55 +00:00
|
|
|
void Install::done(bool error)
|
2007-07-25 20:21:06 +00:00
|
|
|
{
|
2007-07-26 21:04:55 +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)
|
|
|
|
{
|
2007-07-29 18:07:31 +00:00
|
|
|
logger->abort();
|
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
|
2008-01-25 00:12:25 +00:00
|
|
|
QSettings installlog(settings->mountpoint()
|
2007-08-30 19:08:25 +00:00
|
|
|
+ "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
|
2008-01-25 00:12:25 +00:00
|
|
|
installlog.setValue("platform", settings->curPlatform());
|
2007-08-30 19:08:25 +00:00
|
|
|
installlog.sync();
|
2007-07-25 20:21:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Install::setDetailsCurrent(bool show)
|
|
|
|
{
|
|
|
|
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).")
|
|
|
|
.arg(version.value("bleed_rev"), version.value("bleed_date")));
|
|
|
|
if(version.value("rel_rev").isEmpty())
|
2007-07-25 20:21:06 +00:00
|
|
|
ui.labelNote->setText(tr("<b>Note:</b> This option will always "
|
|
|
|
"download a fresh copy. "
|
|
|
|
"<b>This is the recommended version.</b>"));
|
|
|
|
else
|
|
|
|
ui.labelNote->setText(tr("<b>Note:</b> This option will always "
|
|
|
|
"download a fresh copy."));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Install::setDetailsStable(bool show)
|
|
|
|
{
|
|
|
|
if(show) {
|
|
|
|
ui.labelDetails->setText(
|
|
|
|
tr("This is the last released version of Rockbox."));
|
|
|
|
|
2007-08-26 16:03:56 +00:00
|
|
|
if(!version.value("rel_rev").isEmpty())
|
|
|
|
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>")
|
|
|
|
.arg(version.value("rel_rev")));
|
2007-07-25 20:21:06 +00:00
|
|
|
else ui.labelNote->setText("");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Install::setDetailsArchived(bool show)
|
|
|
|
{
|
|
|
|
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).")
|
|
|
|
.arg(version.value("arch_rev"), version.value("arch_date")));
|
2007-07-25 20:21:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-08-26 16:03:56 +00:00
|
|
|
void Install::setVersionStrings(QMap<QString, QString> ver)
|
2007-07-25 20:21:06 +00:00
|
|
|
{
|
2007-08-26 16:03:56 +00:00
|
|
|
version = ver;
|
|
|
|
// version strings map is as following:
|
|
|
|
// rel_rev release version revision id
|
|
|
|
// rel_date release version release date
|
|
|
|
// same for arch_* and bleed_*
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2007-08-26 16:03:56 +00:00
|
|
|
if(version.value("arch_rev").isEmpty()) {
|
2007-07-25 20:21:06 +00:00
|
|
|
ui.radioArchived->setEnabled(false);
|
|
|
|
qDebug() << "no information about archived version available!";
|
|
|
|
}
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2007-08-26 16:03:56 +00:00
|
|
|
if(!version.value("rel_rev").isEmpty()) {
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
qDebug() << "Install::setVersionStrings" << version;
|
2007-07-25 20:21:06 +00:00
|
|
|
}
|
|
|
|
|
2008-05-11 18:22:42 +00:00
|
|
|
|