summaryrefslogtreecommitdiffstats
path: root/tdeioslave/media/mediamanager
diff options
context:
space:
mode:
authorMichele Calgaro <[email protected]>2022-03-27 20:01:48 +0900
committerMichele Calgaro <[email protected]>2022-03-27 20:01:48 +0900
commit4974727d50923a4393e5f0daddf4694c6e082a84 (patch)
tree97b2bc694bab23db107f132188ebed4fc46ac3da /tdeioslave/media/mediamanager
parent88d92af3c14c0b0b9149440c1b5d38e8fb7cbd79 (diff)
downloadtdebase-4974727d50923a4393e5f0daddf4694c6e082a84.tar.gz
tdebase-4974727d50923a4393e5f0daddf4694c6e082a84.zip
Add 'safeRemove' and 'safeRemoveByNode' to mediamanager DCOP interface.
Signed-off-by: Michele Calgaro <[email protected]>
Diffstat (limited to 'tdeioslave/media/mediamanager')
-rw-r--r--tdeioslave/media/mediamanager/mediamanager.cpp26
-rw-r--r--tdeioslave/media/mediamanager/mediamanager.h2
-rw-r--r--tdeioslave/media/mediamanager/tdehardwarebackend.cpp18
-rw-r--r--tdeioslave/media/mediamanager/tdehardwarebackend.h1
4 files changed, 47 insertions, 0 deletions
diff --git a/tdeioslave/media/mediamanager/mediamanager.cpp b/tdeioslave/media/mediamanager/mediamanager.cpp
index dba4c1150..f8c2a574b 100644
--- a/tdeioslave/media/mediamanager/mediamanager.cpp
+++ b/tdeioslave/media/mediamanager/mediamanager.cpp
@@ -288,6 +288,20 @@ TQStringVariantMap MediaManager::eject(const TQString &uid)
return result;
}
+TQStringVariantMap MediaManager::safeRemove(const TQString &uid)
+{
+#ifdef COMPILE_TDEHARDWAREBACKEND
+ if (m_tdebackend)
+ {
+ return m_tdebackend->safeRemove(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)
{
const Medium *medium = m_mediaList.findByNode(deviceNode);
@@ -348,6 +362,18 @@ TQStringVariantMap MediaManager::ejectByNode(const TQString &deviceNode)
return eject(medium->id());
}
+TQStringVariantMap MediaManager::safeRemoveByNode(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 safeRemove(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 dfb3e577c..7bc67b24c 100644
--- a/tdeioslave/media/mediamanager/mediamanager.h
+++ b/tdeioslave/media/mediamanager/mediamanager.h
@@ -53,12 +53,14 @@ k_dcop:
TQStringVariantMap unlock(const TQString &uid, const TQString &password);
TQStringVariantMap lock(const TQString &uid, bool releaseHolders);
TQStringVariantMap eject(const TQString &uid);
+ TQStringVariantMap safeRemove(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, bool releaseHolders);
TQStringVariantMap ejectByNode(const TQString &deviceNode);
+ TQStringVariantMap safeRemoveByNode(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 bb5849149..0e6eb4ad8 100644
--- a/tdeioslave/media/mediamanager/tdehardwarebackend.cpp
+++ b/tdeioslave/media/mediamanager/tdehardwarebackend.cpp
@@ -1575,6 +1575,24 @@ TQStringVariantMap TDEBackend::eject(const TQString &id)
return result;
}
+TQStringVariantMap TDEBackend::safeRemove(const TQString &id)
+{
+ kdDebug(1219) << "TDEBackend::safeRemove 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;
+ }
+
+ releaseHolderDevices(medium->deviceNode(), true);
+ return eject(id);
+}
+
void TDEBackend::releaseHolderDevices(const TQString &deviceNode, bool handleThis)
{
kdDebug(1219) << "TDEBackend::releaseHolderDevices for node " << deviceNode
diff --git a/tdeioslave/media/mediamanager/tdehardwarebackend.h b/tdeioslave/media/mediamanager/tdehardwarebackend.h
index e1b3a9f85..308a9421e 100644
--- a/tdeioslave/media/mediamanager/tdehardwarebackend.h
+++ b/tdeioslave/media/mediamanager/tdehardwarebackend.h
@@ -74,6 +74,7 @@ public:
TQStringVariantMap unlock(const TQString &id, const TQString &password);
TQStringVariantMap lock(const TQString &id, bool releaseHolders);
TQStringVariantMap eject(const TQString &id);
+ TQStringVariantMap safeRemove(const TQString &uid);
private:
/**