From b487b5bb8b314d381b6d13dcf4f49898f24b6f4a Mon Sep 17 00:00:00 2001 From: Mavridis Philippe Date: Fri, 15 Jan 2021 17:28:25 +0200 Subject: directorylist.*: Reimplemented mounting process. What remains is to figure out a way to pass ClamAV the mountpoint instead of the block device name. Signed-off-by: Mavridis Philippe --- src/directorylist.cpp | 51 +++++++++++++++++++++++++++------------------------ src/directorylist.h | 1 + 2 files changed, 28 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/directorylist.cpp b/src/directorylist.cpp index 80571ab..e62e532 100644 --- a/src/directorylist.cpp +++ b/src/directorylist.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -29,7 +30,6 @@ #include #include #include -#include #include "directorylist.h" @@ -432,6 +432,20 @@ DeviceItem::paintCell( TQPainter * p, const TQColorGroup & cg, int column, int w TQCheckListItem::paintCell( p, isDisabled() ? listView()->palette().disabled() : _cg, column, width, align ); } +TQString DeviceItem::getMountPoint( const TQString & device ) +{ + DCOPRef mediamanager("kded", "mediamanager"); + DCOPReply reply = mediamanager.call( "properties", device ); + + TQStringList properties; + reply.get( properties, "TQStringList" ); + + TQString mountpoint = * (properties.at(7) ); + + return mountpoint; + +} + void DeviceItem::mountDevice( const TQString & device) { @@ -439,34 +453,23 @@ DeviceItem::mountDevice( const TQString & device) if (!kapp->dcopClient()->isAttached()) kapp->dcopClient()->attach(); + TQString mountpoint; + mountpoint = getMountPoint(device); - //Set Up our DCOP Calls + if( mountpoint != TQString::null ) // already mounted + return; - TQStringList retVal; - TQCString mediacall="mediamanager"; - TQCString devicecall="properties"; - if ( KDE::versionMajor() == 3 && KDE::versionMinor() < 4 ) - { - mediacall="mountwatcher"; - devicecall="basicDeviceInfo"; - } - - - //Mount any devices that are not already mounted + DCOPRef mediamanager("kded", "mediamanager"); + DCOPReply reply = mediamanager.call( "mountByNode", device ); - DCOPRef mediamanager("kded", mediacall); - DCOPReply reply = mediamanager.call( devicecall, device ); + bool success; + reply.get( success, "bool" ); + + mountpoint = getMountPoint(device); - if ( !reply.isValid() ) - { - ////kdDebug() << "not valid" << endl; + if(! success || mountpoint == TQString::null ) { + KMessageBox::sorry( 0, i18n("Cannot mount %1. Please check that you have the permissions needed to mount the device, as well as the needed kernel modules loaded.") ); } - retVal = reply; - ////kdDebug() << retVal << endl; - ////kdDebug() << retVal[1] << endl; - ////kdDebug() << retVal[10] << endl; - if (!(retVal[10].contains("_mounted"))) - new KAutoMount( true, "", retVal[5], "","", false ); } diff --git a/src/directorylist.h b/src/directorylist.h index 343c3fa..4e4c058 100644 --- a/src/directorylist.h +++ b/src/directorylist.h @@ -113,6 +113,7 @@ class DeviceItem : public TQObject, public TQCheckListItem void completed() { if( childCount() == 0 ) { setExpandable( false ); repaint(); } } private: void mountDevice(const TQString & device); + TQString getMountPoint(const TQString & device); KDirLister m_lister; KURL m_url; bool m_listed; -- cgit v1.2.1