summaryrefslogtreecommitdiffstats
path: root/tdeioslave/media/mounthelper
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2022-02-19 16:13:03 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2022-02-19 16:13:03 +0900
commit8d0f49aeb4a37176e25c7393ad6a31b8b9e8fcf4 (patch)
treea0cb97849a1dea54c91bed8bca9bfb800bdf5019 /tdeioslave/media/mounthelper
parentcc236553afa96e1f2bd2dba35b9d93080e273f8c (diff)
downloadtdebase-8d0f49aeb4a37176e25c7393ad6a31b8b9e8fcf4.tar.gz
tdebase-8d0f49aeb4a37176e25c7393ad6a31b8b9e8fcf4.zip
Added 'eject' and 'ejectByNode' to mediamanager DCOP interface.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'tdeioslave/media/mounthelper')
-rw-r--r--tdeioslave/media/mounthelper/tdeio_media_mounthelper.cpp77
-rw-r--r--tdeioslave/media/mounthelper/tdeio_media_mounthelper.h2
2 files changed, 19 insertions, 60 deletions
diff --git a/tdeioslave/media/mounthelper/tdeio_media_mounthelper.cpp b/tdeioslave/media/mounthelper/tdeio_media_mounthelper.cpp
index ef3f10e8e..bbfbaa6b2 100644
--- a/tdeioslave/media/mounthelper/tdeio_media_mounthelper.cpp
+++ b/tdeioslave/media/mounthelper/tdeio_media_mounthelper.cpp
@@ -57,20 +57,6 @@ const Medium MountHelper::findMedium(const TQString &device)
void MountHelper::mount(const Medium &medium)
{
- if (medium.id().isEmpty()) {
- m_errorStr = i18n("Try to mount an unknown medium.");
- errorAndExit();
- }
- TQString device = medium.deviceNode();
- if (!medium.isMountable()) {
- m_errorStr = i18n("%1 is not a mountable media.").arg(device);
- errorAndExit();
- }
- else if (medium.isMounted()) {
- m_errorStr = i18n("%1 is already mounted to %2.").arg(device).arg(medium.mountPoint());
- errorAndExit();
- }
-
DCOPReply reply = m_mediamanager.call("mount", medium.id());
TQStringVariantMap mountResult;
if (reply.isValid()) {
@@ -84,20 +70,6 @@ void MountHelper::mount(const Medium &medium)
void MountHelper::unmount(const Medium &medium)
{
- if (medium.id().isEmpty()) {
- m_errorStr = i18n("Try to unmount an unknown medium.");
- errorAndExit();
- }
- TQString device = medium.deviceNode();
- if (!medium.isMountable()) {
- m_errorStr = i18n("%1 is not a mountable media.").arg(device);
- errorAndExit();
- }
- else if (!medium.isMounted()) {
- m_errorStr = i18n("%1 is already unmounted.").arg(device);
- errorAndExit();
- }
-
DCOPReply reply = m_mediamanager.call("unmount", medium.id());
TQStringVariantMap unmountResult;
if (reply.isValid()) {
@@ -112,19 +84,9 @@ void MountHelper::unmount(const Medium &medium)
void MountHelper::unlock(const Medium &medium)
{
- if (medium.id().isEmpty()) {
- m_errorStr = i18n("Try to unlock an unknown medium.");
- errorAndExit();
- }
TQString device = medium.deviceNode();
- if (!medium.isEncrypted())
- {
- m_errorStr = i18n("%1 is not an encrypted media.").arg(device);
- errorAndExit();
- }
- if (!medium.needUnlocking())
- {
- m_errorStr = i18n("%1 is already unlocked.").arg(device);
+ if (device.isEmpty()) {
+ m_errorStr = i18n("Try to unlock an unknown medium.");
errorAndExit();
}
@@ -175,32 +137,29 @@ void MountHelper::lock(const Medium &medium)
}
}
-void MountHelper::eject(const TQString &device, bool quiet)
+void MountHelper::eject(const Medium &medium)
{
#ifdef WITH_TDEHWLIB
- // Try TDE HW library eject first...
- TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
- TDEGenericDevice *hwdevice = hwdevices->findByDeviceNode(device);
- if (hwdevice->type() == TDEGenericDeviceType::Disk)
+ DCOPReply reply = m_mediamanager.call("eject", medium.id());
+ TQStringVariantMap ejectResult;
+ if (reply.isValid()) {
+ reply.get(ejectResult);
+ }
+ if (!ejectResult.contains("result") || !ejectResult["result"].toBool()) {
+ m_errorStr = ejectResult.contains("errStr") ? ejectResult["errStr"].toString() : i18n("Unknown eject error.");
+ kdDebug() << "medium eject " << m_errorStr << endl;
+ errorAndExit();
+ }
+ else
{
- TDEStorageDevice *sdevice = static_cast<TDEStorageDevice*>(hwdevice);
- TQStringVariantMap ejectResult = sdevice->ejectDrive();
- if (ejectResult["result"].toBool() == true)
- {
- // Success!
- ::exit(0);
- }
+ ::exit(0); // Success!
}
#endif
// Otherwise fall back to tdeeject
TDEProcess *proc = new TDEProcess(TQT_TQOBJECT(this));
*proc << "tdeeject";
- if (quiet)
- {
- *proc << "-q";
- }
- *proc << device;
+ *proc << medium.deviceNode();
connect(proc, TQT_SIGNAL(processExited(TDEProcess*)), this, TQT_SLOT(ejectFinished(TDEProcess*)));
proc->start();
}
@@ -356,13 +315,13 @@ MountHelper::MountHelper() : TDEApplication(), m_mediamanager("kded", "mediamana
}
else if (args->isSet("e"))
{
- eject(device, true);
+ eject(medium);
::exit(0);
}
else if (args->isSet("s"))
{
safeRemoval(medium);
- eject(device, true);
+ eject(medium);
::exit(0);
}
else if (args->isSet("f"))
diff --git a/tdeioslave/media/mounthelper/tdeio_media_mounthelper.h b/tdeioslave/media/mounthelper/tdeio_media_mounthelper.h
index 5bbe594b8..eff02b1e1 100644
--- a/tdeioslave/media/mounthelper/tdeio_media_mounthelper.h
+++ b/tdeioslave/media/mounthelper/tdeio_media_mounthelper.h
@@ -53,7 +53,7 @@ private:
void unmount(const Medium &medium);
void unlock(const Medium &medium);
void lock(const Medium &medium);
- void eject(const TQString &device, bool quiet=false);
+ void eject(const Medium &medium);
void safeRemoval(const Medium &medium);
void releaseHolders(const Medium &medium, bool handleThis = false);
void openRealFolder(const Medium &medium);