Make AskForScan() per-device rather than per device lister and fix cddadevice to use the url rather than the unique id.

This commit is contained in:
John Maguire 2011-08-11 22:10:14 +02:00
parent b458c9d24c
commit 50824cafe9
7 changed files with 12 additions and 6 deletions

View File

@ -53,7 +53,7 @@ void CddaDevice::Init() {
return;
}
GST_CDDA_BASE_SRC(cdda_)->device = g_strdup (unique_id_.toLocal8Bit().constData());
GST_CDDA_BASE_SRC(cdda_)->device = g_strdup (url_.path().toLocal8Bit().constData());
// Change the element's state to ready and paused, to be able to query it
if (gst_element_set_state(cdda_, GST_STATE_READY) == GST_STATE_CHANGE_FAILURE ||
@ -88,7 +88,7 @@ void CddaDevice::Init() {
song.set_id(track_number);
song.set_valid(true);
song.set_filetype(Song::Type_Cdda);
song.set_url(QUrl(QString("cdda://%1/%2").arg(unique_id()).arg(track_number)));
song.set_url(QUrl(QString("cdda://%1/%2").arg(url_.path()).arg(track_number)));
song.set_title(QString("Track %1").arg(track_number));
song.set_track(track_number);
songs << song;

View File

@ -37,7 +37,7 @@ public:
quint64 DeviceCapacity(const QString& id);
quint64 DeviceFreeSpace(const QString& id);
QVariantMap DeviceHardwareInfo(const QString& id);
bool AskForScan() { return false; }
bool AskForScan(const QString&) const { return false; }
QString MakeFriendlyName(const QString&);
QList<QUrl> MakeDeviceUrls(const QString&);
void UnmountDevice(const QString&);

View File

@ -53,7 +53,7 @@ public:
// When connecting to a device for the first time, do we want an user's
// confirmation for scanning it? (by default yes)
virtual bool AskForScan() { return true; }
virtual bool AskForScan(const QString&) const { return true; }
virtual QString MakeFriendlyName(const QString& id) = 0;
virtual QList<QUrl> MakeDeviceUrls(const QString& id) = 0;

View File

@ -319,7 +319,7 @@ QVariant DeviceManager::data(const QModelIndex& index, int role) const {
if (info.database_id_ == -1 &&
!info.BestBackend()->lister_->DeviceNeedsMount(info.BestBackend()->unique_id_)) {
if (info.BestBackend()->lister_->AskForScan()) {
if (info.BestBackend()->lister_->AskForScan(info.BestBackend()->unique_id_)) {
boost::scoped_ptr<QMessageBox> dialog(new QMessageBox(
QMessageBox::Information, tr("Connect device"),
tr("This is the first time you have connected this device. Clementine will now scan the device to find music files - this may take some time."),

View File

@ -308,8 +308,9 @@ void DeviceView::DeviceDisconnected(int row) {
void DeviceView::Forget() {
QModelIndex device_idx = MapToDevice(menu_index_);
QString unique_id = manager_->data(device_idx, DeviceManager::Role_UniqueId).toString();
if (manager_->GetLister(device_idx.row()) &&
manager_->GetLister(device_idx.row())->AskForScan()) {
manager_->GetLister(device_idx.row())->AskForScan(unique_id)) {
boost::scoped_ptr<QMessageBox> dialog(new QMessageBox(
QMessageBox::Question, tr("Forget device"),
tr("Forgetting a device will remove it from this list and Clementine will have to rescan all the songs again next time you connect it."),

View File

@ -24,6 +24,7 @@ class MacDeviceLister : public DeviceLister {
virtual quint64 DeviceCapacity(const QString& id);
virtual quint64 DeviceFreeSpace(const QString& id);
virtual QVariantMap DeviceHardwareInfo(const QString& id);
virtual bool AskForScan(const QString& serial) const;
virtual QString MakeFriendlyName(const QString& id);
virtual QList<QUrl> MakeDeviceUrls(const QString& id);

View File

@ -823,6 +823,10 @@ quint64 MacDeviceLister::DeviceFreeSpace(const QString& serial){
QVariantMap MacDeviceLister::DeviceHardwareInfo(const QString& serial){return QVariantMap();}
bool MacDeviceLister::AskForScan(const QString& serial) const {
return !IsCDDevice(serial);
}
void MacDeviceLister::UnmountDevice(const QString& serial) {
if (IsMTPSerial(serial)) return;