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: |
|
33 /*! |
|
34 Used to get drive status for convenience. |
|
35 /sa DriveType is used to get drive type. |
|
36 */ |
29 enum driveState |
37 enum driveState |
30 { |
38 { |
31 EDriveNotPresent = 0x1, |
39 EDriveNotPresent = 0x1, // true when Drive have not inserted, for example, MMC Card |
32 EDriveLocked = 0x2, |
40 EDriveAvailable = 0x2, // false when drive is locked or corrupted, for example MMC Card |
33 EDriveCorrupted = 0x4, |
41 EDriveLocked = 0x4, |
34 EDriveWriteProtected = 0x8, |
42 EDriveCorrupted = 0x8, |
35 EDriveRemovable = 0x10, |
43 EDriveWriteProtected = 0x10, |
36 EDriveRom = 0x20, |
44 EDriveRemovable = 0x20, |
37 EDriveFormattable = 0x40, |
45 EDriveRom = 0x40, |
38 EDriveFormatted = 0x80, |
46 EDriveFormattable = 0x80, |
39 EDriveLockable = 0x100, |
47 EDriveFormatted = 0x100, |
40 EDrivePasswordProtected = 0x200, |
48 EDriveLockable = 0x200, |
41 EDriveBackupped = 0x400, |
49 EDrivePasswordProtected = 0x400, |
42 EDriveConnected = 0x800, |
50 EDriveBackupped = 0x800, |
43 EDriveEjectable = 0x1000, |
51 EDriveConnected = 0x1000, |
44 EDriveInUse = 0x2000, |
52 EDriveEjectable = 0x2000, |
45 EDriveMassStorage = 0x4000, |
53 EDriveInUse = 0x4000, |
46 EDriveRam = 0x8000, |
54 EDriveMassStorage = 0x8000, |
47 EDriveAvailable = 0x10000 |
55 EDriveRam = 0x10000, |
|
56 EDriveUsbMemory = 0x20000, |
|
57 EDriveRemote = 0x40000, |
48 }; |
58 }; |
|
59 |
|
60 /*! |
|
61 Used to get drive type for convenience. |
|
62 */ |
|
63 enum DriveType |
|
64 { |
|
65 EDriveTypeNotExist = -1, // specified drive is not existed in device |
|
66 EDriveTypeRom, |
|
67 EDriveTypeRam, |
|
68 EDriveTypePhoneMemory, |
|
69 EDriveTypeMassStorage, |
|
70 EDriveTypeMemoryCard, |
|
71 EDriveTypeUsbMemory, |
|
72 EDriveTypeRemote, |
|
73 }; |
|
74 |
49 Q_DECLARE_FLAGS( DriveState, driveState ) |
75 Q_DECLARE_FLAGS( DriveState, driveState ) |
50 |
76 |
51 FmDriverInfo( quint64 s, quint64 f, const QString &n, const QString &vN, const quint32 driveState ) : |
77 FmDriverInfo( quint64 s, quint64 f, const QString &n, const QString &vN, const quint32 driveState ) : |
52 mSize( s ), mFreeSize( f ), mName( n ), mVolumeName( vN ), mDriveState( driveState ) {} |
78 mSize( s ), mFreeSize( f ), mName( n ), mVolumeName( vN ), mDriveState( driveState ) {} |
53 FmDriverInfo( const FmDriverInfo &other ) |
79 FmDriverInfo( const FmDriverInfo &other ) |
62 this->mName = rhs.mName; |
88 this->mName = rhs.mName; |
63 this->mVolumeName = rhs.mVolumeName; |
89 this->mVolumeName = rhs.mVolumeName; |
64 this->mDriveState = rhs.mDriveState; |
90 this->mDriveState = rhs.mDriveState; |
65 return *this; |
91 return *this; |
66 } |
92 } |
67 |
93 |
|
94 /*! |
|
95 Total size for drive |
|
96 */ |
68 quint64 size() const { return mSize; } |
97 quint64 size() const { return mSize; } |
|
98 |
|
99 /*! |
|
100 Free size for drive |
|
101 */ |
69 quint64 freeSize() const { return mFreeSize; } |
102 quint64 freeSize() const { return mFreeSize; } |
|
103 |
|
104 /*! |
|
105 path for drive |
|
106 */ |
70 QString name() const { return mName; } |
107 QString name() const { return mName; } |
|
108 |
|
109 /*! |
|
110 volume for drive |
|
111 */ |
71 QString volumeName() const { return mVolumeName; } |
112 QString volumeName() const { return mVolumeName; } |
|
113 |
|
114 /*! |
|
115 status for drive |
|
116 */ |
72 DriveState driveState() const { return mDriveState; } |
117 DriveState driveState() const { return mDriveState; } |
|
118 |
|
119 /*! |
|
120 drive type |
|
121 */ |
|
122 DriveType driveType(); |
73 |
123 |
74 private: |
124 private: |
75 quint64 mSize; |
125 quint64 mSize; |
76 quint64 mFreeSize; |
126 quint64 mFreeSize; |
77 QString mName; |
127 QString mName; |
78 QString mVolumeName; |
128 QString mVolumeName; |
79 DriveState mDriveState; |
129 DriveState mDriveState; |
|
130 DriveType mDriveType; |
80 }; |
131 }; |
81 Q_DECLARE_OPERATORS_FOR_FLAGS( FmDriverInfo::DriveState ) |
132 Q_DECLARE_OPERATORS_FOR_FLAGS( FmDriverInfo::DriveState ) |
82 |
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 */ |
83 class FmUtils |
142 class FmUtils |
84 { |
143 { |
85 public: |
144 public: |
86 static QString getDriveNameFromPath( const QString &path ); |
145 ////////////////////////////////////////////////////////////////// |
87 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> |
88 static FmDriverInfo queryDriverInfo( const QString &driverName ); |
168 static FmDriverInfo queryDriverInfo( const QString &driverName ); |
89 static QString formatStorageSize( quint64 size ); |
169 |
90 //static quint32 getDriverState( const QString &driverName ); |
170 // password related functions |
91 static int removeDrivePwd( const QString &driverName, const QString &Pwd ); |
171 static int removeDrivePwd( const QString &driverName, const QString &Pwd ); |
92 static int unlockDrive( const QString &driverName, const QString &Pwd ); |
172 static int unlockDrive( const QString &driverName, const QString &Pwd ); |
93 static int checkDrivePwd( const QString &driverName, const QString &pwd); |
173 static int checkDrivePwd( const QString &driverName, const QString &pwd); |
94 static int setDrivePwd( const QString &driverName, const QString &oldPwd, const QString &newPwd); |
174 static int setDrivePwd( const QString &driverName, const QString &oldPwd, const QString &newPwd); |
95 static void emptyPwd( QString &pwd ); |
175 static void emptyPwd( QString &pwd ); |
96 static int renameDrive( const QString &driverName, const QString &newVolumeName); |
176 |
97 static void ejectDrive( const QString &driverName ); |
177 // external drive related functions |
98 static QString getFileType( const QString &filePath ); |
178 static int renameDrive( const QString &driverName, const QString &newVolumeName); |
99 static quint64 getDriveDetailsResult( const QString &folderPath, const QString &extension ); |
179 static int ejectDrive( const QString &driverName ); |
100 static bool isDriveC( const QString &driverName ); |
180 |
101 static bool isDrive( const QString &path ); |
181 // drive security related functions |
102 static void createDefaultFolders( const QString &driverName ); |
182 static bool checkDriveAccessFilter( const QString &driveName ); |
103 static QString fillPathWithSplash( const QString &filePath ); |
183 static QString checkDriveToFolderFilter( const QString &path ); |
104 static QString removePathSplash( const QString &filePath ); |
184 static QString checkFolderToDriveFilter( const QString &path ); |
105 static QString formatPath( const QString &path ); |
185 static int isPathAccessabel( const QString &path ); |
106 static bool checkDriveFilter( const QString &driveName ); |
186 static bool isDriveAvailable( const QString &path ); |
107 static QString checkDriveToFolderFilter( const QString &path ); |
187 |
108 static QString checkFolderToDriveFilter( const QString &path ); |
188 // system default folder related functions |
109 static bool isPathAccessabel( const QString &path ); |
189 static bool isDefaultFolder( const QString &folderPath ); |
110 static bool isDriveAvailable( const QString &path ); |
190 static void createDefaultFolders( const QString &driverName ); |
111 static bool isPathEqual( const QString &pathFst, const QString &pathLast ); |
191 static QString localize( const QString &path ); |
112 |
192 |
113 /// fill driveList of drives can be shown in driveListView |
193 // copy move related functions |
114 static void getDriveList( QStringList &driveList, bool isHideUnAvailableDrive ); |
194 static int setFileAttributes( const QString &srcFile, const QString &desFile ); |
115 static QString fillDriveVolume( QString driveName, bool isFillWithDefaultVolume ); |
195 static bool hasEnoughSpace( const QString &targetDrive, qint64 size ); |
116 |
196 static int moveInsideDrive( const QString &source, const QString &target ); |
117 static int launchFile( const QString &filePath ); |
197 |
118 static void sendFiles( QStringList &filePathList ); |
198 // other fucntions |
119 static QString getBurConfigPath( QString appPath ); |
199 static int launchFile( const QString &filePath ); |
120 static bool isDefaultFolder( const QString &folderPath ); |
200 static void sendFiles( QStringList &filePathList ); |
121 static QString Localize( const QString &path ); |
201 static QString getBurConfigPath( QString appPath ); |
122 |
202 static QString getFileType( const QString &filePath ); |
|
203 static bool isDriveC( const QString &driverName ); |
|
204 static int getMaxFileNameLength(); |
|
205 static bool checkMaxPathLength( const QString& path ); |
|
206 // </platformBasedFunctions> |
|
207 ////////////////////////////////////////////////////////////////// |
123 }; |
208 }; |
124 |
209 |
125 #endif |
210 #endif |
126 |
211 |