sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
/**
|
sl@0
|
20 |
@test
|
sl@0
|
21 |
@internalComponent
|
sl@0
|
22 |
|
sl@0
|
23 |
This contains CT_FsData
|
sl@0
|
24 |
*/
|
sl@0
|
25 |
|
sl@0
|
26 |
// User includes
|
sl@0
|
27 |
#include "T_FsData.h"
|
sl@0
|
28 |
#include "T_VolumeInfoData.h"
|
sl@0
|
29 |
#include "FileserverUtil.h"
|
sl@0
|
30 |
|
sl@0
|
31 |
/*@{*/
|
sl@0
|
32 |
///Constants
|
sl@0
|
33 |
|
sl@0
|
34 |
_LIT(KPromptProcess, "t_prompt.exe");
|
sl@0
|
35 |
|
sl@0
|
36 |
|
sl@0
|
37 |
/// Enumerations
|
sl@0
|
38 |
_LIT(KMediaNotPresent, "EMediaNotPresent");
|
sl@0
|
39 |
_LIT(KMediaUnknown, "EMediaUnknown");
|
sl@0
|
40 |
_LIT(KMediaFloppy, "EMediaFloppy");
|
sl@0
|
41 |
_LIT(KMediaHardDisk, "EMediaHardDisk");
|
sl@0
|
42 |
_LIT(KMediaCdRom, "EMediaCdRom");
|
sl@0
|
43 |
_LIT(KMediaRam, "EMediaRam");
|
sl@0
|
44 |
_LIT(KMediaFlash, "EMediaFlash");
|
sl@0
|
45 |
_LIT(KMediaRom, "EMediaRom");
|
sl@0
|
46 |
_LIT(KMediaRemote, "EMediaRemote");
|
sl@0
|
47 |
_LIT(KMediaNANDFlash, "EMediaNANDFlash");
|
sl@0
|
48 |
|
sl@0
|
49 |
_LIT(KBatNotSupported, "EBatNotSupported");
|
sl@0
|
50 |
_LIT(KBatLow, "EBatLow");
|
sl@0
|
51 |
_LIT(KBatGood, "EBatGood");
|
sl@0
|
52 |
|
sl@0
|
53 |
_LIT(KDriveAttLocalStr, "KDriveAttLocal");
|
sl@0
|
54 |
_LIT(KDriveAttRomStr, "KDriveAttRom");
|
sl@0
|
55 |
_LIT(KDriveAttRedirectedStr, "KDriveAttRedirected");
|
sl@0
|
56 |
_LIT(KDriveAttSubstedStr, "KDriveAttSubsted");
|
sl@0
|
57 |
_LIT(KDriveAttInternalStr, "KDriveAttInternal");
|
sl@0
|
58 |
_LIT(KDriveAttRemovableStr, "KDriveAttRemovable");
|
sl@0
|
59 |
|
sl@0
|
60 |
_LIT(KMediaAttVariableSizeStr, "KMediaAttVariableSize");
|
sl@0
|
61 |
_LIT(KMediaAttDualDensityStr, "KMediaAttDualDensity");
|
sl@0
|
62 |
_LIT(KMediaAttFormattableStr, "KMediaAttFormattable");
|
sl@0
|
63 |
_LIT(KMediaAttWriteProtectedStr, "KMediaAttWriteProtected");
|
sl@0
|
64 |
_LIT(KMediaAttLockableStr, "KMediaAttLockable");
|
sl@0
|
65 |
_LIT(KMediaAttLockedStr, "KMediaAttLocked");
|
sl@0
|
66 |
|
sl@0
|
67 |
|
sl@0
|
68 |
/// Parameters
|
sl@0
|
69 |
_LIT(KStore, "store");
|
sl@0
|
70 |
_LIT(KMediaType, "media_type");
|
sl@0
|
71 |
_LIT(KDriveAtt, "drive_att");
|
sl@0
|
72 |
_LIT(KMediaAtt, "media_att");
|
sl@0
|
73 |
_LIT(KDriveIndex, "drive_index");
|
sl@0
|
74 |
_LIT(KDriveChar, "drive_char");
|
sl@0
|
75 |
_LIT(KArraySize, "array_size");
|
sl@0
|
76 |
_LIT(KArrayIndex, "array_index_");
|
sl@0
|
77 |
_LIT(KVolumeLabel, "volume_label");
|
sl@0
|
78 |
_LIT(KSubstPath, "subst_path");
|
sl@0
|
79 |
_LIT(KDriveName, "drive_name");
|
sl@0
|
80 |
_LIT(KDriveOldPassword, "drive_old_password");
|
sl@0
|
81 |
_LIT(KDriveNewPassword, "drive_new_password");
|
sl@0
|
82 |
_LIT(KBytesToReserve, "bytes_to_reserve");
|
sl@0
|
83 |
_LIT(KDriveIsValid, "drive_is_valid");
|
sl@0
|
84 |
_LIT(KDrivePath, "drive_path");
|
sl@0
|
85 |
_LIT(KDrive, "drive");
|
sl@0
|
86 |
_LIT(KBatteryState, "battery_state");
|
sl@0
|
87 |
_LIT(KSaveInInstance, "save_in_instance");
|
sl@0
|
88 |
_LIT(KVolumeObject, "store_volume");
|
sl@0
|
89 |
|
sl@0
|
90 |
|
sl@0
|
91 |
/// Commands
|
sl@0
|
92 |
_LIT(KCmdDriveList, "DriveList");
|
sl@0
|
93 |
_LIT(KCmdDrive, "Drive");
|
sl@0
|
94 |
_LIT(KCmdVolume, "Volume");
|
sl@0
|
95 |
_LIT(KCmdSetVolumeLabel, "SetVolumeLabel");
|
sl@0
|
96 |
_LIT(KCmdSubst, "Subst");
|
sl@0
|
97 |
_LIT(KCmdSetSubst, "SetSubst");
|
sl@0
|
98 |
_LIT(KCmdGetMediaSerialNumber, "GetMediaSerialNumber");
|
sl@0
|
99 |
_LIT(KCmdIsValidDrive, "IsValidDrive");
|
sl@0
|
100 |
_LIT(KCmdCharToDrive, "CharToDrive");
|
sl@0
|
101 |
_LIT(KCmdDriveToChar, "DriveToChar");
|
sl@0
|
102 |
_LIT(KCmdCheckDisk, "CheckDisk");
|
sl@0
|
103 |
_LIT(KCmdScanDrive, "ScanDrive");
|
sl@0
|
104 |
_LIT(KCmdGetDriveName, "GetDriveName");
|
sl@0
|
105 |
_LIT(KCmdSetDriveName, "SetDriveName");
|
sl@0
|
106 |
_LIT(KCmdLockDrive, "LockDrive");
|
sl@0
|
107 |
_LIT(KCmdUnlockDrive, "UnlockDrive");
|
sl@0
|
108 |
_LIT(KCmdClearPassword, "ClearPassword");
|
sl@0
|
109 |
_LIT(KCmdErasePassword, "ErasePassword");
|
sl@0
|
110 |
_LIT(KCmdReserveDriveSpace, "ReserveDriveSpace");
|
sl@0
|
111 |
_LIT(KCmdGetReserveAccess, "GetReserveAccess");
|
sl@0
|
112 |
_LIT(KCmdReleaseReserveAccess, "ReleaseReserveAccess");
|
sl@0
|
113 |
_LIT(KCmdPrompt, "prompt");
|
sl@0
|
114 |
_LIT(KCmdGetSystemDrive, "GetSystemDrive");
|
sl@0
|
115 |
_LIT(KCmdSetSystemDrive, "SetSystemDrive");
|
sl@0
|
116 |
_LIT(KCmdGetSystemDriveChar, "GetSystemDriveChar");
|
sl@0
|
117 |
_LIT(KCmdVolumeIOParam, "VolumeIOParam");
|
sl@0
|
118 |
|
sl@0
|
119 |
/*@}*/
|
sl@0
|
120 |
|
sl@0
|
121 |
/**
|
sl@0
|
122 |
* Process a drives related command read from the ini file
|
sl@0
|
123 |
*
|
sl@0
|
124 |
* @param aCommand the command to process
|
sl@0
|
125 |
* @param aSection the entry in the ini file requiring the command to be processed
|
sl@0
|
126 |
*
|
sl@0
|
127 |
* @return ETrue if the command is processed
|
sl@0
|
128 |
*/
|
sl@0
|
129 |
TBool CT_FsData::DoCommandDrivesL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/)
|
sl@0
|
130 |
{
|
sl@0
|
131 |
TBool retVal = ETrue;
|
sl@0
|
132 |
//Parsing the aCommand to choose which function has to be executed.
|
sl@0
|
133 |
|
sl@0
|
134 |
if (aCommand == KCmdDriveList)
|
sl@0
|
135 |
{
|
sl@0
|
136 |
DoCmdDriveList(aSection);
|
sl@0
|
137 |
}
|
sl@0
|
138 |
else if (aCommand == KCmdDrive)
|
sl@0
|
139 |
{
|
sl@0
|
140 |
DoCmdDriveL(aSection);
|
sl@0
|
141 |
}
|
sl@0
|
142 |
else if (aCommand == KCmdVolume)
|
sl@0
|
143 |
{
|
sl@0
|
144 |
DoCmdVolumeL(aSection);
|
sl@0
|
145 |
}
|
sl@0
|
146 |
else if (aCommand == KCmdSetVolumeLabel)
|
sl@0
|
147 |
{
|
sl@0
|
148 |
DoCmdSetVolumeLabel(aSection);
|
sl@0
|
149 |
}
|
sl@0
|
150 |
else if (aCommand == KCmdSubst)
|
sl@0
|
151 |
{
|
sl@0
|
152 |
DoCmdSubst(aSection);
|
sl@0
|
153 |
}
|
sl@0
|
154 |
else if (aCommand == KCmdSetSubst)
|
sl@0
|
155 |
{
|
sl@0
|
156 |
DoCmdSetSubst(aSection);
|
sl@0
|
157 |
}
|
sl@0
|
158 |
else if (aCommand == KCmdGetMediaSerialNumber)
|
sl@0
|
159 |
{
|
sl@0
|
160 |
DoCmdGetMediaSerialNumber(aSection);
|
sl@0
|
161 |
}
|
sl@0
|
162 |
else if (aCommand == KCmdIsValidDrive)
|
sl@0
|
163 |
{
|
sl@0
|
164 |
DoCmdIsValidDrive(aSection);
|
sl@0
|
165 |
}
|
sl@0
|
166 |
else if (aCommand == KCmdCharToDrive)
|
sl@0
|
167 |
{
|
sl@0
|
168 |
DoCmdCharToDrive(aSection);
|
sl@0
|
169 |
}
|
sl@0
|
170 |
else if (aCommand == KCmdDriveToChar)
|
sl@0
|
171 |
{
|
sl@0
|
172 |
DoCmdDriveToChar(aSection);
|
sl@0
|
173 |
}
|
sl@0
|
174 |
else if (aCommand == KCmdCheckDisk)
|
sl@0
|
175 |
{
|
sl@0
|
176 |
DoCmdCheckDisk(aSection);
|
sl@0
|
177 |
}
|
sl@0
|
178 |
else if (aCommand == KCmdScanDrive)
|
sl@0
|
179 |
{
|
sl@0
|
180 |
DoCmdScanDrive(aSection);
|
sl@0
|
181 |
}
|
sl@0
|
182 |
else if (aCommand == KCmdGetDriveName)
|
sl@0
|
183 |
{
|
sl@0
|
184 |
DoCmdGetDriveName(aSection);
|
sl@0
|
185 |
}
|
sl@0
|
186 |
else if (aCommand == KCmdSetDriveName)
|
sl@0
|
187 |
{
|
sl@0
|
188 |
DoCmdSetDriveName(aSection);
|
sl@0
|
189 |
}
|
sl@0
|
190 |
else if (aCommand == KCmdLockDrive)
|
sl@0
|
191 |
{
|
sl@0
|
192 |
DoCmdLockDrive(aSection);
|
sl@0
|
193 |
}
|
sl@0
|
194 |
else if (aCommand == KCmdUnlockDrive)
|
sl@0
|
195 |
{
|
sl@0
|
196 |
DoCmdUnlockDrive(aSection);
|
sl@0
|
197 |
}
|
sl@0
|
198 |
else if (aCommand == KCmdClearPassword)
|
sl@0
|
199 |
{
|
sl@0
|
200 |
DoCmdClearPassword(aSection);
|
sl@0
|
201 |
}
|
sl@0
|
202 |
else if (aCommand == KCmdErasePassword)
|
sl@0
|
203 |
{
|
sl@0
|
204 |
DoCmdErasePassword(aSection);
|
sl@0
|
205 |
}
|
sl@0
|
206 |
else if (aCommand == KCmdReserveDriveSpace)
|
sl@0
|
207 |
{
|
sl@0
|
208 |
DoCmdReserveDriveSpace(aSection);
|
sl@0
|
209 |
}
|
sl@0
|
210 |
else if (aCommand == KCmdGetReserveAccess)
|
sl@0
|
211 |
{
|
sl@0
|
212 |
DoCmdGetReserveAccess(aSection);
|
sl@0
|
213 |
}
|
sl@0
|
214 |
else if (aCommand == KCmdReleaseReserveAccess)
|
sl@0
|
215 |
{
|
sl@0
|
216 |
DoCmdReleaseReserveAccess(aSection);
|
sl@0
|
217 |
}
|
sl@0
|
218 |
else if (aCommand == KCmdPrompt)
|
sl@0
|
219 |
{
|
sl@0
|
220 |
DoCmdPromptL(aSection);
|
sl@0
|
221 |
}
|
sl@0
|
222 |
else if (aCommand == KCmdGetSystemDrive)
|
sl@0
|
223 |
{
|
sl@0
|
224 |
DoCmdGetSystemDrive(aSection);
|
sl@0
|
225 |
}
|
sl@0
|
226 |
else if (aCommand == KCmdGetSystemDriveChar)
|
sl@0
|
227 |
{
|
sl@0
|
228 |
DoCmdGetSystemDriveChar(aSection);
|
sl@0
|
229 |
}
|
sl@0
|
230 |
else if (aCommand == KCmdSetSystemDrive)
|
sl@0
|
231 |
{
|
sl@0
|
232 |
DoCmdSetSystemDrive(aSection);
|
sl@0
|
233 |
}
|
sl@0
|
234 |
else if (aCommand == KCmdVolumeIOParam)
|
sl@0
|
235 |
{
|
sl@0
|
236 |
DoCmdVolumeIOParam(aSection);
|
sl@0
|
237 |
}
|
sl@0
|
238 |
else
|
sl@0
|
239 |
{
|
sl@0
|
240 |
retVal = EFalse;
|
sl@0
|
241 |
}
|
sl@0
|
242 |
|
sl@0
|
243 |
return retVal;
|
sl@0
|
244 |
}
|
sl@0
|
245 |
|
sl@0
|
246 |
|
sl@0
|
247 |
TBool CT_FsData::GetMediaTypeFromConfig(const TDesC& aSection, TMediaType& aMediaType)
|
sl@0
|
248 |
{
|
sl@0
|
249 |
// Read media type from INI file
|
sl@0
|
250 |
TPtrC mediaTypeStr;
|
sl@0
|
251 |
TBool ret = GET_OPTIONAL_STRING_PARAMETER(KMediaType(), aSection, mediaTypeStr);
|
sl@0
|
252 |
|
sl@0
|
253 |
if (ret)
|
sl@0
|
254 |
{
|
sl@0
|
255 |
if (mediaTypeStr == KMediaNotPresent)
|
sl@0
|
256 |
{
|
sl@0
|
257 |
aMediaType = EMediaNotPresent;
|
sl@0
|
258 |
}
|
sl@0
|
259 |
else if (mediaTypeStr == KMediaUnknown)
|
sl@0
|
260 |
{
|
sl@0
|
261 |
aMediaType = EMediaUnknown;
|
sl@0
|
262 |
}
|
sl@0
|
263 |
else if (mediaTypeStr == KMediaFloppy)
|
sl@0
|
264 |
{
|
sl@0
|
265 |
aMediaType = EMediaFloppy;
|
sl@0
|
266 |
}
|
sl@0
|
267 |
else if (mediaTypeStr == KMediaHardDisk)
|
sl@0
|
268 |
{
|
sl@0
|
269 |
aMediaType = EMediaHardDisk;
|
sl@0
|
270 |
}
|
sl@0
|
271 |
else if (mediaTypeStr == KMediaCdRom)
|
sl@0
|
272 |
{
|
sl@0
|
273 |
aMediaType = EMediaCdRom;
|
sl@0
|
274 |
}
|
sl@0
|
275 |
else if (mediaTypeStr == KMediaRam)
|
sl@0
|
276 |
{
|
sl@0
|
277 |
aMediaType = EMediaRam;
|
sl@0
|
278 |
}
|
sl@0
|
279 |
else if (mediaTypeStr == KMediaFlash)
|
sl@0
|
280 |
{
|
sl@0
|
281 |
aMediaType = EMediaFlash;
|
sl@0
|
282 |
}
|
sl@0
|
283 |
else if (mediaTypeStr == KMediaRom)
|
sl@0
|
284 |
{
|
sl@0
|
285 |
aMediaType = EMediaRom;
|
sl@0
|
286 |
}
|
sl@0
|
287 |
else if (mediaTypeStr == KMediaRemote)
|
sl@0
|
288 |
{
|
sl@0
|
289 |
aMediaType = EMediaRemote;
|
sl@0
|
290 |
}
|
sl@0
|
291 |
else if (mediaTypeStr == KMediaNANDFlash)
|
sl@0
|
292 |
{
|
sl@0
|
293 |
aMediaType = EMediaNANDFlash;
|
sl@0
|
294 |
}
|
sl@0
|
295 |
else
|
sl@0
|
296 |
{
|
sl@0
|
297 |
TInt mediaType = 0;
|
sl@0
|
298 |
ret = GET_MANDATORY_INT_PARAMETER(KMediaType, aSection, mediaType);
|
sl@0
|
299 |
if (ret)
|
sl@0
|
300 |
{
|
sl@0
|
301 |
aMediaType = (TMediaType) mediaType;
|
sl@0
|
302 |
}
|
sl@0
|
303 |
}
|
sl@0
|
304 |
}
|
sl@0
|
305 |
return ret;
|
sl@0
|
306 |
}
|
sl@0
|
307 |
|
sl@0
|
308 |
TBool CT_FsData::ConvertToDriveAtts(const TDesC& aDriveAttStr, TUint& aDriveAtt)
|
sl@0
|
309 |
{
|
sl@0
|
310 |
TBool ret = ETrue;
|
sl@0
|
311 |
if ( aDriveAttStr==KDriveAttLocalStr )
|
sl@0
|
312 |
{
|
sl@0
|
313 |
aDriveAtt=KDriveAttLocal;
|
sl@0
|
314 |
}
|
sl@0
|
315 |
else if ( aDriveAttStr==KDriveAttRomStr )
|
sl@0
|
316 |
{
|
sl@0
|
317 |
aDriveAtt=KDriveAttRom;
|
sl@0
|
318 |
}
|
sl@0
|
319 |
else if ( aDriveAttStr==KDriveAttRedirectedStr )
|
sl@0
|
320 |
{
|
sl@0
|
321 |
aDriveAtt=KDriveAttRedirected;
|
sl@0
|
322 |
}
|
sl@0
|
323 |
else if ( aDriveAttStr==KDriveAttSubstedStr )
|
sl@0
|
324 |
{
|
sl@0
|
325 |
aDriveAtt=KDriveAttSubsted;
|
sl@0
|
326 |
}
|
sl@0
|
327 |
else if ( aDriveAttStr==KDriveAttInternalStr )
|
sl@0
|
328 |
{
|
sl@0
|
329 |
aDriveAtt=KDriveAttInternal;
|
sl@0
|
330 |
}
|
sl@0
|
331 |
else if ( aDriveAttStr==KDriveAttRemovableStr )
|
sl@0
|
332 |
{
|
sl@0
|
333 |
aDriveAtt=KDriveAttRemovable;
|
sl@0
|
334 |
}
|
sl@0
|
335 |
else
|
sl@0
|
336 |
{
|
sl@0
|
337 |
TInt location = aDriveAttStr.Match(_L("*|*"));
|
sl@0
|
338 |
if( location!=KErrNotFound )
|
sl@0
|
339 |
{
|
sl@0
|
340 |
//Converting Left part of the data
|
sl@0
|
341 |
TPtrC tempStr = aDriveAttStr.Left(location);
|
sl@0
|
342 |
ret=ConvertToDriveAtts(tempStr, aDriveAtt);
|
sl@0
|
343 |
|
sl@0
|
344 |
//Converting right data can be with another "|"
|
sl@0
|
345 |
tempStr.Set(aDriveAttStr.Mid(location+1));
|
sl@0
|
346 |
|
sl@0
|
347 |
TUint driveAttTmp;
|
sl@0
|
348 |
if ( ConvertToDriveAtts(tempStr, driveAttTmp) )
|
sl@0
|
349 |
{
|
sl@0
|
350 |
aDriveAtt=aDriveAtt|driveAttTmp;
|
sl@0
|
351 |
}
|
sl@0
|
352 |
else
|
sl@0
|
353 |
{
|
sl@0
|
354 |
ret=EFalse;
|
sl@0
|
355 |
}
|
sl@0
|
356 |
}
|
sl@0
|
357 |
else
|
sl@0
|
358 |
{
|
sl@0
|
359 |
ret=EFalse;
|
sl@0
|
360 |
}
|
sl@0
|
361 |
}
|
sl@0
|
362 |
|
sl@0
|
363 |
return ret;
|
sl@0
|
364 |
}
|
sl@0
|
365 |
|
sl@0
|
366 |
void CT_FsData::DoCmdPromptL(const TDesC& /*aSection*/)
|
sl@0
|
367 |
{
|
sl@0
|
368 |
RProcess promptProcess;
|
sl@0
|
369 |
TInt err = promptProcess.Create(KPromptProcess, KNullDesC);
|
sl@0
|
370 |
|
sl@0
|
371 |
if (err == KErrNone)
|
sl@0
|
372 |
{
|
sl@0
|
373 |
CleanupClosePushL(promptProcess);
|
sl@0
|
374 |
TRequestStatus promptStatus;
|
sl@0
|
375 |
promptProcess.Rendezvous(promptStatus);
|
sl@0
|
376 |
|
sl@0
|
377 |
if (promptStatus == KRequestPending)
|
sl@0
|
378 |
{
|
sl@0
|
379 |
promptProcess.Resume();
|
sl@0
|
380 |
User::WaitForRequest(promptStatus);
|
sl@0
|
381 |
if (err != KErrNone)
|
sl@0
|
382 |
{
|
sl@0
|
383 |
ERR_PRINTF2(_L("Prompt process finished with error %d"), promptStatus.Int());
|
sl@0
|
384 |
SetBlockResult(EFail);
|
sl@0
|
385 |
}
|
sl@0
|
386 |
}
|
sl@0
|
387 |
else
|
sl@0
|
388 |
{
|
sl@0
|
389 |
promptProcess.RendezvousCancel(promptStatus);
|
sl@0
|
390 |
promptProcess.Kill(0);
|
sl@0
|
391 |
ERR_PRINTF2(_L("Executing of prompt process failed with error %d"), promptStatus.Int());
|
sl@0
|
392 |
SetBlockResult(EFail);
|
sl@0
|
393 |
}
|
sl@0
|
394 |
|
sl@0
|
395 |
CleanupStack::PopAndDestroy();
|
sl@0
|
396 |
}
|
sl@0
|
397 |
else
|
sl@0
|
398 |
{
|
sl@0
|
399 |
ERR_PRINTF2(_L("Failed to create prompt process with error %d"), err);
|
sl@0
|
400 |
SetBlockResult(EFail);
|
sl@0
|
401 |
}
|
sl@0
|
402 |
}
|
sl@0
|
403 |
|
sl@0
|
404 |
TBool CT_FsData::GetDriveAttsFromConfig(const TDesC& aSection, TUint& aDriveAtt)
|
sl@0
|
405 |
{
|
sl@0
|
406 |
aDriveAtt = 0;
|
sl@0
|
407 |
|
sl@0
|
408 |
TPtrC driveAttStr;
|
sl@0
|
409 |
TBool ret = GET_OPTIONAL_STRING_PARAMETER(KDriveAtt(), aSection, driveAttStr);
|
sl@0
|
410 |
if ( ret )
|
sl@0
|
411 |
{
|
sl@0
|
412 |
if ( !ConvertToDriveAtts(driveAttStr, aDriveAtt) )
|
sl@0
|
413 |
{
|
sl@0
|
414 |
TInt intTemp;
|
sl@0
|
415 |
ret=GET_MANDATORY_INT_PARAMETER(KDriveAtt(), aSection, intTemp);
|
sl@0
|
416 |
if ( ret )
|
sl@0
|
417 |
{
|
sl@0
|
418 |
aDriveAtt=intTemp;
|
sl@0
|
419 |
}
|
sl@0
|
420 |
}
|
sl@0
|
421 |
}
|
sl@0
|
422 |
|
sl@0
|
423 |
return ret;
|
sl@0
|
424 |
}
|
sl@0
|
425 |
|
sl@0
|
426 |
TBool CT_FsData::GetBatteryStateFromConfig(const TDesC& aSection, TBatteryState& aBatteryState)
|
sl@0
|
427 |
{
|
sl@0
|
428 |
// Read media type from INI file
|
sl@0
|
429 |
aBatteryState = EBatLow;
|
sl@0
|
430 |
|
sl@0
|
431 |
TPtrC batteryStateStr;
|
sl@0
|
432 |
TBool ret = GET_OPTIONAL_STRING_PARAMETER(KBatteryState(), aSection, batteryStateStr);
|
sl@0
|
433 |
|
sl@0
|
434 |
if (ret)
|
sl@0
|
435 |
{
|
sl@0
|
436 |
if (batteryStateStr == KBatNotSupported)
|
sl@0
|
437 |
{
|
sl@0
|
438 |
aBatteryState = EBatNotSupported;
|
sl@0
|
439 |
}
|
sl@0
|
440 |
else if (batteryStateStr == KBatGood)
|
sl@0
|
441 |
{
|
sl@0
|
442 |
aBatteryState = EBatGood;
|
sl@0
|
443 |
}
|
sl@0
|
444 |
|
sl@0
|
445 |
if (batteryStateStr == KBatLow)
|
sl@0
|
446 |
{
|
sl@0
|
447 |
aBatteryState = EBatLow;
|
sl@0
|
448 |
}
|
sl@0
|
449 |
else
|
sl@0
|
450 |
{
|
sl@0
|
451 |
aBatteryState = EBatNotSupported;
|
sl@0
|
452 |
}
|
sl@0
|
453 |
}
|
sl@0
|
454 |
|
sl@0
|
455 |
return ret;
|
sl@0
|
456 |
}
|
sl@0
|
457 |
|
sl@0
|
458 |
TBool CT_FsData::ConvertToMediaAtts(const TDesC& aMediaAttStr, TUint& aMediaAtt)
|
sl@0
|
459 |
{
|
sl@0
|
460 |
TBool ret = ETrue;
|
sl@0
|
461 |
if ( aMediaAttStr==KMediaAttVariableSizeStr )
|
sl@0
|
462 |
{
|
sl@0
|
463 |
aMediaAtt=KMediaAttVariableSize;
|
sl@0
|
464 |
}
|
sl@0
|
465 |
else if ( aMediaAttStr==KMediaAttDualDensityStr )
|
sl@0
|
466 |
{
|
sl@0
|
467 |
aMediaAtt=KMediaAttDualDensity;
|
sl@0
|
468 |
}
|
sl@0
|
469 |
else if ( aMediaAttStr==KMediaAttFormattableStr )
|
sl@0
|
470 |
{
|
sl@0
|
471 |
aMediaAtt=KMediaAttFormattable;
|
sl@0
|
472 |
}
|
sl@0
|
473 |
else if ( aMediaAttStr==KMediaAttWriteProtectedStr )
|
sl@0
|
474 |
{
|
sl@0
|
475 |
aMediaAtt=KMediaAttWriteProtected;
|
sl@0
|
476 |
}
|
sl@0
|
477 |
else if ( aMediaAttStr==KMediaAttLockableStr )
|
sl@0
|
478 |
{
|
sl@0
|
479 |
aMediaAtt=KMediaAttLockable;
|
sl@0
|
480 |
}
|
sl@0
|
481 |
else if ( aMediaAttStr==KMediaAttLockedStr )
|
sl@0
|
482 |
{
|
sl@0
|
483 |
aMediaAtt=KMediaAttLocked;
|
sl@0
|
484 |
}
|
sl@0
|
485 |
else
|
sl@0
|
486 |
{
|
sl@0
|
487 |
TInt location = aMediaAttStr.Match(_L("*|*"));
|
sl@0
|
488 |
if( location!=KErrNotFound )
|
sl@0
|
489 |
{
|
sl@0
|
490 |
//Converting Left part of the data
|
sl@0
|
491 |
TPtrC tempStr = aMediaAttStr.Left(location);
|
sl@0
|
492 |
ret=ConvertToMediaAtts(tempStr, aMediaAtt);
|
sl@0
|
493 |
|
sl@0
|
494 |
//Converting right data can be with another "|"
|
sl@0
|
495 |
tempStr.Set(aMediaAttStr.Mid(location+1));
|
sl@0
|
496 |
|
sl@0
|
497 |
TUint mediaAttTmp;
|
sl@0
|
498 |
if ( ConvertToMediaAtts(tempStr, mediaAttTmp) )
|
sl@0
|
499 |
{
|
sl@0
|
500 |
aMediaAtt=aMediaAtt|mediaAttTmp;
|
sl@0
|
501 |
}
|
sl@0
|
502 |
else
|
sl@0
|
503 |
{
|
sl@0
|
504 |
ret=EFalse;
|
sl@0
|
505 |
}
|
sl@0
|
506 |
}
|
sl@0
|
507 |
else
|
sl@0
|
508 |
{
|
sl@0
|
509 |
ret=EFalse;
|
sl@0
|
510 |
}
|
sl@0
|
511 |
}
|
sl@0
|
512 |
|
sl@0
|
513 |
return ret;
|
sl@0
|
514 |
}
|
sl@0
|
515 |
|
sl@0
|
516 |
TBool CT_FsData::GetMediaAttsFromConfig(const TDesC& aSection, TUint& aMediaAtt)
|
sl@0
|
517 |
{
|
sl@0
|
518 |
aMediaAtt = 0;
|
sl@0
|
519 |
|
sl@0
|
520 |
TPtrC mediaAttStr;
|
sl@0
|
521 |
TBool ret = GET_OPTIONAL_STRING_PARAMETER(KMediaAtt(), aSection, mediaAttStr);
|
sl@0
|
522 |
if (ret)
|
sl@0
|
523 |
{
|
sl@0
|
524 |
if ( !ConvertToMediaAtts(mediaAttStr, aMediaAtt) )
|
sl@0
|
525 |
{
|
sl@0
|
526 |
TInt intTemp;
|
sl@0
|
527 |
ret=GET_MANDATORY_INT_PARAMETER(KMediaAtt(), aSection, intTemp);
|
sl@0
|
528 |
if ( ret )
|
sl@0
|
529 |
{
|
sl@0
|
530 |
aMediaAtt=intTemp;
|
sl@0
|
531 |
}
|
sl@0
|
532 |
}
|
sl@0
|
533 |
}
|
sl@0
|
534 |
|
sl@0
|
535 |
return ret;
|
sl@0
|
536 |
}
|
sl@0
|
537 |
|
sl@0
|
538 |
void CT_FsData::DoCmdDriveList(const TDesC& aSection)
|
sl@0
|
539 |
{
|
sl@0
|
540 |
INFO_PRINTF1(_L("Calls RFs::DriveList()."));
|
sl@0
|
541 |
|
sl@0
|
542 |
//Get the list of drives which presents in system. There should be 26 slots where each non-zero slot means a drive in system.
|
sl@0
|
543 |
TDriveList driveList;
|
sl@0
|
544 |
TInt errorCode = iFs->DriveList(driveList);
|
sl@0
|
545 |
|
sl@0
|
546 |
//Check error code.
|
sl@0
|
547 |
if (errorCode != KErrNone)
|
sl@0
|
548 |
{
|
sl@0
|
549 |
ERR_PRINTF2(_L("Function DriveList() failed with %d error code."), errorCode);
|
sl@0
|
550 |
SetError(errorCode);
|
sl@0
|
551 |
}
|
sl@0
|
552 |
else
|
sl@0
|
553 |
{
|
sl@0
|
554 |
//Get data from config
|
sl@0
|
555 |
//Get first drive index from config.
|
sl@0
|
556 |
TInt arraySize = 0;
|
sl@0
|
557 |
TLex lexer;
|
sl@0
|
558 |
if (GET_MANDATORY_INT_PARAMETER(KArraySize(), aSection, arraySize))
|
sl@0
|
559 |
{
|
sl@0
|
560 |
|
sl@0
|
561 |
TInt arrayIndex = 0;
|
sl@0
|
562 |
for(TInt i = 0; i < arraySize; i++)
|
sl@0
|
563 |
{
|
sl@0
|
564 |
TBuf<KBufferStringLength>tmpBuff;
|
sl@0
|
565 |
|
sl@0
|
566 |
tmpBuff.Append(KArrayIndex);
|
sl@0
|
567 |
tmpBuff.AppendNum(i+1);
|
sl@0
|
568 |
if (GET_MANDATORY_INT_PARAMETER( tmpBuff, aSection, arrayIndex))
|
sl@0
|
569 |
{
|
sl@0
|
570 |
|
sl@0
|
571 |
//Check that drive C and drive Z or others what realy present are in list. Also user can change the drives and check their presence.
|
sl@0
|
572 |
if (driveList[arrayIndex] == 0)
|
sl@0
|
573 |
{
|
sl@0
|
574 |
ERR_PRINTF2(_L(" Disk no. %d not present."), arrayIndex);
|
sl@0
|
575 |
SetBlockResult(EFail);
|
sl@0
|
576 |
}
|
sl@0
|
577 |
}
|
sl@0
|
578 |
}
|
sl@0
|
579 |
|
sl@0
|
580 |
}
|
sl@0
|
581 |
}
|
sl@0
|
582 |
}
|
sl@0
|
583 |
|
sl@0
|
584 |
|
sl@0
|
585 |
void CT_FsData::DoCmdDriveL(const TDesC& aSection)
|
sl@0
|
586 |
{
|
sl@0
|
587 |
INFO_PRINTF1(_L("Calls RFs::Drive()."));
|
sl@0
|
588 |
|
sl@0
|
589 |
//Get drive index from config.
|
sl@0
|
590 |
TDriveNumber driveIndex;
|
sl@0
|
591 |
TBool nonDefault = GetDriveNumberFromConfig(aSection, KDrive(), driveIndex);
|
sl@0
|
592 |
|
sl@0
|
593 |
//Get info about drive.
|
sl@0
|
594 |
TDriveInfo driveInfo;
|
sl@0
|
595 |
TInt errorCode;
|
sl@0
|
596 |
if(nonDefault)
|
sl@0
|
597 |
{
|
sl@0
|
598 |
errorCode = iFs->Drive(driveInfo, driveIndex);
|
sl@0
|
599 |
}
|
sl@0
|
600 |
else
|
sl@0
|
601 |
{
|
sl@0
|
602 |
errorCode = iFs->Drive(driveInfo);
|
sl@0
|
603 |
}
|
sl@0
|
604 |
|
sl@0
|
605 |
if(errorCode == KErrNone)
|
sl@0
|
606 |
{
|
sl@0
|
607 |
if ( !VerifyTDriveInfoDataFromIniL(aSection, driveInfo))
|
sl@0
|
608 |
{
|
sl@0
|
609 |
SetBlockResult(EFail);
|
sl@0
|
610 |
}
|
sl@0
|
611 |
}
|
sl@0
|
612 |
else
|
sl@0
|
613 |
{
|
sl@0
|
614 |
ERR_PRINTF2(_L("Function Drive() failed with %d error code"), errorCode);
|
sl@0
|
615 |
SetError(errorCode);
|
sl@0
|
616 |
}
|
sl@0
|
617 |
}
|
sl@0
|
618 |
|
sl@0
|
619 |
TBool CT_FsData::VerifyTDriveInfoDataFromIniL(const TDesC& aSection, TDriveInfo& aDriveInfo)
|
sl@0
|
620 |
{
|
sl@0
|
621 |
TBool ret = ETrue;
|
sl@0
|
622 |
|
sl@0
|
623 |
INFO_PRINTF2(_L("TDriveInfo.iType =%d"), aDriveInfo.iType);
|
sl@0
|
624 |
INFO_PRINTF2(_L("TDriveInfo.iBattery =%d"), aDriveInfo.iBattery);
|
sl@0
|
625 |
INFO_PRINTF2(_L("TDriveInfo.iDriveAtt=0x%X"), aDriveInfo.iDriveAtt);
|
sl@0
|
626 |
TUint driveAttMask[]=
|
sl@0
|
627 |
{
|
sl@0
|
628 |
KDriveAttLocal,
|
sl@0
|
629 |
KDriveAttRom,
|
sl@0
|
630 |
KDriveAttRedirected,
|
sl@0
|
631 |
KDriveAttSubsted,
|
sl@0
|
632 |
KDriveAttInternal,
|
sl@0
|
633 |
KDriveAttRemovable,
|
sl@0
|
634 |
};
|
sl@0
|
635 |
TPtrC driveAttText[]=
|
sl@0
|
636 |
{
|
sl@0
|
637 |
KDriveAttLocalStr(),
|
sl@0
|
638 |
KDriveAttRomStr(),
|
sl@0
|
639 |
KDriveAttRedirectedStr(),
|
sl@0
|
640 |
KDriveAttSubstedStr(),
|
sl@0
|
641 |
KDriveAttInternalStr(),
|
sl@0
|
642 |
KDriveAttRemovableStr(),
|
sl@0
|
643 |
};
|
sl@0
|
644 |
TInt size = sizeof(driveAttMask) / sizeof(driveAttMask[0]);
|
sl@0
|
645 |
TInt index;
|
sl@0
|
646 |
for ( index=0; index<size; ++index )
|
sl@0
|
647 |
{
|
sl@0
|
648 |
if ( aDriveInfo.iDriveAtt&driveAttMask[index] )
|
sl@0
|
649 |
{
|
sl@0
|
650 |
INFO_PRINTF2(_L("DriveAtt %S ON"), &driveAttText[index]);
|
sl@0
|
651 |
}
|
sl@0
|
652 |
}
|
sl@0
|
653 |
INFO_PRINTF2(_L("TDriveInfo.iMediaAtt=0x%X"), aDriveInfo.iMediaAtt);
|
sl@0
|
654 |
TUint mediaAttMask[]=
|
sl@0
|
655 |
{
|
sl@0
|
656 |
KMediaAttVariableSize,
|
sl@0
|
657 |
KMediaAttDualDensity,
|
sl@0
|
658 |
KMediaAttFormattable,
|
sl@0
|
659 |
KMediaAttWriteProtected,
|
sl@0
|
660 |
KMediaAttLockable,
|
sl@0
|
661 |
KMediaAttLocked,
|
sl@0
|
662 |
};
|
sl@0
|
663 |
TPtrC mediaAttText[]=
|
sl@0
|
664 |
{
|
sl@0
|
665 |
KMediaAttVariableSizeStr(),
|
sl@0
|
666 |
KMediaAttDualDensityStr(),
|
sl@0
|
667 |
KMediaAttFormattableStr(),
|
sl@0
|
668 |
KMediaAttWriteProtectedStr(),
|
sl@0
|
669 |
KMediaAttLockableStr(),
|
sl@0
|
670 |
KMediaAttLockedStr(),
|
sl@0
|
671 |
};
|
sl@0
|
672 |
|
sl@0
|
673 |
size = sizeof(mediaAttMask) / sizeof(mediaAttMask[0]);
|
sl@0
|
674 |
for ( index=0; index<size; ++index )
|
sl@0
|
675 |
{
|
sl@0
|
676 |
if ( aDriveInfo.iMediaAtt&mediaAttMask[index] )
|
sl@0
|
677 |
{
|
sl@0
|
678 |
INFO_PRINTF2(_L("MediaAtt %S ON"), &mediaAttText[index]);
|
sl@0
|
679 |
}
|
sl@0
|
680 |
}
|
sl@0
|
681 |
|
sl@0
|
682 |
//Get drive type from config.
|
sl@0
|
683 |
TMediaType mediaType;
|
sl@0
|
684 |
if (GetMediaTypeFromConfig(aSection, mediaType))
|
sl@0
|
685 |
{
|
sl@0
|
686 |
//Checking that type of drive is equal to passed through config file.
|
sl@0
|
687 |
if (aDriveInfo.iType != mediaType)
|
sl@0
|
688 |
{
|
sl@0
|
689 |
ERR_PRINTF3(_L("Drive has wrong type. actual: %d, expected: %d"), aDriveInfo.iType, mediaType);
|
sl@0
|
690 |
ret = EFalse;
|
sl@0
|
691 |
}
|
sl@0
|
692 |
}
|
sl@0
|
693 |
|
sl@0
|
694 |
//Optional battery state checking
|
sl@0
|
695 |
TBatteryState batteryState;
|
sl@0
|
696 |
if (GetBatteryStateFromConfig(aSection, batteryState))
|
sl@0
|
697 |
{
|
sl@0
|
698 |
//Checking that type of drive is equal to passed through config file.
|
sl@0
|
699 |
if (aDriveInfo.iBattery != batteryState)
|
sl@0
|
700 |
{
|
sl@0
|
701 |
ERR_PRINTF3(_L("BatteryState is wrong. actual: %d, expected: %d"), aDriveInfo.iBattery, batteryState);
|
sl@0
|
702 |
ret = EFalse;
|
sl@0
|
703 |
}
|
sl@0
|
704 |
}
|
sl@0
|
705 |
|
sl@0
|
706 |
//Optional media attributes checking
|
sl@0
|
707 |
TUint mediaAtts;
|
sl@0
|
708 |
if (GetMediaAttsFromConfig(aSection, mediaAtts))
|
sl@0
|
709 |
{
|
sl@0
|
710 |
//Checking that type of drive is equal to passed through config file.
|
sl@0
|
711 |
if ( (aDriveInfo.iMediaAtt&mediaAtts)==mediaAtts )
|
sl@0
|
712 |
{
|
sl@0
|
713 |
ERR_PRINTF1(_L("Media attributes are wrong"));
|
sl@0
|
714 |
ret = EFalse;
|
sl@0
|
715 |
}
|
sl@0
|
716 |
}
|
sl@0
|
717 |
|
sl@0
|
718 |
//Optional drive attributes checking.
|
sl@0
|
719 |
TUint driveAtts;
|
sl@0
|
720 |
if (GetDriveAttsFromConfig(aSection, driveAtts))
|
sl@0
|
721 |
{
|
sl@0
|
722 |
//Checking that type of drive is equal to passed through config file.
|
sl@0
|
723 |
if ( (aDriveInfo.iDriveAtt!=driveAtts)==driveAtts )
|
sl@0
|
724 |
{
|
sl@0
|
725 |
ERR_PRINTF1(_L("Drive attributes are wrong"));
|
sl@0
|
726 |
ret = EFalse;
|
sl@0
|
727 |
}
|
sl@0
|
728 |
}
|
sl@0
|
729 |
|
sl@0
|
730 |
return ret;
|
sl@0
|
731 |
}
|
sl@0
|
732 |
|
sl@0
|
733 |
void CT_FsData::DoCmdVolumeL(const TDesC& aSection)
|
sl@0
|
734 |
{
|
sl@0
|
735 |
INFO_PRINTF1(_L("Calls RFs:: Volume()."));
|
sl@0
|
736 |
|
sl@0
|
737 |
//Get drive index from config.
|
sl@0
|
738 |
TDriveNumber driveIndex;
|
sl@0
|
739 |
|
sl@0
|
740 |
TBool nonDefault = GetDriveNumberFromConfig(aSection, KDrive(), driveIndex);
|
sl@0
|
741 |
|
sl@0
|
742 |
//Get info about volume.
|
sl@0
|
743 |
TInt errorCode;
|
sl@0
|
744 |
|
sl@0
|
745 |
if(nonDefault)
|
sl@0
|
746 |
{
|
sl@0
|
747 |
errorCode = iFs->Volume(iVolumeInfo, driveIndex);
|
sl@0
|
748 |
}
|
sl@0
|
749 |
else
|
sl@0
|
750 |
{
|
sl@0
|
751 |
errorCode = iFs->Volume(iVolumeInfo);
|
sl@0
|
752 |
}
|
sl@0
|
753 |
//Check error code.
|
sl@0
|
754 |
if (errorCode != KErrNone)
|
sl@0
|
755 |
{
|
sl@0
|
756 |
ERR_PRINTF2(_L("Function Volume() failed with %d error code"), errorCode);
|
sl@0
|
757 |
SetError(errorCode);
|
sl@0
|
758 |
}
|
sl@0
|
759 |
else
|
sl@0
|
760 |
{
|
sl@0
|
761 |
if ( !FileserverUtil::VerifyTVolumeInfoDataFromIniL(*this, aSection, iVolumeInfo))
|
sl@0
|
762 |
{
|
sl@0
|
763 |
SetBlockResult(EFail);
|
sl@0
|
764 |
}
|
sl@0
|
765 |
|
sl@0
|
766 |
if ( !VerifyTDriveInfoDataFromIniL(aSection, iVolumeInfo.iDrive))
|
sl@0
|
767 |
{
|
sl@0
|
768 |
SetBlockResult(EFail);
|
sl@0
|
769 |
}
|
sl@0
|
770 |
|
sl@0
|
771 |
|
sl@0
|
772 |
TBool save;
|
sl@0
|
773 |
if(GET_OPTIONAL_BOOL_PARAMETER(KSaveInInstance(), aSection, save))
|
sl@0
|
774 |
{
|
sl@0
|
775 |
if(save)
|
sl@0
|
776 |
{
|
sl@0
|
777 |
iVolumeLabel.Copy(iVolumeInfo.iName);
|
sl@0
|
778 |
}
|
sl@0
|
779 |
}
|
sl@0
|
780 |
|
sl@0
|
781 |
TPtrC volumeObjectName;
|
sl@0
|
782 |
if (GET_OPTIONAL_STRING_PARAMETER(KVolumeObject, aSection, volumeObjectName))
|
sl@0
|
783 |
{
|
sl@0
|
784 |
CT_VolumeInfoData* volumeWrapperObject = NULL;
|
sl@0
|
785 |
volumeWrapperObject = static_cast<CT_VolumeInfoData*>(GetDataWrapperL(volumeObjectName));
|
sl@0
|
786 |
if(volumeWrapperObject)
|
sl@0
|
787 |
{
|
sl@0
|
788 |
TVolumeInfo* volumeObject = new(ELeave) TVolumeInfo();
|
sl@0
|
789 |
*volumeObject = iVolumeInfo;
|
sl@0
|
790 |
volumeWrapperObject->SetObjectL(volumeObject);
|
sl@0
|
791 |
}
|
sl@0
|
792 |
}
|
sl@0
|
793 |
}
|
sl@0
|
794 |
|
sl@0
|
795 |
}
|
sl@0
|
796 |
|
sl@0
|
797 |
|
sl@0
|
798 |
void CT_FsData::DoCmdSetVolumeLabel(const TDesC& aSection)
|
sl@0
|
799 |
{
|
sl@0
|
800 |
INFO_PRINTF1(_L("Calls RFs:: SetVolumeLabel()."));
|
sl@0
|
801 |
|
sl@0
|
802 |
//Get drive index from config.
|
sl@0
|
803 |
TDriveNumber driveIndex;
|
sl@0
|
804 |
TBool nonDefault = GetDriveNumberFromConfig(aSection, KDrive(), driveIndex);
|
sl@0
|
805 |
|
sl@0
|
806 |
//Get volume name from config.
|
sl@0
|
807 |
TPtrC volumeLabel;
|
sl@0
|
808 |
if (!GET_OPTIONAL_STRING_PARAMETER(KVolumeLabel(), aSection, volumeLabel))
|
sl@0
|
809 |
{
|
sl@0
|
810 |
volumeLabel.Set(iVolumeLabel);
|
sl@0
|
811 |
}
|
sl@0
|
812 |
|
sl@0
|
813 |
//Trying to set the volume label. By some reason it always retturn KErrNotSupported.
|
sl@0
|
814 |
TInt errorCode;
|
sl@0
|
815 |
if(nonDefault)
|
sl@0
|
816 |
{
|
sl@0
|
817 |
errorCode = iFs->SetVolumeLabel(volumeLabel, driveIndex);
|
sl@0
|
818 |
}
|
sl@0
|
819 |
else
|
sl@0
|
820 |
{
|
sl@0
|
821 |
errorCode = iFs->SetVolumeLabel(volumeLabel);
|
sl@0
|
822 |
}
|
sl@0
|
823 |
|
sl@0
|
824 |
//Check error code.
|
sl@0
|
825 |
if (errorCode != KErrNone)
|
sl@0
|
826 |
{
|
sl@0
|
827 |
ERR_PRINTF2(_L("Function SetVolumeLabel() failed with %d error code"), errorCode);
|
sl@0
|
828 |
SetError(errorCode);
|
sl@0
|
829 |
}
|
sl@0
|
830 |
}
|
sl@0
|
831 |
|
sl@0
|
832 |
|
sl@0
|
833 |
void CT_FsData::DoCmdSubst(const TDesC& aSection)
|
sl@0
|
834 |
{
|
sl@0
|
835 |
INFO_PRINTF1(_L("Calls RFs:: Subst()."));
|
sl@0
|
836 |
|
sl@0
|
837 |
//Get drive index from config.
|
sl@0
|
838 |
TDriveNumber driveIndex;
|
sl@0
|
839 |
|
sl@0
|
840 |
|
sl@0
|
841 |
TBool nonDefault = GetDriveNumberFromConfig(aSection, KDrive(), driveIndex);
|
sl@0
|
842 |
|
sl@0
|
843 |
|
sl@0
|
844 |
TBuf16<KBufferStringLength> substPath;
|
sl@0
|
845 |
|
sl@0
|
846 |
//Get the path to substed drive.
|
sl@0
|
847 |
|
sl@0
|
848 |
TInt errorCode;
|
sl@0
|
849 |
if(nonDefault)
|
sl@0
|
850 |
{
|
sl@0
|
851 |
errorCode = iFs->Subst(substPath, driveIndex);
|
sl@0
|
852 |
}
|
sl@0
|
853 |
else
|
sl@0
|
854 |
{
|
sl@0
|
855 |
errorCode = iFs->Subst(substPath);
|
sl@0
|
856 |
}
|
sl@0
|
857 |
|
sl@0
|
858 |
//Check error code.
|
sl@0
|
859 |
if (errorCode != KErrNone)
|
sl@0
|
860 |
{
|
sl@0
|
861 |
ERR_PRINTF2(_L("Function Subst() failed with %d error code"), errorCode);
|
sl@0
|
862 |
SetError(errorCode);
|
sl@0
|
863 |
}
|
sl@0
|
864 |
else
|
sl@0
|
865 |
{
|
sl@0
|
866 |
//Get drive index from config.
|
sl@0
|
867 |
TPtrC substPathFromConf;
|
sl@0
|
868 |
if (GET_MANDATORY_STRING_PARAMETER(KSubstPath(), aSection, substPathFromConf))
|
sl@0
|
869 |
{
|
sl@0
|
870 |
|
sl@0
|
871 |
//As long as it has to be in similar format we must convert substPathFromConf to TBuf16<255>
|
sl@0
|
872 |
|
sl@0
|
873 |
//Comparing paths.
|
sl@0
|
874 |
if (substPathFromConf.CompareF(substPath) != 0)
|
sl@0
|
875 |
{
|
sl@0
|
876 |
ERR_PRINTF2(_L("Subst path is wrong %S"), &substPathFromConf);
|
sl@0
|
877 |
SetBlockResult(EFail);
|
sl@0
|
878 |
}
|
sl@0
|
879 |
}
|
sl@0
|
880 |
}
|
sl@0
|
881 |
|
sl@0
|
882 |
|
sl@0
|
883 |
}
|
sl@0
|
884 |
|
sl@0
|
885 |
|
sl@0
|
886 |
void CT_FsData::DoCmdSetSubst(const TDesC& aSection)
|
sl@0
|
887 |
{
|
sl@0
|
888 |
INFO_PRINTF1(_L("Calls RFs:: SetSubst()."));
|
sl@0
|
889 |
|
sl@0
|
890 |
|
sl@0
|
891 |
//Get drive index from config.
|
sl@0
|
892 |
TDriveNumber driveIndex;
|
sl@0
|
893 |
TBool nonDefault = GetDriveNumberFromConfig(aSection, KDrive(), driveIndex);
|
sl@0
|
894 |
|
sl@0
|
895 |
|
sl@0
|
896 |
//Get drive index from config.
|
sl@0
|
897 |
TPtrC substPath;
|
sl@0
|
898 |
if (GET_MANDATORY_STRING_PARAMETER(KSubstPath(), aSection, substPath))
|
sl@0
|
899 |
{
|
sl@0
|
900 |
|
sl@0
|
901 |
//Substing the drive with index driveIndex to path substPath.
|
sl@0
|
902 |
TInt errorCode;
|
sl@0
|
903 |
if(nonDefault)
|
sl@0
|
904 |
{
|
sl@0
|
905 |
errorCode = iFs->SetSubst(substPath, driveIndex);
|
sl@0
|
906 |
}
|
sl@0
|
907 |
else
|
sl@0
|
908 |
{
|
sl@0
|
909 |
errorCode = iFs->SetSubst(substPath);
|
sl@0
|
910 |
}
|
sl@0
|
911 |
|
sl@0
|
912 |
//Check error code.
|
sl@0
|
913 |
if (errorCode != KErrNone)
|
sl@0
|
914 |
{
|
sl@0
|
915 |
ERR_PRINTF2(_L("Function SetSubst() failed with %d error code"), errorCode);
|
sl@0
|
916 |
SetError(errorCode);
|
sl@0
|
917 |
}
|
sl@0
|
918 |
|
sl@0
|
919 |
}
|
sl@0
|
920 |
|
sl@0
|
921 |
|
sl@0
|
922 |
|
sl@0
|
923 |
}
|
sl@0
|
924 |
|
sl@0
|
925 |
|
sl@0
|
926 |
void CT_FsData::DoCmdGetMediaSerialNumber(const TDesC& aSection)
|
sl@0
|
927 |
{
|
sl@0
|
928 |
INFO_PRINTF1(_L("Calls RFs::GetMediaSerialNumber()."));
|
sl@0
|
929 |
|
sl@0
|
930 |
//Get drive index from config.
|
sl@0
|
931 |
TDriveNumber driveIndex;
|
sl@0
|
932 |
if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex))
|
sl@0
|
933 |
{
|
sl@0
|
934 |
//Get the media serial number.
|
sl@0
|
935 |
TMediaSerialNumber mediaSerialNumber;
|
sl@0
|
936 |
TInt errorCode = iFs->GetMediaSerialNumber(mediaSerialNumber, driveIndex);
|
sl@0
|
937 |
|
sl@0
|
938 |
//Check error code.
|
sl@0
|
939 |
if (errorCode != KErrNone)
|
sl@0
|
940 |
{
|
sl@0
|
941 |
ERR_PRINTF2(_L("Function GetMediaSerialNumber() failed with %d error code"), errorCode);
|
sl@0
|
942 |
SetError(errorCode);
|
sl@0
|
943 |
}
|
sl@0
|
944 |
}
|
sl@0
|
945 |
else
|
sl@0
|
946 |
{
|
sl@0
|
947 |
ERR_PRINTF2(_L("Not found %S parameter"), &KDrive());
|
sl@0
|
948 |
SetBlockResult(EFail);
|
sl@0
|
949 |
}
|
sl@0
|
950 |
|
sl@0
|
951 |
}
|
sl@0
|
952 |
|
sl@0
|
953 |
|
sl@0
|
954 |
void CT_FsData::DoCmdIsValidDrive(const TDesC& aSection)
|
sl@0
|
955 |
{
|
sl@0
|
956 |
INFO_PRINTF1(_L("Calls RFs::IsValidDirve()."));
|
sl@0
|
957 |
|
sl@0
|
958 |
//Get drive index from config.
|
sl@0
|
959 |
TDriveNumber driveIndex;
|
sl@0
|
960 |
if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex))
|
sl@0
|
961 |
{
|
sl@0
|
962 |
TBool actualValid = RFs::IsValidDrive(driveIndex);
|
sl@0
|
963 |
INFO_PRINTF2(_L("iFs->IsValidDrive = %d"), actualValid);
|
sl@0
|
964 |
|
sl@0
|
965 |
//Get drive validity flag rom config.
|
sl@0
|
966 |
TBool expectedValid;
|
sl@0
|
967 |
if ( GET_OPTIONAL_BOOL_PARAMETER(KDriveIsValid(), aSection, expectedValid) )
|
sl@0
|
968 |
{
|
sl@0
|
969 |
if ( actualValid!=expectedValid )
|
sl@0
|
970 |
{
|
sl@0
|
971 |
ERR_PRINTF1(_L("Function IsValid() returned unexpected result"));
|
sl@0
|
972 |
SetBlockResult(EFail);
|
sl@0
|
973 |
}
|
sl@0
|
974 |
}
|
sl@0
|
975 |
}
|
sl@0
|
976 |
else
|
sl@0
|
977 |
{
|
sl@0
|
978 |
ERR_PRINTF2(_L("Not found %S parameter"), &KDrive());
|
sl@0
|
979 |
SetBlockResult(EFail);
|
sl@0
|
980 |
}
|
sl@0
|
981 |
}
|
sl@0
|
982 |
|
sl@0
|
983 |
|
sl@0
|
984 |
void CT_FsData::DoCmdCharToDrive(const TDesC& aSection)
|
sl@0
|
985 |
{
|
sl@0
|
986 |
INFO_PRINTF1(_L("Calls RFs:: CharToDrive()."));
|
sl@0
|
987 |
|
sl@0
|
988 |
//Get drive index from config.
|
sl@0
|
989 |
//We meed integer there, because function uses TInt, not TDriveNumber.
|
sl@0
|
990 |
|
sl@0
|
991 |
TDriveNumber driveIndex;
|
sl@0
|
992 |
|
sl@0
|
993 |
|
sl@0
|
994 |
//Get drive char from config.
|
sl@0
|
995 |
TPtrC driveCharTmp;
|
sl@0
|
996 |
if (GET_MANDATORY_STRING_PARAMETER(KDriveChar(), aSection, driveCharTmp))
|
sl@0
|
997 |
{
|
sl@0
|
998 |
|
sl@0
|
999 |
TChar driveChar = driveCharTmp.Ptr()[0];
|
sl@0
|
1000 |
TInt driveIndex2;
|
sl@0
|
1001 |
TInt errorCode = RFs::CharToDrive(driveChar, driveIndex2);
|
sl@0
|
1002 |
|
sl@0
|
1003 |
//Check error code.
|
sl@0
|
1004 |
if (errorCode != KErrNone)
|
sl@0
|
1005 |
{
|
sl@0
|
1006 |
ERR_PRINTF2(_L("Function CharToDrive() failed with %d error code"), errorCode);
|
sl@0
|
1007 |
SetError(errorCode);
|
sl@0
|
1008 |
}
|
sl@0
|
1009 |
else
|
sl@0
|
1010 |
{
|
sl@0
|
1011 |
//Get drive index from config
|
sl@0
|
1012 |
if (GetDriveNumberFromConfig(aSection, KDriveIndex(), driveIndex))
|
sl@0
|
1013 |
{
|
sl@0
|
1014 |
if (driveIndex != driveIndex2)
|
sl@0
|
1015 |
{
|
sl@0
|
1016 |
ERR_PRINTF1(_L("Wrong conversion from char to index"));
|
sl@0
|
1017 |
SetBlockResult(EFail);
|
sl@0
|
1018 |
}
|
sl@0
|
1019 |
}
|
sl@0
|
1020 |
}
|
sl@0
|
1021 |
}
|
sl@0
|
1022 |
else
|
sl@0
|
1023 |
{
|
sl@0
|
1024 |
ERR_PRINTF2(_L("Not found %S parameter"), &KDrive());
|
sl@0
|
1025 |
SetBlockResult(EFail);
|
sl@0
|
1026 |
}
|
sl@0
|
1027 |
}
|
sl@0
|
1028 |
|
sl@0
|
1029 |
|
sl@0
|
1030 |
void CT_FsData::DoCmdDriveToChar(const TDesC& aSection)
|
sl@0
|
1031 |
{
|
sl@0
|
1032 |
INFO_PRINTF1(_L("Calls RFs:: DriveToChar()."));
|
sl@0
|
1033 |
|
sl@0
|
1034 |
TPtrC driveCharTmp;
|
sl@0
|
1035 |
|
sl@0
|
1036 |
//Get drive path from config.
|
sl@0
|
1037 |
TDriveNumber driveIndex;
|
sl@0
|
1038 |
if (GetDriveNumberFromConfig(aSection, KDriveIndex(), driveIndex))
|
sl@0
|
1039 |
{
|
sl@0
|
1040 |
|
sl@0
|
1041 |
TChar driveChar2;
|
sl@0
|
1042 |
TInt errorCode = RFs::DriveToChar(driveIndex, driveChar2);
|
sl@0
|
1043 |
//Check error code.
|
sl@0
|
1044 |
|
sl@0
|
1045 |
if (errorCode != KErrNone)
|
sl@0
|
1046 |
{
|
sl@0
|
1047 |
ERR_PRINTF2(_L("Function DriveToChar() failed with %d error code"), errorCode);
|
sl@0
|
1048 |
SetError(errorCode);
|
sl@0
|
1049 |
}
|
sl@0
|
1050 |
else
|
sl@0
|
1051 |
{
|
sl@0
|
1052 |
INFO_PRINTF3(_L("DriveToChar(%d) = %c"), driveIndex, TUint(driveChar2));
|
sl@0
|
1053 |
|
sl@0
|
1054 |
//Get drive char from config.
|
sl@0
|
1055 |
if (GET_OPTIONAL_STRING_PARAMETER(KDriveChar(), aSection, driveCharTmp))
|
sl@0
|
1056 |
{
|
sl@0
|
1057 |
|
sl@0
|
1058 |
TChar driveChar= driveCharTmp.Ptr()[0];
|
sl@0
|
1059 |
if (driveChar != driveChar2)
|
sl@0
|
1060 |
{
|
sl@0
|
1061 |
ERR_PRINTF1(_L("Wrong conversion from char to index"));
|
sl@0
|
1062 |
SetBlockResult(EFail);
|
sl@0
|
1063 |
}
|
sl@0
|
1064 |
}
|
sl@0
|
1065 |
}
|
sl@0
|
1066 |
}
|
sl@0
|
1067 |
else
|
sl@0
|
1068 |
{
|
sl@0
|
1069 |
ERR_PRINTF2(_L("Not found %S parameter"), &KDrive());
|
sl@0
|
1070 |
SetBlockResult(EFail);
|
sl@0
|
1071 |
}
|
sl@0
|
1072 |
}
|
sl@0
|
1073 |
|
sl@0
|
1074 |
|
sl@0
|
1075 |
void CT_FsData::DoCmdCheckDisk(const TDesC& aSection)
|
sl@0
|
1076 |
{
|
sl@0
|
1077 |
INFO_PRINTF1(_L("Calls RFs:: CheckDisk()."));
|
sl@0
|
1078 |
|
sl@0
|
1079 |
//Get drive path from config.
|
sl@0
|
1080 |
TPtrC drivePath;
|
sl@0
|
1081 |
if (GET_MANDATORY_STRING_PARAMETER(KDrivePath(), aSection, drivePath))
|
sl@0
|
1082 |
{
|
sl@0
|
1083 |
|
sl@0
|
1084 |
TInt errorCode = iFs->CheckDisk(drivePath);
|
sl@0
|
1085 |
|
sl@0
|
1086 |
//Check error code.
|
sl@0
|
1087 |
if (errorCode != KErrNone)
|
sl@0
|
1088 |
{
|
sl@0
|
1089 |
ERR_PRINTF2(_L("Function CheckDisk() failed with %d error code"), errorCode);
|
sl@0
|
1090 |
SetError(errorCode);
|
sl@0
|
1091 |
}
|
sl@0
|
1092 |
|
sl@0
|
1093 |
}
|
sl@0
|
1094 |
|
sl@0
|
1095 |
}
|
sl@0
|
1096 |
|
sl@0
|
1097 |
void CT_FsData::DoCmdScanDrive(const TDesC& aSection)
|
sl@0
|
1098 |
{
|
sl@0
|
1099 |
INFO_PRINTF1(_L("Calls RFs:: ScanDisk()."));
|
sl@0
|
1100 |
|
sl@0
|
1101 |
//Get drive path from config.
|
sl@0
|
1102 |
TPtrC drivePath;
|
sl@0
|
1103 |
if (GET_MANDATORY_STRING_PARAMETER(KDrivePath(), aSection, drivePath))
|
sl@0
|
1104 |
{
|
sl@0
|
1105 |
|
sl@0
|
1106 |
TInt errorCode = iFs->ScanDrive(drivePath);
|
sl@0
|
1107 |
|
sl@0
|
1108 |
//Check error code.
|
sl@0
|
1109 |
if (errorCode != KErrNone)
|
sl@0
|
1110 |
{
|
sl@0
|
1111 |
ERR_PRINTF2(_L("Function ScanDrive() failed with %d error code"), errorCode);
|
sl@0
|
1112 |
SetError(errorCode);
|
sl@0
|
1113 |
}
|
sl@0
|
1114 |
|
sl@0
|
1115 |
}
|
sl@0
|
1116 |
|
sl@0
|
1117 |
}
|
sl@0
|
1118 |
|
sl@0
|
1119 |
|
sl@0
|
1120 |
void CT_FsData::DoCmdGetDriveName(const TDesC& aSection)
|
sl@0
|
1121 |
{
|
sl@0
|
1122 |
INFO_PRINTF1(_L("Calls RFs::Calls GetDriveName()"));
|
sl@0
|
1123 |
|
sl@0
|
1124 |
//Get drive index from config.
|
sl@0
|
1125 |
TDriveNumber driveIndex;
|
sl@0
|
1126 |
|
sl@0
|
1127 |
if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex))
|
sl@0
|
1128 |
{
|
sl@0
|
1129 |
TBuf<KBufferStringLength> driveName;
|
sl@0
|
1130 |
TInt errorCode = iFs->GetDriveName(driveIndex, driveName);
|
sl@0
|
1131 |
|
sl@0
|
1132 |
//Check error code.
|
sl@0
|
1133 |
if (errorCode != KErrNone)
|
sl@0
|
1134 |
{
|
sl@0
|
1135 |
ERR_PRINTF2(_L("Function SetDriveLabel() failed with %d error code"), errorCode);
|
sl@0
|
1136 |
SetError(errorCode);
|
sl@0
|
1137 |
}
|
sl@0
|
1138 |
else
|
sl@0
|
1139 |
{
|
sl@0
|
1140 |
//Get drive name from config.
|
sl@0
|
1141 |
TPtrC driveNameFromConf;
|
sl@0
|
1142 |
if(GET_OPTIONAL_STRING_PARAMETER(KDriveName(), aSection, driveNameFromConf))
|
sl@0
|
1143 |
{
|
sl@0
|
1144 |
TPtrC driveNamePtr = driveName;
|
sl@0
|
1145 |
if (driveNamePtr != driveNameFromConf)
|
sl@0
|
1146 |
{
|
sl@0
|
1147 |
ERR_PRINTF3(_L("Names mismatch: %S != %S"), &driveNamePtr, &driveNameFromConf);
|
sl@0
|
1148 |
SetBlockResult(EFail);
|
sl@0
|
1149 |
}
|
sl@0
|
1150 |
}
|
sl@0
|
1151 |
|
sl@0
|
1152 |
TBool save;
|
sl@0
|
1153 |
|
sl@0
|
1154 |
if(GET_OPTIONAL_BOOL_PARAMETER(KSaveInInstance(), aSection, save))
|
sl@0
|
1155 |
{
|
sl@0
|
1156 |
if(save)
|
sl@0
|
1157 |
{
|
sl@0
|
1158 |
iDriveName.Copy(iDriveName);
|
sl@0
|
1159 |
}
|
sl@0
|
1160 |
}
|
sl@0
|
1161 |
}
|
sl@0
|
1162 |
}
|
sl@0
|
1163 |
else
|
sl@0
|
1164 |
{
|
sl@0
|
1165 |
ERR_PRINTF2(_L("Not found %S parameter"), &KDrive());
|
sl@0
|
1166 |
SetBlockResult(EFail);
|
sl@0
|
1167 |
}
|
sl@0
|
1168 |
}
|
sl@0
|
1169 |
|
sl@0
|
1170 |
|
sl@0
|
1171 |
void CT_FsData::DoCmdSetDriveName(const TDesC& aSection)
|
sl@0
|
1172 |
{
|
sl@0
|
1173 |
INFO_PRINTF1(_L("Calls RFs::SetDriveName()."));
|
sl@0
|
1174 |
|
sl@0
|
1175 |
//Get drive index from config.
|
sl@0
|
1176 |
TDriveNumber driveIndex;
|
sl@0
|
1177 |
if ( GetDriveNumberFromConfig(aSection, KDrive(), driveIndex) )
|
sl@0
|
1178 |
{
|
sl@0
|
1179 |
//Get drive name from config.
|
sl@0
|
1180 |
TPtrC driveName;
|
sl@0
|
1181 |
if ( !GET_OPTIONAL_STRING_PARAMETER(KDriveName(), aSection, driveName) )
|
sl@0
|
1182 |
{
|
sl@0
|
1183 |
driveName.Set(iDriveName);
|
sl@0
|
1184 |
}
|
sl@0
|
1185 |
|
sl@0
|
1186 |
//Check error code.
|
sl@0
|
1187 |
TInt errorCode = iFs->SetDriveName(driveIndex, driveName);
|
sl@0
|
1188 |
if (errorCode != KErrNone)
|
sl@0
|
1189 |
{
|
sl@0
|
1190 |
ERR_PRINTF2(_L("Function SetDriveLabel() failed with %d error code"), errorCode);
|
sl@0
|
1191 |
SetError(errorCode);
|
sl@0
|
1192 |
}
|
sl@0
|
1193 |
}
|
sl@0
|
1194 |
else
|
sl@0
|
1195 |
{
|
sl@0
|
1196 |
ERR_PRINTF2(_L("Not found %S parameter"), KDriveIndex);
|
sl@0
|
1197 |
SetBlockResult(EFail);
|
sl@0
|
1198 |
}
|
sl@0
|
1199 |
}
|
sl@0
|
1200 |
|
sl@0
|
1201 |
//
|
sl@0
|
1202 |
void CT_FsData::DoCmdLockDrive(const TDesC& aSection)
|
sl@0
|
1203 |
{
|
sl@0
|
1204 |
INFO_PRINTF1(_L("Calls RFs::LockDrive()."));
|
sl@0
|
1205 |
|
sl@0
|
1206 |
//Get old password from config.
|
sl@0
|
1207 |
TPtrC drivePassword;
|
sl@0
|
1208 |
if ( GET_MANDATORY_STRING_PARAMETER(KDriveOldPassword(), aSection, drivePassword) )
|
sl@0
|
1209 |
{
|
sl@0
|
1210 |
//Get drive index from config.
|
sl@0
|
1211 |
TDriveNumber driveIndex;
|
sl@0
|
1212 |
if ( GetDriveNumberFromConfig(aSection, KDrive(), driveIndex) )
|
sl@0
|
1213 |
{
|
sl@0
|
1214 |
//Get new password from config.
|
sl@0
|
1215 |
TPtrC driveNewPassword;
|
sl@0
|
1216 |
if ( GET_MANDATORY_STRING_PARAMETER(KDriveNewPassword(), aSection, driveNewPassword) )
|
sl@0
|
1217 |
{
|
sl@0
|
1218 |
// get boolean value from config
|
sl@0
|
1219 |
TBool store;
|
sl@0
|
1220 |
if (GET_MANDATORY_BOOL_PARAMETER(KStore(), aSection, store))
|
sl@0
|
1221 |
{
|
sl@0
|
1222 |
TMediaPassword password;
|
sl@0
|
1223 |
password.Copy(driveNewPassword);
|
sl@0
|
1224 |
iPassword.Copy(drivePassword);
|
sl@0
|
1225 |
|
sl@0
|
1226 |
TInt errorCode = iFs->LockDrive(driveIndex, iPassword, password, store);
|
sl@0
|
1227 |
|
sl@0
|
1228 |
//Check error code.
|
sl@0
|
1229 |
if (errorCode == KErrNone)
|
sl@0
|
1230 |
{
|
sl@0
|
1231 |
iPassword=password;
|
sl@0
|
1232 |
}
|
sl@0
|
1233 |
else
|
sl@0
|
1234 |
{
|
sl@0
|
1235 |
ERR_PRINTF2(_L("Function LockDrive() failed with %d error code"), errorCode);
|
sl@0
|
1236 |
SetError(errorCode);
|
sl@0
|
1237 |
}
|
sl@0
|
1238 |
}
|
sl@0
|
1239 |
}
|
sl@0
|
1240 |
}
|
sl@0
|
1241 |
}
|
sl@0
|
1242 |
}
|
sl@0
|
1243 |
|
sl@0
|
1244 |
|
sl@0
|
1245 |
void CT_FsData::DoCmdUnlockDrive(const TDesC& aSection)
|
sl@0
|
1246 |
{
|
sl@0
|
1247 |
INFO_PRINTF1(_L("Calls RFs::UnlockDrive()."));
|
sl@0
|
1248 |
|
sl@0
|
1249 |
//Get old password from config.
|
sl@0
|
1250 |
TPtrC drivePassword;
|
sl@0
|
1251 |
if ( GET_MANDATORY_STRING_PARAMETER(KDriveOldPassword(), aSection, drivePassword) )
|
sl@0
|
1252 |
{
|
sl@0
|
1253 |
//Get drive index from config.
|
sl@0
|
1254 |
TDriveNumber driveIndex;
|
sl@0
|
1255 |
if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex))
|
sl@0
|
1256 |
{
|
sl@0
|
1257 |
// get boolean value from config
|
sl@0
|
1258 |
TBool store;
|
sl@0
|
1259 |
if (GET_MANDATORY_BOOL_PARAMETER(KStore(), aSection, store))
|
sl@0
|
1260 |
{
|
sl@0
|
1261 |
TMediaPassword password;
|
sl@0
|
1262 |
//Converting string to appropriative password format(TMediaPassword is typedef for TBuf<16>)
|
sl@0
|
1263 |
password.Copy(drivePassword);
|
sl@0
|
1264 |
|
sl@0
|
1265 |
TInt errorCode = iFs->UnlockDrive(driveIndex, password, store);
|
sl@0
|
1266 |
|
sl@0
|
1267 |
//Check error code.
|
sl@0
|
1268 |
if (errorCode == KErrNone)
|
sl@0
|
1269 |
{
|
sl@0
|
1270 |
iPassword=password;
|
sl@0
|
1271 |
}
|
sl@0
|
1272 |
else
|
sl@0
|
1273 |
{
|
sl@0
|
1274 |
ERR_PRINTF2(_L("Function UnlockDrive() failed with %d error code"), errorCode);
|
sl@0
|
1275 |
SetError(errorCode);
|
sl@0
|
1276 |
}
|
sl@0
|
1277 |
}
|
sl@0
|
1278 |
}
|
sl@0
|
1279 |
else
|
sl@0
|
1280 |
{
|
sl@0
|
1281 |
ERR_PRINTF2(_L("Not found %S parameter"),KDrive);
|
sl@0
|
1282 |
SetBlockResult(EFail);
|
sl@0
|
1283 |
}
|
sl@0
|
1284 |
}
|
sl@0
|
1285 |
}
|
sl@0
|
1286 |
|
sl@0
|
1287 |
|
sl@0
|
1288 |
void CT_FsData::DoCmdClearPassword(const TDesC& aSection)
|
sl@0
|
1289 |
{
|
sl@0
|
1290 |
INFO_PRINTF1(_L("Calls RFs::ClearPassword()."));
|
sl@0
|
1291 |
|
sl@0
|
1292 |
//Get old password from config.
|
sl@0
|
1293 |
TPtrC driveOldPasswordTmp;
|
sl@0
|
1294 |
if (GET_MANDATORY_STRING_PARAMETER(KDriveOldPassword(), aSection, driveOldPasswordTmp))
|
sl@0
|
1295 |
{
|
sl@0
|
1296 |
//Get drive index from config.
|
sl@0
|
1297 |
TDriveNumber driveIndex;
|
sl@0
|
1298 |
if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex))
|
sl@0
|
1299 |
{
|
sl@0
|
1300 |
//Converting string to appropriative password format(TMediaPassword is typedef for TBuf<16>)
|
sl@0
|
1301 |
TMediaPassword driveOldPassword;
|
sl@0
|
1302 |
driveOldPassword.Copy(driveOldPasswordTmp);
|
sl@0
|
1303 |
|
sl@0
|
1304 |
TInt errorCode = iFs->ClearPassword(driveIndex, driveOldPassword);
|
sl@0
|
1305 |
if (errorCode != KErrNone)
|
sl@0
|
1306 |
{
|
sl@0
|
1307 |
ERR_PRINTF2(_L("Function ClearPassword() failed with %d error code"), errorCode);
|
sl@0
|
1308 |
SetError(errorCode);
|
sl@0
|
1309 |
}
|
sl@0
|
1310 |
}
|
sl@0
|
1311 |
else
|
sl@0
|
1312 |
{
|
sl@0
|
1313 |
ERR_PRINTF2(_L("Not found %S parameter"),KDrive);
|
sl@0
|
1314 |
SetBlockResult(EFail);
|
sl@0
|
1315 |
}
|
sl@0
|
1316 |
}
|
sl@0
|
1317 |
}
|
sl@0
|
1318 |
|
sl@0
|
1319 |
|
sl@0
|
1320 |
void CT_FsData::DoCmdErasePassword(const TDesC& aSection)
|
sl@0
|
1321 |
{
|
sl@0
|
1322 |
INFO_PRINTF1(_L("Calls RFs::ErasePassword()."));
|
sl@0
|
1323 |
|
sl@0
|
1324 |
//Get drive from config.
|
sl@0
|
1325 |
TDriveNumber driveIndex;
|
sl@0
|
1326 |
if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex))
|
sl@0
|
1327 |
{
|
sl@0
|
1328 |
TInt errorCode = iFs->ErasePassword(driveIndex);
|
sl@0
|
1329 |
|
sl@0
|
1330 |
//Check error code.
|
sl@0
|
1331 |
if (errorCode != KErrNone)
|
sl@0
|
1332 |
{
|
sl@0
|
1333 |
ERR_PRINTF2(_L("Function ErasePassword() failed with %d error code"), errorCode);
|
sl@0
|
1334 |
SetError(errorCode);
|
sl@0
|
1335 |
}
|
sl@0
|
1336 |
}
|
sl@0
|
1337 |
else
|
sl@0
|
1338 |
{
|
sl@0
|
1339 |
ERR_PRINTF2(_L("Not found %S parameter"), &KDrive());
|
sl@0
|
1340 |
SetBlockResult(EFail);
|
sl@0
|
1341 |
}
|
sl@0
|
1342 |
}
|
sl@0
|
1343 |
|
sl@0
|
1344 |
|
sl@0
|
1345 |
void CT_FsData::DoCmdReserveDriveSpace(const TDesC& aSection)
|
sl@0
|
1346 |
{
|
sl@0
|
1347 |
INFO_PRINTF1(_L("Calls RFs::ReserveDriveSpace()."));
|
sl@0
|
1348 |
|
sl@0
|
1349 |
//Get amount of bytes to be reserved from config.
|
sl@0
|
1350 |
TInt bytesToReserve;
|
sl@0
|
1351 |
if (GET_MANDATORY_INT_PARAMETER(KBytesToReserve(), aSection, bytesToReserve))
|
sl@0
|
1352 |
{
|
sl@0
|
1353 |
TDriveNumber driveIndex;
|
sl@0
|
1354 |
|
sl@0
|
1355 |
if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex))
|
sl@0
|
1356 |
{
|
sl@0
|
1357 |
TInt errorCode = iFs->ReserveDriveSpace(driveIndex, bytesToReserve);
|
sl@0
|
1358 |
|
sl@0
|
1359 |
//Check error code.
|
sl@0
|
1360 |
if (errorCode != KErrNone)
|
sl@0
|
1361 |
{
|
sl@0
|
1362 |
ERR_PRINTF2(_L("Function ReserveDriveSpace() failed with %d error code"), errorCode);
|
sl@0
|
1363 |
SetError(errorCode);
|
sl@0
|
1364 |
}
|
sl@0
|
1365 |
}
|
sl@0
|
1366 |
else
|
sl@0
|
1367 |
{
|
sl@0
|
1368 |
ERR_PRINTF2(_L("Not found %S parameter"),KDrive);
|
sl@0
|
1369 |
SetBlockResult(EFail);
|
sl@0
|
1370 |
}
|
sl@0
|
1371 |
}
|
sl@0
|
1372 |
}
|
sl@0
|
1373 |
|
sl@0
|
1374 |
|
sl@0
|
1375 |
void CT_FsData::DoCmdGetReserveAccess(const TDesC& aSection)
|
sl@0
|
1376 |
{
|
sl@0
|
1377 |
INFO_PRINTF1(_L("Calls RFs::GetReserveAccess()."));
|
sl@0
|
1378 |
|
sl@0
|
1379 |
//Get drive index from config.
|
sl@0
|
1380 |
TDriveNumber driveIndex;
|
sl@0
|
1381 |
if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex))
|
sl@0
|
1382 |
{
|
sl@0
|
1383 |
TInt errorCode = iFs->GetReserveAccess(driveIndex);
|
sl@0
|
1384 |
|
sl@0
|
1385 |
//Check error code.
|
sl@0
|
1386 |
if (errorCode != KErrNone)
|
sl@0
|
1387 |
{
|
sl@0
|
1388 |
ERR_PRINTF2(_L("Function GetReserveAccess() failed with %d error code"), errorCode);
|
sl@0
|
1389 |
SetError(errorCode);
|
sl@0
|
1390 |
}
|
sl@0
|
1391 |
}
|
sl@0
|
1392 |
else
|
sl@0
|
1393 |
{
|
sl@0
|
1394 |
ERR_PRINTF2(_L("Not found %S parameter"), &KDrive());
|
sl@0
|
1395 |
SetBlockResult(EFail);
|
sl@0
|
1396 |
}
|
sl@0
|
1397 |
}
|
sl@0
|
1398 |
|
sl@0
|
1399 |
|
sl@0
|
1400 |
void CT_FsData::DoCmdReleaseReserveAccess(const TDesC& aSection)
|
sl@0
|
1401 |
{
|
sl@0
|
1402 |
INFO_PRINTF1(_L("Calls RFs::ReleaseReserveAccess()."));
|
sl@0
|
1403 |
|
sl@0
|
1404 |
//Get drive index from config.
|
sl@0
|
1405 |
TDriveNumber driveIndex;
|
sl@0
|
1406 |
if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex))
|
sl@0
|
1407 |
{
|
sl@0
|
1408 |
TInt errorCode = iFs->ReleaseReserveAccess(driveIndex);
|
sl@0
|
1409 |
|
sl@0
|
1410 |
//Check error code.
|
sl@0
|
1411 |
if (errorCode != KErrNone)
|
sl@0
|
1412 |
{
|
sl@0
|
1413 |
ERR_PRINTF2(_L("Function ReleaseReserveAccess() failed with %d error code"), errorCode);
|
sl@0
|
1414 |
SetError(errorCode);
|
sl@0
|
1415 |
}
|
sl@0
|
1416 |
}
|
sl@0
|
1417 |
else
|
sl@0
|
1418 |
{
|
sl@0
|
1419 |
ERR_PRINTF2(_L("Not found %S parameter"), &KDrive());
|
sl@0
|
1420 |
SetBlockResult(EFail);
|
sl@0
|
1421 |
}
|
sl@0
|
1422 |
}
|
sl@0
|
1423 |
|
sl@0
|
1424 |
void CT_FsData::DoCmdGetSystemDrive(const TDesC& aSection)
|
sl@0
|
1425 |
{
|
sl@0
|
1426 |
INFO_PRINTF1(_L("Calls RFs::GetSystemDrive()."));
|
sl@0
|
1427 |
|
sl@0
|
1428 |
TDriveNumber driveNumber = RFs::GetSystemDrive();
|
sl@0
|
1429 |
INFO_PRINTF2(_L("System Drive = %d"), driveNumber);
|
sl@0
|
1430 |
|
sl@0
|
1431 |
//Get drive index from config.
|
sl@0
|
1432 |
TDriveNumber driveIndex;
|
sl@0
|
1433 |
if ( GetDriveNumberFromConfig(aSection, KDrive(), driveIndex) )
|
sl@0
|
1434 |
{
|
sl@0
|
1435 |
//Check error code.
|
sl@0
|
1436 |
if (driveNumber != driveIndex)
|
sl@0
|
1437 |
{
|
sl@0
|
1438 |
ERR_PRINTF1(_L("GetSystemDrive() returned unexpected drive"));
|
sl@0
|
1439 |
SetBlockResult(EFail);
|
sl@0
|
1440 |
}
|
sl@0
|
1441 |
}
|
sl@0
|
1442 |
else
|
sl@0
|
1443 |
{
|
sl@0
|
1444 |
ERR_PRINTF2(_L("Not found %S parameter"), &KDrive());
|
sl@0
|
1445 |
SetBlockResult(EFail);
|
sl@0
|
1446 |
}
|
sl@0
|
1447 |
}
|
sl@0
|
1448 |
|
sl@0
|
1449 |
void CT_FsData::DoCmdSetSystemDrive(const TDesC& aSection)
|
sl@0
|
1450 |
{
|
sl@0
|
1451 |
INFO_PRINTF1(_L("Calls RFs::SetSystemDrive()"));
|
sl@0
|
1452 |
|
sl@0
|
1453 |
// get drive number from parameters
|
sl@0
|
1454 |
TDriveNumber driveNumber = EDriveA;
|
sl@0
|
1455 |
if (GetDriveNumberFromConfig(aSection, KDrive(), driveNumber))
|
sl@0
|
1456 |
{
|
sl@0
|
1457 |
TInt err = iFs->SetSystemDrive(driveNumber);
|
sl@0
|
1458 |
// check error code
|
sl@0
|
1459 |
if (err != KErrNone)
|
sl@0
|
1460 |
{
|
sl@0
|
1461 |
ERR_PRINTF2(_L("SetSystemDrive() error: %d"), err);
|
sl@0
|
1462 |
SetError(err);
|
sl@0
|
1463 |
}
|
sl@0
|
1464 |
}
|
sl@0
|
1465 |
else
|
sl@0
|
1466 |
{
|
sl@0
|
1467 |
ERR_PRINTF2(_L("No %S"), &KDrive());
|
sl@0
|
1468 |
SetBlockResult(EFail);
|
sl@0
|
1469 |
}
|
sl@0
|
1470 |
|
sl@0
|
1471 |
}
|
sl@0
|
1472 |
|
sl@0
|
1473 |
void CT_FsData::DoCmdGetSystemDriveChar(const TDesC& aSection)
|
sl@0
|
1474 |
{
|
sl@0
|
1475 |
INFO_PRINTF1(_L("Calls RFs::GetSystemDriveChar()"));
|
sl@0
|
1476 |
|
sl@0
|
1477 |
TChar drvChar = RFs::GetSystemDriveChar();
|
sl@0
|
1478 |
INFO_PRINTF2(_L("GetSystemDriveChar() = %c"), TUint(drvChar));
|
sl@0
|
1479 |
//Get drive char from config.
|
sl@0
|
1480 |
TPtrC driveCharTmp;
|
sl@0
|
1481 |
if (GET_OPTIONAL_STRING_PARAMETER(KDriveChar(), aSection, driveCharTmp))
|
sl@0
|
1482 |
{
|
sl@0
|
1483 |
TChar driveCharExpect = driveCharTmp.Ptr()[0];
|
sl@0
|
1484 |
driveCharExpect.UpperCase();
|
sl@0
|
1485 |
drvChar.UpperCase();
|
sl@0
|
1486 |
if ( drvChar != driveCharExpect)
|
sl@0
|
1487 |
{
|
sl@0
|
1488 |
ERR_PRINTF1(_L("Drive char != expected drive char"));
|
sl@0
|
1489 |
SetBlockResult(EFail);
|
sl@0
|
1490 |
}
|
sl@0
|
1491 |
}
|
sl@0
|
1492 |
}
|
sl@0
|
1493 |
|
sl@0
|
1494 |
void CT_FsData::DoCmdVolumeIOParam(const TDesC& aSection)
|
sl@0
|
1495 |
{
|
sl@0
|
1496 |
INFO_PRINTF1(_L("Calls RFs::VolumeIOParam()"));
|
sl@0
|
1497 |
|
sl@0
|
1498 |
// get drive number from parameters
|
sl@0
|
1499 |
TDriveNumber driveNumber = EDriveA;
|
sl@0
|
1500 |
if (GetDriveNumberFromConfig(aSection, KDrive(), driveNumber))
|
sl@0
|
1501 |
{
|
sl@0
|
1502 |
TVolumeIOParamInfo volumeIOParamInf;
|
sl@0
|
1503 |
TInt err = iFs->VolumeIOParam(driveNumber, volumeIOParamInf);
|
sl@0
|
1504 |
// check error code
|
sl@0
|
1505 |
if (err != KErrNone)
|
sl@0
|
1506 |
{
|
sl@0
|
1507 |
ERR_PRINTF2(_L("VolumeIOParam() error: %d"), err);
|
sl@0
|
1508 |
SetError(err);
|
sl@0
|
1509 |
}
|
sl@0
|
1510 |
else
|
sl@0
|
1511 |
{
|
sl@0
|
1512 |
INFO_PRINTF2(_L("VolumeIOParam BlockSize: %d"), volumeIOParamInf.iBlockSize );
|
sl@0
|
1513 |
INFO_PRINTF2(_L("VolumeIOParam ClusterSize: %d"), volumeIOParamInf.iClusterSize );
|
sl@0
|
1514 |
INFO_PRINTF2(_L("VolumeIOParam RecReadBufSize: %d"), volumeIOParamInf.iRecReadBufSize );
|
sl@0
|
1515 |
INFO_PRINTF2(_L("VolumeIOParam RecWriteBufSize: %d"), volumeIOParamInf.iRecWriteBufSize );
|
sl@0
|
1516 |
}
|
sl@0
|
1517 |
}
|
sl@0
|
1518 |
else
|
sl@0
|
1519 |
{
|
sl@0
|
1520 |
ERR_PRINTF2(_L("No %S"), &KDrive());
|
sl@0
|
1521 |
SetBlockResult(EFail);
|
sl@0
|
1522 |
}
|
sl@0
|
1523 |
}
|
sl@0
|
1524 |
|
sl@0
|
1525 |
|