kio Library API Documentation

global.h

00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2000 David Faure <faure@kde.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00016 Boston, MA 02111-1307, USA. 00017 */ 00018 #ifndef __global_h__ 00019 #define __global_h__ "$Id: global.h,v 1.66 2003/10/01 02:45:50 staikos Exp $" 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 signed long long int fileoffset_t; 00039 typedef unsigned long long int filesize_t; 00040 00047 QString convertSize( KIO::filesize_t size ); 00048 00056 QString number( KIO::filesize_t size ); 00057 00064 QString convertSizeFromKB( KIO::filesize_t kbSize ); 00065 00074 QTime calculateRemaining( KIO::filesize_t totalSize, KIO::filesize_t processedSize, KIO::filesize_t speed ); 00075 00085 QString itemsSummaryString(uint items, uint files, uint dirs, KIO::filesize_t size, bool showSize); 00086 00094 QString encodeFileName( const QString & str ); 00101 QString decodeFileName( const QString & str ); 00102 00106 enum Command { 00107 CMD_HOST = '0', // 48 00108 CMD_CONNECT = '1', // 49 00109 CMD_DISCONNECT = '2', // 50 00110 CMD_SLAVE_STATUS = '3', // 51 00111 CMD_SLAVE_CONNECT = '4', // 52 00112 CMD_SLAVE_HOLD = '5', // 53 00113 CMD_NONE = 'A', // 65 00114 CMD_TESTDIR = 'B', // 66 00115 CMD_GET = 'C', // 67 00116 CMD_PUT = 'D', // 68 00117 CMD_STAT = 'E', // 69 00118 CMD_MIMETYPE = 'F', // 70 00119 CMD_LISTDIR = 'G', // 71 00120 CMD_MKDIR = 'H', // 72 00121 CMD_RENAME = 'I', // 73 00122 CMD_COPY = 'J', // 74 00123 CMD_DEL = 'K', // 75 00124 CMD_CHMOD = 'L', // 76 00125 CMD_SPECIAL = 'M', // 77 00126 CMD_USERPASS = 'N', // 78 00127 CMD_REPARSECONFIGURATION = 'O', // 79 00128 CMD_META_DATA = 'P', // 80 00129 CMD_SYMLINK = 'Q', // 81 00130 CMD_SUBURL = 'R', // 82 Inform the slave about the url it is streaming on. 00131 CMD_MESSAGEBOXANSWER = 'S', // 83 00132 CMD_RESUMEANSWER = 'T', // 84 00133 CMD_CONFIG = 'U', // 85 00134 CMD_MULTI_GET = 'V' // 86 00135 // Add new ones here once a release is done, to avoid breaking binary compatibility. 00136 // Note that protocol-specific commands shouldn't be added here, but should use special. 00137 }; 00138 00142 enum Error { 00143 ERR_CANNOT_OPEN_FOR_READING = 1, 00144 ERR_CANNOT_OPEN_FOR_WRITING = 2, 00145 ERR_CANNOT_LAUNCH_PROCESS = 3, 00146 ERR_INTERNAL = 4, 00147 ERR_MALFORMED_URL = 5, 00148 ERR_UNSUPPORTED_PROTOCOL = 6, 00149 ERR_NO_SOURCE_PROTOCOL = 7, 00150 ERR_UNSUPPORTED_ACTION = 8, 00151 ERR_IS_DIRECTORY = 9, // ... where a file was expected 00152 ERR_IS_FILE = 10, // ... where a directory was expected (e.g. listing) 00153 ERR_DOES_NOT_EXIST = 11, 00154 ERR_FILE_ALREADY_EXIST = 12, 00155 ERR_DIR_ALREADY_EXIST = 13, 00156 ERR_UNKNOWN_HOST = 14, 00157 ERR_ACCESS_DENIED = 15, 00158 ERR_WRITE_ACCESS_DENIED = 16, 00159 ERR_CANNOT_ENTER_DIRECTORY = 17, 00160 ERR_PROTOCOL_IS_NOT_A_FILESYSTEM = 18, 00161 ERR_CYCLIC_LINK = 19, 00162 ERR_USER_CANCELED = 20, 00163 ERR_CYCLIC_COPY = 21, 00164 ERR_COULD_NOT_CREATE_SOCKET = 22, 00165 ERR_COULD_NOT_CONNECT = 23, 00166 ERR_CONNECTION_BROKEN = 24, 00167 ERR_NOT_FILTER_PROTOCOL = 25, 00168 ERR_COULD_NOT_MOUNT = 26, 00169 ERR_COULD_NOT_UNMOUNT = 27, 00170 ERR_COULD_NOT_READ = 28, 00171 ERR_COULD_NOT_WRITE = 29, 00172 ERR_COULD_NOT_BIND = 30, 00173 ERR_COULD_NOT_LISTEN = 31, 00174 ERR_COULD_NOT_ACCEPT = 32, 00175 ERR_COULD_NOT_LOGIN = 33, 00176 ERR_COULD_NOT_STAT = 34, 00177 ERR_COULD_NOT_CLOSEDIR = 35, 00178 ERR_COULD_NOT_MKDIR = 37, 00179 ERR_COULD_NOT_RMDIR = 38, 00180 ERR_CANNOT_RESUME = 39, 00181 ERR_CANNOT_RENAME = 40, 00182 ERR_CANNOT_CHMOD = 41, 00183 ERR_CANNOT_DELETE = 42, 00184 // The text argument is the protocol that the dead slave supported. 00185 // This means for example: file, ftp, http, ... 00186 ERR_SLAVE_DIED = 43, 00187 ERR_OUT_OF_MEMORY = 44, 00188 ERR_UNKNOWN_PROXY_HOST = 45, 00189 ERR_COULD_NOT_AUTHENTICATE = 46, 00190 ERR_ABORTED = 47, // Action got aborted from application side 00191 // ERR_WARNING, // Errors terminate the job now. Use warning() instead. 00192 ERR_INTERNAL_SERVER = 48, 00193 ERR_SERVER_TIMEOUT = 49, 00194 ERR_SERVICE_NOT_AVAILABLE = 50, 00195 ERR_UNKNOWN = 51, 00196 // (was a warning) ERR_CHECKSUM_MISMATCH = 52, 00197 ERR_UNKNOWN_INTERRUPT = 53, 00198 ERR_CANNOT_DELETE_ORIGINAL = 54, 00199 ERR_CANNOT_DELETE_PARTIAL = 55, 00200 ERR_CANNOT_RENAME_ORIGINAL = 56, 00201 ERR_CANNOT_RENAME_PARTIAL = 57, 00202 ERR_NEED_PASSWD = 58, 00203 ERR_CANNOT_SYMLINK = 59, 00204 ERR_NO_CONTENT = 60, // Action succeeded but no content will follow. 00205 ERR_DISK_FULL = 61, 00206 ERR_IDENTICAL_FILES = 62, // src==dest when moving/copying 00207 ERR_SLAVE_DEFINED = 63, // for slave specified errors that can be 00208 // rich text. Email links will be handled 00209 // by the standard email app and all hrefs 00210 // will be handled by the standard browser. 00211 // <a href="exec:/khelpcenter ?" will be 00212 // forked. 00213 ERR_UPGRADE_REQUIRED = 64, // A transport upgrade is required to access this 00214 // object. For instance, TLS is demanded by 00215 // the server in order to continue. 00216 ERR_POST_DENIED = 65 // Issued when trying to POST data to a certain Ports 00217 // see job.cpp 00218 }; 00219 00227 QString buildErrorString(int errorCode, const QString &errorText); 00228 00239 QString buildHTMLErrorString(int errorCode, const QString &errorText, 00240 const KURL *reqUrl = 0L, int method = -1 ); 00241 00258 QByteArray rawErrorDetail(int errorCode, const QString &errorText, 00259 const KURL *reqUrl = 0L, int method = -1 ); 00260 00269 QString unsupportedActionErrorString(const QString &protocol, int cmd); 00270 00274 enum UDSAtomTypes { 00276 UDS_STRING = 1, 00277 UDS_LONG = 2, 00278 UDS_TIME = 4 | UDS_LONG, 00279 00281 UDS_SIZE = 8 | UDS_LONG, 00282 UDS_SIZE_LARGE = 32768 | UDS_LONG, // For internal use only 00284 UDS_USER = 16 | UDS_STRING, 00288 UDS_ICON_NAME = 24 | UDS_STRING, 00290 UDS_GROUP = 32 | UDS_STRING, 00294 UDS_EXTRA = 48 | UDS_STRING, 00296 UDS_NAME = 64 | UDS_STRING, 00298 UDS_ACCESS = 128 | UDS_LONG, 00300 UDS_MODIFICATION_TIME = 256 | UDS_TIME, 00302 UDS_ACCESS_TIME = 512 | UDS_TIME, 00304 UDS_CREATION_TIME = 1024 | UDS_TIME, 00308 UDS_FILE_TYPE = 2048 | UDS_LONG, 00311 UDS_LINK_DEST = 4096 | UDS_STRING, 00313 UDS_URL = 8192 | UDS_STRING, 00315 UDS_MIME_TYPE = 16384 | UDS_STRING, 00318 UDS_GUESSED_MIME_TYPE = 16392 | UDS_STRING, 00321 UDS_XML_PROPERTIES = 32768 | UDS_STRING 00322 }; 00323 00329 enum CacheControl 00330 { 00331 CC_CacheOnly, 00332 CC_Cache, 00333 CC_Verify, 00334 CC_Refresh, 00335 00336 CC_Reload 00337 }; 00338 00346 KIO::CacheControl parseCacheControl(const QString &cacheControl); 00347 00355 QString getCacheControlString(KIO::CacheControl cacheControl); 00356 00362 QString findDeviceMountPoint( const QString& device ); 00363 00371 QString findPathMountPoint( const QString & filename ); 00372 00380 bool probably_slow_mounted(const QString& filename); 00381 00388 bool manually_mounted(const QString& filename); 00389 00390 enum FileSystemFlag { SupportsChmod, SupportsChown, SupportsUTime, 00391 SupportsSymlinks, CaseInsensitive }; 00411 bool testFileSystemFlag(const QString& filename, FileSystemFlag flag); 00412 00413 00414 /************ 00415 * 00416 * Universal Directory Service 00417 * 00418 * Any file or URL can be represented by the UDSEntry type below 00419 * A UDSEntry is a list of atoms 00420 * Each atom contains a specific bit of information for the file 00421 * 00422 * The following UDS constants represent the different possible values 00423 * for m_uds in the UDS atom structure below 00424 * 00425 * Each atom contains a specific bit of information for the file 00426 */ 00427 class UDSAtom 00428 { 00429 public: 00433 QString m_str; 00437 long long m_long; 00438 00442 unsigned int m_uds; 00443 }; 00444 00448 typedef QValueList<UDSAtom> UDSEntry; 00449 typedef QValueList<UDSEntry> UDSEntryList; 00450 typedef QValueListIterator<UDSEntry> UDSEntryListIterator; 00451 typedef QValueListConstIterator<UDSEntry> UDSEntryListConstIterator; 00452 00456 class MetaData : public QMap<QString, QString> 00457 { 00458 public: 00462 MetaData() : QMap<QString, QString>() { }; 00466 MetaData(const QMap<QString, QString>&metaData) : 00467 QMap<QString, QString>(metaData) { }; 00468 00474 MetaData & operator+= ( const QMap<QString,QString> &metaData ) 00475 { 00476 QMap<QString,QString>::ConstIterator it; 00477 for( it = metaData.begin(); 00478 it != metaData.end(); 00479 ++it) 00480 { 00481 replace(it.key(), it.data()); 00482 } 00483 return *this; 00484 } 00485 }; 00486 00487 } 00488 #endif
KDE Logo
This file is part of the documentation for kio Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Sep 29 09:41:00 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003