summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2007-09-27 08:50:47 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2007-09-27 08:50:47 +0000
commitddbb75142571e05b6f046594840151d8b4b379b1 (patch)
tree455097c97dedd16e8c82d1204cfcda516fa1800f
parent750f0acee30b5b89fb1547cc8bbe1b9f165044bf (diff)
Add parsing of ajbrec.ajz file header for autodetection. All archos targets should now be detectable. Fix a stupid bug in file-based detection.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14865 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--rbutil/rbutilqt/autodetection.cpp69
-rw-r--r--rbutil/rbutilqt/autodetection.h2
2 files changed, 66 insertions, 5 deletions
diff --git a/rbutil/rbutilqt/autodetection.cpp b/rbutil/rbutilqt/autodetection.cpp
index def1d12ef7..7be8cca707 100644
--- a/rbutil/rbutilqt/autodetection.cpp
+++ b/rbutil/rbutilqt/autodetection.cpp
@@ -56,6 +56,7 @@ bool Autodetection::detect()
QDir dir(mountpoints.at(i));
if(dir.exists())
{
+ qDebug() << "file checking:" << mountpoints.at(i);
// check logfile first.
if(QFile(mountpoints.at(i) + "/.rockbox/rbutil.log").exists()) {
QSettings log(mountpoints.at(i) + "/.rockbox/rbutil.log",
@@ -95,23 +96,28 @@ bool Autodetection::detect()
m_mountpoint = mountpoints.at(i);
return true;
}
- if(rootentries.contains("ONDIOST.BIN"), Qt::CaseInsensitive)
+ if(rootentries.contains("ONDIOST.BIN", Qt::CaseInsensitive))
{
// ONDIOST.BIN in root -> Ondio FM
m_device = "ondiofm";
m_mountpoint = mountpoints.at(i);
return true;
}
- if(rootentries.contains("ONDIOSP.BIN"), Qt::CaseInsensitive)
+ if(rootentries.contains("ONDIOSP.BIN", Qt::CaseInsensitive))
{
// ONDIOSP.BIN in root -> Ondio SP
m_device = "ondiosp";
m_mountpoint = mountpoints.at(i);
return true;
}
- if(rootentries.contains("ajbrec.ajz"), Qt::CaseInsensitive)
+ if(rootentries.contains("ajbrec.ajz", Qt::CaseInsensitive))
{
- qDebug() << "it's an archos. further detection needed";
+ qDebug() << "ajbrec.ajz found. Trying detectAjbrec()";
+ if(detectAjbrec(mountpoints.at(i))) {
+ m_mountpoint = mountpoints.at(i);
+ qDebug() << m_device;
+ return true;
+ }
}
// detection based on player specific folders
QStringList rootfolders = root.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
@@ -122,7 +128,6 @@ bool Autodetection::detect()
m_mountpoint = mountpoints.at(i);
return true;
}
- qDebug() << rootfolders;
}
}
@@ -260,6 +265,7 @@ bool Autodetection::detectUsb()
while(u) {
uint32_t id;
id = u->descriptor.idVendor << 16 | u->descriptor.idProduct;
+ m_usbconid.append(id);
qDebug("%x", id);
if(usbids.contains(id)) {
@@ -332,6 +338,7 @@ bool Autodetection::detectUsb()
else {
uint32_t id;
id = vid << 16 | pid;
+ m_usbconid.append(id);
qDebug("VID: %04x PID: %04x", vid, pid);
if(usbids.contains(id)) {
m_device = usbids.value(id);
@@ -357,3 +364,55 @@ bool Autodetection::detectUsb()
#endif
return false;
}
+
+
+bool Autodetection::detectAjbrec(QString root)
+{
+ QFile f(root + "/ajbrec.ajz");
+ char header[24];
+ f.open(QIODevice::ReadOnly);
+ if(!f.read(header, 24)) return false;
+
+ // check the header of the file.
+ // recorder v1 had a 6 bytes sized header
+ // recorder v2, FM, Ondio SP and FM have a 24 bytes header.
+
+ // recorder v1 has the binary length in the first 4 bytes, so check
+ // for them first.
+ int len = (header[0]<<24) | (header[1]<<16) | (header[2]<<8) | header[3];
+ qDebug() << "possible bin length:" << len;
+ qDebug() << "file len:" << f.size();
+ if((f.size() - 6) == len)
+ m_device = "recorder";
+
+ // size didn't match, now we need to assume we have a headerlength of 24.
+ switch(header[11]) {
+ case 2:
+ m_device = "recorderv2";
+ break;
+
+ case 4:
+ m_device = "fmrecorder";
+ break;
+
+ case 8:
+ // newer recorder firmwares also use the version id 8
+ // so check usb id too.
+ if(m_usbconid.contains(0x058f9330))
+ m_device = "ondiofm";
+ else
+ m_device = "recorderv2";
+ break;
+
+ case 16:
+ m_device = "ondiosp";
+ break;
+
+ default:
+ break;
+ }
+ f.close();
+
+ if(m_device.isEmpty()) return false;
+ return true;
+}
diff --git a/rbutil/rbutilqt/autodetection.h b/rbutil/rbutilqt/autodetection.h
index 83eb3979fe..a620b69566 100644
--- a/rbutil/rbutilqt/autodetection.h
+++ b/rbutil/rbutilqt/autodetection.h
@@ -46,10 +46,12 @@ private:
QStringList getMountpoints(void);
QString resolveMountPoint(QString);
bool detectUsb(void);
+ bool detectAjbrec(QString);
QString m_device;
QString m_mountpoint;
QString m_errdev;
+ QList<int> m_usbconid;
};