KIO

global.h
1 /*
2  This file is part of the KDE libraries
3  SPDX-FileCopyrightText: 2000-2005 David Faure <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-only
6 */
7 #ifndef KIO_GLOBAL_H
8 #define KIO_GLOBAL_H
9 
10 #include "kiocore_export.h"
11 
12 #include <QFile> // for QFile::Permissions
13 #include <QString>
14 
15 #include <KJob>
16 
17 #include "jobtracker.h" // for source compat
18 #include "metadata.h" // for source compat
19 
20 class QUrl;
21 
22 class QTime;
23 
24 #if defined(Q_OS_WIN) && defined(Q_CC_MSVC)
25 // on windows ssize_t is not defined, only SSIZE_T exists
26 #include <basetsd.h>
27 typedef SSIZE_T ssize_t;
28 #endif
29 
30 /**
31  * @short A namespace for KIO globals
32  *
33  */
34 namespace KIO
35 {
36 /// 64-bit file offset
37 typedef qlonglong fileoffset_t;
38 /// 64-bit file size
39 typedef qulonglong filesize_t;
40 
41 /**
42  * Converts @p size from bytes to the string representation.
43  *
44  * @param size size in bytes
45  * @return converted size as a string - e.g. 123.4 KiB , 12.0 MiB
46  */
47 KIOCORE_EXPORT QString convertSize(KIO::filesize_t size);
48 
49 /**
50  * Converts a size to a string representation
51  * Not unlike QString::number(...)
52  *
53  * @param size size in bytes
54  * @return converted size as a string - e.g. 123456789
55  */
56 KIOCORE_EXPORT QString number(KIO::filesize_t size);
57 
58 /**
59  * Converts size from kibi-bytes (2^10) to the string representation.
60  *
61  * @param kibSize size in kibi-bytes (2^10)
62  * @return converted size as a string - e.g. 123.4 KiB , 12.0 MiB
63  */
64 KIOCORE_EXPORT QString convertSizeFromKiB(KIO::filesize_t kibSize);
65 
66 /**
67  * Calculates remaining time in seconds from total size, processed size and speed.
68  *
69  * @param totalSize total size in bytes
70  * @param processedSize processed size in bytes
71  * @param speed speed in bytes per second
72  * @return calculated remaining time in seconds
73  */
74 KIOCORE_EXPORT unsigned int calculateRemainingSeconds(KIO::filesize_t totalSize, KIO::filesize_t processedSize, KIO::filesize_t speed);
75 
76 /**
77  * Convert @p seconds to a string representing number of days, hours, minutes and seconds
78  *
79  * @param seconds number of seconds to convert
80  * @return string representation in a locale depending format
81  */
82 KIOCORE_EXPORT QString convertSeconds(unsigned int seconds);
83 
84 #if KIOCORE_ENABLE_DEPRECATED_SINCE(3, 4)
85 /**
86  * Calculates remaining time from total size, processed size and speed.
87  *
88  * @param totalSize total size in bytes
89  * @param processedSize processed size in bytes
90  * @param speed speed in bytes per second
91  * @return calculated remaining time
92  * @deprecated Since 3.4, use calculateRemainingSeconds() instead, as QTime is limited to 23:59:59
93  */
94 KIOCORE_EXPORT
95 KIOCORE_DEPRECATED_VERSION(3, 4, "Use KIO::calculateRemainingSeconds(KIO::filesize_t, KIO::filesize_t, KIO::filesize_t")
96 QTime calculateRemaining(KIO::filesize_t totalSize, KIO::filesize_t processedSize, KIO::filesize_t speed);
97 #endif
98 
99 /**
100  * Helper for showing information about a set of files and directories
101  * @param items the number of items (= @p files + @p dirs + number of symlinks :)
102  * @param files the number of files
103  * @param dirs the number of dirs
104  * @param size the sum of the size of the @p files
105  * @param showSize whether to show the size in the result
106  * @return the summary string
107  */
108 KIOCORE_EXPORT QString itemsSummaryString(uint items, uint files, uint dirs, KIO::filesize_t size, bool showSize);
109 
110 /**
111  * Encodes (from the text displayed to the real filename)
112  * This translates '/' into a "unicode fraction slash", QChar(0x2044).
113  * Used by KIO::link, for instance.
114  * @param str the file name to encode
115  * @return the encoded file name
116  */
117 KIOCORE_EXPORT QString encodeFileName(const QString &str);
118 /**
119  * Decodes (from the filename to the text displayed)
120  * This doesn't do anything anymore, it used to do the opposite of encodeFileName
121  * when encodeFileName was using %2F for '/'.
122  * @param str the file name to decode
123  * @return the decoded file name
124  */
125 KIOCORE_EXPORT QString decodeFileName(const QString &str);
126 
127 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 61)
128 /**
129  * Given a directory path and a filename (which usually exists already),
130  * this function returns a suggested name for a file that doesn't exist
131  * in that directory. The existence is only checked for local urls though.
132  * The suggested file name is of the form "foo 1", "foo 2" etc.
133  * @since 5.0
134  * @deprecated since 5.61, use KFileUtils::suggestName() from KCoreAddons
135  */
136 KIOCORE_EXPORT
137 KIOCORE_DEPRECATED_VERSION(5, 61, "Use KFileUtils::suggestName(const QUrl &, const QString &) from KCoreAddons")
138 QString suggestName(const QUrl &baseURL, const QString &oldName);
139 #endif
140 
141 /**
142  * Error codes that can be emitted by KIO.
143  */
144 enum Error {
145  ERR_CANNOT_OPEN_FOR_READING = KJob::UserDefinedError + 1,
146  ERR_CANNOT_OPEN_FOR_WRITING = KJob::UserDefinedError + 2,
147  ERR_CANNOT_LAUNCH_PROCESS = KJob::UserDefinedError + 3,
148  ERR_INTERNAL = KJob::UserDefinedError + 4,
149  ERR_MALFORMED_URL = KJob::UserDefinedError + 5,
150  ERR_UNSUPPORTED_PROTOCOL = KJob::UserDefinedError + 6,
151  ERR_NO_SOURCE_PROTOCOL = KJob::UserDefinedError + 7,
152  ERR_UNSUPPORTED_ACTION = KJob::UserDefinedError + 8,
153  ERR_IS_DIRECTORY = KJob::UserDefinedError + 9, ///< ... where a file was expected
154  ERR_IS_FILE = KJob::UserDefinedError + 10, ///< ... where a directory was expected (e.g.\ listing)
155  ERR_DOES_NOT_EXIST = KJob::UserDefinedError + 11,
156  ERR_FILE_ALREADY_EXIST = KJob::UserDefinedError + 12,
157  ERR_DIR_ALREADY_EXIST = KJob::UserDefinedError + 13,
158  ERR_UNKNOWN_HOST = KJob::UserDefinedError + 14,
159  ERR_ACCESS_DENIED = KJob::UserDefinedError + 15,
160  ERR_WRITE_ACCESS_DENIED = KJob::UserDefinedError + 16,
161  ERR_CANNOT_ENTER_DIRECTORY = KJob::UserDefinedError + 17,
162  ERR_PROTOCOL_IS_NOT_A_FILESYSTEM = KJob::UserDefinedError + 18,
163  ERR_CYCLIC_LINK = KJob::UserDefinedError + 19,
164  ERR_USER_CANCELED = KJob::KilledJobError,
165  ERR_CYCLIC_COPY = KJob::UserDefinedError + 21,
166 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 0)
167  ERR_COULD_NOT_CREATE_SOCKET ///< @deprecated Since 5.0, use ERR_CANNOT_CREATE_SOCKET
168  KIOCORE_ENUMERATOR_DEPRECATED_VERSION_BELATED(5, 82, 5, 0, "Use ERR_CANNOT_CREATE_SOCKET.") = KJob::UserDefinedError + 22,
169 #endif
170  ERR_CANNOT_CREATE_SOCKET = KJob::UserDefinedError + 22,
171 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 0)
172  ERR_COULD_NOT_CONNECT ///< @deprecated Since 5.0, use ERR_CANNOT_CONNECT
173  KIOCORE_ENUMERATOR_DEPRECATED_VERSION_BELATED(5, 82, 5, 0, "Use ERR_CANNOT_CONNECT.") = KJob::UserDefinedError + 23,
174 #endif
175  ERR_CANNOT_CONNECT = KJob::UserDefinedError + 23,
176  ERR_CONNECTION_BROKEN = KJob::UserDefinedError + 24,
177  ERR_NOT_FILTER_PROTOCOL = KJob::UserDefinedError + 25,
178 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 0)
179  ERR_COULD_NOT_MOUNT ///< @deprecated Since 5.0, use ERR_CANNOT_MOUNT
180  KIOCORE_ENUMERATOR_DEPRECATED_VERSION_BELATED(5, 82, 5, 0, "Use ERR_CANNOT_MOUNT.") = KJob::UserDefinedError + 26,
181 #endif
182  ERR_CANNOT_MOUNT = KJob::UserDefinedError + 26,
183 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 0)
184  ERR_COULD_NOT_UNMOUNT ///< @deprecated Since 5.0, use ERR_CANNOT_UNMOUNT
185  KIOCORE_ENUMERATOR_DEPRECATED_VERSION_BELATED(5, 82, 5, 0, "Use ERR_CANNOT_UNMOUNT.") = KJob::UserDefinedError + 27,
186 #endif
187  ERR_CANNOT_UNMOUNT = KJob::UserDefinedError + 27,
188 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 0)
189  ERR_COULD_NOT_READ ///< @deprecated Since 5.0, use ERR_CANNOT_READ
190  KIOCORE_ENUMERATOR_DEPRECATED_VERSION_BELATED(5, 82, 5, 0, "Use ERR_CANNOT_READ.") = KJob::UserDefinedError + 28,
191 #endif
192  ERR_CANNOT_READ = KJob::UserDefinedError + 28,
193 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 0)
194  ERR_COULD_NOT_WRITE ///< @deprecated Since 5.0, use ERR_CANNOT_WRITE
195  KIOCORE_ENUMERATOR_DEPRECATED_VERSION_BELATED(5, 82, 5, 0, "Use ERR_CANNOT_WRITE.") = KJob::UserDefinedError + 29,
196 #endif
197  ERR_CANNOT_WRITE = KJob::UserDefinedError + 29,
198 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 0)
199  ERR_COULD_NOT_BIND ///< @deprecated Since 5.0, use ERR_CANNOT_BIND
200  KIOCORE_ENUMERATOR_DEPRECATED_VERSION_BELATED(5, 82, 5, 0, "Use ERR_CANNOT_BIND.") = KJob::UserDefinedError + 30,
201 #endif
202  ERR_CANNOT_BIND = KJob::UserDefinedError + 30,
203 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 0)
204  ERR_COULD_NOT_LISTEN ///< @deprecated Since 5.0, use ERR_CANNOT_LISTEN
205  KIOCORE_ENUMERATOR_DEPRECATED_VERSION_BELATED(5, 82, 5, 0, "Use ERR_CANNOT_LISTEN.") = KJob::UserDefinedError + 31,
206 #endif
207  ERR_CANNOT_LISTEN = KJob::UserDefinedError + 31,
208 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 0)
209  ERR_COULD_NOT_ACCEPT ///< @deprecated Since 5.0, use ERR_CANNOT_ACCEPT
210  KIOCORE_ENUMERATOR_DEPRECATED_VERSION_BELATED(5, 82, 5, 0, "Use ERR_CANNOT_ACCEPT.") = KJob::UserDefinedError + 32,
211 #endif
212  ERR_CANNOT_ACCEPT = KJob::UserDefinedError + 32,
213 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 0)
214  ERR_COULD_NOT_LOGIN ///< @deprecated Since 5.0, use ERR_CANNOT_LOGIN
215  KIOCORE_ENUMERATOR_DEPRECATED_VERSION_BELATED(5, 82, 5, 0, "Use ERR_CANNOT_LOGIN.") = KJob::UserDefinedError + 33,
216 #endif
217  ERR_CANNOT_LOGIN = KJob::UserDefinedError + 33,
218 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 0)
219  ERR_COULD_NOT_STAT ///< @deprecated Since 5.0, use ERR_CANNOT_STAT
220  KIOCORE_ENUMERATOR_DEPRECATED_VERSION_BELATED(5, 82, 5, 0, "Use ERR_CANNOT_STAT.") = KJob::UserDefinedError + 34,
221 #endif
222  ERR_CANNOT_STAT = KJob::UserDefinedError + 34,
223 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 0)
224  ERR_COULD_NOT_CLOSEDIR ///< @deprecated Since 5.0, use ERR_CANNOT_CLOSEDIR
225  KIOCORE_ENUMERATOR_DEPRECATED_VERSION_BELATED(5, 82, 5, 0, "Use ERR_CANNOT_CLOSEDIR.") = KJob::UserDefinedError + 35,
226 #endif
227  ERR_CANNOT_CLOSEDIR = KJob::UserDefinedError + 35,
228 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 0)
229  ERR_COULD_NOT_MKDIR ///< @deprecated Since 5.0, use ERR_CANNOT_MKDIR
230  KIOCORE_ENUMERATOR_DEPRECATED_VERSION_BELATED(5, 82, 5, 0, "Use ERR_CANNOT_AUTHENTICATE.") = KJob::UserDefinedError + 37,
231 #endif
232  ERR_CANNOT_MKDIR = KJob::UserDefinedError + 37,
233 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 0)
234  ERR_COULD_NOT_RMDIR ///< @deprecated Since 5.0, use ERR_CANNOT_RMDIR
235  KIOCORE_ENUMERATOR_DEPRECATED_VERSION_BELATED(5, 82, 5, 0, "Use ERR_CANNOT_RMDIR.") = KJob::UserDefinedError + 38,
236 #endif
237  ERR_CANNOT_RMDIR = KJob::UserDefinedError + 38,
238  ERR_CANNOT_RESUME = KJob::UserDefinedError + 39,
239  ERR_CANNOT_RENAME = KJob::UserDefinedError + 40,
240  ERR_CANNOT_CHMOD = KJob::UserDefinedError + 41,
241  ERR_CANNOT_DELETE = KJob::UserDefinedError + 42,
242  // The text argument is the protocol that the dead worker supported.
243  // This means for example: file, ftp, http, ...
244  ERR_WORKER_DIED = KJob::UserDefinedError + 43, ///< @since 5.96
245 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 96)
246  ERR_SLAVE_DIED ///< @deprecated Since 5.96, use ERR_WORKER_DIED
247  KIOCORE_ENUMERATOR_DEPRECATED_VERSION(5, 96, "Use ERR_WORKER_DIED.") = ERR_WORKER_DIED,
248 #endif
249  ERR_OUT_OF_MEMORY = KJob::UserDefinedError + 44,
250  ERR_UNKNOWN_PROXY_HOST = KJob::UserDefinedError + 45,
251 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 0)
252  ERR_COULD_NOT_AUTHENTICATE ///< @deprecated Since 5.0, use ERR_CANNOT_AUTHENTICATE
253  KIOCORE_ENUMERATOR_DEPRECATED_VERSION_BELATED(5, 82, 5, 0, "Use ERR_CANNOT_AUTHENTICATE.") = KJob::UserDefinedError + 46,
254 #endif
255  ERR_CANNOT_AUTHENTICATE = KJob::UserDefinedError + 46,
256  ERR_ABORTED = KJob::UserDefinedError + 47, ///< Action got aborted from application side
257  ERR_INTERNAL_SERVER = KJob::UserDefinedError + 48,
258  ERR_SERVER_TIMEOUT = KJob::UserDefinedError + 49,
259  ERR_SERVICE_NOT_AVAILABLE = KJob::UserDefinedError + 50,
260  ERR_UNKNOWN = KJob::UserDefinedError + 51,
261  // (was a warning) ERR_CHECKSUM_MISMATCH = 52,
262  ERR_UNKNOWN_INTERRUPT = KJob::UserDefinedError + 53,
263  ERR_CANNOT_DELETE_ORIGINAL = KJob::UserDefinedError + 54,
264  ERR_CANNOT_DELETE_PARTIAL = KJob::UserDefinedError + 55,
265  ERR_CANNOT_RENAME_ORIGINAL = KJob::UserDefinedError + 56,
266  ERR_CANNOT_RENAME_PARTIAL = KJob::UserDefinedError + 57,
267  ERR_NEED_PASSWD = KJob::UserDefinedError + 58,
268  ERR_CANNOT_SYMLINK = KJob::UserDefinedError + 59,
269  ERR_NO_CONTENT = KJob::UserDefinedError + 60, ///< Action succeeded but no content will follow.
270  ERR_DISK_FULL = KJob::UserDefinedError + 61,
271  ERR_IDENTICAL_FILES = KJob::UserDefinedError + 62, ///< src==dest when moving/copying
272  /**
273  * For worker specified errors that can be
274  * rich text. Email links will be handled
275  * by the standard email app and all hrefs
276  * will be handled by the standard browser.
277  * <a href="exec:/khelpcenter ?" will be
278  * forked.
279  * @since 5.96
280  */
281  ERR_WORKER_DEFINED = KJob::UserDefinedError + 63,
282 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 96)
283  /**
284  * For slave specified errors that can be
285  * rich text. Email links will be handled
286  * by the standard email app and all hrefs
287  * will be handled by the standard browser.
288  * <a href="exec:/khelpcenter ?" will be
289  * forked.
290  * @deprecated Since 5.96, use ERR_WORKER_DEFINED
291  */
292  ERR_SLAVE_DEFINED KIOCORE_ENUMERATOR_DEPRECATED_VERSION(5, 96, "Use ERR_WORKER_DEFINED.") = ERR_WORKER_DEFINED,
293 #endif
294  ERR_UPGRADE_REQUIRED = KJob::UserDefinedError + 64, ///< A transport upgrade is required to access this
295  ///< object. For instance, TLS is demanded by
296  ///< the server in order to continue.
297  ERR_POST_DENIED = KJob::UserDefinedError + 65, ///< Issued when trying to POST data to a certain Ports
298 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 0)
299  ERR_COULD_NOT_SEEK ///< @deprecated Since 5.0, use ERR_CANNOT_SEEK
300  KIOCORE_ENUMERATOR_DEPRECATED_VERSION_BELATED(5, 82, 5, 0, "Use ERR_CANNOT_SEEK.") = KJob::UserDefinedError + 66,
301 #endif
302  // see job.cpp
303  ERR_CANNOT_SEEK = KJob::UserDefinedError + 66,
304  ERR_CANNOT_SETTIME = KJob::UserDefinedError + 67, ///< Emitted by setModificationTime
305  ERR_CANNOT_CHOWN = KJob::UserDefinedError + 68,
306  ERR_POST_NO_SIZE = KJob::UserDefinedError + 69,
307  ERR_DROP_ON_ITSELF = KJob::UserDefinedError + 70, ///< from KIO::DropJob, @since 5.6
308  ERR_CANNOT_MOVE_INTO_ITSELF = KJob::UserDefinedError + 71, ///< emitted by KIO::move, @since 5.18
309  // TODO KF6 remove reference to slavebase
310  ERR_PASSWD_SERVER = KJob::UserDefinedError + 72, ///< returned by WorkerBase::openPasswordDialog and SlaveBase::openPasswordDialogV2, @since 5.24
311  ERR_CANNOT_CREATE_WORKER = KJob::UserDefinedError + 73, ///< used by Slave::createSlave, @since 5.96
312 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 96)
313  ERR_CANNOT_CREATE_SLAVE ///< used by Slave::createSlave, @since 5.30 @deprecated Since 5.96, use ERR_CANNOT_CREATE_WORKER
314  KIOCORE_ENUMERATOR_DEPRECATED_VERSION(5, 96, "Use ERR_CANNOT_CREATE_WORKER.") = ERR_CANNOT_CREATE_WORKER,
315 #endif
316  ERR_FILE_TOO_LARGE_FOR_FAT32 = KJob::UserDefinedError + 74, ///< @since 5.54
317  ERR_OWNER_DIED ///< Value used between kuiserver and views when the job owner disappears unexpectedly. It should not be emitted by workers. @since 5.54
318  = KJob::UserDefinedError + 75,
319  ERR_PRIVILEGE_NOT_REQUIRED = KJob::UserDefinedError + 76, ///< used by file ioworker, @since 5.60
320  ERR_CANNOT_TRUNCATE = KJob::UserDefinedError + 77, // used by FileJob::truncate, @since 5.66
321  /**
322  * Indicates failure to create a symlink due to the underlying filesystem (FAT/ExFAT)
323  * not supporting them. Used by e.g. CopyJob.
324  * @since 5.88
325  */
326  ERR_SYMLINKS_NOT_SUPPORTED = KJob::UserDefinedError + 78,
327 
328  /**
329  * Moving files/dirs to the Trash failed due to size constraints.
330  *
331  * @since 5.100
332  */
333  ERR_TRASH_FILE_TOO_LARGE = KJob::UserDefinedError + 79,
334 };
335 
336 /**
337  * Specifies how to use the cache.
338  * @see parseCacheControl()
339  * @see getCacheControlString()
340  */
342  CC_CacheOnly, ///< Fail request if not in cache
343  CC_Cache, ///< Use cached entry if available
344  CC_Verify, ///< Validate cached entry with remote site if expired
345  CC_Refresh, ///< Always validate cached entry with remote site
346  CC_Reload, ///< Always fetch from remote site.
347 };
348 
349 /**
350  * Specifies privilege file operation status.
351  * @since 5.43
352  */
354  OperationAllowed = 1,
355  OperationCanceled,
356  OperationNotAllowed,
357 };
358 
359 /**
360  * Describes the fields that a stat command will retrieve
361  * @see UDSEntry
362  * @see StatDetails
363  * @since 5.69
364  */
366  /// No field returned, useful to check if a file exists
368  /// Filename, access, type, size, linkdest
369  StatBasic = 0x1,
370  /// uid, gid
371  StatUser = 0x2,
372  /// atime, mtime, btime
373  StatTime = 0x4,
374  /// Resolve symlinks
376  /// ACL data
377  StatAcl = 0x10,
378  /// dev, inode
379  StatInode = 0x20,
380  /// Recursive size
381  /// @since 5.70
383  /// MIME type
384  /// @since 5.82
385  StatMimeType = 0x80,
386 
387  /// Default StatDetail flag when creating a @c StatJob.
388  /// Equivalent to setting <tt>StatBasic | StatUser | StatTime | StatAcl | StatResolveSymlink</tt>
390 };
391 /**
392  * Stores a combination of #StatDetail values.
393  */
394 Q_DECLARE_FLAGS(StatDetails, StatDetail)
395 
396 Q_DECLARE_OPERATORS_FOR_FLAGS(KIO::StatDetails)
397 
398 /**
399  * Parses the string representation of the cache control option.
400  *
401  * @param cacheControl the string representation
402  * @return the cache control value
403  * @see getCacheControlString()
404  */
405 KIOCORE_EXPORT KIO::CacheControl parseCacheControl(const QString &cacheControl);
406 
407 /**
408  * Returns a string representation of the given cache control method.
409  *
410  * @param cacheControl the cache control method
411  * @return the string representation
412  * @see parseCacheControl()
413  */
414 KIOCORE_EXPORT QString getCacheControlString(KIO::CacheControl cacheControl);
415 
416 /**
417  * Return the "favicon" (see http://www.favicon.com) for the given @p url,
418  * if available. Does NOT attempt to download the favicon, it only returns
419  * one that is already available.
420  *
421  * If unavailable, returns QString().
422  * Use KIO::FavIconRequestJob instead of this method if you can wait
423  * for the favicon to be downloaded.
424  *
425  * @param url the URL of the favicon
426  * @return the path to the icon (to be passed to QIcon()), or QString()
427  *
428  * @since 5.0
429  */
430 KIOCORE_EXPORT QString favIconForUrl(const QUrl &url);
431 
432 /**
433  * Converts KIO file permissions from mode_t to QFile::Permissions format.
434  *
435  * This is a convenience function for converting KIO permissions parameter from
436  * mode_t to QFile::Permissions.
437  *
438  * @param permissions KIO file permissions.
439  *
440  * @return -1 if @p permissions is -1, otherwise its OR'ed QFile::Permission equivalent.
441  * @since 4.12
442  */
443 KIOCORE_EXPORT QFile::Permissions convertPermissions(int permissions);
444 
445 /**
446  * Return the icon name for a URL.
447  * Most of the time this returns the MIME type icon,
448  * but also has fallback to favicon and protocol-specific icon.
449  *
450  * Pass this to QIcon::fromTheme().
451  *
452  * @since 5.0
453  */
454 KIOCORE_EXPORT QString iconNameForUrl(const QUrl &url);
455 
456 /**
457  * This function is useful to implement the "Up" button in a file manager for example.
458  *
459  * @return a URL that is a level higher
460  *
461  * @since 5.0
462  */
463 KIOCORE_EXPORT QUrl upUrl(const QUrl &url);
464 
465 }
466 #endif
@ ERR_WORKER_DEFINED
For worker specified errors that can be rich text.
Definition: global.h:281
@ ERR_SLAVE_DEFINED
For slave specified errors that can be rich text.
Definition: global.h:292
@ ERR_ABORTED
Action got aborted from application side.
Definition: global.h:256
KIOCORE_EXPORT QTime calculateRemaining(KIO::filesize_t totalSize, KIO::filesize_t processedSize, KIO::filesize_t speed)
Calculates remaining time from total size, processed size and speed.
Definition: global.cpp:88
@ ERR_PRIVILEGE_NOT_REQUIRED
used by file ioworker,
Definition: global.h:319
KIOCORE_EXPORT QString convertSize(KIO::filesize_t size)
Converts size from bytes to the string representation.
Definition: global.cpp:43
@ StatRecursiveSize
Recursive size.
Definition: global.h:382
@ ERR_WORKER_DIED
Definition: global.h:244
@ ERR_COULD_NOT_MOUNT
Definition: global.h:179
qulonglong filesize_t
64-bit file size
Definition: global.h:39
@ StatTime
atime, mtime, btime
Definition: global.h:373
KIOCORE_EXPORT QFile::Permissions convertPermissions(int permissions)
Converts KIO file permissions from mode_t to QFile::Permissions format.
Definition: job_error.cpp:1281
@ StatAcl
ACL data.
Definition: global.h:377
@ ERR_PASSWD_SERVER
returned by WorkerBase::openPasswordDialog and SlaveBase::openPasswordDialogV2,
Definition: global.h:310
@ StatInode
dev, inode
Definition: global.h:379
KIOCORE_EXPORT QString favIconForUrl(const QUrl &url)
Return the "favicon" (see http://www.favicon.com) for the given url, if available.
Definition: global.cpp:203
KIOCORE_EXPORT QString encodeFileName(const QString &str)
Encodes (from the text displayed to the real filename) This translates '/' into a "unicode fraction s...
Definition: global.cpp:139
@ ERR_COULD_NOT_CLOSEDIR
Definition: global.h:224
@ ERR_COULD_NOT_STAT
Definition: global.h:219
@ ERR_SYMLINKS_NOT_SUPPORTED
Indicates failure to create a symlink due to the underlying filesystem (FAT/ExFAT) not supporting the...
Definition: global.h:326
KIOCORE_EXPORT QString convertSeconds(unsigned int seconds)
Convert seconds to a string representing number of days, hours, minutes and seconds.
Definition: global.cpp:71
@ ERR_COULD_NOT_CONNECT
Definition: global.h:172
@ ERR_COULD_NOT_BIND
Definition: global.h:199
@ ERR_COULD_NOT_UNMOUNT
Definition: global.h:184
@ ERR_COULD_NOT_ACCEPT
Definition: global.h:209
@ StatUser
uid, gid
Definition: global.h:371
@ ERR_COULD_NOT_LISTEN
Definition: global.h:204
KIOCORE_EXPORT QString iconNameForUrl(const QUrl &url)
Return the icon name for a URL.
Definition: global.cpp:212
qlonglong fileoffset_t
64-bit file offset
Definition: global.h:37
@ CC_Verify
Validate cached entry with remote site if expired.
Definition: global.h:344
KIOCORE_EXPORT unsigned int calculateRemainingSeconds(KIO::filesize_t totalSize, KIO::filesize_t processedSize, KIO::filesize_t speed)
Calculates remaining time in seconds from total size, processed size and speed.
Definition: global.cpp:62
@ ERR_IDENTICAL_FILES
src==dest when moving/copying
Definition: global.h:271
KIOCORE_EXPORT QString decodeFileName(const QString &str)
Decodes (from the filename to the text displayed) This doesn't do anything anymore,...
Definition: global.cpp:146
@ StatResolveSymlink
Resolve symlinks.
Definition: global.h:375
@ ERR_CANNOT_CREATE_SLAVE
used by Slave::createSlave,
Definition: global.h:313
@ ERR_COULD_NOT_MKDIR
Definition: global.h:229
@ ERR_UPGRADE_REQUIRED
A transport upgrade is required to access this.
Definition: global.h:294
@ ERR_COULD_NOT_LOGIN
Definition: global.h:214
@ StatNoDetails
No field returned, useful to check if a file exists.
Definition: global.h:367
StatDetail
Describes the fields that a stat command will retrieve.
Definition: global.h:365
KIOCORE_EXPORT QString itemsSummaryString(uint items, uint files, uint dirs, KIO::filesize_t size, bool showSize)
Helper for showing information about a set of files and directories.
Definition: global.cpp:113
@ ERR_FILE_TOO_LARGE_FOR_FAT32
Definition: global.h:316
@ ERR_IS_FILE
... where a directory was expected (e.g. listing)
Definition: global.h:154
@ ERR_SLAVE_DIED
Definition: global.h:246
@ ERR_COULD_NOT_READ
Definition: global.h:189
typedef Permissions
KIOCORE_EXPORT QUrl upUrl(const QUrl &url)
This function is useful to implement the "Up" button in a file manager for example.
Definition: global.cpp:261
@ StatBasic
Filename, access, type, size, linkdest.
Definition: global.h:369
@ StatMimeType
MIME type.
Definition: global.h:385
@ ERR_COULD_NOT_AUTHENTICATE
Definition: global.h:252
@ ERR_COULD_NOT_CREATE_SOCKET
Definition: global.h:167
Error
Error codes that can be emitted by KIO.
Definition: global.h:144
PrivilegeOperationStatus
Specifies privilege file operation status.
Definition: global.h:353
@ ERR_TRASH_FILE_TOO_LARGE
Moving files/dirs to the Trash failed due to size constraints.
Definition: global.h:333
@ ERR_CANNOT_MOVE_INTO_ITSELF
emitted by KIO::move,
Definition: global.h:308
@ ERR_IS_DIRECTORY
... where a file was expected
Definition: global.h:153
@ ERR_COULD_NOT_SEEK
Definition: global.h:299
@ ERR_DROP_ON_ITSELF
from KIO::DropJob,
Definition: global.h:307
@ ERR_COULD_NOT_RMDIR
Definition: global.h:234
A namespace for KIO globals.
@ ERR_NO_CONTENT
Action succeeded but no content will follow.
Definition: global.h:269
KIOCORE_EXPORT QString number(KIO::filesize_t size)
Converts a size to a string representation Not unlike QString::number(...)
Definition: global.cpp:55
@ ERR_COULD_NOT_WRITE
Definition: global.h:194
KIOCORE_EXPORT QString getCacheControlString(KIO::CacheControl cacheControl)
Returns a string representation of the given cache control method.
Definition: global.cpp:182
@ ERR_POST_DENIED
Issued when trying to POST data to a certain Ports.
Definition: global.h:297
CacheControl
Specifies how to use the cache.
Definition: global.h:341
@ ERR_CANNOT_SETTIME
Emitted by setModificationTime.
Definition: global.h:304
KIOCORE_EXPORT QString convertSizeFromKiB(KIO::filesize_t kibSize)
Converts size from kibi-bytes (2^10) to the string representation.
Definition: global.cpp:50
@ CC_CacheOnly
Fail request if not in cache.
Definition: global.h:342
KIOCORE_EXPORT KIO::CacheControl parseCacheControl(const QString &cacheControl)
Parses the string representation of the cache control option.
Definition: global.cpp:158
@ ERR_OWNER_DIED
Value used between kuiserver and views when the job owner disappears unexpectedly....
Definition: global.h:317
@ CC_Reload
Always fetch from remote site.
Definition: global.h:346
@ CC_Refresh
Always validate cached entry with remote site.
Definition: global.h:345
@ CC_Cache
Use cached entry if available.
Definition: global.h:343
@ StatDefaultDetails
Default StatDetail flag when creating a StatJob.
Definition: global.h:389
KIOCORE_EXPORT QString suggestName(const QUrl &baseURL, const QString &oldName)
Given a directory path and a filename (which usually exists already), this function returns a suggest...
Definition: global.cpp:280
@ ERR_CANNOT_CREATE_WORKER
used by Slave::createSlave,
Definition: global.h:311
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon May 8 2023 03:54:42 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.