75 if( fieldsElement && fieldsElement->SubElements().Count() > 0) |
75 if( fieldsElement && fieldsElement->SubElements().Count() > 0) |
76 { |
76 { |
77 // Get sub-elements |
77 // Get sub-elements |
78 const RPointerArray<CCreatorScriptElement>& fields = fieldsElement->SubElements(); |
78 const RPointerArray<CCreatorScriptElement>& fields = fieldsElement->SubElements(); |
79 // Create files, the amount of files is defined by fileAmount: |
79 // Create files, the amount of files is defined by fileAmount: |
80 if( iLoopIndex < fileAmount ) |
80 for( TInt cI = 0; cI < fileAmount; ++cI ) |
81 { |
81 { |
82 CFilesParameters* param = new (ELeave) CFilesParameters; |
82 CFilesParameters* param = new (ELeave) CFilesParameters; |
83 CleanupStack::PushL( param ); |
83 CleanupStack::PushL( param ); |
84 |
84 |
85 for( TInt i = 0; i < fields.Count(); ++i ) |
85 for( TInt i = 0; i < fields.Count(); ++i ) |
119 { |
119 { |
120 param->iFileCommand = ECmdCreateFileEntryEmptyFolder; |
120 param->iFileCommand = ECmdCreateFileEntryEmptyFolder; |
121 } |
121 } |
122 iEngine->AppendToCommandArrayL( param->iFileCommand, param); |
122 iEngine->AppendToCommandArrayL( param->iFileCommand, param); |
123 CleanupStack::Pop( param ); |
123 CleanupStack::Pop( param ); |
124 StartNextLoop(); |
|
125 } |
|
126 else |
|
127 { |
|
128 AsyncCommandFinished(); |
|
129 } |
|
130 } |
|
131 else |
|
132 { |
|
133 _LIT(KDummy, ""); |
|
134 if( iLoopIndex < fileAmount ) |
|
135 { |
|
136 CFilesParameters* param = new (ELeave) CFilesParameters; |
|
137 CleanupStack::PushL(param); |
|
138 delete param->iFullFilePath; |
|
139 param->iFullFilePath = 0; |
|
140 TFileName defaultPath; |
|
141 param->iFileCommand = GetFileCommandL(KDummy, ETrue); |
|
142 iEngine->SetDefaultPathForFileCommandL(param->iFileCommand, defaultPath); |
|
143 param->iFullFilePath = defaultPath.AllocL(); |
|
144 |
|
145 iEngine->AppendToCommandArrayL(param->iFileCommand, param); |
|
146 CleanupStack::Pop(param); |
|
147 StartNextLoop(); |
|
148 } |
|
149 else |
|
150 { |
|
151 AsyncCommandFinished(); |
|
152 } |
|
153 } |
|
154 } |
|
155 |
|
156 void CCreatorFileElement::ExecuteCommandL() |
|
157 { |
|
158 const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount); |
|
159 TInt fileAmount = 1; |
|
160 if( amountAttr ) |
|
161 { |
|
162 fileAmount = ConvertStrToIntL(amountAttr->Value()); |
|
163 } |
|
164 // Get 'fields' element |
|
165 CCreatorScriptElement* fieldsElement = FindSubElement(KFields); |
|
166 if( fieldsElement && fieldsElement->SubElements().Count() > 0) |
|
167 { |
|
168 // Get sub-elements |
|
169 const RPointerArray<CCreatorScriptElement>& fields = fieldsElement->SubElements(); |
|
170 // Create files, the amount of files is defined by fileAmount: |
|
171 for( TInt cI = 0; cI < fileAmount; ++cI ) |
|
172 { |
|
173 CFilesParameters* param = new (ELeave) CFilesParameters; |
|
174 CleanupStack::PushL( param ); |
|
175 |
|
176 for( TInt i = 0; i < fields.Count(); ++i ) |
|
177 { |
|
178 CCreatorScriptElement* field = fields[i]; |
|
179 TPtrC elemName = field->Name(); |
|
180 TPtrC elemContent = field->Content(); |
|
181 |
|
182 const CCreatorScriptAttribute* randomAttr = field->FindAttributeByName( KRandomLength ); |
|
183 |
|
184 if( elemName == KType ) |
|
185 { |
|
186 param->iFileCommand = GetFileCommandL(elemContent, randomAttr || elemContent.Length() == 0); |
|
187 } |
|
188 else if( elemName == KDirectory ) |
|
189 { |
|
190 delete param->iFullFilePath; |
|
191 param->iFullFilePath = 0; |
|
192 if( randomAttr == 0 && elemContent.Length() > 0 ) |
|
193 { |
|
194 param->iFullFilePath = elemContent.AllocL(); |
|
195 } |
|
196 else |
|
197 { |
|
198 TFileName defaultPath; |
|
199 iEngine->SetDefaultPathForFileCommandL( param->iFileCommand, defaultPath ); |
|
200 param->iFullFilePath = defaultPath.AllocL(); |
|
201 } |
|
202 } |
|
203 else if ( elemName == KEncryption ) |
|
204 { |
|
205 ParseDRMElementsL( field, param ); |
|
206 } |
|
207 } |
|
208 |
|
209 if ( !param->iFileCommand ) |
|
210 { |
|
211 param->iFileCommand = ECmdCreateFileEntryEmptyFolder; |
|
212 } |
|
213 iEngine->AppendToCommandArrayL( param->iFileCommand, param); |
|
214 CleanupStack::Pop( param ); |
|
215 } |
124 } |
216 } |
125 } |
217 else |
126 else |
218 { |
127 { |
219 _LIT(KDummy, ""); |
128 _LIT(KDummy, ""); |