Fix CD handling

pull/2/head
Timothy Pearson 12 years ago
parent 4c44d87c73
commit 6f88082957

@ -47,11 +47,11 @@
#define CHECK_FOR_AND_EXECUTE_AUTOMOUNT(udi, medium, allowNotification) { \ #define CHECK_FOR_AND_EXECUTE_AUTOMOUNT(udi, medium, allowNotification) { \
TQMap<TQString,TQString> options = MediaManagerUtils::splitOptions(mountoptions(udi)); \ TQMap<TQString,TQString> options = MediaManagerUtils::splitOptions(mountoptions(udi)); \
kdDebug() << "automount " << options["automount"] << endl; \ kdDebug(1219) << "automount " << options["automount"] << endl; \
if (options["automount"] == "true" && allowNotification ) { \ if (options["automount"] == "true" && allowNotification ) { \
TQString error = mount(medium); \ TQString error = mount(medium); \
if (!error.isEmpty()) \ if (!error.isEmpty()) \
kdDebug() << "error " << error << endl; \ kdDebug(1219) << "error " << error << endl; \
} \ } \
} }
@ -129,10 +129,13 @@ bool TDEBackend::ListDevices()
// Create a media instance for a new storage device // Create a media instance for a new storage device
void TDEBackend::AddDevice(TDEStorageDevice * sdevice, bool allowNotification) void TDEBackend::AddDevice(TDEStorageDevice * sdevice, bool allowNotification)
{ {
kdDebug(1219) << "TDEBackend::AddDevice for " << sdevice->uniqueID() << endl;
// If the device is already listed, do not process it // If the device is already listed, do not process it
// This should not happen, but who knows... // This should not happen, but who knows...
/** @todo : refresh properties instead ? */ /** @todo : refresh properties instead ? */
if (m_mediaList.findById(sdevice->uniqueID())) { if (m_mediaList.findById(sdevice->uniqueID())) {
kdDebug(1219) << "TDEBackend::AddDevice for " << sdevice->uniqueID() << " found existing entry in media list" << endl;
return; return;
} }
@ -168,6 +171,8 @@ void TDEBackend::AddDevice(TDEStorageDevice * sdevice, bool allowNotification)
// Insert medium into list // Insert medium into list
m_mediaList.addMedium(medium, allowNotification); m_mediaList.addMedium(medium, allowNotification);
kdDebug(1219) << "TDEBackend::AddDevice inserted hard medium for " << sdevice->uniqueID() << endl;
// Automount if enabled // Automount if enabled
CHECK_FOR_AND_EXECUTE_AUTOMOUNT(sdevice->uniqueID(), medium, allowNotification) CHECK_FOR_AND_EXECUTE_AUTOMOUNT(sdevice->uniqueID(), medium, allowNotification)
} }
@ -194,6 +199,8 @@ void TDEBackend::AddDevice(TDEStorageDevice * sdevice, bool allowNotification)
// Insert medium into list // Insert medium into list
m_mediaList.addMedium(medium, allowNotification); m_mediaList.addMedium(medium, allowNotification);
kdDebug(1219) << "TDEBackend::AddDevice inserted optical medium for " << sdevice->uniqueID() << endl;
// Automount if enabled // Automount if enabled
CHECK_FOR_AND_EXECUTE_AUTOMOUNT(sdevice->uniqueID(), medium, allowNotification) CHECK_FOR_AND_EXECUTE_AUTOMOUNT(sdevice->uniqueID(), medium, allowNotification)
} }
@ -236,6 +243,9 @@ void TDEBackend::AddDevice(TDEStorageDevice * sdevice, bool allowNotification)
} }
m_mediaList.addMedium(medium, allowNotification); m_mediaList.addMedium(medium, allowNotification);
kdDebug(1219) << "TDEBackend::AddDevice inserted floppy medium for " << sdevice->uniqueID() << endl;
return; return;
} }
} }
@ -250,6 +260,8 @@ void TDEBackend::AddDevice(TDEStorageDevice * sdevice, bool allowNotification)
setCameraProperties(medium); setCameraProperties(medium);
m_mediaList.addMedium(medium, allowNotification); m_mediaList.addMedium(medium, allowNotification);
kdDebug(1219) << "TDEBackend::AddDevice inserted camera medium for " << sdevice->uniqueID() << endl;
return; return;
} }
} }
@ -257,7 +269,10 @@ void TDEBackend::AddDevice(TDEStorageDevice * sdevice, bool allowNotification)
void TDEBackend::RemoveDevice(TDEStorageDevice * sdevice) void TDEBackend::RemoveDevice(TDEStorageDevice * sdevice)
{ {
kdDebug(1219) << "TDEBackend::RemoveDevice for " << sdevice->uniqueID() << endl;
if (!m_mediaList.findById(sdevice->uniqueID())) { if (!m_mediaList.findById(sdevice->uniqueID())) {
kdDebug(1219) << "TDEBackend::RemoveDevice for " << sdevice->uniqueID() << " existing entry in media list was not found" << endl;
return; return;
} }
@ -266,14 +281,22 @@ void TDEBackend::RemoveDevice(TDEStorageDevice * sdevice)
void TDEBackend::ModifyDevice(TDEStorageDevice * sdevice) void TDEBackend::ModifyDevice(TDEStorageDevice * sdevice)
{ {
kdDebug(1219) << "TDEBackend::ModifyDevice for " << sdevice->uniqueID() << endl;
bool allowNotification = false; bool allowNotification = false;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Removable) && (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Inserted))) {
allowNotification = true;
}
ResetProperties(sdevice, allowNotification); ResetProperties(sdevice, allowNotification);
} }
void TDEBackend::ResetProperties(TDEStorageDevice * sdevice, bool allowNotification, bool overrideIgnoreList) void TDEBackend::ResetProperties(TDEStorageDevice * sdevice, bool allowNotification, bool overrideIgnoreList)
{ {
kdDebug(1219) << "TDEBackend::ResetProperties for " << sdevice->uniqueID() << " allowNotification: " << allowNotification << " overrideIgnoreList: " << overrideIgnoreList << endl;
if (!m_mediaList.findById(sdevice->uniqueID())) { if (!m_mediaList.findById(sdevice->uniqueID())) {
// This device is not currently in the device list, so add it and exit // This device is not currently in the device list, so add it and exit
kdDebug(1219) << "TDEBackend::ResetProperties for " << sdevice->uniqueID() << " existing entry in media list was not found" << endl;
AddDevice(sdevice, allowNotification); AddDevice(sdevice, allowNotification);
return; return;
} }
@ -358,6 +381,12 @@ void TDEBackend::ResetProperties(TDEStorageDevice * sdevice, bool allowNotificat
// END // END
if (sdevice->isDiskOfType(TDEDiskDeviceType::Optical)) {
kdDebug(1219) << "TDEBackend::ResetProperties for " << sdevice->uniqueID() << " device was removed from system" << endl;
RemoveDevice(sdevice);
return;
}
m_mediaList.changeMediumState(*m, allowNotification); m_mediaList.changeMediumState(*m, allowNotification);
delete m; delete m;
@ -722,13 +751,7 @@ TQStringList TDEBackend::mountoptions(const TQString &name)
config.setGroup(current_group); config.setGroup(current_group);
} }
if ((sdevice->isDiskOfType(TDEDiskDeviceType::CDROM)) if ((sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::CDRW))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::DVDROM))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::DVDRAM))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::DVDRW))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::BDROM))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::BDRW))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio)) || (sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::CDVideo)) || (sdevice->isDiskOfType(TDEDiskDeviceType::CDVideo))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::DVDVideo)) || (sdevice->isDiskOfType(TDEDiskDeviceType::DVDVideo))
@ -862,7 +885,7 @@ bool TDEBackend::setMountoptions(const TQString &name, const TQStringList &optio
TQString drive_udi = driveUDIFromDeviceUID(medium->id()); TQString drive_udi = driveUDIFromDeviceUID(medium->id());
kdDebug() << "setMountoptions " << name << " " << options << endl; kdDebug(1219) << "setMountoptions " << name << " " << options << endl;
KConfig config("mediamanagerrc"); KConfig config("mediamanagerrc");
config.setGroup(drive_udi); config.setGroup(drive_udi);
@ -1315,6 +1338,12 @@ TQString TDEBackend::driveUDIFromDeviceUID(TQString uuid) {
TQString ret; TQString ret;
if (sdevice) { if (sdevice) {
ret = sdevice->diskUUID(); ret = sdevice->diskUUID();
if (ret == "") {
ret = sdevice->deviceNode();
}
if (ret == "") {
ret = sdevice->uniqueID();
}
} }
if (ret == "") { if (ret == "") {
return TQString::null; return TQString::null;

Loading…
Cancel
Save