summaryrefslogtreecommitdiff
path: root/rbutil
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2007-08-23 15:24:28 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2007-08-23 15:24:28 +0000
commit1152a12d9189d8960a145066454e04d02ed4a171 (patch)
treedcb068254ed6dcd5b31764776bdce3a03da824d1 /rbutil
parentc494e371c849a9275811f238211d6cf510f38e03 (diff)
Add Ipod detection using ipodpatcher.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14441 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil')
-rw-r--r--rbutil/rbutilqt/autodetection.cpp37
-rw-r--r--rbutil/rbutilqt/autodetection.h9
2 files changed, 43 insertions, 3 deletions
diff --git a/rbutil/rbutilqt/autodetection.cpp b/rbutil/rbutilqt/autodetection.cpp
index 443db9b24a..e8eb498d62 100644
--- a/rbutil/rbutilqt/autodetection.cpp
+++ b/rbutil/rbutilqt/autodetection.cpp
@@ -31,7 +31,7 @@ bool Autodetection::detect()
// Try detection via rockbox.info
QStringList mountpoints = getMountpoints();
-
+
for(int i=0; i< mountpoints.size();i++)
{
QDir dir(mountpoints.at(i));
@@ -54,10 +54,19 @@ bool Autodetection::detect()
}
//try ipodpatcher
-
+ struct ipod_t ipod;
+
+ int n = ipod_scan(&ipod);
+ if(n == 1) {
+ qDebug() << "Ipod found:" << ipod.modelstr << "at" << ipod.diskname;
+ m_device = ipod.targetname;
+ m_mountpoint = resolveMountPoint(ipod.diskname);
+ return true;
+ }
//try sansapatcher
+
return false;
}
@@ -96,4 +105,28 @@ QStringList Autodetection::getMountpoints()
#endif
}
+QString Autodetection::resolveMountPoint(QString device)
+{
+ qDebug() << "Autodetection::resolveMountPoint(QString)" << device;
+#if defined(Q_OS_LINUX)
+ FILE *fp = fopen( "/proc/mounts", "r" );
+ if( !fp ) return QString("");
+ char *dev, *dir;
+ while( fscanf( fp, "%as %as %*s %*s %*s %*s", &dev, &dir ) != EOF )
+ {
+ if( QString(dev).startsWith(device) )
+ {
+ QString directory = dir;
+ free( dev );
+ free( dir );
+ return directory;
+ }
+ free( dev );
+ free( dir );
+ }
+ fclose( fp );
+
+#endif
+ return QString("");
+}
diff --git a/rbutil/rbutilqt/autodetection.h b/rbutil/rbutilqt/autodetection.h
index 0a941a0d5d..e950ab7149 100644
--- a/rbutil/rbutilqt/autodetection.h
+++ b/rbutil/rbutilqt/autodetection.h
@@ -23,6 +23,12 @@
#include <QtGui>
+extern "C" {
+ // Ipodpatcher
+#include "../ipodpatcher/ipodpatcher.h"
+#include "../sansapatcher/sansapatcher.h"
+};
+
class Autodetection :public QObject
{
Q_OBJECT
@@ -36,7 +42,8 @@ public:
QString getMountPoint() {return m_mountpoint;}
private:
- QStringList getMountpoints();
+ QStringList getMountpoints(void);
+ QString resolveMountPoint(QString);
QString m_device;
QString m_mountpoint;