summaryrefslogtreecommitdiffstats
path: root/tdecore
diff options
context:
space:
mode:
authorMichele Calgaro <[email protected]>2021-08-11 14:36:14 +0900
committerMichele Calgaro <[email protected]>2021-08-13 16:01:01 +0900
commitf159fa61a972641944adc614d33baf5e52ac5e0e (patch)
treea00705c6f65529f40f90f622ccd8cc4cb60f5c89 /tdecore
parentde4f27a2eea6f7b8e723dc8966a34ce1de0952d0 (diff)
downloadtdelibs-f159fa61a972641944adc614d33baf5e52ac5e0e.tar.gz
tdelibs-f159fa61a972641944adc614d33baf5e52ac5e0e.zip
tdehw lib: reworked device notifications to avoid repeated scanning of devices.
Signed-off-by: Michele Calgaro <[email protected]>
Diffstat (limited to 'tdecore')
-rw-r--r--tdecore/tdehw/tdehardwaredevices.cpp111
-rw-r--r--tdecore/tdehw/tdehardwaredevices.h12
-rw-r--r--tdecore/tdehw/tdestoragedevice.cpp115
-rw-r--r--tdecore/tdehw/tdestoragedevice.h15
4 files changed, 84 insertions, 169 deletions
diff --git a/tdecore/tdehw/tdehardwaredevices.cpp b/tdecore/tdehw/tdehardwaredevices.cpp
index b25020c04..dbeffad6c 100644
--- a/tdecore/tdehw/tdehardwaredevices.cpp
+++ b/tdecore/tdehw/tdehardwaredevices.cpp
@@ -210,7 +210,7 @@ TDEHardwareDevices::TDEHardwareDevices() {
m_batteryWatchTimer = new TQTimer(this);
connect( m_batteryWatchTimer, SIGNAL(timeout()), this, SLOT(processBatteryDevices()) );
- // Update internal device information
+ // Update internal device information.
queryHardwareInformation();
}
}
@@ -281,18 +281,21 @@ void TDEHardwareDevices::setBatteryUpdatesEnabled(bool enable) {
}
}
-void TDEHardwareDevices::rescanDeviceInformation(TDEGenericDevice* hwdevice) {
- rescanDeviceInformation(hwdevice, true);
-}
-
-void TDEHardwareDevices::rescanDeviceInformation(TDEGenericDevice* hwdevice, bool regenerateDeviceTree) {
- struct udev_device *dev;
- dev = udev_device_new_from_syspath(m_udevStruct, hwdevice->systemPath().ascii());
- updateExistingDeviceInformation(hwdevice);
+void TDEHardwareDevices::rescanDeviceInformation(TDEGenericDevice* hwdevice, udev_device* dev, bool regenerateDeviceTree) {
+ bool toUnref = false;
+ if (!dev)
+ {
+ dev = udev_device_new_from_syspath(m_udevStruct, hwdevice->systemPath().ascii());
+ toUnref = true;
+ }
+ updateExistingDeviceInformation(hwdevice, dev);
if (regenerateDeviceTree) {
updateParentDeviceInformation(hwdevice); // Update parent/child tables for this device
}
- udev_device_unref(dev);
+ if (toUnref)
+ {
+ udev_device_unref(dev);
+ }
}
TDEGenericDevice* TDEHardwareDevices::findBySystemPath(TQString syspath) {
@@ -389,8 +392,7 @@ void TDEHardwareDevices::processHotPluggedHardware() {
TDEGenericDevice *device = classifyUnknownDevice(dev);
// Make sure this device is not a duplicate
- TDEGenericDevice *hwdevice;
- for (hwdevice = m_deviceList.first(); hwdevice; hwdevice = m_deviceList.next()) {
+ for (TDEGenericDevice *hwdevice = m_deviceList.first(); hwdevice; hwdevice = m_deviceList.next()) {
if (hwdevice->systemPath() == device->systemPath()) {
delete device;
device = 0;
@@ -402,6 +404,18 @@ void TDEHardwareDevices::processHotPluggedHardware() {
m_deviceList.append(device);
updateParentDeviceInformation(device); // Update parent/child tables for this device
emit hardwareAdded(device);
+ if (device->type() == TDEGenericDeviceType::Disk) {
+ // Make sure slave status is also updated
+ TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(device);
+ TQStringList slavedevices = sdevice->slaveDevices();
+ for (TQStringList::Iterator slaveit = slavedevices.begin(); slaveit != slavedevices.end(); ++slaveit) {
+ TDEGenericDevice* slavedevice = findBySystemPath(*slaveit);
+ if (slavedevice && slavedevice->type() == TDEGenericDeviceType::Disk) {
+ rescanDeviceInformation(slavedevice);
+ emit hardwareUpdated(slavedevice);
+ }
+ }
+ }
}
}
else if (actionevent == "remove") {
@@ -411,32 +425,22 @@ void TDEHardwareDevices::processHotPluggedHardware() {
TDEGenericDevice *hwdevice;
for (hwdevice = m_deviceList.first(); hwdevice; hwdevice = m_deviceList.next()) {
if (hwdevice->systemPath() == systempath) {
- // Temporarily disable auto-deletion to ensure object validity when calling the Removed events below
- m_deviceList.setAutoDelete(false);
-
- // If the device is a storage device and has a slave, update it as well
+ // Make sure slave status is also updated
if (hwdevice->type() == TDEGenericDeviceType::Disk) {
TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(hwdevice);
TQStringList slavedevices = sdevice->slaveDevices();
- m_deviceList.remove(hwdevice);
- for ( TQStringList::Iterator slaveit = slavedevices.begin(); slaveit != slavedevices.end(); ++slaveit ) {
+ for (TQStringList::Iterator slaveit = slavedevices.begin(); slaveit != slavedevices.end(); ++slaveit) {
TDEGenericDevice* slavedevice = findBySystemPath(*slaveit);
- if (slavedevice) {
+ if (slavedevice && slavedevice->type() == TDEGenericDeviceType::Disk) {
rescanDeviceInformation(slavedevice);
emit hardwareUpdated(slavedevice);
}
}
}
- else {
- m_deviceList.remove(hwdevice);
- }
+ rescanDeviceInformation(hwdevice, dev);
emit hardwareRemoved(hwdevice);
-
- // Reenable auto-deletion and delete the removed device object
- m_deviceList.setAutoDelete(true);
- delete hwdevice;
-
+ m_deviceList.remove(hwdevice);
break;
}
}
@@ -449,8 +453,7 @@ void TDEHardwareDevices::processHotPluggedHardware() {
for (hwdevice = m_deviceList.first(); hwdevice; hwdevice = m_deviceList.next()) {
if (hwdevice->systemPath() == systempath) {
if (!hwdevice->blacklistedForUpdate()) {
- classifyUnknownDevice(dev, hwdevice, false);
- updateParentDeviceInformation(hwdevice); // Update parent/child tables for this device
+ rescanDeviceInformation(hwdevice, dev);
emit hardwareUpdated(hwdevice);
}
}
@@ -885,7 +888,7 @@ void TDEHardwareDevices::processStatelessDevices() {
TDEGenericHardwareList devList = listAllPhysicalDevices();
for ( hwdevice = devList.first(); hwdevice; hwdevice = devList.next() ) {
if ((hwdevice->type() == TDEGenericDeviceType::RootSystem) || (hwdevice->type() == TDEGenericDeviceType::Network) || (hwdevice->type() == TDEGenericDeviceType::OtherSensor) || (hwdevice->type() == TDEGenericDeviceType::Event) || (hwdevice->type() == TDEGenericDeviceType::Battery) || (hwdevice->type() == TDEGenericDeviceType::PowerSupply)) {
- rescanDeviceInformation(hwdevice, false);
+ rescanDeviceInformation(hwdevice, NULL, false);
emit hardwareUpdated(hwdevice);
#ifdef STATELESSPROFILING
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time2);
@@ -909,13 +912,13 @@ void TDEHardwareDevices::processBatteryDevices() {
TDEGenericHardwareList devList = listAllPhysicalDevices();
for ( hwdevice = devList.first(); hwdevice; hwdevice = devList.next() ) {
if (hwdevice->type() == TDEGenericDeviceType::Battery) {
- rescanDeviceInformation(hwdevice, false);
+ rescanDeviceInformation(hwdevice, NULL, false);
emit hardwareUpdated(hwdevice);
}
else if (hwdevice->type() == TDEGenericDeviceType::PowerSupply) {
TDEMainsPowerDevice *pdevice = dynamic_cast<TDEMainsPowerDevice*>(hwdevice);
int previousOnlineState = pdevice->online();
- rescanDeviceInformation(hwdevice, false);
+ rescanDeviceInformation(hwdevice, NULL, false);
if (pdevice->online() != previousOnlineState) {
emit hardwareUpdated(hwdevice);
}
@@ -931,7 +934,6 @@ void TDEHardwareDevices::processEventDeviceKeyPressed(unsigned int keycode, TDEE
void TDEHardwareDevices::processModifiedMounts() {
// Detect what changed between the old mount table and the new one,
// and emit appropriate events
-
TQMap<TQString, bool> deletedEntries = m_mountTable;
// Read in the new mount table
@@ -957,43 +959,26 @@ void TDEHardwareDevices::processModifiedMounts() {
}
}
+ // Added devices
TQMap<TQString, bool>::Iterator it;
for ( it = addedEntries.begin(); it != addedEntries.end(); ++it ) {
- TQStringList mountInfo = TQStringList::split(" ", it.key(), true);
// Try to find a device that matches the altered node
+ TQStringList mountInfo = TQStringList::split(" ", it.key(), true);
TDEGenericDevice* hwdevice = findByDeviceNode(*mountInfo.at(0));
- if (hwdevice) {
+ if (hwdevice && hwdevice->type() == TDEGenericDeviceType::Disk) {
+ rescanDeviceInformation(hwdevice);
emit hardwareUpdated(hwdevice);
- // If the device is a storage device and has a slave, update it as well
- if (hwdevice->type() == TDEGenericDeviceType::Disk) {
- TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(hwdevice);
- TQStringList slavedevices = sdevice->slaveDevices();
- for ( TQStringList::Iterator slaveit = slavedevices.begin(); slaveit != slavedevices.end(); ++slaveit ) {
- TDEGenericDevice* slavedevice = findBySystemPath(*slaveit);
- if (slavedevice) {
- emit hardwareUpdated(slavedevice);
- }
- }
- }
}
}
+
+ // Removed devices
for ( it = deletedEntries.begin(); it != deletedEntries.end(); ++it ) {
- TQStringList mountInfo = TQStringList::split(" ", it.key(), true);
// Try to find a device that matches the altered node
+ TQStringList mountInfo = TQStringList::split(" ", it.key(), true);
TDEGenericDevice* hwdevice = findByDeviceNode(*mountInfo.at(0));
- if (hwdevice) {
+ if (hwdevice && hwdevice->type() == TDEGenericDeviceType::Disk) {
+ rescanDeviceInformation(hwdevice);
emit hardwareUpdated(hwdevice);
- // If the device is a storage device and has a slave, update it as well
- if (hwdevice->type() == TDEGenericDeviceType::Disk) {
- TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(hwdevice);
- TQStringList slavedevices = sdevice->slaveDevices();
- for ( TQStringList::Iterator slaveit = slavedevices.begin(); slaveit != slavedevices.end(); ++slaveit ) {
- TDEGenericDevice* slavedevice = findBySystemPath(*slaveit);
- if (slavedevice) {
- emit hardwareUpdated(slavedevice);
- }
- }
- }
}
}
}
@@ -2466,12 +2451,6 @@ TDEGenericDevice* TDEHardwareDevices::classifyUnknownDevice(udev_device* dev, TD
udev_device_unref(dev);
}
- // Get the device mapped name if present
- TDEStorageDevice *sdevice = dynamic_cast<TDEStorageDevice*>(device);
- if (sdevice) {
- sdevice->updateMappedName();
- }
-
return device;
}
@@ -2872,6 +2851,8 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice *devic
}
sdevice->internalSetDiskLabel(disklabel);
+ sdevice->internalUpdateMountPath();
+ sdevice->internalUpdateMappedName();
}
}
diff --git a/tdecore/tdehw/tdehardwaredevices.h b/tdecore/tdehw/tdehardwaredevices.h
index f3c5e1a93..db63e9d34 100644
--- a/tdecore/tdehw/tdehardwaredevices.h
+++ b/tdecore/tdehw/tdehardwaredevices.h
@@ -207,19 +207,13 @@ class TDECORE_EXPORT TDEHardwareDevices : public TQObject
/**
* Rescan a hardware device to look for changes
* WARNING: This method can be very expensive. Use with caution!
- * @param hwdevice TDEGenericDevice* with the device to rescan
- */
- void rescanDeviceInformation(TDEGenericDevice* hwdevice);
-
- /**
- * Rescan a hardware device to look for changes
- * WARNING: This method can be very expensive. Use with caution!
* The computational expense can be reduced somewhat if the device tree structure
* has not changed by calling this method with regenerateDeviceTree = false.
* @param hwdevice TDEGenericDevice* with the device to rescan
+ * @param dev udev_device* with the udev device to rescan
* @param regenerateDeviceTree true to update parent/child links in device tree
*/
- void rescanDeviceInformation(TDEGenericDevice* hwdevice, bool regenerateDeviceTree);
+ void rescanDeviceInformation(TDEGenericDevice* hwdevice, udev_device* dev = NULL, bool regenerateDeviceTree = true);
/**
* Enable or disable automatic state updates of triggerless hardware devices
@@ -238,7 +232,7 @@ class TDECORE_EXPORT TDEHardwareDevices : public TQObject
* @param enable a bool specifiying whether or not automatic updates should be enabled
*/
void setBatteryUpdatesEnabled(bool enable);
-
+
/**
* Convert a byte count to human readable form
* @param bytes a double containing the number of bytes
diff --git a/tdecore/tdehw/tdestoragedevice.cpp b/tdecore/tdehw/tdestoragedevice.cpp
index 4e4d92c82..08fb246e1 100644
--- a/tdecore/tdehw/tdestoragedevice.cpp
+++ b/tdecore/tdehw/tdestoragedevice.cpp
@@ -71,7 +71,7 @@ TQString TDEStorageDevice::mappedName() {
return m_mappedName;
}
-void TDEStorageDevice::updateMappedName() {
+void TDEStorageDevice::internalUpdateMappedName() {
// Get the device mapped name if present
m_mappedName = TQString::null;
TQString dmnodename = systemPath();
@@ -329,20 +329,19 @@ TQStringVariantMap TDEStorageDevice::ejectDrive() {
TQStringVariantMap result;
TQStringVariantMap ejectResult;
+ // If the device is mounted, try unmounting it first
+ if (!mountPath().isEmpty()) {
+ unmountDevice();
+ }
+
#ifdef WITH_UDISKS2
if (!(TDEGlobal::dirs()->findExe("udisksctl").isEmpty())) {
ejectResult = udisks2EjectDrive(this);
if (ejectResult["result"].toBool()) {
- // Update internal mount data
- TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
- TDEGlobal::hardwareDevices()->processModifiedMounts();
result["result"] = true;
return result;
}
else {
- // Update internal mount data
- TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
- TDEGlobal::hardwareDevices()->processModifiedMounts();
result["errStr"] = ejectResult["errStr"];
result["result"] = false;
return result;
@@ -353,16 +352,10 @@ TQStringVariantMap TDEStorageDevice::ejectDrive() {
if (!(TDEGlobal::dirs()->findExe("udisks").isEmpty())) {
ejectResult = udisksEjectDrive(this);
if (ejectResult["result"].toBool()) {
- // Update internal mount data
- TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
- TDEGlobal::hardwareDevices()->processModifiedMounts();
result["result"] = true;
return result;
}
else {
- // Update internal mount data
- TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
- TDEGlobal::hardwareDevices()->processModifiedMounts();
result["errStr"] = ejectResult["errStr"];
result["result"] = false;
return result;
@@ -380,9 +373,6 @@ TQStringVariantMap TDEStorageDevice::ejectDrive() {
eject_output = ts.read();
int retcode = pclose(exepipe);
if (retcode == 0) {
- // Update internal mount data
- TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
- TDEGlobal::hardwareDevices()->processModifiedMounts();
result["result"] = true;
return result;
}
@@ -393,9 +383,6 @@ TQStringVariantMap TDEStorageDevice::ejectDrive() {
}
}
- // Update internal mount data
- TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
- TDEGlobal::hardwareDevices()->processModifiedMounts();
result["result"] = false;
return result;
}
@@ -695,7 +682,13 @@ TQString TDEStorageDevice::deviceFriendlySize() {
return TDEHardwareDevices::bytesToFriendlySizeString(deviceSize());
}
-TQString TDEStorageDevice::mountPath() {
+TQString TDEStorageDevice::mountPath()
+{
+ return m_mountPath;
+}
+
+void TDEStorageDevice::internalUpdateMountPath()
+{
// See if this device node is mounted
// This requires parsing /proc/mounts, looking for deviceNode()
@@ -703,8 +696,10 @@ TQString TDEStorageDevice::mountPath() {
// It likes to advertise mounts as /dev/mapper/<something>,
// where <something> is listed in <system path>/dm/name
- // First, ensure that all device information (mainly holders/slaves) is accurate
- TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
+ // Assumed all device information (mainly holders/slaves) is accurate
+ // prior to the call
+
+ m_mountPath = TQString::null;
TQStringList lines;
TQFile file( "/proc/mounts" );
@@ -717,30 +712,15 @@ TQString TDEStorageDevice::mountPath() {
TQString testNode = *mountInfo.at(0);
// Check for match
if ((testNode == deviceNode()) || (testNode == mappedName()) || (testNode == ("/dev/disk/by-uuid/" + diskUUID()))) {
- TQString ret = *mountInfo.at(1);
- ret.replace("\\040", " ");
+ m_mountPath = *mountInfo.at(1);
+ m_mountPath.replace("\\040", " ");
file.close();
- return ret;
+ return;
}
lines += line;
}
file.close();
}
-
- // While this device is not directly mounted, it could concievably be mounted via the Device Mapper
- // If so, try to retrieve the mount path...
- TQStringList slaveDeviceList = holdingDevices();
- for ( TQStringList::Iterator slavedevit = slaveDeviceList.begin(); slavedevit != slaveDeviceList.end(); ++slavedevit ) {
- // Try to locate this device path in the TDE device tree
- TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
- TDEGenericDevice *hwdevice = hwdevices->findBySystemPath(*slavedevit);
- if ((hwdevice) && (hwdevice->type() == TDEGenericDeviceType::Disk)) {
- TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(hwdevice);
- return sdevice->mountPath();
- }
- }
-
- return TQString::null;
}
TQStringVariantMap TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageMountOptions mountOptions) {
@@ -824,7 +804,6 @@ TQStringVariantMap TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageM
mountResult = udisks2MountDrive(devNode, fileSystemType, optionString);
if (mountResult["result"].toBool()) {
// Update internal mount data
- TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts();
result["mountPath"] = mountPath();
result["result"] = true;
@@ -832,7 +811,6 @@ TQStringVariantMap TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageM
}
else if (mountResult["retcode"].toInt() == -1) {
// Update internal mount data
- TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts();
result["errStr"] = mountResult["errStr"];
result["result"] = false;
@@ -846,7 +824,6 @@ TQStringVariantMap TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageM
mountResult = udisksMountDrive(devNode, fileSystemType, udisksOptions);
if (mountResult["result"].toBool()) {
// Update internal mount data
- TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts();
result["mountPath"] = mountPath();
result["result"] = true;
@@ -854,7 +831,6 @@ TQStringVariantMap TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageM
}
else if (mountResult["retcode"].toInt() == -1) {
// Update internal mount data
- TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts();
result["errStr"] = mountResult["errStr"];
result["result"] = false;
@@ -944,7 +920,6 @@ TQStringVariantMap TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageM
}
// Update internal mount data
- TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts();
result["mountPath"] = mountPath();
result["result"] = !mountPath().isEmpty();
@@ -955,13 +930,13 @@ TQStringVariantMap TDEStorageDevice::unmountDevice() {
TQStringVariantMap result;
// Check if device is already unmounted
- TQString mountpoint = mountPath();
- if (mountpoint.isEmpty()) {
+ TQString mountpath = mountPath();
+ if (mountpath.isEmpty()) {
result["result"] = true;
return result;
}
- mountpoint.replace("'", "'\\''");
+ mountpath.replace("'", "'\\''");
TQString devNode = deviceNode();
TQString command = TQString::null;
TQStringVariantMap unmountResult;
@@ -971,14 +946,12 @@ TQStringVariantMap TDEStorageDevice::unmountDevice() {
unmountResult = udisks2UnmountDrive(devNode, TQString::null);
if (unmountResult["result"].toBool()) {
// Update internal mount data
- TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts();
result["result"] = true;
return result;
}
else if (unmountResult["retcode"].toInt() == -1) {
// Update internal mount data
- TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts();
result["errStr"] = unmountResult["errStr"];
result["result"] = false;
@@ -992,14 +965,12 @@ TQStringVariantMap TDEStorageDevice::unmountDevice() {
unmountResult = udisksUnmountDrive(devNode, TQStringList());
if (unmountResult["result"].toBool()) {
// Update internal mount data
- TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts();
result["result"] = true;
return result;
}
else if (unmountResult["retcode"].toInt() == -1) {
// Update internal mount data
- TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts();
result["errStr"] = unmountResult["errStr"];
result["result"] = false;
@@ -1011,13 +982,13 @@ TQStringVariantMap TDEStorageDevice::unmountDevice() {
// The UDISKS v1 DBUS service was either not available or was unusable
// Use 'udevil' command, if available
if (!TDEGlobal::dirs()->findExe("udevil").isEmpty()) {
- command = TQString("udevil umount '%1' 2>&1").arg(mountpoint);
+ command = TQString("udevil umount '%1' 2>&1").arg(mountpath);
}
#endif
// If no other method was found, use 'pmount' command if available
if(command.isEmpty() && !TDEGlobal::dirs()->findExe("pumount").isEmpty()) {
- command = TQString("pumount '%1' 2>&1").arg(mountpoint);
+ command = TQString("pumount '%1' 2>&1").arg(mountpath);
}
if(command.isEmpty()) {
@@ -1034,7 +1005,6 @@ TQStringVariantMap TDEStorageDevice::unmountDevice() {
int retcode = pclose(exepipe);
if (retcode == 0) {
// Update internal mount data
- TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts();
result["result"] = true;
return result;
@@ -1046,7 +1016,6 @@ TQStringVariantMap TDEStorageDevice::unmountDevice() {
}
// Update internal mount data
- TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts();
result["result"] = false;
return result;
@@ -1056,14 +1025,6 @@ TQStringVariantMap TDEStorageDevice::unlockDevice(const TQString &passphrase)
{
TQStringVariantMap result;
- // Check if device is already mounted
- TQString mountpath = mountPath();
- if (!mountpath.isEmpty()) {
- result["unlockedDevice"] = mountpath;
- result["result"] = true;
- return result;
- }
-
TQString devNode = deviceNode();
devNode.replace("'", "'\\''");
@@ -1073,17 +1034,11 @@ TQStringVariantMap TDEStorageDevice::unlockDevice(const TQString &passphrase)
// Try to use UDISKS v2 via DBUS, if available
unlockResult = udisks2UnlockDrive(devNode, passphrase);
if (unlockResult["result"].toBool()) {
- // Update internal mount data
- TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
- TDEGlobal::hardwareDevices()->processModifiedMounts();
result["unlockedDevice"] = unlockResult["unlockedDevice"];
result["result"] = true;
return result;
}
else if (unlockResult["retcode"].toInt() == -1) {
- // Update internal mount data
- TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
- TDEGlobal::hardwareDevices()->processModifiedMounts();
result["errStr"] = unlockResult["errStr"];
result["result"] = false;
return result;
@@ -1114,9 +1069,6 @@ TQStringVariantMap TDEStorageDevice::unlockDevice(const TQString &passphrase)
delete ts;
int retcode = pclose(exepipe);
if (retcode == 0) {
- // Update internal mount data
- TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
- TDEGlobal::hardwareDevices()->processModifiedMounts();
result["result"] = true;
}
else {
@@ -1138,14 +1090,6 @@ TQStringVariantMap TDEStorageDevice::lockDevice()
{
TQStringVariantMap result;
- // Check if device is mounted
- TQString mountpath = mountPath();
- if (!mountpath.isEmpty()) {
- result["errStr"] = i18n("The device is currently mounted and cannot be locked.");
- result["result"] = false;
- return result;
- }
-
TQString devNode = deviceNode();
devNode.replace("'", "'\\''");
@@ -1155,16 +1099,10 @@ TQStringVariantMap TDEStorageDevice::lockDevice()
// Try to use UDISKS v2 via DBUS, if available
lockResult = udisks2LockDrive(devNode);
if (lockResult["result"].toBool()) {
- // Update internal mount data
- TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
- TDEGlobal::hardwareDevices()->processModifiedMounts();
result["result"] = true;
return result;
}
else if (lockResult["retcode"].toInt() == -1) {
- // Update internal mount data
- TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
- TDEGlobal::hardwareDevices()->processModifiedMounts();
result["errStr"] = lockResult["errStr"];
result["result"] = false;
return result;
@@ -1181,9 +1119,6 @@ TQStringVariantMap TDEStorageDevice::lockDevice()
delete ts;
int retcode = pclose(exepipe);
if (retcode == 0) {
- // Update internal mount data
- TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
- TDEGlobal::hardwareDevices()->processModifiedMounts();
result["result"] = true;
}
else {
diff --git a/tdecore/tdehw/tdestoragedevice.h b/tdecore/tdehw/tdestoragedevice.h
index 0a8ef7283..c279586f8 100644
--- a/tdecore/tdehw/tdestoragedevice.h
+++ b/tdecore/tdehw/tdestoragedevice.h
@@ -199,11 +199,6 @@ class TDECORE_EXPORT TDEStorageDevice : public TDEGenericDevice
TQString mappedName();
/**
- * Find and store the alternative mapped name of a mapped device
- */
- void updateMappedName();
-
- /**
* @return an OR-ed combination of TDEDiskDeviceType::TDEDiskDeviceType type flags
*/
TDEDiskDeviceType::TDEDiskDeviceType diskType();
@@ -494,6 +489,16 @@ class TDECORE_EXPORT TDEStorageDevice : public TDEGenericDevice
*/
void internalGetLUKSKeySlotStatus();
+ /**
+ * Find and store the alternative mapped name of a mapped device
+ */
+ void internalUpdateMappedName();
+
+ /**
+ * Find and store the mount point of the device, if any
+ */
+ void internalUpdateMountPath();
+
private:
TQString m_mappedName; // Alternative name for a mapped device
TDEDiskDeviceType::TDEDiskDeviceType m_diskType;