From eddc47cc64c692986468a5ba41e2f82ae16356f6 Mon Sep 17 00:00:00 2001 From: David Sansome Date: Tue, 12 Apr 2011 17:27:01 +0000 Subject: [PATCH] Recognise iPods correctly when using GIO. --- src/devices/devicelister.cpp | 14 +++++++------- src/devices/devicelister.h | 3 ++- src/devices/giolister.cpp | 12 +++++++++++- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/devices/devicelister.cpp b/src/devices/devicelister.cpp index 6e231f9b1..ea4f28359 100644 --- a/src/devices/devicelister.cpp +++ b/src/devices/devicelister.cpp @@ -54,12 +54,6 @@ void DeviceLister::ThreadStarted() { namespace { -bool IsIpod(const QString& path) { - return QFile::exists(path + "/iTunes_Control") || - QFile::exists(path + "/iPod_Control") || - QFile::exists(path + "/iTunes/iTunes_Control"); -} - #ifdef HAVE_LIBGPOD QString GetIpodColour(Itdb_IpodModel model) { @@ -164,7 +158,7 @@ QString GetIpodModel(Itdb_IpodModel model) { } -QUrl DeviceLister::MakeUrlFromLocalPath(const QString& path) { +QUrl DeviceLister::MakeUrlFromLocalPath(const QString& path) const { if (IsIpod(path)) { QUrl ret; ret.setScheme("ipod"); @@ -175,6 +169,12 @@ QUrl DeviceLister::MakeUrlFromLocalPath(const QString& path) { return QUrl::fromLocalFile(path); } +bool DeviceLister::IsIpod(const QString& path) const { + return QFile::exists(path + "/iTunes_Control") || + QFile::exists(path + "/iPod_Control") || + QFile::exists(path + "/iTunes/iTunes_Control"); +} + QStringList DeviceLister::GuessIconForPath(const QString& path) { QStringList ret; diff --git a/src/devices/devicelister.h b/src/devices/devicelister.h index c58a83bbb..15ba7f932 100644 --- a/src/devices/devicelister.h +++ b/src/devices/devicelister.h @@ -73,7 +73,8 @@ signals: protected: virtual void Init() = 0; - QUrl MakeUrlFromLocalPath(const QString& path); + QUrl MakeUrlFromLocalPath(const QString& path) const; + bool IsIpod(const QString& path) const; QStringList GuessIconForPath(const QString& path); QStringList GuessIconForModel(const QString& vendor, const QString& model); diff --git a/src/devices/giolister.cpp b/src/devices/giolister.cpp index 17e190ece..6b4975b73 100644 --- a/src/devices/giolister.cpp +++ b/src/devices/giolister.cpp @@ -171,8 +171,18 @@ QList GioLister::MakeDeviceUrls(const QString& id) { // gphoto2 gives invalid hostnames with []:, characters in uri.replace(QRegExp("//\\[usb:(\\d+),(\\d+)\\]"), "//usb-\\1-\\2"); + QUrl url(uri); + QList ret; - ret << uri; + + // Special case for file:// GIO URIs - we have to check whether they point + // to an ipod. + if (url.isValid() && url.scheme() == "file") { + ret << MakeUrlFromLocalPath(url.path()); + } else { + ret << url; + } + ret << MakeUrlFromLocalPath(mount_point); return ret; }