summaryrefslogtreecommitdiffstats
path: root/tdeioslave/media/mediamanager/mediamanager.cpp
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2021-03-06 21:06:00 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2021-03-06 21:06:18 +0900
commitd289ed30ed679d78a0ef2e06a66ed2c21d07bd16 (patch)
treeb88a273b11a8652ae865e957af7de421411ee828 /tdeioslave/media/mediamanager/mediamanager.cpp
parent6d7fe7fdb4c802a034ef763c7bc0d0768a47cff5 (diff)
downloadtdebase-d289ed30ed679d78a0ef2e06a66ed2c21d07bd16.tar.gz
tdebase-d289ed30ed679d78a0ef2e06a66ed2c21d07bd16.zip
mediamanager: added DCOP call to get medium's mimetype from its name.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'tdeioslave/media/mediamanager/mediamanager.cpp')
-rw-r--r--tdeioslave/media/mediamanager/mediamanager.cpp73
1 files changed, 47 insertions, 26 deletions
diff --git a/tdeioslave/media/mediamanager/mediamanager.cpp b/tdeioslave/media/mediamanager/mediamanager.cpp
index a74a887be..325609baf 100644
--- a/tdeioslave/media/mediamanager/mediamanager.cpp
+++ b/tdeioslave/media/mediamanager/mediamanager.cpp
@@ -136,39 +136,22 @@ void MediaManager::loadBackends()
m_mediaList.blockSignals(false);
}
-
-TQStringList MediaManager::fullList()
-{
- TQPtrList<Medium> list = m_mediaList.list();
-
- TQStringList result;
-
- TQPtrList<Medium>::const_iterator it = list.begin();
- TQPtrList<Medium>::const_iterator end = list.end();
- for (; it!=end; ++it)
- {
- result+= (*it)->properties();
- result+= Medium::SEPARATOR;
- }
-
- return result;
-}
-
-TQStringList MediaManager::properties(const TQString &name)
+const Medium* MediaManager::getMediumByName(const TQString &name)
{
const Medium *m = m_mediaList.findByName(name);
-
if (!m)
{
KURL u(name);
- kdDebug() << "Media::prop " << name << " " << u.isValid() << endl;
+ kdDebug() << "Media::getMediumByName " << name << " " << u.isValid() << endl;
if (u.isValid())
{
if (u.protocol() == "system")
{
TQString path = u.path();
if (path.startsWith("/media/"))
+ {
path = path.mid(strlen("/media/"));
+ }
m = m_mediaList.findByName(path);
kdDebug() << "findByName " << path << m << endl;
}
@@ -189,19 +172,44 @@ TQStringList MediaManager::properties(const TQString &name)
{
path = TDEStandardDirs::realFilePath(u.path());
kdDebug() << "comparing " << (*it)->mountPoint() << " " << path << " " << (*it)->deviceNode() << endl;
- if ((*it)->mountPoint() == path || (*it)->deviceNode() == path) {
- m = *it;
- break;
+ if ((*it)->mountPoint() == path || (*it)->deviceNode() == path)
+ {
+ m = *it;
+ break;
}
}
}
}
}
+ return m;
+}
- if (m) {
+TQStringList MediaManager::fullList()
+{
+ TQPtrList<Medium> list = m_mediaList.list();
+
+ TQStringList result;
+
+ TQPtrList<Medium>::const_iterator it = list.begin();
+ TQPtrList<Medium>::const_iterator end = list.end();
+ for (; it!=end; ++it)
+ {
+ result+= (*it)->properties();
+ result+= Medium::SEPARATOR;
+ }
+
+ return result;
+}
+
+TQStringList MediaManager::properties(const TQString &name)
+{
+ const Medium *m = getMediumByName(name);
+ if (m)
+ {
return m->properties();
}
- else {
+ else
+ {
return TQStringList();
}
}
@@ -396,6 +404,19 @@ TQStringVariantMap MediaManager::lockByNode(const TQString &deviceNode)
return lock(medium->id());
}
+TQString MediaManager::mimeType(const TQString &name)
+{
+ const Medium *m = getMediumByName(name);
+ if (m)
+ {
+ return m->mimeType();
+ }
+ else
+ {
+ return TQString::null;
+ }
+}
+
TQString MediaManager::nameForLabel(const TQString &label)
{
const TQPtrList<Medium> media = m_mediaList.list();