filemanager/src/inc/fmutils.h
changeset 40 4167eb56f30d
parent 33 328cf6fbe40c
child 47 12b82dc0e8db
equal deleted inserted replaced
33:328cf6fbe40c 40:4167eb56f30d
    21 
    21 
    22 #include "fmcommon.h"
    22 #include "fmcommon.h"
    23 
    23 
    24 #include <QString>
    24 #include <QString>
    25 
    25 
       
    26 /*!
       
    27     \class FmDriverInfo
       
    28     \brief The class FmDriverInfo provide drive info data
       
    29  */
    26 class FmDriverInfo
    30 class FmDriverInfo
    27 {
    31 {
    28 public:
    32 public:
    29     /*!
    33     /*!
    30         Used to get drive status for convenience.
    34         Used to get drive status for convenience.
    56     /*!
    60     /*!
    57         Used to get drive type for convenience.
    61         Used to get drive type for convenience.
    58     */
    62     */
    59     enum DriveType
    63     enum DriveType
    60     {
    64     {
       
    65         EDriveTypeNotExist = -1, // specified drive is not existed in device
    61         EDriveTypeRom,
    66         EDriveTypeRom,
    62         EDriveTypeRam,
    67         EDriveTypeRam,
    63         EDriveTypePhoneMemory,
    68         EDriveTypePhoneMemory,
    64         EDriveTypeMassStorage,
    69         EDriveTypeMassStorage,
    65         EDriveTypeMemoryCard,
    70         EDriveTypeMemoryCard,
    83         this->mName = rhs.mName;
    88         this->mName = rhs.mName;
    84         this->mVolumeName = rhs.mVolumeName;
    89         this->mVolumeName = rhs.mVolumeName;
    85         this->mDriveState = rhs.mDriveState;
    90         this->mDriveState = rhs.mDriveState;
    86         return *this;
    91         return *this;
    87     }
    92     }
    88 
    93     
       
    94     /*!
       
    95         Total size for drive
       
    96     */
    89     quint64 size() const { return mSize; }
    97     quint64 size() const { return mSize; }
       
    98     
       
    99     /*!
       
   100         Free size for drive
       
   101     */
    90     quint64 freeSize() const { return mFreeSize; }
   102     quint64 freeSize() const { return mFreeSize; }
       
   103     
       
   104     /*!
       
   105         path for drive
       
   106     */
    91     QString name() const { return mName; }
   107     QString name() const { return mName; }
       
   108     
       
   109     /*!
       
   110         volume for drive
       
   111     */
    92     QString volumeName() const { return mVolumeName; }
   112     QString volumeName() const { return mVolumeName; }
       
   113     
       
   114     /*!
       
   115         status for drive
       
   116     */
    93     DriveState driveState() const { return mDriveState; }
   117     DriveState driveState() const { return mDriveState; }
    94     FmDriverInfo::DriveType driveType();
   118     
       
   119     /*!
       
   120         drive type
       
   121     */
       
   122     DriveType driveType();
    95     
   123     
    96 private:
   124 private:
    97     quint64 mSize;
   125     quint64 mSize;
    98     quint64 mFreeSize;
   126     quint64 mFreeSize;
    99     QString mName;
   127     QString mName;
   101     DriveState mDriveState;
   129     DriveState mDriveState;
   102     DriveType mDriveType;
   130     DriveType mDriveType;
   103 };
   131 };
   104 Q_DECLARE_OPERATORS_FOR_FLAGS( FmDriverInfo::DriveState )
   132 Q_DECLARE_OPERATORS_FOR_FLAGS( FmDriverInfo::DriveState )
   105 
   133 
       
   134 /*!
       
   135     \class FmUtils
       
   136     \brief The class FmUtils provide util functions
       
   137     This class is implemented by three parts:
       
   138     fmutils.cpp for Qt Based functions
       
   139     fmutils_s60.cpp is symbian implement version for platform based functions
       
   140     fmutils_win.cpp is win32 implement version for platform based functions( a simple wrapper )
       
   141  */
   106 class FmUtils
   142 class FmUtils
   107 {
   143 {
   108 public:
   144 public:
   109     static QString getDriveNameFromPath( const QString &path );
   145     //////////////////////////////////////////////////////////////////
   110 	static QString getDriveLetterFromPath( const QString &path );
   146     // <QtBasedFunctions>
       
   147     static QString  getDriveNameFromPath( const QString &path );
       
   148     static QString  getDriveLetterFromPath( const QString &path );
       
   149     static QString  formatStorageSize( quint64 size );
       
   150     static bool     isDrive( const QString &path );
       
   151     static QString  formatPath( const QString &path  );
       
   152     static QString  fillPathWithSplash( const QString &filePath );
       
   153     static QString  removePathSplash( const QString &filePath );
       
   154     static void     getDriveList( QStringList &driveList, bool isHideUnAvailableDrive );
       
   155     static QString  fillDriveVolume( QString driveName, bool isFillWithDefaultVolume );
       
   156     static QString  getDefaultVolumeName( const QString &driveName );
       
   157     static QString  getVolumeNameWithDefaultNameIfNull( const QString &diskName, bool &defaultName );
       
   158     static bool     isPathEqual( const QString &pathFst, const QString &pathLast );
       
   159     static bool     checkFolderFileName( const QString& name );
       
   160     static bool     checkNewFolderOrFile( const QString& fileName, const QString &path, QString &errString );
       
   161     static bool     isSubLevelPath( const QString &src, const QString &dest );
       
   162     // </QtBasedFunctions>
       
   163     //////////////////////////////////////////////////////////////////
       
   164     
       
   165     
       
   166     //////////////////////////////////////////////////////////////////
       
   167     // <platformBasedFunctions>
   111     static FmDriverInfo queryDriverInfo( const QString &driverName );
   168     static FmDriverInfo queryDriverInfo( const QString &driverName );
   112     static QString formatStorageSize( quint64 size );
   169     
   113     static int removeDrivePwd( const QString &driverName, const QString &Pwd );
   170     // password related functions
   114     static int unlockDrive( const QString &driverName, const QString &Pwd );
   171     static int      removeDrivePwd( const QString &driverName, const QString &Pwd );
   115     static int checkDrivePwd( const QString &driverName, const QString &pwd);
   172     static int      unlockDrive( const QString &driverName, const QString &Pwd );
   116     static int setDrivePwd( const QString &driverName, const QString &oldPwd, const QString &newPwd);
   173     static int      checkDrivePwd( const QString &driverName, const QString &pwd);
   117     static void emptyPwd( QString &pwd );
   174     static int      setDrivePwd( const QString &driverName, const QString &oldPwd, const QString &newPwd);
   118     static int renameDrive( const QString &driverName, const QString &newVolumeName);
   175     static void     emptyPwd( QString &pwd );
   119     static int ejectDrive( const QString &driverName );
   176     
   120     static QString getFileType( const QString &filePath  );
   177     // external drive related functions
   121     static quint64 getDriveDetailsResult( const QString &folderPath, const QString &extension );
   178     static int      renameDrive( const QString &driverName, const QString &newVolumeName);
   122     static bool isDriveC( const QString &driverName );
   179     static int      ejectDrive( const QString &driverName );
   123     static bool isDrive( const QString &path );
   180     
   124 	static void createDefaultFolders( const QString &driverName );
   181     // drive security related functions
   125     static QString fillPathWithSplash( const QString &filePath );
   182     static bool     checkDriveAccessFilter( const QString &driveName );
   126     static QString removePathSplash( const QString &filePath );
   183     static QString  checkDriveToFolderFilter( const QString &path );
   127     static QString formatPath( const QString &path  );
   184     static QString  checkFolderToDriveFilter( const QString &path );
   128     static bool checkDriveAccessFilter( const QString &driveName );
   185     static int      isPathAccessabel( const QString &path );
   129     static QString checkDriveToFolderFilter( const QString &path );
   186     static bool     isDriveAvailable( const QString &path );
   130     static QString checkFolderToDriveFilter( const QString &path );
   187     
   131     static int isPathAccessabel( const QString &path );
   188     // system default folder related functions
   132     static bool isDriveAvailable( const QString &path );
   189     static bool     isDefaultFolder( const QString &folderPath  );
   133     static bool isPathEqual( const QString &pathFst, const QString &pathLast );
   190     static void     createDefaultFolders( const QString &driverName );
   134 
   191     static QString  localize( const QString &path );
   135     /// fill driveList of drives can be shown in driveListView
   192         
   136     static void getDriveList( QStringList &driveList, bool isHideUnAvailableDrive );
   193     // copy move related functions
   137     static QString fillDriveVolume( QString driveName, bool isFillWithDefaultVolume );
   194     static int      setFileAttributes( const QString &srcFile, const QString &desFile );
   138 
   195     static bool     hasEnoughSpace( const QString &targetDrive, qint64 size );
   139     static int launchFile( const QString &filePath );
   196     static int      moveInsideDrive( const QString &source, const QString &target );
   140     static void sendFiles( QStringList &filePathList );
   197 	
   141     static QString getBurConfigPath( QString appPath );
   198     // other fucntions
   142     static bool isDefaultFolder( const QString &folderPath  );
   199     static int      launchFile( const QString &filePath );
   143     static QString Localize( const QString &path );
   200     static QString  getBurConfigPath( QString appPath );
   144     
   201     static QString  getFileType( const QString &filePath  );
   145     static int getMaxFileNameLength();
   202     static bool     isDriveC( const QString &driverName );
   146     static bool checkMaxPathLength( const QString& path );
   203     static int      getMaxFileNameLength();
   147     static bool checkFolderFileName( const QString& name );
   204     static bool     checkMaxPathLength( const QString& path );
   148     
   205     // </platformBasedFunctions>
   149     /**
   206     //////////////////////////////////////////////////////////////////
   150      * check file or folder path is illegal or not.
       
   151      *
       
   152 	 * @param  fileName file/folder name, used to check illegal characters
       
   153      * @param  path file/folder path, used to check if path is available to use.
       
   154      * @param  errString if return false, errString will be set for error note.
       
   155      * @return true for not illegal and false for illegal path.
       
   156      */
       
   157     static bool checkNewFolderOrFile( const QString& fileName, const QString &path, QString &errString );
       
   158     
       
   159     /*
       
   160      * get the volume name of the disk, if it is null, then return the default name.
       
   161      * @param diskName the driver letter.
       
   162      * @param defaultName whether it is the default name.
       
   163      * @return the volume name.
       
   164      */
       
   165     static QString getVolumeNameWithDefaultNameIfNull( const QString &diskName, bool &defaultName );
       
   166 
       
   167     static bool isSubLevelPath( const QString &src, const QString &dest );
       
   168 
       
   169 	static int setFileAttributes( const QString &srcFile, const QString &desFile ); 
       
   170 };
   207 };
   171 
   208 
   172 #endif
   209 #endif
   173 
   210