mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
Simplify and cleanup rockbox-info.txt handling.
Simplify RockboxInfo file handling. Remove Detect::installedVersion() and Detect::installedTarget(), as those became wrappers around RockboxInfo without functionality. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22237 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
ad7dab615f
commit
84ced00bbd
8 changed files with 23 additions and 53 deletions
|
@ -92,7 +92,7 @@ bool Autodetection::detect()
|
||||||
|
|
||||||
// check rockbox-info.txt afterwards.
|
// check rockbox-info.txt afterwards.
|
||||||
RockboxInfo info(mounts.at(i));
|
RockboxInfo info(mounts.at(i));
|
||||||
if(info.open())
|
if(info.success())
|
||||||
{
|
{
|
||||||
if(m_device.isEmpty())
|
if(m_device.isEmpty())
|
||||||
{
|
{
|
||||||
|
|
|
@ -396,36 +396,6 @@ QUrl Detect::systemProxy(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** @brief detects the installed Rockbox version
|
|
||||||
* @return QString with version. Empty if not aviable
|
|
||||||
*/
|
|
||||||
QString Detect::installedVersion(QString mountpoint)
|
|
||||||
{
|
|
||||||
RockboxInfo info(mountpoint);
|
|
||||||
if(!info.open())
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
return info.version();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** @brief detects installed rockbox target string
|
|
||||||
* @return target name (platform) of installed Rockbox, empty string on error.
|
|
||||||
*/
|
|
||||||
QString Detect::installedTarget(QString mountpoint)
|
|
||||||
{
|
|
||||||
RockboxInfo info(mountpoint);
|
|
||||||
if(!info.open())
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
return info.target();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** @brief checks different Enviroment things. Ask if user wants to continue.
|
/** @brief checks different Enviroment things. Ask if user wants to continue.
|
||||||
* @param settings A pointer to rbutils settings class
|
* @param settings A pointer to rbutils settings class
|
||||||
* @param permission if it should check for permission
|
* @param permission if it should check for permission
|
||||||
|
@ -449,7 +419,8 @@ QString Detect::check(bool permission)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check TargetId
|
// Check TargetId
|
||||||
QString installed = installedTarget(RbSettings::value(RbSettings::Mountpoint).toString());
|
RockboxInfo rbinfo(RbSettings::value(RbSettings::Mountpoint).toString());
|
||||||
|
QString installed = rbinfo.target();
|
||||||
if(!installed.isEmpty() && installed != RbSettings::value(RbSettings::CurConfigureModel).toString())
|
if(!installed.isEmpty() && installed != RbSettings::value(RbSettings::CurConfigureModel).toString())
|
||||||
{
|
{
|
||||||
text += QObject::tr("<li>Target mismatch detected.\n"
|
text += QObject::tr("<li>Target mismatch detected.\n"
|
||||||
|
|
|
@ -45,8 +45,6 @@ public:
|
||||||
static QMap<uint32_t, QString> listUsbDevices(void);
|
static QMap<uint32_t, QString> listUsbDevices(void);
|
||||||
|
|
||||||
static QUrl systemProxy(void);
|
static QUrl systemProxy(void);
|
||||||
static QString installedVersion(QString mountpoint);
|
|
||||||
static QString installedTarget(QString mountpoint);
|
|
||||||
|
|
||||||
static QString check(bool permission);
|
static QString check(bool permission);
|
||||||
|
|
||||||
|
|
|
@ -161,17 +161,14 @@ QString findExecutable(QString name)
|
||||||
|
|
||||||
RockboxInfo::RockboxInfo(QString mountpoint)
|
RockboxInfo::RockboxInfo(QString mountpoint)
|
||||||
{
|
{
|
||||||
m_path = mountpoint +"/.rockbox/rockbox-info.txt";
|
qDebug() << "[RockboxInfo] trying to find rockbox-info at" << mountpoint;
|
||||||
}
|
QFile file(mountpoint + "/.rockbox/rockbox-info.txt");
|
||||||
|
m_success = false;
|
||||||
bool RockboxInfo::open()
|
|
||||||
{
|
|
||||||
QFile file(m_path);
|
|
||||||
if(!file.exists())
|
if(!file.exists())
|
||||||
return false;
|
return;
|
||||||
|
|
||||||
if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
return false;
|
return;
|
||||||
|
|
||||||
// read file contents
|
// read file contents
|
||||||
while (!file.atEnd())
|
while (!file.atEnd())
|
||||||
|
@ -195,7 +192,9 @@ bool RockboxInfo::open()
|
||||||
m_targetid = line.remove("Target id:").trimmed();
|
m_targetid = line.remove("Target id:").trimmed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
return true;
|
m_success = true;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,18 +35,18 @@ class RockboxInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RockboxInfo(QString mountpoint);
|
RockboxInfo(QString mountpoint);
|
||||||
bool open();
|
|
||||||
|
|
||||||
QString version() {return m_version;}
|
QString version() {return m_version;}
|
||||||
QString features(){return m_features;}
|
QString features(){return m_features;}
|
||||||
QString targetID() {return m_targetid;}
|
QString targetID() {return m_targetid;}
|
||||||
QString target() {return m_target;}
|
QString target() {return m_target;}
|
||||||
|
bool success() { return m_success; }
|
||||||
private:
|
private:
|
||||||
QString m_path;
|
|
||||||
QString m_version;
|
QString m_version;
|
||||||
QString m_features;
|
QString m_features;
|
||||||
QString m_targetid;
|
QString m_targetid;
|
||||||
QString m_target;
|
QString m_target;
|
||||||
|
bool m_success;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -47,7 +47,7 @@ bool VoiceFileCreator::createVoiceFile()
|
||||||
|
|
||||||
// read rockbox-info.txt
|
// read rockbox-info.txt
|
||||||
RockboxInfo info(m_mountpoint);
|
RockboxInfo info(m_mountpoint);
|
||||||
if(!info.open())
|
if(!info.success())
|
||||||
{
|
{
|
||||||
emit logItem(tr("could not find rockbox-info.txt"),LOGERROR);
|
emit logItem(tr("could not find rockbox-info.txt"),LOGERROR);
|
||||||
emit done(true);
|
emit done(true);
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "rbzip.h"
|
#include "rbzip.h"
|
||||||
#include "detect.h"
|
#include "detect.h"
|
||||||
#include "rbsettings.h"
|
#include "rbsettings.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
Install::Install(QWidget *parent) : QDialog(parent)
|
Install::Install(QWidget *parent) : QDialog(parent)
|
||||||
{
|
{
|
||||||
|
@ -34,7 +35,8 @@ Install::Install(QWidget *parent) : QDialog(parent)
|
||||||
connect(ui.backup, SIGNAL(stateChanged(int)), this, SLOT(backupCheckboxChanged(int)));
|
connect(ui.backup, SIGNAL(stateChanged(int)), this, SLOT(backupCheckboxChanged(int)));
|
||||||
|
|
||||||
//! check if rockbox is already installed
|
//! check if rockbox is already installed
|
||||||
QString version = Detect::installedVersion(RbSettings::value(RbSettings::Mountpoint).toString());
|
RockboxInfo rbinfo(RbSettings::value(RbSettings::Mountpoint).toString());
|
||||||
|
QString version = rbinfo.version();
|
||||||
|
|
||||||
if(version != "")
|
if(version != "")
|
||||||
{
|
{
|
||||||
|
|
|
@ -526,13 +526,12 @@ bool RbUtilQt::installAuto()
|
||||||
buildInfo.close();
|
buildInfo.close();
|
||||||
|
|
||||||
// check installed Version and Target
|
// check installed Version and Target
|
||||||
QString rbVersion = Detect::installedVersion(RbSettings::value(RbSettings::Mountpoint).toString());
|
|
||||||
QString warning = Detect::check(false);
|
QString warning = Detect::check(false);
|
||||||
|
|
||||||
if(!warning.isEmpty())
|
if(!warning.isEmpty())
|
||||||
{
|
{
|
||||||
if(QMessageBox::warning(this, tr("Really continue?"), warning,
|
if(QMessageBox::warning(this, tr("Really continue?"), warning,
|
||||||
QMessageBox::Ok | QMessageBox::Abort, QMessageBox::Abort) == QMessageBox::Abort)
|
QMessageBox::Ok | QMessageBox::Abort, QMessageBox::Abort)
|
||||||
|
== QMessageBox::Abort)
|
||||||
{
|
{
|
||||||
logger->addItem(tr("Aborted!"), LOGERROR);
|
logger->addItem(tr("Aborted!"), LOGERROR);
|
||||||
logger->setFinished();
|
logger->setFinished();
|
||||||
|
@ -541,7 +540,8 @@ bool RbUtilQt::installAuto()
|
||||||
}
|
}
|
||||||
|
|
||||||
// check version
|
// check version
|
||||||
if(rbVersion != "")
|
RockboxInfo rbinfo(RbSettings::value(RbSettings::Mountpoint).toString());
|
||||||
|
if(rbinfo.version() != "")
|
||||||
{
|
{
|
||||||
if(QMessageBox::question(this, tr("Installed Rockbox detected"),
|
if(QMessageBox::question(this, tr("Installed Rockbox detected"),
|
||||||
tr("Rockbox installation detected. Do you want to backup first?"),
|
tr("Rockbox installation detected. Do you want to backup first?"),
|
||||||
|
@ -549,7 +549,7 @@ bool RbUtilQt::installAuto()
|
||||||
{
|
{
|
||||||
logger->addItem(tr("Starting backup..."),LOGINFO);
|
logger->addItem(tr("Starting backup..."),LOGINFO);
|
||||||
QString backupName = RbSettings::value(RbSettings::Mountpoint).toString()
|
QString backupName = RbSettings::value(RbSettings::Mountpoint).toString()
|
||||||
+ "/.backup/rockbox-backup-" + rbVersion + ".zip";
|
+ "/.backup/rockbox-backup-" + rbinfo.version() + ".zip";
|
||||||
|
|
||||||
//! create dir, if it doesnt exist
|
//! create dir, if it doesnt exist
|
||||||
QFileInfo backupFile(backupName);
|
QFileInfo backupFile(backupName);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue