|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * Zhiqiang Yang <zhiqiang.yang@nokia.com> |
|
14 * |
|
15 * Description: |
|
16 * The header file of the file manager utilities |
|
17 */ |
|
18 |
|
19 #ifndef FMUTILS_H |
|
20 #define FMUTILS_H |
|
21 |
|
22 #include "fmcommon.h" |
|
23 |
|
24 #include <QString> |
|
25 |
|
26 class FmDriverInfo |
|
27 { |
|
28 public: |
|
29 FmDriverInfo( quint64 s, quint64 f, const QString &n, const QString &vN ) : mSize( s ), mFreeSize( f ), mName( n ), mVolumeName( vN ) {} |
|
30 FmDriverInfo( const FmDriverInfo &other ) |
|
31 { |
|
32 *this = other; |
|
33 } |
|
34 |
|
35 FmDriverInfo &operator= ( const FmDriverInfo &rhs ) |
|
36 { |
|
37 this->mSize = rhs.mSize; |
|
38 this->mFreeSize = rhs.mFreeSize; |
|
39 this->mName = rhs.mName; |
|
40 this->mVolumeName = rhs.mVolumeName; |
|
41 return *this; |
|
42 } |
|
43 |
|
44 quint64 size() const { return mSize; } |
|
45 quint64 freeSize() const { return mFreeSize; } |
|
46 QString name() const { return mName; } |
|
47 QString volumeName() const { return mVolumeName; } |
|
48 |
|
49 enum driveState |
|
50 { |
|
51 EDriveNotPresent = 0x1, |
|
52 EDriveLocked = 0x2, |
|
53 EDriveCorrupted = 0x4, |
|
54 EDriveWriteProtected = 0x8, |
|
55 EDriveRemovable = 0x10, |
|
56 EDriveRom = 0x20, |
|
57 EDriveFormattable = 0x40, |
|
58 EDriveFormatted = 0x80, |
|
59 EDriveLockable = 0x100, |
|
60 EDrivePasswordProtected = 0x200, |
|
61 EDriveBackupped = 0x400, |
|
62 EDriveConnected = 0x800, |
|
63 EDriveEjectable = 0x1000, |
|
64 EDriveInUse = 0x2000, |
|
65 EDriveMassStorage = 0x4000, |
|
66 EDriveRam = 0x8000 |
|
67 }; |
|
68 private: |
|
69 quint64 mSize; |
|
70 quint64 mFreeSize; |
|
71 QString mName; |
|
72 QString mVolumeName; |
|
73 }; |
|
74 |
|
75 class FmUtils |
|
76 { |
|
77 public: |
|
78 static QString getDriveNameFromPath( const QString &path ); |
|
79 static FmDriverInfo queryDriverInfo( const QString &driverName ); |
|
80 static QString formatStorageSize( quint64 size ); |
|
81 static quint32 getDriverState( const QString &driverName ); |
|
82 static int removeDrivePwd( const QString &driverName, const QString &Pwd ); |
|
83 static int unlockDrive( const QString &driverName, const QString &Pwd ); |
|
84 static int setDrivePwd( const QString &driverName, const QString &oldPwd, const QString &newPwd); |
|
85 static void emptyPwd( QString &pwd ); |
|
86 static int renameDrive( const QString &driverName, const QString &newVolumeName); |
|
87 static int ejectDrive( const QString &driverName ); |
|
88 static int formatDrive( const QString &driverName ); |
|
89 static QString getFileType( const QString &filePath ); |
|
90 static quint64 getDriveDetailsResult( const QString &folderPath, const QString &extension ); |
|
91 static bool isDriveC( const QString &driverName ); |
|
92 static void createDefaultFolders( const QString &driverName ); |
|
93 static QString fillPathWithSplash( const QString &filePath ); |
|
94 static QString removePathSplash( const QString &filePath ); |
|
95 static bool checkDriveFilter( const QString &driveName ); |
|
96 static QString checkDriveToFolderFilter( const QString &path ); |
|
97 static QString checkFolderToDriveFilter( const QString &path ); |
|
98 static bool isPathAccessabel( const QString &path ); |
|
99 static bool isDriveAvailable( const QString &path ); |
|
100 |
|
101 /// fill driveList of drives can be shown in driveListView |
|
102 static void getDriveList( QStringList &driveList, bool isHideUnAvailableDrive ); |
|
103 static QString fillDriveVolume( QString driveName, bool isFillWithDefaultVolume ); |
|
104 |
|
105 static int launchFile( const QString &filePath ); |
|
106 static void sendFiles( QList<QVariant> filePathList ); |
|
107 static QString getBurConfigPath( QString appPath ); |
|
108 |
|
109 }; |
|
110 |
|
111 #endif |
|
112 |