tdeioslave media: added LOCKED property to Medium class.

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

@ -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

@ -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();

@ -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)));

@ -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())
{

@ -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);

@ -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()));

Loading…
Cancel
Save