Add Ipod detection using ipodpatcher.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14441 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
c494e371c8
commit
1152a12d91
2 changed files with 43 additions and 3 deletions
|
@ -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("");
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue