tdeioslave media: fixed handling of mountable state for encrypted devices.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/35/head
Michele Calgaro 5 years ago
parent d34f23f403
commit b54fcda719
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -179,7 +179,14 @@ void Medium::setDeviceNode(const TQString &deviceNode)
void Medium::setMountPoint(const TQString &mountPoint)
{
m_properties[MOUNT_POINT] = mountPoint;
if (isMountable())
{
m_properties[MOUNT_POINT] = mountPoint;
}
else
{
m_properties[MOUNT_POINT] = TQString::null;
}
}
void Medium::setFsType(const TQString &fsType)
@ -189,7 +196,14 @@ void Medium::setFsType(const TQString &fsType)
void Medium::setMounted(bool mounted)
{
m_properties[MOUNTED] = mounted ? "true" : "false";
if (isMountable())
{
m_properties[MOUNTED] = mounted ? "true" : "false";
}
else
{
m_properties[MOUNTED] = "false";
}
}
void Medium::setBaseURL(const TQString &baseURL)

@ -148,7 +148,7 @@ bool MediaImpl::listMedia(TQValueList<TDEIO::UDSEntry> &list)
Medium::MList::const_iterator it = media.begin();
Medium::MList::const_iterator end = media.end();
for(; it!=end; ++it)
for(; it != end; ++it)
{
if (!(*it).hidden()) {
entry.clear();
@ -365,6 +365,11 @@ void MediaImpl::slotStatResult(TDEIO::Job *job)
TDEIO::UDSEntry MediaImpl::extractUrlInfos(const KURL &url)
{
if (url.isEmpty())
{
return TDEIO::UDSEntry();
}
m_entryBuffer.clear();
TDEIO::StatJob *job = TDEIO::stat(url, false);
@ -448,7 +453,7 @@ void MediaImpl::createMediumEntry(TDEIO::UDSEntry& entry,
else
{
KURL url = medium.prettyBaseURL();
entry+= extractUrlInfos(url);
entry += extractUrlInfos(url);
}
}

@ -506,13 +506,13 @@ void HALBackend::setVolumeProperties(Medium* medium)
medium->setEncrypted(true);
char* clearUdi = libhal_volume_crypto_get_clear_volume_udi(m_halContext, halVolume);
TQString clearUdiString;
TQString clearUdiString;
if (clearUdi != NULL) {
kdDebug(1219) << "HALBackend::setVolumeProperties : crypto clear volume avail - " << clearUdi << endl;
halClearVolume = libhal_volume_from_udi(m_halContext, clearUdi);
// ignore if halClearVolume is NULL -> just not unlocked in this case
clearUdiString = clearUdi;
libhal_free_string(clearUdi);
clearUdiString = clearUdi;
libhal_free_string(clearUdi);
}
if (halClearVolume)
@ -660,8 +660,6 @@ void HALBackend::setVolumeProperties(Medium* medium)
case LIBHAL_DRIVE_TYPE_PORTABLE_AUDIO_PLAYER:
{
medium->setIconName("ipod" + MOUNTED_ICON_SUFFIX);
medium->setMountable(false);
if (libhal_device_get_property_QString(m_halContext, driveUdi.latin1(), "info.product") == "iPod" &&
KProtocolInfo::isKnownProtocol( TQString("ipod") ) )
{

@ -135,7 +135,6 @@ bool MediaList::changeMediumState(const Medium &medium, bool allowNotification)
m->setMountable(medium.isMountable());
if (medium.isMountable())
{
m->setMountable(true);
m->setDeviceNode(medium.deviceNode());
m->setClearDeviceUdi(medium.clearDeviceUdi());
m->setMountPoint(medium.mountPoint());
@ -226,6 +225,11 @@ bool MediaList::changeMediumState(const TQString &id,
Medium *medium = m_idMap[id];
if (medium->deviceNode().isEmpty() || !medium->isMountable())
{
return false;
}
medium->setMountable(true);
medium->setDeviceNode(deviceNode);
medium->setMountPoint(mountPoint);
@ -267,13 +271,13 @@ bool MediaList::changeMediumState(const TQString &id, bool mounted,
Medium *medium = m_idMap[id];
medium->setMountable(true);
medium->setMounted(mounted);
if (medium->deviceNode().isEmpty() || !medium->isMountable())
{
return false;
}
medium->setMounted(mounted);
if (!mimeType.isEmpty())
{
medium->setMimeType( mimeType );

@ -452,7 +452,7 @@ void TDEBackend::setVolumeProperties(Medium* medium)
TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
TDEStorageDevice * sdevice = hwdevices->findDiskByUID(medium->id());
TDEStorageDevice *sdevice = hwdevices->findDiskByUID(medium->id());
if (!sdevice) {
return;
}
@ -465,7 +465,15 @@ void TDEBackend::setVolumeProperties(Medium* medium)
medium->setEncrypted(false);
}
medium->setMountable(true);
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());
@ -785,7 +793,6 @@ void TDEBackend::setVolumeProperties(Medium* medium)
}
if (sdevice->isDiskOfType(TDEDiskDeviceType::MediaDevice)) {
medium->setIconName("ipod" + MOUNTED_ICON_SUFFIX);
medium->setMountable(false);
if (sdevice->vendorModel().upper().contains("IPOD") && KProtocolInfo::isKnownProtocol(TQString("ipod"))) {
medium->setBaseURL("ipod:/");
medium->setMountable(true);
@ -829,7 +836,15 @@ bool TDEBackend::setFloppyProperties(Medium* medium)
medium->setEncrypted(false);
}
medium->setMountable(true);
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());

@ -81,9 +81,9 @@ MountHelper::MountHelper() : TDEApplication()
return;
}
if (!medium.isMountable() && !args->isSet("e") && !args->isSet("s"))
if (!medium.isMountable() && !medium.isEncrypted() && !args->isSet("e") && !args->isSet("s"))
{
m_errorStr = i18n("%1 is not a mountable media.").arg(url.prettyURL());
m_errorStr = i18n("%1 is not a mountable or encrypted media.").arg(url.prettyURL());
TQTimer::singleShot(0, this, TQT_SLOT(error()));
return;
}

Loading…
Cancel
Save