summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2019-09-15 14:30:27 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2019-10-14 22:58:15 +0900
commit83edd347fbde0a85933e1cb4ecb99c94d346d335 (patch)
tree35ccd4aed01610cf05ce9243ca1a213bb6318086
parentfc25c30c68c6fad556bfd8e05d26c8c99416b1f0 (diff)
downloadtdebase-bug/2273/luks.tar.gz
tdebase-bug/2273/luks.zip
konqueror & kdesktop: default action for a media encrypted disk isbug/2273/luks
either lock or unlock based on the current locking status. Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
-rw-r--r--konqueror/konq_mainwindow.cc23
-rw-r--r--libkonq/tdefileivi.cc41
2 files changed, 53 insertions, 11 deletions
diff --git a/konqueror/konq_mainwindow.cc b/konqueror/konq_mainwindow.cc
index 890b7a457..8ce8ab800 100644
--- a/konqueror/konq_mainwindow.cc
+++ b/konqueror/konq_mainwindow.cc
@@ -476,11 +476,9 @@ void KonqMainWindow::openURL( KonqView *_view, const KURL &_url,
const TQString &_serviceType, KonqOpenURLRequest& req,
bool trustedSource )
{
-#ifndef NDEBUG // needed for req.debug()
kdDebug(1202) << "KonqMainWindow::openURL : url = '" << _url << "' "
<< "serviceType='" << _serviceType << "' req=" << req.debug()
<< " view=" << _view << endl;
-#endif
KURL url( _url );
if (url.url().startsWith("$(")) {
@@ -562,6 +560,27 @@ void KonqMainWindow::openURL( KonqView *_view, const KURL &_url,
return;
}
+ // Default action for media encrypted disks is either lock or unlock based on current status
+ TQString lockingAction = TQString::null;
+ if (serviceType.contains("encrypted_locked")) {
+ lockingAction = "konqueror/servicemenus/media_unlock.desktop";
+ }
+ else if (serviceType.contains("encrypted_unlocked")) {
+ lockingAction = "konqueror/servicemenus/media_lock.desktop";
+ }
+ if (!lockingAction.isEmpty()) {
+ TQString lockingService = TDEGlobal::dirs()->findResource("data", lockingAction);
+ if (!lockingService.isEmpty()) {
+ TQValueList<KDEDesktopMimeType::Service> serviceList = KDEDesktopMimeType::userDefinedServices(lockingService, url.isLocalFile());
+ if (serviceList.count() == 1) {
+ KURL::List m_lstURLs;
+ m_lstURLs.append(url);
+ KDEDesktopMimeType::executeService(m_lstURLs, serviceList[0]);
+ return;
+ }
+ }
+ }
+
TQString nameFilter = detectNameFilter( url );
if ( !nameFilter.isEmpty() )
{
diff --git a/libkonq/tdefileivi.cc b/libkonq/tdefileivi.cc
index 2e23cfbf7..eb289def2 100644
--- a/libkonq/tdefileivi.cc
+++ b/libkonq/tdefileivi.cc
@@ -32,6 +32,8 @@
#include <kdebug.h>
#include <krun.h>
#include <kservice.h>
+#include <kmimetype.h> // for KDEDesktopMimeType
+#include <kstandarddirs.h>
#undef Bool
@@ -386,17 +388,38 @@ void KFileIVI::returnPressed()
if ( static_cast<KonqIconViewWidget*>(iconView())->isDesktop() ) {
KURL url = m_fileitem->url();
if (url.protocol() == "media") {
- // The user reasonably expects to be placed within the media:/ tree
- // when opening a media device from the desktop
- KService::Ptr service = KService::serviceByDesktopName("konqueror");
- if (service) {
- // HACK
- // There doesn't seem to be a way to prevent KRun from resolving the URL to its
- // local path, so simpy launch Konqueror with the correct arguments instead...
- KRun::runCommand("konqueror " + url.url(), "konqueror", service->icon());
+ TQString mimetype = m_fileitem->mimetype();
+ TQString lockingAction = TQString::null;
+ if (mimetype.contains("encrypted_locked")) {
+ lockingAction = "konqueror/servicemenus/media_unlock.desktop";
+ }
+ else if (mimetype.contains("encrypted_unlocked")) {
+ lockingAction = "konqueror/servicemenus/media_lock.desktop";
+ }
+ if (!lockingAction.isEmpty()) {
+ TQString lockingService = TDEGlobal::dirs()->findResource("data", lockingAction);
+ if (!lockingService.isEmpty()) {
+ TQValueList<KDEDesktopMimeType::Service> serviceList = KDEDesktopMimeType::userDefinedServices(lockingService, m_fileitem->isLocalFile());
+ if (serviceList.count() == 1) {
+ KURL::List m_lstURLs;
+ m_lstURLs.append(m_fileitem->url());
+ KDEDesktopMimeType::executeService(m_lstURLs, serviceList[0]);
+ }
+ }
}
else {
- (void) new KRun( url, m_fileitem->mode(), m_fileitem->isLocalFile() );
+ // The user reasonably expects to be placed within the media:/ tree
+ // when opening a media device from the desktop
+ KService::Ptr service = KService::serviceByDesktopName("konqueror");
+ if (service) {
+ // HACK
+ // There doesn't seem to be a way to prevent KRun from resolving the URL to its
+ // local path, so simpy launch Konqueror with the correct arguments instead...
+ KRun::runCommand("konqueror " + url.url(), "konqueror", service->icon());
+ }
+ else {
+ (void) new KRun( url, m_fileitem->mode(), m_fileitem->isLocalFile() );
+ }
}
}
else {