From 8363619e666b37cf8e33f71ea1bfe44676b401e3 Mon Sep 17 00:00:00 2001 From: Dominik Wenger Date: Wed, 20 Jan 2010 22:18:36 +0000 Subject: rbutil: store the info from the server centrally in RbSetttings. Dont download build-info multiple times. Rename install.cpp git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24301 a1c6a512-1295-4272-9138-f99709370657 --- rbutil/rbutilqt/base/rbsettings.cpp | 60 ++++++- rbutil/rbutilqt/base/rbsettings.h | 17 ++ rbutil/rbutilqt/install.cpp | 319 ------------------------------------ rbutil/rbutilqt/install.h | 66 -------- rbutil/rbutilqt/installwindow.cpp | 309 ++++++++++++++++++++++++++++++++++ rbutil/rbutilqt/installwindow.h | 64 ++++++++ rbutil/rbutilqt/rbutilqt.cpp | 106 ++++++------ rbutil/rbutilqt/rbutilqt.h | 1 - rbutil/rbutilqt/rbutilqt.pro | 4 +- 9 files changed, 509 insertions(+), 437 deletions(-) delete mode 100644 rbutil/rbutilqt/install.cpp delete mode 100644 rbutil/rbutilqt/install.h create mode 100644 rbutil/rbutilqt/installwindow.cpp create mode 100644 rbutil/rbutilqt/installwindow.h diff --git a/rbutil/rbutilqt/base/rbsettings.cpp b/rbutil/rbutilqt/base/rbsettings.cpp index bd6f94f2f4..527312b108 100644 --- a/rbutil/rbutilqt/base/rbsettings.cpp +++ b/rbutil/rbutilqt/base/rbsettings.cpp @@ -94,9 +94,24 @@ const static struct { { RbSettings::EncoderVolume, ":encoder:/volume", "1.0" }, }; +// server settings +const static struct { + RbSettings::ServerSettings setting; + const char* name; + const char* def; +} ServerSettingsList[] = { + { RbSettings::CurReleaseVersion, ":platform:/releaseversion", "" }, + { RbSettings::CurStatus, ":platform:/status", "" }, + { RbSettings::DailyRevision, "dailyrev", "" }, + { RbSettings::DailyDate, "dailydate", "" }, + { RbSettings::BleedingRevision, "bleedingrev", "" }, + { RbSettings::BleedingDate, "bleedingdate", "" }, +}; + //! pointer to setting object to NULL QSettings* RbSettings::systemSettings = NULL; QSettings* RbSettings::userSettings = NULL; +QSettings* RbSettings::serverSettings = NULL; void RbSettings::ensureRbSettingsExists() { @@ -106,7 +121,13 @@ void RbSettings::ensureRbSettingsExists() // only use built-in rbutil.ini systemSettings = new QSettings(":/ini/rbutil.ini", QSettings::IniFormat, 0); } - + + if(serverSettings == NULL) + { + serverSettings = new QSettings(QSettings::IniFormat, + QSettings::UserScope, "rockbox.org", "RockboxUtility",NULL); + } + if(userSettings == NULL) { // portable installation: @@ -200,6 +221,20 @@ QVariant RbSettings::subValue(QString sub, enum UserSettings setting) return userSettings->value(s, UserSettingsList[i].def); } +QVariant RbSettings::value(enum ServerSettings setting) +{ + ensureRbSettingsExists(); + + // locate setting item + int i = 0; + while(ServerSettingsList[i].setting != setting) + i++; + + QString s = constructSettingPath(ServerSettingsList[i].name); + qDebug() << "[Settings] GET SERV:" << s << serverSettings->value(s, ServerSettingsList[i].def).toString(); + return serverSettings->value(s, ServerSettingsList[i].def); +} + void RbSettings::setValue(enum UserSettings setting , QVariant value) { QString empty; @@ -216,8 +251,29 @@ void RbSettings::setSubValue(QString sub, enum UserSettings setting, QVariant va i++; QString s = constructSettingPath(UserSettingsList[i].name, sub); - qDebug() << "[Settings] SET U:" << s << userSettings->value(s).toString(); userSettings->setValue(s, value); + qDebug() << "[Settings] SET U:" << s << userSettings->value(s).toString(); +} + +void RbSettings::setValue(enum ServerSettings setting, QVariant value) +{ + QString empty; + return setPlatformValue(empty, setting, value); +} + +void RbSettings::setPlatformValue(QString platform, enum ServerSettings setting, QVariant value) +{ + ensureRbSettingsExists(); + + // locate setting item + int i = 0; + while(ServerSettingsList[i].setting != setting) + i++; + + QString s = ServerSettingsList[i].name; + s.replace(":platform:", platform); + serverSettings->setValue(s, value); + qDebug() << "[Settings] SET SERV:" << s << serverSettings->value(s).toString(); } diff --git a/rbutil/rbutilqt/base/rbsettings.h b/rbutil/rbutilqt/base/rbsettings.h index b3f0430208..5e128e602d 100644 --- a/rbutil/rbutilqt/base/rbsettings.h +++ b/rbutil/rbutilqt/base/rbsettings.h @@ -97,6 +97,16 @@ class RbSettings : public QObject CurConfigureModel, }; + //! All Server settings + enum ServerSettings { + CurReleaseVersion, + CurStatus, + DailyRevision, + DailyDate, + BleedingRevision, + BleedingDate, + }; + //! call this to flush the user Settings static void sync(); //! returns the filename of the usersettings file @@ -115,12 +125,18 @@ class RbSettings : public QObject static QVariant value(enum SystemSettings setting); //! get a value from user settings static QVariant value(enum UserSettings setting); + //! get a value from server settings + static QVariant value(enum ServerSettings setting); //! set a user setting value static void setValue(enum UserSettings setting , QVariant value); + //! set a server setting value + static void setValue(enum ServerSettings setting , QVariant value); //! get a user setting from a subvalue (ie for encoders and tts engines) static QVariant subValue(QString sub, enum UserSettings setting); //! set a user setting from a subvalue (ie for encoders and tts engines) static void setSubValue(QString sub, enum UserSettings setting, QVariant value); + //! set a value for a server settings for a named platform. + static void setPlatformValue(QString platform, enum ServerSettings setting, QVariant value); //! get a value from system settings for a named platform. static QVariant platformValue(QString platform, enum SystemSettings setting); @@ -135,6 +151,7 @@ class RbSettings : public QObject //! pointers to our setting objects static QSettings *systemSettings; static QSettings *userSettings; + static QSettings *serverSettings; }; #endif diff --git a/rbutil/rbutilqt/install.cpp b/rbutil/rbutilqt/install.cpp deleted file mode 100644 index 8deaf95c29..0000000000 --- a/rbutil/rbutilqt/install.cpp +++ /dev/null @@ -1,319 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * - * Copyright (C) 2007 by Dominik Riebeling - * $Id$ - * - * 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" -#include "rbzip.h" -#include "system.h" -#include "rbsettings.h" -#include "utils.h" - -Install::Install(QWidget *parent) : QDialog(parent) -{ - 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))); - connect(ui.changeBackup, SIGNAL(pressed()), this, SLOT(changeBackupPath())); - connect(ui.backup, SIGNAL(stateChanged(int)), this, SLOT(backupCheckboxChanged(int))); - - //! check if rockbox is already installed - RockboxInfo rbinfo(RbSettings::value(RbSettings::Mountpoint).toString()); - QString version = rbinfo.version(); - - if(version != "") - { - ui.Backupgroup->show(); - m_backupName = RbSettings::value(RbSettings::Mountpoint).toString(); - if(!m_backupName.endsWith("/")) m_backupName += "/"; - m_backupName += ".backup/rockbox-backup-"+version+".zip"; - // for some reason the label doesn't return its final size yet. - // Delay filling ui.backupLocation until the checkbox is changed. - } - else - { - ui.Backupgroup->hide(); - } - backupCheckboxChanged(Qt::Unchecked); -} - - -void Install::resizeEvent(QResizeEvent *e) -{ - (void)e; - - // recalculate width of elided text. - updateBackupLocation(); -} - - -void Install::updateBackupLocation(void) -{ - ui.backupLocation->setText(QDir::toNativeSeparators( - fontMetrics().elidedText(tr("Backup to %1").arg(m_backupName), - Qt::ElideMiddle, ui.backupLocation->size().width()))); -} - - -void Install::backupCheckboxChanged(int state) -{ - if(state == Qt::Checked) - { - ui.backupLocation->show(); - ui.changeBackup->show(); - // update backup location display. - updateBackupLocation(); - } - else - { - ui.backupLocation->hide(); - ui.changeBackup->hide(); - } -} - - -void Install::accept() -{ - logger = new ProgressLoggerGui(this); - logger->show(); - QString mountPoint = RbSettings::value(RbSettings::Mountpoint).toString(); - qDebug() << "[Install] mountpoint:" << RbSettings::value(RbSettings::Mountpoint).toString(); - // show dialog with error if mount point is wrong - if(!QFileInfo(mountPoint).isDir()) { - logger->addItem(tr("Mount point is wrong!"),LOGERROR); - logger->setFinished(); - return; - } - - QString myversion; - QString buildname = RbSettings::value(RbSettings::CurBuildserverModel).toString(); - if(ui.radioStable->isChecked()) { - file = RbSettings::value(RbSettings::ReleaseUrl).toString(); - RbSettings::setValue(RbSettings::Build, "stable"); - myversion = version.value("rel_rev"); - } - else if(ui.radioArchived->isChecked()) { - file = RbSettings::value(RbSettings::DailyUrl).toString(); - RbSettings::setValue(RbSettings::Build, "archived"); - myversion = "r" + version.value("arch_rev") + "-" + version.value("arch_date"); - } - else if(ui.radioCurrent->isChecked()) { - file = RbSettings::value(RbSettings::BleedingUrl).toString(); - RbSettings::setValue(RbSettings::Build, "current"); - myversion = "r" + version.value("bleed_rev"); - } - else { - qDebug() << "[Install] no build selected -- this shouldn't happen"; - return; - } - file.replace("%MODEL%", buildname); - file.replace("%RELVERSION%", version.value("rel_rev")); - file.replace("%REVISION%", version.value("arch_rev")); - file.replace("%DATE%", version.value("arch_date")); - - RbSettings::sync(); - - QString warning = check(false); - if(!warning.isEmpty()) - { - if(QMessageBox::warning(this, tr("Really continue?"), warning, - QMessageBox::Ok | QMessageBox::Abort, QMessageBox::Abort) - == QMessageBox::Abort) - { - logger->addItem(tr("Aborted!"),LOGERROR); - logger->setFinished(); - return; - } - } - - //! check if we should backup - if(ui.backup->isChecked()) - { - logger->addItem(tr("Beginning Backup..."),LOGINFO); - - //! create dir, if it doesnt exist - QFileInfo backupFile(m_backupName); - if(!QDir(backupFile.path()).exists()) - { - QDir a; - a.mkpath(backupFile.path()); - } - - //! create backup - RbZip backup; - connect(&backup,SIGNAL(zipProgress(int,int)),logger,SLOT(setProgress(int,int))); - if(backup.createZip(m_backupName, - RbSettings::value(RbSettings::Mountpoint).toString() + "/.rockbox") == Zip::Ok) - { - logger->addItem(tr("Backup successful"),LOGOK); - } - else - { - logger->addItem(tr("Backup failed!"),LOGERROR); - logger->setFinished(); - return; - } - } - - //! install build - installer = new ZipInstaller(this); - installer->setUrl(file); - installer->setLogSection("Rockbox (Base)"); - if(!RbSettings::value(RbSettings::CacheDisabled).toBool() - && !ui.checkBoxCache->isChecked()) - { - installer->setCache(true); - } - installer->setLogVersion(myversion); - installer->setMountPoint(mountPoint); - - connect(installer, SIGNAL(done(bool)), this, SLOT(done(bool))); - - 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(); - -} - -void Install::changeBackupPath() -{ - QString backupString = QFileDialog::getSaveFileName(this, - tr("Select Backup Filename"), m_backupName, "*.zip"); - // only update if a filename was entered, ignore if cancelled - if(!backupString.isEmpty()) { - m_backupName = backupString; - updateBackupLocation(); - } -} - - -// Zip installer has finished -void Install::done(bool error) -{ - qDebug() << "[Install] done, error:" << error; - - if(error) - { - logger->setFinished(); - return; - } - - // no error, close the window, when the logger is closed - connect(logger,SIGNAL(closed()),this,SLOT(close())); - // add platform info to log file for later detection - QSettings installlog(RbSettings::value(RbSettings::Mountpoint).toString() - + "/.rockbox/rbutil.log", QSettings::IniFormat, 0); - installlog.setValue("platform", RbSettings::value(RbSettings::Platform).toString()); - installlog.sync(); -} - - -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 " - "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()) - ui.labelNote->setText(tr("This is the recommended version.")); - else - ui.labelNote->setText(""); - } -} - - -void Install::setDetailsStable(bool show) -{ - if(show) { - ui.labelDetails->setText( - tr("This is the last released version of Rockbox.")); - - if(!version.value("rel_rev").isEmpty()) - ui.labelNote->setText(tr("Note: " - "The lastest released version is %1. " - "This is the recommended version.") - .arg(version.value("rel_rev"))); - 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 " - "features than the last stable release but may be much less stable. " - "Features may change regularly.")); - ui.labelNote->setText(tr("Note: archived version is r%1 (%2).") - .arg(version.value("arch_rev"), version.value("arch_date"))); - } -} - - - -void Install::setVersionStrings(QMap& ver) -{ - 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_* - - if(version.value("arch_rev").isEmpty()) { - ui.radioArchived->setEnabled(false); - qDebug() << "[Install] no information about archived version available!"; - } - if(version.value("rel_rev").isEmpty()) { - 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" - && !version.value("rel_rev").isEmpty()) - 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); - else 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] setting version strings to:" << version; -} - - diff --git a/rbutil/rbutilqt/install.h b/rbutil/rbutilqt/install.h deleted file mode 100644 index 4ac6f281af..0000000000 --- a/rbutil/rbutilqt/install.h +++ /dev/null @@ -1,66 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * - * Copyright (C) 2007 by Dominik Riebeling - * $Id$ - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#ifndef INSTALL_H -#define INSTALL_H - -#include - -#include "ui_installfrm.h" -#include "zipinstaller.h" -#include "progressloggergui.h" - -class Install : public QDialog -{ - Q_OBJECT - public: - Install(QWidget *parent); - void setVersionStrings(QMap&); - - public slots: - void accept(void); - - private: - Ui::InstallFrm ui; - ProgressLoggerGui* logger; - QHttp *download; - QFile *target; - QString file; - ZipInstaller* installer; - QMap version; - QString m_backupName; - void resizeEvent(QResizeEvent*); - - void changeBackupPath(QString); - void updateBackupLocation(void); - - private slots: - void setDetailsCurrent(bool); - void setDetailsStable(bool); - void setDetailsArchived(bool); - void done(bool); - void changeBackupPath(void); - void backupCheckboxChanged(int state); - -}; - - -#endif diff --git a/rbutil/rbutilqt/installwindow.cpp b/rbutil/rbutilqt/installwindow.cpp new file mode 100644 index 0000000000..eb0dbf228d --- /dev/null +++ b/rbutil/rbutilqt/installwindow.cpp @@ -0,0 +1,309 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Copyright (C) 2007 by Dominik Riebeling + * $Id$ + * + * 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 "installwindow.h" +#include "ui_installfrm.h" +#include "rbzip.h" +#include "system.h" +#include "rbsettings.h" +#include "utils.h" + +InstallWindow::InstallWindow(QWidget *parent) : QDialog(parent) +{ + 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))); + connect(ui.changeBackup, SIGNAL(pressed()), this, SLOT(changeBackupPath())); + connect(ui.backup, SIGNAL(stateChanged(int)), this, SLOT(backupCheckboxChanged(int))); + + //! check if rockbox is already installed + RockboxInfo rbinfo(RbSettings::value(RbSettings::Mountpoint).toString()); + QString version = rbinfo.version(); + + if(version != "") + { + ui.Backupgroup->show(); + m_backupName = RbSettings::value(RbSettings::Mountpoint).toString(); + if(!m_backupName.endsWith("/")) m_backupName += "/"; + m_backupName += ".backup/rockbox-backup-"+version+".zip"; + // for some reason the label doesn't return its final size yet. + // Delay filling ui.backupLocation until the checkbox is changed. + } + else + { + ui.Backupgroup->hide(); + } + backupCheckboxChanged(Qt::Unchecked); + + + if(RbSettings::value(RbSettings::DailyRevision).toString().isEmpty()) { + ui.radioArchived->setEnabled(false); + qDebug() << "[Install] no information about archived version available!"; + } + if(RbSettings::value(RbSettings::CurReleaseVersion).toString().isEmpty()) { + 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" + && !RbSettings::value(RbSettings::CurReleaseVersion).toString().isEmpty()) + 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); + else if(!RbSettings::value(RbSettings::CurReleaseVersion).toString().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); + } + +} + + +void InstallWindow::resizeEvent(QResizeEvent *e) +{ + (void)e; + + // recalculate width of elided text. + updateBackupLocation(); +} + + +void InstallWindow::updateBackupLocation(void) +{ + ui.backupLocation->setText(QDir::toNativeSeparators( + fontMetrics().elidedText(tr("Backup to %1").arg(m_backupName), + Qt::ElideMiddle, ui.backupLocation->size().width()))); +} + + +void InstallWindow::backupCheckboxChanged(int state) +{ + if(state == Qt::Checked) + { + ui.backupLocation->show(); + ui.changeBackup->show(); + // update backup location display. + updateBackupLocation(); + } + else + { + ui.backupLocation->hide(); + ui.changeBackup->hide(); + } +} + + +void InstallWindow::accept() +{ + logger = new ProgressLoggerGui(this); + logger->show(); + QString mountPoint = RbSettings::value(RbSettings::Mountpoint).toString(); + qDebug() << "[Install] mountpoint:" << RbSettings::value(RbSettings::Mountpoint).toString(); + // show dialog with error if mount point is wrong + if(!QFileInfo(mountPoint).isDir()) { + logger->addItem(tr("Mount point is wrong!"),LOGERROR); + logger->setFinished(); + return; + } + + QString myversion; + QString buildname = RbSettings::value(RbSettings::CurBuildserverModel).toString(); + if(ui.radioStable->isChecked()) { + file = RbSettings::value(RbSettings::ReleaseUrl).toString(); + RbSettings::setValue(RbSettings::Build, "stable"); + myversion = RbSettings::value(RbSettings::CurReleaseVersion).toString(); + } + else if(ui.radioArchived->isChecked()) { + file = RbSettings::value(RbSettings::DailyUrl).toString(); + RbSettings::setValue(RbSettings::Build, "archived"); + myversion = "r" + RbSettings::value(RbSettings::DailyRevision).toString() + "-" + RbSettings::value(RbSettings::DailyDate).toString(); + } + else if(ui.radioCurrent->isChecked()) { + file = RbSettings::value(RbSettings::BleedingUrl).toString(); + RbSettings::setValue(RbSettings::Build, "current"); + myversion = "r" + RbSettings::value(RbSettings::BleedingRevision).toString(); + } + else { + qDebug() << "[Install] no build selected -- this shouldn't happen"; + return; + } + file.replace("%MODEL%", buildname); + file.replace("%RELVERSION%", RbSettings::value(RbSettings::CurReleaseVersion).toString()); + file.replace("%REVISION%", RbSettings::value(RbSettings::DailyRevision).toString()); + file.replace("%DATE%", RbSettings::value(RbSettings::DailyDate).toString()); + + RbSettings::sync(); + + QString warning = check(false); + if(!warning.isEmpty()) + { + if(QMessageBox::warning(this, tr("Really continue?"), warning, + QMessageBox::Ok | QMessageBox::Abort, QMessageBox::Abort) + == QMessageBox::Abort) + { + logger->addItem(tr("Aborted!"),LOGERROR); + logger->setFinished(); + return; + } + } + + //! check if we should backup + if(ui.backup->isChecked()) + { + logger->addItem(tr("Beginning Backup..."),LOGINFO); + + //! create dir, if it doesnt exist + QFileInfo backupFile(m_backupName); + if(!QDir(backupFile.path()).exists()) + { + QDir a; + a.mkpath(backupFile.path()); + } + + //! create backup + RbZip backup; + connect(&backup,SIGNAL(zipProgress(int,int)),logger,SLOT(setProgress(int,int))); + if(backup.createZip(m_backupName, + RbSettings::value(RbSettings::Mountpoint).toString() + "/.rockbox") == Zip::Ok) + { + logger->addItem(tr("Backup successful"),LOGOK); + } + else + { + logger->addItem(tr("Backup failed!"),LOGERROR); + logger->setFinished(); + return; + } + } + + //! install build + installer = new ZipInstaller(this); + installer->setUrl(file); + installer->setLogSection("Rockbox (Base)"); + if(!RbSettings::value(RbSettings::CacheDisabled).toBool() + && !ui.checkBoxCache->isChecked()) + { + installer->setCache(true); + } + installer->setLogVersion(myversion); + installer->setMountPoint(mountPoint); + + connect(installer, SIGNAL(done(bool)), this, SLOT(done(bool))); + + 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(); + +} + +void InstallWindow::changeBackupPath() +{ + QString backupString = QFileDialog::getSaveFileName(this, + tr("Select Backup Filename"), m_backupName, "*.zip"); + // only update if a filename was entered, ignore if cancelled + if(!backupString.isEmpty()) { + m_backupName = backupString; + updateBackupLocation(); + } +} + + +// Zip installer has finished +void InstallWindow::done(bool error) +{ + qDebug() << "[Install] done, error:" << error; + + if(error) + { + logger->setFinished(); + return; + } + + // no error, close the window, when the logger is closed + connect(logger,SIGNAL(closed()),this,SLOT(close())); + // add platform info to log file for later detection + QSettings installlog(RbSettings::value(RbSettings::Mountpoint).toString() + + "/.rockbox/rbutil.log", QSettings::IniFormat, 0); + installlog.setValue("platform", RbSettings::value(RbSettings::Platform).toString()); + installlog.sync(); +} + + +void InstallWindow::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 " + "a change is made. Latest version is r%1 (%2).") + .arg(RbSettings::value(RbSettings::BleedingRevision).toString(),RbSettings::value(RbSettings::BleedingDate).toString())); + if(RbSettings::value(RbSettings::CurReleaseVersion).toString().isEmpty()) + ui.labelNote->setText(tr("This is the recommended version.")); + else + ui.labelNote->setText(""); + } +} + + +void InstallWindow::setDetailsStable(bool show) +{ + if(show) { + ui.labelDetails->setText( + tr("This is the last released version of Rockbox.")); + + if(!RbSettings::value(RbSettings::CurReleaseVersion).toString().isEmpty()) + ui.labelNote->setText(tr("Note: " + "The lastest released version is %1. " + "This is the recommended version.") + .arg(RbSettings::value(RbSettings::CurReleaseVersion).toString())); + else ui.labelNote->setText(""); + } +} + + +void InstallWindow::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 " + "features than the last stable release but may be much less stable. " + "Features may change regularly.")); + ui.labelNote->setText(tr("Note: archived version is r%1 (%2).") + .arg(RbSettings::value(RbSettings::DailyRevision).toString(),RbSettings::value(RbSettings::DailyDate).toString())); + } +} + + + diff --git a/rbutil/rbutilqt/installwindow.h b/rbutil/rbutilqt/installwindow.h new file mode 100644 index 0000000000..e1a347099e --- /dev/null +++ b/rbutil/rbutilqt/installwindow.h @@ -0,0 +1,64 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Copyright (C) 2007 by Dominik Riebeling + * $Id$ + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef INSTALL_H +#define INSTALL_H + +#include + +#include "ui_installfrm.h" +#include "zipinstaller.h" +#include "progressloggergui.h" + +class InstallWindow : public QDialog +{ + Q_OBJECT + public: + InstallWindow(QWidget *parent); + + public slots: + void accept(void); + + private: + Ui::InstallFrm ui; + ProgressLoggerGui* logger; + QHttp *download; + QFile *target; + QString file; + ZipInstaller* installer; + QString m_backupName; + void resizeEvent(QResizeEvent*); + + void changeBackupPath(QString); + void updateBackupLocation(void); + + private slots: + void setDetailsCurrent(bool); + void setDetailsStable(bool); + void setDetailsArchived(bool); + void done(bool); + void changeBackupPath(void); + void backupCheckboxChanged(int state); + +}; + + +#endif diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp index 8860acc3bb..85d990a775 100644 --- a/rbutil/rbutilqt/rbutilqt.cpp +++ b/rbutil/rbutilqt/rbutilqt.cpp @@ -24,7 +24,7 @@ #include "ui_rbutilqtfrm.h" #include "ui_aboutbox.h" #include "configure.h" -#include "install.h" +#include "installwindow.h" #include "installtalkwindow.h" #include "createvoicewindow.h" #include "httpget.h" @@ -167,8 +167,6 @@ void RbUtilQt::updateTabs(int count) void RbUtilQt::downloadInfo() { - // make sure the version map is repopulated correctly later. - versmap.clear(); // try to get the current build information daily = new HttpGet(this); connect(daily, SIGNAL(done(bool)), this, SLOT(downloadDone(bool))); @@ -196,23 +194,32 @@ void RbUtilQt::downloadDone(bool error) } qDebug() << "[RbUtil] network status:" << daily->error(); + // read info into settings object buildInfo.open(); QSettings info(buildInfo.fileName(), QSettings::IniFormat, this); buildInfo.close(); - versmap.insert("arch_rev", info.value("dailies/rev").toString()); - versmap.insert("arch_date", info.value("dailies/date").toString()); - + RbSettings::setValue(RbSettings::DailyRevision,info.value("dailies/rev")); + QDate date = QDate::fromString(info.value("dailies/date").toString(), "yyyyMMdd"); + RbSettings::setValue(RbSettings::DailyDate,date.toString()); + info.beginGroup("release"); - versmap.insert("rel_rev", info.value(RbSettings::value(RbSettings::CurBuildserverModel).toString()).toString()); + QStringList keys = info.allKeys(); + for(int i=0; i < keys.size(); i++) + { + RbSettings::setPlatformValue(keys[i],RbSettings::CurReleaseVersion,info.value(keys[i])); + } info.endGroup(); - bool installable = !versmap.value("rel_rev").isEmpty(); - - ui.buttonSmall->setEnabled(installable); - ui.buttonComplete->setEnabled(installable); - ui.actionSmall_Installation->setEnabled(installable); - ui.actionComplete_Installation->setEnabled(installable); + info.beginGroup("status"); + keys = info.allKeys(); + for(int i=0; i < keys.size(); i++) + { + RbSettings::setPlatformValue(keys[i],RbSettings::CurStatus,info.value(keys[i])); + } + info.endGroup(); + + //start bleeding info download bleeding = new HttpGet(this); connect(bleeding, SIGNAL(done(bool)), this, SLOT(downloadBleedingDone(bool))); connect(bleeding, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool))); @@ -223,22 +230,6 @@ void RbUtilQt::downloadDone(bool error) bleeding->getFile(QUrl(RbSettings::value(RbSettings::BleedingInfo).toString())); ui.statusbar->showMessage(tr("Downloading build information, please wait ...")); - if(RbSettings::value(RbSettings::RbutilVersion) != PUREVERSION) { - QApplication::processEvents(); - QMessageBox::information(this, tr("New installation"), - tr("This is a new installation of Rockbox Utility, or a new version. " - "The configuration dialog will now open to allow you to setup the program, " - " or review your settings.")); - configDialog(); - } - else if(chkConfig(false)) { - QApplication::processEvents(); - QMessageBox::critical(this, tr("Configuration error"), - tr("Your configuration is invalid. This is most likely due " - "to a changed device path. The configuration dialog will " - "now open to allow you to correct the problem.")); - configDialog(); - } } @@ -251,11 +242,12 @@ void RbUtilQt::downloadBleedingDone(bool error) bleedingInfo.open(); QSettings info(bleedingInfo.fileName(), QSettings::IniFormat, this); bleedingInfo.close(); - versmap.insert("bleed_rev", info.value("bleeding/rev").toString()); - versmap.insert("bleed_date", info.value("bleeding/timestamp").toString()); - qDebug() << "[RbUtil] version map:" << versmap; - ui.statusbar->showMessage(tr("Download build information finished."), 5000); + RbSettings::setValue(RbSettings::BleedingRevision,info.value("bleeding/rev")); + QDateTime date = QDateTime::fromString(info.value("bleeding/timestamp").toString(), "yyyyMMddThhmmssZ"); + RbSettings::setValue(RbSettings::BleedingDate,date.toString()); + ui.statusbar->showMessage(tr("Download build information finished."), 5000); + updateSettings(); m_gotInfo = true; //start check for updates @@ -317,7 +309,6 @@ void RbUtilQt::configDialog() { Config *cw = new Config(this); connect(cw, SIGNAL(settingsUpdated()), this, SLOT(updateSettings())); - connect(cw, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo())); cw->show(); } @@ -338,6 +329,23 @@ void RbUtilQt::updateSettings() } HttpGet::setGlobalCache(RbSettings::value(RbSettings::CachePath).toString()); HttpGet::setGlobalDumbCache(RbSettings::value(RbSettings::CacheOffline).toBool()); + + if(RbSettings::value(RbSettings::RbutilVersion) != PUREVERSION) { + QApplication::processEvents(); + QMessageBox::information(this, tr("New installation"), + tr("This is a new installation of Rockbox Utility, or a new version. " + "The configuration dialog will now open to allow you to setup the program, " + " or review your settings.")); + configDialog(); + } + else if(chkConfig(false)) { + QApplication::processEvents(); + QMessageBox::critical(this, tr("Configuration error"), + tr("Your configuration is invalid. This is most likely due " + "to a changed device path. The configuration dialog will " + "now open to allow you to correct the problem.")); + configDialog(); + } } @@ -373,6 +381,13 @@ void RbUtilQt::updateDevice() if(mountpoint.isEmpty()) mountpoint = "<invalid>"; ui.labelDevice->setText(tr("%1 %2 at %3") .arg(brand, name, QDir::toNativeSeparators(mountpoint))); + + // hide quickstart buttons if no release available + bool installable = !RbSettings::value(RbSettings::CurReleaseVersion).toString().isEmpty(); + ui.buttonSmall->setEnabled(installable); + ui.buttonComplete->setEnabled(installable); + ui.actionSmall_Installation->setEnabled(installable); + ui.actionComplete_Installation->setEnabled(installable); } @@ -411,7 +426,7 @@ void RbUtilQt::completeInstall() "This will install Rockbox %1. To install the most recent " "development build available press \"Cancel\" and " "use the \"Installation\" tab.") - .arg(versmap.value("rel_rev")), + .arg(RbSettings::value(RbSettings::CurReleaseVersion).toString()), QMessageBox::Ok | QMessageBox::Cancel) != QMessageBox::Ok) return; // create logger @@ -469,7 +484,7 @@ void RbUtilQt::smallInstall() "This will install Rockbox %1. To install the most recent " "development build available press \"Cancel\" and " "use the \"Installation\" tab.") - .arg(versmap.value("rel_rev")), + .arg(RbSettings::value(RbSettings::CurReleaseVersion).toString()), QMessageBox::Ok | QMessageBox::Cancel) != QMessageBox::Ok) return; @@ -543,7 +558,7 @@ bool RbUtilQt::installAuto() { QString file = RbSettings::value(RbSettings::ReleaseUrl).toString(); file.replace("%MODEL%", RbSettings::value(RbSettings::CurBuildserverModel).toString()); - file.replace("%RELVERSION%", versmap.value("rel_rev")); + file.replace("%RELVERSION%", RbSettings::value(RbSettings::CurReleaseVersion).toString()); // check installed Version and Target QString warning = check(false); @@ -600,7 +615,7 @@ bool RbUtilQt::installAuto() ZipInstaller* installer = new ZipInstaller(this); installer->setUrl(file); installer->setLogSection("Rockbox (Base)"); - installer->setLogVersion(versmap.value("rel_rev")); + installer->setLogVersion(RbSettings::value(RbSettings::CurReleaseVersion).toString()); if(!RbSettings::value(RbSettings::CacheDisabled).toBool()) installer->setCache(true); installer->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString()); @@ -617,10 +632,7 @@ bool RbUtilQt::installAuto() void RbUtilQt::install() { - Install *installWindow = new Install(this); - - installWindow->setVersionStrings(versmap); - + InstallWindow *installWindow = new InstallWindow(this); installWindow->show(); } @@ -837,7 +849,7 @@ void RbUtilQt::installFonts() installer->setUrl(RbSettings::value(RbSettings::FontUrl).toString()); installer->setLogSection("Fonts"); - installer->setLogVersion(versmap.value("arch_date")); + installer->setLogVersion(RbSettings::value(RbSettings::DailyDate).toString()); installer->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString()); if(!RbSettings::value(RbSettings::CacheDisabled).toBool()) installer->setCache(true); @@ -876,12 +888,12 @@ void RbUtilQt::installVoice() QString voiceurl = RbSettings::value(RbSettings::VoiceUrl).toString(); voiceurl += RbSettings::value(RbSettings::CurBuildserverModel).toString() + "-" + - versmap.value("arch_date") + "-english.zip"; + RbSettings::value(RbSettings::DailyDate).toString() + "-english.zip"; qDebug() << "[RbUtil] voicefile URL:" << voiceurl; installer->setUrl(voiceurl); installer->setLogSection("Voice"); - installer->setLogVersion(versmap.value("arch_date")); + installer->setLogVersion(RbSettings::value(RbSettings::DailyDate).toString()); installer->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString()); if(!RbSettings::value(RbSettings::CacheDisabled).toBool()) installer->setCache(true); @@ -931,7 +943,7 @@ void RbUtilQt::installDoom() installer->setUrl(RbSettings::value(RbSettings::DoomUrl).toString()); installer->setLogSection("Game Addons"); - installer->setLogVersion(versmap.value("arch_date")); + installer->setLogVersion(RbSettings::value(RbSettings::DailyDate).toString()); installer->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString()); if(!RbSettings::value(RbSettings::CacheDisabled).toBool()) installer->setCache(true); @@ -1050,7 +1062,7 @@ void RbUtilQt::downloadManual(void) if(manual.isEmpty()) manual = "rockbox-" + RbSettings::value(RbSettings::Platform).toString(); - QString date = versmap.value("arch_date"); + QString date = RbSettings::value(RbSettings::DailyDate).toString(); QString manualurl; QString target; diff --git a/rbutil/rbutilqt/rbutilqt.h b/rbutil/rbutilqt/rbutilqt.h index 31bae73630..c47926e5a2 100644 --- a/rbutil/rbutilqt/rbutilqt.h +++ b/rbutil/rbutilqt/rbutilqt.h @@ -55,7 +55,6 @@ class RbUtilQt : public QMainWindow ProgressLoggerGui *logger; ZipInstaller *installer; QUrl proxy(void); - QMap versmap; bool chkConfig(bool); volatile bool m_installed; diff --git a/rbutil/rbutilqt/rbutilqt.pro b/rbutil/rbutilqt/rbutilqt.pro index e335797409..731a4a24ae 100644 --- a/rbutil/rbutilqt/rbutilqt.pro +++ b/rbutil/rbutilqt/rbutilqt.pro @@ -65,7 +65,7 @@ QMAKE_EXTRA_TARGETS += lrelease SOURCES += rbutilqt.cpp \ main.cpp \ - install.cpp \ + installwindow.cpp \ base/httpget.cpp \ configure.cpp \ zip/zip.cpp \ @@ -115,7 +115,7 @@ SOURCES += rbutilqt.cpp \ ../../tools/iriver.c \ HEADERS += rbutilqt.h \ - install.h \ + installwindow.h \ base/httpget.h \ configure.h \ zip/zip.h \ -- cgit v1.2.3