summaryrefslogtreecommitdiff
path: root/rbutil
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil')
-rw-r--r--rbutil/rbutilqt/base/autodetection.cpp39
-rw-r--r--rbutil/rbutilqt/base/autodetection.h21
-rw-r--r--rbutil/rbutilqt/configure.cpp181
-rw-r--r--rbutil/rbutilqt/configure.h1
4 files changed, 154 insertions, 88 deletions
diff --git a/rbutil/rbutilqt/base/autodetection.cpp b/rbutil/rbutilqt/base/autodetection.cpp
index fa2fe63cb8..de3765ffb1 100644
--- a/rbutil/rbutilqt/base/autodetection.cpp
+++ b/rbutil/rbutilqt/base/autodetection.cpp
@@ -38,6 +38,7 @@ bool Autodetection::detect()
m_device = "";
m_mountpoint = "";
m_errdev = "";
+ m_usberr = "";
detectUsb();
@@ -146,7 +147,8 @@ bool Autodetection::detect()
// if the found ipod is a macpod also notice it as device with problem.
if(ipod.macpod)
m_errdev = ipod.targetname;
- m_device = ipod.targetname;
+ else
+ m_device = ipod.targetname;
// since resolveMountPoint is doing exact matches we need to select
// the correct partition.
QString mp(ipod.diskname);
@@ -218,8 +220,8 @@ bool Autodetection::detectUsb()
return true;
}
if(usberror.contains(attached.at(i))) {
- m_errdev = usberror.value(attached.at(i)).at(0);
- qDebug() << "[USB] detected problem with player" << m_errdev;
+ m_usberr = usberror.value(attached.at(i)).at(0);
+ qDebug() << "[USB] detected problem with player" << m_usberr;
return true;
}
QString idstring = QString("%1").arg(attached.at(i), 8, 16, QChar('0'));
@@ -233,6 +235,37 @@ bool Autodetection::detectUsb()
}
+QList<struct Autodetection::Detected> Autodetection::detected(void)
+{
+ struct Detected d;
+
+ m_detected.clear();
+ if(!m_device.isEmpty()) {
+ d.device = m_device;
+ d.mountpoint = m_mountpoint;
+ d.status = PlayerOk;
+ m_detected.append(d);
+ }
+ else if(!m_errdev.isEmpty()) {
+ d.device = m_errdev;
+ d.status = PlayerWrongFilesystem;
+ m_detected.append(d);
+ }
+ else if(!m_usberr.isEmpty()) {
+ d.device = m_usberr;
+ d.status = PlayerMtpMode;
+ m_detected.append(d);
+ }
+ else if(!m_incompat.isEmpty()) {
+ d.device = m_incompat;
+ d.status = PlayerIncompatible;
+ m_detected.append(d);
+ }
+
+ return m_detected;
+}
+
+
bool Autodetection::detectAjbrec(QString root)
{
QFile f(root + "/ajbrec.ajz");
diff --git a/rbutil/rbutilqt/base/autodetection.h b/rbutil/rbutilqt/base/autodetection.h
index 1543aef766..65a24abb8f 100644
--- a/rbutil/rbutilqt/base/autodetection.h
+++ b/rbutil/rbutilqt/base/autodetection.h
@@ -33,21 +33,34 @@ class Autodetection :public QObject
public:
Autodetection(QObject* parent=0);
+ enum PlayerStatus {
+ PlayerOk,
+ PlayerIncompatible,
+ PlayerMtpMode,
+ PlayerWrongFilesystem,
+ PlayerError,
+ };
+
+ struct Detected {
+ QString device;
+ QString mountpoint;
+ enum PlayerStatus status;
+ };
+
bool detect();
- QString getDevice() {return m_device;}
- QString getMountPoint() {return m_mountpoint;}
- QString errdev(void) { return m_errdev; }
- QString incompatdev(void) { return m_incompat; }
+ QList<struct Detected> detected(void);
private:
QString resolveMountPoint(QString);
bool detectUsb(void);
bool detectAjbrec(QString);
+ QList<struct Detected> m_detected;
QString m_device;
QString m_mountpoint;
QString m_errdev;
+ QString m_usberr;
QString m_incompat;
QList<int> m_usbconid;
};
diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp
index ccf3eea465..922dc19b7c 100644
--- a/rbutil/rbutilqt/configure.cpp
+++ b/rbutil/rbutilqt/configure.cpp
@@ -725,98 +725,117 @@ void Config::autodetect()
this->setCursor(Qt::WaitCursor);
QCoreApplication::processEvents();
- if(detector.detect()) //let it detect
+ detector.detect();
+ QList<struct Autodetection::Detected> detected;
+ detected = detector.detected();
+ this->unsetCursor();
+ if(detected.size() > 1) {
+ // FIXME: handle multiple found players.
+ QMessageBox::information(this, tr("Device Detection"),
+ tr("Multiple devices have been detected. Please disconnect "
+ "all players but one and try again."));
+ ui.treeDevices->setEnabled(true);
+ }
+ else if(detected.size() == 0) {
+ QMessageBox::warning(this, tr("Device Detection"),
+ tr("Could not detect a device.\n"
+ "Select your device and Mountpoint manually."),
+ QMessageBox::Ok ,QMessageBox::Ok);
+ ui.treeDevices->setEnabled(true);
+ }
+ else if(detected.at(0).status != Autodetection::PlayerOk) {
+ QString msg;
+ switch(detected.at(0).status) {
+ case Autodetection::PlayerIncompatible:
+ msg += tr("Detected an unsupported player:\n%1\n"
+ "Sorry, Rockbox doesn't run on your player.")
+ .arg(SystemInfo::platformValue(detected.at(0).device,
+ SystemInfo::CurName).toString());
+ break;
+ case Autodetection::PlayerMtpMode:
+ msg = tr("%1 in MTP mode found!\n"
+ "You need to change your player to MSC mode for installation. ")
+ .arg(SystemInfo::platformValue(detected.at(0).device,
+ SystemInfo::CurName).toString());
+ break;
+ case Autodetection::PlayerWrongFilesystem:
+ if(SystemInfo::platformValue(detected.at(0).device,
+ SystemInfo::CurBootloaderMethod) == "ipod") {
+ msg = tr("%1 \"MacPod\" found!\n"
+ "Rockbox needs a FAT formatted Ipod (so-called \"WinPod\") "
+ "to run. ").arg(SystemInfo::platformValue(
+ detected.at(0).device, SystemInfo::CurName).toString());
+ }
+ else {
+ msg = tr("The player contains an incompatible filesystem.\n"
+ "Make sure you selected the correct mountpoint and "
+ "the player is set up to use a filesystem compatible "
+ "with Rockbox.");
+ }
+ break;
+ case Autodetection::PlayerError:
+ msg += tr("An unknown error occured during player detection.");
+ break;
+ default:
+ break;
+ }
+ QMessageBox::information(this, tr("Device Detection"), msg);
+ ui.treeDevices->setEnabled(true);
+ }
+ else {
+ selectDevice(detected.at(0).device, detected.at(0).mountpoint);
+ }
+
+}
+
+void Config::selectDevice(QString device, QString mountpoint)
+{
+ // collapse all items
+ for(int a = 0; a < ui.treeDevices->topLevelItemCount(); a++)
+ ui.treeDevices->topLevelItem(a)->setExpanded(false);
+ // deselect the selected item(s)
+ for(int a = 0; a < ui.treeDevices->selectedItems().size(); a++)
+ ui.treeDevices->selectedItems().at(a)->setSelected(false);
+
+ // find the new item
+ // enumerate all platform items
+ QList<QTreeWidgetItem*> itmList
+ = ui.treeDevices->findItems("*",Qt::MatchWildcard);
+ for(int i=0; i< itmList.size();i++)
{
- QString devicename = detector.getDevice();
- // deexpand all items
- for(int a = 0; a < ui.treeDevices->topLevelItemCount(); a++)
- ui.treeDevices->topLevelItem(a)->setExpanded(false);
- //deselect the selected item(s)
- for(int a = 0; a < ui.treeDevices->selectedItems().size(); a++)
- ui.treeDevices->selectedItems().at(a)->setSelected(false);
-
- // find the new item
- // enumerate all platform items
- QList<QTreeWidgetItem*> itmList
- = ui.treeDevices->findItems("*",Qt::MatchWildcard);
- for(int i=0; i< itmList.size();i++)
+ //enumerate device items
+ for(int j=0;j < itmList.at(i)->childCount();j++)
{
- //enumerate device items
- for(int j=0;j < itmList.at(i)->childCount();j++)
+ QString data = itmList.at(i)->child(j)->data(0, Qt::UserRole).toString();
+ // unset bold flag
+ QFont f = itmList.at(i)->child(j)->font(0);
+ f.setBold(false);
+ itmList.at(i)->child(j)->setFont(0, f);
+
+ if(device == data) // item found
{
- QString data = itmList.at(i)->child(j)->data(0, Qt::UserRole).toString();
- // unset bold flag
- QFont f = itmList.at(i)->child(j)->font(0);
- f.setBold(false);
+ f.setBold(true);
itmList.at(i)->child(j)->setFont(0, f);
-
- if(devicename == data) // item found
- {
- f.setBold(true);
- itmList.at(i)->child(j)->setFont(0, f);
- itmList.at(i)->child(j)->setSelected(true); //select the item
- itmList.at(i)->setExpanded(true); //expand the platform item
- //ui.treeDevices->indexOfTopLevelItem(itmList.at(i)->child(j));
- ui.treeDevices->scrollToItem(itmList.at(i)->child(j));
- break;
- }
- }
- }
- this->unsetCursor();
-
- if(!detector.errdev().isEmpty()) {
- QString text;
- if(SystemInfo::platformValue(detector.errdev(),
- SystemInfo::CurBootloaderMethod) == "ipod") {
- text = tr("%1 \"MacPod\" found!\n"
- "Rockbox needs a FAT formatted Ipod (so-called \"WinPod\") "
- "to run. ").arg(SystemInfo::platformValue(
- detector.errdev(), SystemInfo::CurName).toString());
+ itmList.at(i)->child(j)->setSelected(true); //select the item
+ itmList.at(i)->setExpanded(true); //expand the platform item
+ //ui.treeDevices->indexOfTopLevelItem(itmList.at(i)->child(j));
+ ui.treeDevices->scrollToItem(itmList.at(i)->child(j));
+ break;
}
- // treat all other errors as MTP device for now.
- else {
- text = tr("%1 in MTP mode found!\n"
- "You need to change your player to MSC mode for installation. ")
- .arg(SystemInfo::platformValue(detector.errdev(),
- SystemInfo::CurName).toString());
- }
- text += tr("Until you change this installation will fail!");
-
- QMessageBox::critical(this, tr("Fatal error"), text, QMessageBox::Ok);
- return;
}
- if(!detector.incompatdev().isEmpty()) {
- QString text;
- text = tr("Detected an unsupported player:\n%1\n"
- "Sorry, Rockbox doesn't run on your player.")
- .arg(SystemInfo::platformValue(detector.incompatdev(),
- SystemInfo::CurName).toString());
-
- QMessageBox::critical(this, tr("Fatal: player incompatible"),
- text, QMessageBox::Ok);
- return;
- }
+ }
+ this->unsetCursor();
- if(detector.getMountPoint() != "" )
- {
- setMountpoint(detector.getMountPoint());
- }
- else
- {
- QMessageBox::warning(this, tr("Autodetection"),
- tr("Could not detect a Mountpoint.\n"
- "Select your Mountpoint manually."),
- QMessageBox::Ok ,QMessageBox::Ok);
- }
+ if(!mountpoint.isEmpty())
+ {
+ setMountpoint(mountpoint);
}
else
{
- this->unsetCursor();
QMessageBox::warning(this, tr("Autodetection"),
- tr("Could not detect a device.\n"
- "Select your device and Mountpoint manually."),
- QMessageBox::Ok ,QMessageBox::Ok);
-
+ tr("Could not detect a Mountpoint.\n"
+ "Select your Mountpoint manually."),
+ QMessageBox::Ok, QMessageBox::Ok);
}
ui.treeDevices->setEnabled(true);
}
diff --git a/rbutil/rbutilqt/configure.h b/rbutil/rbutilqt/configure.h
index dd80f65b31..4e69996d1f 100644
--- a/rbutil/rbutilqt/configure.h
+++ b/rbutil/rbutilqt/configure.h
@@ -54,6 +54,7 @@ class Config : public QDialog
QString mountpoint;
void updateCacheInfo(QString);
void changeEvent(QEvent *event);
+ void selectDevice(QString device, QString mountpoint);
private slots:
void showProxyPassword(bool show);