From e119eb28db6f5113b3082c0a46db2f487e5dda90 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sun, 7 Mar 2021 16:18:25 +0900 Subject: [PATCH] If requested to navigate to an encrypted disk from the location bar or CLI, offer the user the ability to unlock the disk and subsequently navigate to the "media" folder. This mirrors the same functionality introduced in Konqueror. Signed-off-by: Michele Calgaro --- src/urlnavigator.cpp | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/urlnavigator.cpp b/src/urlnavigator.cpp index 47eab75..725c062 100644 --- a/src/urlnavigator.cpp +++ b/src/urlnavigator.cpp @@ -22,6 +22,7 @@ #include "urlnavigator.h" #include +#include #include #include #include @@ -39,6 +40,7 @@ #include #include #include +#include #include "dolphin.h" #include "dolphinsettings.h" @@ -117,7 +119,8 @@ void URLNavigator::setURL(const KURL& url) { TQString urlStr(url.prettyURL()); - if (url.protocol() == "zip") { + if (url.protocol() == "zip") + { bool stillInside = false; if( KMimeType::findByPath( url.url(-1) )->is("application/x-zip") || KMimeType::findByPath( url.url(-1) )->is("application/x-jar") ) { @@ -180,6 +183,35 @@ void URLNavigator::setURL(const KURL& url) urlStr = url.path(); } } + else if (urlStr.startsWith("system:/media") || urlStr.startsWith("media:/")) + { + DCOPRef mediamanager("kded", "mediamanager"); + DCOPReply reply = mediamanager.call("mimeType", urlStr ); + if (reply.isValid()) + { + TQString itemMimeType = reply; + if (itemMimeType.contains("encrypted")) + { + if (itemMimeType.contains("encrypted_locked")) + { + TQString lockingService = TDEGlobal::dirs()->findResource("data", "d3lphin/servicemenus/media_unlock.desktop"); + if (!lockingService.isEmpty()) + { + TQValueList serviceList = KDEDesktopMimeType::userDefinedServices(lockingService, url.isLocalFile()); + if (serviceList.count() == 1) + { + KURL::List m_lstURLs; + m_lstURLs.append(url); + KDEDesktopMimeType::executeService(m_lstURLs, serviceList[0]); + } + } + } + setURL(KURL("system:/media")); + return; + } + } + + } if (urlStr.at(0) == '~') {