diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2019-08-25 14:34:16 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2020-10-17 10:48:29 +0800 |
commit | 7c6e00a43ce3626e0450954ab1234c78048fcb58 (patch) | |
tree | b732915f07a411b97c02734de6be5f68827e7198 | |
parent | b54fcda719b94c629c11e9b3462f2c9a2c5a9666 (diff) | |
download | tdebase-7c6e00a43ce3626e0450954ab1234c78048fcb58.tar.gz tdebase-7c6e00a43ce3626e0450954ab1234c78048fcb58.zip |
tdeioslave media: added LOCKED property to Medium class.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
-rw-r--r-- | tdeioslave/media/libmediacommon/medium.cpp | 23 | ||||
-rw-r--r-- | tdeioslave/media/libmediacommon/medium.h | 19 | ||||
-rw-r--r-- | tdeioslave/media/mediamanager/halbackend.cpp | 5 | ||||
-rw-r--r-- | tdeioslave/media/mediamanager/medialist.cpp | 2 | ||||
-rw-r--r-- | tdeioslave/media/mediamanager/tdehardwarebackend.cpp | 2 | ||||
-rw-r--r-- | tdeioslave/media/mounthelper/tdeio_media_mounthelper.cpp | 2 |
6 files changed, 37 insertions, 16 deletions
diff --git a/tdeioslave/media/libmediacommon/medium.cpp b/tdeioslave/media/libmediacommon/medium.cpp index c185a8c9f..cb06a5eb8 100644 --- a/tdeioslave/media/libmediacommon/medium.cpp +++ b/tdeioslave/media/libmediacommon/medium.cpp @@ -43,6 +43,7 @@ void Medium::initMedium() m_properties += TQString::null; // CLEAR_DEVICE_UDI m_properties += "false"; // HIDDEN m_properties += "false"; // SOFT_HIDDEN + m_properties += "false"; // LOCKED } Medium::Medium(const TQString id, TQString uuid, const TQString name) @@ -86,6 +87,7 @@ const Medium Medium::create(const TQStringList &properties) m.m_properties[CLEAR_DEVICE_UDI] = properties[CLEAR_DEVICE_UDI]; m.m_properties[HIDDEN] = properties[HIDDEN]; m.m_properties[SOFT_HIDDEN] = properties[SOFT_HIDDEN]; + m.m_properties[LOCKED] = properties[LOCKED]; } return m; @@ -221,9 +223,13 @@ void Medium::setIconName(const TQString &iconName) m_properties[ICON_NAME] = iconName; } -void Medium::setEncrypted(bool state) +void Medium::setEncrypted(bool encrypted) { - m_properties[ENCRYPTED] = ( state ? "true" : "false" ); + m_properties[ENCRYPTED] = encrypted ? "true" : "false"; + if (!encrypted) + { + setLocked(false); + } } void Medium::setClearDeviceUdi(const TQString &clearDeviceUdi) @@ -233,12 +239,17 @@ void Medium::setClearDeviceUdi(const TQString &clearDeviceUdi) void Medium::setHidden(bool state) { - m_properties[HIDDEN] = ( state ? "true" : "false" ); + m_properties[HIDDEN] = state ? "true" : "false"; } void Medium::setSoftHidden(bool state) { - m_properties[SOFT_HIDDEN] = ( state ? "true" : "false" ); + m_properties[SOFT_HIDDEN] = state ? "true" : "false"; +} + +void Medium::setLocked(bool locked) +{ + m_properties[LOCKED] = locked ? "true" : "false"; } bool Medium::needMounting() const @@ -246,9 +257,9 @@ bool Medium::needMounting() const return isMountable() && !isMounted(); } -bool Medium::needDecryption() const +bool Medium::needUnlocking() const { - return isEncrypted() && clearDeviceUdi().isEmpty(); + return isEncrypted() && isLocked(); } KURL Medium::prettyBaseURL() const diff --git a/tdeioslave/media/libmediacommon/medium.h b/tdeioslave/media/libmediacommon/medium.h index 7e7f2b04a..49a7fb980 100644 --- a/tdeioslave/media/libmediacommon/medium.h +++ b/tdeioslave/media/libmediacommon/medium.h @@ -46,7 +46,8 @@ public: static const uint CLEAR_DEVICE_UDI = 14; static const uint HIDDEN = 15; static const uint SOFT_HIDDEN = 16; - static const uint PROPERTIES_COUNT = 17; + static const uint LOCKED = 17; + static const uint PROPERTIES_COUNT = 18; static const TQString SEPARATOR; Medium(const TQString id, TQString uuid, const TQString name); @@ -60,21 +61,22 @@ public: TQString name() const { return m_properties[NAME]; } TQString label() const { return m_properties[LABEL]; } TQString userLabel() const { return m_properties[USER_LABEL]; } - bool isMountable() const { return m_properties[MOUNTABLE]=="true"; } + bool isMountable() const { return m_properties[MOUNTABLE] == "true"; } TQString deviceNode() const { return m_properties[DEVICE_NODE]; } TQString mountPoint() const { return m_properties[MOUNT_POINT]; } TQString fsType() const { return m_properties[FS_TYPE]; } - bool isMounted() const { return m_properties[MOUNTED]=="true"; } + bool isMounted() const { return m_properties[MOUNTED] == "true"; } TQString baseURL() const { return m_properties[BASE_URL]; } TQString mimeType() const { return m_properties[MIME_TYPE]; } TQString iconName() const { return m_properties[ICON_NAME]; } - bool isEncrypted() const { return m_properties[ENCRYPTED]=="true"; }; + bool isEncrypted() const { return m_properties[ENCRYPTED] == "true"; }; TQString clearDeviceUdi() const { return m_properties[CLEAR_DEVICE_UDI]; }; - bool hidden() const { return m_properties[HIDDEN]=="true"; }; - bool softHidden() const { return m_properties[SOFT_HIDDEN]=="true"; }; + bool hidden() const { return m_properties[HIDDEN] == "true"; }; + bool softHidden() const { return m_properties[SOFT_HIDDEN] == "true"; }; + bool isLocked() const { return m_properties[LOCKED] == "true"; }; bool needMounting() const; - bool needDecryption() const; + bool needUnlocking() const; KURL prettyBaseURL() const; TQString prettyLabel() const; @@ -89,10 +91,11 @@ public: void setBaseURL(const TQString &baseURL); void setMimeType(const TQString &mimeType); void setIconName(const TQString &iconName); - void setEncrypted(bool state); + void setEncrypted(bool encrypted); void setClearDeviceUdi(const TQString &clearDeviceUdi); void setHidden(bool state); void setSoftHidden(bool state); + void setLocked(bool locked); Medium(); diff --git a/tdeioslave/media/mediamanager/halbackend.cpp b/tdeioslave/media/mediamanager/halbackend.cpp index 6badc33c3..190dda774 100644 --- a/tdeioslave/media/mediamanager/halbackend.cpp +++ b/tdeioslave/media/mediamanager/halbackend.cpp @@ -517,6 +517,7 @@ void HALBackend::setVolumeProperties(Medium* medium) if (halClearVolume) { + medium->setLocked(false); medium->setMountable(true); medium->setDeviceNode(libhal_volume_get_device_file(halVolume)); medium->setClearDeviceUdi(clearUdiString); @@ -526,7 +527,8 @@ void HALBackend::setVolumeProperties(Medium* medium) } else { - medium->setMountable(true); + medium->setLocked(true); + medium->setMountable(false); medium->setDeviceNode(libhal_volume_get_device_file(halVolume)); medium->setClearDeviceUdi(TQString::null); medium->setMountPoint(TQString::null); @@ -537,6 +539,7 @@ void HALBackend::setVolumeProperties(Medium* medium) else { kdDebug(1219) << "HALBackend::setVolumeProperties : normal volume" << endl; + medium->setEncrypted(false); medium->setMountable(true); medium->setDeviceNode(libhal_volume_get_device_file(halVolume)); medium->setMountPoint(TQString::fromUtf8(libhal_volume_get_mount_point(halVolume))); diff --git a/tdeioslave/media/mediamanager/medialist.cpp b/tdeioslave/media/mediamanager/medialist.cpp index b2dd84c60..8ea9aec50 100644 --- a/tdeioslave/media/mediamanager/medialist.cpp +++ b/tdeioslave/media/mediamanager/medialist.cpp @@ -132,6 +132,8 @@ bool MediaList::changeMediumState(const Medium &medium, bool allowNotification) Medium *m = m_idMap[medium.id()]; + m->setEncrypted(medium.isEncrypted()); + m->setLocked(medium.isLocked()); m->setMountable(medium.isMountable()); if (medium.isMountable()) { diff --git a/tdeioslave/media/mediamanager/tdehardwarebackend.cpp b/tdeioslave/media/mediamanager/tdehardwarebackend.cpp index 74180ca9a..bcd610ef4 100644 --- a/tdeioslave/media/mediamanager/tdehardwarebackend.cpp +++ b/tdeioslave/media/mediamanager/tdehardwarebackend.cpp @@ -460,6 +460,7 @@ void TDEBackend::setVolumeProperties(Medium* medium) medium->setName(generateName(sdevice->deviceNode())); if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) || sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted)) { medium->setEncrypted(true); + medium->setLocked(!sdevice->isDiskOfType(TDEDiskDeviceType::UnlockedCrypt)); } else { medium->setEncrypted(false); @@ -831,6 +832,7 @@ bool TDEBackend::setFloppyProperties(Medium* medium) medium->setName(generateName(sdevice->deviceNode())); if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) || sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted)) { medium->setEncrypted(true); + medium->setLocked(!sdevice->isDiskOfType(TDEDiskDeviceType::UnlockedCrypt)); } else { medium->setEncrypted(false); diff --git a/tdeioslave/media/mounthelper/tdeio_media_mounthelper.cpp b/tdeioslave/media/mounthelper/tdeio_media_mounthelper.cpp index d3fb4ac35..564934667 100644 --- a/tdeioslave/media/mounthelper/tdeio_media_mounthelper.cpp +++ b/tdeioslave/media/mounthelper/tdeio_media_mounthelper.cpp @@ -137,7 +137,7 @@ MountHelper::MountHelper() : TDEApplication() TQTimer::singleShot(0, this, TQT_SLOT(error())); return; } - if (!medium.needDecryption()) + if (!medium.needUnlocking()) { m_errorStr = i18n("%1 is already unlocked.").arg(url.prettyURL()); TQTimer::singleShot(0, this, TQT_SLOT(error())); |