/* This file is part of the KDE libraries Copyright (C) 2000 David Faure This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef __tdeio_global_h__ #define __tdeio_global_h__ #include #include #include #include #include #include #include /** * @short A namespace for KIO globals * */ namespace TDEIO { /// 64-bit file offset typedef TQ_LLONG fileoffset_t; /// 64-bit file size typedef TQ_ULLONG filesize_t; /** * Converts @p size from bytes to the string representation. * * @param size size in bytes * @return converted size as a string - e.g. 123.4 kB , 12.0 MB */ TDEIO_EXPORT TQString convertSize( TDEIO::filesize_t size ); /** * Converts @p size from bytes to a string representation with includes * the size in bytes. * e.g. 90 B, 240 B, 1.4 KB (1495 B), 2.6MB (2,734,344 B), 0 B * @param size size in bytes * @return converted size as a string - e.g. 1.4 KB (1495 B), 45 B */ TDEIO_EXPORT TQString convertSizeWithBytes( TDEIO::filesize_t size ); /** * Converts a size to a string representation * Not unlike TQString::number(...) * * @param size size in bytes * @return converted size as a string - e.g. 123456789 */ TDEIO_EXPORT TQString number( TDEIO::filesize_t size ); /** * Converts size from kilo-bytes to the string representation. * * @param kbSize size in kilo-bytes * @return converted size as a string - e.g. 123.4 kB , 12.0 MB */ TDEIO_EXPORT TQString convertSizeFromKB( TDEIO::filesize_t kbSize ); /** * Calculates remaining time in seconds from total size, processed size and speed. * * @param totalSize total size in bytes * @param processedSize processed size in bytes * @param speed speed in bytes per second * @return calculated remaining time in seconds * * @since 3.4 */ TDEIO_EXPORT unsigned int calculateRemainingSeconds( TDEIO::filesize_t totalSize, TDEIO::filesize_t processedSize, TDEIO::filesize_t speed ); /** * Convert @p seconds to a string representing number of days, hours, minutes and seconds * * @param seconds number of seconds to convert * @return string representation in a locale depending format * * @since 3.4 */ TDEIO_EXPORT TQString convertSeconds( unsigned int seconds ); /** * Calculates remaining time from total size, processed size and speed. * Warning: As TQTime is limited to 23:59:59, use calculateRemainingSeconds() instead * * @param totalSize total size in bytes * @param processedSize processed size in bytes * @param speed speed in bytes per second * @return calculated remaining time */ TDEIO_EXPORT TQTime calculateRemaining( TDEIO::filesize_t totalSize, TDEIO::filesize_t processedSize, TDEIO::filesize_t speed ) KDE_DEPRECATED; /** * Helper for showing information about a set of files and directories * @param items the number of items (= @p files + @p dirs + number of symlinks :) * @param files the number of files * @param dirs the number of dirs * @param size the sum of the size of the @p files * @param showSize whether to show the size in the result * @return the summary string */ TDEIO_EXPORT TQString itemsSummaryString(uint items, uint files, uint dirs, TDEIO::filesize_t size, bool showSize); /** * Encodes (from the text displayed to the real filename) * This translates % into %% and / into %2f * Used by TDEIO::link, for instance. * @param str the file name to encode * @return the encoded file name */ TDEIO_EXPORT TQString encodeFileName( const TQString & str ); /** * Decodes (from the filename to the text displayed) * This translates %2[fF] into / and %% into % * @param str the file name to decode * @return the decoded file name */ TDEIO_EXPORT TQString decodeFileName( const TQString & str ); /** * Commands that can be invoked by a job. */ enum Command { CMD_HOST = '0', // 48 CMD_CONNECT = '1', // 49 CMD_DISCONNECT = '2', // 50 CMD_SLAVE_STATUS = '3', // 51 CMD_SLAVE_CONNECT = '4', // 52 CMD_SLAVE_HOLD = '5', // 53 CMD_NONE = 'A', // 65 CMD_TESTDIR = 'B', // 66 CMD_GET = 'C', // 67 CMD_PUT = 'D', // 68 CMD_STAT = 'E', // 69 CMD_MIMETYPE = 'F', // 70 CMD_LISTDIR = 'G', // 71 CMD_MKDIR = 'H', // 72 CMD_RENAME = 'I', // 73 CMD_COPY = 'J', // 74 CMD_DEL = 'K', // 75 CMD_CHMOD = 'L', // 76 CMD_SPECIAL = 'M', // 77 CMD_USERPASS = 'N', // 78 CMD_REPARSECONFIGURATION = 'O', // 79 CMD_META_DATA = 'P', // 80 CMD_SYMLINK = 'Q', // 81 CMD_SUBURL = 'R', // 82 Inform the slave about the url it is streaming on. CMD_MESSAGEBOXANSWER = 'S', // 83 CMD_RESUMEANSWER = 'T', // 84 CMD_CONFIG = 'U', // 85 CMD_MULTI_GET = 'V', // 86 CMD_LOCALURL = 'W' // 87 // Add new ones here once a release is done, to avoid breaking binary compatibility. // Note that protocol-specific commands shouldn't be added here, but should use special. }; /** * Error codes that can be emitted by KIO. */ enum Error { ERR_CANNOT_OPEN_FOR_READING = 1, ERR_CANNOT_OPEN_FOR_WRITING = 2, ERR_CANNOT_LAUNCH_PROCESS = 3, ERR_INTERNAL = 4, ERR_MALFORMED_URL = 5, ERR_UNSUPPORTED_PROTOCOL = 6, ERR_NO_SOURCE_PROTOCOL = 7, ERR_UNSUPPORTED_ACTION = 8, ERR_IS_DIRECTORY = 9, // ... where a file was expected ERR_IS_FILE = 10, // ... where a directory was expected (e.g. listing) ERR_DOES_NOT_EXIST = 11, ERR_FILE_ALREADY_EXIST = 12, ERR_DIR_ALREADY_EXIST = 13, ERR_UNKNOWN_HOST = 14, ERR_ACCESS_DENIED = 15, ERR_WRITE_ACCESS_DENIED = 16, ERR_CANNOT_ENTER_DIRECTORY = 17, ERR_PROTOCOL_IS_NOT_A_FILESYSTEM = 18, ERR_CYCLIC_LINK = 19, ERR_USER_CANCELED = 20, ERR_CYCLIC_COPY = 21, ERR_COULD_NOT_CREATE_SOCKET = 22, // KDE4: s/COULD_NOT/CANNOT/ or the other way round ERR_COULD_NOT_CONNECT = 23, ERR_CONNECTION_BROKEN = 24, ERR_NOT_FILTER_PROTOCOL = 25, ERR_COULD_NOT_MOUNT = 26, ERR_COULD_NOT_UNMOUNT = 27, ERR_COULD_NOT_READ = 28, ERR_COULD_NOT_WRITE = 29, ERR_COULD_NOT_BIND = 30, ERR_COULD_NOT_LISTEN = 31, ERR_COULD_NOT_ACCEPT = 32, ERR_COULD_NOT_LOGIN = 33, ERR_COULD_NOT_STAT = 34, ERR_COULD_NOT_CLOSEDIR = 35, ERR_COULD_NOT_MKDIR = 37, ERR_COULD_NOT_RMDIR = 38, ERR_CANNOT_RESUME = 39, ERR_CANNOT_RENAME = 40, ERR_CANNOT_CHMOD = 41, ERR_CANNOT_DELETE = 42, // The text argument is the protocol that the dead slave supported. // This means for example: file, ftp, http, ... ERR_SLAVE_DIED = 43, ERR_OUT_OF_MEMORY = 44, ERR_UNKNOWN_PROXY_HOST = 45, ERR_COULD_NOT_AUTHENTICATE = 46, ERR_ABORTED = 47, // Action got aborted from application side ERR_INTERNAL_SERVER = 48, ERR_SERVER_TIMEOUT = 49, ERR_SERVICE_NOT_AVAILABLE = 50, ERR_UNKNOWN = 51, // (was a warning) ERR_CHECKSUM_MISMATCH = 52, ERR_UNKNOWN_INTERRUPT = 53, ERR_CANNOT_DELETE_ORIGINAL = 54, ERR_CANNOT_DELETE_PARTIAL = 55, ERR_CANNOT_RENAME_ORIGINAL = 56, ERR_CANNOT_RENAME_PARTIAL = 57, ERR_NEED_PASSWD = 58, ERR_CANNOT_SYMLINK = 59, ERR_NO_CONTENT = 60, // Action succeeded but no content will follow. ERR_DISK_FULL = 61, ERR_IDENTICAL_FILES = 62, // src==dest when moving/copying ERR_SLAVE_DEFINED = 63, // for slave specified errors that can be // rich text. Email links will be handled // by the standard email app and all hrefs // will be handled by the standard browser. //