author | hgs |
Wed, 29 Sep 2010 10:37:03 +0800 | |
changeset 46 | d58987eac7e8 |
parent 37 | 15bc28c9dd51 |
permissions | -rw-r--r-- |
14
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/* |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
8 |
* |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
11 |
* |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
12 |
* Contributors: |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
13 |
* Zhiqiang Yang <zhiqiang.yang@nokia.com> |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
14 |
* |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
15 |
* Description: |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
16 |
* The header file of the file manager utilities |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
*/ |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
18 |
|
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
19 |
#ifndef FMUTILS_H |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
20 |
#define FMUTILS_H |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
21 |
|
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
22 |
#include "fmcommon.h" |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
23 |
|
46 | 24 |
#include <QDir> |
14
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
25 |
#include <QString> |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
26 |
|
37 | 27 |
/*! |
28 |
\class FmDriverInfo |
|
29 |
\brief The class FmDriverInfo provide drive info data |
|
30 |
*/ |
|
14
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
31 |
class FmDriverInfo |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
32 |
{ |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
33 |
public: |
37 | 34 |
/*! |
35 |
Used to get drive status for convenience. |
|
36 |
/sa DriveType is used to get drive type. |
|
37 |
*/ |
|
14
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
38 |
enum driveState |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
39 |
{ |
37 | 40 |
EDriveNotPresent = 0x1, // true when Drive have not inserted, for example, MMC Card |
41 |
EDriveAvailable = 0x2, // false when drive is locked or corrupted, for example MMC Card |
|
42 |
EDriveLocked = 0x4, |
|
43 |
EDriveCorrupted = 0x8, |
|
44 |
EDriveWriteProtected = 0x10, |
|
45 |
EDriveRemovable = 0x20, |
|
46 |
EDriveRom = 0x40, |
|
47 |
EDriveFormattable = 0x80, |
|
48 |
EDriveFormatted = 0x100, |
|
49 |
EDriveLockable = 0x200, |
|
50 |
EDrivePasswordProtected = 0x400, |
|
51 |
EDriveBackupped = 0x800, |
|
52 |
EDriveConnected = 0x1000, |
|
53 |
EDriveEjectable = 0x2000, |
|
54 |
EDriveInUse = 0x4000, |
|
55 |
EDriveMassStorage = 0x8000, |
|
56 |
EDriveRam = 0x10000, |
|
57 |
EDriveUsbMemory = 0x20000, |
|
58 |
EDriveRemote = 0x40000, |
|
14
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
59 |
}; |
37 | 60 |
|
61 |
/*! |
|
62 |
Used to get drive type for convenience. |
|
63 |
*/ |
|
64 |
enum DriveType |
|
65 |
{ |
|
66 |
EDriveTypeNotExist = -1, // specified drive is not existed in device |
|
67 |
EDriveTypeRom, |
|
68 |
EDriveTypeRam, |
|
69 |
EDriveTypePhoneMemory, |
|
70 |
EDriveTypeMassStorage, |
|
71 |
EDriveTypeMemoryCard, |
|
72 |
EDriveTypeUsbMemory, |
|
73 |
EDriveTypeRemote, |
|
74 |
}; |
|
75 |
||
16
ada7962b4308
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
14
diff
changeset
|
76 |
Q_DECLARE_FLAGS( DriveState, driveState ) |
ada7962b4308
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
14
diff
changeset
|
77 |
|
ada7962b4308
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
14
diff
changeset
|
78 |
FmDriverInfo( quint64 s, quint64 f, const QString &n, const QString &vN, const quint32 driveState ) : |
ada7962b4308
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
14
diff
changeset
|
79 |
mSize( s ), mFreeSize( f ), mName( n ), mVolumeName( vN ), mDriveState( driveState ) {} |
ada7962b4308
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
14
diff
changeset
|
80 |
FmDriverInfo( const FmDriverInfo &other ) |
ada7962b4308
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
14
diff
changeset
|
81 |
{ |
ada7962b4308
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
14
diff
changeset
|
82 |
*this = other; |
ada7962b4308
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
14
diff
changeset
|
83 |
} |
ada7962b4308
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
14
diff
changeset
|
84 |
|
ada7962b4308
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
14
diff
changeset
|
85 |
FmDriverInfo &operator= ( const FmDriverInfo &rhs ) |
ada7962b4308
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
14
diff
changeset
|
86 |
{ |
ada7962b4308
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
14
diff
changeset
|
87 |
this->mSize = rhs.mSize; |
ada7962b4308
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
14
diff
changeset
|
88 |
this->mFreeSize = rhs.mFreeSize; |
ada7962b4308
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
14
diff
changeset
|
89 |
this->mName = rhs.mName; |
ada7962b4308
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
14
diff
changeset
|
90 |
this->mVolumeName = rhs.mVolumeName; |
ada7962b4308
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
14
diff
changeset
|
91 |
this->mDriveState = rhs.mDriveState; |
ada7962b4308
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
14
diff
changeset
|
92 |
return *this; |
ada7962b4308
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
14
diff
changeset
|
93 |
} |
37 | 94 |
|
95 |
/*! |
|
96 |
Total size for drive |
|
97 |
*/ |
|
16
ada7962b4308
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
14
diff
changeset
|
98 |
quint64 size() const { return mSize; } |
37 | 99 |
|
100 |
/*! |
|
101 |
Free size for drive |
|
102 |
*/ |
|
16
ada7962b4308
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
14
diff
changeset
|
103 |
quint64 freeSize() const { return mFreeSize; } |
37 | 104 |
|
105 |
/*! |
|
106 |
path for drive |
|
107 |
*/ |
|
16
ada7962b4308
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
14
diff
changeset
|
108 |
QString name() const { return mName; } |
37 | 109 |
|
110 |
/*! |
|
111 |
volume for drive |
|
112 |
*/ |
|
16
ada7962b4308
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
14
diff
changeset
|
113 |
QString volumeName() const { return mVolumeName; } |
37 | 114 |
|
115 |
/*! |
|
116 |
status for drive |
|
117 |
*/ |
|
16
ada7962b4308
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
14
diff
changeset
|
118 |
DriveState driveState() const { return mDriveState; } |
ada7962b4308
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
14
diff
changeset
|
119 |
|
37 | 120 |
/*! |
121 |
drive type |
|
122 |
*/ |
|
123 |
DriveType driveType(); |
|
124 |
||
14
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
125 |
private: |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
126 |
quint64 mSize; |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
127 |
quint64 mFreeSize; |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
128 |
QString mName; |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
129 |
QString mVolumeName; |
16
ada7962b4308
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
14
diff
changeset
|
130 |
DriveState mDriveState; |
37 | 131 |
DriveType mDriveType; |
14
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
132 |
}; |
16
ada7962b4308
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
14
diff
changeset
|
133 |
Q_DECLARE_OPERATORS_FOR_FLAGS( FmDriverInfo::DriveState ) |
14
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
134 |
|
37 | 135 |
/*! |
136 |
\class FmUtils |
|
137 |
\brief The class FmUtils provide util functions |
|
138 |
This class is implemented by three parts: |
|
139 |
fmutils.cpp for Qt Based functions |
|
140 |
fmutils_s60.cpp is symbian implement version for platform based functions |
|
141 |
fmutils_win.cpp is win32 implement version for platform based functions( a simple wrapper ) |
|
142 |
*/ |
|
14
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
143 |
class FmUtils |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
144 |
{ |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
145 |
public: |
37 | 146 |
////////////////////////////////////////////////////////////////// |
147 |
// <QtBasedFunctions> |
|
148 |
static QString getDriveNameFromPath( const QString &path ); |
|
149 |
static QString getDriveLetterFromPath( const QString &path ); |
|
150 |
static QString formatStorageSize( quint64 size ); |
|
151 |
static bool isDrive( const QString &path ); |
|
46 | 152 |
static QString formatPath( const QString &path, const QChar &splitter = QDir::separator() ); |
153 |
static QString fillPathWithSplash( const QString &filePath, const QChar &splitter = QDir::separator() ); |
|
37 | 154 |
static QString removePathSplash( const QString &filePath ); |
155 |
static void getDriveList( QStringList &driveList, bool isHideUnAvailableDrive ); |
|
156 |
static QString fillDriveVolume( QString driveName, bool isFillWithDefaultVolume ); |
|
157 |
static QString getDefaultVolumeName( const QString &driveName ); |
|
158 |
static QString getVolumeNameWithDefaultNameIfNull( const QString &diskName, bool &defaultName ); |
|
159 |
static bool isPathEqual( const QString &pathFst, const QString &pathLast ); |
|
160 |
static bool checkFolderFileName( const QString& name ); |
|
161 |
static bool checkNewFolderOrFile( const QString& fileName, const QString &path, QString &errString ); |
|
162 |
static bool isSubLevelPath( const QString &src, const QString &dest ); |
|
46 | 163 |
static bool isSystemFolder( const QString &path ); |
37 | 164 |
// </QtBasedFunctions> |
165 |
////////////////////////////////////////////////////////////////// |
|
166 |
||
167 |
||
168 |
////////////////////////////////////////////////////////////////// |
|
169 |
// <platformBasedFunctions> |
|
14
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
170 |
static FmDriverInfo queryDriverInfo( const QString &driverName ); |
37 | 171 |
|
172 |
// password related functions |
|
173 |
static int removeDrivePwd( const QString &driverName, const QString &Pwd ); |
|
174 |
static int unlockDrive( const QString &driverName, const QString &Pwd ); |
|
175 |
static int checkDrivePwd( const QString &driverName, const QString &pwd); |
|
176 |
static int setDrivePwd( const QString &driverName, const QString &oldPwd, const QString &newPwd); |
|
177 |
static void emptyPwd( QString &pwd ); |
|
178 |
||
179 |
// external drive related functions |
|
180 |
static int renameDrive( const QString &driverName, const QString &newVolumeName); |
|
181 |
static int ejectDrive( const QString &driverName ); |
|
182 |
||
183 |
// drive security related functions |
|
184 |
static bool checkDriveAccessFilter( const QString &driveName ); |
|
185 |
static QString checkDriveToFolderFilter( const QString &path ); |
|
186 |
static QString checkFolderToDriveFilter( const QString &path ); |
|
187 |
static int isPathAccessabel( const QString &path ); |
|
188 |
static bool isDriveAvailable( const QString &path ); |
|
189 |
||
190 |
// system default folder related functions |
|
191 |
static bool isDefaultFolder( const QString &folderPath ); |
|
192 |
static void createDefaultFolders( const QString &driverName ); |
|
193 |
static QString localize( const QString &path ); |
|
194 |
||
195 |
// copy move related functions |
|
196 |
static int setFileAttributes( const QString &srcFile, const QString &desFile ); |
|
197 |
static bool hasEnoughSpace( const QString &targetDrive, qint64 size ); |
|
198 |
static int moveInsideDrive( const QString &source, const QString &target ); |
|
199 |
||
200 |
// other fucntions |
|
201 |
static int launchFile( const QString &filePath ); |
|
202 |
static QString getBurConfigPath( QString appPath ); |
|
203 |
static QString getFileType( const QString &filePath ); |
|
204 |
static bool isDriveC( const QString &driverName ); |
|
205 |
static int getMaxFileNameLength(); |
|
206 |
static bool checkMaxPathLength( const QString& path ); |
|
46 | 207 |
static void setSystem( bool isSystem ); |
208 |
static QString numberToDriveName( int drive ); |
|
37 | 209 |
// </platformBasedFunctions> |
210 |
////////////////////////////////////////////////////////////////// |
|
14
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
211 |
}; |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
212 |
|
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
213 |
#endif |
1957042d8c7e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
214 |