summaryrefslogtreecommitdiffstats
path: root/tdeioslave
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
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')
-rw-r--r--tdeioslave/media/mediamanager/mediamanager.cpp73
-rw-r--r--tdeioslave/media/mediamanager/mediamanager.h3
2 files changed, 50 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();
diff --git a/tdeioslave/media/mediamanager/mediamanager.h b/tdeioslave/media/mediamanager/mediamanager.h
index d8a31d8e1..3c49109f3 100644
--- a/tdeioslave/media/mediamanager/mediamanager.h
+++ b/tdeioslave/media/mediamanager/mediamanager.h
@@ -41,6 +41,8 @@ public:
MediaManager(const TQCString &obj);
~MediaManager();
+ const Medium* getMediumByName(const TQString &name);
+
k_dcop:
TQStringList fullList();
TQStringList properties(const TQString &name);
@@ -57,6 +59,7 @@ k_dcop:
TQStringVariantMap unlockByNode(const TQString &deviceNode, const TQString &password);
TQStringVariantMap lockByNode(const TQString &deviceNode);
+ TQString mimeType(const TQString &name);
TQString nameForLabel(const TQString &label);
ASYNC setUserLabel(const TQString &name, const TQString &label);