summaryrefslogtreecommitdiffstats
path: root/tdeioslave/media/mediamanager/tdehardwarebackend.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tdeioslave/media/mediamanager/tdehardwarebackend.cpp')
-rw-r--r--tdeioslave/media/mediamanager/tdehardwarebackend.cpp660
1 files changed, 412 insertions, 248 deletions
diff --git a/tdeioslave/media/mediamanager/tdehardwarebackend.cpp b/tdeioslave/media/mediamanager/tdehardwarebackend.cpp
index c399d280d..a5900c883 100644
--- a/tdeioslave/media/mediamanager/tdehardwarebackend.cpp
+++ b/tdeioslave/media/mediamanager/tdehardwarebackend.cpp
@@ -49,16 +49,15 @@
TDEBackend::TDEBackend(MediaList &list, TQObject* parent)
: TQObject()
, BackendBase(list)
- , m_unlockDialog(0)
, m_parent(parent)
{
// Initialize the TDE device manager
TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
// Connect device monitoring signals/slots
- connect(hwdevices, TQT_SIGNAL(hardwareAdded(TDEGenericDevice*)), this, TQT_SLOT(AddDeviceHandler(TDEGenericDevice*)));
- connect(hwdevices, TQT_SIGNAL(hardwareRemoved(TDEGenericDevice*)), this, TQT_SLOT(RemoveDeviceHandler(TDEGenericDevice*)));
- connect(hwdevices, TQT_SIGNAL(hardwareUpdated(TDEGenericDevice*)), this, TQT_SLOT(ModifyDeviceHandler(TDEGenericDevice*)));
+ connect(hwdevices, TQ_SIGNAL(hardwareAdded(TDEGenericDevice*)), this, TQ_SLOT(AddDeviceHandler(TDEGenericDevice*)));
+ connect(hwdevices, TQ_SIGNAL(hardwareRemoved(TDEGenericDevice*)), this, TQ_SLOT(RemoveDeviceHandler(TDEGenericDevice*)));
+ connect(hwdevices, TQ_SIGNAL(hardwareUpdated(TDEGenericDevice*)), this, TQ_SLOT(ModifyDeviceHandler(TDEGenericDevice*)));
// List devices at startup
ListDevices();
@@ -139,29 +138,30 @@ void TDEBackend::AddDevice(TDEStorageDevice * sdevice, bool allowNotification)
bool allowDialogNotification = allowNotification;
TDEConfig config("mediamanagerrc");
config.setGroup("Global");
- if (!config.readBoolEntry("NotificationPopupsEnabled", false)) {
+ if (!config.readBoolEntry("NotificationPopupsEnabled", true)) {
allowDialogNotification = false;
}
// Add volume block devices
if (sdevice->isDiskOfType(TDEDiskDeviceType::HDD)) {
/* We only list volumes that...
- * - are encrypted with LUKS or
+ * - are encrypted or
* - have a filesystem or
* - have an audio track
*/
- if (!(sdevice->isDiskOfType(TDEDiskDeviceType::LUKS))
- && !(sdevice->checkDiskStatus(TDEDiskDeviceStatus::ContainsFilesystem))
- && !(sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio))
- && !(sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank))
+ if (!sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted) &&
+ !sdevice->checkDiskStatus(TDEDiskDeviceStatus::ContainsFilesystem) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio) &&
+ !sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)
) {
//
}
- /* We also don't display devices that underlie other devices;
- * e.g. the raw partition of a device mapper volume
- */
- else if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::UsedByDevice)
- || (sdevice->fileSystemUsage().upper() == "RAID")) {
+ // We also don't display devices that underlie other devices, unless they are encrypted devices
+ else if ((sdevice->checkDiskStatus(TDEDiskDeviceStatus::UsedByDevice) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted)) ||
+ sdevice->fileSystemUsage().upper() == "RAID") {
//
}
else {
@@ -169,16 +169,6 @@ void TDEBackend::AddDevice(TDEStorageDevice * sdevice, bool allowNotification)
Medium* medium = new Medium(sdevice->uniqueID(), driveUDIFromDeviceUID(sdevice->uniqueID()), "");
setVolumeProperties(medium);
- // Do not list the LUKS backend device if it has been unlocked elsewhere
- if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS)) {
- if (sdevice->holdingDevices().count() > 0) {
- medium->setHidden(true);
- }
- else {
- medium->setHidden(false);
- }
- }
-
// Hide udev hidden devices by default but allow the user to override if desired via Show Hidden Files
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Hidden)) {
medium->setSoftHidden(true);
@@ -266,33 +256,29 @@ void TDEBackend::AddDevice(TDEStorageDevice * sdevice, bool allowNotification)
}
/* We only list volumes that...
- * - are encrypted with LUKS or
+ * - are encrypted or
* - have a filesystem or
- * - are a floppy disk
+ * - have an audio track
*/
- if (!(sdevice->isDiskOfType(TDEDiskDeviceType::LUKS))
- && !(sdevice->checkDiskStatus(TDEDiskDeviceStatus::ContainsFilesystem))
- && !(sdevice->isDiskOfType(TDEDiskDeviceType::Floppy))
- && !(sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank))
+ if (!sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted) &&
+ !sdevice->checkDiskStatus(TDEDiskDeviceStatus::ContainsFilesystem) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio) &&
+ !sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)
) {
//
}
+ // We also don't display devices that underlie other devices, unless they are encrypted devices
+ else if ((sdevice->checkDiskStatus(TDEDiskDeviceStatus::UsedByDevice) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted)) ||
+ sdevice->fileSystemUsage().upper() == "RAID") {
+ //
+ }
else {
// Create medium
Medium* medium = new Medium(sdevice->uniqueID(), driveUDIFromDeviceUID(sdevice->uniqueID()), "");
-
setFloppyProperties(medium);
-
- // Do not list the LUKS backend device if it has been unlocked elsewhere
- if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS)) {
- if (sdevice->holdingDevices().count() > 0) {
- medium->setHidden(true);
- }
- else {
- medium->setHidden(false);
- }
- }
-
m_mediaList.addMedium(medium, allowDialogNotification);
kdDebug(1219) << "TDEBackend::AddDevice inserted floppy medium for " << sdevice->uniqueID() << endl;
@@ -334,8 +320,7 @@ void TDEBackend::ModifyDevice(TDEStorageDevice * sdevice)
{
kdDebug(1219) << "TDEBackend::ModifyDevice for " << sdevice->uniqueID() << endl;
- bool allowNotification = false;
- ResetProperties(sdevice, allowNotification);
+ ResetProperties(sdevice, false);
}
void TDEBackend::ResetProperties(TDEStorageDevice * sdevice, bool allowNotification, bool overrideIgnoreList)
@@ -359,24 +344,28 @@ void TDEBackend::ResetProperties(TDEStorageDevice * sdevice, bool allowNotificat
Medium* m = new Medium(sdevice->uniqueID(), driveUDIFromDeviceUID(sdevice->uniqueID()), "");
// Keep these conditions in sync with ::AddDevice above, OR ELSE!!!
- // BEGIN
if (sdevice->isDiskOfType(TDEDiskDeviceType::HDD)) {
- if (!(sdevice->isDiskOfType(TDEDiskDeviceType::LUKS))
- && !(sdevice->checkDiskStatus(TDEDiskDeviceStatus::ContainsFilesystem))
- && !(sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio))
- && !(sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank))
+ /* We only list volumes that...
+ * - are encrypted or
+ * - have a filesystem or
+ * - have an audio track
+ */
+ if (!sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted) &&
+ !sdevice->checkDiskStatus(TDEDiskDeviceStatus::ContainsFilesystem) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio) &&
+ !sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)
) {
+ //
+ }
+ // We also don't display devices that underlie other devices, unless they are encrypted devices
+ else if ((sdevice->checkDiskStatus(TDEDiskDeviceStatus::UsedByDevice) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted)) ||
+ sdevice->fileSystemUsage().upper() == "RAID") {
+ //
}
else {
- // Do not list the LUKS backend device if it has been unlocked elsewhere
- if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS)) {
- if (sdevice->holdingDevices().count() > 0) {
- m->setHidden(true);
- }
- else {
- m->setHidden(false);
- }
- }
setVolumeProperties(m);
}
}
@@ -416,25 +405,27 @@ void TDEBackend::ResetProperties(TDEStorageDevice * sdevice, bool allowNotificat
(sdevice->isDiskOfType(TDEDiskDeviceType::Zip)) ||
(sdevice->isDiskOfType(TDEDiskDeviceType::Jaz))
) {
-
- if (!(sdevice->isDiskOfType(TDEDiskDeviceType::LUKS))
- && !(sdevice->checkDiskStatus(TDEDiskDeviceStatus::ContainsFilesystem))
- && !(sdevice->isDiskOfType(TDEDiskDeviceType::Floppy))
- && !(sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank))
+ /* We only list volumes that...
+ * - are encrypted or
+ * - have a filesystem or
+ * - have an audio track
+ */
+ if (!sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted) &&
+ !sdevice->checkDiskStatus(TDEDiskDeviceStatus::ContainsFilesystem) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio) &&
+ !sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)
) {
//
}
+ // We also don't display devices that underlie other devices, unless they are encrypted devices
+ else if ((sdevice->checkDiskStatus(TDEDiskDeviceStatus::UsedByDevice) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) &&
+ !sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted)) ||
+ sdevice->fileSystemUsage().upper() == "RAID") {
+ //
+ }
else {
- // Do not list the LUKS backend device if it has been unlocked elsewhere
- if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS)) {
- if (sdevice->holdingDevices().count() > 0) {
- m->setHidden(true);
- }
- else {
- m->setHidden(false);
- }
- }
-
setFloppyProperties(m);
}
}
@@ -443,8 +434,6 @@ void TDEBackend::ResetProperties(TDEStorageDevice * sdevice, bool allowNotificat
setCameraProperties(m);
}
- // END
-
if ((sdevice->checkDiskStatus(TDEDiskDeviceStatus::Removable)) && (!(sdevice->checkDiskStatus(TDEDiskDeviceStatus::Inserted)))) {
kdDebug(1219) << "TDEBackend::ResetProperties for " << sdevice->uniqueID() << " device was removed from system" << endl;
RemoveDevice(sdevice);
@@ -462,27 +451,40 @@ void TDEBackend::setVolumeProperties(Medium* medium)
TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
- TDEStorageDevice * sdevice = hwdevices->findDiskByUID(medium->id());
+ TDEStorageDevice *sdevice = hwdevices->findDiskByUID(medium->id());
if (!sdevice) {
return;
}
medium->setName(generateName(sdevice->deviceNode()));
- if ((sdevice->isDiskOfType(TDEDiskDeviceType::LUKS)) || (sdevice->isDiskOfType(TDEDiskDeviceType::UnlockedCrypt))) {
+ if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) || sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted)) {
medium->setEncrypted(true);
+ medium->setLocked(!sdevice->isDiskOfType(TDEDiskDeviceType::UnlockedCrypt));
}
else {
medium->setEncrypted(false);
}
- // USAGE: mountableState(Device node, Mount point, Filesystem type, Mounted ?)
- medium->mountableState(sdevice->deviceNode(), sdevice->mountPath(), sdevice->fileSystemName(), !sdevice->mountPath().isNull());
+ if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) || sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted) ||
+ sdevice->fileSystemUsage().upper() == "RAID") {
+ // Encrypted disks or device underlying other devices are not mountable
+ medium->setMountable(false);
+ }
+ else {
+ medium->setMountable(true);
+ }
+
+ medium->setDeviceNode(sdevice->deviceNode());
+ medium->setMountPoint(sdevice->mountPath());
+ medium->setFsType(sdevice->fileSystemName());
+ medium->setMounted(!sdevice->mountPath().isEmpty());
TQString diskLabel = sdevice->diskLabel();
bool useDefaultLabel = diskLabel.isNull();
if (useDefaultLabel) {
diskLabel = i18n("%1 Removable Device").arg(sdevice->deviceFriendlySize());
}
+ diskLabel += " (" + sdevice->deviceNode() + ")";
TQString mimeType;
@@ -518,14 +520,15 @@ void TDEBackend::setVolumeProperties(Medium* medium)
// Default
mimeType = "media/cdrom" + MOUNT_MEDIA_SUFFIX;
if (useDefaultLabel) {
- diskLabel = i18n("%1 Removable Device").arg(sdevice->deviceFriendlySize());
+ diskLabel = i18n("%1 Removable Disk (%2)").arg(sdevice->deviceFriendlySize(), sdevice->deviceNode());
}
if (sdevice->isDiskOfType(TDEDiskDeviceType::CDROM)) {
mimeType = "media/cdrom" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankcd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank CD-ROM");
}
}
@@ -534,7 +537,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/cd-r" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankcd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank CD-R");
}
}
@@ -543,7 +547,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/cd-rw" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankcd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank CD-RW");
}
}
@@ -552,7 +557,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/cd-rw" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankcd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank Magneto-Optical CD");
}
}
@@ -561,7 +567,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/cd-rw" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankcd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank Mount Ranier CD-RW");
}
}
@@ -570,7 +577,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/cd-rw" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankcd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank Mount Ranier CD-RW-W");
}
}
@@ -579,7 +587,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/dvd" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankdvd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank DVD-ROM");
}
}
@@ -588,7 +597,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/dvd" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankdvd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank DVD-RAM");
}
}
@@ -597,7 +607,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/dvd" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankdvd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank DVD-R");
}
}
@@ -606,7 +617,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/dvd" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankdvd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank DVD-RW");
}
}
@@ -615,7 +627,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/dvd" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankdvd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank Dual Layer DVD-R");
}
}
@@ -624,7 +637,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/dvd" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankdvd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank Dual Layer DVD-RW");
}
}
@@ -633,7 +647,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/dvd" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankdvd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank DVD+R");
}
}
@@ -642,7 +657,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/dvd" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankdvd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank DVD+RW");
}
}
@@ -651,7 +667,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/dvd" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankdvd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank Dual Layer DVD+R");
}
}
@@ -660,7 +677,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/dvd" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankdvd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank Dual Layer DVD+RW");
}
}
@@ -669,7 +687,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/bluray" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankbluray";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank BLURAY-ROM");
}
}
@@ -678,7 +697,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/bluray" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankbluray";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank BLURAY-R");
}
}
@@ -687,7 +707,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/bluray" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankbluray";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank BLURAY-RW");
}
}
@@ -696,7 +717,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/bluray" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankbluray";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank HDDVD-ROM");
}
}
@@ -705,7 +727,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/bluray" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankbluray";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank HDDVD-R");
}
}
@@ -714,14 +737,16 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/bluray" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankbluray";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank HDDVD-RW");
}
}
if (sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio)) {
mimeType = "media/audiocd";
- medium->unmountableState("audiocd:/?device=" + sdevice->deviceNode());
+ medium->setMountable(false);
+ medium->setBaseURL("audiocd:/?device=" + sdevice->deviceNode());
diskLabel = i18n("Audio CD");
}
@@ -746,12 +771,11 @@ void TDEBackend::setVolumeProperties(Medium* medium)
diskLabel = i18n("%1 Fixed Disk (%2)").arg(sdevice->deviceFriendlySize(), sdevice->deviceNode());
}
- if (sdevice->isDiskOfType(TDEDiskDeviceType::USB)
- || sdevice->checkDiskStatus(TDEDiskDeviceStatus::Removable)
- || sdevice->checkDiskStatus(TDEDiskDeviceStatus::Hotpluggable)) {
+ if (sdevice->isDiskOfType(TDEDiskDeviceType::USB) ||
+ sdevice->checkDiskStatus(TDEDiskDeviceStatus::Removable)) {
mimeType = "media/removable" + MOUNT_MEDIA_SUFFIX;
if (useDefaultLabel) {
- diskLabel = i18n("%1 Removable Device").arg(sdevice->deviceFriendlySize());
+ diskLabel = i18n("%1 Removable Disk (%2)").arg(sdevice->deviceFriendlySize(), sdevice->deviceNode());
}
}
@@ -769,9 +793,10 @@ void TDEBackend::setVolumeProperties(Medium* medium)
}
if (sdevice->isDiskOfType(TDEDiskDeviceType::MediaDevice)) {
medium->setIconName("ipod" + MOUNTED_ICON_SUFFIX);
- if (sdevice->vendorModel().upper().contains("IPOD") && KProtocolInfo::isKnownProtocol( TQString("ipod") ) ) {
- medium->unmountableState( "ipod:/" );
- medium->mountableState(!sdevice->mountPath().isNull());
+ if (sdevice->vendorModel().upper().contains("IPOD") && KProtocolInfo::isKnownProtocol(TQString("ipod"))) {
+ medium->setBaseURL("ipod:/");
+ medium->setMountable(true);
+ medium->setMounted(!sdevice->mountPath().isEmpty());
}
}
if (sdevice->isDiskOfType(TDEDiskDeviceType::Tape)) {
@@ -782,15 +807,6 @@ void TDEBackend::setVolumeProperties(Medium* medium)
}
}
- if (!medium->needMounting()) {
- if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS)) {
- if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::UsedByDevice)) {
- // Encrypted base devices must be set to this mimetype or they won't open when the base device node is passed to the tdeioslave
- mimeType = "media/removable_mounted";
- }
- }
- }
-
medium->setLabel(diskLabel);
medium->setMimeType(mimeType);
}
@@ -813,22 +829,38 @@ bool TDEBackend::setFloppyProperties(Medium* medium)
// Any more?
if ((sdevice->isDiskOfType(TDEDiskDeviceType::Zip)) || (sdevice->isDiskOfType(TDEDiskDeviceType::Jaz))) {
medium->setName(generateName(sdevice->deviceNode()));
- if ((sdevice->isDiskOfType(TDEDiskDeviceType::LUKS)) || (sdevice->isDiskOfType(TDEDiskDeviceType::UnlockedCrypt))) {
+ if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) || sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted)) {
medium->setEncrypted(true);
+ medium->setLocked(!sdevice->isDiskOfType(TDEDiskDeviceType::UnlockedCrypt));
}
else {
medium->setEncrypted(false);
}
- // USAGE: mountableState(Device node, Mount point, Filesystem type, Mounted ?)
- medium->mountableState(sdevice->deviceNode(), sdevice->mountPath(), sdevice->fileSystemName(), !sdevice->mountPath().isNull());
+ if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) || sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted) ||
+ sdevice->fileSystemUsage().upper() == "RAID") {
+ // Encrypted disks or device underlying other devices are not mountable
+ medium->setMountable(false);
+ }
+ else {
+ medium->setMountable(true);
+ }
+
+ medium->setDeviceNode(sdevice->deviceNode());
+ medium->setMountPoint(sdevice->mountPath());
+ medium->setFsType(sdevice->fileSystemName());
+ medium->setMounted(!sdevice->mountPath().isEmpty());
}
if (sdevice->isDiskOfType(TDEDiskDeviceType::Floppy)) {
setFloppyMountState(medium);
// We don't use the routine above as floppy disks are extremely slow (we don't want them accessed at all during media listing)
- medium->mountableState(sdevice->deviceNode(), sdevice->mountPath(), sdevice->fileSystemName(), !sdevice->mountPath().isNull());
+ medium->setMountable(true);
+ medium->setDeviceNode(sdevice->deviceNode());
+ medium->setMountPoint(sdevice->mountPath());
+ medium->setFsType(sdevice->fileSystemName());
+ medium->setMounted(!sdevice->mountPath().isEmpty());
if (sdevice->mountPath().isNull()) {
medium->setMimeType("media/floppy_unmounted");
@@ -850,7 +882,7 @@ bool TDEBackend::setFloppyProperties(Medium* medium)
// Set label
TQString diskLabel = sdevice->diskLabel();
if (diskLabel.isNull()) {
- diskLabel = i18n("%1 Zip Disk").arg(sdevice->deviceFriendlySize());
+ diskLabel = i18n("%1 Zip Disk (%2)").arg(sdevice->deviceFriendlySize(), sdevice->deviceNode());
}
medium->setLabel(diskLabel);
}
@@ -885,7 +917,8 @@ void TDEBackend::setCameraProperties(Medium* medium)
device.sprintf("camera://@[usb:%s,%s]/", devNode0.ascii(), devNode1.ascii());
}
- medium->unmountableState(device);
+ medium->setMountable(false);
+ medium->setBaseURL(device);
medium->setMimeType("media/gphoto2camera");
medium->setIconName(TQString::null);
@@ -909,7 +942,11 @@ void TDEBackend::setFloppyMountState( Medium *medium )
if ((*it)->mountedFrom() == medium->deviceNode() ) {
fstype = (*it)->mountType().isNull() ? (*it)->mountType() : "auto";
mountpoint = (*it)->mountPoint();
- medium->mountableState( medium->deviceNode(), mountpoint, fstype, true );
+ medium->setMountable(true);
+ medium->setDeviceNode(medium->deviceNode());
+ medium->setMountPoint(mountpoint);
+ medium->setFsType(fstype);
+ medium->setMounted(true);
return;
}
}
@@ -997,7 +1034,7 @@ TQStringList TDEBackend::mountoptions(const TQString &name)
bool removable = false;
if (!drive_udi.isNull()) {
- removable = ((sdevice->checkDiskStatus(TDEDiskDeviceStatus::Removable)) || (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Hotpluggable)));
+ removable = sdevice->checkDiskStatus(TDEDiskDeviceStatus::Removable);
}
TQString tmp;
@@ -1173,23 +1210,19 @@ bool TDEBackend::setMountoptions(const TQString &name, const TQStringList &optio
return true;
}
-void TDEBackend::slotPasswordReady() {
- m_decryptionPassword = m_unlockDialog->getPassword();
- m_decryptPasswordValid = true;
-}
-
-void TDEBackend::slotPasswordCancel() {
- m_decryptionPassword = TQString::null;
- m_decryptPasswordValid = true;
-}
-
TQStringVariantMap TDEBackend::mount(const Medium *medium)
{
kdDebug(1219) << "TDEBackend::mount for medium " << medium->name() << endl;
TQStringVariantMap result;
- if (medium->isMounted()) {
- result["result"] = true;
+ if (!medium->isMountable()) {
+ result["errStr"] = i18n("%1 is not a mountable media.").arg(medium->deviceNode());
+ result["result"] = false;
+ return result;
+ }
+ else if (medium->isMounted()) {
+ result["errStr"] = i18n("%1 is already mounted to %2.").arg(medium->deviceNode()).arg(medium->mountPoint());
+ result["result"] = false;
return result;
}
@@ -1201,7 +1234,7 @@ TQStringVariantMap TDEBackend::mount(const Medium *medium)
data.medium = medium;
TDEIO::Job *job = TDEIO::mount(false, 0, medium->deviceNode(), mountPoint);
- connect(job, TQT_SIGNAL(result(TDEIO::Job*)), TQT_SLOT(slotResult(TDEIO::Job*)));
+ connect(job, TQ_SIGNAL(result(TDEIO::Job*)), TQ_SLOT(slotResult(TDEIO::Job*)));
mount_jobs[job] = &data;
// The caller expects the device to be mounted when the function
// completes. Thus block until the job completes.
@@ -1222,7 +1255,7 @@ TQStringVariantMap TDEBackend::mount(const Medium *medium)
TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
TDEStorageDevice *sdevice = hwdevices->findDiskByUID(medium->id());
if (!sdevice) {
- result["errStr"] = i18n("Internal error. Couldn't find medium.");
+ result["errStr"] = i18n("Internal error. Couldn't find medium id %1.").arg(medium->id());
result["result"] = false;
return result;
}
@@ -1242,99 +1275,13 @@ TQStringVariantMap TDEBackend::mount(const Medium *medium)
}
TQString qerror;
- if (!medium->isEncrypted()) {
- // normal volume
- TQStringVariantMap mountResult = sdevice->mountDevice(diskLabel, valids);
- TQString mountedPath = mountResult.contains("mountPath") ? mountResult["mountPath"].toString() : TQString::null;
- if (mountedPath.isEmpty()) {
- qerror = i18n("Unable to mount this device.");
- TQString errStr = mountResult.contains("errStr") ? mountResult["errStr"].toString() : TQString::null;
- if (!errStr.isEmpty()) {
- qerror.append(i18n("<p>Technical details:<br>").append(errStr));
- }
- }
- }
- else {
- TQString iconName = medium->iconName();
- if (iconName.isEmpty())
- {
- TQString mime = medium->mimeType();
- iconName = KMimeType::mimeType(mime)->icon(mime, false);
- }
-
- bool continue_trying_to_decrypt = true;
- while (continue_trying_to_decrypt == true) {
- m_decryptPasswordValid = false;
-
- m_unlockDialog = new Dialog(sdevice->deviceNode(), iconName);
- m_unlockDialog->show();
-
- connect(m_unlockDialog, TQT_SIGNAL (user1Clicked()), this, TQT_SLOT (slotPasswordReady()));
- connect(m_unlockDialog, TQT_SIGNAL (cancelClicked()), this, TQT_SLOT (slotPasswordCancel()));
- connect(this, TQT_SIGNAL (signalDecryptionPasswordError(TQString)), m_unlockDialog, TQT_SLOT (slotDialogError(TQString)));
-
- while (m_decryptPasswordValid == false) {
- tqApp->processEvents();
- }
-
- m_unlockDialog->setEnabled(false);
- tqApp->processEvents();
-
- if (m_decryptionPassword.isNull()) {
- delete m_unlockDialog;
- result["errStr"] = i18n("Decryption aborted");
- result["result"] = false;
- return result;
- }
- else {
- // Just for some added fun, if udev emits a medium change event, which I then forward, with mounted==0, it stops the MediaProtocol::listDir method dead in its tracks,
- // and therefore the media:/ tdeioslave won't refresh after the encrypted device mount
- // Therefore, I need to ignore all change events on this device during the mount process and hope nothing bad happens as a result!
- if (!m_ignoreDeviceChangeEvents.contains(sdevice->uniqueID())) {
- m_ignoreDeviceChangeEvents.append(sdevice->uniqueID());
- }
-
- // mount encrypted volume with password
- TQStringVariantMap mountResult = sdevice->mountEncryptedDevice(m_decryptionPassword, diskLabel, valids);
- TQString mountedPath = mountResult.contains("mountPath") ? mountResult["mountPath"].toString() : TQString::null;
- if (mountedPath.isEmpty()) {
- if (mountResult.contains("retCode") && mountResult["retCode"].toInt() == 0) {
- // Mounting was successful
- // Because the TDE hardware backend is event driven it might take a little while for the new enlock mapped device to show up
- // Wait up to 30 seconds for it to appear...
- for (int i=0;i<300;i++) {
- mountedPath = sdevice->mountPath();
- if (!mountedPath.isEmpty()) {
- break;
- }
- tqApp->processEvents(50);
- usleep(50000);
- }
- }
- }
- if (mountedPath.isEmpty()) {
- if (mountResult.contains("retCode") && mountResult["retCode"].toInt() == 25600) {
- // Probable LUKS failure
- // Retry
- m_unlockDialog->setEnabled(true);
- continue_trying_to_decrypt = true;
- }
- else {
- qerror = i18n("Cannot mount encrypted locked drives!");
- qerror = i18n("Unable to mount this device.");
- TQString errStr = mountResult.contains("errStr") ? mountResult["errStr"].toString() : TQString::null;
- if (!errStr.isEmpty()) {
- qerror.append(i18n("<p>Technical details:<br>").append(errStr));
- }
- continue_trying_to_decrypt = false;
- }
- }
- else {
- continue_trying_to_decrypt = false;
- }
-
- delete m_unlockDialog;
- }
+ TQStringVariantMap mountResult = sdevice->mountDevice(diskLabel, valids);
+ TQString mountedPath = mountResult.contains("mountPath") ? mountResult["mountPath"].toString() : TQString::null;
+ if (mountedPath.isEmpty()) {
+ qerror = i18n("<b>Unable to mount this device.</b>");
+ TQString errStr = mountResult.contains("errStr") ? mountResult["errStr"].toString() : TQString::null;
+ if (!errStr.isEmpty()) {
+ qerror.append(i18n("<p>Technical details:<br>").append(errStr));
}
}
@@ -1373,16 +1320,20 @@ TQStringVariantMap TDEBackend::unmount(const TQString &id)
kdDebug(1219) << "TDEBackend::unmount for id " << id << endl;
TQStringVariantMap result;
-
- const Medium* medium = m_mediaList.findById(id);
+ const Medium *medium = m_mediaList.findById(id);
if (!medium) {
result["errStr"] = i18n("No such medium: %1").arg(id);
result["result"] = false;
return result;
}
-
- if (!medium->isMounted()) {
- result["result"] = true;
+ else if (!medium->isMountable()) {
+ result["errStr"] = i18n("%1 is not a mountable media.").arg(medium->deviceNode());
+ result["result"] = false;
+ return result;
+ }
+ else if (!medium->isMounted()) {
+ result["errStr"] = i18n("%1 is already unmounted.").arg(medium->deviceNode());
+ result["result"] = false;
return result;
}
@@ -1394,7 +1345,7 @@ TQStringVariantMap TDEBackend::unmount(const TQString &id)
data.medium = medium;
TDEIO::Job *job = TDEIO::unmount( medium->mountPoint(), false );
- connect(job, TQT_SIGNAL(result(TDEIO::Job*)), TQT_SLOT(slotResult(TDEIO::Job*)));
+ connect(job, TQ_SIGNAL(result(TDEIO::Job*)), TQ_SLOT(slotResult(TDEIO::Job*)));
mount_jobs[job] = &data;
// The caller expects the device to be unmounted when the function
// completes. Thus block until the job completes.
@@ -1415,7 +1366,7 @@ TQStringVariantMap TDEBackend::unmount(const TQString &id)
TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
TDEStorageDevice *sdevice = hwdevices->findDiskByUID(medium->id());
if (!sdevice) {
- result["errStr"] = i18n("Internal error. Couldn't find medium.");
+ result["errStr"] = i18n("Internal error. Couldn't find medium id %1.").arg(medium->id());
result["result"] = false;
return result;
}
@@ -1428,7 +1379,7 @@ TQStringVariantMap TDEBackend::unmount(const TQString &id)
TQStringVariantMap unmountResult = sdevice->unmountDevice();
if (unmountResult["result"].toBool() == false) {
// Unmount failed!
- qerror = i18n("Unfortunately, the device <b>%1</b> (%2) named <b>'%3'</b> and currently mounted at "
+ qerror = i18n("The device <b>%1</b> (%2) named <b>'%3'</b> and currently mounted at "
"<b>%4</b> could not be unmounted. ").arg("system:/media/" + medium->name(), medium->deviceNode(),
medium->prettyLabel(), medium->prettyBaseURL().pathOrURL());
TQString errStr = unmountResult.contains("errStr") ? unmountResult["errStr"].toString() : TQString::null;
@@ -1441,7 +1392,7 @@ TQStringVariantMap TDEBackend::unmount(const TQString &id)
// Failed as BUSY
TQString processesUsingDev = listUsingProcesses(medium);
if (!processesUsingDev.isNull()) {
- if (KMessageBox::warningYesNo(0, i18n("<qt>The device <b>%1</b> (%2) named <b>'%3'</b> and currently "
+ if (KMessageBox::warningYesNo(0, i18n("The device <b>%1</b> (%2) named <b>'%3'</b> and currently "
"mounted at <b>%4</b> can not be unmounted at this time.<p>%5<p><b>Would you like to forcibly "
"terminate these processes?</b><br><i>All unsaved data would be lost</i>").arg("system:/media/" +
medium->name()).arg(medium->deviceNode()).arg(medium->prettyLabel()).arg(medium->prettyBaseURL().pathOrURL())
@@ -1450,7 +1401,7 @@ TQStringVariantMap TDEBackend::unmount(const TQString &id)
unmountResult = sdevice->unmountDevice();
if (unmountResult["result"].toBool() == false) {
// Unmount failed!
- qerror = i18n("Unfortunately, the device <b>%1</b> (%2) named <b>'%3'</b> and currently mounted at "
+ qerror = i18n("The device <b>%1</b> (%2) named <b>'%3'</b> and currently mounted at "
"<b>%4</b> could not be unmounted. ").arg("system:/media/" + medium->name(), medium->deviceNode(),
medium->prettyLabel(), medium->prettyBaseURL().pathOrURL());
TQString errStr = unmountResult.contains("errStr") ? unmountResult["errStr"].toString() : TQString::null;
@@ -1476,10 +1427,225 @@ TQStringVariantMap TDEBackend::unmount(const TQString &id)
m_mediaList.removeMedium(uid, true);
}
+ ResetProperties(sdevice, false, true);
+ result["result"] = true;
+ return result;
+}
+
+TQStringVariantMap TDEBackend::unlock(const TQString &id, const TQString &password)
+{
+ kdDebug(1219) << "TDEBackend::unlock for id " << id << endl;
+
+ TQStringVariantMap result;
+ const Medium *medium = m_mediaList.findById(id);
+ if (!medium) {
+ result["errStr"] = i18n("No such medium: %1").arg(id);
+ result["result"] = false;
+ return result;
+ }
+ else if (!medium->isEncrypted()) {
+ result["errStr"] = i18n("%1 is not an encrypted media.").arg(medium->deviceNode());
+ result["result"] = false;
+ return result;
+ }
+ else if (!medium->needUnlocking()) {
+ result["errStr"] = i18n("%1 is already unlocked.").arg(medium->deviceNode());
+ result["result"] = false;
+ return result;
+ }
+
+ TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
+ TDEStorageDevice *sdevice = hwdevices->findDiskByUID(medium->id());
+ if (!sdevice) {
+ result["errStr"] = i18n("Internal error. Couldn't find medium id %1.").arg(medium->id());
+ result["result"] = false;
+ return result;
+ }
+
+ TQStringVariantMap unlockResult = sdevice->unlockDevice(password);
+ if (unlockResult["result"].toBool() == false) {
+ TQString qerror = i18n("<b>Unable to unlock the device.</b>");
+ TQString errStr = unlockResult.contains("errStr") ? unlockResult["errStr"].toString() : TQString::null;
+ if (!errStr.isEmpty()) {
+ qerror.append(i18n("<p>Technical details:<br>").append(errStr));
+ result["errStr"] = qerror;
+ result["result"] = false;
+ return result;
+ }
+ }
+
+ ResetProperties(sdevice, false, true);
+ result["result"] = true;
+ return result;
+}
+
+TQStringVariantMap TDEBackend::lock(const TQString &id, bool releaseHolders)
+{
+ kdDebug(1219) << "TDEBackend::lock for id " << id << ", release holders "
+ << releaseHolders << endl;
+
+ TQStringVariantMap result;
+
+ const Medium *medium = m_mediaList.findById(id);
+ if (!medium) {
+ result["errStr"] = i18n("No such medium: %1").arg(id);
+ result["result"] = false;
+ return result;
+ }
+ else if (!medium->isEncrypted()) {
+ result["errStr"] = i18n("%1 is not an encrypted media.").arg(medium->deviceNode());
+ result["result"] = false;
+ return result;
+ }
+ else if (medium->needUnlocking()) {
+ result["errStr"] = i18n("%1 is already locked.").arg(medium->deviceNode());
+ result["result"] = false;
+ return result;
+ }
+
+ TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
+ TDEStorageDevice *sdevice = hwdevices->findDiskByUID(medium->id());
+ if (!sdevice) {
+ result["errStr"] = i18n("Internal error. Couldn't find medium id %1.").arg(medium->id());
+ result["result"] = false;
+ return result;
+ }
+
+ // Release device holders if requested
+ if (releaseHolders)
+ {
+ releaseHolderDevices(medium->deviceNode(), false);
+ }
+
+ TQStringVariantMap lockResult = sdevice->lockDevice();
+ if (lockResult["result"].toBool() == false) {
+ TQString qerror = i18n("<b>Unable to lock the device.</b>");
+ TQString errStr = lockResult.contains("errStr") ? lockResult["errStr"].toString() : TQString::null;
+ if (!errStr.isEmpty()) {
+ qerror.append(i18n("<p>Technical details:<br>").append(errStr));
+ result["errStr"] = qerror;
+ result["result"] = false;
+ return result;
+ }
+ }
+
+ ResetProperties(sdevice, false, true);
result["result"] = true;
return result;
}
+TQStringVariantMap TDEBackend::eject(const TQString &id)
+{
+ kdDebug(1219) << "TDEBackend::eject for id " << id << endl;
+
+ TQStringVariantMap result;
+
+ const Medium *medium = m_mediaList.findById(id);
+ if (!medium)
+ {
+ result["errStr"] = i18n("No such medium: %1").arg(id);
+ result["result"] = false;
+ return result;
+ }
+
+ TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
+ TDEStorageDevice *sdevice = hwdevices->findDiskByUID(medium->id());
+ if (!sdevice)
+ {
+ result["errStr"] = i18n("Internal error. Couldn't find medium id %1.").arg(medium->id());
+ result["result"] = false;
+ return result;
+ }
+
+ TQStringVariantMap ejectResult = sdevice->ejectDrive();
+ if (ejectResult["result"].toBool() == false)
+ {
+ TQString qerror = i18n("<b>Unable to eject the device.</b>");
+ TQString errStr = ejectResult.contains("errStr") ? ejectResult["errStr"].toString() : TQString::null;
+ if (!errStr.isEmpty())
+ {
+ qerror.append(i18n("<p>Technical details:<br>").append(errStr));
+ result["errStr"] = qerror;
+ result["result"] = false;
+ return result;
+ }
+ }
+
+ result["result"] = true;
+ return result;
+}
+
+TQStringVariantMap TDEBackend::safeRemove(const TQString &id)
+{
+ kdDebug(1219) << "TDEBackend::safeRemove for id " << id << endl;
+
+ TQStringVariantMap result;
+
+ const Medium *medium = m_mediaList.findById(id);
+ if (!medium)
+ {
+ result["errStr"] = i18n("No such medium: %1").arg(id);
+ result["result"] = false;
+ return result;
+ }
+
+ releaseHolderDevices(medium->deviceNode(), true);
+ return eject(id);
+}
+
+void TDEBackend::releaseHolderDevices(const TQString &deviceNode, bool handleThis)
+{
+ kdDebug(1219) << "TDEBackend::releaseHolderDevices for node " << deviceNode
+ << ", handle this " << (handleThis ? "yes" : "no") << endl;
+
+ const Medium *medium = m_mediaList.findByNode(deviceNode);
+ if (!medium)
+ {
+ return;
+ }
+
+ // Scan the holding devices and unmount/lock them if possible
+ TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
+ TDEStorageDevice *sdevice = hwdevices->findDiskByUID(medium->id());
+ if (sdevice)
+ {
+ TQStringList holdingDeviceList = sdevice->holdingDevices();
+ for (TQStringList::Iterator holdingDevIt = holdingDeviceList.begin(); holdingDevIt != holdingDeviceList.end(); ++holdingDevIt)
+ {
+ TDEGenericDevice *hwHolderDevice = hwdevices->findBySystemPath(*holdingDevIt);
+ if (hwHolderDevice->type() == TDEGenericDeviceType::Disk)
+ {
+ TDEStorageDevice *holderSDevice = static_cast<TDEStorageDevice*>(hwHolderDevice);
+ const Medium *holderMedium = m_mediaList.findByNode(holderSDevice->deviceNode());
+ if (holderMedium && !holderMedium->id().isEmpty())
+ {
+ releaseHolderDevices(holderMedium->deviceNode(), true);
+ }
+ }
+ }
+ }
+
+ if (handleThis)
+ {
+ // Unmount if necessary
+ if (medium->isMountable() && medium->isMounted())
+ {
+ unmount(medium->id());
+ // Must process udev events before continuing, to make sure all
+ // affected devices are properly updated
+ tqApp->processEvents();
+ }
+ // Lock if necessary.
+ if (medium->isEncrypted() && !medium->isLocked())
+ {
+ lock(medium->id(), false);
+ // Must process udev events before continuing, to make sure all
+ // affected devices are properly updated
+ tqApp->processEvents();
+ }
+ }
+}
+
void TDEBackend::slotResult(TDEIO::Job *job)
{
TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
@@ -1491,8 +1657,7 @@ void TDEBackend::slotResult(TDEIO::Job *job)
if (job->error() == TDEIO::ERR_COULD_NOT_UNMOUNT) {
TQString proclist(listUsingProcesses(medium));
- qerror = "<qt>";
- qerror += "<p>" + i18n("Unfortunately, the device <b>%1</b> (%2) named <b>'%3'</b> and "
+ qerror += "<p>" + i18n("The device <b>%1</b> (%2) named <b>'%3'</b> and "
"currently mounted at <b>%4</b> could not be unmounted. ").arg(
"system:/media/" + medium->name(),
medium->deviceNode(),
@@ -1504,7 +1669,6 @@ void TDEBackend::slotResult(TDEIO::Job *job)
if (!proclist.isEmpty()) {
qerror += proclist;
}
- qerror += "</qt>";
} else if (job->error()) {
qerror = job->errorText();
}