diff options
-rw-r--r-- | kcontrol/hwmanager/devicepropsdlg.cpp | 103 | ||||
-rw-r--r-- | kcontrol/hwmanager/devicepropsdlg.h | 2 | ||||
-rw-r--r-- | kcontrol/hwmanager/hwdevicetray.cpp | 135 | ||||
-rw-r--r-- | kcontrol/hwmanager/hwdevicetray.h | 2 | ||||
-rw-r--r-- | tdeioslave/media/mediamanager/tdehardwarebackend.cpp | 2 |
5 files changed, 55 insertions, 189 deletions
diff --git a/kcontrol/hwmanager/devicepropsdlg.cpp b/kcontrol/hwmanager/devicepropsdlg.cpp index 1056aec57..e0f673de5 100644 --- a/kcontrol/hwmanager/devicepropsdlg.cpp +++ b/kcontrol/hwmanager/devicepropsdlg.cpp @@ -29,6 +29,7 @@ #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) @@ -253,7 +254,7 @@ void SensorDisplayWidget::updateDisplay() { } DevicePropertiesDialog::DevicePropertiesDialog(TDEGenericDevice* device, TQWidget *parent) - : KDialogBase(Plain, TQString::null, Ok|Cancel, Ok, parent, 0L, true, true), m_passDlg(NULL) + : KDialogBase(Plain, TQString::null, Ok|Cancel, Ok, parent, 0L, true, true) { m_device = device; enableButtonOK( false ); @@ -350,10 +351,6 @@ DevicePropertiesDialog::DevicePropertiesDialog(TDEGenericDevice* device, TQWidge DevicePropertiesDialog::~DevicePropertiesDialog() { - if (m_passDlg) - { - delete m_passDlg; - } } void DevicePropertiesDialog::processHardwareRemoved(TDEGenericDevice* dev) { @@ -909,99 +906,49 @@ void DevicePropertiesDialog::setHibernationMethod(int value) { void DevicePropertiesDialog::mountDisk() { TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(m_device); - // Use DCOP call instead of a tdehw call for consistent behavior across TDE - DCOPRef mediamanager("kded", "mediamanager"); - DCOPReply reply = mediamanager.call("mountByNode", sdevice->deviceNode()); - TQStringVariantMap mountResult; - if (reply.isValid()) { - reply.get(mountResult); - } - if (!mountResult.contains("result") || mountResult["result"].toBool() == false) { - // Mount failed! - TQString errStr = mountResult.contains("errStr") ? mountResult["errStr"].toString() : i18n("Unable to mount the device."); - KMessageBox::error(this, "<qt>" + errStr + "</qt>", i18n("Mount failed")); + 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")); } - - populateDeviceInformation(); } void DevicePropertiesDialog::unmountDisk() { TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(m_device); - // Use DCOP call instead of a tdehw call for consistent behavior across TDE - DCOPRef mediamanager("kded", "mediamanager"); - DCOPReply reply = mediamanager.call("unmountByNode", sdevice->deviceNode()); - TQStringVariantMap unmountResult; - if (reply.isValid()) { - reply.get(unmountResult); - } - if (!unmountResult.contains("result") || unmountResult["result"].toBool() == false) { - // Unmount failed! - TQString errStr = unmountResult.contains("errStr") ? unmountResult["errStr"].toString() : i18n("Unable to unmount the device."); - KMessageBox::error(this, "<qt>" + errStr + "</qt>", i18n("Unmount failed")); - } - - populateDeviceInformation(); -} - -void DevicePropertiesDialog::unlockDisk() { - TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(m_device); - - if (!m_passDlg) + TDEProcess proc; + proc << "tdeio_media_mounthelper" << "-u" << sdevice->deviceNode(); + if (!proc.start(TDEProcess::DontCare)) { - m_passDlg = new PasswordDlg(); - connect(m_passDlg, TQT_SIGNAL(user1Clicked()), this, TQT_SLOT(doUnlockDisk())); + KMessageBox::error(this, i18n("Could not start tdeio_media_mounthelper process."), + i18n("Device monitor")); } - m_passDlg->setDevice(sdevice->deviceNode()); - m_passDlg->clearPassword(); - m_passDlg->show(); } -void DevicePropertiesDialog::doUnlockDisk() { +void DevicePropertiesDialog::unlockDisk() { TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(m_device); - // Use DCOP call instead of a tdehw call for consistent behavior across TDE - DCOPRef mediamanager("kded", "mediamanager"); - DCOPReply reply = mediamanager.call("unlockByNode", sdevice->deviceNode(), m_passDlg->getPassword()); - TQStringVariantMap unlockResult; - if (reply.isValid()) { - reply.get(unlockResult); - } - if (!unlockResult.contains("result") || !unlockResult["result"].toBool()) + TDEProcess proc; + proc << "tdeio_media_mounthelper" << "-k" << sdevice->deviceNode(); + if (!proc.start(TDEProcess::DontCare)) { - TQString errStr = unlockResult.contains("errStr") ? unlockResult["errStr"].toString() : TQString::null; - if (errStr.isEmpty()) - { - errStr = i18n("<qt>Unable to unlock the device.<p>Potential reasons include:<br>Wrong password " - "and/or user privilege level.<br>Corrupt data on storage device.</qt>"); - } - KMessageBox::error(this, errStr, i18n("Unlock failed")); - m_passDlg->clearPassword(); - } - else { - m_passDlg->hide(); + KMessageBox::error(this, i18n("Could not start tdeio_media_mounthelper process."), + i18n("Device monitor")); } - - populateDeviceInformation(); } void DevicePropertiesDialog::lockDisk() { TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(m_device); - // Use DCOP call instead of a tdehw call for consistent behavior across TDE - DCOPRef mediamanager("kded", "mediamanager"); - DCOPReply reply = mediamanager.call("lockByNode", sdevice->deviceNode(), true); - TQStringVariantMap lockResult; - if (reply.isValid()) { - reply.get(lockResult); - } - if (!lockResult.contains("result") || lockResult["result"].toBool() == false) { - // Lock failed! - TQString errStr = lockResult.contains("errStr") ? lockResult["errStr"].toString() : i18n("Unable to lock the device."); - KMessageBox::error(this, "<qt>" + errStr + "</qt>", i18n("Lock failed")); + 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")); } - - populateDeviceInformation(); } void DevicePropertiesDialog::cryptLUKSAddKey() { diff --git a/kcontrol/hwmanager/devicepropsdlg.h b/kcontrol/hwmanager/devicepropsdlg.h index 50fd1cac1..a1f46e563 100644 --- a/kcontrol/hwmanager/devicepropsdlg.h +++ b/kcontrol/hwmanager/devicepropsdlg.h @@ -191,7 +191,6 @@ private slots: void mountDisk(); void unmountDisk(); void unlockDisk(); - void doUnlockDisk(); void lockDisk(); void cryptLUKSAddKey(); @@ -207,7 +206,6 @@ private slots: private: TDEGenericDevice* m_device; DevicePropertiesDialogBase* base; - PasswordDlg *m_passDlg; TQGridLayout* m_sensorDataGrid; SensorDisplayWidgetList m_sensorDataGridWidgets; diff --git a/kcontrol/hwmanager/hwdevicetray.cpp b/kcontrol/hwmanager/hwdevicetray.cpp index 5b7f51558..350433b71 100644 --- a/kcontrol/hwmanager/hwdevicetray.cpp +++ b/kcontrol/hwmanager/hwdevicetray.cpp @@ -33,6 +33,7 @@ #include <kdebug.h> #include <khelpmenu.h> #include <kiconloader.h> +#include "kprocess.h" #include <tdelocale.h> #include <tdepopupmenu.h> #include <kstdaction.h> @@ -54,7 +55,7 @@ #include "hwdevicetray.h" HwDeviceSystemTray::HwDeviceSystemTray(TQWidget* parent, const char *name) - : KSystemTray(parent, name), m_passDlg(NULL) + : KSystemTray(parent, name) { // Create notifier m_hardwareNotifierContainer = new TDEPassivePopupStackContainer(); @@ -99,10 +100,6 @@ HwDeviceSystemTray::HwDeviceSystemTray(TQWidget* parent, const char *name) HwDeviceSystemTray::~HwDeviceSystemTray() { delete m_hardwareNotifierContainer; - if (m_passDlg) - { - delete m_passDlg; - } } /*! @@ -440,21 +437,13 @@ void HwDeviceSystemTray::slotMountDevice(int parameter) { if (sdevice->mountPath().isEmpty()) { - // Use DCOP call instead of a tdehw call for consistent behavior across TDE - DCOPRef mediamanager("kded", "mediamanager"); - DCOPReply reply = mediamanager.call("mountByNode", sdevice->deviceNode()); - TQStringVariantMap mountResult; - if (reply.isValid()) - { - reply.get(mountResult); - } - if (!mountResult.contains("result") || mountResult["result"].toBool() == false) + TDEProcess proc; + proc << "tdeio_media_mounthelper" << "-m" << sdevice->deviceNode(); + if (!proc.start(TDEProcess::DontCare)) { - // Mount failed! - TQString errStr = mountResult.contains("errStr") ? mountResult["errStr"].toString() : i18n("Unable to mount the device."); - KMessageBox::error(0, "<qt>" + errStr + "</qt>", i18n("Mount failed")); + KMessageBox::error(this, i18n("Could not start tdeio_media_mounthelper process."), + i18n("Device monitor")); } - return; } } } @@ -475,21 +464,13 @@ void HwDeviceSystemTray::slotUnmountDevice(int parameter) { if (!sdevice->mountPath().isEmpty()) { - // Use DCOP call instead of a tdehw call for consistent behavior across TDE - DCOPRef mediamanager("kded", "mediamanager"); - DCOPReply reply = mediamanager.call("unmountByNode", sdevice->deviceNode()); - TQStringVariantMap unmountResult; - if (reply.isValid()) + TDEProcess proc; + proc << "tdeio_media_mounthelper" << "-u" << sdevice->deviceNode(); + if (!proc.start(TDEProcess::DontCare)) { - reply.get(unmountResult); + KMessageBox::error(this, i18n("Could not start tdeio_media_mounthelper process."), + i18n("Device monitor")); } - if (!unmountResult.contains("result") || unmountResult["result"].toBool() == false) - { - // Unmount failed! - TQString errStr = unmountResult.contains("errStr") ? unmountResult["errStr"].toString() : i18n("Unable to unmount the device."); - KMessageBox::error(0, "<qt>" + errStr + "</qt>", i18n("Unmount failed")); - } - return; } } } @@ -508,57 +489,13 @@ void HwDeviceSystemTray::slotUnlockDevice(int parameter) TDEStorageDevice *sdevice = static_cast<TDEStorageDevice*>(hwdevice); if ((sdevice->diskUUID() == uuid) || (sdevice->systemPath() == uuid)) { - if (!m_passDlg) + TDEProcess proc; + proc << "tdeio_media_mounthelper" << "-k" << sdevice->deviceNode(); + if (!proc.start(TDEProcess::DontCare)) { - m_passDlg = new PasswordDlg(); - connect(m_passDlg, TQT_SIGNAL(user1Clicked()), this, TQT_SLOT(doUnlockDisk())); + KMessageBox::error(this, i18n("Could not start tdeio_media_mounthelper process."), + i18n("Device monitor")); } - m_passDlg->setDevice(sdevice->deviceNode()); - m_passDlg->index = parameter; - m_passDlg->clearPassword(); - m_passDlg->show(); - return; - } - } - } -} - -void HwDeviceSystemTray::doUnlockDisk() -{ - TQString uuid = m_unlockMenuIndexMap[m_passDlg->index]; - if (!uuid.isEmpty()) - { - TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices(); - TDEGenericHardwareList diskDeviceList = hwdevices->listByDeviceClass(TDEGenericDeviceType::Disk); - for (TDEGenericDevice *hwdevice = diskDeviceList.first(); hwdevice; hwdevice = diskDeviceList.next()) - { - TDEStorageDevice *sdevice = static_cast<TDEStorageDevice*>(hwdevice); - if ((sdevice->diskUUID() == uuid) || (sdevice->systemPath() == uuid)) - { - // Use DCOP call instead of a tdehw call for consistent behavior across TDE - DCOPRef mediamanager("kded", "mediamanager"); - DCOPReply reply = mediamanager.call("unlockByNode", sdevice->deviceNode(), m_passDlg->getPassword()); - TQStringVariantMap unlockResult; - if (reply.isValid()) - { - reply.get(unlockResult); - } - if (!unlockResult.contains("result") || !unlockResult["result"].toBool()) - { - TQString errStr = unlockResult.contains("errStr") ? unlockResult["errStr"].toString() : TQString::null; - if (errStr.isEmpty()) - { - errStr = i18n("<qt>Unable to unlock the device.<p>Potential reasons include:<br>Wrong password " - "and/or user privilege level.<br>Corrupt data on storage device.</qt>"); - } - KMessageBox::error(0, errStr, i18n("Unlock failed")); - m_passDlg->clearPassword(); - } - else - { - m_passDlg->hide(); - } - return; } } } @@ -576,22 +513,14 @@ void HwDeviceSystemTray::slotLockDevice(int parameter) TDEStorageDevice *sdevice = static_cast<TDEStorageDevice*>(hwdevice); if ((sdevice->diskUUID() == uuid) || (sdevice->systemPath() == uuid)) { - // Use DCOP call instead of a tdehw call for consistent behavior across TDE - DCOPRef mediamanager("kded", "mediamanager"); - DCOPReply reply = mediamanager.call("lockByNode", sdevice->deviceNode(), true); - TQStringVariantMap lockResult; - if (reply.isValid()) - { - reply.get(lockResult); - } - if (!lockResult.contains("result") || lockResult["result"].toBool() == false) + TDEProcess proc; + proc << "tdeio_media_mounthelper" << "-l" << sdevice->deviceNode(); + if (!proc.start(TDEProcess::DontCare)) { - // Lock failed! - TQString errStr = lockResult.contains("errStr") ? lockResult["errStr"].toString() : i18n("Unable to lock the device."); - KMessageBox::error(0, "<qt>" + errStr + "</qt>", i18n("Lock failed")); + KMessageBox::error(this, i18n("Could not start tdeio_media_mounthelper process."), + i18n("Device monitor")); } - return; - } + } } } } @@ -608,21 +537,13 @@ void HwDeviceSystemTray::slotEjectDevice(int parameter) TDEStorageDevice *sdevice = static_cast<TDEStorageDevice*>(hwdevice); if ((sdevice->diskUUID() == uuid) || (sdevice->systemPath() == uuid)) { - // Use DCOP call instead of a tdehw call for consistent behavior across TDE - DCOPRef mediamanager("kded", "mediamanager"); - DCOPReply reply = mediamanager.call("ejectByNode", sdevice->deviceNode()); - TQStringVariantMap ejectResult; - if (reply.isValid()) + TDEProcess proc; + proc << "tdeio_media_mounthelper" << "-e" << sdevice->deviceNode(); + if (!proc.start(TDEProcess::DontCare)) { - reply.get(ejectResult); + KMessageBox::error(this, i18n("Could not start tdeio_media_mounthelper process."), + i18n("Device monitor")); } - if (!ejectResult.contains("result") || ejectResult["result"].toBool() == false) - { - // Eject failed! - TQString errStr = ejectResult.contains("errStr") ? ejectResult["errStr"].toString() : i18n("Unable to eject the device."); - KMessageBox::error(0, "<qt>" + errStr + "</qt>", i18n("Eject failed")); - } - return; } } } diff --git a/kcontrol/hwmanager/hwdevicetray.h b/kcontrol/hwmanager/hwdevicetray.h index 1300ac6ec..ad7f46ca5 100644 --- a/kcontrol/hwmanager/hwdevicetray.h +++ b/kcontrol/hwmanager/hwdevicetray.h @@ -74,7 +74,6 @@ private slots: void deviceRemoved(TDEGenericDevice*); void deviceChanged(TDEGenericDevice*); void devicePopupClicked(KPassivePopup*, TQPoint, TQString); - void doUnlockDisk(); void doDiskNotifications(bool scanOnly); private: @@ -99,7 +98,6 @@ private: TQStringMap m_propertiesMenuIndexMap; TDEPopupMenu* m_menu; KSimpleConfig *r_config; - PasswordDlg *m_passDlg; struct KnownDiskDeviceInfo { diff --git a/tdeioslave/media/mediamanager/tdehardwarebackend.cpp b/tdeioslave/media/mediamanager/tdehardwarebackend.cpp index 2a54f6b6b..bb5849149 100644 --- a/tdeioslave/media/mediamanager/tdehardwarebackend.cpp +++ b/tdeioslave/media/mediamanager/tdehardwarebackend.cpp @@ -1427,6 +1427,7 @@ TQStringVariantMap TDEBackend::unmount(const TQString &id) m_mediaList.removeMedium(uid, true); } + ResetProperties(sdevice, false, true); result["result"] = true; return result; } @@ -1528,6 +1529,7 @@ TQStringVariantMap TDEBackend::lock(const TQString &id, bool releaseHolders) } } + ResetProperties(sdevice, false, true); result["result"] = true; return result; } |