1/* This file is part of the KDE libraries
2 * Copyright (C) 1999 Waldo Bastian <bastian@kde.org>
3 * 2000, 2007 David Faure <faure@kde.org>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License version 2 as published by the Free Software Foundation;
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 **/
19
20#ifndef KDESKTOPFILEACTIONS_H
21#define KDESKTOPFILEACTIONS_H
22
23#include <kserviceaction.h>
24#include <kio/kio_export.h>
25#include <kurl.h>
26class KDesktopFile;
27class KService;
28
29/**
30 * KDesktopFileActions provides a number of methods related to actions in desktop files.
31 */
32namespace KDesktopFileActions
33{
34 /**
35 * Returns a list of services for the given .desktop file that are handled
36 * by kio itself. Namely mount/unmount for FSDevice files.
37 * @return the list of services
38 */
39 KIO_EXPORT QList<KServiceAction> builtinServices( const KUrl& url );
40
41 /**
42 * Returns a list of services defined by the user as possible actions
43 * on the given .desktop file. May include separators (see KServiceAction::isSeparator)
44 * which should appear in user-visible representations of those actions,
45 * such as separators in a menu.
46 * @param path the path to the desktop file describing the services
47 * @param bLocalFiles true if those services are to be applied to local files only
48 * (if false, services that don't have %u or %U in the Exec line won't be taken into account).
49 * @return the list of user defined actions
50 */
51 KIO_EXPORT QList<KServiceAction> userDefinedServices( const QString& path, bool bLocalFiles );
52
53 /**
54 * Overload of userDefinedServices but also allows you to pass a list of urls for this file.
55 * This allows for the menu to be changed depending on the exact files via
56 * the X-KDE-GetActionMenu extension.
57 */
58 KIO_EXPORT QList<KServiceAction> userDefinedServices( const QString& path, const KDesktopFile& desktopFile, bool bLocalFiles, const KUrl::List & file_list = KUrl::List());
59
60 /**
61 * Returns a list of services defined by the user as possible actions
62 * on the given .desktop file represented by the KService instance.
63 * May include separators (see KServiceAction::isSeparator) which should
64 * appear in user-visible representations of those actions,
65 * such as separators in a menu.
66 * @param path the path to the desktop file describing the services
67 * @param bLocalFiles true if those services are to be applied to local files only
68 * (if false, services that don't have %u or %U in the Exec line won't be taken into account).
69 * @param file_list list of urls; this allows for the menu to be changed depending on the exact files via
70 * the X-KDE-GetActionMenu extension.
71 *
72 * @return the list of user defined actions
73 */
74 KIO_EXPORT QList<KServiceAction> userDefinedServices( const KService& service, bool bLocalFiles, const KUrl::List & file_list = KUrl::List() );
75
76 /**
77 * Execute @p service on the list of @p urls.
78 * @param urls the list of urls
79 * @param service the service to execute
80 */
81 KIO_EXPORT void executeService( const KUrl::List& urls, const KServiceAction& service );
82
83 /**
84 * Invokes the default action for the desktop entry. If the desktop
85 * entry is not local, then only false is returned. Otherwise we
86 * would create a security problem. Only types Link and Mimetype
87 * could be followed.
88 *
89 * @param _url the url to run
90 * @param _is_local true if the URL is local, false otherwise
91 * @return true on success and false on failure.
92 * @see KRun::runUrl
93 */
94 KIO_EXPORT bool run( const KUrl& _url, bool _is_local );
95}
96
97#endif
98