Warning: That file was not part of the compilation database. It may have many parsing errors.
1 | /* This file is part of the KDE libraries |
---|---|
2 | Copyright (c) 1999 Pietro Iglio <iglio@kde.org> |
3 | |
4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. |
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 | #ifndef KDESKTOPFILE_H |
20 | #define KDESKTOPFILE_H |
21 | |
22 | #include <kconfig.h> |
23 | |
24 | class KConfigGroup; |
25 | class KDesktopFilePrivate; |
26 | |
27 | /** |
28 | * \class KDesktopFile kdesktopfile.h <KDesktopFile> |
29 | * |
30 | * %KDE Desktop File Management. |
31 | * This class implements %KDE's support for the freedesktop.org |
32 | * <em>Desktop Entry Spec</em>. |
33 | * |
34 | * @author Pietro Iglio <iglio@kde.org> |
35 | * @see KConfigBase KConfig |
36 | * @see <a href="http://standards.freedesktop.org/desktop-entry-spec/latest/">Desktop Entry Spec</a> |
37 | */ |
38 | class KDECORE_EXPORT KDesktopFile : public KConfig |
39 | { |
40 | public: |
41 | /** |
42 | * Constructs a KDesktopFile object. |
43 | * |
44 | * See KStandardDirs for more information on resources. |
45 | * |
46 | * @param resourceType Allows you to change what sort of resource |
47 | * to search for if @p fileName is not absolute. |
48 | * For instance, you might want to specify "config". |
49 | * @param fileName The name or path of the desktop file. If it |
50 | * is not absolute, it will be located |
51 | * using the resource type @p resType. |
52 | */ |
53 | explicit KDesktopFile(const char *resourceType, const QString &fileName); |
54 | |
55 | /** |
56 | * Constructs a KDesktopFile object. |
57 | * |
58 | * See KStandardDirs for more information on resources. |
59 | * |
60 | * @param fileName The name or path of the desktop file. If it |
61 | * is not absolute, it will be located |
62 | * using the resource type "apps" |
63 | */ |
64 | explicit KDesktopFile(const QString &fileName); |
65 | |
66 | /** |
67 | * Destructs the KDesktopFile object. |
68 | * |
69 | * Writes back any dirty configuration entries. |
70 | */ |
71 | virtual ~KDesktopFile(); |
72 | |
73 | /** |
74 | * Checks whether this is really a desktop file. |
75 | * |
76 | * The check is performed looking at the file extension (the file is not |
77 | * opened). |
78 | * Currently, the only valid extension is ".desktop". |
79 | * @param path the path of the file to check |
80 | * @return true if the file appears to be a desktop file. |
81 | */ |
82 | static bool isDesktopFile(const QString& path); |
83 | |
84 | /** |
85 | * Checks whether the user is authorized to run this desktop file. |
86 | * By default users are authorized to run all desktop files but |
87 | * the KIOSK framework can be used to activate certain restrictions. |
88 | * See README.kiosk for more information. |
89 | * |
90 | * Note: Since KDE 4.3, there are more restrictions on authorized |
91 | * desktop files to prevent users from inadvertently running trojan |
92 | * desktop files. Your application launchers should have the executable |
93 | * bit set to prevent issues. To see if a restriction is due to |
94 | * KIOSK, see KAuthorized. |
95 | * |
96 | * @param path the file to check |
97 | * @return true if the user is authorized to run the file |
98 | */ |
99 | static bool isAuthorizedDesktopFile(const QString& path); |
100 | |
101 | /** |
102 | * Returns the location where changes for the .desktop file @p path |
103 | * should be written to. |
104 | */ |
105 | static QString locateLocal(const QString &path); |
106 | |
107 | KConfigGroup desktopGroup() const; |
108 | |
109 | /** |
110 | * Returns the value of the "Type=" entry. |
111 | * @return the type or QString() if not specified |
112 | */ |
113 | QString readType() const; |
114 | |
115 | /** |
116 | * Returns the value of the "Icon=" entry. |
117 | * @return the icon or QString() if not specified |
118 | */ |
119 | QString readIcon() const; |
120 | |
121 | /** |
122 | * Returns the value of the "Name=" entry. |
123 | * @return the name or QString() if not specified |
124 | */ |
125 | QString readName() const; |
126 | |
127 | /** |
128 | * Returns the value of the "Comment=" entry. |
129 | * @return the comment or QString() if not specified |
130 | */ |
131 | QString readComment() const; |
132 | |
133 | /** |
134 | * Returns the value of the "GenericName=" entry. |
135 | * @return the generic name or QString() if not specified |
136 | */ |
137 | QString readGenericName() const; |
138 | |
139 | /** |
140 | * Returns the value of the "Path=" entry. |
141 | * @return the path or QString() if not specified |
142 | */ |
143 | QString readPath() const; |
144 | |
145 | /** |
146 | * Returns the value of the "Dev=" entry. |
147 | * @return the device or QString() if not specified |
148 | */ |
149 | QString readDevice() const; |
150 | |
151 | /** |
152 | * Returns the value of the "URL=" entry. |
153 | * @return the URL or QString() if not specified |
154 | */ |
155 | QString readUrl() const; |
156 | |
157 | /** |
158 | * Returns a list of the "Actions=" entries. |
159 | * @return the list of actions |
160 | */ |
161 | QStringList readActions() const; |
162 | |
163 | /** |
164 | * Sets the desktop action group. |
165 | * @param group the new action group |
166 | */ |
167 | KConfigGroup actionGroup(const QString &group); |
168 | |
169 | const KConfigGroup actionGroup(const QString &group) const; |
170 | |
171 | /** |
172 | * Returns true if the action group exists, false otherwise |
173 | * @param group the action group to test |
174 | * @return true if the action group exists |
175 | */ |
176 | bool hasActionGroup(const QString &group) const; |
177 | |
178 | /** |
179 | * Checks whether there is a "Type=Link" entry. |
180 | * |
181 | * The link points to the "URL=" entry. |
182 | * @return true if there is a "Type=Link" entry |
183 | */ |
184 | bool hasLinkType() const; |
185 | |
186 | /** |
187 | * Checks whether there is an entry "Type=Application". |
188 | * @return true if there is a "Type=Application" entry |
189 | */ |
190 | bool hasApplicationType() const; |
191 | |
192 | /** |
193 | * Checks whether there is an entry "Type=MimeType". |
194 | * @return true if there is a "Type=MimeType" entry |
195 | */ |
196 | bool hasMimeTypeType() const; // funny name :) |
197 | |
198 | /** |
199 | * Checks whether there is an entry "Type=FSDevice". |
200 | * @return true if there is a "Type=FSDevice" entry |
201 | */ |
202 | bool hasDeviceType() const; |
203 | |
204 | /** |
205 | * Checks whether the TryExec field contains a binary |
206 | * which is found on the local system. |
207 | * @return true if TryExec contains an existing binary |
208 | */ |
209 | bool tryExec() const; |
210 | |
211 | /** |
212 | * Returns the value of the "X-DocPath=" Or "DocPath=" entry. |
213 | * @return The value of the "X-DocPath=" Or "DocPath=" entry. |
214 | */ |
215 | QString readDocPath() const; |
216 | |
217 | /** |
218 | * Returns the entry of the "SortOrder=" entry. |
219 | * @return the value of the "SortOrder=" entry. |
220 | */ |
221 | QStringList sortOrder() const; |
222 | |
223 | /** |
224 | * Whether the entry should be suppressed in menus. |
225 | * This handles the NoDisplay key, but also OnlyShowIn / NotShowIn. |
226 | * @return true to suppress this service |
227 | * @since 4.1 |
228 | */ |
229 | bool noDisplay() const; |
230 | |
231 | /** |
232 | * Copies all entries from this config object to a new |
233 | * KDesktopFile object that will save itself to @p file. |
234 | * |
235 | * Actual saving to @p file happens when the returned object is |
236 | * destructed or when sync() is called upon it. |
237 | * |
238 | * @param file the new KDesktopFile object it will save itself to. |
239 | */ |
240 | KDesktopFile* copyTo(const QString &file) const; |
241 | |
242 | QString fileName() const; |
243 | |
244 | const char *resource() const; |
245 | |
246 | protected: |
247 | /** Virtual hook, used to add new "virtual" functions while maintaining |
248 | binary compatibility. Unused in this class. |
249 | */ |
250 | // virtual void virtual_hook( int id, void* data ); |
251 | private: |
252 | |
253 | Q_DISABLE_COPY(KDesktopFile) |
254 | |
255 | Q_DECLARE_PRIVATE(KDesktopFile) |
256 | }; |
257 | |
258 | #endif |
259 |
Warning: That file was not part of the compilation database. It may have many parsing errors.