mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kio: remove redundant KDesktopFileActions::userDefinedServices() overload
there is one convenience overload already Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
0364baa81f
commit
3fb2096129
2 changed files with 28 additions and 32 deletions
|
@ -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<KServiceAction> KDesktopFileActions::builtinServices( const KUrl& _url )
|
|||
return result;
|
||||
}
|
||||
|
||||
QList<KServiceAction> KDesktopFileActions::userDefinedServices( const QString& path, bool bLocalFiles )
|
||||
{
|
||||
KDesktopFile cfg( path );
|
||||
return userDefinedServices( cfg, bLocalFiles );
|
||||
}
|
||||
|
||||
QList<KServiceAction> KDesktopFileActions::userDefinedServices( const KDesktopFile& cfg, bool bLocalFiles, const KUrl::List & file_list )
|
||||
QList<KServiceAction> KDesktopFileActions::userDefinedServices(const KDesktopFile& cfg,
|
||||
bool bLocalFiles,
|
||||
const KUrl::List &file_list)
|
||||
{
|
||||
KService service(&cfg);
|
||||
return userDefinedServices(service, bLocalFiles, file_list);
|
||||
}
|
||||
|
||||
QList<KServiceAction> KDesktopFileActions::userDefinedServices( const KService& service, bool bLocalFiles, const KUrl::List & file_list )
|
||||
QList<KServiceAction> KDesktopFileActions::userDefinedServices(const KService &service,
|
||||
bool bLocalFiles,
|
||||
const KUrl::List &file_list)
|
||||
{
|
||||
QList<KServiceAction> result;
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace KDesktopFileActions
|
|||
* by kio itself. Namely mount/unmount for FSDevice files.
|
||||
* @return the list of services
|
||||
*/
|
||||
KIO_EXPORT QList<KServiceAction> builtinServices( const KUrl& url );
|
||||
KIO_EXPORT QList<KServiceAction> 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<KServiceAction> 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<KServiceAction> userDefinedServices( const KDesktopFile& desktopFile, bool bLocalFiles, const KUrl::List & file_list = KUrl::List());
|
||||
KIO_EXPORT QList<KServiceAction> 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<KServiceAction> userDefinedServices( const KService& service, bool bLocalFiles, const KUrl::List & file_list = KUrl::List() );
|
||||
KIO_EXPORT QList<KServiceAction> 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
|
||||
|
|
Loading…
Add table
Reference in a new issue