From 3fb20961297035f634a4f4a6921a8b2fed16642e Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Mon, 13 May 2024 06:14:23 +0300 Subject: [PATCH] kio: remove redundant KDesktopFileActions::userDefinedServices() overload there is one convenience overload already Signed-off-by: Ivailo Monev --- kio/kio/kdesktopfileactions.cpp | 34 ++++++++++++++++----------------- kio/kio/kdesktopfileactions.h | 26 ++++++++++++------------- 2 files changed, 28 insertions(+), 32 deletions(-) diff --git a/kio/kio/kdesktopfileactions.cpp b/kio/kio/kdesktopfileactions.cpp index 351ae8c4..1907697f 100644 --- a/kio/kio/kdesktopfileactions.cpp +++ b/kio/kio/kdesktopfileactions.cpp @@ -41,32 +41,32 @@ enum BuiltinServiceType { ST_MOUNT = 0x0E1B05B0, ST_UNMOUNT = 0x0E1B05B1 }; // r static bool runFSDevice( const KUrl& _url, const KDesktopFile &cfg ); static bool runLink( const KUrl& _url, const KDesktopFile &cfg ); -bool KDesktopFileActions::run( const KUrl& u, bool _is_local ) +bool KDesktopFileActions::run(const KUrl &url, bool is_local) { // It might be a security problem to run external untrusted desktop // entry files - if ( !_is_local ) + if (!is_local) return false; - KDesktopFile cfg(u.toLocalFile()); + KDesktopFile cfg(url.toLocalFile()); if ( !cfg.desktopGroup().hasKey("Type") ) { KMessageBox::error( nullptr, - i18n("The desktop entry file %1 has no Type=... entry.", u.toLocalFile()) + i18n("The desktop entry file %1 has no Type=... entry.", url.toLocalFile()) ); return false; } // kDebug() << "TYPE = " << type.data(); - if ( cfg.hasDeviceType() ) - return runFSDevice( u, cfg ); - else if ( cfg.hasApplicationType() + if (cfg.hasDeviceType()) + return runFSDevice(url, cfg); + else if (cfg.hasApplicationType() || (cfg.readType() == "Service" && !cfg.desktopGroup().readEntry("Exec").isEmpty())) // for kio_settings - return KToolInvocation::self()->startServiceByStorageId( u.toLocalFile() ); - else if ( cfg.hasLinkType() ) - return runLink( u, cfg ); + return KToolInvocation::self()->startServiceByStorageId(url.toLocalFile()); + else if (cfg.hasLinkType()) + return runLink(url, cfg); KMessageBox::error( nullptr, @@ -179,19 +179,17 @@ QList KDesktopFileActions::builtinServices( const KUrl& _url ) return result; } -QList KDesktopFileActions::userDefinedServices( const QString& path, bool bLocalFiles ) -{ - KDesktopFile cfg( path ); - return userDefinedServices( cfg, bLocalFiles ); -} - -QList KDesktopFileActions::userDefinedServices( const KDesktopFile& cfg, bool bLocalFiles, const KUrl::List & file_list ) +QList KDesktopFileActions::userDefinedServices(const KDesktopFile& cfg, + bool bLocalFiles, + const KUrl::List &file_list) { KService service(&cfg); return userDefinedServices(service, bLocalFiles, file_list); } -QList KDesktopFileActions::userDefinedServices( const KService& service, bool bLocalFiles, const KUrl::List & file_list ) +QList KDesktopFileActions::userDefinedServices(const KService &service, + bool bLocalFiles, + const KUrl::List &file_list) { QList result; diff --git a/kio/kio/kdesktopfileactions.h b/kio/kio/kdesktopfileactions.h index cb0fc8c1..75b11486 100644 --- a/kio/kio/kdesktopfileactions.h +++ b/kio/kio/kdesktopfileactions.h @@ -37,7 +37,7 @@ namespace KDesktopFileActions * by kio itself. Namely mount/unmount for FSDevice files. * @return the list of services */ - KIO_EXPORT QList builtinServices( const KUrl& url ); + KIO_EXPORT QList builtinServices(const KUrl &url); /** * Returns a list of services defined by the user as possible actions @@ -47,16 +47,13 @@ namespace KDesktopFileActions * @param path the path to the desktop file describing the services * @param bLocalFiles true if those services are to be applied to local files only * (if false, services that don't have %u or %U in the Exec line won't be taken into account). + * @param file_list list of urls; this allows for the menu to be changed depending on the exact files via + * the X-KDE-GetActionMenu extension. + * * @return the list of user defined actions */ - KIO_EXPORT QList userDefinedServices( const QString& path, bool bLocalFiles ); - - /** - * Overload of userDefinedServices but also allows you to pass a list of urls for this file. - * This allows for the menu to be changed depending on the exact files via - * the X-KDE-GetActionMenu extension. - */ - KIO_EXPORT QList userDefinedServices( const KDesktopFile& desktopFile, bool bLocalFiles, const KUrl::List & file_list = KUrl::List()); + KIO_EXPORT QList userDefinedServices(const KDesktopFile &desktopFile, bool bLocalFiles, + const KUrl::List &file_list = KUrl::List()); /** * Returns a list of services defined by the user as possible actions @@ -72,14 +69,15 @@ namespace KDesktopFileActions * * @return the list of user defined actions */ - KIO_EXPORT QList userDefinedServices( const KService& service, bool bLocalFiles, const KUrl::List & file_list = KUrl::List() ); + KIO_EXPORT QList userDefinedServices(const KService &service, bool bLocalFiles, + const KUrl::List &file_list = KUrl::List()); /** * Execute @p service on the list of @p urls. * @param urls the list of urls * @param service the service to execute */ - KIO_EXPORT void executeService( const KUrl::List& urls, const KServiceAction& service ); + KIO_EXPORT void executeService(const KUrl::List &urls, const KServiceAction &service); /** * Invokes the default action for the desktop entry. If the desktop @@ -87,12 +85,12 @@ namespace KDesktopFileActions * would create a security problem. Only types Link and Mimetype * could be followed. * - * @param _url the url to run - * @param _is_local true if the URL is local, false otherwise + * @param url the url to run + * @param is_local true if the URL is local, false otherwise * @return true on success and false on failure. * @see KRun, KToolInvocation */ - KIO_EXPORT bool run( const KUrl& _url, bool _is_local ); + KIO_EXPORT bool run(const KUrl &url, bool is_local); } #endif