summaryrefslogtreecommitdiffstats
path: root/kcontrol/hwmanager/devicepropsdlg.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kcontrol/hwmanager/devicepropsdlg.cpp')
-rw-r--r--kcontrol/hwmanager/devicepropsdlg.cpp237
1 files changed, 176 insertions, 61 deletions
diff --git a/kcontrol/hwmanager/devicepropsdlg.cpp b/kcontrol/hwmanager/devicepropsdlg.cpp
index 18ac13f7a..4baabe29a 100644
--- a/kcontrol/hwmanager/devicepropsdlg.cpp
+++ b/kcontrol/hwmanager/devicepropsdlg.cpp
@@ -29,6 +29,9 @@
#include <tqpainter.h>
#include <tqstyle.h>
#include <tqinternal_p.h>
+#include <kprocess.h>
+#include <dcopclient.h>
+#include <dcopref.h>
#undef Unsorted // Required for --enable-final (tqdir.h)
#include <tqfiledialog.h>
@@ -45,6 +48,7 @@
#include <ksslcertificate.h>
#include "cryptpassworddlg.h"
+#include "passworddlg.h"
#include "devicepropsdlg.h"
@@ -295,16 +299,20 @@ DevicePropertiesDialog::DevicePropertiesDialog(TDEGenericDevice* device, TQWidge
}
if (m_device->type() == TDEGenericDeviceType::CPU) {
- connect(base->comboCPUGovernor, TQT_SIGNAL(activated(const TQString &)), this, TQT_SLOT(setCPUGovernor(const TQString &)));
+ connect(base->comboCPUGovernor, TQ_SIGNAL(activated(const TQString &)), this, TQ_SLOT(setCPUGovernor(const TQString &)));
}
if (m_device->type() == TDEGenericDeviceType::Disk) {
TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(m_device);
- connect(base->buttonDiskMount, TQT_SIGNAL(clicked()), this, TQT_SLOT(mountDisk()));
- connect(base->buttonDiskUnmount, TQT_SIGNAL(clicked()), this, TQT_SLOT(unmountDisk()));
+ connect(base->buttonDiskMount, TQ_SIGNAL(clicked()), this, TQ_SLOT(mountDisk()));
+ connect(base->buttonDiskUnmount, TQ_SIGNAL(clicked()), this, TQ_SLOT(unmountDisk()));
+ connect(base->buttonDiskUnlock, TQ_SIGNAL(clicked()), this, TQ_SLOT(unlockDisk()));
+ connect(base->buttonDiskLock, TQ_SIGNAL(clicked()), this, TQ_SLOT(lockDisk()));
+ connect(base->buttonDiskEject, TQ_SIGNAL(clicked()), this, TQ_SLOT(ejectDisk()));
+ connect(base->buttonDiskSafeRemove, TQ_SIGNAL(clicked()), this, TQ_SLOT(safeRemoveDisk()));
if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS)) {
- connect(base->cryptLUKSAddKey, TQT_SIGNAL(clicked()), this, TQT_SLOT(cryptLUKSAddKey()));
- connect(base->cryptLUKSDelKey, TQT_SIGNAL(clicked()), this, TQT_SLOT(cryptLUKSDelKey()));
- connect(base->cryptLUKSKeySlotList, TQT_SIGNAL(selectionChanged()), this, TQT_SLOT(processLockouts()));
+ connect(base->cryptLUKSAddKey, TQ_SIGNAL(clicked()), this, TQ_SLOT(cryptLUKSAddKey()));
+ connect(base->cryptLUKSDelKey, TQ_SIGNAL(clicked()), this, TQ_SLOT(cryptLUKSDelKey()));
+ connect(base->cryptLUKSKeySlotList, TQ_SIGNAL(selectionChanged()), this, TQ_SLOT(processLockouts()));
base->cryptLUKSKeySlotList->setAllColumnsShowFocus(true);
base->cryptLUKSKeySlotList->setFullWidth(true);
cryptLUKSPopulateList();
@@ -324,10 +332,10 @@ DevicePropertiesDialog::DevicePropertiesDialog(TDEGenericDevice* device, TQWidge
m_sensorDataGridWidgets.setAutoDelete(true);
}
if (m_device->type() == TDEGenericDeviceType::Backlight) {
- connect(base->sliderBacklightBrightness, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(setBacklightBrightness(int)));
+ connect(base->sliderBacklightBrightness, TQ_SIGNAL(valueChanged(int)), this, TQ_SLOT(setBacklightBrightness(int)));
}
if (m_device->type() == TDEGenericDeviceType::RootSystem) {
- connect(base->comboSystemHibernationMethod, TQT_SIGNAL(activated(int)), this, TQT_SLOT(setHibernationMethod(int)));
+ connect(base->comboSystemHibernationMethod, TQ_SIGNAL(activated(int)), this, TQ_SLOT(setHibernationMethod(int)));
}
TQGridLayout *mainGrid = new TQGridLayout(plainPage(), 1, 1, 0, spacingHint());
@@ -337,8 +345,8 @@ DevicePropertiesDialog::DevicePropertiesDialog(TDEGenericDevice* device, TQWidge
TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
- connect(hwdevices, TQT_SIGNAL(hardwareRemoved(TDEGenericDevice*)), this, TQT_SLOT(processHardwareRemoved(TDEGenericDevice*)));
- connect(hwdevices, TQT_SIGNAL(hardwareUpdated(TDEGenericDevice*)), this, TQT_SLOT(processHardwareUpdated(TDEGenericDevice*)));
+ connect(hwdevices, TQ_SIGNAL(hardwareRemoved(TDEGenericDevice*)), this, TQ_SLOT(processHardwareRemoved(TDEGenericDevice*)));
+ connect(hwdevices, TQ_SIGNAL(hardwareUpdated(TDEGenericDevice*)), this, TQ_SLOT(processHardwareUpdated(TDEGenericDevice*)));
populateDeviceInformation();
}
@@ -367,7 +375,49 @@ static TQString formatDisplayString(TQString input) {
return TQStyleSheet::escape(input);
}
-void DevicePropertiesDialog::populateDeviceInformation() {
+bool DevicePropertiesDialog::isMonitoredDevice(TDEStorageDevice *sdevice)
+{
+ // Type selection logic largely duplicated from the media manager tdeioslave
+ return ((sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) ||
+ sdevice->checkDiskStatus(TDEDiskDeviceStatus::ContainsFilesystem) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio) ||
+ sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) &&
+ !sdevice->checkDiskStatus(TDEDiskDeviceStatus::Hidden) &&
+ (sdevice->isDiskOfType(TDEDiskDeviceType::HDD) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::CDROM) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::CDR) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::CDRW) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::CDMO) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::CDMRRW) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::CDMRRWW) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDROM) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDRAM) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDR) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDRW) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDRDL) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDRWDL) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDPLUSR) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDPLUSRW) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDPLUSRDL) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDPLUSRWDL) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::BDROM) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::BDR) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::BDRW) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::HDDVDROM) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::HDDVDR) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::HDDVDRW) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::CDVideo) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::DVDVideo) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::BDVideo) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::Floppy) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::Zip) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::Jaz) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::Camera)));
+}
+
+void DevicePropertiesDialog::populateDeviceInformation()
+{
if (m_device) {
base->labelDeviceType->setText(m_device->friendlyDeviceType());
base->iconDeviceType->setPixmap(m_device->icon(TDEIcon::SizeSmall));
@@ -416,48 +466,88 @@ void DevicePropertiesDialog::populateDeviceInformation() {
if (volUUID == "") volUUID = i18n("<none>");
base->labelDiskUUID->setText(formatDisplayString(volUUID));
+ TQString mappedName = sdevice->mappedName();
+ if (mappedName == "") mappedName = i18n("<none>");
+ base->labelMappedName->setText(formatDisplayString(mappedName));
+
// Show status
TQString status_text = "<qt>";
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Mountable)) {
- status_text += "Mountable<br>";
+ status_text += i18n("Mountable") + "<br>";
}
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Removable)) {
- status_text += "Removable<br>";
+ status_text += i18n("Removable") + "<br>";
}
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Inserted)) {
- status_text += "Inserted<br>";
+ status_text += i18n("Inserted") + "<br>";
}
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
- status_text += "Blank<br>";
+ status_text += i18n("Blank") + "<br>";
}
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::UsedByDevice)) {
- status_text += "In use<br>";
+ status_text += i18n("In use") + "<br>";
}
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::UsesDevice)) {
- status_text += "Uses other device<br>";
+ status_text += i18n("Uses other device") + "<br>";
}
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::ContainsFilesystem)) {
- status_text += "Contains a filesystem<br>";
- }
- if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Hotpluggable)) {
- status_text += "Hotpluggable<br>";
+ status_text += i18n("Contains a filesystem") + "<br>";
}
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Hidden)) {
- status_text += "Hidden<br>";
+ status_text += i18n("Hidden") + "<br>";
}
if (status_text == "<qt>") {
- status_text += "<i>Unavailable</i>";
+ status_text += "<i>" + i18n("Unknown") + "</i>";
}
status_text += "</qt>";
base->labelDiskStatus->setText(status_text);
- // Update mount/unmount button status
- if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Mountable)) {
- base->groupDiskActions->show();
+ // Update action button status
+ base->buttonDiskMount->setEnabled(false);
+ base->buttonDiskUnmount->setEnabled(false);
+ base->buttonDiskUnlock->setEnabled(false);
+ base->buttonDiskLock->setEnabled(false);
+ base->buttonDiskEject->setEnabled(false);
+ base->buttonDiskSafeRemove->setEnabled(false);
+ base->buttonDiskMount->setHidden(true);
+ base->buttonDiskUnmount->setHidden(true);
+ base->buttonDiskUnlock->setHidden(true);
+ base->buttonDiskLock->setHidden(true);
+ base->buttonDiskEject->setHidden(true);
+ base->buttonDiskSafeRemove->setHidden(true);
+ bool showGroup = false;
+ if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Mountable))
+ {
base->buttonDiskMount->setEnabled((sdevice->mountPath() == ""));
base->buttonDiskUnmount->setEnabled((sdevice->mountPath() != ""));
+ base->buttonDiskMount->setHidden(false);
+ base->buttonDiskUnmount->setHidden(false);
+ showGroup = true;
}
- else {
+ else if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) ||
+ sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted))
+ {
+ base->buttonDiskUnlock->setEnabled(!sdevice->isDiskOfType(TDEDiskDeviceType::UnlockedCrypt));
+ base->buttonDiskLock->setEnabled(sdevice->isDiskOfType(TDEDiskDeviceType::UnlockedCrypt));
+ base->buttonDiskUnlock->setHidden(false);
+ base->buttonDiskLock->setHidden(false);
+ showGroup = true;
+ }
+ if (isMonitoredDevice(sdevice) &&
+ sdevice->checkDiskStatus(TDEDiskDeviceStatus::Removable))
+ {
+ base->buttonDiskEject->setEnabled(true);
+ base->buttonDiskSafeRemove->setEnabled(true);
+ base->buttonDiskEject->setHidden(false);
+ base->buttonDiskSafeRemove->setHidden(false);
+ showGroup = true;
+ }
+ if (showGroup)
+ {
+ base->groupDiskActions->show();
+ }
+ else
+ {
base->groupDiskActions->hide();
}
}
@@ -659,7 +749,7 @@ void DevicePropertiesDialog::populateDeviceInformation() {
}
// RandR warning
- base->labelRandrWarning->setText("<qt><b>NOTE: Any further integration of displays into TDE <i>REQUIRES</i> multi GPU support and other features slated for RandR 2.0.</b><p>Development on such features has been sorely lacking for well over a year as of 2012; if you want to see Linux come up to Windows and Macintosh standards in this area <i>please tell the Xorg developers</i> at http://www.x.org/wiki/XorgMailingLists<p>The TDE project badly needs these features before it can proceed with graphical monitor configuration tools:<br> * GPU object support<br> * The ability to query the active driver name for any Xorg output<p><b>To recap, this is <i>not a TDE shortcoming</i>, but rather is the result of a lack of fundamental Linux support for graphics configuration!</b></qt>");
+ base->labelRandrWarning->setText(i18n("<qt><b>NOTE: Any further integration of displays into TDE <i>REQUIRES</i> multi GPU support and other features slated for RandR 2.0.</b><p>Development on such features has been sorely lacking for well over a year as of 2012; if you want to see Linux come up to Windows and Macintosh standards in this area <i>please tell the Xorg developers</i> at http://www.x.org/wiki/XorgMailingLists<p>The TDE project badly needs these features before it can proceed with graphical monitor configuration tools:<br> * GPU object support<br> * The ability to query the active driver name for any Xorg output<p><b>To recap, this is <i>not a TDE shortcoming</i>, but rather is the result of a lack of fundamental Linux support for graphics configuration!</b></qt>"));
}
if (m_device->type() == TDEGenericDeviceType::RootSystem) {
@@ -791,8 +881,8 @@ void DevicePropertiesDialog::populateDeviceInformation() {
if (m_device->type() == TDEGenericDeviceType::CryptographicCard) {
TDECryptographicCardDevice* cdevice = static_cast<TDECryptographicCardDevice*>(m_device);
- connect(cdevice, TQT_SIGNAL(cardInserted(TDECryptographicCardDevice*)), this, TQT_SLOT(cryptographicCardInserted()));
- connect(cdevice, TQT_SIGNAL(cardRemoved(TDECryptographicCardDevice*)), this, TQT_SLOT(cryptographicCardRemoved()));
+ connect(cdevice, TQ_SIGNAL(cardInserted(TDECryptographicCardDevice*)), this, TQ_SLOT(cryptographicCardInserted()));
+ connect(cdevice, TQ_SIGNAL(cardRemoved(TDECryptographicCardDevice*)), this, TQ_SLOT(cryptographicCardRemoved()));
updateCryptographicCardStatusDisplay();
}
@@ -879,49 +969,74 @@ void DevicePropertiesDialog::setHibernationMethod(int value) {
void DevicePropertiesDialog::mountDisk() {
TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(m_device);
- TQString qerror;
- TQString diskLabel = sdevice->diskLabel();
- if (diskLabel.isNull()) {
- diskLabel = i18n("%1 Removable Device").arg(sdevice->deviceFriendlySize());
+
+ TDEProcess proc;
+ proc << "tdeio_media_mounthelper" << "-m" << sdevice->deviceNode();
+ if (!proc.start(TDEProcess::DontCare))
+ {
+ KMessageBox::error(this, i18n("Could not start tdeio_media_mounthelper process."),
+ i18n("Device monitor"));
}
- TDEStorageMountOptions mountOptions;
- TQStringVariantMap mountResult = sdevice->mountDevice(diskLabel, mountOptions);
- TQString mountedPath = mountResult.contains("mountPath") ? mountResult["mountPath"].toString() : TQString::null;
- if (mountedPath.isEmpty()) {
- qerror = i18n("<qt>Unable to mount this device.<p>Potential reasons include:<br>Improper device and/or user privilege level<br>Corrupt data on storage device");
- TQString errStr = mountResult.contains("errStr") ? mountResult["errStr"].toString() : TQString::null;
- if (!errStr.isEmpty()) {
- qerror.append(i18n("<p>Technical details:<br>").append(errStr));
- }
- qerror.append("</qt>");
+}
+
+void DevicePropertiesDialog::unmountDisk() {
+ TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(m_device);
+
+ TDEProcess proc;
+ proc << "tdeio_media_mounthelper" << "-u" << sdevice->deviceNode();
+ if (!proc.start(TDEProcess::DontCare))
+ {
+ KMessageBox::error(this, i18n("Could not start tdeio_media_mounthelper process."),
+ i18n("Device monitor"));
}
- else {
- qerror = "";
+}
+
+void DevicePropertiesDialog::unlockDisk() {
+ TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(m_device);
+
+ TDEProcess proc;
+ proc << "tdeio_media_mounthelper" << "-k" << sdevice->deviceNode();
+ if (!proc.start(TDEProcess::DontCare))
+ {
+ KMessageBox::error(this, i18n("Could not start tdeio_media_mounthelper process."),
+ i18n("Device monitor"));
}
+}
- if (qerror != "") KMessageBox::error(this, qerror, i18n("Mount Failed"));
+void DevicePropertiesDialog::lockDisk() {
+ TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(m_device);
- populateDeviceInformation();
+ TDEProcess proc;
+ proc << "tdeio_media_mounthelper" << "-l" << sdevice->deviceNode();
+ if (!proc.start(TDEProcess::DontCare))
+ {
+ KMessageBox::error(this, i18n("Could not start tdeio_media_mounthelper process."),
+ i18n("Device monitor"));
+ }
}
-void DevicePropertiesDialog::unmountDisk() {
+void DevicePropertiesDialog::ejectDisk() {
TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(m_device);
- TQString qerror;
- TQStringVariantMap unmountResult = sdevice->unmountDevice();
- if (unmountResult["result"].toBool() == false) {
- // Unmount failed!
- qerror = "<qt>" + i18n("Unfortunately, the device could not be unmounted.");
- TQString errStr = unmountResult.contains("errStr") ? unmountResult["errStr"].toString() : TQString::null;
- if (!errStr.isEmpty()) {
- qerror.append(i18n("<p>Technical details:<br>").append(errStr));
- }
- qerror.append("</qt>");
+ TDEProcess proc;
+ proc << "tdeio_media_mounthelper" << "-e" << sdevice->deviceNode();
+ if (!proc.start(TDEProcess::DontCare))
+ {
+ KMessageBox::error(this, i18n("Could not start tdeio_media_mounthelper process."),
+ i18n("Device monitor"));
}
+}
- if (qerror != "") KMessageBox::error(this, qerror, i18n("Unmount Failed"));
+void DevicePropertiesDialog::safeRemoveDisk() {
+ TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(m_device);
- populateDeviceInformation();
+ TDEProcess proc;
+ proc << "tdeio_media_mounthelper" << "-s" << sdevice->deviceNode();
+ if (!proc.start(TDEProcess::DontCare))
+ {
+ KMessageBox::error(this, i18n("Could not start tdeio_media_mounthelper process."),
+ i18n("Device monitor"));
+ }
}
void DevicePropertiesDialog::cryptLUKSAddKey() {