119 if ( iFilePaths && iFilePaths->Count() ) |
122 if ( iFilePaths && iFilePaths->Count() ) |
120 { |
123 { |
121 TRAP_IGNORE( StorePathsForDeleteL( *iFilePaths ) ); |
124 TRAP_IGNORE( StorePathsForDeleteL( *iFilePaths ) ); |
122 } |
125 } |
123 delete iFilePaths; |
126 delete iFilePaths; |
124 delete iDirectoryQueriedFromUser; |
|
125 delete iParameters; |
127 delete iParameters; |
126 delete iUserParameters; |
128 delete iUserParameters; |
127 iApaLs.Close(); |
129 iApaLs.Close(); |
128 } |
130 } |
129 |
131 |
130 //---------------------------------------------------------------------------- |
132 //---------------------------------------------------------------------------- |
131 |
133 |
|
134 void CCreatorFiles::QueryDialogClosedL(TBool aPositiveAction, TInt aUserData) |
|
135 { |
|
136 LOGSTRING("Creator: CCreatorFiles::QueryDialogClosedL"); |
|
137 |
|
138 if( aPositiveAction == EFalse ) |
|
139 { |
|
140 iEngine->ShutDownEnginesL(); |
|
141 return; |
|
142 } |
|
143 |
|
144 const TDesC* showText = &KSavingText; |
|
145 TBool finished(EFalse); |
|
146 TBool retval(ETrue); |
|
147 switch(aUserData) |
|
148 { |
|
149 case ECreatorFilesDelete: |
|
150 showText = &KDeletingText; |
|
151 iEntriesToBeCreated = 1; |
|
152 finished = ETrue; |
|
153 break; |
|
154 case ECreatorFilesStart: |
|
155 { |
|
156 // set a default directory (eg. c:\Nokia\Images\) |
|
157 iEngine->SetDefaultPathForFileCommandL(iCommand, iDirectoryQueriedFromUser); |
|
158 TBuf<50> promptText; |
|
159 if (iCommand == ECmdCreateFileEntryEmptyFolder) |
|
160 promptText.Copy( _L("Specify the folder path and name") ); |
|
161 else |
|
162 promptText.Copy( _L("Specify the directory") ); |
|
163 |
|
164 // show directory query dialog |
|
165 retval = iEngine->GetEngineWrapper()->DirectoryQueryDialog(promptText, iDirectoryQueriedFromUser, this, ECreatorFilesGetDirectory ); |
|
166 } |
|
167 break; |
|
168 case ECreatorFilesGetDirectory: |
|
169 // check that the root folder is correct |
|
170 if ( iDirectoryQueriedFromUser.Length() < 3 || BaflUtils::CheckFolder( iFs, iDirectoryQueriedFromUser.Left(3) ) != KErrNone ) |
|
171 { |
|
172 iEngine->GetEngineWrapper()->ShowErrorMessage(_L("Invalid path")); |
|
173 retval = EFalse; |
|
174 } |
|
175 else |
|
176 { |
|
177 // check the directory contains a trailing backlash |
|
178 if ( iDirectoryQueriedFromUser.Right(1) != _L("\\") ) |
|
179 { |
|
180 iDirectoryQueriedFromUser.Append(_L("\\")); |
|
181 } |
|
182 // copy the directory name to a class member |
|
183 if ( iCommand == ECmdCreateFileEntryEmptyFolder ) |
|
184 { |
|
185 finished = ETrue; |
|
186 } |
|
187 else |
|
188 { |
|
189 retval = AskDRMDataFromUserL(); |
|
190 } |
|
191 } |
|
192 break; |
|
193 case ECreatorFilesAskDRMData: |
|
194 if ( iDummy > 0 ) |
|
195 { |
|
196 iUserParameters->iEncrypt = ETrue; |
|
197 } |
|
198 if ( iDummy == 2 ) |
|
199 { |
|
200 iUserParameters->iPermission = CDRMPermission::NewL(); |
|
201 CDRMPermission* perm = iUserParameters->iPermission; |
|
202 perm->iTopLevel->iActiveConstraints = EConstraintNone; |
|
203 perm->iPlay->iActiveConstraints = EConstraintNone; |
|
204 perm->iDisplay->iActiveConstraints = EConstraintNone; |
|
205 perm->iPrint->iActiveConstraints = EConstraintNone; |
|
206 perm->iExecute->iActiveConstraints = EConstraintNone; |
|
207 perm->iUniqueID = 0; |
|
208 // DRM Combined Delivery |
|
209 iDummy = 0; |
|
210 retval = iEngine->GetEngineWrapper()->EntriesQueryDialog( &iDummy, _L("How many counts(0=unlimited)?"), ETrue, this, ECreatorFilesAskDRM_CD_Counts ); |
|
211 } |
|
212 else |
|
213 { |
|
214 finished = ETrue; |
|
215 } |
|
216 break; |
|
217 case ECreatorFilesAskDRM_CD_Counts: |
|
218 if ( iDummy > 0 ) |
|
219 { |
|
220 TInt count = iDummy; |
|
221 CDRMPermission* perm = iUserParameters->iPermission; |
|
222 // apply constraints to all permission types |
|
223 // applied type will be selected by setting iAvailableRights |
|
224 // when determining the file type |
|
225 perm->iDisplay->iActiveConstraints |= EConstraintCounter; |
|
226 perm->iDisplay->iCounter = count; |
|
227 perm->iDisplay->iOriginalCounter = count; |
|
228 |
|
229 perm->iPlay->iActiveConstraints |= EConstraintCounter; |
|
230 perm->iPlay->iCounter = count; |
|
231 perm->iPlay->iOriginalCounter = count; |
|
232 |
|
233 perm->iPrint->iActiveConstraints |= EConstraintCounter; |
|
234 perm->iPrint->iCounter = count; |
|
235 perm->iPrint->iOriginalCounter = count; |
|
236 |
|
237 perm->iExecute->iActiveConstraints |= EConstraintCounter; |
|
238 perm->iExecute->iCounter = count; |
|
239 perm->iExecute->iOriginalCounter = count; |
|
240 } |
|
241 iDummy = 0; |
|
242 retval = iEngine->GetEngineWrapper()->EntriesQueryDialog( &iDummy, _L("How many minutes until expire(0=unlimited)?"), ETrue, |
|
243 this, ECreatorFilesAskDRM_CD_Minutes |
|
244 ); |
|
245 break; |
|
246 case ECreatorFilesAskDRM_CD_Minutes: |
|
247 if ( iDummy > 0 ) |
|
248 { |
|
249 TInt minutes = iDummy; |
|
250 CDRMPermission* perm = iUserParameters->iPermission; |
|
251 // apply constraints to all permission types |
|
252 // applied type will be selected by setting iAvailableRights |
|
253 // when determining the file type |
|
254 perm->iDisplay->iActiveConstraints |= EConstraintInterval; |
|
255 perm->iDisplay->iInterval = TTimeIntervalSeconds( 60 * minutes ); |
|
256 perm->iDisplay->iIntervalStart = Time::NullTTime(); |
|
257 |
|
258 perm->iPlay->iActiveConstraints |= EConstraintInterval; |
|
259 perm->iPlay->iInterval = TTimeIntervalSeconds( 60 * minutes ); |
|
260 perm->iPlay->iIntervalStart = Time::NullTTime(); |
|
261 |
|
262 perm->iPrint->iActiveConstraints |= EConstraintInterval; |
|
263 perm->iPrint->iInterval = TTimeIntervalSeconds( 60 * minutes ); |
|
264 perm->iPrint->iIntervalStart = Time::NullTTime(); |
|
265 |
|
266 perm->iExecute->iActiveConstraints |= EConstraintInterval; |
|
267 perm->iExecute->iInterval = TTimeIntervalSeconds( 60 * minutes ); |
|
268 perm->iExecute->iIntervalStart = Time::NullTTime(); |
|
269 } |
|
270 finished = ETrue; |
|
271 break; |
|
272 default: |
|
273 //some error |
|
274 retval = EFalse; |
|
275 break; |
|
276 } |
|
277 if( retval == EFalse ) |
|
278 { |
|
279 iEngine->ShutDownEnginesL(); |
|
280 } |
|
281 else if( finished ) |
|
282 { |
|
283 // add this command to command array |
|
284 iEngine->AppendToCommandArrayL(iCommand, NULL, iEntriesToBeCreated); |
|
285 // started exucuting commands |
|
286 iEngine->ExecuteFirstCommandL( *showText ); |
|
287 } |
|
288 } |
|
289 |
|
290 //---------------------------------------------------------------------------- |
|
291 |
132 TBool CCreatorFiles::AskDataFromUserL(TInt aCommand) |
292 TBool CCreatorFiles::AskDataFromUserL(TInt aCommand) |
133 { |
293 { |
134 LOGSTRING("Creator: CCreatorFiles::AskDataFromUserL"); |
294 LOGSTRING("Creator: CCreatorFiles::AskDataFromUserL"); |
135 |
295 |
136 CCreatorModuleBase::AskDataFromUserL( aCommand ); |
296 CCreatorModuleBase::AskDataFromUserL( aCommand ); |
137 |
297 |
138 if ( aCommand == ECmdDeleteCreatorFiles ) |
298 if ( aCommand == ECmdDeleteCreatorFiles ) |
139 { |
299 { |
140 return iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all files created with Creator?") ); |
300 return iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all files created with Creator?"), this, ECreatorFilesDelete ); |
141 } |
301 } |
142 |
302 |
143 delete iUserParameters; |
303 delete iUserParameters; |
144 iUserParameters = NULL; |
304 iUserParameters = NULL; |
145 iUserParameters = new(ELeave) CFilesParameters(); |
305 iUserParameters = new(ELeave) CFilesParameters(); |
146 |
306 |
147 iDirectoryQueriedFromUser->Des().Copy( KNullDesC ); |
307 iDirectoryQueriedFromUser.Copy( KNullDesC ); |
148 |
308 |
149 if (iEngine->GetEngineWrapper()->EntriesQueryDialog(&iEntriesToBeCreated, _L("How many entries to create?"))) |
309 return iEngine->GetEngineWrapper()->EntriesQueryDialog(&iEntriesToBeCreated, _L("How many entries to create?"), EFalse, this, ECreatorFilesStart ); |
150 { |
|
151 // set a default directory (eg. c:\Nokia\Images\) |
|
152 TFileName directory; |
|
153 iEngine->SetDefaultPathForFileCommandL(aCommand, directory); |
|
154 |
|
155 // directory query dialog |
|
156 /* |
|
157 CAknTextQueryDialog* textDialog = CAknTextQueryDialog::NewL(directory, CAknQueryDialog::ENoTone); |
|
158 textDialog->SetMaxLength(256); |
|
159 */ |
|
160 |
|
161 TBuf<50> promptText; |
|
162 |
|
163 if (aCommand == ECmdCreateFileEntryEmptyFolder) |
|
164 promptText.Copy( _L("Specify the folder path and name") ); |
|
165 else |
|
166 promptText.Copy( _L("Specify the directory") ); |
|
167 // show directory query dialog |
|
168 if (iEngine->GetEngineWrapper()->DirectoryQueryDialog(promptText, directory)) |
|
169 { |
|
170 // check that the root folder is correct |
|
171 if (directory.Length() < 3 || BaflUtils::CheckFolder(iFs, directory.Left(3)) != KErrNone) |
|
172 { |
|
173 iEngine->GetEngineWrapper()->ShowErrorMessage(_L("Invalid path")); |
|
174 return EFalse; |
|
175 } |
|
176 else |
|
177 { |
|
178 // check the directory contains a trailing backlash |
|
179 if (directory.Right(1) != _L("\\")) |
|
180 directory.Append(_L("\\")); |
|
181 |
|
182 // copy the directory name to a class member |
|
183 iDirectoryQueriedFromUser->Des() = directory; |
|
184 if ( aCommand == ECmdCreateFileEntryEmptyFolder ) return ETrue; |
|
185 else return AskDRMDataFromUserL(); |
|
186 } |
|
187 } |
|
188 else |
|
189 return EFalse; |
|
190 } |
|
191 else |
|
192 return EFalse; |
|
193 |
|
194 } |
310 } |
195 |
311 |
196 |
312 |
197 //---------------------------------------------------------------------------- |
313 //---------------------------------------------------------------------------- |
198 |
314 |
559 |
675 |
560 TBool CCreatorFiles::AskDRMDataFromUserL() |
676 TBool CCreatorFiles::AskDRMDataFromUserL() |
561 { |
677 { |
562 LOGSTRING("Creator: CCreatorFiles::AskDRMDataFromUserL"); |
678 LOGSTRING("Creator: CCreatorFiles::AskDRMDataFromUserL"); |
563 // Encryption -dialog |
679 // Encryption -dialog |
564 TInt encIndex( 0 ); |
|
565 |
|
566 |
|
567 //CAknListQueryDialog* encDlg = new (ELeave) CAknListQueryDialog( &encIndex ); |
|
568 //encDlg->PrepareLC( R_ENCRYPTION_DIALOG ); |
|
569 //Create flat array from which list is built. |
|
570 CDesCArrayFlat* items = new(ELeave) CDesCArrayFlat(5); |
680 CDesCArrayFlat* items = new(ELeave) CDesCArrayFlat(5); |
571 CleanupStack::PushL(items); |
681 CleanupStack::PushL(items); |
572 |
682 |
573 // Add entires to list |
683 // Add entires to list |
574 items->AppendL( _L("None") ); |
684 items->AppendL( _L("None") ); |
575 items->AppendL( _L("DRM Forward Lock") ); |
685 items->AppendL( _L("DRM Forward Lock") ); |
576 items->AppendL( _L("DRM Combined Delivery") ); |
686 items->AppendL( _L("DRM Combined Delivery") ); |
577 |
687 |
578 // Add items into main list |
688 |
579 //encDlg->SetOwnershipType( ELbmOwnsItemArray ); |
|
580 //encDlg->SetItemTextArray( items ); |
|
581 CleanupStack::Pop( items ); |
|
582 //encDlg->ListBox()->SetCurrentItemIndexAndDraw( 0 ); |
|
583 |
|
584 // create a popup list |
689 // create a popup list |
585 if ( iEngine->GetEngineWrapper()->PopupListDialog(_L("Encryption"), items, &encIndex, this, 1) ) |
690 iDummy = 0; |
586 { |
691 TBool retval = iEngine->GetEngineWrapper()->PopupListDialog(_L("Encryption"), items, &iDummy, this, ECreatorFilesAskDRMData ); |
587 if ( encIndex > 0 ) |
692 CleanupStack::PopAndDestroy( items ); |
588 { |
693 return retval; |
589 iUserParameters->iEncrypt = ETrue; |
|
590 } |
|
591 if ( encIndex == 2 ) |
|
592 { |
|
593 iUserParameters->iPermission = CDRMPermission::NewL(); |
|
594 CDRMPermission* perm = iUserParameters->iPermission; |
|
595 perm->iTopLevel->iActiveConstraints = EConstraintNone; |
|
596 perm->iPlay->iActiveConstraints = EConstraintNone; |
|
597 perm->iDisplay->iActiveConstraints = EConstraintNone; |
|
598 perm->iPrint->iActiveConstraints = EConstraintNone; |
|
599 perm->iExecute->iActiveConstraints = EConstraintNone; |
|
600 perm->iUniqueID = 0; |
|
601 // DRM Combined Delivery |
|
602 return AskDRMCDDataFromUserL(); |
|
603 } |
|
604 return ETrue; |
|
605 } |
|
606 else |
|
607 { |
|
608 return EFalse; |
|
609 } |
|
610 } |
|
611 |
|
612 //---------------------------------------------------------------------------- |
|
613 |
|
614 TBool CCreatorFiles::AskDRMCDDataFromUserL() |
|
615 { |
|
616 LOGSTRING("Creator: CCreatorFiles::AskDRMCDDataFromUserL"); |
|
617 TInt count(0); |
|
618 if ( iEngine->GetEngineWrapper()->EntriesQueryDialog( &iDummy, _L("How many counts\r\n(0=unlimited)?"), ETrue ) ) |
|
619 { |
|
620 if ( count > 0 ) |
|
621 { |
|
622 CDRMPermission* perm = iUserParameters->iPermission; |
|
623 // apply constraints to all permission types |
|
624 // applied type will be selected by setting iAvailableRights |
|
625 // when determining the file type |
|
626 perm->iDisplay->iActiveConstraints |= EConstraintCounter; |
|
627 perm->iDisplay->iCounter = count; |
|
628 perm->iDisplay->iOriginalCounter = count; |
|
629 |
|
630 perm->iPlay->iActiveConstraints |= EConstraintCounter; |
|
631 perm->iPlay->iCounter = count; |
|
632 perm->iPlay->iOriginalCounter = count; |
|
633 |
|
634 perm->iPrint->iActiveConstraints |= EConstraintCounter; |
|
635 perm->iPrint->iCounter = count; |
|
636 perm->iPrint->iOriginalCounter = count; |
|
637 |
|
638 perm->iExecute->iActiveConstraints |= EConstraintCounter; |
|
639 perm->iExecute->iCounter = count; |
|
640 perm->iExecute->iOriginalCounter = count; |
|
641 } |
|
642 } |
|
643 else |
|
644 { |
|
645 return EFalse; |
|
646 } |
|
647 /* |
|
648 TInt seconds( 0 ); |
|
649 if ( iEngine->GetEngineWrapper()->EntriesQueryDialog( seconds, _L("How many accumulated seconds until expire (0=unlimited)?"), ETrue ) ) |
|
650 { |
|
651 if ( seconds > 0 ) |
|
652 { |
|
653 CDRMPermission* perm = iUserParameters->iPermission; |
|
654 // apply constraints to all permission types |
|
655 // applied type will be selected by setting iAvailableRights |
|
656 // when determining the file type |
|
657 perm->iDisplay->iActiveConstraints |= EConstraintAccumulated; |
|
658 perm->iDisplay->iEndTime = Time::MaxTTime(); |
|
659 perm->iDisplay->iStartTime = Time::MinTTime();; |
|
660 perm->iDisplay->iAccumulatedTime = seconds; |
|
661 |
|
662 perm->iPlay->iActiveConstraints |= EConstraintAccumulated; |
|
663 perm->iPlay->iEndTime = Time::MaxTTime(); |
|
664 perm->iPlay->iStartTime = Time::MinTTime();; |
|
665 perm->iPlay->iAccumulatedTime = seconds; |
|
666 |
|
667 perm->iPrint->iActiveConstraints |= EConstraintAccumulated; |
|
668 perm->iPrint->iEndTime = Time::MaxTTime(); |
|
669 perm->iPrint->iStartTime = Time::MinTTime();; |
|
670 perm->iPrint->iAccumulatedTime = seconds; |
|
671 |
|
672 perm->iExecute->iActiveConstraints |= EConstraintAccumulated; |
|
673 perm->iExecute->iEndTime = Time::MaxTTime(); |
|
674 perm->iExecute->iStartTime = Time::MinTTime();; |
|
675 perm->iExecute->iAccumulatedTime = seconds; |
|
676 } |
|
677 } |
|
678 else |
|
679 { |
|
680 return EFalse; |
|
681 } |
|
682 */ |
|
683 |
|
684 TInt minutes( 0 ); |
|
685 if ( iEngine->GetEngineWrapper()->EntriesQueryDialog( &iDummy, _L("How many minutes until expire (0=unlimited)?"), ETrue ) ) |
|
686 { |
|
687 if ( minutes > 0 ) |
|
688 { |
|
689 CDRMPermission* perm = iUserParameters->iPermission; |
|
690 // apply constraints to all permission types |
|
691 // applied type will be selected by setting iAvailableRights |
|
692 // when determining the file type |
|
693 perm->iDisplay->iActiveConstraints |= EConstraintInterval; |
|
694 perm->iDisplay->iInterval = TTimeIntervalSeconds( 60 * minutes ); |
|
695 perm->iDisplay->iIntervalStart = Time::NullTTime(); |
|
696 |
|
697 perm->iPlay->iActiveConstraints |= EConstraintInterval; |
|
698 perm->iPlay->iInterval = TTimeIntervalSeconds( 60 * minutes ); |
|
699 perm->iPlay->iIntervalStart = Time::NullTTime(); |
|
700 |
|
701 perm->iPrint->iActiveConstraints |= EConstraintInterval; |
|
702 perm->iPrint->iInterval = TTimeIntervalSeconds( 60 * minutes ); |
|
703 perm->iPrint->iIntervalStart = Time::NullTTime(); |
|
704 |
|
705 perm->iExecute->iActiveConstraints |= EConstraintInterval; |
|
706 perm->iExecute->iInterval = TTimeIntervalSeconds( 60 * minutes ); |
|
707 perm->iExecute->iIntervalStart = Time::NullTTime(); |
|
708 } |
|
709 } |
|
710 else |
|
711 { |
|
712 return EFalse; |
|
713 } |
|
714 |
|
715 return ETrue; |
|
716 } |
694 } |
717 |
695 |
718 //---------------------------------------------------------------------------- |
696 //---------------------------------------------------------------------------- |
719 void CCreatorFiles::DeleteAllL() |
697 void CCreatorFiles::DeleteAllL() |
720 { |
698 { |