16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 |
19 |
20 #include <aknlists.h> |
20 #include <aknlists.h> |
21 #include <aknsskininstance.h> |
21 #include <AknsSkinInstance.h> |
22 #include <data_caging_path_literals.hrh> |
22 #include <data_caging_path_literals.hrh> |
23 |
23 |
24 #include "engine.h" |
24 #include "engine.h" |
25 #include "enginewrapper.h" |
25 #include "enginewrapper.h" |
26 #include "creator_traces.h" |
26 #include "creator_traces.h" |
27 #include "creator_factory.h" |
27 #include "creator_factory.h" |
|
28 #include "creator_scriptentry.h" |
28 |
29 |
29 |
30 |
30 |
31 |
31 const TInt KReadBufSize = 8192; |
32 const TInt KReadBufSize = 8192; |
32 |
33 |
66 |
67 |
67 CCommandParser::~CCommandParser() |
68 CCommandParser::~CCommandParser() |
68 { |
69 { |
69 LOGSTRING("Creator: CCommandParser::~CCommandParser"); |
70 LOGSTRING("Creator: CCommandParser::~CCommandParser"); |
70 |
71 |
71 if (iSearchArray) |
72 if (iSearchArray){ |
72 delete iSearchArray; |
73 delete iSearchArray; |
|
74 iSearchArray = NULL; |
|
75 } |
73 |
76 |
74 if (iReadBuf) |
77 if (iReadBuf) |
75 delete iReadBuf; |
78 delete iReadBuf; |
76 } |
79 } |
77 |
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 |
|
83 void CCommandParser::QueryDialogClosedL(TBool aPositiveAction, TInt aUserData) |
|
84 { |
|
85 User::LeaveIfNull(iSearchArray); |
|
86 |
|
87 if( aUserData == EGetingScript && aPositiveAction && iSearchArray->Count() ) |
|
88 { |
|
89 iObserver->FileChosenL( ETrue, iSearchArray->MdcaPoint(iSelectedItem) ); |
|
90 } |
|
91 else if( aUserData == EGetingRandomDataFile && aPositiveAction && iSearchArray->Count() ) |
|
92 { |
|
93 TFileName fileName; |
|
94 if (iSelectedItem == (iSearchArray->Count() - 1)) |
|
95 { |
|
96 // "default" (resource file) selected |
|
97 fileName.Copy(KNullDesC); |
|
98 } |
|
99 else |
|
100 { |
|
101 // xml file selected |
|
102 fileName.Copy(iSearchArray->MdcaPoint(iSelectedItem)); |
|
103 } |
|
104 iObserver->FileChosenL( ETrue, fileName ); |
|
105 } |
|
106 else |
|
107 { |
|
108 iObserver->FileChosenL( EFalse ); |
|
109 } |
|
110 delete iSearchArray; |
|
111 iSearchArray = NULL; |
|
112 iObserver = NULL; |
|
113 } |
78 |
114 |
79 // --------------------------------------------------------------------------- |
115 // --------------------------------------------------------------------------- |
80 //#if(!defined __SERIES60_30__ && !defined __SERIES60_31__) |
116 //#if(!defined __SERIES60_30__ && !defined __SERIES60_31__) |
81 void CCommandParser::OpenScriptL() {} |
117 void CCommandParser::OpenScriptL() {} |
82 TBool CCommandParser::OpenScriptL(RFile& aScriptFile) |
118 TBool CCommandParser::OpenScriptL(MCommandParserObserver* aObserver) |
83 { |
119 { |
84 LOGSTRING("Creator: CCommandParser::OpenScriptL"); |
120 LOGSTRING("Creator: CCommandParser::OpenScriptL"); |
|
121 |
|
122 User::LeaveIfNull( aObserver ); |
|
123 iObserver = aObserver; |
|
124 iSelectedItem = 0; |
|
125 |
85 TBool ret = EFalse; |
126 TBool ret = EFalse; |
86 |
127 |
87 // init the search array |
128 // init the search array |
88 iSearchArray = new(ELeave) CDesCArrayFlat(500); |
129 delete iSearchArray; |
|
130 iSearchArray = new(ELeave) CDesCArrayFlat(20); |
89 |
131 |
90 // wait dialog |
132 // wait dialog |
91 // TODO |
133 // TODO |
92 //CAknGlobalNote* waitDialog = CAknGlobalNote::NewLC(); |
134 //CAknGlobalNote* waitDialog = CAknGlobalNote::NewLC(); |
93 //waitDialog->SetSoftkeys(R_AVKON_SOFTKEYS_CANCEL); |
135 //waitDialog->SetSoftkeys(R_AVKON_SOFTKEYS_CANCEL); |
152 else |
194 else |
153 { |
195 { |
154 fileNameArray->AppendL(filename.Name()); |
196 fileNameArray->AppendL(filename.Name()); |
155 } |
197 } |
156 } |
198 } |
157 CleanupStack::Pop(fileNameArray); |
199 |
158 |
200 ret = iEngine->GetEngineWrapper()->PopupListDialog(_L("Select script"), fileNameArray, &iSelectedItem, this, EGetingScript); |
159 |
201 CleanupStack::PopAndDestroy(fileNameArray); |
160 // create a popup list |
|
161 int index = 0; |
|
162 TBool result = iEngine->GetEngineWrapper()->PopupListDialog(_L("Select script"), fileNameArray, index); |
|
163 //CAknSinglePopupMenuStyleListBox* listBox = new(ELeave) CAknSinglePopupMenuStyleListBox; |
|
164 //CleanupStack::PushL(listBox); |
|
165 |
|
166 //CAknPopupList* popupList = CAknPopupList::NewL( listBox, R_AVKON_SOFTKEYS_SELECT_CANCEL, AknPopupLayouts::EMenuWindow ); |
|
167 //CleanupStack::PushL(popupList); |
|
168 //popupList->SetTitleL(_L("Select script")); |
|
169 //listBox->ConstructL( popupList, EAknListBoxSelectionList|EAknListBoxLoopScrolling ); |
|
170 //listBox->CreateScrollBarFrameL( ETrue ); |
|
171 //listBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); |
|
172 //listBox->Model()->SetItemTextArray( fileNameArray ); |
|
173 //listBox->Model()->SetOwnershipType( ELbmOwnsItemArray ); // !!! |
|
174 //listBox->HandleItemAdditionL(); |
|
175 |
|
176 |
|
177 // define MMC icon |
|
178 //MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
179 //_LIT( KFLDMemoryCardUiBitmapFile, "z:aknmemorycardui.mbm" ); |
|
180 //CAknIconArray* iconArray = new( ELeave ) CAknIconArray( 1 ); |
|
181 //listBox->ItemDrawer()->ColumnData()->SetIconArray( iconArray ); |
|
182 |
|
183 //TParse* fp = new(ELeave) TParse(); |
|
184 //fp->Set(KFLDMemoryCardUiBitmapFile, &KDC_APP_BITMAP_DIR, NULL); |
|
185 //TFileName resourceFileName( fp->FullName() ); |
|
186 //delete fp; |
|
187 |
|
188 //CGulIcon* icon = AknsUtils::CreateGulIconL( skin, KAknsIIDQgnIndiMmcAdd, |
|
189 // resourceFileName, |
|
190 // EMbmAknmemorycarduiQgn_indi_mmc_add, |
|
191 // EMbmAknmemorycarduiQgn_indi_mmc_add_mask ); |
|
192 //CleanupStack::PushL( icon ); |
|
193 //iconArray->AppendL( icon ); |
|
194 //CleanupStack::Pop( icon ); |
|
195 |
|
196 // execute dialog |
|
197 //TBool result; // = popupList->ExecuteLD(); |
|
198 //CleanupStack::Pop(); // popupList |
|
199 |
|
200 if ( result ) |
|
201 { |
|
202 // open the file for reading |
|
203 //RFile file; |
|
204 TRAPD(err, aScriptFile.Open(CEikonEnv::Static()->FsSession(), iSearchArray->MdcaPoint(index), EFileRead)); |
|
205 if( err != KErrNone) |
|
206 { |
|
207 aScriptFile.Close(); |
|
208 User::Leave(err); |
|
209 } |
|
210 ret = ETrue; |
|
211 } |
|
212 //CleanupStack::PopAndDestroy(); //listBox |
|
213 } |
202 } |
214 else // no scripts found from the search paths |
203 else // no scripts found from the search paths |
215 { |
204 { |
216 iEngine->GetEngineWrapper()->ShowNote(_L("No scripts found")); |
205 iEngine->GetEngineWrapper()->ShowNote(_L("No scripts found")); |
217 } |
206 delete iSearchArray; |
218 |
207 iSearchArray = NULL; |
219 delete iSearchArray; |
208 } |
220 iSearchArray = NULL; |
209 |
|
210 |
221 return ret; |
211 return ret; |
222 } |
212 } |
223 /* |
213 /* |
224 #else |
214 #else |
225 // --------------------------------------------------------------------------- |
215 // --------------------------------------------------------------------------- |
474 } |
464 } |
475 |
465 |
476 // add "default" (resource file) to list |
466 // add "default" (resource file) to list |
477 fileNameArray->AppendL(_L("Default")); |
467 fileNameArray->AppendL(_L("Default")); |
478 |
468 |
479 CleanupStack::Pop(fileNameArray); |
469 ret = iEngine->GetEngineWrapper()->PopupListDialog(_L("Select random data file"), fileNameArray, &iSelectedItem, this); |
480 |
470 CleanupStack::PopAndDestroy(fileNameArray); |
481 // create a popup list |
|
482 int index = 0; |
|
483 TBool result = iEngine->GetEngineWrapper()->PopupListDialog(_L("Select random data file"), fileNameArray, index); |
|
484 /* |
|
485 CAknSinglePopupMenuStyleListBox* listBox = new(ELeave) CAknSinglePopupMenuStyleListBox; |
|
486 CleanupStack::PushL(listBox); |
|
487 CAknPopupList* popupList = CAknPopupList::NewL( listBox, R_AVKON_SOFTKEYS_SELECT_CANCEL, AknPopupLayouts::EMenuWindow ); |
|
488 CleanupStack::PushL(popupList); |
|
489 popupList->SetTitleL(_L("Select random data file")); |
|
490 listBox->ConstructL( popupList, EAknListBoxSelectionList|EAknListBoxLoopScrolling ); |
|
491 listBox->CreateScrollBarFrameL( ETrue ); |
|
492 listBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); |
|
493 listBox->Model()->SetItemTextArray( fileNameArray ); |
|
494 listBox->Model()->SetOwnershipType( ELbmOwnsItemArray ); // !!! |
|
495 listBox->HandleItemAdditionL(); |
|
496 |
|
497 |
|
498 // define MMC icon |
|
499 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
500 _LIT( KFLDMemoryCardUiBitmapFile, "z:aknmemorycardui.mbm" ); |
|
501 CAknIconArray* iconArray = new( ELeave ) CAknIconArray( 1 ); |
|
502 listBox->ItemDrawer()->ColumnData()->SetIconArray( iconArray ); |
|
503 |
|
504 TParse* fp = new(ELeave) TParse(); |
|
505 fp->Set(KFLDMemoryCardUiBitmapFile, &KDC_APP_BITMAP_DIR, NULL); |
|
506 TFileName resourceFileName( fp->FullName() ); |
|
507 delete fp; |
|
508 |
|
509 CGulIcon* icon = AknsUtils::CreateGulIconL( skin, KAknsIIDQgnIndiMmcAdd, |
|
510 resourceFileName, |
|
511 EMbmAknmemorycarduiQgn_indi_mmc_add, |
|
512 EMbmAknmemorycarduiQgn_indi_mmc_add_mask ); |
|
513 CleanupStack::PushL( icon ); |
|
514 iconArray->AppendL( icon ); |
|
515 CleanupStack::Pop( icon ); |
|
516 |
|
517 |
|
518 // execute dialog |
|
519 TBool result = popupList->ExecuteLD(); |
|
520 CleanupStack::Pop(); // popupList |
|
521 */ |
|
522 if ( result ) |
|
523 { |
|
524 if (index == (fileNameArray->Count() - 1)) |
|
525 { |
|
526 // "default" (resource file) selected |
|
527 aFilename.Copy(KNullDesC); |
|
528 } |
|
529 else |
|
530 { |
|
531 // xml file selected |
|
532 aFilename.Copy(iSearchArray->MdcaPoint(index)); |
|
533 } |
|
534 ret = ETrue; |
|
535 } |
|
536 // CleanupStack::PopAndDestroy(); //listBox |
|
537 } |
471 } |
538 else // no random data files found from the search paths |
472 else // no random data files found from the search paths |
539 { |
473 { |
540 iEngine->GetEngineWrapper()->ShowNote(_L("No random data files found")); |
474 iEngine->GetEngineWrapper()->ShowNote(_L("No random data files found")); |
541 } |
475 delete iSearchArray; |
542 |
476 iSearchArray = NULL; |
543 delete iSearchArray; |
477 } |
544 iSearchArray = NULL; |
478 |
545 return ret; |
479 return ret; |
546 } |
480 } |
547 |
481 |
548 TInt CCommandParser::FindFilesRecursiveL(const TDesC& aFileName, const TDesC& aPath) |
482 TInt CCommandParser::FindFilesRecursiveL(const TDesC& aFileName, const TDesC& aPath) |
549 { |
483 { |