Update contrib.
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
23 This contains CT_FsData
34 _LIT(KDriveA, "EDriveA");
35 _LIT(KDriveB, "EDriveB");
36 _LIT(KDriveC, "EDriveC");
37 _LIT(KDriveD, "EDriveD");
38 _LIT(KDriveE, "EDriveE");
39 _LIT(KDriveF, "EDriveF");
40 _LIT(KDriveG, "EDriveG");
41 _LIT(KDriveH, "EDriveH");
42 _LIT(KDriveI, "EDriveI");
43 _LIT(KDriveJ, "EDriveJ");
44 _LIT(KDriveK, "EDriveK");
45 _LIT(KDriveL, "EDriveL");
46 _LIT(KDriveM, "EDriveM");
47 _LIT(KDriveN, "EDriveN");
48 _LIT(KDriveO, "EDriveO");
49 _LIT(KDriveP, "EDriveP");
50 _LIT(KDriveQ, "EDriveQ");
51 _LIT(KDriveR, "EDriveR");
52 _LIT(KDriveS, "EDriveS");
53 _LIT(KDriveT, "EDriveT");
54 _LIT(KDriveU, "EDriveU");
55 _LIT(KDriveV, "EDriveV");
56 _LIT(KDriveW, "EDriveW");
57 _LIT(KDriveX, "EDriveX");
58 _LIT(KDriveY, "EDriveY");
59 _LIT(KDriveZ, "EDriveZ");
61 _LIT(KWriteMappingsAndSet, "EWriteMappingsAndSet");
62 _LIT(KWriteMappingsNoSet, "EWriteMappingsNoSet");
63 _LIT(KSwapIntMappingAndSet, "ESwapIntMappingAndSet");
67 _LIT(KDrive, "drive");
68 _LIT(KDriveMappingElement, "drive_mapping_element_");
69 _LIT(KDriveMappingSize, "drive_mapping_size");
70 _LIT(KDriveMappingOperation, "drive_mapping_operation");
71 _LIT(KFileName, "file_name");
72 _LIT(KFileSystemName, "file_system_name");
73 _LIT(KNewFileSystemName, "new_file_system_name");
74 _LIT(KFlags, "flags");
75 _LIT(KIsSync, "is_sync");
76 _LIT(KExtensionName, "extension_name");
77 _LIT(KPosition, "position");
80 _LIT(KCommandNum, "command_num");
81 _LIT(KSaveInInstance, "save_in_instance");
82 _LIT(KLocalDrive, "local_drive");
83 _LIT(KCompositeDrive, "composite_drive");
84 _LIT(KIsMountSuccess, "is_mount_success");
85 _LIT(KParam1, "param1");
86 _LIT(KParam2, "param2");
87 _LIT(KIndex, "index");
88 _LIT(KSubTypeName, "sub_type_name");
92 _LIT(KCmdAddFileSystem, "AddFileSystem");
93 _LIT(KCmdDismountFileSystem, "DismountFileSystem");
94 _LIT(KCmdFileSystemName, "FileSystemName");
95 _LIT(KCmdMountFileSystem, "MountFileSystem");
96 _LIT(KCmdMountFileSystemAndScan, "MountFileSystemAndScan");
97 _LIT(KCmdRemountDrive, "RemountDrive");
98 _LIT(KCmdRemoveFileSystem, "RemoveFileSystem");
99 _LIT(KCmdAddExtension, "AddExtension");
100 _LIT(KCmdMountExtension, "MountExtension");
101 _LIT(KCmdRemoveExtension, "RemoveExtension");
102 _LIT(KCmdExtensionName, "ExtensionName");
103 _LIT(KCmdAddCompositeMount, "AddCompositeMount");
104 _LIT(KCmdAllowDismount, "AllowDismount");
105 _LIT(KCmdNotifyDismount, "NotifyDismount");
106 _LIT(KCmdNotifyDismountCancel, "NotifyDismountCancel");
107 _LIT(KCmdStartupInitComplete, "StartupInitComplete");
108 _LIT(KCmdSwapFileSystem, "SwapFileSystem");
109 _LIT(KCmdSetStartupConfiguration, "SetStartupConfiguration");
110 _LIT(KCmdDismountExtension, "DismountExtension");
111 _LIT(KCmdSetLocalDriveMapping, "SetLocalDriveMapping");
112 _LIT(KCmdFinaliseDrives, "FinaliseDrives");
113 _LIT(KCmdFileSystemSubType, "FileSystemSubType");
117 TBool CT_FsData::DoCommandMountsL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
119 * Process a mounts related command read from the ini file
121 * @param aCommand the command to process
122 * @param aSection the entry in the ini file requiring the command to be processed
124 * @return ETrue if the command is processed
127 TBool retVal = ETrue;
129 if (aCommand == KCmdAddFileSystem)
131 DoCmdAddFileSystem(aSection);
133 else if (aCommand == KCmdDismountFileSystem)
135 DoCmdDismountFileSystem(aSection);
137 else if (aCommand == KCmdFileSystemName)
139 DoCmdFileSystemName(aSection);
141 else if (aCommand == KCmdMountFileSystem)
143 DoCmdMountFileSystem(aSection);
145 else if (aCommand == KCmdMountFileSystemAndScan)
147 DoCmdMountFileSystemAndScan(aSection);
149 else if (aCommand == KCmdRemoveFileSystem)
151 DoCmdRemoveFileSystem(aSection);
153 else if (aCommand == KCmdRemountDrive)
155 DoCmdRemountDriveL(aSection);
157 else if (aCommand == KCmdAddExtension)
159 DoCmdAddExtension(aSection);
161 else if (aCommand == KCmdRemoveExtension)
163 DoCmdRemoveExtension(aSection);
165 else if (aCommand == KCmdExtensionName)
167 DoCmdExtensionName(aSection);
169 else if (aCommand == KCmdMountExtension)
171 DoCmdMountExtension(aSection);
173 else if (aCommand == KCmdAllowDismount)
175 DoCmdAllowDismount(aSection);
177 else if (aCommand == KCmdNotifyDismount)
179 DoCmdNotifyDismountL(aSection, aAsyncErrorIndex);
181 else if (aCommand == KCmdNotifyDismountCancel)
183 DoCmdNotifyDismountCancel(aSection);
185 else if (aCommand == KCmdStartupInitComplete)
187 DoCmdStartupInitCompleteL(aAsyncErrorIndex);
189 else if (aCommand == KCmdSwapFileSystem)
191 DoCmdSwapFileSystem(aSection);
193 else if (aCommand == KCmdSetStartupConfiguration)
195 DoCmdSetStartupConfigurationL(aSection);
197 else if (aCommand == KCmdFinaliseDrives)
199 DoCmdFinaliseDrives();
201 else if (aCommand == KCmdAddCompositeMount)
203 DoCmdAddCompositeMount(aSection);
205 else if (aCommand == KCmdDismountExtension)
207 DoCmdDismountExtension(aSection);
209 else if (aCommand == KCmdSetLocalDriveMapping)
211 DoCmdSetLocalDriveMappingL(aSection);
213 else if (aCommand == KCmdFileSystemSubType)
215 DoCmdFileSystemSubType(aSection);
226 void CT_FsData::DoCmdAddFileSystem(const TDesC& aSection)
227 /** Calls RFs::AddFileSystem() */
229 INFO_PRINTF1(_L("Calls RFs::AddFileSystem()"));
231 // get file name from parameters
233 if ( GET_MANDATORY_STRING_PARAMETER(KFileName(), aSection, fileName))
235 // call AddFileSystem()
236 TInt err = iFs->AddFileSystem(fileName);
241 ERR_PRINTF2(_L("AddFileSystem error: %d"), err);
247 void CT_FsData::DoCmdMountFileSystem(const TDesC& aSection)
248 /** Calls RFs::MountFileSystem() */
250 INFO_PRINTF1(_L("Calls RFs::MountFileSystem()"));
252 TBool dataOk = ETrue;
254 // get drive number from parameters
255 TDriveNumber driveNumber = EDriveA;
256 if (!GetDriveNumberFromConfig(aSection, KDrive(), driveNumber))
258 ERR_PRINTF2(_L("No %S"), &KDrive());
259 SetBlockResult(EFail);
263 // get file system name from parameters
264 TPtrC fileSystemName;
265 if ( !GET_OPTIONAL_STRING_PARAMETER(KFileSystemName(), aSection, fileSystemName) )
267 fileSystemName.Set(iFileSystemName);
272 // get file system name from parameters
273 TBool isSync = EFalse;
277 TBool hasExtensionName=GET_OPTIONAL_STRING_PARAMETER(KExtensionName(), aSection, extensionName);
278 if (GET_OPTIONAL_BOOL_PARAMETER(KIsSync(), aSection, isSync))
280 if ( hasExtensionName )
282 // call MountFileSystem()
283 INFO_PRINTF5(_L("MountFileSystem(%S, %S, %d, %d)"), &fileSystemName, &extensionName, driveNumber, isSync);
284 err = iFs->MountFileSystem(fileSystemName, extensionName, driveNumber, isSync);
288 // call MountFileSystem()
289 INFO_PRINTF4(_L("MountFileSystem(%S, %d, %d)"), &fileSystemName, driveNumber, isSync);
290 err = iFs->MountFileSystem(fileSystemName, driveNumber, isSync);
295 if ( hasExtensionName )
297 // call MountFileSystem()
298 INFO_PRINTF4(_L("MountFileSystem(%S, %S, %d)"), &fileSystemName, &extensionName, driveNumber);
299 err = iFs->MountFileSystem(fileSystemName, extensionName, driveNumber);
303 // call MountFileSystem()
304 INFO_PRINTF3(_L("MountFileSystem(%S, %d)"), &fileSystemName, driveNumber);
305 err = iFs->MountFileSystem(fileSystemName, driveNumber);
311 ERR_PRINTF2(_L("MountFileSystem error: %d"), err);
318 void CT_FsData::DoCmdMountFileSystemAndScan(const TDesC& aSection)
319 /** Calls RFs::MountFileSystemAndScan() */
321 INFO_PRINTF1(_L("Calls RFs::MountFileSystemAndScan()"));
323 TBool dataOk = ETrue;
325 // get drive number from parameters
326 TDriveNumber driveNumber = EDriveA;
327 if (!GetDriveNumberFromConfig(aSection, KDrive(), driveNumber))
329 ERR_PRINTF2(_L("No %S"), &KDrive());
330 SetBlockResult(EFail);
334 // get file system name from parameters
335 TPtrC fileSystemName;
336 if ( !GET_OPTIONAL_STRING_PARAMETER(KFileSystemName(), aSection, fileSystemName) )
338 fileSystemName.Set(iFileSystemName);
344 TBool isMountSuccess = EFalse;
345 // get extension name from parameters
347 if (GET_OPTIONAL_STRING_PARAMETER(KExtensionName(), aSection, extensionName))
349 //call MountFileSystemAndScan
350 INFO_PRINTF4(_L("MountFileSystemAndScan(%S, %S, %d, isMountSuccess)"), &fileSystemName, &extensionName, driveNumber);
351 err = iFs->MountFileSystemAndScan(fileSystemName, extensionName, driveNumber, isMountSuccess);
355 //call MountFileSystemAndScan
356 INFO_PRINTF3(_L("MountFileSystemAndScan(%S, %d, isMountSuccess)"), &fileSystemName, driveNumber);
357 err = iFs->MountFileSystemAndScan(fileSystemName, driveNumber, isMountSuccess);
363 ERR_PRINTF2(_L("MountFileSystemAndScan error: %d"), err);
370 INFO_PRINTF1(_L("MountFileSystemAndScan() successfully mounted"));
374 INFO_PRINTF1(_L("MountFileSystemAndScan() not mounted"));
377 //check if mount was successful
378 TBool expected = EFalse;
379 if ( GET_OPTIONAL_BOOL_PARAMETER(KIsMountSuccess(), aSection, expected) )
381 if ( isMountSuccess!=expected )
383 ERR_PRINTF1(_L("MountFileSystemAndScan() does not match expected value"));
384 SetBlockResult(EFail);
391 void CT_FsData::DoCmdDismountFileSystem(const TDesC& aSection)
392 /** Calls RFs::DismountFileSystem() */
394 INFO_PRINTF1(_L("Calls RFs::DismountFileSystem()"));
396 TBool dataOk = ETrue;
398 // get drive number from parameters
399 TDriveNumber driveNumber = EDriveA;
400 if (!GetDriveNumberFromConfig(aSection, KDrive(), driveNumber))
402 ERR_PRINTF2(_L("No %S"), &KDrive());
403 SetBlockResult(EFail);
406 // get file system name from parameters
407 TPtrC fileSystemName;
408 if (!GET_OPTIONAL_STRING_PARAMETER(KFileSystemName(), aSection, fileSystemName))
410 fileSystemName.Set(iFileSystemName);
415 // call DismountFileSystem()
416 TInt err = iFs->DismountFileSystem(fileSystemName, driveNumber);
421 ERR_PRINTF2(_L("DismountFileSystem error: %d"), err);
428 void CT_FsData::DoCmdRemoveFileSystem(const TDesC& aSection)
429 /** Calls RFs::RemoveFileSystem() */
431 INFO_PRINTF1(_L("Calls RFs::RemoveFileSystem()"));
433 // get file name from parameters
434 TPtrC fileSystemName;
435 if ( !GET_OPTIONAL_STRING_PARAMETER(KFileSystemName(), aSection, fileSystemName) )
437 fileSystemName.Set(iFileSystemName);
440 // call RemoveFileSystem()
441 TInt err = iFs->RemoveFileSystem(fileSystemName);
446 ERR_PRINTF2(_L("RemoveFileSystem error: %d"), err);
452 void CT_FsData::DoCmdFileSystemName(const TDesC& aSection)
453 /** Calls RFs::FileSystemName() */
455 INFO_PRINTF1(_L("Calls RFs::FileSystemName()"));
457 // get a flag if we need to remember the file system name in an instance variable
459 GET_OPTIONAL_BOOL_PARAMETER(KSaveInInstance(), aSection, save);
461 // get drive number from parameters
462 TDriveNumber driveNumber = EDriveA;
463 if (!GetDriveNumberFromConfig(aSection, KDrive(), driveNumber))
465 ERR_PRINTF2(_L("No %S"), &KDrive());
466 SetBlockResult(EFail);
470 // call FileSystemName()
471 TFullName fileSystemName;
472 TInt err = iFs->FileSystemName(fileSystemName, driveNumber);
473 INFO_PRINTF2(_L("File system name: %S"), &fileSystemName);
480 iFileSystemName=fileSystemName;
485 ERR_PRINTF2(_L("FileSystemName error: %d"), err);
489 //Check expected result
491 if (GET_OPTIONAL_STRING_PARAMETER(KFileSystemName(), aSection, fsNameExpect))
493 if ( fsNameExpect != fileSystemName)
495 ERR_PRINTF1(_L("File system name != expected name"));
496 SetBlockResult(EFail);
503 void CT_FsData::DoCmdAddExtension(const TDesC& aSection)
504 /** Calls RFs::AddExtension() */
506 INFO_PRINTF1(_L("Calls RFs::AddExtension()"));
508 if ( GET_MANDATORY_STRING_PARAMETER(KFileName(), aSection, fileName) )
511 TInt err = iFs->AddExtension(fileName);
516 ERR_PRINTF2(_L("AddExtension error: %d"), err);
523 void CT_FsData::DoCmdMountExtension(const TDesC& aSection)
524 /** Calls RFs::MountExtension() */
526 INFO_PRINTF1(_L("Calls RFs::MountExtension()"));
528 TBool dataOk = ETrue;
530 // get drive number from parameters
531 TDriveNumber driveNumber = EDriveA;
532 if (!GetDriveNumberFromConfig(aSection, KDrive(), driveNumber))
534 ERR_PRINTF2(_L("No %S"), &KDrive());
535 SetBlockResult(EFail);
539 // get extension name from parameters
541 if (!GET_MANDATORY_STRING_PARAMETER(KExtensionName(), aSection, extensionName))
548 TInt err = iFs->MountExtension(extensionName, driveNumber);
551 ERR_PRINTF2(_L("MountExtension error: %d"), err);
557 void CT_FsData::DoCmdDismountExtension(const TDesC& aSection)
558 /** Calls RFs::DismountExtension() */
560 INFO_PRINTF1(_L("Calls RFs::DismountExtension()"));
562 TBool dataOk = ETrue;
564 // get drive number from parameters
565 TDriveNumber driveNumber = EDriveA;
566 if (!GetDriveNumberFromConfig(aSection, KDrive(), driveNumber))
568 ERR_PRINTF2(_L("No %S"), &KDrive());
569 SetBlockResult(EFail);
574 if (!GET_MANDATORY_STRING_PARAMETER(KExtensionName(), aSection, extensionName))
580 //call DismountExtension
581 TInt err = iFs->DismountExtension(extensionName, driveNumber);
586 ERR_PRINTF2(_L("DismountExtension error: %d"), err);
594 void CT_FsData::DoCmdRemoveExtension(const TDesC& aSection)
595 /** Calls RFs::RemoveExtension() */
597 INFO_PRINTF1(_L("Calls RFs::RemoveExtension()"));
600 if (GET_MANDATORY_STRING_PARAMETER(KExtensionName(), aSection, extensionName))
602 //call RemoveExtension
603 TInt err = iFs->RemoveExtension(extensionName);
608 ERR_PRINTF2(_L("RemoveExtension error: %d"), err);
615 void CT_FsData::DoCmdExtensionName(const TDesC& aSection)
616 /** Calls RFs::ExtensionName() */
618 INFO_PRINTF1(_L("Calls RFs::ExtensionName()"));
620 TBool dataOk = ETrue;
622 // get drive number from parameters
623 TDriveNumber driveNumber = EDriveA;
624 if (!GetDriveNumberFromConfig(aSection, KDrive(), driveNumber))
626 ERR_PRINTF2(_L("No %S"), &KDrive());
627 SetBlockResult(EFail);
630 //get position of the extension in the extension hierarchy.
632 if (!GET_MANDATORY_INT_PARAMETER(KPosition(), aSection, pos))
640 TInt err = iFs->ExtensionName(iExtensionName, driveNumber, pos);
645 if (GET_OPTIONAL_STRING_PARAMETER(KExtensionName(), aSection, extNameExpect))
647 if(extNameExpect != iExtensionName)
649 ERR_PRINTF3(_L("ExtensionName: %S != %S expected name"), &iExtensionName, &extNameExpect);
650 SetBlockResult(EFail);
654 INFO_PRINTF2(_L("ExtensionName: %S"), &iExtensionName);
659 INFO_PRINTF2(_L("ExtensionName: %S"), &iExtensionName);
665 ERR_PRINTF2(_L("ExtensionName error: %d"), err);
672 void CT_FsData::DoCmdRemountDriveL(const TDesC& aSection)
673 /** Calls RFs::RemountDrive() */
675 INFO_PRINTF1(_L("Calls RFs::RemountDrive()"));
676 TBool dataOk = ETrue;
678 // get drive number from parameters
679 TDriveNumber driveNumber = EDriveA;
680 if (!GetDriveNumberFromConfig(aSection, KDrive(), driveNumber))
682 ERR_PRINTF2(_L("No %S"), &KDrive());
683 SetBlockResult(EFail);
687 // get flags from parameters can be in hex(0x00000001) or in decimal(1)
691 if(GetHexFromConfig(aSection, KFlags, tempVal))
695 else if(GET_OPTIONAL_INT_PARAMETER(KFlags(), aSection, tempVal))
701 ERR_PRINTF2(_L("No parameter %S"), &KFlags());
702 SetBlockResult(EFail);
707 HBufC8* fileDataBuff = NULL;
709 // get file name from parameters
711 TBool useMountInfo = GET_OPTIONAL_STRING_PARAMETER(KFileName(), aSection, fileName);
715 TInt error = file.Open(FileServer(), fileName, EFileRead | EFileShareAny);
716 if(error == KErrNone)
718 CleanupClosePushL(file);
719 INFO_PRINTF1(_L("File Opened."));
722 error = file.Size(size);
723 INFO_PRINTF2(_L("File Size=%d."), size);
724 if(error == KErrNone)
727 fileDataBuff = HBufC8::NewL(size);
728 INFO_PRINTF1(_L("Buffer created."));
730 CleanupStack::PushL(fileDataBuff);
731 TPtr8 fileData = fileDataBuff->Des();
732 error = file.Read(fileData);
733 if(error != KErrNone)
735 ERR_PRINTF2(_L("Reading File, Error: %d"), error);
737 SetBlockResult(EFail);
742 ERR_PRINTF2(_L("File Size, Error: %d."), error);
744 SetBlockResult(EFail);
749 ERR_PRINTF2(_L("File Open, Error: %d"), error);
751 SetBlockResult(EFail);
757 // call RemountDrive()
758 TInt err = iFs->RemountDrive(driveNumber, fileDataBuff, flags);
759 INFO_PRINTF2(_L("RemountDrive Flags: %u"), flags);
764 ERR_PRINTF2(_L("RemountDrive error: %d"), err);
769 // cleanup if mountInfo was used
772 CleanupStack::PopAndDestroy(2, &file); // file, fileDataBuff
778 void CT_FsData::DoCmdNotifyDismountL(const TDesC& aSection, const TInt aAsyncErrorIndex)
779 /** Calls RFs::NotifyDismount() */
781 INFO_PRINTF1(_L("Calls RFs::NotifyDismount()"));
783 TNotifyDismountMode mode = EFsDismountRegisterClient;
785 //get NotifyDismountMode from parameters
786 if(GET_MANDATORY_STRING_PARAMETER(KMode(), aSection, modeStr))
788 if(modeStr == _L("EFsDismountRegisterClient"))
790 mode = EFsDismountRegisterClient;
792 else if(modeStr == _L("EFsDismountNotifyClients"))
794 mode = EFsDismountNotifyClients;
796 else if(modeStr == _L("EFsDismountForceDismount"))
798 mode = EFsDismountForceDismount;
803 if(GET_OPTIONAL_INT_PARAMETER(KMode, aSection, modeNumber))
805 mode = (TNotifyDismountMode)modeNumber;
809 ERR_PRINTF3(_L("NotifyDismount() incorrect parameter %S in %S"), &modeStr, &KMode());
810 SetBlockResult(EFail);
815 TDriveNumber driveNumber = EDriveA;
816 if (!GetDriveNumberFromConfig(aSection, KDrive(), driveNumber))
818 ERR_PRINTF2(_L("No %S"), &KDrive());
819 SetBlockResult(EFail);
823 // call NotifyDismount()
824 CActiveCallback* active = CActiveCallback::NewLC(*this);
825 iNotifyDismount.AppendL(active);
826 CleanupStack::Pop(active);
828 iFs->NotifyDismount(driveNumber, active->iStatus, mode);
829 active->Activate(aAsyncErrorIndex);
835 void CT_FsData::DoCmdNotifyDismountCancel(const TDesC& aSection)
836 /** Calls RFs::NotifyDismountCancel() */
838 INFO_PRINTF1(_L("Calls RFs::NotifyDismountCancel()"));
842 if(GET_MANDATORY_BOOL_PARAMETER(KAll(), aSection, all))
846 //Cancels all outstanding requests.
847 iFs->NotifyDismountCancel();
848 INFO_PRINTF1(_L("NotifyDismountCancel()"));
852 // Cancels a specific outstanding request
854 GET_OPTIONAL_INT_PARAMETER(KIndex, aSection, index);
856 //Cancels a specific outstanding request
857 iFs->NotifyDismountCancel(iNotifyDismount[index]->iStatus);
858 INFO_PRINTF1(_L("NotifyDismountCancel(TRequestStatus)"));
864 void CT_FsData::DoCmdAllowDismount(const TDesC& aSection)
865 /** Calls RFs::AllowDismount() */
867 INFO_PRINTF1(_L("Calls RFs::AllowDismount()"));
869 // get drive number from parameters
870 TDriveNumber driveNumber = EDriveA;
871 if(!GetDriveNumberFromConfig(aSection, KDrive(), driveNumber))
873 ERR_PRINTF2(_L("No %S"), &KDrive());
874 SetBlockResult(EFail);
879 TInt err = iFs->AllowDismount(driveNumber);
883 ERR_PRINTF2(_L("AllowDismount error: %d"), err);
890 void CT_FsData::DoCmdSetStartupConfigurationL(const TDesC& aSection)
891 /** Calls RFs::SetStartupConfiguration() */
893 INFO_PRINTF1(_L("Calls RFs::SetStartupConfiguration()"));
895 //get Command from parameters
897 TStartupConfigurationCmd configCommand = ELoaderPriority;
898 if(GET_MANDATORY_STRING_PARAMETER(KCommandNum(), aSection, commandNum))
900 //Converting from string to TStartupConfigurationCmd
901 if(commandNum == _L("ELoaderPriority"))
903 configCommand = ELoaderPriority;
905 else if(commandNum == _L("ESetRugged"))
907 configCommand = ESetRugged;
909 else if(commandNum == _L("EMaxStartupConfigurationCmd"))
911 configCommand = EMaxStartupConfigurationCmd;
915 if(GET_OPTIONAL_STRING_PARAMETER(KParam1(), aSection, name))
917 param1 = GetDataObjectL(name);
921 if(GET_OPTIONAL_STRING_PARAMETER(KParam2(), aSection, name))
923 param2 = GetDataObjectL(name);
925 //call SetStartupConfiguration
926 TInt err = iFs->SetStartupConfiguration(configCommand, param1, param2);
927 INFO_PRINTF2(_L("RFs::SetStartupConfiguration() %S"), &commandNum);
931 ERR_PRINTF2(_L("SetStartupConfiguration() error: %d"), err);
937 void CT_FsData::DoCmdAddCompositeMount(const TDesC& aSection)
939 INFO_PRINTF1(_L("Calls RFs::AddCompositeMount()"));
941 TBool dataOk = ETrue;
943 // get drive number from parameters
944 TDriveNumber localDriveToMount = EDriveA;
945 if (!GetDriveNumberFromConfig(aSection, KLocalDrive(), localDriveToMount))
947 ERR_PRINTF2(_L("No %S"), &KLocalDrive());
948 SetBlockResult(EFail);
952 // get composite drive number from parameters
953 TDriveNumber compositeDrive = EDriveA;
954 if (!GetDriveNumberFromConfig(aSection, KCompositeDrive(), compositeDrive))
956 ERR_PRINTF2(_L("No %S"), &KCompositeDrive());
957 SetBlockResult(EFail);
961 // get Sync from parameters
963 if(!GET_MANDATORY_BOOL_PARAMETER(KIsSync(), aSection, sync))
968 // get fileSystemName from parameters
969 TPtrC fileSystemName;
970 if ( !GET_OPTIONAL_STRING_PARAMETER(KFileSystemName(), aSection, fileSystemName) )
972 fileSystemName.Set(iFileSystemName);
977 TInt err = iFs->AddCompositeMount(fileSystemName, localDriveToMount, compositeDrive, sync);
978 INFO_PRINTF1(_L("Calls RFs::AddCompositeMount()"));
982 ERR_PRINTF2(_L("AddCompositeMount() error: %d"), err);
987 void CT_FsData::DoCmdStartupInitCompleteL(TInt aAsyncErrorIndex)
988 /** Calls RFs::StartupInitComplete() */
990 INFO_PRINTF1(_L("Calls RFs::StartupInitComplete()"));
992 // call StartupInitComplete()
993 CActiveCallback* active = CActiveCallback::NewLC(*this);
994 iStartupInitComplete.AppendL(active);
995 CleanupStack::Pop(active);
997 iFs->StartupInitComplete(active->iStatus);
998 active->Activate(aAsyncErrorIndex);
1003 void CT_FsData::DoCmdFinaliseDrives()
1004 /** Calls RFs::FinaliseDrives() */
1006 INFO_PRINTF1(_L("Calls RFs::FinaliseDrives()"));
1008 TInt err = iFs->FinaliseDrives();
1011 if (err != KErrNone)
1013 ERR_PRINTF2(_L("FinaliseDrives() error: %d"), err);
1019 void CT_FsData::DoCmdSetLocalDriveMappingL(const TDesC& aSection)
1020 /** Calls RFs::SetLocalDriveMapping() */
1022 INFO_PRINTF1(_L("Calls RFs::SetLocalDriveMapping()"));
1024 // get operation from config
1025 TLocalDriveMappingInfo::TDrvMapOperation operation = TLocalDriveMappingInfo::EWriteMappingsAndSet;
1026 if (!GetDrvMapOperationFromConfig(aSection, KDriveMappingOperation(), operation))
1028 ERR_PRINTF2(_L("No %S"), &KDriveMappingOperation());
1029 SetBlockResult(EFail);
1032 // create an info buffer and set the operation
1033 TLocalDriveMappingInfoBuf infoBuf;
1034 TLocalDriveMappingInfo& info = infoBuf();
1035 info.iOperation = operation;
1037 // get drive mapping array from config
1038 TInt driveMappingSize = 0;
1039 if (GET_MANDATORY_INT_PARAMETER(KDriveMappingSize(), aSection, driveMappingSize))
1041 for(TInt i = 0; i < driveMappingSize; i++)
1043 TBuf<KBufferStringLength> tmpBuff;
1045 tmpBuff.Append(KDriveMappingElement);
1046 tmpBuff.AppendNum(i);
1048 TDriveNumber driveNumber;
1049 if (GetDriveNumberFromConfig(aSection, tmpBuff, driveNumber))
1051 info.iDriveMapping[i] = driveNumber;
1052 INFO_PRINTF3(_L("Drive mapping element[%d] = %d"), i, driveNumber);
1056 ERR_PRINTF2(_L("No %S"), &tmpBuff);
1057 SetBlockResult(EFail);
1062 // call SetLocalDriveMapping()
1063 TInt err = iFs->SetLocalDriveMapping(infoBuf);
1066 if (err != KErrNone)
1068 ERR_PRINTF2(_L("SetLocalDriveMapping() error: %d"), err);
1074 void CT_FsData::DoCmdSwapFileSystem(const TDesC& aSection)
1075 /** Calls RFs::SwapFileSystem() */
1077 INFO_PRINTF1(_L("Calls RFs::SwapFileSystem()"));
1079 //get OldFileSystemName
1080 // get fileSystemName from parameters
1081 TPtrC fileSystemName;
1082 if ( !GET_OPTIONAL_STRING_PARAMETER(KFileSystemName(), aSection, fileSystemName) )
1084 fileSystemName.Set(iFileSystemName);
1087 //get NewFileSystemName
1089 if(!GET_OPTIONAL_STRING_PARAMETER(KNewFileSystemName(), aSection, newFsName))
1091 newFsName.Set(iFileSystemName);
1094 // get drive number from parameters
1095 TBool dataOk = ETrue;
1096 TDriveNumber driveNumber = EDriveA;
1097 if (!GetDriveNumberFromConfig(aSection, KDrive(), driveNumber))
1099 ERR_PRINTF2(_L("No %S"), &KDrive());
1100 SetBlockResult(EFail);
1106 TInt err = iFs->SwapFileSystem(fileSystemName, newFsName, driveNumber);
1108 if (err != KErrNone)
1110 ERR_PRINTF2(_L("SwapFileSystem() error: %d"), err);
1117 void CT_FsData::DoCmdFileSystemSubType(const TDesC& aSection)
1119 INFO_PRINTF1(_L("Calls RFs::FileSystemSubType()"));
1121 // get drive number from parameters
1122 TDriveNumber driveNumber = EDriveA;
1123 if (GetDriveNumberFromConfig(aSection, KDrive(), driveNumber))
1125 TFSName subTypeName;
1126 TInt err = iFs->FileSystemSubType(driveNumber, subTypeName);
1128 if (err != KErrNone)
1130 ERR_PRINTF2(_L("FileSystemSubType() error: %d"), err);
1135 INFO_PRINTF2(_L("FileSystemSubType() subTypeName = %S"), &subTypeName);
1136 //Check expected result
1137 TPtrC subTypeNameExpect;
1138 if (GET_OPTIONAL_STRING_PARAMETER(KSubTypeName(), aSection, subTypeNameExpect))
1140 if ( subTypeNameExpect != subTypeName)
1142 ERR_PRINTF1(_L("File system name != expected name"));
1143 SetBlockResult(EFail);
1150 ERR_PRINTF2(_L("No %S"), &KDrive());
1151 SetBlockResult(EFail);
1155 TBool CT_FsData::GetDriveNumberFromConfig(const TDesC& aSection, const TDesC& aParameterName, TDriveNumber& aDriveNumber)
1156 /** Reads drive number from INI-file */
1158 // Read drive number from INI file
1159 TPtrC driveNumberStr;
1160 TBool ret = GET_OPTIONAL_STRING_PARAMETER(aParameterName, aSection, driveNumberStr);
1163 if (driveNumberStr == KDriveA)
1165 aDriveNumber = EDriveA;
1167 else if (driveNumberStr == KDriveB)
1169 aDriveNumber = EDriveB;
1171 else if (driveNumberStr == KDriveC)
1173 aDriveNumber = EDriveC;
1175 else if (driveNumberStr == KDriveD)
1177 aDriveNumber = EDriveD;
1179 else if (driveNumberStr == KDriveE)
1181 aDriveNumber = EDriveE;
1183 else if (driveNumberStr == KDriveF)
1185 aDriveNumber = EDriveF;
1187 else if (driveNumberStr == KDriveG)
1189 aDriveNumber = EDriveG;
1191 else if (driveNumberStr == KDriveH)
1193 aDriveNumber = EDriveH;
1195 else if (driveNumberStr == KDriveI)
1197 aDriveNumber = EDriveI;
1199 else if (driveNumberStr == KDriveJ)
1201 aDriveNumber = EDriveJ;
1203 else if (driveNumberStr == KDriveK)
1205 aDriveNumber = EDriveK;
1207 else if (driveNumberStr == KDriveL)
1209 aDriveNumber = EDriveL;
1211 else if (driveNumberStr == KDriveM)
1213 aDriveNumber = EDriveM;
1215 else if (driveNumberStr == KDriveN)
1217 aDriveNumber = EDriveN;
1219 else if (driveNumberStr == KDriveO)
1221 aDriveNumber = EDriveO;
1223 else if (driveNumberStr == KDriveP) // Sorry, it's a bit long. But looks nice!
1225 aDriveNumber = EDriveP;
1227 else if (driveNumberStr == KDriveQ)
1229 aDriveNumber = EDriveQ;
1231 else if (driveNumberStr == KDriveR)
1233 aDriveNumber = EDriveR;
1235 else if (driveNumberStr == KDriveS)
1237 aDriveNumber = EDriveS;
1239 else if (driveNumberStr == KDriveT)
1241 aDriveNumber = EDriveT;
1243 else if (driveNumberStr == KDriveU)
1245 aDriveNumber = EDriveU;
1247 else if (driveNumberStr == KDriveV)
1249 aDriveNumber = EDriveV;
1251 else if (driveNumberStr == KDriveW)
1253 aDriveNumber = EDriveW;
1255 else if (driveNumberStr == KDriveX)
1257 aDriveNumber = EDriveX;
1259 else if (driveNumberStr == KDriveY)
1261 aDriveNumber = EDriveY;
1263 else if (driveNumberStr == KDriveZ)
1265 aDriveNumber = EDriveZ;
1269 TInt driveNumber = 0;
1270 ret = GET_OPTIONAL_INT_PARAMETER(aParameterName, aSection, driveNumber);
1273 aDriveNumber = (TDriveNumber) driveNumber;
1282 TBool CT_FsData::GetDrvMapOperationFromConfig(const TDesC& aSection, const TDesC& aParameterName, TLocalDriveMappingInfo::TDrvMapOperation& aOperation)
1283 /** Reads drive mapping operation name from INI-file */
1285 // Read drives mapping operation name from INI file
1287 TBool ret = GET_OPTIONAL_STRING_PARAMETER(aParameterName, aSection, operationStr);
1290 if (operationStr == KWriteMappingsAndSet)
1292 aOperation = TLocalDriveMappingInfo::EWriteMappingsAndSet;
1294 else if (operationStr == KWriteMappingsNoSet)
1296 aOperation = TLocalDriveMappingInfo::EWriteMappingsNoSet;
1298 else if (operationStr == KSwapIntMappingAndSet)
1300 aOperation = TLocalDriveMappingInfo::ESwapIntMappingAndSet;
1305 ret = GET_OPTIONAL_INT_PARAMETER(aParameterName, aSection, operation);
1308 aOperation = (TLocalDriveMappingInfo::TDrvMapOperation) operation;