• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeio/tdeio
 

tdeio/tdeio

  • tdeio
  • tdeio
global.h
1 /* This file is part of the KDE libraries
2  Copyright (C) 2000 David Faure <faure@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 version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 */
18 #ifndef __tdeio_global_h__
19 #define __tdeio_global_h__
20 
21 #include <tqstring.h>
22 #include <tqvaluelist.h>
23 #include <tqptrlist.h>
24 #include <tqdatastream.h>
25 #include <tqdatetime.h>
26 #include <tqmap.h>
27 
28 #include <kurl.h>
29 
34 namespace TDEIO
35 {
37  typedef TQ_LLONG fileoffset_t;
39  typedef TQ_ULLONG filesize_t;
40 
47  TDEIO_EXPORT TQString convertSize( TDEIO::filesize_t size );
48 
56  TDEIO_EXPORT TQString convertSizeWithBytes( TDEIO::filesize_t size );
64  TDEIO_EXPORT TQString number( TDEIO::filesize_t size );
65 
72  TDEIO_EXPORT TQString convertSizeFromKB( TDEIO::filesize_t kbSize );
73 
84  TDEIO_EXPORT unsigned int calculateRemainingSeconds( TDEIO::filesize_t totalSize,
85  TDEIO::filesize_t processedSize, TDEIO::filesize_t speed );
86 
95  TDEIO_EXPORT TQString convertSeconds( unsigned int seconds );
96 
106  TDEIO_EXPORT TQTime calculateRemaining( TDEIO::filesize_t totalSize, TDEIO::filesize_t processedSize, TDEIO::filesize_t speed ) TDE_DEPRECATED;
107 
117  TDEIO_EXPORT TQString itemsSummaryString(uint items, uint files, uint dirs, TDEIO::filesize_t size, bool showSize);
118 
126  TDEIO_EXPORT TQString encodeFileName( const TQString & str );
133  TDEIO_EXPORT TQString decodeFileName( const TQString & str );
134 
138  enum Command {
139  CMD_HOST = '0', // 48
140  CMD_CONNECT = '1', // 49
141  CMD_DISCONNECT = '2', // 50
142  CMD_SLAVE_STATUS = '3', // 51
143  CMD_SLAVE_CONNECT = '4', // 52
144  CMD_SLAVE_HOLD = '5', // 53
145  CMD_NONE = 'A', // 65
146  CMD_TESTDIR = 'B', // 66
147  CMD_GET = 'C', // 67
148  CMD_PUT = 'D', // 68
149  CMD_STAT = 'E', // 69
150  CMD_MIMETYPE = 'F', // 70
151  CMD_LISTDIR = 'G', // 71
152  CMD_MKDIR = 'H', // 72
153  CMD_RENAME = 'I', // 73
154  CMD_COPY = 'J', // 74
155  CMD_DEL = 'K', // 75
156  CMD_CHMOD = 'L', // 76
157  CMD_SPECIAL = 'M', // 77
158  CMD_USERPASS = 'N', // 78
159  CMD_REPARSECONFIGURATION = 'O', // 79
160  CMD_META_DATA = 'P', // 80
161  CMD_SYMLINK = 'Q', // 81
162  CMD_SUBURL = 'R', // 82 Inform the slave about the url it is streaming on.
163  CMD_MESSAGEBOXANSWER = 'S', // 83
164  CMD_RESUMEANSWER = 'T', // 84
165  CMD_CONFIG = 'U', // 85
166  CMD_MULTI_GET = 'V', // 86
167  CMD_LOCALURL = 'W' // 87
168  // Add new ones here once a release is done, to avoid breaking binary compatibility.
169  // Note that protocol-specific commands shouldn't be added here, but should use special.
170  };
171 
175  enum Error {
176  ERR_CANNOT_OPEN_FOR_READING = 1,
177  ERR_CANNOT_OPEN_FOR_WRITING = 2,
178  ERR_CANNOT_LAUNCH_PROCESS = 3,
179  ERR_INTERNAL = 4,
180  ERR_MALFORMED_URL = 5,
181  ERR_UNSUPPORTED_PROTOCOL = 6,
182  ERR_NO_SOURCE_PROTOCOL = 7,
183  ERR_UNSUPPORTED_ACTION = 8,
184  ERR_IS_DIRECTORY = 9, // ... where a file was expected
185  ERR_IS_FILE = 10, // ... where a directory was expected (e.g. listing)
186  ERR_DOES_NOT_EXIST = 11,
187  ERR_FILE_ALREADY_EXIST = 12,
188  ERR_DIR_ALREADY_EXIST = 13,
189  ERR_UNKNOWN_HOST = 14,
190  ERR_ACCESS_DENIED = 15,
191  ERR_WRITE_ACCESS_DENIED = 16,
192  ERR_CANNOT_ENTER_DIRECTORY = 17,
193  ERR_PROTOCOL_IS_NOT_A_FILESYSTEM = 18,
194  ERR_CYCLIC_LINK = 19,
195  ERR_USER_CANCELED = 20,
196  ERR_CYCLIC_COPY = 21,
197  ERR_COULD_NOT_CREATE_SOCKET = 22, // KDE4: s/COULD_NOT/CANNOT/ or the other way round
198  ERR_COULD_NOT_CONNECT = 23,
199  ERR_CONNECTION_BROKEN = 24,
200  ERR_NOT_FILTER_PROTOCOL = 25,
201  ERR_COULD_NOT_MOUNT = 26,
202  ERR_COULD_NOT_UNMOUNT = 27,
203  ERR_COULD_NOT_READ = 28,
204  ERR_COULD_NOT_WRITE = 29,
205  ERR_COULD_NOT_BIND = 30,
206  ERR_COULD_NOT_LISTEN = 31,
207  ERR_COULD_NOT_ACCEPT = 32,
208  ERR_COULD_NOT_LOGIN = 33,
209  ERR_COULD_NOT_STAT = 34,
210  ERR_COULD_NOT_CLOSEDIR = 35,
211  ERR_COULD_NOT_MKDIR = 37,
212  ERR_COULD_NOT_RMDIR = 38,
213  ERR_CANNOT_RESUME = 39,
214  ERR_CANNOT_RENAME = 40,
215  ERR_CANNOT_CHMOD = 41,
216  ERR_CANNOT_DELETE = 42,
217  // The text argument is the protocol that the dead slave supported.
218  // This means for example: file, ftp, http, ...
219  ERR_SLAVE_DIED = 43,
220  ERR_OUT_OF_MEMORY = 44,
221  ERR_UNKNOWN_PROXY_HOST = 45,
222  ERR_COULD_NOT_AUTHENTICATE = 46,
223  ERR_ABORTED = 47, // Action got aborted from application side
224  ERR_INTERNAL_SERVER = 48,
225  ERR_SERVER_TIMEOUT = 49,
226  ERR_SERVICE_NOT_AVAILABLE = 50,
227  ERR_UNKNOWN = 51,
228  // (was a warning) ERR_CHECKSUM_MISMATCH = 52,
229  ERR_UNKNOWN_INTERRUPT = 53,
230  ERR_CANNOT_DELETE_ORIGINAL = 54,
231  ERR_CANNOT_DELETE_PARTIAL = 55,
232  ERR_CANNOT_RENAME_ORIGINAL = 56,
233  ERR_CANNOT_RENAME_PARTIAL = 57,
234  ERR_NEED_PASSWD = 58,
235  ERR_CANNOT_SYMLINK = 59,
236  ERR_NO_CONTENT = 60, // Action succeeded but no content will follow.
237  ERR_DISK_FULL = 61,
238  ERR_IDENTICAL_FILES = 62, // src==dest when moving/copying
239  ERR_SLAVE_DEFINED = 63, // for slave specified errors that can be
240  // rich text. Email links will be handled
241  // by the standard email app and all hrefs
242  // will be handled by the standard browser.
243  // <a href="exec:/khelpcenter ?" will be
244  // forked.
245  ERR_UPGRADE_REQUIRED = 64, // A transport upgrade is required to access this
246  // object. For instance, TLS is demanded by
247  // the server in order to continue.
248  ERR_POST_DENIED = 65, // Issued when trying to POST data to a certain Ports
249  // see job.cpp
250  ERR_OFFLINE_MODE = 66 // Used when an app is in offline mode and a
251  // requested document is unavailable.
252  };
253 
261  TDEIO_EXPORT TQString buildErrorString(int errorCode, const TQString &errorText);
262 
273  TDEIO_EXPORT TQString buildHTMLErrorString(int errorCode, const TQString &errorText,
274  const KURL *reqUrl = 0L, int method = -1 );
275 
292  TDEIO_EXPORT TQByteArray rawErrorDetail(int errorCode, const TQString &errorText,
293  const KURL *reqUrl = 0L, int method = -1 );
294 
303  TDEIO_EXPORT TQString unsupportedActionErrorString(const TQString &protocol, int cmd);
304 
308  enum UDSAtomTypes {
310  UDS_STRING = 1,
311  UDS_LONG = 2,
312  UDS_TIME = 4 | UDS_LONG,
313 
314  // To add new UDS entries below, you can use a step of 8
315  // (i.e. 8, 16, 24, 32, etc.) Only the last 3 bits are a bitfield,
316  // the rest isn't.
317 
319  UDS_SIZE = 8 | UDS_LONG,
320  UDS_SIZE_LARGE = 32768 | UDS_LONG, // For internal use only
322  UDS_USER = 16 | UDS_STRING,
326  UDS_ICON_NAME = 24 | UDS_STRING,
328  UDS_GROUP = 32 | UDS_STRING,
332  UDS_EXTRA = 48 | UDS_STRING,
335  UDS_NAME = 64 | UDS_STRING,
338  UDS_LOCAL_PATH = 72 | UDS_STRING,
341  UDS_HIDDEN = 80 | UDS_LONG,
344  UDS_EXTENDED_ACL = 88 | UDS_LONG,
347  UDS_ACL_STRING = 96 | UDS_STRING,
351  UDS_DEFAULT_ACL_STRING = 104 | UDS_STRING,
352 
353  // available: 112, 120
354 
356  UDS_ACCESS = 128 | UDS_LONG,
358  UDS_MODIFICATION_TIME = 256 | UDS_TIME,
360  UDS_ACCESS_TIME = 512 | UDS_TIME,
362  UDS_CREATION_TIME = 1024 | UDS_TIME,
366  UDS_FILE_TYPE = 2048 | UDS_LONG,
369  UDS_LINK_DEST = 4096 | UDS_STRING,
371  UDS_URL = 8192 | UDS_STRING,
373  UDS_MIME_TYPE = 16384 | UDS_STRING,
376  UDS_GUESSED_MIME_TYPE = 16392 | UDS_STRING,
379  UDS_XML_PROPERTIES = 0x8000 | UDS_STRING
380  };
381 
387  enum CacheControl
388  {
389  CC_CacheOnly,
390  CC_Cache,
391  CC_Verify,
392  CC_Refresh,
394  CC_Reload
395  };
396 
404  TDEIO_EXPORT TDEIO::CacheControl parseCacheControl(const TQString &cacheControl);
405 
413  TDEIO_EXPORT TQString getCacheControlString(TDEIO::CacheControl cacheControl);
414 
420  TDEIO_EXPORT TQString findDeviceMountPoint( const TQString& device );
421 
429  TDEIO_EXPORT TQString findPathMountPoint( const TQString & filename );
430 
438  TDEIO_EXPORT bool probably_slow_mounted(const TQString& filename);
439 
446  TDEIO_EXPORT bool manually_mounted(const TQString& filename);
447 
448  enum FileSystemFlag { SupportsChmod, SupportsChown, SupportsUTime,
449  SupportsSymlinks, CaseInsensitive };
470  TDEIO_EXPORT bool testFileSystemFlag(const TQString& filename, FileSystemFlag flag);
471 
472 
473 /************
474  *
475  * Universal Directory Service
476  *
477  * Any file or URL can be represented by the UDSEntry type below
478  * A UDSEntry is a list of atoms
479  * Each atom contains a specific bit of information for the file
480  *
481  * The following UDS constants represent the different possible values
482  * for m_uds in the UDS atom structure below
483  *
484  * Each atom contains a specific bit of information for the file
485  */
486 class TDEIO_EXPORT UDSAtom
487 {
488 public:
492  TQString m_str;
496  long long m_long;
497 
501  unsigned int m_uds;
502 };
503 
507 typedef TQValueList<UDSAtom> UDSEntry;
508 typedef TQValueList<UDSEntry> UDSEntryList;
509 typedef TQValueListIterator<UDSEntry> UDSEntryListIterator;
510 typedef TQValueListConstIterator<UDSEntry> UDSEntryListConstIterator;
511 
515 class TDEIO_EXPORT MetaData : public TQMap<TQString, TQString>
516 {
517 public:
521  MetaData() : TQMap<TQString, TQString>() { };
525  MetaData(const TQMap<TQString, TQString>&metaData) :
526  TQMap<TQString, TQString>(metaData) { };
527 
533  MetaData & operator+= ( const TQMap<TQString,TQString> &metaData )
534  {
535  TQMap<TQString,TQString>::ConstIterator it;
536  for( it = metaData.begin();
537  it != metaData.end();
538  ++it)
539  {
540  replace(it.key(), it.data());
541  }
542  return *this;
543  }
544 };
545 
546 }
547 #endif
TDEIO::MetaData
MetaData is a simple map of key/value strings.
Definition: global.h:516
TDEIO::MetaData::MetaData
MetaData()
Creates an empty meta data map.
Definition: global.h:521
TDEIO::MetaData::MetaData
MetaData(const TQMap< TQString, TQString > &metaData)
Copy constructor.
Definition: global.h:525
TDEIO
A namespace for TDEIO globals.
Definition: authinfo.h:29
TDEIO::convertSizeWithBytes
TDEIO_EXPORT TQString convertSizeWithBytes(TDEIO::filesize_t size)
Converts size from bytes to a string representation with includes the size in bytes.
Definition: global.cpp:45
TDEIO::convertSizeFromKB
TDEIO_EXPORT TQString convertSizeFromKB(TDEIO::filesize_t kbSize)
Converts size from kilo-bytes to the string representation.
Definition: global.cpp:91
TDEIO::calculateRemainingSeconds
TDEIO_EXPORT unsigned int calculateRemainingSeconds(TDEIO::filesize_t totalSize, TDEIO::filesize_t processedSize, TDEIO::filesize_t speed)
Calculates remaining time in seconds from total size, processed size and speed.
Definition: global.cpp:103
TDEIO::number
TDEIO_EXPORT TQString number(TDEIO::filesize_t size)
Converts a size to a string representation Not unlike TQString::number(...)
Definition: global.cpp:96
TDEIO::convertSeconds
TDEIO_EXPORT TQString convertSeconds(unsigned int seconds)
Convert seconds to a string representing number of days, hours, minutes and seconds.
Definition: global.cpp:112
TDEIO::buildHTMLErrorString
TDEIO_EXPORT TQString buildHTMLErrorString(int errorCode, const TQString &errorText, const KURL *reqUrl=0L, int method=-1)
Returns a translated html error message for errorCode using the additional error information provided...
TDEIO::probably_slow_mounted
TDEIO_EXPORT bool probably_slow_mounted(const TQString &filename)
Checks if the path belongs to a filesystem that is probably slow.
Definition: global.cpp:1967
TDEIO::Command
Command
Commands that can be invoked by a job.
Definition: global.h:138
TDEIO::rawErrorDetail
TDEIO_EXPORT TQByteArray rawErrorDetail(int errorCode, const TQString &errorText, const KURL *reqUrl=0L, int method=-1)
Returns translated error details for errorCode using the additional error information provided by err...
Definition: global.cpp:528
TDEIO::parseCacheControl
TDEIO_EXPORT TDEIO::CacheControl parseCacheControl(const TQString &cacheControl)
Parses the string representation of the cache control option.
Definition: global.cpp:2002
TDEIO::UDSAtomTypes
UDSAtomTypes
Constants used to specify the type of a KUDSAtom.
Definition: global.h:308
TDEIO::UDS_HIDDEN
@ UDS_HIDDEN
Treat the file as a hidden file or as a normal file, regardless of (the absence of) a leading dot in ...
Definition: global.h:341
TDEIO::UDS_ACL_STRING
@ UDS_ACL_STRING
The access control list serialized into a single string.
Definition: global.h:347
TDEIO::UDS_XML_PROPERTIES
@ UDS_XML_PROPERTIES
XML properties, e.g.
Definition: global.h:379
TDEIO::UDS_GUESSED_MIME_TYPE
@ UDS_GUESSED_MIME_TYPE
A mime type to be used for displaying only.
Definition: global.h:376
TDEIO::UDS_DEFAULT_ACL_STRING
@ UDS_DEFAULT_ACL_STRING
The default access control list serialized into a single string.
Definition: global.h:351
TDEIO::UDS_LINK_DEST
@ UDS_LINK_DEST
Name of the file where the link points to Allows to check for a symlink (don't use S_ISLNK !...
Definition: global.h:369
TDEIO::UDS_URL
@ UDS_URL
An alternative URL (If different from the caption)
Definition: global.h:371
TDEIO::UDS_USER
@ UDS_USER
User ID of the file owner.
Definition: global.h:322
TDEIO::UDS_SIZE
@ UDS_SIZE
Size of the file.
Definition: global.h:319
TDEIO::UDS_STRING
@ UDS_STRING
First let's define the item types.
Definition: global.h:310
TDEIO::UDS_CREATION_TIME
@ UDS_CREATION_TIME
The time the file was created.
Definition: global.h:362
TDEIO::UDS_MODIFICATION_TIME
@ UDS_MODIFICATION_TIME
The last time the file was modified.
Definition: global.h:358
TDEIO::UDS_ICON_NAME
@ UDS_ICON_NAME
Name of the icon, that should be used for displaying.
Definition: global.h:326
TDEIO::UDS_FILE_TYPE
@ UDS_FILE_TYPE
File type, part of the mode returned by stat (for a link, this returns the file type of the pointed i...
Definition: global.h:366
TDEIO::UDS_GROUP
@ UDS_GROUP
Group ID of the file owner.
Definition: global.h:328
TDEIO::UDS_EXTRA
@ UDS_EXTRA
Extra data (used only if you specified Columns/ColumnsTypes) This is the only UDS entry that can be r...
Definition: global.h:332
TDEIO::UDS_ACCESS
@ UDS_ACCESS
Access permissions (part of the mode returned by stat)
Definition: global.h:356
TDEIO::UDS_ACCESS_TIME
@ UDS_ACCESS_TIME
The last time the file was opened.
Definition: global.h:360
TDEIO::UDS_NAME
@ UDS_NAME
Filename - as displayed in directory listings etc.
Definition: global.h:335
TDEIO::UDS_LOCAL_PATH
@ UDS_LOCAL_PATH
A local file path if the ioslave display files sitting on the local filesystem (but in another hierar...
Definition: global.h:338
TDEIO::UDS_MIME_TYPE
@ UDS_MIME_TYPE
A mime type; prevents guessing.
Definition: global.h:373
TDEIO::UDS_EXTENDED_ACL
@ UDS_EXTENDED_ACL
Indicates that the entry has extended ACL entries.
Definition: global.h:344
TDEIO::UDSEntry
TQValueList< UDSAtom > UDSEntry
An entry is the list of atoms containing all the information for a file or URL.
Definition: global.h:507
TDEIO::buildErrorString
TDEIO_EXPORT TQString buildErrorString(int errorCode, const TQString &errorText)
Returns a translated error message for errorCode using the additional error information provided by e...
Definition: global.cpp:230
TDEIO::convertSize
TDEIO_EXPORT TQString convertSize(TDEIO::filesize_t size)
Converts size from bytes to the string representation.
Definition: global.cpp:53
TDEIO::calculateRemaining
TDEIO_EXPORT TQTime calculateRemaining(TDEIO::filesize_t totalSize, TDEIO::filesize_t processedSize, TDEIO::filesize_t speed) TDE_DEPRECATED
Calculates remaining time from total size, processed size and speed.
Definition: global.cpp:127
TDEIO::getCacheControlString
TDEIO_EXPORT TQString getCacheControlString(TDEIO::CacheControl cacheControl)
Returns a string representation of the given cache control method.
Definition: global.cpp:2021
TDEIO::testFileSystemFlag
TDEIO_EXPORT bool testFileSystemFlag(const TQString &filename, FileSystemFlag flag)
Checks the capabilities of the filesystem to which a given file belongs.
Definition: global.cpp:1979
TDEIO::manually_mounted
TDEIO_EXPORT bool manually_mounted(const TQString &filename)
Checks if the path belongs to a filesystem that is manually mounted.
Definition: global.cpp:1955
TDEIO::encodeFileName
TDEIO_EXPORT TQString encodeFileName(const TQString &str)
Encodes (from the text displayed to the real filename) This translates % into %% and / into ∕ (U+2215...
Definition: global.cpp:165
TDEIO::CacheControl
CacheControl
Specifies how to use the cache.
Definition: global.h:388
TDEIO::CC_Cache
@ CC_Cache
Use cached entry if available.
Definition: global.h:390
TDEIO::CC_CacheOnly
@ CC_CacheOnly
Fail request if not in cache.
Definition: global.h:389
TDEIO::CC_Refresh
@ CC_Refresh
Always validate cached entry with remote site.
Definition: global.h:392
TDEIO::CC_Verify
@ CC_Verify
Validate cached entry with remote site if expired.
Definition: global.h:391
TDEIO::CC_Reload
@ CC_Reload
Always fetch from remote site.
Definition: global.h:394
TDEIO::unsupportedActionErrorString
TDEIO_EXPORT TQString unsupportedActionErrorString(const TQString &protocol, int cmd)
Returns an appropriate error message if the given command cmd is an unsupported action (ERR_UNSUPPORT...
Definition: global.cpp:439
TDEIO::Error
Error
Error codes that can be emitted by TDEIO.
Definition: global.h:175
TDEIO::findDeviceMountPoint
TDEIO_EXPORT TQString findDeviceMountPoint(const TQString &device)
Returns the mount point where device is mounted right now.
Definition: global.cpp:1401
TDEIO::decodeFileName
TDEIO_EXPORT TQString decodeFileName(const TQString &str)
Decodes (from the filename to the text displayed) This translates %2[fF] into /, %% into %,...
Definition: global.cpp:191
TDEIO::fileoffset_t
TQ_LLONG fileoffset_t
64-bit file offset
Definition: global.h:37
TDEIO::filesize_t
TQ_ULLONG filesize_t
64-bit file size
Definition: global.h:39
TDEIO::findPathMountPoint
TDEIO_EXPORT TQString findPathMountPoint(const TQString &filename)
Returns the mount point on which resides filename.
Definition: global.cpp:1944
TDEIO::itemsSummaryString
TDEIO_EXPORT TQString itemsSummaryString(uint items, uint files, uint dirs, TDEIO::filesize_t size, bool showSize)
Helper for showing information about a set of files and directories.
Definition: global.cpp:150

tdeio/tdeio

Skip menu "tdeio/tdeio"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdeio/tdeio

Skip menu "tdeio/tdeio"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeio/tdeio by doxygen 1.9.1
This website is maintained by Timothy Pearson.