diff options
Diffstat (limited to 'tdeioslave/media/mediamanager')
-rw-r--r-- | tdeioslave/media/mediamanager/medialist.cpp | 17 | ||||
-rw-r--r-- | tdeioslave/media/mediamanager/medialist.h | 8 | ||||
-rw-r--r-- | tdeioslave/media/mediamanager/mediamanager.cpp | 48 | ||||
-rw-r--r-- | tdeioslave/media/mediamanager/mediamanager.h | 5 |
4 files changed, 74 insertions, 4 deletions
diff --git a/tdeioslave/media/mediamanager/medialist.cpp b/tdeioslave/media/mediamanager/medialist.cpp index d9c4f0eb3..fa7aef5f5 100644 --- a/tdeioslave/media/mediamanager/medialist.cpp +++ b/tdeioslave/media/mediamanager/medialist.cpp @@ -52,6 +52,15 @@ const Medium *MediaList::findByName(const TQString &name) const return m_nameMap[name]; } +const Medium *MediaList::findByNode(const TQString &node) const +{ + kdDebug(1219) << "MediaList::findByNode(" << node << ")" << endl; + + if ( !m_nodeMap.contains(node) ) return 0L; + + return m_nodeMap[node]; +} + const Medium *MediaList::findByClearUdi(const TQString &name) { kdDebug(1219) << "MediaList::findByClearUdi(" << name << ")" << endl; @@ -64,7 +73,6 @@ const Medium *MediaList::findByClearUdi(const TQString &name) return 0L; } - TQString MediaList::addMedium(Medium *medium, bool allowNotification) { kdDebug(1219) << "MediaList::addMedium(@" << medium->id() << ")" << endl; @@ -75,6 +83,12 @@ TQString MediaList::addMedium(Medium *medium, bool allowNotification) m_nameMap[name] = medium; } + TQString node = medium->deviceNode(); + if (!m_nodeMap.contains(node)) + { + m_nodeMap[node] = medium; + } + TQString id = medium->id(); if (m_idMap.contains(id)) { @@ -101,6 +115,7 @@ bool MediaList::removeMedium(const TQString &id, bool allowNotification) Medium *medium = m_idMap[id]; m_idMap.remove(id); m_nameMap.remove(medium->name()); + m_nodeMap.remove(medium->deviceNode()); TQString name = medium->name(); m_media.remove(medium); diff --git a/tdeioslave/media/mediamanager/medialist.h b/tdeioslave/media/mediamanager/medialist.h index 59ddb6bd2..f4b088526 100644 --- a/tdeioslave/media/mediamanager/medialist.h +++ b/tdeioslave/media/mediamanager/medialist.h @@ -1,5 +1,5 @@ /* This file is part of the KDE Project - Copyright (c) 2004 K�vin Ottens <ervin ipsquad net> + Copyright (c) 2004 Kévin Ottens <ervin ipsquad net> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -34,6 +34,7 @@ public: const TQPtrList<Medium> list() const; const Medium *findById(const TQString &id) const; const Medium *findByName(const TQString &name) const; + const Medium *findByNode(const TQString &node) const; const Medium *findByClearUdi(const TQString &name); public: @@ -73,8 +74,9 @@ signals: private: TQPtrList<Medium> m_media; - TQMap<TQString,Medium*> m_nameMap; - TQMap<TQString,Medium*> m_idMap; + TQMap<TQString, Medium*> m_idMap; + TQMap<TQString, Medium*> m_nameMap; + TQMap<TQString, Medium*> m_nodeMap; }; #endif diff --git a/tdeioslave/media/mediamanager/mediamanager.cpp b/tdeioslave/media/mediamanager/mediamanager.cpp index ef6721999..6f498ffc8 100644 --- a/tdeioslave/media/mediamanager/mediamanager.cpp +++ b/tdeioslave/media/mediamanager/mediamanager.cpp @@ -355,6 +355,54 @@ TQStringVariantMap MediaManager::undecrypt(const TQString &uid) #endif } +TQStringVariantMap MediaManager::mountByNode(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 mount(medium->id()); +} + +TQStringVariantMap MediaManager::unmountByNode(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 unmount(medium->id()); +} + +TQStringVariantMap MediaManager::decryptByNode(const TQString &deviceNode, const TQString &password) +{ + 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 decrypt(medium->id(), password); +} + +TQStringVariantMap MediaManager::undecryptByNode(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 undecrypt(medium->id()); +} + 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 673629cf9..667626370 100644 --- a/tdeioslave/media/mediamanager/mediamanager.h +++ b/tdeioslave/media/mediamanager/mediamanager.h @@ -52,6 +52,11 @@ k_dcop: TQStringVariantMap decrypt(const TQString &uid, const TQString &password); TQStringVariantMap undecrypt(const TQString &uid); + TQStringVariantMap mountByNode(const TQString &deviceNode); + TQStringVariantMap unmountByNode(const TQString &deviceNode); + TQStringVariantMap decryptByNode(const TQString &deviceNode, const TQString &password); + TQStringVariantMap undecryptByNode(const TQString &deviceNode); + TQString nameForLabel(const TQString &label); ASYNC setUserLabel(const TQString &name, const TQString &label); |