00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __kio_global_h__
00019 #define __kio_global_h__
00020
00021 #include <qstring.h>
00022 #include <qvaluelist.h>
00023 #include <qptrlist.h>
00024 #include <qdatastream.h>
00025 #include <qdatetime.h>
00026 #include <qmap.h>
00027
00028 #include <kurl.h>
00029
00034 namespace KIO
00035 {
00037 typedef Q_LLONG fileoffset_t;
00039 typedef Q_ULLONG filesize_t;
00040
00047 KIO_EXPORT QString convertSize( KIO::filesize_t size );
00048
00056 KIO_EXPORT QString convertSizeWithBytes( KIO::filesize_t size );
00064 KIO_EXPORT QString number( KIO::filesize_t size );
00065
00072 KIO_EXPORT QString convertSizeFromKB( KIO::filesize_t kbSize );
00073
00084 KIO_EXPORT unsigned int calculateRemainingSeconds( KIO::filesize_t totalSize,
00085 KIO::filesize_t processedSize, KIO::filesize_t speed );
00086
00095 KIO_EXPORT QString convertSeconds( unsigned int seconds );
00096
00106 KIO_EXPORT QTime calculateRemaining( KIO::filesize_t totalSize, KIO::filesize_t processedSize, KIO::filesize_t speed ) KDE_DEPRECATED;
00107
00117 KIO_EXPORT QString itemsSummaryString(uint items, uint files, uint dirs, KIO::filesize_t size, bool showSize);
00118
00126 KIO_EXPORT QString encodeFileName( const QString & str );
00133 KIO_EXPORT QString decodeFileName( const QString & str );
00134
00138 enum Command {
00139 CMD_HOST = '0',
00140 CMD_CONNECT = '1',
00141 CMD_DISCONNECT = '2',
00142 CMD_SLAVE_STATUS = '3',
00143 CMD_SLAVE_CONNECT = '4',
00144 CMD_SLAVE_HOLD = '5',
00145 CMD_NONE = 'A',
00146 CMD_TESTDIR = 'B',
00147 CMD_GET = 'C',
00148 CMD_PUT = 'D',
00149 CMD_STAT = 'E',
00150 CMD_MIMETYPE = 'F',
00151 CMD_LISTDIR = 'G',
00152 CMD_MKDIR = 'H',
00153 CMD_RENAME = 'I',
00154 CMD_COPY = 'J',
00155 CMD_DEL = 'K',
00156 CMD_CHMOD = 'L',
00157 CMD_SPECIAL = 'M',
00158 CMD_USERPASS = 'N',
00159 CMD_REPARSECONFIGURATION = 'O',
00160 CMD_META_DATA = 'P',
00161 CMD_SYMLINK = 'Q',
00162 CMD_SUBURL = 'R',
00163 CMD_MESSAGEBOXANSWER = 'S',
00164 CMD_RESUMEANSWER = 'T',
00165 CMD_CONFIG = 'U',
00166 CMD_MULTI_GET = 'V'
00167
00168
00169 };
00170
00174 enum Error {
00175 ERR_CANNOT_OPEN_FOR_READING = 1,
00176 ERR_CANNOT_OPEN_FOR_WRITING = 2,
00177 ERR_CANNOT_LAUNCH_PROCESS = 3,
00178 ERR_INTERNAL = 4,
00179 ERR_MALFORMED_URL = 5,
00180 ERR_UNSUPPORTED_PROTOCOL = 6,
00181 ERR_NO_SOURCE_PROTOCOL = 7,
00182 ERR_UNSUPPORTED_ACTION = 8,
00183 ERR_IS_DIRECTORY = 9,
00184 ERR_IS_FILE = 10,
00185 ERR_DOES_NOT_EXIST = 11,
00186 ERR_FILE_ALREADY_EXIST = 12,
00187 ERR_DIR_ALREADY_EXIST = 13,
00188 ERR_UNKNOWN_HOST = 14,
00189 ERR_ACCESS_DENIED = 15,
00190 ERR_WRITE_ACCESS_DENIED = 16,
00191 ERR_CANNOT_ENTER_DIRECTORY = 17,
00192 ERR_PROTOCOL_IS_NOT_A_FILESYSTEM = 18,
00193 ERR_CYCLIC_LINK = 19,
00194 ERR_USER_CANCELED = 20,
00195 ERR_CYCLIC_COPY = 21,
00196 ERR_COULD_NOT_CREATE_SOCKET = 22,
00197 ERR_COULD_NOT_CONNECT = 23,
00198 ERR_CONNECTION_BROKEN = 24,
00199 ERR_NOT_FILTER_PROTOCOL = 25,
00200 ERR_COULD_NOT_MOUNT = 26,
00201 ERR_COULD_NOT_UNMOUNT = 27,
00202 ERR_COULD_NOT_READ = 28,
00203 ERR_COULD_NOT_WRITE = 29,
00204 ERR_COULD_NOT_BIND = 30,
00205 ERR_COULD_NOT_LISTEN = 31,
00206 ERR_COULD_NOT_ACCEPT = 32,
00207 ERR_COULD_NOT_LOGIN = 33,
00208 ERR_COULD_NOT_STAT = 34,
00209 ERR_COULD_NOT_CLOSEDIR = 35,
00210 ERR_COULD_NOT_MKDIR = 37,
00211 ERR_COULD_NOT_RMDIR = 38,
00212 ERR_CANNOT_RESUME = 39,
00213 ERR_CANNOT_RENAME = 40,
00214 ERR_CANNOT_CHMOD = 41,
00215 ERR_CANNOT_DELETE = 42,
00216
00217
00218 ERR_SLAVE_DIED = 43,
00219 ERR_OUT_OF_MEMORY = 44,
00220 ERR_UNKNOWN_PROXY_HOST = 45,
00221 ERR_COULD_NOT_AUTHENTICATE = 46,
00222 ERR_ABORTED = 47,
00223 ERR_INTERNAL_SERVER = 48,
00224 ERR_SERVER_TIMEOUT = 49,
00225 ERR_SERVICE_NOT_AVAILABLE = 50,
00226 ERR_UNKNOWN = 51,
00227
00228 ERR_UNKNOWN_INTERRUPT = 53,
00229 ERR_CANNOT_DELETE_ORIGINAL = 54,
00230 ERR_CANNOT_DELETE_PARTIAL = 55,
00231 ERR_CANNOT_RENAME_ORIGINAL = 56,
00232 ERR_CANNOT_RENAME_PARTIAL = 57,
00233 ERR_NEED_PASSWD = 58,
00234 ERR_CANNOT_SYMLINK = 59,
00235 ERR_NO_CONTENT = 60,
00236 ERR_DISK_FULL = 61,
00237 ERR_IDENTICAL_FILES = 62,
00238 ERR_SLAVE_DEFINED = 63,
00239
00240
00241
00242
00243
00244 ERR_UPGRADE_REQUIRED = 64,
00245
00246
00247 ERR_POST_DENIED = 65
00248
00249 };
00250
00258 KIO_EXPORT QString buildErrorString(int errorCode, const QString &errorText);
00259
00270 KIO_EXPORT QString buildHTMLErrorString(int errorCode, const QString &errorText,
00271 const KURL *reqUrl = 0L, int method = -1 );
00272
00289 KIO_EXPORT QByteArray rawErrorDetail(int errorCode, const QString &errorText,
00290 const KURL *reqUrl = 0L, int method = -1 );
00291
00300 KIO_EXPORT QString unsupportedActionErrorString(const QString &protocol, int cmd);
00301
00305 enum UDSAtomTypes {
00307 UDS_STRING = 1,
00308 UDS_LONG = 2,
00309 UDS_TIME = 4 | UDS_LONG,
00310
00311
00312
00313
00314
00316 UDS_SIZE = 8 | UDS_LONG,
00317 UDS_SIZE_LARGE = 32768 | UDS_LONG,
00319 UDS_USER = 16 | UDS_STRING,
00323 UDS_ICON_NAME = 24 | UDS_STRING,
00325 UDS_GROUP = 32 | UDS_STRING,
00329 UDS_EXTRA = 48 | UDS_STRING,
00332 UDS_NAME = 64 | UDS_STRING,
00335 UDS_LOCAL_PATH = 72 | UDS_STRING,
00338 UDS_HIDDEN = 80 | UDS_LONG,
00341 UDS_EXTENDED_ACL = 88 | UDS_LONG,
00344 UDS_ACL_STRING = 96 | UDS_STRING,
00348 UDS_DEFAULT_ACL_STRING = 104 | UDS_STRING,
00349
00350
00351
00353 UDS_ACCESS = 128 | UDS_LONG,
00355 UDS_MODIFICATION_TIME = 256 | UDS_TIME,
00357 UDS_ACCESS_TIME = 512 | UDS_TIME,
00359 UDS_CREATION_TIME = 1024 | UDS_TIME,
00363 UDS_FILE_TYPE = 2048 | UDS_LONG,
00366 UDS_LINK_DEST = 4096 | UDS_STRING,
00368 UDS_URL = 8192 | UDS_STRING,
00370 UDS_MIME_TYPE = 16384 | UDS_STRING,
00373 UDS_GUESSED_MIME_TYPE = 16392 | UDS_STRING,
00376 UDS_XML_PROPERTIES = 0x8000 | UDS_STRING
00377 };
00378
00384 enum CacheControl
00385 {
00386 CC_CacheOnly,
00387 CC_Cache,
00388 CC_Verify,
00389 CC_Refresh,
00390
00391 CC_Reload
00392 };
00393
00401 KIO_EXPORT KIO::CacheControl parseCacheControl(const QString &cacheControl);
00402
00410 KIO_EXPORT QString getCacheControlString(KIO::CacheControl cacheControl);
00411
00417 KIO_EXPORT QString findDeviceMountPoint( const QString& device );
00418
00426 KIO_EXPORT QString findPathMountPoint( const QString & filename );
00427
00435 KIO_EXPORT bool probably_slow_mounted(const QString& filename);
00436
00443 KIO_EXPORT bool manually_mounted(const QString& filename);
00444
00445 enum FileSystemFlag { SupportsChmod, SupportsChown, SupportsUTime,
00446 SupportsSymlinks, CaseInsensitive };
00467 KIO_EXPORT bool testFileSystemFlag(const QString& filename, FileSystemFlag flag);
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483 class KIO_EXPORT UDSAtom
00484 {
00485 public:
00489 QString m_str;
00493 long long m_long;
00494
00498 unsigned int m_uds;
00499 };
00500
00504 typedef QValueList<UDSAtom> UDSEntry;
00505 typedef QValueList<UDSEntry> UDSEntryList;
00506 typedef QValueListIterator<UDSEntry> UDSEntryListIterator;
00507 typedef QValueListConstIterator<UDSEntry> UDSEntryListConstIterator;
00508
00512 class KIO_EXPORT MetaData : public QMap<QString, QString>
00513 {
00514 public:
00518 MetaData() : QMap<QString, QString>() { };
00522 MetaData(const QMap<QString, QString>&metaData) :
00523 QMap<QString, QString>(metaData) { };
00524
00530 MetaData & operator+= ( const QMap<QString,QString> &metaData )
00531 {
00532 QMap<QString,QString>::ConstIterator it;
00533 for( it = metaData.begin();
00534 it != metaData.end();
00535 ++it)
00536 {
00537 replace(it.key(), it.data());
00538 }
00539 return *this;
00540 }
00541 };
00542
00543 }
00544 #endif