summaryrefslogtreecommitdiffstats
path: root/rbutil/rbutilqt
diff options
context:
space:
mode:
authorDominik Wenger <domonoky@googlemail.com>2008-06-23 20:31:44 +0000
committerDominik Wenger <domonoky@googlemail.com>2008-06-23 20:31:44 +0000
commit6b0a1ec2a13e8a0e4f39c4957f4d64f0e0c2d8d6 (patch)
tree1cf81a90b1b5fd93c5099aa98280986123c2fcdb /rbutil/rbutilqt
parentd0e95cf0770af9fd034e193bd953480e8a74c6c4 (diff)
downloadrockbox-6b0a1ec2a13e8a0e4f39c4957f4d64f0e0c2d8d6.tar.gz
rockbox-6b0a1ec2a13e8a0e4f39c4957f4d64f0e0c2d8d6.tar.bz2
rockbox-6b0a1ec2a13e8a0e4f39c4957f4d64f0e0c2d8d6.zip
rbutil: warn when you install a build for a different target then already installed.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17769 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/rbutilqt')
-rw-r--r--rbutil/rbutilqt/install.cpp17
-rw-r--r--rbutil/rbutilqt/rbsettings.cpp24
-rw-r--r--rbutil/rbutilqt/rbsettings.h1
-rw-r--r--rbutil/rbutilqt/rbutilqt.cpp19
-rw-r--r--rbutil/rbutilqt/utils.cpp22
-rw-r--r--rbutil/rbutilqt/utils.h1
6 files changed, 83 insertions, 1 deletions
diff --git a/rbutil/rbutilqt/install.cpp b/rbutil/rbutilqt/install.cpp
index dbdd2d4820..8ee1dc1ff5 100644
--- a/rbutil/rbutilqt/install.cpp
+++ b/rbutil/rbutilqt/install.cpp
@@ -121,6 +121,23 @@ void Install::accept()
}
settings->sync();
+ int rbTarget = installedTargetId(settings->mountpoint());
+ if(rbTarget != -1 && rbTarget != settings->curTargetId())
+ {
+ if(QMessageBox::question(this, tr("Device mismatch detected"),
+ tr("Device mismatch detected.\n\n"
+ "Installed Rockbox is for Device: %1.\n"
+ "New Rockbox is for Device: %2.\n\n"
+ "Do you want to continue?").arg(settings->nameOfTargetId(rbTarget),settings->curName()),
+ QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
+ {
+ logger->addItem(tr("Aborted!"),LOGERROR);
+ logger->abort();
+ return;
+ }
+ }
+
+
//! check if we should backup
if(ui.backup->isChecked())
{
diff --git a/rbutil/rbutilqt/rbsettings.cpp b/rbutil/rbutilqt/rbsettings.cpp
index 1bb0f73db7..889164a1c9 100644
--- a/rbutil/rbutilqt/rbsettings.cpp
+++ b/rbutil/rbutilqt/rbsettings.cpp
@@ -370,6 +370,30 @@ QString RbSettings::brand(QString plattform)
return brand;
}
+QString RbSettings::nameOfTargetId(int id)
+{
+ QString result ="";
+ // get a list of ID -> target name
+ QStringList platforms;
+ devices->beginGroup("platforms");
+ platforms = devices->childKeys();
+ devices->endGroup();
+ for(int i = 0; i < platforms.size(); i++)
+ {
+ devices->beginGroup("platforms");
+ QString target = devices->value(platforms.at(i)).toString();
+ devices->endGroup();
+ devices->beginGroup(target);
+ if(devices->value("targetid").toInt() == id)
+ {
+ result = devices->value("name").toString();
+ }
+ devices->endGroup();
+ }
+
+ return result;
+}
+
QMap<int, QString> RbSettings::usbIdMap()
{
QMap<int, QString> map;
diff --git a/rbutil/rbutilqt/rbsettings.h b/rbutil/rbutilqt/rbsettings.h
index f833c5320f..ece247a3de 100644
--- a/rbutil/rbutilqt/rbsettings.h
+++ b/rbutil/rbutilqt/rbsettings.h
@@ -81,6 +81,7 @@ class RbSettings : public QObject
QString name(QString plattform);
QString brand(QString plattform);
QStringList allLanguages();
+ QString nameOfTargetId(int id);
QMap<int, QString> usbIdMap();
QMap<int, QString> usbIdErrorMap();
QMap<int, QString> usbIdIncompatMap();
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp
index a669949aa9..b7231977b2 100644
--- a/rbutil/rbutilqt/rbutilqt.cpp
+++ b/rbutil/rbutilqt/rbutilqt.cpp
@@ -474,8 +474,25 @@ bool RbUtilQt::installAuto()
QString myversion = "r" + versmap.value("bleed_rev");
- //! check if rockbox is already installed
+ // check installed Version and Target
QString rbVersion = installedVersion(settings->mountpoint());
+ int rbTarget = installedTargetId(settings->mountpoint());
+ if(rbTarget != -1 && rbTarget != settings->curTargetId())
+ {
+ if(QMessageBox::question(this, tr("Target mismatch detected"),
+ tr("Target mismatch detected. \n\n"
+ "Installed target: %1.\n"
+ "New Target: %2.\n\n"
+ "Do you want to continue?").arg(settings->nameOfTargetId(rbTarget),settings->curName()),
+ QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
+ {
+ logger->addItem(tr("Aborted!"),LOGERROR);
+ logger->abort();
+ return false;
+ }
+ }
+
+ // check version
if(rbVersion != "")
{
if(QMessageBox::question(this, tr("Installed Rockbox detected"),
diff --git a/rbutil/rbutilqt/utils.cpp b/rbutil/rbutilqt/utils.cpp
index 5aa5cd4a55..9359522f04 100644
--- a/rbutil/rbutilqt/utils.cpp
+++ b/rbutil/rbutilqt/utils.cpp
@@ -180,6 +180,28 @@ QString installedVersion(QString mountpoint)
return "";
}
+int installedTargetId(QString mountpoint)
+{
+ // read rockbox-info.txt
+ QFile info(mountpoint +"/.rockbox/rockbox-info.txt");
+ if(!info.open(QIODevice::ReadOnly))
+ {
+ return -1;
+ }
+
+ QString target, features,version;
+ while (!info.atEnd()) {
+ QString line = info.readLine();
+
+ if(line.contains("Target id:"))
+ {
+ return line.remove("Target id:").trimmed().toInt();
+ }
+ }
+ info.close();
+ return -1;
+
+}
QString getUserName(void)
{
diff --git a/rbutil/rbutilqt/utils.h b/rbutil/rbutilqt/utils.h
index a7be093520..b4d660520e 100644
--- a/rbutil/rbutilqt/utils.h
+++ b/rbutil/rbutilqt/utils.h
@@ -38,6 +38,7 @@ QString resolvePathCase(QString path);
QUrl systemProxy(void);
QString installedVersion(QString mountpoint);
+int installedTargetId(QString mountpoint);
#endif