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
|
// Try detection via rockbox.info
|
||||||
QStringList mountpoints = getMountpoints();
|
QStringList mountpoints = getMountpoints();
|
||||||
|
|
||||||
for(int i=0; i< mountpoints.size();i++)
|
for(int i=0; i< mountpoints.size();i++)
|
||||||
{
|
{
|
||||||
QDir dir(mountpoints.at(i));
|
QDir dir(mountpoints.at(i));
|
||||||
|
@ -54,10 +54,19 @@ bool Autodetection::detect()
|
||||||
}
|
}
|
||||||
|
|
||||||
//try ipodpatcher
|
//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
|
//try sansapatcher
|
||||||
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,4 +105,28 @@ QStringList Autodetection::getMountpoints()
|
||||||
#endif
|
#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>
|
#include <QtGui>
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
// Ipodpatcher
|
||||||
|
#include "../ipodpatcher/ipodpatcher.h"
|
||||||
|
#include "../sansapatcher/sansapatcher.h"
|
||||||
|
};
|
||||||
|
|
||||||
class Autodetection :public QObject
|
class Autodetection :public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -36,7 +42,8 @@ public:
|
||||||
QString getMountPoint() {return m_mountpoint;}
|
QString getMountPoint() {return m_mountpoint;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QStringList getMountpoints();
|
QStringList getMountpoints(void);
|
||||||
|
QString resolveMountPoint(QString);
|
||||||
|
|
||||||
QString m_device;
|
QString m_device;
|
||||||
QString m_mountpoint;
|
QString m_mountpoint;
|
||||||
|
|
Loading…
Reference in a new issue