home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / k3bglobals.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-05-27  |  7.2 KB  |  258 lines

  1. /* 
  2.  *
  3.  * $Id: k3bglobals.h 630384 2007-02-05 09:33:17Z mlaurent $
  4.  * Copyright (C) 2003 Sebastian Trueg <trueg@k3b.org>
  5.  *
  6.  * This file is part of the K3b project.
  7.  * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
  8.  *
  9.  * This program is free software; you can redistribute it and/or modify
  10.  * it under the terms of the GNU General Public License as published by
  11.  * the Free Software Foundation; either version 2 of the License, or
  12.  * (at your option) any later version.
  13.  * See the file "COPYING" for the exact licensing terms.
  14.  */
  15.  
  16.  
  17. #ifndef K3BGLOBALS_H
  18. #define K3BGLOBALS_H
  19.  
  20. #ifdef HAVE_CONFIG_H
  21. #include <config.h>
  22. #endif
  23.  
  24. #include <qstring.h>
  25. #include <qfile.h>
  26. #include <kio/global.h>
  27. #include <kurl.h>
  28. #include <k3bdevicetypes.h>
  29. #include "k3b_export.h"
  30.  
  31. class KConfig;
  32. class K3bVersion;
  33. class K3bExternalBin;
  34.  
  35.  
  36. #include <sys/stat.h>
  37.  
  38.  
  39. #ifdef HAVE_STAT64
  40. #define k3b_struct_stat struct stat64
  41. #define k3b_stat        ::stat64
  42. #define k3b_lstat       ::lstat64
  43. #else
  44. #define k3b_struct_stat struct stat
  45. #define k3b_stat        ::stat
  46. #define k3b_lstat       ::lstat
  47. #endif
  48.  
  49.  
  50. namespace K3bDevice {
  51.   class Device;
  52. }
  53.  
  54. namespace K3b
  55. {
  56.   enum WritingApp { 
  57.     DEFAULT = 1, 
  58.     CDRECORD = 2, 
  59.     CDRDAO = 4,
  60.     DVDRECORD = 8,
  61.     GROWISOFS = 16,
  62.     DVD_RW_FORMAT = 32
  63.   };
  64.  
  65.   LIBK3B_EXPORT int writingAppFromString( const QString& );
  66.  
  67.   /**
  68.    * DATA_MODE_AUTO - let K3b determine the best mode
  69.    * MODE1 - refers to the default Yellow book mode1
  70.    * MODE2 - refers to CDROM XA mode2 form1
  71.    */
  72.   enum DataMode { 
  73.     DATA_MODE_AUTO,
  74.     MODE1, 
  75.     MODE2
  76.   };
  77.  
  78.   /**
  79.    * The sector size denotes the number of bytes K3b provides per sector.
  80.    * This is based on the sizes cdrecord's -data, -xa, and -xamix parameters
  81.    * demand.
  82.    */
  83.   enum SectorSize {
  84.     SECTORSIZE_AUDIO = 2352,
  85.     SECTORSIZE_DATA_2048 = 2048,
  86.     SECTORSIZE_DATA_2048_SUBHEADER = 2056,
  87.     SECTORSIZE_DATA_2324 = 2324,
  88.     SECTORSIZE_DATA_2324_SUBHEADER = 2332,
  89.     SECTORSIZE_RAW = 2448
  90.   };
  91.  
  92.   /**
  93.    * AUTO  - let K3b determine the best mode
  94.    * TAO   - Track at once
  95.    * DAO   - Disk at once (or session at once)
  96.    * RAW   - Raw mode
  97.    *
  98.    * may be or'ed together (except for WRITING_MODE_AUTO of course)
  99.    */
  100.   enum WritingMode { 
  101.     WRITING_MODE_AUTO = 0, 
  102.     TAO = K3bDevice::WRITINGMODE_TAO, 
  103.     DAO = K3bDevice::WRITINGMODE_SAO, 
  104.     RAW = K3bDevice::WRITINGMODE_RAW,
  105.     WRITING_MODE_INCR_SEQ = K3bDevice::WRITINGMODE_INCR_SEQ,  // Incremental Sequential
  106.     WRITING_MODE_RES_OVWR = K3bDevice::WRITINGMODE_RES_OVWR // Restricted Overwrite
  107.   };
  108.  
  109.   LIBK3B_EXPORT QString writingModeString( int );
  110.  
  111.   LIBK3B_EXPORT QString framesToString( int h, bool showFrames = true );
  112.   /*LIBK3B_EXPORT QString sizeToTime( long size );*/
  113.  
  114.   LIBK3B_EXPORT Q_INT16 swapByteOrder( const Q_INT16& i );
  115.   LIBK3B_EXPORT Q_INT32 swapByteOrder( const Q_INT32& i );
  116.   LIBK3B_EXPORT Q_INT64 swapByteOrder( const Q_INT64& i );
  117.  
  118.   int round( double );
  119.  
  120.   /**
  121.    * This checks the free space on the filesystem path is in.
  122.    * We use this since we encountered problems with the KDE version.
  123.    * @returns true on success.
  124.    */
  125.   LIBK3B_EXPORT bool kbFreeOnFs( const QString& path, unsigned long& size, unsigned long& avail );
  126.  
  127.   /**
  128.    * Cut a filename preserving the extension
  129.    */
  130.   LIBK3B_EXPORT QString cutFilename( const QString& name, unsigned int len );
  131.  
  132.   LIBK3B_EXPORT QString removeFilenameExtension( const QString& name );
  133.  
  134.   /**
  135.    * Append a number to a filename preserving the extension.
  136.    * The resulting name's length will not exceed @p maxlen
  137.    */
  138.   LIBK3B_EXPORT QString appendNumberToFilename( const QString& name, int num, unsigned int maxlen );
  139.  
  140.   LIBK3B_EXPORT QString findUniqueFilePrefix( const QString& _prefix = QString::null, const QString& path = QString::null );
  141.  
  142.   /**
  143.    * Find a unique filename in directory d (if d is empty the method uses the defaultTempPath)
  144.    */
  145.   LIBK3B_EXPORT QString findTempFile( const QString& ending = QString::null, const QString& d = QString::null );
  146.  
  147.   /**
  148.    * Wrapper around KStandardDirs::findExe which searches the PATH and some additional
  149.    * directories to find system tools which are normally only in root's PATH.
  150.    */
  151.   LIBK3B_EXPORT QString findExe( const QString& name );
  152.  
  153.   /**
  154.    * get the default K3b temp path to store image files
  155.    */
  156.   LIBK3B_EXPORT QString defaultTempPath();
  157.  
  158.   /**
  159.    * makes sure a path ends with a "/"
  160.    */
  161.   LIBK3B_EXPORT QString prepareDir( const QString& dir );
  162.  
  163.   /**
  164.    * returns the parent dir of a path.
  165.    * CAUTION: this does only work well with absolut paths.
  166.    *
  167.    * Example: /usr/share/doc -> /usr/share/
  168.    */
  169.   QString parentDir( const QString& path );
  170.  
  171.   /**
  172.    * For now this just replaces multiple occurrences of / with a single /
  173.    */
  174.   LIBK3B_EXPORT QString fixupPath( const QString& );
  175.  
  176.   /**
  177.    * resolves a symlinks completely. Meaning it also handles links to links to links...
  178.    */
  179.   LIBK3B_EXPORT QString resolveLink( const QString& );
  180.  
  181.   LIBK3B_EXPORT K3bVersion kernelVersion();
  182.  
  183.   /**
  184.    * Kernel version stripped of all suffixes
  185.    */
  186.   LIBK3B_EXPORT K3bVersion simpleKernelVersion();
  187.  
  188.   QString systemName();
  189.  
  190.   LIBK3B_EXPORT KIO::filesize_t filesize( const KURL& );
  191.  
  192.   /**
  193.    * Calculate the total size of an image file. This also includes
  194.    * images splitted by a K3bFileSplitter.
  195.    *
  196.    * \returns the total size of the image file at url
  197.    */
  198.   LIBK3B_EXPORT KIO::filesize_t imageFilesize( const KURL& url );
  199.  
  200.   /**
  201.    * true if the kernel supports ATAPI devices without SCSI emulation.
  202.    * use in combination with the K3bExternalProgram feature "plain-atapi"
  203.    */
  204.   LIBK3B_EXPORT bool plainAtapiSupport();
  205.   
  206.   /**
  207.    * true if the kernel supports ATAPI devices without SCSI emulation
  208.    * via the ATAPI: pseudo stuff
  209.    * use in combination with the K3bExternalProgram feature "hacked-atapi"
  210.    */
  211.   LIBK3B_EXPORT bool hackedAtapiSupport();
  212.  
  213.   /**
  214.    * Used to create a parameter for cdrecord, cdrdao or readcd.
  215.    * Takes care of SCSI and ATAPI.
  216.    */
  217.   QString externalBinDeviceParameter( K3bDevice::Device* dev, const K3bExternalBin* );
  218.  
  219.   /**
  220.    * Convert an url pointing to a local device to a K3bDevice.
  221.    * Supports media:// and system::// urls.
  222.    */
  223.   LIBK3B_EXPORT K3bDevice::Device* urlToDevice( const KURL& deviceUrl );
  224.  
  225.   /**
  226.    * Tries to convert urls from local protocols != "file" to file (for now supports media:/)
  227.    */
  228.   LIBK3B_EXPORT KURL convertToLocalUrl( const KURL& url );
  229.   LIBK3B_EXPORT KURL::List convertToLocalUrls( const KURL::List& l );
  230.  
  231.   LIBK3B_EXPORT Q_INT16 fromLe16( char* );
  232.   LIBK3B_EXPORT Q_INT32 fromLe32( char* );
  233.   LIBK3B_EXPORT Q_INT64 fromLe64( char* );
  234.  
  235.   LIBK3B_EXPORT bool isMounted( K3bDevice::Device* );
  236.  
  237.   /**
  238.    * Tries to unmount the device ignoring its actual mounting state.
  239.    * This method uses both KIO::unmount and pumount if available.
  240.    */
  241.   LIBK3B_EXPORT bool unmount( K3bDevice::Device* );
  242.  
  243.   /**
  244.    * Tries to mount the medium. Since K3b does not gather any information
  245.    * about mount points the only methods used are pmount and HAL::mount
  246.    */
  247.   LIBK3B_EXPORT bool mount( K3bDevice::Device* );
  248.  
  249.   /**
  250.    * Ejects the medium in the device or simply opens the tray.
  251.    * This method improves over K3bDevice::Device::eject in that it
  252.    * unmounts before ejecting and introduces HAL support.
  253.    */
  254.   LIBK3B_EXPORT bool eject( K3bDevice::Device* );
  255. }
  256.  
  257. #endif
  258.