summaryrefslogtreecommitdiffstats
path: root/tdecore
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-03-29 22:02:21 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-03-29 22:02:21 -0500
commitfc3c24634ee8e44e9c27be14d4189ff3e4256f6d (patch)
tree70215a53ea70b9faac1ba83a9d96f000030c63ba /tdecore
parent513dce7c027b6e60627d4ff6d97bc4e9fffcb060 (diff)
downloadtdelibs-fc3c24634ee8e44e9c27be14d4189ff3e4256f6d.tar.gz
tdelibs-fc3c24634ee8e44e9c27be14d4189ff3e4256f6d.zip
Add new lockDriveMedia method to TDE hardware manager
Diffstat (limited to 'tdecore')
-rw-r--r--tdecore/tdehardwaredevices.cpp28
-rw-r--r--tdecore/tdehardwaredevices.h8
2 files changed, 36 insertions, 0 deletions
diff --git a/tdecore/tdehardwaredevices.cpp b/tdecore/tdehardwaredevices.cpp
index 418326bf0..b385538fb 100644
--- a/tdecore/tdehardwaredevices.cpp
+++ b/tdecore/tdehardwaredevices.cpp
@@ -40,6 +40,7 @@
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <linux/fs.h>
+#include <linux/cdrom.h>
// Backlight devices
#include <linux/fb.h>
@@ -433,6 +434,21 @@ bool TDEStorageDevice::checkDiskStatus(TDEDiskDeviceStatus::TDEDiskDeviceStatus
return ((m_diskStatus&sf)!=(TDEDiskDeviceStatus::TDEDiskDeviceStatus)0);
}
+bool TDEStorageDevice::lockDriveMedia(bool lock) {
+ int fd = open(deviceNode().ascii(), O_RDWR | O_NONBLOCK);
+ if (fd < 0) {
+ return false;
+ }
+ if (ioctl(fd, CDROM_LOCKDOOR, (lock)?1:0) != 0) {
+ close(fd);
+ return false;
+ }
+ else {
+ close(fd);
+ return true;
+ }
+}
+
TQString TDEStorageDevice::diskLabel() {
return m_diskName;
}
@@ -989,6 +1005,9 @@ bool TDECPUDevice::canSetGovernor() {
if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
return reply[0].toVariant().value.toBool();
}
+ else {
+ return FALSE;
+ }
}
else {
return FALSE;
@@ -1168,6 +1187,9 @@ bool TDERootSystemDevice::canSuspend() {
if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
return reply[0].toVariant().value.toBool();
}
+ else {
+ return FALSE;
+ }
}
else {
return FALSE;
@@ -1202,6 +1224,9 @@ bool TDERootSystemDevice::canHibernate() {
if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
return reply[0].toVariant().value.toBool();
}
+ else {
+ return FALSE;
+ }
}
else {
return FALSE;
@@ -1675,6 +1700,9 @@ bool TDEBacklightDevice::canSetBrightness() {
if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
return reply[0].toVariant().value.toBool();
}
+ else {
+ return FALSE;
+ }
}
else {
return FALSE;
diff --git a/tdecore/tdehardwaredevices.h b/tdecore/tdehardwaredevices.h
index 0363596e4..1f41f6267 100644
--- a/tdecore/tdehardwaredevices.h
+++ b/tdecore/tdehardwaredevices.h
@@ -653,6 +653,14 @@ class TDECORE_EXPORT TDEStorageDevice : public TDEGenericDevice
*/
bool checkDiskStatus(TDEDiskDeviceStatus::TDEDiskDeviceStatus sf);
+ /**
+ * @param TRUE to engage media lock, FALSE to disable it
+ * @return TRUE on success, FALSE on failure
+ *
+ * This method currently works on CD-ROM drives and similar devices
+ */
+ bool lockDriveMedia(bool lock);
+
protected:
/**
* @param a TQString with the disk or partition label, if any