summaryrefslogtreecommitdiffstats
path: root/tdeioslave/media/mediamanager
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/mediamanager
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/mediamanager')
-rw-r--r--tdeioslave/media/mediamanager/mediamanager.cpp126
-rw-r--r--tdeioslave/media/mediamanager/mediamanager.h2
-rw-r--r--tdeioslave/media/mediamanager/tdehardwarebackend.cpp42
-rw-r--r--tdeioslave/media/mediamanager/tdehardwarebackend.h3
4 files changed, 114 insertions, 59 deletions
diff --git a/tdeioslave/media/mediamanager/mediamanager.cpp b/tdeioslave/media/mediamanager/mediamanager.cpp
index 9b0ca7ceb..c3cd62524 100644
--- a/tdeioslave/media/mediamanager/mediamanager.cpp
+++ b/tdeioslave/media/mediamanager/mediamanager.cpp
@@ -189,103 +189,103 @@ TQStringList MediaManager::properties(const TQString &name)
TQStringList MediaManager::mountoptions(const TQString &name)
{
#ifdef COMPILE_TDEHARDWAREBACKEND
- if (!m_tdebackend)
- return TQStringList();
- return m_tdebackend->mountoptions(name);
-#else
- return TQStringList();
+ if (m_tdebackend)
+ {
+ return m_tdebackend->mountoptions(name);
+ }
#endif
+ return TQStringList();
}
bool MediaManager::setMountoptions(const TQString &name, const TQStringList &options)
{
#ifdef COMPILE_TDEHARDWAREBACKEND
- if (!m_tdebackend)
- return false;
- return m_tdebackend->setMountoptions(name, options);
-#else
- return false;
+ if (m_tdebackend)
+ {
+ return m_tdebackend->setMountoptions(name, options);
+ }
#endif
+ return false;
}
TQStringVariantMap MediaManager::mount(const TQString &uid)
{
- TQStringVariantMap result;
#ifdef COMPILE_TDEHARDWAREBACKEND
- if (!m_tdebackend) {
- result["errStr"] = i18n("Feature only available with the TDE hardware backend");
- result["result"] = false;
- return result;
+ if (m_tdebackend)
+ {
+ return m_tdebackend->mount(uid);
}
- return m_tdebackend->mount(uid);
#else
- if (!m_fstabbackend) {
- result["errStr"] = i18n("Feature only available with the TDE hardware backend");
- result["result"] = false;
- return result;
+ if (m_fstabbackend)
+ {
+ return m_fstabbackend->mount(uid);
}
- return m_fstabbackend->mount(uid);
#endif
+ TQStringVariantMap result;
+ result["errStr"] = i18n("Feature only available with the TDE or fstab hardware backend");
+ result["result"] = false;
+ return result;
}
TQStringVariantMap MediaManager::unmount(const TQString &uid)
{
- TQStringVariantMap result;
#ifdef COMPILE_TDEHARDWAREBACKEND
- if (!m_tdebackend) {
- result["errStr"] = i18n("Feature only available with the TDE hardware backend");
- result["result"] = false;
- return result;
+ if (m_tdebackend)
+ {
+ return m_tdebackend->unmount(uid);
}
- return m_tdebackend->unmount(uid);
#else
- if (!m_fstabbackend) {
- result["errStr"] = i18n("Feature only available with the TDE hardware backend");
- result["result"] = false;
- return result;
+ if (m_fstabbackend)
+ {
+ return m_fstabbackend->unmount(uid);
}
- return m_fstabbackend->unmount(uid);
#endif
+ TQStringVariantMap result;
+ result["errStr"] = i18n("Feature only available with the TDE or fstab hardware backend");
+ result["result"] = false;
+ return result;
}
TQStringVariantMap MediaManager::unlock(const TQString &uid, const TQString &password)
{
- TQStringVariantMap result;
#ifdef COMPILE_TDEHARDWAREBACKEND
- if (!m_tdebackend) {
- result["errStr"] = i18n("Feature only available with the TDE hardware backend");
- result["result"] = false;
- return result;
+ if (m_tdebackend)
+ {
+ return m_tdebackend->unlock(uid, password);
}
- return m_tdebackend->unlock(uid, password);
-#else
-// if (!m_fstabbackend) {
- result["errStr"] = i18n("Feature only available with the TDE hardware backend");
- result["result"] = false;
- return result;
-// }
-// return m_fstabbackend->unlock(uid, password);
#endif
+ TQStringVariantMap result;
+ result["errStr"] = i18n("Feature only available with the TDE hardware backend");
+ result["result"] = false;
+ return result;
}
TQStringVariantMap MediaManager::lock(const TQString &uid)
{
+#ifdef COMPILE_TDEHARDWAREBACKEND
+ if (m_tdebackend)
+ {
+ return m_tdebackend->lock(uid);
+ }
+#endif
TQStringVariantMap result;
+ result["errStr"] = i18n("Feature only available with the TDE hardware backend");
+ result["result"] = false;
+ return result;
+}
+
+TQStringVariantMap MediaManager::eject(const TQString &uid)
+{
#ifdef COMPILE_TDEHARDWAREBACKEND
- if (!m_tdebackend) {
- result["errStr"] = i18n("Feature only available with the TDE hardware backend");
- result["result"] = false;
- return result;
+ if (m_tdebackend)
+ {
+ return m_tdebackend->eject(uid);
}
- return m_tdebackend->lock(uid);
-#else
-// if (!m_fstabbackend) {
- result["errStr"] = i18n("Feature only available with the TDE hardware backend");
- result["result"] = false;
- return result;
-// }
-// return m_fstabbackend->lock(uid);
#endif
+ TQStringVariantMap result;
+ result["errStr"] = i18n("Feature only available with the TDE hardware backend");
+ result["result"] = false;
+ return result;
}
TQStringVariantMap MediaManager::mountByNode(const TQString &deviceNode)
@@ -336,6 +336,18 @@ TQStringVariantMap MediaManager::lockByNode(const TQString &deviceNode)
return lock(medium->id());
}
+TQStringVariantMap MediaManager::ejectByNode(const TQString &deviceNode)
+{
+ const Medium *medium = m_mediaList.findByNode(deviceNode);
+ if (!medium) {
+ TQStringVariantMap result;
+ result["errStr"] = i18n("No such medium: %1").arg(deviceNode);
+ result["result"] = false;
+ return result;
+ }
+ return eject(medium->id());
+}
+
TQString MediaManager::mimeType(const TQString &name)
{
const Medium *m = getMediumByName(name);
diff --git a/tdeioslave/media/mediamanager/mediamanager.h b/tdeioslave/media/mediamanager/mediamanager.h
index 08810464c..7d5e6dc24 100644
--- a/tdeioslave/media/mediamanager/mediamanager.h
+++ b/tdeioslave/media/mediamanager/mediamanager.h
@@ -52,11 +52,13 @@ k_dcop:
TQStringVariantMap unmount(const TQString &uid);
TQStringVariantMap unlock(const TQString &uid, const TQString &password);
TQStringVariantMap lock(const TQString &uid);
+ TQStringVariantMap eject(const TQString &uid);
TQStringVariantMap mountByNode(const TQString &deviceNode);
TQStringVariantMap unmountByNode(const TQString &deviceNode);
TQStringVariantMap unlockByNode(const TQString &deviceNode, const TQString &password);
TQStringVariantMap lockByNode(const TQString &deviceNode);
+ TQStringVariantMap ejectByNode(const TQString &deviceNode);
TQString mimeType(const TQString &name);
TQString nameForLabel(const TQString &label);
diff --git a/tdeioslave/media/mediamanager/tdehardwarebackend.cpp b/tdeioslave/media/mediamanager/tdehardwarebackend.cpp
index 1da7634d0..ba99b8c0c 100644
--- a/tdeioslave/media/mediamanager/tdehardwarebackend.cpp
+++ b/tdeioslave/media/mediamanager/tdehardwarebackend.cpp
@@ -1474,7 +1474,6 @@ TQStringVariantMap TDEBackend::unlock(const TQString &id, const TQString &passwo
}
ResetProperties(sdevice, false, true);
- result["result"] = unlockResult["unlockedDevice"];
result["result"] = true;
return result;
}
@@ -1526,6 +1525,47 @@ TQStringVariantMap TDEBackend::lock(const TQString &id)
return result;
}
+TQStringVariantMap TDEBackend::eject(const TQString &id)
+{
+ kdDebug(1219) << "TDEBackend::eject for id " << id << endl;
+
+ TQStringVariantMap result;
+
+ const Medium *medium = m_mediaList.findById(id);
+ if (!medium)
+ {
+ result["errStr"] = i18n("No such medium: %1").arg(id);
+ result["result"] = false;
+ return result;
+ }
+
+ TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
+ TDEStorageDevice *sdevice = hwdevices->findDiskByUID(medium->id());
+ if (!sdevice)
+ {
+ result["errStr"] = i18n("Internal error. Couldn't find medium id %1.").arg(medium->id());
+ result["result"] = false;
+ return result;
+ }
+
+ TQStringVariantMap ejectResult = sdevice->ejectDrive();
+ if (ejectResult["result"].toBool() == false)
+ {
+ TQString qerror = i18n("<b>Unable to eject the device.</b>");
+ TQString errStr = ejectResult.contains("errStr") ? ejectResult["errStr"].toString() : TQString::null;
+ if (!errStr.isEmpty())
+ {
+ qerror.append(i18n("<p>Technical details:<br>").append(errStr));
+ result["errStr"] = qerror;
+ result["result"] = false;
+ return result;
+ }
+ }
+
+ result["result"] = true;
+ return result;
+}
+
void TDEBackend::slotResult(TDEIO::Job *job)
{
TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
diff --git a/tdeioslave/media/mediamanager/tdehardwarebackend.h b/tdeioslave/media/mediamanager/tdehardwarebackend.h
index 449d6369d..ab7eeea97 100644
--- a/tdeioslave/media/mediamanager/tdehardwarebackend.h
+++ b/tdeioslave/media/mediamanager/tdehardwarebackend.h
@@ -68,11 +68,12 @@ public:
bool setMountoptions(const TQString &id, const TQStringList &options);
- TQStringVariantMap mount(const TQString &id);
TQStringVariantMap mount(const Medium *medium);
+ TQStringVariantMap mount(const TQString &id);
TQStringVariantMap unmount(const TQString &id);
TQStringVariantMap unlock(const TQString &id, const TQString &password);
TQStringVariantMap lock(const TQString &id);
+ TQStringVariantMap eject(const TQString &uid);
private:
/**