diff -r f8280f3bfeb7 -r 9b2cffad4b5e creator/src/creator_fileelement.cpp --- a/creator/src/creator_fileelement.cpp Tue Sep 14 21:20:12 2010 +0300 +++ b/creator/src/creator_fileelement.cpp Wed Sep 15 12:13:45 2010 +0300 @@ -62,6 +62,97 @@ /* * */ +void CCreatorFileElement::AsyncExecuteCommandL() + { + const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount); + TInt fileAmount = 1; + if( amountAttr ) + { + fileAmount = ConvertStrToIntL(amountAttr->Value()); + } + // Get 'fields' element + CCreatorScriptElement* fieldsElement = FindSubElement(KFields); + if( fieldsElement && fieldsElement->SubElements().Count() > 0) + { + // Get sub-elements + const RPointerArray& fields = fieldsElement->SubElements(); + // Create files, the amount of files is defined by fileAmount: + if( iLoopIndex < fileAmount ) + { + CFilesParameters* param = new (ELeave) CFilesParameters; + CleanupStack::PushL( param ); + + for( TInt i = 0; i < fields.Count(); ++i ) + { + CCreatorScriptElement* field = fields[i]; + TPtrC elemName = field->Name(); + TPtrC elemContent = field->Content(); + + const CCreatorScriptAttribute* randomAttr = field->FindAttributeByName( KRandomLength ); + + if( elemName == KType ) + { + param->iFileCommand = GetFileCommandL(elemContent, randomAttr || elemContent.Length() == 0); + } + else if( elemName == KDirectory ) + { + delete param->iFullFilePath; + param->iFullFilePath = 0; + if( randomAttr == 0 && elemContent.Length() > 0 ) + { + param->iFullFilePath = elemContent.AllocL(); + } + else + { + TFileName defaultPath; + iEngine->SetDefaultPathForFileCommandL( param->iFileCommand, defaultPath ); + param->iFullFilePath = defaultPath.AllocL(); + } + } + else if ( elemName == KEncryption ) + { + ParseDRMElementsL( field, param ); + } + } + + if ( !param->iFileCommand ) + { + param->iFileCommand = ECmdCreateFileEntryEmptyFolder; + } + iEngine->AppendToCommandArrayL( param->iFileCommand, param); + CleanupStack::Pop( param ); + StartNextLoop(); + } + else + { + AsyncCommandFinished(); + } + } + else + { + _LIT(KDummy, ""); + if( iLoopIndex < fileAmount ) + { + CFilesParameters* param = new (ELeave) CFilesParameters; + CleanupStack::PushL(param); + delete param->iFullFilePath; + param->iFullFilePath = 0; + TFileName defaultPath; + param->iFileCommand = GetFileCommandL(KDummy, ETrue); + iEngine->SetDefaultPathForFileCommandL(param->iFileCommand, defaultPath); + param->iFullFilePath = defaultPath.AllocL(); + + iEngine->AppendToCommandArrayL(param->iFileCommand, param); + CleanupStack::Pop(param); + StartNextLoop(); + } + else + { + AsyncCommandFinished(); + } + } + } + void CCreatorFileElement::ExecuteCommandL() { const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount);