1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Class of Mediafiledialog. UI control of mediafilelist |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 |
|
23 #include "mediafiledialog.h" |
|
24 #include "mediafiledialogutils.h" |
|
25 #include "mediafilelist.h" |
|
26 #include "mediafilehandler.h" |
|
27 #include "mediafilelistdebug.h" |
|
28 #include "mediafileprotection.h" |
|
29 #include "mediafilevideopreviewdialog.h" |
|
30 #include "mediafiletest.h" // test code |
|
31 |
|
32 #include <eikclbd.h> // for CColumnListBoxData |
|
33 #include <coecobs.h> // MCoeControlObserver |
|
34 #include <AknUtils.h> // AknTextUtils AknFind |
|
35 #include <AknIconArray.h> // for GulArray |
|
36 #include <AknWaitDialog.h> |
|
37 #include <textresolver.h> |
|
38 #include <StringLoader.h> |
|
39 #include <akninputblock.h> // CAknInputBlock |
|
40 #include <mmferrors.h> |
|
41 // search field |
|
42 #include <aknselectionlist.h> // AknSelectionList.cpp |
|
43 #include <aknsfld.h> // CAknSearchField |
|
44 #include <eikcapc.h> // CEikCaptionedControl |
|
45 |
|
46 #include <aknconsts.h> // KAvkonBitmapFile, KAvkonVariatedBitmapsFile |
|
47 #include <AknsConstants.h> // icon constants |
|
48 #include <aknmemorycardui.mbg> // memory card icon |
|
49 #include <avkon.mbg> |
|
50 |
|
51 #include <avkon.loc> |
|
52 #include <mediafilelist.rsg> |
|
53 #include <mediafilelist.mbg> |
|
54 #include <data_caging_path_literals.hrh> // KDC_APP_RESOURCE_DIR |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 /****************************************************************************** |
|
61 * class CMediaFileDialog |
|
62 ******************************************************************************/ |
|
63 |
|
64 |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CMediaFileDialog::NewL |
|
68 // |
|
69 // ----------------------------------------------------------------------------- |
|
70 CMediaFileDialog* CMediaFileDialog::NewL() |
|
71 { |
|
72 FLOG( _L("CMediaFileDialog::NewL START") ); |
|
73 |
|
74 CMediaFileDialog* self = new (ELeave) CMediaFileDialog(); |
|
75 CleanupStack::PushL( self ); |
|
76 self->ConstructL(); |
|
77 CleanupStack::Pop( self ); |
|
78 |
|
79 FLOG( _L("CMediaFileDialog::NewL END") ); |
|
80 return self; |
|
81 } |
|
82 |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CMediaFileDialog::CMediaFileDialog |
|
86 // |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 CMediaFileDialog::CMediaFileDialog() |
|
90 { |
|
91 FLOG( _L("CMediaFileDialog::CMediaFileDialog START") ); |
|
92 |
|
93 iResourceFileId = KErrNotFound; |
|
94 iForeGround = ETrue; |
|
95 iDatabaseOpen = EFalse; |
|
96 iPeninputActive = EFalse; |
|
97 |
|
98 iNullItemFileTypeOne = KErrNotFound; |
|
99 iNullItemFileTypeTwo = KErrNotFound; |
|
100 iDialogTitle = KNullDesC; |
|
101 iIsDoubleClicked = EFalse; |
|
102 |
|
103 FLOG( _L("CMediaFileDialog::CMediaFileDialog END") ); |
|
104 } |
|
105 |
|
106 |
|
107 // ---------------------------------------------------------------------------- |
|
108 // Destructor |
|
109 // |
|
110 // ---------------------------------------------------------------------------- |
|
111 // |
|
112 CMediaFileDialog::~CMediaFileDialog() |
|
113 { |
|
114 FLOG( _L("CMediaFileDialog::~CMediaFileDialog START") ); |
|
115 |
|
116 if ( iResourceFileId != KErrNotFound ) |
|
117 { |
|
118 CEikonEnv::Static()->DeleteResourceFile( iResourceFileId ); |
|
119 } |
|
120 |
|
121 delete iStatusPaneHandler; |
|
122 delete iMFListHandler; |
|
123 delete iMediaFileHandler; |
|
124 delete iState; |
|
125 |
|
126 delete iFindCtrl; |
|
127 delete iCaller; |
|
128 delete iSearchCaller; |
|
129 |
|
130 delete iAudioPreviewHandler; |
|
131 delete iVideoPreviewHandler; |
|
132 |
|
133 delete iNullItemFileNameOne; |
|
134 delete iNullItemFileNameTwo; |
|
135 |
|
136 if ( iAvkonAppUi ) |
|
137 { |
|
138 iAvkonAppUi->RemoveFromStack(this); |
|
139 } |
|
140 |
|
141 CCoeEnv::Static()->RemoveForegroundObserver( *this ); |
|
142 |
|
143 if ( iPopupNote ) |
|
144 { |
|
145 iPopupNote->HideInfoPopupNote(); |
|
146 delete iPopupNote; |
|
147 } |
|
148 |
|
149 delete iWaitNote; |
|
150 if ( AknLayoutUtils::PenEnabled() ) |
|
151 { |
|
152 iPeninputServer.RemovePenUiActivationHandler(); |
|
153 iPeninputServer.Close(); |
|
154 } |
|
155 |
|
156 delete iIdle; |
|
157 |
|
158 delete iProtectionHandler; |
|
159 |
|
160 delete iInputBlock; |
|
161 |
|
162 #ifdef _DEBUG |
|
163 delete iTest; // test code |
|
164 #endif |
|
165 |
|
166 FLOG( _L("CMediaFileDialog::~CMediaFileDialog END") ); |
|
167 } |
|
168 |
|
169 |
|
170 // ----------------------------------------------------------------------------- |
|
171 // CMediaFileDialog::ConstructL |
|
172 // |
|
173 // ----------------------------------------------------------------------------- |
|
174 // |
|
175 void CMediaFileDialog::ConstructL() |
|
176 { |
|
177 FLOG( _L("CMediaFileDialog::ConstructL START") ); |
|
178 |
|
179 iResourceFileId = TMFDialogUtil::AddResFileL(); |
|
180 |
|
181 CCoeEnv* coeEnv = CCoeEnv::Static(); |
|
182 coeEnv->AddForegroundObserverL( *this ); |
|
183 |
|
184 CAknDialog::ConstructL( R_MEDIA_FILE_DIALOG_MENU ); |
|
185 |
|
186 if ( iMenuBar ) |
|
187 { |
|
188 iMenuBar->SetContextMenuTitleResourceId( |
|
189 R_MEDIA_FILE_DIALOG_CONTEXT_MENU ); |
|
190 } |
|
191 |
|
192 // get previous title so it can be restored |
|
193 iStatusPaneHandler = CStatusPaneHandler::NewL( iAvkonAppUi ); |
|
194 iStatusPaneHandler->StoreOriginalTitleL(); |
|
195 |
|
196 iMediaFileHandler = CMediaFileHandler::NewL(); |
|
197 iMediaFileHandler->SetObserver( this ); |
|
198 |
|
199 iState = CMediaFileDialogState::NewL(); |
|
200 |
|
201 #ifndef RD_VIDEO_AS_RINGING_TONE |
|
202 iState->HideRootFolder( EEFolderVideos, ETrue, |
|
203 KNullDesC, KErrNotFound ); |
|
204 |
|
205 iMediaFileHandler->SetAttrL( CMediaFileList::EAttrExcludeFolder, CMediaFileList::EFolderVideos ); |
|
206 #endif |
|
207 |
|
208 iMFListHandler = CMFListHandler::NewL(); |
|
209 iMFListHandler->SetObserver( this ); |
|
210 |
|
211 iCaller = CMFActiveCaller::NewL( this ); |
|
212 iSearchCaller = CMFActiveCaller::NewL( this ); |
|
213 |
|
214 iAudioPreviewHandler = CMFAudioPreviewHandler::NewL(); |
|
215 iVideoPreviewHandler = CMFVideoPreviewHandler::NewL(); |
|
216 |
|
217 iAudioPreviewHandler->SetObserver( this ); |
|
218 |
|
219 iPopupNote = CAknInfoPopupNoteController::NewL(); |
|
220 |
|
221 iWaitNote = CMediaFileWaitNote::NewL( this ); |
|
222 |
|
223 if ( AknLayoutUtils::PenEnabled() ) |
|
224 { |
|
225 User::LeaveIfError( iPeninputServer.Connect() ); |
|
226 iPeninputServer.AddPenUiActivationHandler( this, EPluginInputModeAll ); |
|
227 } |
|
228 |
|
229 iProtectionHandler = CMFProtectionHandler::NewL(); |
|
230 |
|
231 #ifdef _DEBUG |
|
232 iTest = CMFDialogTest::NewL( this ); // test code |
|
233 #endif |
|
234 |
|
235 FLOG( _L("CMediaFileDialog::ConstructL END") ); |
|
236 } |
|
237 |
|
238 |
|
239 // ----------------------------------------------------------------------------- |
|
240 // CMediaFileDialog::ShowDialogL |
|
241 // |
|
242 // ----------------------------------------------------------------------------- |
|
243 TBool CMediaFileDialog::ShowDialogL( TDes* aFileName, TInt* aNullItem, |
|
244 TInt* aInfo, TDes* aDesInfo ) |
|
245 { |
|
246 __ASSERT_ALWAYS( aFileName, Panic( KErrGeneral ) ); |
|
247 __ASSERT_ALWAYS( aNullItem, Panic( KErrGeneral ) ); |
|
248 |
|
249 iFileName = aFileName; |
|
250 |
|
251 iNullItem = aNullItem; |
|
252 *iNullItem = KErrNotFound; |
|
253 |
|
254 iInfo = aInfo; |
|
255 iDesInfo = aDesInfo; |
|
256 |
|
257 TBool ret = ExecuteLD( R_MEDIA_FILE_DIALOG ); |
|
258 |
|
259 return ret; |
|
260 } |
|
261 |
|
262 |
|
263 // ----------------------------------------------------------------------------- |
|
264 // CMediaFileDialog::SetAttrL |
|
265 // |
|
266 // ----------------------------------------------------------------------------- |
|
267 void CMediaFileDialog::SetAttrL( TInt aAttr, TInt aValue ) |
|
268 { |
|
269 iAudioPreviewHandler->SetAttrL( aAttr, aValue ); |
|
270 iVideoPreviewHandler->SetAttrL( aAttr, aValue ); |
|
271 iMediaFileHandler->SetAttrL( aAttr, aValue ); |
|
272 iProtectionHandler->SetAttrL( aAttr, aValue ); |
|
273 |
|
274 if ( aAttr == CMediaFileList::EAttrExcludeFolder ) |
|
275 { |
|
276 if ( aValue == CMediaFileList::EFolderDownload ) |
|
277 { |
|
278 iState->HideRootFolder( EEFolderDownload, ETrue, |
|
279 KNullDesC, KErrNotFound ); |
|
280 } |
|
281 if ( aValue == CMediaFileList::EFolderVideos ) |
|
282 { |
|
283 iState->HideRootFolder( EEFolderVideos, ETrue, |
|
284 KNullDesC, KErrNotFound ); |
|
285 } |
|
286 } |
|
287 } |
|
288 |
|
289 |
|
290 // ----------------------------------------------------------------------------- |
|
291 // CMediaFileDialog::SetAttrL |
|
292 // |
|
293 // ----------------------------------------------------------------------------- |
|
294 void CMediaFileDialog::SetAttrL( TInt aAttr, const TDesC& aValue ) |
|
295 { |
|
296 iAudioPreviewHandler->SetAttrL( aAttr, aValue ); |
|
297 iVideoPreviewHandler->SetAttrL( aAttr, aValue ); |
|
298 iMediaFileHandler->SetAttrL( aAttr, aValue ); |
|
299 iProtectionHandler->SetAttrL( aAttr, aValue ); |
|
300 |
|
301 if ( aAttr == CMediaFileList::EAttrTitle ) |
|
302 { |
|
303 TMFDialogUtil::StrCopy( iDialogTitle, aValue ); |
|
304 } |
|
305 } |
|
306 |
|
307 |
|
308 // ----------------------------------------------------------------------------- |
|
309 // CMediaFileDialog::SetAttrL |
|
310 // |
|
311 // ----------------------------------------------------------------------------- |
|
312 void CMediaFileDialog::SetAttrL( TInt aAttr, TAny* aValue ) |
|
313 { |
|
314 iAudioPreviewHandler->SetAttrL( aAttr, aValue ); |
|
315 iVideoPreviewHandler->SetAttrL( aAttr, aValue ); |
|
316 iMediaFileHandler->SetAttrL( aAttr, aValue ); |
|
317 } |
|
318 |
|
319 |
|
320 // ----------------------------------------------------------------------------- |
|
321 // CMediaFileDialog::SetNullItemL |
|
322 // |
|
323 // ----------------------------------------------------------------------------- |
|
324 // |
|
325 void CMediaFileDialog::SetNullItemL( const TDesC& aText, |
|
326 const TDesC& aMediaFile, |
|
327 TInt aMediaFileType, TInt aIconId ) |
|
328 { |
|
329 TInt iconId = EEIconEmpty; |
|
330 if ( aIconId == CMediaFileList::ENullItemIconDefaultTone ) |
|
331 { |
|
332 iconId = EEIconTone; |
|
333 } |
|
334 else if ( aIconId == CMediaFileList::ENullItemIconOff ) |
|
335 { |
|
336 iconId = EEIconNullItemOff; |
|
337 } |
|
338 |
|
339 TInt mediaType = CMediaFileList::EMediaFileTypeAudio; |
|
340 if ( aMediaFileType == CMediaFileList::EMediaFileTypeVideo ) |
|
341 { |
|
342 mediaType = CMediaFileList::EMediaFileTypeVideo; |
|
343 } |
|
344 |
|
345 |
|
346 if ( !iNullItemFileNameOne ) |
|
347 { |
|
348 iNullItemFileNameOne = aMediaFile.AllocL(); |
|
349 iNullItemFileTypeOne = mediaType; |
|
350 |
|
351 iState->EnableNullItemL( EEFolderNullItemOne, aText, iconId ); |
|
352 } |
|
353 else if ( !iNullItemFileNameTwo ) |
|
354 { |
|
355 iNullItemFileNameTwo = aMediaFile.AllocL(); |
|
356 iNullItemFileTypeTwo = mediaType; |
|
357 |
|
358 iState->EnableNullItemL( EEFolderNullItemTwo, aText, iconId ); |
|
359 } |
|
360 else |
|
361 { |
|
362 User::Leave( KErrNotSupported ); // two null items supported |
|
363 } |
|
364 } |
|
365 |
|
366 |
|
367 |
|
368 //------------------------------------------------------------------------------ |
|
369 // CMediaFileDialog::ActivateL |
|
370 // |
|
371 // Called by system when dialog is activated. |
|
372 //------------------------------------------------------------------------------ |
|
373 // |
|
374 void CMediaFileDialog::ActivateL() |
|
375 { |
|
376 CAknDialog::ActivateL(); |
|
377 |
|
378 // this cannot be in ConstructL which is executed before dialog is launched |
|
379 iAvkonAppUi->AddToStackL( this ); |
|
380 AknFind::HandleFixedFindSizeChanged( this, iListBox, FindBox() ); |
|
381 DrawNow(); |
|
382 } |
|
383 |
|
384 |
|
385 // ----------------------------------------------------------------------------- |
|
386 // CMediaFileDialog::PreLayoutDynInitL |
|
387 // |
|
388 // ----------------------------------------------------------------------------- |
|
389 // |
|
390 void CMediaFileDialog::PreLayoutDynInitL() |
|
391 { |
|
392 const TInt KFindBoxLength = 20; |
|
393 |
|
394 iListBox = (CAknSingleGraphicStyleListBox*) (ControlOrNull(1)); |
|
395 iListBox->DisableSingleClick(ETrue); |
|
396 __ASSERT_ALWAYS( iListBox, TMFDialogUtil::Panic( KErrGeneral ) ); |
|
397 |
|
398 iListBox->Model()->SetItemTextArray( iMFListHandler ); |
|
399 iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
400 |
|
401 iListBox->SetListBoxObserver( this ); |
|
402 iListBox->CreateScrollBarFrameL( ETrue ); |
|
403 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
404 CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto ); |
|
405 |
|
406 iListBox->SetContainerWindowL( *this ); |
|
407 |
|
408 SetIconsL(); |
|
409 |
|
410 iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue ); |
|
411 |
|
412 |
|
413 iState->Init(); |
|
414 |
|
415 if ( iDialogTitle.Length() > 0 ) |
|
416 { |
|
417 iStatusPaneHandler->SetTitleL( iDialogTitle ); |
|
418 } |
|
419 else |
|
420 { |
|
421 iStatusPaneHandler->SetTitleL( R_QTN_MEDIA_FILE_DIALOG_TITLE ); |
|
422 } |
|
423 iStatusPaneHandler->SetNaviPaneTitleL( KNullDesC ); |
|
424 |
|
425 |
|
426 // |
|
427 // create find box. NOTE: findbox functionality is quite complex and |
|
428 // is implemented by copy pasting code from other apps. |
|
429 // |
|
430 |
|
431 CFindControl* control = ( CFindControl* )ControlOrNull( EFindControl ); |
|
432 if ( control ) |
|
433 { |
|
434 CAknSearchField::TSearchFieldStyle flags = CAknSearchField::EFixed; |
|
435 control->iFind = CAknSearchField::NewL( |
|
436 *control, flags, 0, KFindBoxLength ); |
|
437 //control->iFind = searchField; |
|
438 control->SetContainerWindowL( *this ); |
|
439 CEikEdwin& edwin = control->iFind->Editor(); |
|
440 control->iFind->AddAdaptiveSearchTextObserverL( this ); |
|
441 } |
|
442 |
|
443 if ( FindBox() ) |
|
444 { |
|
445 CAknFilteredTextListBoxModel* model = |
|
446 STATIC_CAST( CAknFilteredTextListBoxModel*, iListBox->Model() ); |
|
447 |
|
448 FindBox()->MakeVisible( EFalse ); |
|
449 } |
|
450 |
|
451 |
|
452 UpdateListBoxL(); |
|
453 |
|
454 DrawDeferred(); |
|
455 } |
|
456 |
|
457 |
|
458 //------------------------------------------------------------------------------ |
|
459 // CMediaFileDialog::ProcessCommandL |
|
460 // |
|
461 // Handle commands from menu. NOTE: Current implemntation does not use menu. |
|
462 // Menu handling code is here for (possible) future use. |
|
463 //------------------------------------------------------------------------------ |
|
464 // |
|
465 void CMediaFileDialog::ProcessCommandL( TInt aCommandId ) |
|
466 { |
|
467 HideMenu(); |
|
468 |
|
469 switch (aCommandId) |
|
470 { |
|
471 case EAknCmdHelp: |
|
472 { |
|
473 break; |
|
474 } |
|
475 |
|
476 case EAknSoftkeySelect: |
|
477 { |
|
478 TBool ret = HandleOKL( EAttrSelect ); |
|
479 if ( ret ) |
|
480 { |
|
481 TryExitL( EEikCmdExit ); |
|
482 } |
|
483 break; |
|
484 } |
|
485 |
|
486 case EAknSoftkeyView: |
|
487 { |
|
488 PreviewL( CMediaFileList::EMediaFileTypeVideo ); |
|
489 break; |
|
490 } |
|
491 case EAknCmdOpen: |
|
492 { |
|
493 HandleOKL( EAttrOpen ); |
|
494 break; |
|
495 } |
|
496 |
|
497 case EAknCmdExit: |
|
498 case EEikCmdExit: |
|
499 { |
|
500 // close dialog and exit calling application |
|
501 iAvkonAppUi->ProcessCommandL( EAknCmdExit ); |
|
502 break; |
|
503 } |
|
504 |
|
505 default: |
|
506 break; |
|
507 } |
|
508 } |
|
509 |
|
510 |
|
511 //------------------------------------------------------------------------------ |
|
512 // CMediaFileDialog::OkToExitL |
|
513 // |
|
514 // Hanlde commands from cba. |
|
515 //------------------------------------------------------------------------------ |
|
516 // |
|
517 TBool CMediaFileDialog::OkToExitL(TInt aButtonId) |
|
518 { |
|
519 if ( aButtonId == EEikBidCancel ) |
|
520 { |
|
521 return ETrue; // close dialog |
|
522 } |
|
523 |
|
524 if ( aButtonId == EEikBidOk ) |
|
525 { |
|
526 TBool ret = HandleOKL( EAttrSelect ); |
|
527 return ret; |
|
528 } |
|
529 |
|
530 if ( aButtonId == EAknSoftkeyBack ) |
|
531 { |
|
532 if ( !HandleBackL() ) |
|
533 { |
|
534 #ifdef _DEBUG |
|
535 // start test code |
|
536 TInt currentIndex = CurrentItemListIndex(); |
|
537 if ( iState->FolderId( currentIndex ) == EEFolderRecordings ) |
|
538 { |
|
539 if ( !iTest->TestL( 0 ) ) |
|
540 { |
|
541 return ETrue; // test canceled |
|
542 } |
|
543 return EFalse; // test accepted |
|
544 } |
|
545 // end test code |
|
546 #endif |
|
547 |
|
548 return ETrue; // Back pressed in top level folder |
|
549 } |
|
550 |
|
551 return EFalse; // leave dialog open |
|
552 } |
|
553 |
|
554 if ( aButtonId == EAknSoftkeyContextOptions ) |
|
555 { |
|
556 ShowContextMenuL( R_MEDIA_FILE_DIALOG_CONTEXT_MENU ); |
|
557 return EFalse; |
|
558 } |
|
559 |
|
560 if ( aButtonId == EAknSoftkeyOpen ) |
|
561 { |
|
562 TBool ret = HandleOKL( EAttrOpen ); |
|
563 return ret; |
|
564 } |
|
565 |
|
566 if ( aButtonId == EAknSoftkeySelect ) |
|
567 { |
|
568 TBool ret = HandleOKL( EAttrSelect ); |
|
569 return ret; |
|
570 } |
|
571 |
|
572 if ( aButtonId == EAknSoftkeyView ) |
|
573 { |
|
574 PreviewL( CMediaFileList::EMediaFileTypeVideo ); |
|
575 return EFalse; |
|
576 } |
|
577 |
|
578 if ( aButtonId == EAknSoftkeyEmpty ) |
|
579 { |
|
580 return EFalse; |
|
581 } |
|
582 |
|
583 return CAknDialog::OkToExitL( aButtonId ); |
|
584 } |
|
585 |
|
586 |
|
587 // ---------------------------------------------------------------------------- |
|
588 // CMediaFileDialog::OfferKeyEventL |
|
589 // |
|
590 // ---------------------------------------------------------------------------- |
|
591 // |
|
592 TKeyResponse CMediaFileDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent, |
|
593 TEventCode aType) |
|
594 { |
|
595 // must pass escape event to dialog - findbox and listbox "eat" escape events |
|
596 TKeyResponse res = EKeyWasNotConsumed; |
|
597 if ( aType == EEventKey && aKeyEvent.iCode == EKeyEscape ) |
|
598 { |
|
599 res = CAknDialog::OfferKeyEventL( aKeyEvent, aType ); |
|
600 } |
|
601 if ( res == EKeyWasConsumed ) |
|
602 { |
|
603 return res; |
|
604 } |
|
605 |
|
606 |
|
607 TBool backSpace = EFalse; |
|
608 |
|
609 if (aType == EEventKey) |
|
610 { |
|
611 switch (aKeyEvent.iCode) |
|
612 { |
|
613 case EKeyEnter: |
|
614 { |
|
615 break; |
|
616 } |
|
617 case EKeyUpArrow: |
|
618 case EKeyDownArrow: |
|
619 { |
|
620 TInt itemCount = iListBox->Model()->NumberOfItems(); |
|
621 if ( itemCount == 1 ) |
|
622 { |
|
623 PreviewL( CMediaFileList::EMediaFileTypeAudio ); |
|
624 } |
|
625 break; |
|
626 } |
|
627 |
|
628 case EKeyLeftArrow: |
|
629 { |
|
630 if (FindBox() && FindBox()->IsVisible() |
|
631 && FindBox()->TextLength() != 0) |
|
632 { |
|
633 FindBoxCursorMoveL( 0 ); |
|
634 res = EKeyWasConsumed; |
|
635 } |
|
636 else |
|
637 { |
|
638 HandleBackL(); |
|
639 return EKeyWasConsumed; |
|
640 } |
|
641 break; |
|
642 } |
|
643 |
|
644 case EKeyRightArrow: |
|
645 { |
|
646 if (FindBox() && FindBox()->IsVisible() |
|
647 && FindBox()->TextLength() != 0) |
|
648 { |
|
649 FindBoxCursorMoveL( 1 ); |
|
650 res = EKeyWasConsumed; |
|
651 } |
|
652 else |
|
653 { |
|
654 HandleOKL( EAttrOpen ); |
|
655 return EKeyWasConsumed; |
|
656 } |
|
657 break; |
|
658 } |
|
659 |
|
660 case EKeyBackspace: |
|
661 { |
|
662 backSpace = ETrue; |
|
663 break; |
|
664 } |
|
665 |
|
666 default: |
|
667 { |
|
668 break; |
|
669 } |
|
670 } |
|
671 |
|
672 if ( FindBox() && FindBox()->IsVisible() ) |
|
673 { |
|
674 res = FindBox()->OfferKeyEventL( aKeyEvent, aType ); |
|
675 |
|
676 if ( backSpace && FindBox()->TextLength() == 0 && |
|
677 ( iState->CurrentFolder() == EEFolderSearch || |
|
678 iState->CurrentFolder() == EEFolderSearchMusic ) && !iPeninputActive ) |
|
679 { |
|
680 // user cleared search field - go back to main view |
|
681 HandleBackL(); |
|
682 return EKeyWasConsumed; |
|
683 } |
|
684 } |
|
685 } |
|
686 |
|
687 |
|
688 if ( res == EKeyWasNotConsumed ) |
|
689 { |
|
690 res = CAknDialog::OfferKeyEventL( aKeyEvent, aType); |
|
691 } |
|
692 return res; |
|
693 } |
|
694 |
|
695 |
|
696 // ----------------------------------------------------------------------------- |
|
697 // CMediaFileDialog::FindBoxCursorMoveL( TInt aType ) |
|
698 // |
|
699 // NOTE: This function is used to move the cursor of the find box. |
|
700 // ----------------------------------------------------------------------------- |
|
701 // |
|
702 void CMediaFileDialog::FindBoxCursorMoveL( TInt aType ) |
|
703 { |
|
704 if ( FindBox() && FindBox()->IsVisible() ) |
|
705 { |
|
706 TInt pos = FindBox()->Editor().CursorPos(); |
|
707 TInt textLength = FindBox()->Editor().TextLength(); |
|
708 if ( aType == 0 )//left |
|
709 { |
|
710 pos = pos - 1; |
|
711 if ( pos < 0 ) |
|
712 { |
|
713 pos = textLength; |
|
714 } |
|
715 } |
|
716 else if ( aType == 1 ) |
|
717 { |
|
718 pos = pos + 1; |
|
719 if ( pos > textLength ) |
|
720 { |
|
721 pos = 0; |
|
722 } |
|
723 } |
|
724 else |
|
725 { |
|
726 pos = textLength; |
|
727 } |
|
728 FindBox()->Editor().SetCursorPosL( pos ,EFalse ); |
|
729 } |
|
730 } |
|
731 // ----------------------------------------------------------------------------- |
|
732 // CMediaFileDialog::SetSizeAndPosition (from CAknDialog) |
|
733 // |
|
734 // NOTE: This code is copy paste from elsewhere. |
|
735 // ----------------------------------------------------------------------------- |
|
736 // |
|
737 void CMediaFileDialog::SetSizeAndPosition( const TSize& /*aSize*/ ) |
|
738 { |
|
739 TRect mainPane; |
|
740 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPane ); |
|
741 |
|
742 SetRect( mainPane ); |
|
743 |
|
744 if ( FindBox() && FindBox()->IsVisible() ) |
|
745 { |
|
746 AknFind::HandleFixedFindSizeChanged( this, iListBox, FindBox() ); |
|
747 } |
|
748 |
|
749 Line( ESelectionListControl)->SetRect( iListBox->Rect() ); |
|
750 if ( FindBox() ) |
|
751 { |
|
752 Line( EFindControl )->SetRect( iListBox->Rect() ); |
|
753 } |
|
754 } |
|
755 |
|
756 |
|
757 // ---------------------------------------------------------------------------- |
|
758 // CMediaFileDialog::HandleResourceChange |
|
759 // |
|
760 // ---------------------------------------------------------------------------- |
|
761 // |
|
762 void CMediaFileDialog::HandleResourceChange(TInt aType) |
|
763 { |
|
764 if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
765 { |
|
766 // handle change in layout orientation |
|
767 CAknDialog::HandleResourceChange( aType ); |
|
768 if ( FindBox() && FindBox()->IsVisible() ) |
|
769 { |
|
770 AknFind::HandleFixedFindSizeChanged( this, iListBox, FindBox() ); |
|
771 } |
|
772 return; |
|
773 } |
|
774 |
|
775 if (aType == KAknsMessageSkinChange) |
|
776 { |
|
777 TRAP_IGNORE( SetIconsL() ); |
|
778 } |
|
779 |
|
780 CCoeControl::HandleResourceChange( aType ); |
|
781 } |
|
782 |
|
783 |
|
784 //------------------------------------------------------------------------------ |
|
785 // CMediaFileDialog::DynInitMenuPaneL |
|
786 // |
|
787 // Called by system before menu is shown. NOTE: Menu currently not used. |
|
788 //------------------------------------------------------------------------------ |
|
789 // |
|
790 void CMediaFileDialog::DynInitMenuPaneL(TInt aResourceID, CEikMenuPane* aMenuPane ) |
|
791 { |
|
792 TInt menu1 = R_MEDIA_FILE_DIALOG_MENU_PANE; |
|
793 TInt menu2 = R_MEDIA_FILE_DIALOG_CONTEXT_MENU_PANE; |
|
794 |
|
795 if ( aResourceID != menu1 && aResourceID != menu2 ) |
|
796 { |
|
797 return; // not one of our menus |
|
798 } |
|
799 |
|
800 TInt itemCount = iListBox->Model()->NumberOfItems(); |
|
801 TInt currentIndex = iListBox->CurrentItemIndex(); |
|
802 TInt folderId = iState->FolderId( currentIndex ); |
|
803 TInt currentFolderId = iState->CurrentFolder(); |
|
804 |
|
805 |
|
806 // context menu only used in video folder |
|
807 if ( aResourceID == R_MEDIA_FILE_DIALOG_CONTEXT_MENU_PANE ) |
|
808 { |
|
809 if ( itemCount == 0 ) |
|
810 { |
|
811 // folder is empty |
|
812 DeleteMenuItem( aMenuPane, EAknSoftkeySelect ); |
|
813 DeleteMenuItem( aMenuPane, EAknSoftkeyView ); |
|
814 } |
|
815 return; |
|
816 } |
|
817 |
|
818 |
|
819 if ( itemCount == 0 ) |
|
820 { |
|
821 // list has no items |
|
822 DeleteMenuItem( aMenuPane, EAknCmdOpen ); |
|
823 DeleteMenuItem( aMenuPane, EAknSoftkeySelect ); |
|
824 DeleteMenuItem( aMenuPane, EAknSoftkeyView ); |
|
825 return; |
|
826 } |
|
827 |
|
828 if ( folderId == EEFolderDownload || folderId == EEFolderNullItemOne || |
|
829 folderId == EEFolderNullItemTwo ) |
|
830 { |
|
831 // selected item is null item |
|
832 DeleteMenuItem( aMenuPane, EAknCmdOpen ); |
|
833 DeleteMenuItem( aMenuPane, EAknSoftkeyView ); |
|
834 } |
|
835 else if ( folderId != KErrNotFound ) |
|
836 { |
|
837 // selected item is folder |
|
838 DeleteMenuItem( aMenuPane, EAknSoftkeySelect ); |
|
839 DeleteMenuItem( aMenuPane, EAknSoftkeyView ); |
|
840 } |
|
841 else |
|
842 { |
|
843 // selected item is file |
|
844 if ( iState->CurrentFolder() == EEFolderVideos ) |
|
845 { |
|
846 DeleteMenuItem( aMenuPane, EAknCmdOpen ); |
|
847 } |
|
848 else if ( iState->CurrentFolder() == EEFolderSearch ) |
|
849 { |
|
850 DeleteMenuItem( aMenuPane, EAknCmdOpen ); |
|
851 |
|
852 if ( !IsVideoFile( currentIndex ) ) |
|
853 { |
|
854 DeleteMenuItem( aMenuPane, EAknSoftkeyView ); |
|
855 } |
|
856 } |
|
857 else |
|
858 { |
|
859 DeleteMenuItem( aMenuPane, EAknCmdOpen ); |
|
860 DeleteMenuItem( aMenuPane, EAknSoftkeyView ); |
|
861 } |
|
862 } |
|
863 } |
|
864 |
|
865 |
|
866 // --------------------------------------------------------------------------- |
|
867 // CMediaFileDialog::CountComponentControls |
|
868 // |
|
869 // Gets the number of controls contained in a compound control. |
|
870 // --------------------------------------------------------------------------- |
|
871 // |
|
872 TInt CMediaFileDialog::CountComponentControls() const |
|
873 { |
|
874 TInt newitems = 0; |
|
875 if ( FindBox() ) |
|
876 { |
|
877 newitems++; |
|
878 } |
|
879 return CAknDialog::CountComponentControls() + newitems; |
|
880 } |
|
881 |
|
882 |
|
883 // --------------------------------------------------------------------------- |
|
884 // CMediaFileDialog::CountComponentControls |
|
885 // |
|
886 // --------------------------------------------------------------------------- |
|
887 // |
|
888 CCoeControl* CMediaFileDialog::ComponentControl( TInt aIndex ) const |
|
889 { |
|
890 if ( aIndex == CAknDialog::CountComponentControls() ) |
|
891 { |
|
892 return FindBox(); |
|
893 } |
|
894 return CAknDialog::ComponentControl( aIndex ); |
|
895 } |
|
896 |
|
897 |
|
898 // ----------------------------------------------------------------------------- |
|
899 // CMediaFileDialog::FindBox |
|
900 // |
|
901 // ----------------------------------------------------------------------------- |
|
902 // |
|
903 CAknSearchField* CMediaFileDialog::FindBox() const |
|
904 { |
|
905 CFindControl* control = ( CFindControl* )ControlOrNull( EFindControl ); |
|
906 if ( control ) |
|
907 { |
|
908 return control->iFind; |
|
909 } |
|
910 else |
|
911 { |
|
912 return NULL; |
|
913 } |
|
914 } |
|
915 |
|
916 // --------------------------------------------------------------------------- |
|
917 // CMediaFileDialog::ResetFindBoxL |
|
918 // |
|
919 // --------------------------------------------------------------------------- |
|
920 // |
|
921 void CMediaFileDialog::ResetFindBoxL() |
|
922 { |
|
923 if ( !FindBox() ) |
|
924 { |
|
925 return; |
|
926 } |
|
927 |
|
928 CAknFilteredTextListBoxModel* model = |
|
929 STATIC_CAST( CAknFilteredTextListBoxModel*, iListBox->Model() ); |
|
930 CAknListBoxFilterItems* filter = model->Filter(); |
|
931 TInt currentFolder = iState->CurrentFolder(); |
|
932 |
|
933 // reset find box |
|
934 if ( filter ) |
|
935 { |
|
936 filter->ResetFilteringL(); |
|
937 filter->SetObserver( NULL ); |
|
938 model->RemoveFilter(); |
|
939 |
|
940 // CreateFilterL sets CAknSearchField to observe filter |
|
941 // (CAknListBoxFilterItems) but RemoveFilter does not remove observer |
|
942 FindBox()->SetObserver( NULL ); |
|
943 } |
|
944 |
|
945 if (FindBox()->TextLength() > 0 && (currentFolder != EEFolderSearch |
|
946 && currentFolder != EEFolderSearchMusic)) |
|
947 { |
|
948 FindBox()->SetSearchTextL( KNullDesC ); |
|
949 } |
|
950 |
|
951 |
|
952 // show/hide find box |
|
953 if ( iState->FindBoxNeeded() ) |
|
954 { |
|
955 if ( currentFolder != EEFolderSearch && |
|
956 currentFolder != EEFolderSearchMusic && |
|
957 currentFolder != EEFolderRoot && |
|
958 currentFolder != EEFolderMusic ) |
|
959 { |
|
960 // normal find only finds matches from listbox item texts |
|
961 model->CreateFilterL( iListBox, FindBox() ); |
|
962 filter = model->Filter(); |
|
963 filter->ResetFilteringL(); |
|
964 filter->SetObserver( this ); // MCoeControlObserver |
|
965 } |
|
966 else |
|
967 { |
|
968 // search and root folders have custom find that makes |
|
969 // database search |
|
970 FindBox()->SetObserver( this ); // MCoeControlObserver |
|
971 } |
|
972 // if ( currentFolder == EEFolderSearch || |
|
973 // currentFolder == EEFolderSearchMusic ) |
|
974 // { |
|
975 // FindBox()->SetSearchTextL( iSearchText ); |
|
976 // } |
|
977 |
|
978 FindBox()->MakeVisible( ETrue ); |
|
979 } |
|
980 else |
|
981 { |
|
982 FindBox()->MakeVisible( EFalse ); |
|
983 } |
|
984 |
|
985 TSize size; |
|
986 SetSizeAndPosition( size ); |
|
987 } |
|
988 |
|
989 |
|
990 // ----------------------------------------------------------------------------- |
|
991 // CMediaFileDialog::CreateCustomControlL (from CAknDialog) |
|
992 // |
|
993 // Create find control. |
|
994 // ----------------------------------------------------------------------------- |
|
995 // |
|
996 SEikControlInfo CMediaFileDialog::CreateCustomControlL( TInt aControlType ) |
|
997 { |
|
998 if ( aControlType != EAknCtSelectionListPopupFind && |
|
999 aControlType != EAknCtSelectionListFixedFind ) |
|
1000 { |
|
1001 SEikControlInfo info; |
|
1002 info.iControl = NULL; |
|
1003 info.iFlags = 0; |
|
1004 info.iTrailerTextId = 0; |
|
1005 return info; |
|
1006 } |
|
1007 |
|
1008 CCoeControl* findControl = NULL; |
|
1009 findControl = new (ELeave) CFindControl; |
|
1010 |
|
1011 SEikControlInfo info; |
|
1012 info.iControl = findControl; |
|
1013 info.iFlags = 0; |
|
1014 info.iTrailerTextId = 0; |
|
1015 return info; |
|
1016 } |
|
1017 |
|
1018 |
|
1019 // ---------------------------------------------------------------------------- |
|
1020 // CMediaFileDialog::SetIconsL |
|
1021 // |
|
1022 // ---------------------------------------------------------------------------- |
|
1023 // |
|
1024 void CMediaFileDialog::SetIconsL() |
|
1025 { |
|
1026 _LIT( KBitmapFile, "mediafilelist.mbm" ); |
|
1027 |
|
1028 |
|
1029 if ( !iListBox ) |
|
1030 { |
|
1031 return; |
|
1032 } |
|
1033 |
|
1034 TMFDialogUtil::SetIconFileNameL( KBitmapFile, iIconFileName ); |
|
1035 |
|
1036 CArrayPtr<CGulIcon>* icons = new (ELeave) CAknIconArray(1); |
|
1037 CleanupStack::PushL( icons ); |
|
1038 |
|
1039 |
|
1040 // |
|
1041 // NOTE: append order must match TMediaFileListIcons |
|
1042 // |
|
1043 |
|
1044 // music item icon |
|
1045 icons->AppendL( IconL( KAknsIIDQgnIndiAiNtMusic, iIconFileName, |
|
1046 EMbmMediafilelistQgn_indi_ai_nt_music, |
|
1047 EMbmMediafilelistQgn_indi_ai_nt_music_mask ) ); |
|
1048 |
|
1049 // tone item icon, default tone icon |
|
1050 icons->AppendL( IconL( KAknsIIDQgnPropMupAudio, iIconFileName, |
|
1051 EMbmMediafilelistQgn_prop_mup_audio, |
|
1052 EMbmMediafilelistQgn_prop_mup_audio_mask ) ); |
|
1053 |
|
1054 // video item icon |
|
1055 icons->AppendL( IconL( KAknsIIDQgnPropFmgrFileVideo, iIconFileName, |
|
1056 EMbmMediafilelistQgn_prop_fmgr_file_video, |
|
1057 EMbmMediafilelistQgn_prop_fmgr_file_video_mask ) ); |
|
1058 |
|
1059 // recording item icon |
|
1060 icons->AppendL( IconL( KAknsIIDQgnPropFmgrFileVoicerec, iIconFileName, |
|
1061 EMbmMediafilelistQgn_prop_fmgr_file_voicerec, |
|
1062 EMbmMediafilelistQgn_prop_fmgr_file_voicerec_mask ) ); |
|
1063 |
|
1064 // artist icon |
|
1065 icons->AppendL( IconL( KAknsIIDQgnPropMupArtist, iIconFileName, |
|
1066 EMbmMediafilelistQgn_prop_mup_artist, |
|
1067 EMbmMediafilelistQgn_prop_mup_artist_mask ) ); |
|
1068 |
|
1069 // album icon |
|
1070 icons->AppendL( IconL( KAknsIIDQgnPropMupAlbum, iIconFileName, |
|
1071 EMbmMediafilelistQgn_prop_mup_album, |
|
1072 EMbmMediafilelistQgn_prop_mup_album_mask ) ); |
|
1073 |
|
1074 // genre icon |
|
1075 icons->AppendL( IconL( KAknsIIDQgnPropMupGenre, iIconFileName, |
|
1076 EMbmMediafilelistQgn_prop_mup_genre, |
|
1077 EMbmMediafilelistQgn_prop_mup_genre_mask ) ); |
|
1078 |
|
1079 // composer icon |
|
1080 icons->AppendL( IconL( KAknsIIDQgnPropMupComposer, iIconFileName, |
|
1081 EMbmMediafilelistQgn_prop_mup_composer, |
|
1082 EMbmMediafilelistQgn_prop_mup_composer_mask ) ); |
|
1083 |
|
1084 // folder icon (tones, music, videos, recordings, all music, artist, |
|
1085 // album, genre, composer, artist all) |
|
1086 icons->AppendL( IconL( KAknsIIDQgnPropFolderSmall, iIconFileName, |
|
1087 EMbmMediafilelistQgn_prop_folder_small, |
|
1088 EMbmMediafilelistQgn_prop_folder_small_mask ) ); |
|
1089 |
|
1090 // unknown folder icon |
|
1091 icons->AppendL( IconL( KAknsIIDQgnPropMceUnknownRead, iIconFileName, |
|
1092 EMbmMediafilelistQgn_prop_mce_unknown_read, |
|
1093 EMbmMediafilelistQgn_prop_mce_unknown_read ) ); |
|
1094 |
|
1095 // download item icon (null item) |
|
1096 icons->AppendL( IconL( KAknsIIDQgnPropLinkEmbdSmall, iIconFileName, |
|
1097 EMbmMediafilelistQgn_prop_link_embd_small, |
|
1098 EMbmMediafilelistQgn_prop_link_embd_small_mask ) ); |
|
1099 |
|
1100 // off item icon (null item) |
|
1101 icons->AppendL( IconL( KAknsIIDQgnPropSmlSyncOff, iIconFileName, |
|
1102 EMbmMediafilelistQgn_prop_sml_sync_off, |
|
1103 EMbmMediafilelistQgn_prop_sml_sync_off_mask ) ); |
|
1104 |
|
1105 // memory card icon |
|
1106 icons->AppendL( IconL( KAknsIIDQgnIndiMmcAdd, iIconFileName, |
|
1107 EMbmMediafilelistQgn_indi_mmc_add, |
|
1108 EMbmMediafilelistQgn_indi_mmc_add_mask, EAknsCIQsnIconColorsCG13 ) ); |
|
1109 |
|
1110 // mass storage icon |
|
1111 icons->AppendL( IconL( KAknsIIDQgnPropLinkEmbdSmall, iIconFileName, |
|
1112 EMbmMediafilelistQgn_indi_fmgr_ms_add, |
|
1113 EMbmMediafilelistQgn_indi_fmgr_ms_add_mask,EAknsCIQsnIconColorsCG13 ) ); |
|
1114 |
|
1115 // empty icon |
|
1116 icons->AppendL( IconL( KAknsIIDQgnPropEmpty, KAvkonBitmapFile, |
|
1117 EMbmAvkonQgn_prop_empty, |
|
1118 EMbmAvkonQgn_prop_empty_mask ) ); |
|
1119 |
|
1120 // delete old icons |
|
1121 CArrayPtr<CGulIcon>* arr = iListBox->ItemDrawer()->ColumnData()->IconArray(); |
|
1122 if ( arr ) |
|
1123 { |
|
1124 arr->ResetAndDestroy(); |
|
1125 delete arr; |
|
1126 arr = NULL; |
|
1127 } |
|
1128 |
|
1129 iListBox->ItemDrawer()->ColumnData()->SetIconArray( icons ); |
|
1130 CleanupStack::Pop( icons ); |
|
1131 } |
|
1132 |
|
1133 |
|
1134 // ----------------------------------------------------------------------------- |
|
1135 // CMediaFileDialog::IconL |
|
1136 // |
|
1137 // ----------------------------------------------------------------------------- |
|
1138 // |
|
1139 CGulIcon* CMediaFileDialog::IconL(TAknsItemID aId, const TDesC& aFileName, |
|
1140 TInt aFileIndex, TInt aFileMaskIndex) |
|
1141 { |
|
1142 CGulIcon* icon = AknsUtils::CreateGulIconL(AknsUtils::SkinInstance(), aId, |
|
1143 aFileName, aFileIndex, aFileMaskIndex); |
|
1144 return icon; |
|
1145 } |
|
1146 |
|
1147 |
|
1148 // ----------------------------------------------------------------------------- |
|
1149 // CMediaFileDialog::IconL |
|
1150 // For MMC icon and Mass Storage icon |
|
1151 // ----------------------------------------------------------------------------- |
|
1152 // |
|
1153 CGulIcon* CMediaFileDialog::IconL(TAknsItemID aId, const TDesC& aFileName, |
|
1154 TInt aFileIndex, TInt aFileMaskIndex, TAknsQsnIconColorsIndex colorIndex) |
|
1155 { |
|
1156 TRgb defaultColour(KRgbBlack); |
|
1157 CFbsBitmap* bmap = NULL; |
|
1158 CFbsBitmap* mask = NULL; |
|
1159 |
|
1160 AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), defaultColour, KAknsIIDQsnIconColors, |
|
1161 colorIndex); |
|
1162 AknsUtils::CreateColorIconLC(AknsUtils::SkinInstance(), KAknsIIDQgnIndiMmcAdd, |
|
1163 KAknsIIDQsnIconColors, colorIndex, bmap, mask, |
|
1164 aFileName, aFileIndex, aFileMaskIndex, defaultColour); |
|
1165 |
|
1166 CGulIcon* icon = CGulIcon::NewL(bmap, mask); |
|
1167 icon->SetBitmapsOwnedExternally(EFalse); |
|
1168 CleanupStack::Pop(2); |
|
1169 return icon; |
|
1170 } |
|
1171 |
|
1172 |
|
1173 // ---------------------------------------------------------------------------- |
|
1174 // CMediaFileDialog::ShowContextMenuL |
|
1175 // |
|
1176 // ---------------------------------------------------------------------------- |
|
1177 // |
|
1178 void CMediaFileDialog::ShowContextMenuL( TInt /*aResource*/ ) |
|
1179 { |
|
1180 // Switch to Context specific options menu, |
|
1181 if ( iMenuBar ) |
|
1182 { |
|
1183 TRAP_IGNORE( iMenuBar->TryDisplayContextMenuBarL() ); |
|
1184 } |
|
1185 } |
|
1186 |
|
1187 |
|
1188 //------------------------------------------------------------------------------ |
|
1189 // CMediaFileDialog::HandleBackL |
|
1190 // |
|
1191 //------------------------------------------------------------------------------ |
|
1192 // |
|
1193 TBool CMediaFileDialog::HandleBackL() |
|
1194 { |
|
1195 TInt err = KErrNone; |
|
1196 TBool ret = ETrue; |
|
1197 |
|
1198 TRAP( err, ret = DoHandleBackL() ); |
|
1199 |
|
1200 if ( err != KErrNone ) |
|
1201 { |
|
1202 FLOG( _L("### CMediaFileDialog::HandleBackL (%d) ###"), err ); |
|
1203 |
|
1204 ResetDialogL( err ); |
|
1205 return ETrue; |
|
1206 } |
|
1207 |
|
1208 return ret; |
|
1209 } |
|
1210 |
|
1211 |
|
1212 //------------------------------------------------------------------------------ |
|
1213 // CMediaFileDialog::DoHandleBackL |
|
1214 // |
|
1215 //------------------------------------------------------------------------------ |
|
1216 // |
|
1217 TBool CMediaFileDialog::DoHandleBackL() |
|
1218 { |
|
1219 if ( iState->CurrentFolder() == EEFolderRoot ) |
|
1220 { |
|
1221 // return EFalse only when called from root folder |
|
1222 return EFalse; |
|
1223 } |
|
1224 |
|
1225 if ( !iMediaFileHandler->QueryReady() ) |
|
1226 { |
|
1227 FLOG( _L("### CMediaFileDialog::DoHandleBackL: query in progress ###") ); |
|
1228 return ETrue; // query in progress |
|
1229 } |
|
1230 |
|
1231 TInt folderId = iState->NextFolderUp(); |
|
1232 TInt currentIndex = CurrentItemListIndex(); |
|
1233 |
|
1234 iState->SetQueryInfo( folderId, KNullDesC, currentIndex, EEQueryUp ); |
|
1235 QueryL( folderId ); |
|
1236 |
|
1237 return ETrue; |
|
1238 } |
|
1239 |
|
1240 |
|
1241 //------------------------------------------------------------------------------ |
|
1242 // CMediaFileDialog::HandleOKL |
|
1243 // |
|
1244 //------------------------------------------------------------------------------ |
|
1245 // |
|
1246 TBool CMediaFileDialog::HandleOKL( TInt aAttr ) |
|
1247 { |
|
1248 TInt err = KErrNone; |
|
1249 TBool ret = EFalse; |
|
1250 |
|
1251 TRAP( err, ret = DoHandleOKL( aAttr ) ); |
|
1252 |
|
1253 if ( err != KErrNone ) |
|
1254 { |
|
1255 FLOG( _L("### CMediaFileDialog::HandleOKL (%d) ###"), err ); |
|
1256 |
|
1257 ResetDialogL( err ); |
|
1258 return EFalse; |
|
1259 } |
|
1260 |
|
1261 return ret; |
|
1262 } |
|
1263 |
|
1264 |
|
1265 //------------------------------------------------------------------------------ |
|
1266 // CMediaFileDialog::DoHandleOKL |
|
1267 // |
|
1268 // Selects file or opens folder. If file is selected (ie dialog can |
|
1269 // be closed) return value is ETrue. |
|
1270 //------------------------------------------------------------------------------ |
|
1271 // |
|
1272 TBool CMediaFileDialog::DoHandleOKL( TInt aAttr ) |
|
1273 { |
|
1274 if ( !iMediaFileHandler->QueryReady() ) |
|
1275 { |
|
1276 FLOG( _L("### CMediaFileDialog::DoHandleOKL: query in progress ###") ); |
|
1277 return EFalse; // query in progress |
|
1278 } |
|
1279 |
|
1280 TInt currentIndex = CurrentItemListIndex(); |
|
1281 if ( currentIndex == KErrNotFound ) |
|
1282 { |
|
1283 return EFalse; // empty folder |
|
1284 } |
|
1285 |
|
1286 TBool isPersistent = EFalse; |
|
1287 TInt iconId = EEIconEmpty; |
|
1288 TInt folderId = KErrNotFound; |
|
1289 iState->GetFolderInfo( currentIndex, folderId, iBuf, |
|
1290 isPersistent, iconId ); |
|
1291 |
|
1292 if ( folderId == EEFolderDownload || folderId == EEFolderNullItemOne || |
|
1293 folderId == EEFolderNullItemTwo || folderId == KErrNotFound ) |
|
1294 { |
|
1295 if ( aAttr == EAttrOpen ) |
|
1296 { |
|
1297 return EFalse; // these can only be selected, not opened |
|
1298 } |
|
1299 } |
|
1300 |
|
1301 |
|
1302 if ( folderId == EEFolderDownload ) |
|
1303 { |
|
1304 *iNullItem = 0; |
|
1305 // user selected 'Download' item - launch browser |
|
1306 CWebBrowserLauncher* launcher = CWebBrowserLauncher::NewLC(); |
|
1307 launcher->LaunchBrowserL(); |
|
1308 CleanupStack::PopAndDestroy( launcher ); |
|
1309 return EFalse; |
|
1310 } |
|
1311 |
|
1312 if ( folderId == EEFolderNullItemOne ) |
|
1313 { |
|
1314 if ( iNullItemFileNameOne ) |
|
1315 { |
|
1316 TMFDialogUtil::StrCopy( *iFileName, *iNullItemFileNameOne ); |
|
1317 } |
|
1318 *iNullItem = 1; |
|
1319 return ETrue; |
|
1320 } |
|
1321 |
|
1322 if ( folderId == EEFolderNullItemTwo ) |
|
1323 { |
|
1324 if ( iNullItemFileNameTwo ) |
|
1325 { |
|
1326 TMFDialogUtil::StrCopy( *iFileName, *iNullItemFileNameTwo ); |
|
1327 } |
|
1328 *iNullItem = 2; |
|
1329 return ETrue; |
|
1330 } |
|
1331 |
|
1332 if ( folderId == KErrNotFound ) |
|
1333 { |
|
1334 // user has selected some media file |
|
1335 GetSelectedItemFileName( currentIndex, iBuf ); |
|
1336 |
|
1337 TBool ret = ETrue; |
|
1338 |
|
1339 // protection check not done when item is double checked |
|
1340 // if ( aAttr != EAttrDoubleClicked ) |
|
1341 if (!ifilevalid) |
|
1342 { |
|
1343 iFileisvalid = iProtectionHandler->IsFileValid( iBuf, |
|
1344 CMFProtectionHandler::ESelect ); |
|
1345 ifilevalid=ETrue; |
|
1346 } |
|
1347 |
|
1348 if ( !iFileisvalid) |
|
1349 { |
|
1350 ifilevalid=EFalse; |
|
1351 } |
|
1352 if ( iFileisvalid ) |
|
1353 { |
|
1354 TMFDialogUtil::StrCopy( *iFileName, iBuf ); |
|
1355 } |
|
1356 |
|
1357 return iFileisvalid; // ret is ETrue is selected file's drm is OK |
|
1358 } |
|
1359 |
|
1360 |
|
1361 if ( folderId != KErrNotFound && aAttr != EAttrSelect ) |
|
1362 { |
|
1363 iBuf = KNullDesC; |
|
1364 // selected list item is folder |
|
1365 if ( !isPersistent ) |
|
1366 { |
|
1367 // read non-persistent folder text from database |
|
1368 GetListItemText( currentIndex, iBuf ); |
|
1369 } |
|
1370 |
|
1371 iState->SetQueryInfo( folderId, iBuf, currentIndex, EEQueryDown ); |
|
1372 QueryL( folderId ); |
|
1373 } |
|
1374 |
|
1375 return EFalse; |
|
1376 } |
|
1377 |
|
1378 |
|
1379 //------------------------------------------------------------------------------ |
|
1380 // CMediaFileDialog::SearchL |
|
1381 // |
|
1382 //------------------------------------------------------------------------------ |
|
1383 // |
|
1384 void CMediaFileDialog::SearchL() |
|
1385 { |
|
1386 TInt err = KErrNone; |
|
1387 |
|
1388 TRAP( err, DoSearchL() ); |
|
1389 |
|
1390 if ( err != KErrNone ) |
|
1391 { |
|
1392 ResetDialogL( err ); |
|
1393 } |
|
1394 } |
|
1395 |
|
1396 |
|
1397 //------------------------------------------------------------------------------ |
|
1398 // CMediaFileDialog::DoSearchL |
|
1399 // |
|
1400 //------------------------------------------------------------------------------ |
|
1401 // |
|
1402 void CMediaFileDialog::DoSearchL() |
|
1403 { |
|
1404 if ( !FindBox() ) |
|
1405 { |
|
1406 return; |
|
1407 } |
|
1408 |
|
1409 if ( iPeninputActive) |
|
1410 { |
|
1411 return; |
|
1412 } |
|
1413 if ( !iMediaFileHandler->QueryReady() ) |
|
1414 { |
|
1415 FLOG( _L("### CMediaFileDialog::DoSearchL: query in progress ###") ); |
|
1416 return; // query in progress |
|
1417 } |
|
1418 |
|
1419 TInt currentFolder = iState->CurrentFolder(); |
|
1420 |
|
1421 if ( FindBox()->TextLength() == 0 ) |
|
1422 { |
|
1423 return; |
|
1424 } |
|
1425 FindBox()->GetSearchText( iSearchText ); |
|
1426 |
|
1427 _LIT(KSpecialChar, "%"); |
|
1428 _LIT(KReplaceChar, "\\%" ); |
|
1429 TBuf<10> buf; |
|
1430 buf.Copy( KSpecialChar ); |
|
1431 TInt position = iSearchText.FindF( buf ); |
|
1432 if ( position != KErrNotFound ) |
|
1433 { |
|
1434 buf.Copy( KReplaceChar ); |
|
1435 iSearchText.Replace( position,1,buf ); |
|
1436 } |
|
1437 |
|
1438 |
|
1439 if ( currentFolder == EEFolderRoot || currentFolder == EEFolderSearch ) |
|
1440 { |
|
1441 TInt currentIndex = iListBox->CurrentItemIndex(); |
|
1442 iState->SetQueryInfo( EEFolderSearch, KNullDesC, currentIndex, EEQueryDown ); |
|
1443 |
|
1444 QueryL( EEFolderSearch ); |
|
1445 } |
|
1446 else if ( currentFolder == EEFolderMusic || currentFolder == EEFolderSearchMusic ) |
|
1447 { |
|
1448 TInt currentIndex = iListBox->CurrentItemIndex(); |
|
1449 iState->SetQueryInfo( EEFolderSearchMusic, KNullDesC, currentIndex, EEQueryDown ); |
|
1450 |
|
1451 QueryL( EEFolderSearchMusic ); |
|
1452 } |
|
1453 } |
|
1454 |
|
1455 |
|
1456 //------------------------------------------------------------------------------ |
|
1457 // CMediaFileDialog::ResetDialogL |
|
1458 // |
|
1459 //------------------------------------------------------------------------------ |
|
1460 // |
|
1461 void CMediaFileDialog::ResetDialogL( TInt aError) |
|
1462 { |
|
1463 iMediaFileHandler->EnableObserverCall( EFalse ); |
|
1464 iMediaFileHandler->CancelQuery(); |
|
1465 iMediaFileHandler->EnableObserverCall( ETrue ); |
|
1466 |
|
1467 iState->Init(); |
|
1468 UpdateListBoxL(); |
|
1469 |
|
1470 if ( aError != KErrNone ) |
|
1471 { |
|
1472 ShowErrorNoteL( aError ); |
|
1473 } |
|
1474 } |
|
1475 |
|
1476 |
|
1477 //------------------------------------------------------------------------------ |
|
1478 // CMediaFileDialog::QueryL |
|
1479 // |
|
1480 //------------------------------------------------------------------------------ |
|
1481 // |
|
1482 void CMediaFileDialog::QueryL( TInt aFolderId, TBool aDatabaseChanged ) |
|
1483 { |
|
1484 if ( !iMediaFileHandler->QueryReady() || !iDatabaseOpen ) |
|
1485 { |
|
1486 FLOG( _L("### CMediaFileDialog::QueryL: query in progress ###") ); |
|
1487 return; |
|
1488 } |
|
1489 |
|
1490 iMediaFileHandler->EnableObserverCall( ETrue ); |
|
1491 |
|
1492 TInt folderId = aFolderId; |
|
1493 |
|
1494 iMediaFileHandler->SetQueryId( folderId ); |
|
1495 |
|
1496 if ( folderId == EEFolderAllMusic ) |
|
1497 { |
|
1498 iMediaFileHandler->QueryMusicL( 0 ); |
|
1499 } |
|
1500 |
|
1501 else if ( folderId == EEFolderVideos ) |
|
1502 { |
|
1503 iMediaFileHandler->QueryVideosL( 0 ); |
|
1504 } |
|
1505 |
|
1506 else if ( folderId == EEFolderArtistRoot || |
|
1507 folderId == EEFolderAlbumRoot || |
|
1508 folderId == EEFolderGenreRoot || |
|
1509 folderId == EEFolderComposerRoot ) |
|
1510 { |
|
1511 if ( iState->UnknownCount( folderId ) == KErrNotFound ) |
|
1512 { |
|
1513 TInt attr = MapAttribute( folderId ); |
|
1514 iMediaFileHandler->QueryMusicUnknownCountL( attr ); |
|
1515 } |
|
1516 else |
|
1517 { |
|
1518 TInt attr = MapAttribute( folderId ); |
|
1519 iMediaFileHandler->QueryAttributeValuesL( attr ); |
|
1520 } |
|
1521 } |
|
1522 |
|
1523 else if ( folderId == EEFolderAlbum || folderId == EEFolderGenre || |
|
1524 folderId == EEFolderComposer ) |
|
1525 { |
|
1526 TInt attr = MapAttribute( folderId ); |
|
1527 iState->GetText( folderId, iBuf ); |
|
1528 iMediaFileHandler->QueryMusicL( attr, iBuf ); |
|
1529 } |
|
1530 |
|
1531 else if ( folderId == EEFolderArtistUnknown || folderId == EEFolderAlbumUnknown || |
|
1532 folderId == EEFolderGenreUnknown ||folderId == EEFolderComposerUnknown ) |
|
1533 { |
|
1534 TInt attr = MapAttribute( folderId ); |
|
1535 iMediaFileHandler->QueryMusicUnknownL( attr ); |
|
1536 } |
|
1537 |
|
1538 else if ( folderId == EEFolderArtist ) |
|
1539 { |
|
1540 iState->GetText( EEFolderArtist, iBuf ); |
|
1541 iMediaFileHandler->QueryArtistL( CMediaFileHandler::EQueryArtist, |
|
1542 iBuf, KNullDesC, aDatabaseChanged ); |
|
1543 } |
|
1544 |
|
1545 else if ( folderId == EEFolderArtistAll ) |
|
1546 { |
|
1547 iState->GetText( EEFolderArtist, iBuf ); |
|
1548 iMediaFileHandler->QueryArtistL( CMediaFileHandler::EQueryArtistAll, |
|
1549 iBuf, KNullDesC, aDatabaseChanged ); |
|
1550 } |
|
1551 |
|
1552 else if ( folderId == EEFolderArtistAlbum ) |
|
1553 { |
|
1554 TBuf<KBufSize128> buf; |
|
1555 iState->GetText( EEFolderArtistAlbum, buf ); |
|
1556 iState->GetText( EEFolderArtist, iBuf ); |
|
1557 iMediaFileHandler->QueryArtistL( CMediaFileHandler::EQueryArtistAlbum, |
|
1558 iBuf, buf, aDatabaseChanged ); |
|
1559 } |
|
1560 |
|
1561 else if ( folderId == EEFolderArtistAlbumUnknown ) |
|
1562 { |
|
1563 iState->GetText( EEFolderArtist, iBuf ); |
|
1564 iMediaFileHandler->QueryArtistL( CMediaFileHandler::EQueryArtistUnknown, |
|
1565 iBuf, KNullDesC, aDatabaseChanged ); |
|
1566 } |
|
1567 |
|
1568 else if ( folderId == EEFolderTones ) |
|
1569 { |
|
1570 //iMediaFileHandler->QueryTonesL( 0 ); |
|
1571 iMediaFileHandler->QueryDefaultTonesL( 0 ); |
|
1572 ShowWaitNoteL( EFalse ); |
|
1573 } |
|
1574 |
|
1575 else if ( folderId == EEFolderRecordings ) |
|
1576 { |
|
1577 iMediaFileHandler->QueryRecordingsL( 0 ); |
|
1578 } |
|
1579 |
|
1580 else if ( folderId == EEFolderSearch ) |
|
1581 { |
|
1582 if ( iSearchText.Length() > 0 ) |
|
1583 { |
|
1584 iMediaFileHandler->SearchL( iSearchText ); |
|
1585 } |
|
1586 else |
|
1587 { |
|
1588 iMediaFileHandler->QueryEmptyL(); |
|
1589 } |
|
1590 } |
|
1591 else if ( folderId == EEFolderSearchMusic ) |
|
1592 { |
|
1593 if ( iSearchText.Length() > 0 ) |
|
1594 { |
|
1595 iMediaFileHandler->SearchAudioL( iSearchText ); |
|
1596 } |
|
1597 else |
|
1598 { |
|
1599 iMediaFileHandler->QueryEmptyL(); |
|
1600 } |
|
1601 } |
|
1602 else |
|
1603 { |
|
1604 // make empty query |
|
1605 iMediaFileHandler->QueryEmptyL(); |
|
1606 } |
|
1607 |
|
1608 if ( !iMediaFileHandler->QueryReady() ) |
|
1609 { |
|
1610 // query is running - show wait note with delay. wait note is |
|
1611 // removed in HandleMFEventL |
|
1612 ShowWaitNoteL( aDatabaseChanged ); |
|
1613 } |
|
1614 |
|
1615 #ifdef _DEBUG |
|
1616 iTest->SetTime(); |
|
1617 #endif |
|
1618 } |
|
1619 |
|
1620 |
|
1621 // ----------------------------------------------------------------------------- |
|
1622 // CMediaFileDialog::MapAttribute |
|
1623 // |
|
1624 // ----------------------------------------------------------------------------- |
|
1625 // |
|
1626 TInt CMediaFileDialog::MapAttribute( TInt aFolderId ) |
|
1627 { |
|
1628 TInt attr = KErrNotFound; |
|
1629 |
|
1630 switch ( aFolderId ) |
|
1631 { |
|
1632 case EEFolderArtistRoot: |
|
1633 case EEFolderArtist: |
|
1634 case EEFolderArtistUnknown: |
|
1635 { |
|
1636 attr = CMediaFileHandler::EAttrArtist; |
|
1637 break; |
|
1638 } |
|
1639 case EEFolderAlbumRoot: |
|
1640 case EEFolderAlbum: |
|
1641 case EEFolderAlbumUnknown: |
|
1642 { |
|
1643 attr = CMediaFileHandler::EAttrAlbum; |
|
1644 break; |
|
1645 } |
|
1646 case EEFolderGenreRoot: |
|
1647 case EEFolderGenre: |
|
1648 case EEFolderGenreUnknown: |
|
1649 { |
|
1650 attr = CMediaFileHandler::EAttrGenre; |
|
1651 break; |
|
1652 } |
|
1653 case EEFolderComposerRoot: |
|
1654 case EEFolderComposer: |
|
1655 case EEFolderComposerUnknown: |
|
1656 { |
|
1657 attr = CMediaFileHandler::EAttrComposer; |
|
1658 break; |
|
1659 } |
|
1660 default: |
|
1661 { |
|
1662 break; |
|
1663 } |
|
1664 } |
|
1665 |
|
1666 return attr; |
|
1667 } |
|
1668 |
|
1669 |
|
1670 // ----------------------------------------------------------------------------- |
|
1671 // CMediaFileDialog::ShowDetailsPopupL |
|
1672 // |
|
1673 // ----------------------------------------------------------------------------- |
|
1674 // |
|
1675 void CMediaFileDialog::ShowDetailsPopupL() |
|
1676 { |
|
1677 if ( !iMediaFileHandler->QueryReady() ) |
|
1678 { |
|
1679 return; // query in progress |
|
1680 } |
|
1681 |
|
1682 TInt currentIndex = CurrentItemListIndex(); |
|
1683 TInt folderId = iState->CurrentFolder(); |
|
1684 |
|
1685 if ( folderId != EEFolderSearch && folderId != EEFolderSearchMusic ) |
|
1686 { |
|
1687 return; |
|
1688 } |
|
1689 if ( currentIndex < 0 ) |
|
1690 { |
|
1691 return; |
|
1692 } |
|
1693 |
|
1694 TInt id = iMediaFileHandler->Attribute( currentIndex, |
|
1695 CMediaFileHandler::EAttrMediaFileId, |
|
1696 iState->CurrentFolder() ); |
|
1697 if ( id == KErrNotFound ) |
|
1698 { |
|
1699 return; |
|
1700 } |
|
1701 |
|
1702 TInt mediaType = iMediaFileHandler->Attribute( currentIndex, |
|
1703 CMediaFileHandler::EAttrMediaType, |
|
1704 iState->CurrentFolder() ); |
|
1705 |
|
1706 TInt storageType = iMediaFileHandler->Attribute( currentIndex, |
|
1707 CMediaFileHandler::EAttrStorageType, |
|
1708 iState->CurrentFolder() ); |
|
1709 |
|
1710 CMediaFileData* data = NULL; |
|
1711 |
|
1712 if ( storageType == CMediaFileHandler::ERomStorage ) |
|
1713 { |
|
1714 if ( mediaType == CMediaFileHandler::EMediaTypeTone ) |
|
1715 { |
|
1716 data = iMediaFileHandler->RomMediaFileDataL( id , CMediaFileHandler::EMediaTypeTone ); |
|
1717 } |
|
1718 if ( mediaType == CMediaFileHandler::EMediaTypeVideo ) |
|
1719 { |
|
1720 data = iMediaFileHandler->RomMediaFileDataL( id , CMediaFileHandler::EMediaTypeVideo ); |
|
1721 } |
|
1722 } |
|
1723 else |
|
1724 { |
|
1725 data = iMediaFileHandler->ReadMediaFileDataL( id ); |
|
1726 } |
|
1727 |
|
1728 CleanupStack::PushL( data ); |
|
1729 if ( data ) |
|
1730 { |
|
1731 GetPopupText( data, iPopupText ); |
|
1732 } |
|
1733 |
|
1734 CleanupStack::PopAndDestroy( data ); |
|
1735 |
|
1736 if ( iPopupText.Length() > 0 ) |
|
1737 { |
|
1738 ShowPopupNoteL( iPopupText ); |
|
1739 } |
|
1740 } |
|
1741 |
|
1742 |
|
1743 // ----------------------------------------------------------------------------- |
|
1744 // CMediaFileDialog::GetPopupText |
|
1745 // |
|
1746 // ----------------------------------------------------------------------------- |
|
1747 // |
|
1748 void CMediaFileDialog::GetPopupText( CMediaFileData* aData, TDes& aText ) |
|
1749 { |
|
1750 TBuf<KBufSize64> searchText; |
|
1751 TBuf<KBufSize64> attributeName; |
|
1752 |
|
1753 aText = KNullDesC; |
|
1754 |
|
1755 if ( FindBox()->TextLength() >= KBufSize64 ) |
|
1756 { |
|
1757 return; |
|
1758 } |
|
1759 FindBox()->GetSearchText( searchText ); |
|
1760 |
|
1761 aData->GetAttr( CMediaFileHandler::EAttrSongName, aText ); |
|
1762 if ( MatchFound( aText, searchText ) ) |
|
1763 { |
|
1764 aText = KNullDesC; |
|
1765 return; |
|
1766 } |
|
1767 |
|
1768 aData->GetAttr( CMediaFileHandler::EAttrArtist, aText ); |
|
1769 if ( MatchFound( aText, searchText ) ) |
|
1770 { |
|
1771 StringLoader::Load( attributeName, R_QTN_PREVIEW_POPUP_ARTIST ); |
|
1772 aText.Insert( 0, attributeName ); |
|
1773 return; |
|
1774 } |
|
1775 |
|
1776 aData->GetAttr( CMediaFileHandler::EAttrAlbum, aText ); |
|
1777 if ( MatchFound( aText, searchText ) ) |
|
1778 { |
|
1779 StringLoader::Load( attributeName, R_QTN_PREVIEW_POPUP_ALBUM ); |
|
1780 aText.Insert( 0, attributeName ); |
|
1781 return; |
|
1782 } |
|
1783 |
|
1784 aData->GetAttr( CMediaFileHandler::EAttrGenre, aText ); |
|
1785 if ( MatchFound( aText, searchText ) ) |
|
1786 { |
|
1787 StringLoader::Load( attributeName, R_QTN_PREVIEW_POPUP_GENRE ); |
|
1788 aText.Insert( 0, attributeName ); |
|
1789 return; |
|
1790 } |
|
1791 |
|
1792 aData->GetAttr( CMediaFileHandler::EAttrComposer, aText ); |
|
1793 if ( MatchFound( aText, searchText ) ) |
|
1794 { |
|
1795 StringLoader::Load( attributeName, R_QTN_PREVIEW_POPUP_COMPOSER ); |
|
1796 aText.Insert( 0, attributeName ); |
|
1797 return; |
|
1798 } |
|
1799 |
|
1800 aText = KNullDesC; |
|
1801 } |
|
1802 |
|
1803 |
|
1804 // ----------------------------------------------------------------------------- |
|
1805 // CMediaFileDialog::MatchFound |
|
1806 // |
|
1807 // ----------------------------------------------------------------------------- |
|
1808 // |
|
1809 TBool CMediaFileDialog::MatchFound( const TDesC& aAttribute, |
|
1810 const TDesC& aText ) |
|
1811 { |
|
1812 _LIT( KSpace, " " ); |
|
1813 |
|
1814 if ( aText.Length() >= KBufSize64 ) |
|
1815 { |
|
1816 return EFalse; // too long search text |
|
1817 } |
|
1818 |
|
1819 if ( aAttribute.FindC( aText ) == 0 ) |
|
1820 { |
|
1821 // match found from the beginning of the first word |
|
1822 return ETrue; |
|
1823 } |
|
1824 |
|
1825 TBuf<KBufSize64> buf; |
|
1826 buf = aText; |
|
1827 buf.Insert( 0, KSpace ); |
|
1828 |
|
1829 if ( aAttribute.FindC( buf ) != KErrNotFound ) |
|
1830 { |
|
1831 // match found from the beginning of the word |
|
1832 return ETrue; |
|
1833 } |
|
1834 |
|
1835 return EFalse; |
|
1836 } |
|
1837 |
|
1838 |
|
1839 // ----------------------------------------------------------------------------- |
|
1840 // CMediaFileDialog::PreviewL |
|
1841 // |
|
1842 // ----------------------------------------------------------------------------- |
|
1843 // |
|
1844 void CMediaFileDialog::PreviewL( TInt aMediaType ) |
|
1845 { |
|
1846 //FLOG( _L("CMediaFileDialog::PreviewL START") ); |
|
1847 |
|
1848 if ( !iMediaFileHandler->QueryReady() ) |
|
1849 { |
|
1850 FLOG( _L("### CMediaFileDialog::PreviewL: query in progress ###") ); |
|
1851 return; // query in progress |
|
1852 } |
|
1853 |
|
1854 if ( !iForeGround ) |
|
1855 { |
|
1856 return; // dialog is not visible |
|
1857 } |
|
1858 |
|
1859 TInt currentIndex = CurrentItemListIndex(); |
|
1860 if ( currentIndex == KErrNotFound ) |
|
1861 { |
|
1862 return; // list is empty |
|
1863 } |
|
1864 |
|
1865 TInt folderId = iState->FolderId( currentIndex ); |
|
1866 if ( folderId == EEFolderNullItemOne || folderId == EEFolderNullItemTwo ) |
|
1867 { |
|
1868 PreviewNullItemL( folderId ); |
|
1869 return; |
|
1870 } |
|
1871 |
|
1872 if ( folderId != KErrNotFound ) |
|
1873 { |
|
1874 return; // focused list item is folder |
|
1875 } |
|
1876 |
|
1877 |
|
1878 if ( iState->CurrentFolder() == EEFolderVideos && |
|
1879 aMediaType != CMediaFileList::EMediaFileTypeVideo ) |
|
1880 { |
|
1881 return; |
|
1882 } |
|
1883 |
|
1884 GetSelectedItemFileName( currentIndex, iBuf ); |
|
1885 if ( iBuf.Length() == 0 ) |
|
1886 { |
|
1887 return; |
|
1888 } |
|
1889 |
|
1890 if ( aMediaType == CMediaFileList::EMediaFileTypeVideo ) |
|
1891 { |
|
1892 PreviewVideoL( iBuf ); |
|
1893 return; |
|
1894 } |
|
1895 |
|
1896 if ( iState->CurrentFolder() == EEFolderSearch ) |
|
1897 { |
|
1898 if ( IsVideoFile( currentIndex ) ) |
|
1899 { |
|
1900 return; // search folder may contain videos - no automatic preview |
|
1901 } |
|
1902 } |
|
1903 |
|
1904 if ( !iProtectionHandler->IsFileValid( iBuf, CMFProtectionHandler::EPlay ) ) |
|
1905 { |
|
1906 return; |
|
1907 } |
|
1908 |
|
1909 iAudioPreviewHandler->SetAttrL( TMFDialogUtil::EAttrFileName, iBuf ); |
|
1910 iAudioPreviewHandler->PlayL(); |
|
1911 |
|
1912 //FLOG( _L("CMediaFileDialog::PreviewL END") ); |
|
1913 } |
|
1914 |
|
1915 |
|
1916 // ----------------------------------------------------------------------------- |
|
1917 // CMediaFileDialog::PreviewVideoL |
|
1918 // |
|
1919 // ----------------------------------------------------------------------------- |
|
1920 // |
|
1921 void CMediaFileDialog::PreviewVideoL( const TDesC& aFileName ) |
|
1922 { |
|
1923 if ( !iProtectionHandler->IsVideoValid( aFileName, CMFProtectionHandler::EPlay ) ) |
|
1924 { |
|
1925 return; |
|
1926 } |
|
1927 |
|
1928 // in case "Beep once" one audio beep is played before showing video |
|
1929 TInt type = iAudioPreviewHandler->Attr( CMediaFileList::EAttrRingingType ); |
|
1930 if ( type == CMFPreviewHandlerBase::ERingingTypeBeepOnce ) |
|
1931 { |
|
1932 iAudioPreviewHandler->SetAttrL( TMFDialogUtil::EAttrFileName, aFileName ); |
|
1933 iAudioPreviewHandler->PlayL(); |
|
1934 } |
|
1935 |
|
1936 iVideoPreviewHandler->SetAttrL( TMFDialogUtil::EAttrFileName, aFileName ); |
|
1937 TInt err = KErrNone; |
|
1938 if ( iVideoPreviewDlg && iVideoPreviewHandler->IsPlaying() ) |
|
1939 { |
|
1940 iVideoPreviewDlg->CloseDialogL(); |
|
1941 iVideoPreviewDlg = NULL; |
|
1942 } |
|
1943 iVideoPreviewDlg = CVideoPreviewDialog::NewL( iVideoPreviewHandler ); |
|
1944 TBool ret = iVideoPreviewDlg->ShowDialogLD( &err ); |
|
1945 |
|
1946 if ( err != KErrNone ) |
|
1947 { |
|
1948 FLOG( _L("### CVideoPreviewDialog::ShowDialogLD (%d) ###"), err ); |
|
1949 } |
|
1950 |
|
1951 ShowPreviewErrorNoteL( err, CMediaFileHandler::EMediaTypeVideo ); |
|
1952 |
|
1953 if ( ret ) |
|
1954 { |
|
1955 CloseDialogWithDelayL(); |
|
1956 } |
|
1957 } |
|
1958 |
|
1959 |
|
1960 // ----------------------------------------------------------------------------- |
|
1961 // CMediaFileDialog::PreviewLNullItemL |
|
1962 // |
|
1963 // ----------------------------------------------------------------------------- |
|
1964 // |
|
1965 void CMediaFileDialog::PreviewNullItemL( TInt aFolderId ) |
|
1966 { |
|
1967 HBufC* fileName = NULL; |
|
1968 TInt fileType = KErrNotFound; |
|
1969 |
|
1970 if ( aFolderId == EEFolderNullItemOne ) |
|
1971 { |
|
1972 fileType = iNullItemFileTypeOne; |
|
1973 fileName = iNullItemFileNameOne; |
|
1974 } |
|
1975 if ( aFolderId == EEFolderNullItemTwo ) |
|
1976 { |
|
1977 fileType = iNullItemFileTypeTwo; |
|
1978 fileName = iNullItemFileNameTwo; |
|
1979 } |
|
1980 |
|
1981 if ( fileType != CMediaFileList::EMediaFileTypeAudio && |
|
1982 fileType != CMediaFileList::EMediaFileTypeVideo ) |
|
1983 { |
|
1984 return; |
|
1985 } |
|
1986 if ( !fileName ) |
|
1987 { |
|
1988 return; |
|
1989 } |
|
1990 |
|
1991 if ( fileType == CMediaFileList::EMediaFileTypeAudio ) |
|
1992 { |
|
1993 iAudioPreviewHandler->SetAttrL( TMFDialogUtil::EAttrFileName, *fileName ); |
|
1994 iAudioPreviewHandler->PlayL(); |
|
1995 } |
|
1996 if ( fileType == CMediaFileList::EMediaFileTypeVideo ) |
|
1997 { |
|
1998 // null item file type cannot be video |
|
1999 } |
|
2000 } |
|
2001 |
|
2002 |
|
2003 //------------------------------------------------------------------------------ |
|
2004 // CMediaFileDialog::CancelPreview |
|
2005 // |
|
2006 //------------------------------------------------------------------------------ |
|
2007 // |
|
2008 void CMediaFileDialog::CancelPreview() |
|
2009 { |
|
2010 iAudioPreviewHandler->Stop(); |
|
2011 iCaller->Cancel(); |
|
2012 } |
|
2013 |
|
2014 |
|
2015 // ----------------------------------------------------------------------------- |
|
2016 // CMediaFileDialog::StartPreviewWithDelay |
|
2017 // |
|
2018 // ----------------------------------------------------------------------------- |
|
2019 // |
|
2020 void CMediaFileDialog::StartPreviewWithDelay() |
|
2021 { |
|
2022 const TInt KOneSecond = 1000; |
|
2023 |
|
2024 iAudioPreviewHandler->Stop(); |
|
2025 |
|
2026 // automatic preview starts after delay. see HandleActiveCallL. |
|
2027 iCaller->Start( EAttrPreview, KOneSecond ); |
|
2028 } |
|
2029 |
|
2030 |
|
2031 // ----------------------------------------------------------------------------- |
|
2032 // CMediaFileDialog::StartSearchWithDelay |
|
2033 // |
|
2034 // ----------------------------------------------------------------------------- |
|
2035 // |
|
2036 void CMediaFileDialog::StartSearchWithDelay() |
|
2037 { |
|
2038 if ( iPeninputActive ) |
|
2039 { |
|
2040 // search does not start automatically in pen input mode |
|
2041 return; |
|
2042 } |
|
2043 |
|
2044 const TInt KOneSecond = 1000; |
|
2045 |
|
2046 // search starts after delay. see HandleActiveCallL. |
|
2047 iSearchCaller->Start( EAttrSearch, KOneSecond ); |
|
2048 } |
|
2049 |
|
2050 |
|
2051 // ----------------------------------------------------------------------------- |
|
2052 // CMediaFileDialog::StartRomScan() |
|
2053 // |
|
2054 // ----------------------------------------------------------------------------- |
|
2055 // |
|
2056 void CMediaFileDialog::StartRomScan() |
|
2057 { |
|
2058 delete iIdle; |
|
2059 iIdle = NULL; |
|
2060 iIdle = CIdle::NewL( CActive::EPriorityIdle ); |
|
2061 |
|
2062 if ( iIdle ) |
|
2063 { |
|
2064 iIdle->Start( TCallBack( StartRomScaning, iMediaFileHandler ) ); |
|
2065 } |
|
2066 } |
|
2067 |
|
2068 // ----------------------------------------------------------------------------- |
|
2069 // CMediaFileDialog::StartRomScaning() |
|
2070 // |
|
2071 // ----------------------------------------------------------------------------- |
|
2072 // |
|
2073 |
|
2074 TInt CMediaFileDialog::StartRomScaning( TAny* aInstance ) |
|
2075 { |
|
2076 CMediaFileHandler* handler = static_cast<CMediaFileHandler*> ( aInstance ); |
|
2077 handler->StartRomScaning( CMediaFileHandler::EQueryTone ); |
|
2078 return 0; |
|
2079 } |
|
2080 |
|
2081 // ----------------------------------------------------------------------------- |
|
2082 // CMediaFileDialog::IsVideoFile |
|
2083 // |
|
2084 // ----------------------------------------------------------------------------- |
|
2085 // |
|
2086 TBool CMediaFileDialog::IsVideoFile( TInt aCurrentIndex ) |
|
2087 { |
|
2088 if ( aCurrentIndex < 0 ) |
|
2089 { |
|
2090 return EFalse; |
|
2091 } |
|
2092 |
|
2093 TInt current = iState->CurrentFolder(); |
|
2094 |
|
2095 if ( current == EEFolderVideos ) |
|
2096 { |
|
2097 return ETrue; |
|
2098 } |
|
2099 |
|
2100 if ( current != EEFolderSearch ) |
|
2101 { |
|
2102 return EFalse; |
|
2103 } |
|
2104 |
|
2105 TInt mediaType = iMediaFileHandler->Attribute( aCurrentIndex, |
|
2106 CMediaFileHandler::EAttrMediaType, |
|
2107 current ); |
|
2108 |
|
2109 if ( mediaType == CMediaFileHandler::EMediaTypeVideo ) |
|
2110 { |
|
2111 return ETrue; |
|
2112 } |
|
2113 |
|
2114 return EFalse; |
|
2115 } |
|
2116 |
|
2117 |
|
2118 // ----------------------------------------------------------------------------- |
|
2119 // CMediaFileDialog::IsValidVideoFileL |
|
2120 // |
|
2121 // ----------------------------------------------------------------------------- |
|
2122 // |
|
2123 TBool CMediaFileDialog::IsValidVideoFileL( TInt aCurrentIndex, TInt aIntention ) |
|
2124 { |
|
2125 TBuf<KBufSize128> buf; |
|
2126 |
|
2127 if ( !IsVideoFile( aCurrentIndex ) ) |
|
2128 { |
|
2129 return EFalse; |
|
2130 } |
|
2131 |
|
2132 CMFProtectionHandler::TIntention intention; |
|
2133 if ( aIntention == CMFProtectionHandler::EPlay ) |
|
2134 { |
|
2135 intention = CMFProtectionHandler::EPlay; |
|
2136 } |
|
2137 else |
|
2138 { |
|
2139 intention = CMFProtectionHandler::ESelect; |
|
2140 } |
|
2141 GetSelectedItemFileName( aCurrentIndex, buf ); |
|
2142 |
|
2143 if ( iProtectionHandler->IsVideoValid( buf, intention ) ) |
|
2144 { |
|
2145 return ETrue; |
|
2146 } |
|
2147 return EFalse; |
|
2148 } |
|
2149 |
|
2150 |
|
2151 |
|
2152 // ---------------------------------------------------------------------------- |
|
2153 // CMediaFileDialog::UpdateListBoxL |
|
2154 // |
|
2155 // Update listbox contents (currently open folder items). |
|
2156 // ---------------------------------------------------------------------------- |
|
2157 // |
|
2158 void CMediaFileDialog::UpdateListBoxL( TBool aRestFindBox ) |
|
2159 { |
|
2160 // prevent flickering during listbox update. ResetFindBoxL seems |
|
2161 // to draw listbox many times |
|
2162 iListBox->MakeVisible( EFalse ); |
|
2163 |
|
2164 TRAP_IGNORE( DoUpdateListBoxL( aRestFindBox ) ); |
|
2165 |
|
2166 iListBox->MakeVisible( ETrue ); |
|
2167 } |
|
2168 |
|
2169 |
|
2170 // ---------------------------------------------------------------------------- |
|
2171 // CMediaFileDialog::DoUpdateListBoxL |
|
2172 // |
|
2173 // Update listbox contents (currently open folder items). |
|
2174 // ---------------------------------------------------------------------------- |
|
2175 // |
|
2176 void CMediaFileDialog::DoUpdateListBoxL( TBool aRestFindBox ) |
|
2177 { |
|
2178 iState->SetUnknownFolderPosition( iMediaFileHandler->ResultCount() ); |
|
2179 |
|
2180 // check current item index in case media file database has changed |
|
2181 CheckListboxIndex(); |
|
2182 if ( aRestFindBox ) |
|
2183 { |
|
2184 ResetFindBoxL(); |
|
2185 iListBox->HandleItemAdditionL(); |
|
2186 } |
|
2187 |
|
2188 TInt index = iState->CurrentItemIndex(); |
|
2189 if ( index >= 0 && index < iListBox->Model()->NumberOfItems() ) |
|
2190 { |
|
2191 iListBox->SetCurrentItemIndex( index ); |
|
2192 } |
|
2193 else |
|
2194 { |
|
2195 iListBox->SetCurrentItemIndex( 0 ); |
|
2196 } |
|
2197 |
|
2198 TBuf<KBufSize128> buf; |
|
2199 if ( iState->CurrentFolder() == EEFolderSearch || |
|
2200 iState->CurrentFolder() == EEFolderSearchMusic ) |
|
2201 { |
|
2202 TInt count = iListBox->Model()->NumberOfItems(); |
|
2203 iState->GetSearchTitle( buf, count ); |
|
2204 } |
|
2205 else |
|
2206 { |
|
2207 iState->GetTitle( iState->CurrentFolder(), buf ); |
|
2208 //#ifdef _DEBUG |
|
2209 TInt folder = iState->CurrentFolder(); |
|
2210 if ( iState->FindBoxNeeded() && folder != EEFolderMusic && |
|
2211 folder != EEFolderRoot ) |
|
2212 { |
|
2213 TBuf<KBufSize128> buf2( buf ); |
|
2214 TInt count = iListBox->Model()->NumberOfItems(); |
|
2215 buf.Format( _L("%S (%d)"), &buf2, count ); |
|
2216 } |
|
2217 //#endif |
|
2218 } |
|
2219 |
|
2220 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( buf ); |
|
2221 iStatusPaneHandler->SetNaviPaneTitle( buf ); |
|
2222 |
|
2223 UpdateCbaL( 0 ); |
|
2224 |
|
2225 DrawNow(); |
|
2226 |
|
2227 if ( iState->QueryDirection() != EEQueryUpdate ) |
|
2228 { |
|
2229 CancelPreview(); |
|
2230 } |
|
2231 |
|
2232 ShowDetailsPopupL(); // for search view info popup |
|
2233 } |
|
2234 |
|
2235 |
|
2236 // ----------------------------------------------------------------------------- |
|
2237 // CMediaFileDialog::UpdateCbaL |
|
2238 // |
|
2239 // Update cba. NOTE: Commented code (menu cba) is for (possible) future use. |
|
2240 // ----------------------------------------------------------------------------- |
|
2241 // |
|
2242 void CMediaFileDialog::UpdateCbaL( TInt /*aAttr*/ ) |
|
2243 { |
|
2244 TInt itemCount = iListBox->Model()->NumberOfItems(); |
|
2245 TInt currentIndex = CurrentItemListIndex(); |
|
2246 TInt folderId = iState->FolderId( currentIndex ); |
|
2247 TInt currentFolderId = iState->CurrentFolder(); |
|
2248 |
|
2249 |
|
2250 CEikButtonGroupContainer& cba = ButtonGroupContainer(); // from eikbtgpc.h |
|
2251 |
|
2252 |
|
2253 // Videos folder |
|
2254 if ( currentFolderId == EEFolderVideos ) |
|
2255 { |
|
2256 if ( itemCount == 0 ) |
|
2257 { |
|
2258 cba.SetCommandSetL( R_AVKON_SOFTKEYS_BACK ); |
|
2259 //cba.SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_BACK ); |
|
2260 } |
|
2261 else |
|
2262 { |
|
2263 if ( IsValidVideoFileL( currentIndex, CMFProtectionHandler::EPlay ) ) |
|
2264 { |
|
2265 cba.SetCommandSetL( R_MEDIA_FILE_DIALOG_CBA_PREVIEW_SELECT_BACK ); |
|
2266 } |
|
2267 else |
|
2268 { |
|
2269 cba.SetCommandSetL( R_MEDIA_FILE_DIALOG_CBA_SELECT_SELECT_BACK ); |
|
2270 } |
|
2271 |
|
2272 //cba.SetCommandSetL( R_MEDIA_FILE_DIALOG_CBA_OPTIONS_CONTEXT_BACK ); |
|
2273 } |
|
2274 return; |
|
2275 } |
|
2276 |
|
2277 |
|
2278 // Search folder |
|
2279 if ( currentFolderId == EEFolderSearch || |
|
2280 currentFolderId == EEFolderSearchMusic ) |
|
2281 { |
|
2282 if ( itemCount == 0 ) |
|
2283 { |
|
2284 cba.SetCommandSetL( R_AVKON_SOFTKEYS_BACK ); |
|
2285 // cba.SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_BACK ); |
|
2286 } |
|
2287 else |
|
2288 { |
|
2289 if ( IsValidVideoFileL( currentIndex, CMFProtectionHandler::EPlay ) ) |
|
2290 { |
|
2291 cba.SetCommandSetL( R_MEDIA_FILE_DIALOG_CBA_PREVIEW_SELECT_BACK ); |
|
2292 } |
|
2293 else |
|
2294 { |
|
2295 cba.SetCommandSetL( R_MEDIA_FILE_DIALOG_CBA_SELECT_SELECT_BACK ); |
|
2296 } |
|
2297 //cba.SetCommandSetL( R_MEDIA_FILE_DIALOG_CBA_OPTIONS_SELECT_BACK ); |
|
2298 } |
|
2299 return; |
|
2300 } |
|
2301 |
|
2302 |
|
2303 // Root folder |
|
2304 if ( currentFolderId == EEFolderRoot ) |
|
2305 { |
|
2306 if ( folderId == EEFolderDownload || folderId == EEFolderNullItemOne || |
|
2307 folderId == EEFolderNullItemTwo ) |
|
2308 { |
|
2309 //cba.SetCommandSetL( R_MEDIA_FILE_DIALOG_CBA_OPTIONS_SELECT_BACK ); |
|
2310 cba.SetCommandSetL( R_MEDIA_FILE_DIALOG_CBA_SELECT_SELECT_BACK ); |
|
2311 } |
|
2312 else |
|
2313 { |
|
2314 //cba.SetCommandSetL( R_MEDIA_FILE_DIALOG_CBA_OPTIONS_OPEN_BACK ); |
|
2315 cba.SetCommandSetL( R_MEDIA_FILE_DIALOG_CBA_OPEN_OPEN_BACK ); |
|
2316 } |
|
2317 return; |
|
2318 } |
|
2319 |
|
2320 |
|
2321 // other folders |
|
2322 if ( itemCount == 0 ) |
|
2323 { |
|
2324 // folder is empty |
|
2325 cba.SetCommandSetL( R_AVKON_SOFTKEYS_BACK ); |
|
2326 //cba.SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_BACK ); |
|
2327 } |
|
2328 else if ( folderId != KErrNotFound ) |
|
2329 { |
|
2330 // list items are folders |
|
2331 cba.SetCommandSetL( R_MEDIA_FILE_DIALOG_CBA_OPEN_OPEN_BACK ); |
|
2332 //cba.SetCommandSetL( R_MEDIA_FILE_DIALOG_CBA_OPTIONS_OPEN_BACK ); |
|
2333 } |
|
2334 else |
|
2335 { |
|
2336 // list items are files |
|
2337 cba.SetCommandSetL( R_MEDIA_FILE_DIALOG_CBA_SELECT_SELECT_BACK ); |
|
2338 //cba.SetCommandSetL( R_MEDIA_FILE_DIALOG_CBA_OPTIONS_SELECT_BACK ); |
|
2339 } |
|
2340 } |
|
2341 |
|
2342 |
|
2343 // ----------------------------------------------------------------------------- |
|
2344 // CMediaFileDialog::Panic |
|
2345 // |
|
2346 // ----------------------------------------------------------------------------- |
|
2347 // |
|
2348 void CMediaFileDialog::Panic( TInt aReason ) |
|
2349 { |
|
2350 _LIT( KPanicCategory, "CMediaFileDialog" ); |
|
2351 |
|
2352 User::Panic( KPanicCategory, aReason ); |
|
2353 } |
|
2354 |
|
2355 |
|
2356 // ----------------------------------------------------------------------------- |
|
2357 // CMediaFileDialog::ShowErrorNoteL |
|
2358 // |
|
2359 // ----------------------------------------------------------------------------- |
|
2360 // |
|
2361 void CMediaFileDialog::ShowErrorNoteL( TInt aError ) |
|
2362 { |
|
2363 TInt err = aError; |
|
2364 |
|
2365 if ( err == KErrNone ) |
|
2366 { |
|
2367 return; |
|
2368 } |
|
2369 |
|
2370 iBuf = KNullDesC; |
|
2371 CTextResolver* tr = CTextResolver::NewLC(); |
|
2372 iBuf = tr->ResolveErrorString( err, CTextResolver::ECtxNoCtxNoSeparator ); |
|
2373 CleanupStack::PopAndDestroy( tr ); |
|
2374 |
|
2375 if ( iBuf.Length() > 0 ) |
|
2376 { |
|
2377 TMFDialogUtil::ShowErrorNoteL( iBuf ); |
|
2378 } |
|
2379 } |
|
2380 |
|
2381 |
|
2382 // ----------------------------------------------------------------------------- |
|
2383 // CMediaFileDialog::ShowPreviewErrorNoteL |
|
2384 // |
|
2385 // ----------------------------------------------------------------------------- |
|
2386 // |
|
2387 void CMediaFileDialog::ShowPreviewErrorNoteL( TInt aError, TInt aMediaType ) |
|
2388 { |
|
2389 TInt err = KErrNone; |
|
2390 |
|
2391 if ( aError == KErrNoMemory || aError == KErrDiskFull ) |
|
2392 { |
|
2393 CTextResolver* tr = CTextResolver::NewLC(); |
|
2394 iBuf = tr->ResolveErrorString( aError, CTextResolver::ECtxNoCtxNoSeparator ); |
|
2395 CleanupStack::PopAndDestroy( tr ); |
|
2396 err = aError; |
|
2397 } |
|
2398 else if ( aError == KErrNotSupported || aError == KErrCorrupt ||aError == KErrMMPartialPlayback) |
|
2399 { |
|
2400 if ( aMediaType == CMediaFileHandler::EMediaTypeVideo ) |
|
2401 { |
|
2402 StringLoader::Load( iBuf, R_QTN_INFO_CLIP_FORMAT_ERROR ); |
|
2403 } |
|
2404 else |
|
2405 { |
|
2406 StringLoader::Load( iBuf, R_QTN_INFO_FILE_FORMAT_ERROR ); |
|
2407 } |
|
2408 err = aError; |
|
2409 } |
|
2410 |
|
2411 if ( err == KErrNone ) |
|
2412 { |
|
2413 return; |
|
2414 } |
|
2415 |
|
2416 #ifdef _DEBUG |
|
2417 TMFDialogUtil::ShowErrorNoteL( iBuf, aError ); |
|
2418 #else |
|
2419 TMFDialogUtil::ShowErrorNoteL( iBuf ); |
|
2420 #endif |
|
2421 |
|
2422 } |
|
2423 |
|
2424 |
|
2425 //------------------------------------------------------------------------------ |
|
2426 // CMediaFileDialog::ShowWaitNoteL |
|
2427 // |
|
2428 //------------------------------------------------------------------------------ |
|
2429 // |
|
2430 void CMediaFileDialog::ShowWaitNoteL( TBool aDatabaseChanged ) |
|
2431 { |
|
2432 TBuf<KBufSize128> buf; |
|
2433 |
|
2434 if ( aDatabaseChanged ) |
|
2435 { |
|
2436 StringLoader::Load( buf, R_QTN_WAIT_NOTE_UPDATE ); |
|
2437 //buf = _L("Refreshing"); |
|
2438 } |
|
2439 else if ( iState->QueryFolder() == EEFolderSearch || |
|
2440 iState->QueryFolder() == EEFolderSearchMusic ) |
|
2441 { |
|
2442 StringLoader::Load( buf, R_QTN_WAIT_NOTE_SEARCH ); |
|
2443 } |
|
2444 else |
|
2445 { |
|
2446 StringLoader::Load( buf, R_QTN_WAIT_NOTE_OPEN ); |
|
2447 } |
|
2448 |
|
2449 iWaitNote->LaunchL( buf ); |
|
2450 } |
|
2451 |
|
2452 |
|
2453 // ----------------------------------------------------------------------------- |
|
2454 // CMediaFileDialog::DeleteMenuItem |
|
2455 // |
|
2456 // ----------------------------------------------------------------------------- |
|
2457 // |
|
2458 void CMediaFileDialog::DeleteMenuItem( CEikMenuPane* aMenuPane, TInt aCommandId ) |
|
2459 { |
|
2460 TInt pos = KErrNotFound; |
|
2461 if ( aMenuPane->MenuItemExists( aCommandId, pos ) ) |
|
2462 { |
|
2463 aMenuPane->DeleteMenuItem( aCommandId ); |
|
2464 } |
|
2465 } |
|
2466 |
|
2467 |
|
2468 // ----------------------------------------------------------------------------- |
|
2469 // CMediaFileDialog::ShowPopupNote |
|
2470 // |
|
2471 // ----------------------------------------------------------------------------- |
|
2472 // |
|
2473 void CMediaFileDialog::ShowPopupNoteL( const TDesC& aText ) |
|
2474 { |
|
2475 const TInt KPopupDisplayTime = 3*1000; |
|
2476 const TInt KPopupDelayTime = 500; |
|
2477 |
|
2478 iPopupNote->SetTextL( aText ); |
|
2479 iPopupNote->SetTimeDelayBeforeShow( KPopupDelayTime ); |
|
2480 iPopupNote->SetTimePopupInView( KPopupDisplayTime ); |
|
2481 iPopupNote->ShowInfoPopupNote(); |
|
2482 } |
|
2483 |
|
2484 |
|
2485 // ----------------------------------------------------------------------------- |
|
2486 // CMediaFileDialog::CurrentItemListIndex |
|
2487 // |
|
2488 // ----------------------------------------------------------------------------- |
|
2489 // |
|
2490 TInt CMediaFileDialog::CurrentItemListIndex() |
|
2491 { |
|
2492 TInt itemCount = iListBox->Model()->NumberOfItems(); |
|
2493 TInt currentIndex = iListBox->CurrentItemIndex(); |
|
2494 |
|
2495 if ( itemCount == 0 || currentIndex < 0 ) |
|
2496 { |
|
2497 return KErrNotFound; // list or find box is empty |
|
2498 } |
|
2499 |
|
2500 // convert from findbox index into original list index |
|
2501 if ( FindBox() && FindBox()->IsVisible() ) |
|
2502 { |
|
2503 TInt tempIndex = currentIndex; |
|
2504 CAknFilteredTextListBoxModel* model = |
|
2505 STATIC_CAST(CAknFilteredTextListBoxModel*, iListBox->Model()); |
|
2506 |
|
2507 if ( model->Filter() ) |
|
2508 { |
|
2509 currentIndex = model->Filter()->FilteredItemIndex( tempIndex ); |
|
2510 } |
|
2511 } |
|
2512 |
|
2513 return currentIndex; |
|
2514 } |
|
2515 |
|
2516 |
|
2517 //------------------------------------------------------------------------------ |
|
2518 // CMediaFileDialog::GetSelectedItemFileName |
|
2519 // |
|
2520 //------------------------------------------------------------------------------ |
|
2521 // |
|
2522 void CMediaFileDialog::GetSelectedItemFileName( TInt aListboxIndex, TDes& aFileName ) |
|
2523 { |
|
2524 aFileName = KNullDesC; |
|
2525 |
|
2526 __ASSERT_DEBUG( iState->QueryNeeded(), Panic( KErrGeneral ) ); |
|
2527 |
|
2528 TInt id = iState->CurrentFolder(); |
|
2529 |
|
2530 // read selected list item text from metadata |
|
2531 TInt extraIndexes = iState->LeadingPersistentFolderCount(); |
|
2532 TInt queryIndex = aListboxIndex - extraIndexes; |
|
2533 |
|
2534 iMediaFileHandler->GetAttribute( queryIndex, CMediaFileHandler::EAttrFullName, |
|
2535 aFileName, id ); |
|
2536 } |
|
2537 |
|
2538 |
|
2539 // ----------------------------------------------------------------------------- |
|
2540 // CMediaFileDialog::ConstructListboxItem |
|
2541 // |
|
2542 // ----------------------------------------------------------------------------- |
|
2543 // |
|
2544 TPtrC CMediaFileDialog::ConstructListboxItem( TInt aListboxIndex ) |
|
2545 { |
|
2546 _LIT( KFormat2, "%d\t%S\t%d" ); |
|
2547 |
|
2548 TBool isPersistent = EFalse; |
|
2549 TInt mediaTypeIcon = EEIconEmpty; |
|
2550 TInt storageTypeIcon = EEIconEmpty; |
|
2551 TInt folderId = KErrNotFound; |
|
2552 iState->GetFolderInfo( aListboxIndex, folderId, iListboxItemText1, |
|
2553 isPersistent, mediaTypeIcon ); |
|
2554 if ( folderId != KErrNotFound ) |
|
2555 { |
|
2556 if ( !isPersistent ) |
|
2557 { |
|
2558 GetListItemText( aListboxIndex, iListboxItemText1 ); |
|
2559 } |
|
2560 } |
|
2561 else |
|
2562 { |
|
2563 GetListItemText( aListboxIndex, iListboxItemText1 ); |
|
2564 mediaTypeIcon = MediaTypeIcon( aListboxIndex ); |
|
2565 storageTypeIcon = StorageTypeIcon( aListboxIndex ); |
|
2566 } |
|
2567 |
|
2568 iListboxItemText2.Format( KFormat2, mediaTypeIcon, &iListboxItemText1, storageTypeIcon ); |
|
2569 return iListboxItemText2; |
|
2570 } |
|
2571 |
|
2572 |
|
2573 // ----------------------------------------------------------------------------- |
|
2574 // CMediaFileDialog::MediaTypeIcon |
|
2575 // |
|
2576 // ----------------------------------------------------------------------------- |
|
2577 // |
|
2578 TInt CMediaFileDialog::MediaTypeIcon( TInt aListboxIndex ) |
|
2579 { |
|
2580 if ( aListboxIndex < 0 ) |
|
2581 { |
|
2582 return EEIconEmpty; |
|
2583 } |
|
2584 |
|
2585 TInt mediaType = iMediaFileHandler->Attribute( aListboxIndex, |
|
2586 CMediaFileHandler::EAttrMediaType, |
|
2587 iState->CurrentFolder() ); |
|
2588 |
|
2589 TInt iconId = EEIconMusic; |
|
2590 if ( mediaType == CMediaFileHandler::EMediaTypeTone ) |
|
2591 { |
|
2592 iconId = EEIconTone; |
|
2593 } |
|
2594 else if ( mediaType == CMediaFileHandler::EMediaTypeVideo ) |
|
2595 { |
|
2596 iconId = EEIconVideo; |
|
2597 } |
|
2598 else if ( mediaType == CMediaFileHandler::EMediaTypeRecording ) |
|
2599 { |
|
2600 iconId = EEIconRecording; |
|
2601 } |
|
2602 |
|
2603 return iconId; |
|
2604 } |
|
2605 |
|
2606 |
|
2607 // ----------------------------------------------------------------------------- |
|
2608 // CMediaFileDialog::StorageTypeIcon |
|
2609 // |
|
2610 // ----------------------------------------------------------------------------- |
|
2611 // |
|
2612 TInt CMediaFileDialog::StorageTypeIcon( TInt aListboxIndex ) |
|
2613 { |
|
2614 if ( aListboxIndex < 0 ) |
|
2615 { |
|
2616 return EEIconEmpty; |
|
2617 } |
|
2618 |
|
2619 TInt storageType = iMediaFileHandler->Attribute( aListboxIndex, |
|
2620 CMediaFileHandler::EAttrStorageType, |
|
2621 iState->CurrentFolder() ); |
|
2622 TInt iconId = EEIconEmpty; |
|
2623 if ( storageType == CMediaFileHandler::EMassStorage ) |
|
2624 { |
|
2625 iconId = EEIconMassStorage; |
|
2626 } |
|
2627 |
|
2628 if ( storageType == CMediaFileHandler::EMemoryCard ) |
|
2629 { |
|
2630 iconId = EEIconMemoryCard; |
|
2631 } |
|
2632 |
|
2633 return iconId; |
|
2634 } |
|
2635 |
|
2636 |
|
2637 // ----------------------------------------------------------------------------- |
|
2638 // CMediaFileDialog::GetListItemText |
|
2639 // |
|
2640 // ----------------------------------------------------------------------------- |
|
2641 // |
|
2642 void CMediaFileDialog::GetListItemText( TInt aListboxIndex, TDes& aText ) |
|
2643 { |
|
2644 __ASSERT_DEBUG( iState->QueryNeeded(), Panic( KErrGeneral ) ); |
|
2645 |
|
2646 TInt id = iState->CurrentFolder(); |
|
2647 |
|
2648 // read selected list item text from metadata |
|
2649 TInt extraIndexes = iState->LeadingPersistentFolderCount(); |
|
2650 TInt queryIndex = aListboxIndex - extraIndexes; |
|
2651 |
|
2652 iMediaFileHandler->GetAttribute( queryIndex, |
|
2653 CMediaFileHandler::EAttrSongName, aText, id ); |
|
2654 } |
|
2655 |
|
2656 |
|
2657 |
|
2658 // ----------------------------------------------------------------------------- |
|
2659 // CMediaFileDialog::ListboxItemCount (from CMFListHandlerObserver) |
|
2660 // |
|
2661 // ----------------------------------------------------------------------------- |
|
2662 // |
|
2663 TInt CMediaFileDialog::ListboxItemCount() |
|
2664 { |
|
2665 TInt count1 = iState->PersistentFolderCount(); |
|
2666 TInt count2 = 0; |
|
2667 |
|
2668 if ( iState->QueryNeeded() ) |
|
2669 { |
|
2670 count2 = iMediaFileHandler->ResultCount(); |
|
2671 } |
|
2672 return count1 + count2; |
|
2673 } |
|
2674 |
|
2675 |
|
2676 // ----------------------------------------------------------------------------- |
|
2677 // CMediaFileDialog::HandleMFEventL (from MMediaFileHandlerObserver) |
|
2678 // |
|
2679 // ----------------------------------------------------------------------------- |
|
2680 // |
|
2681 void CMediaFileDialog::HandleMFEventL( TInt aEvent, TInt aError ) |
|
2682 { |
|
2683 // |
|
2684 // handle cancel button |
|
2685 // |
|
2686 if ( aEvent == MMediaFileHandlerObserver::EQueryCanceled ) |
|
2687 { |
|
2688 iWaitNote->CancelProgressDialogL(); |
|
2689 iSearchText = KNullDesC; |
|
2690 UpdateListBoxL(); |
|
2691 return; |
|
2692 } |
|
2693 |
|
2694 // |
|
2695 // handle error |
|
2696 // |
|
2697 if ( aError != KErrNone ) |
|
2698 { |
|
2699 iWaitNote->CancelProgressDialogL(); |
|
2700 ResetDialogL( aError ); |
|
2701 |
|
2702 FLOG( _L("### CMediaFileDialog::HandleMFEventL (%d) ###"), aError ); |
|
2703 return; |
|
2704 } |
|
2705 |
|
2706 |
|
2707 if ( aEvent != MMediaFileHandlerObserver::EUnknownQueryComplete ) |
|
2708 { |
|
2709 // unknown query is always followed by another query |
|
2710 iWaitNote->CancelProgressDialogL(); |
|
2711 } |
|
2712 |
|
2713 |
|
2714 if ( aEvent == MMediaFileHandlerObserver::EUnknownQueryComplete ) |
|
2715 { |
|
2716 TInt count = iMediaFileHandler->ResultCount(); |
|
2717 TInt folderId = iState->QueryFolder(); |
|
2718 iState->SetUnknownCount( folderId, count ); |
|
2719 |
|
2720 TInt err = KErrNone; |
|
2721 TRAP( err, QueryL( folderId ) ); |
|
2722 if ( err != KErrNone ) |
|
2723 { |
|
2724 iWaitNote->CancelProgressDialogL(); |
|
2725 User::Leave( err ); |
|
2726 } |
|
2727 } |
|
2728 |
|
2729 if ( aEvent == MMediaFileHandlerObserver::EQueryComplete ) |
|
2730 { |
|
2731 // query was successful - update dialog state |
|
2732 iState->SetStateAfterQuery(); |
|
2733 |
|
2734 TInt count = iMediaFileHandler->ResultCount(); |
|
2735 |
|
2736 if ( iState->CurrentFolder() == EEFolderArtist ) |
|
2737 { |
|
2738 TInt count = iMediaFileHandler->UnknownArtistCount(); |
|
2739 iState->SetUnknownCount( EEFolderArtist, count ); |
|
2740 } |
|
2741 iState->HideUnknownFolders(); |
|
2742 UpdateListBoxL(); |
|
2743 |
|
2744 #ifdef _DEBUG |
|
2745 iTest->PrintTimeL( _L("query took") ); // test code |
|
2746 #endif |
|
2747 } |
|
2748 |
|
2749 if ( aEvent == MMediaFileHandlerObserver::EMediaFileChanged ) |
|
2750 { |
|
2751 HandleMediaFileChanged(); |
|
2752 } |
|
2753 |
|
2754 if ( aEvent == MMediaFileHandlerObserver::EScanRomComplete ) |
|
2755 { |
|
2756 iWaitNote->CancelProgressDialogL(); |
|
2757 } |
|
2758 |
|
2759 if ( aEvent == MMediaFileHandlerObserver::EInitComplete ) |
|
2760 { |
|
2761 iDatabaseOpen = ETrue; |
|
2762 |
|
2763 StartRomScan(); |
|
2764 } |
|
2765 } |
|
2766 |
|
2767 |
|
2768 // ----------------------------------------------------------------------------- |
|
2769 // CMediaFileDialog::HandleMediaFileChanged |
|
2770 // |
|
2771 // Handle situation where file system changes and media files are added / |
|
2772 // removed. This function makes a query to update current folder and |
|
2773 // stores name or id of the currently selected item. Current item info |
|
2774 // is needed to restore current item after query. |
|
2775 // ----------------------------------------------------------------------------- |
|
2776 // |
|
2777 void CMediaFileDialog::HandleMediaFileChanged() |
|
2778 { |
|
2779 // query is ongoing - ignore this file change event |
|
2780 if ( !iMediaFileHandler->QueryReady() ) |
|
2781 { |
|
2782 FLOG( _L("### CMediaFileDialog::HandleMediaFileChanged: query in progress ###") ); |
|
2783 return; |
|
2784 } |
|
2785 |
|
2786 iState->ResetUnknownCount(); |
|
2787 TMFCurrentItemInfo& info = iState->CurrentItemInfo(); |
|
2788 info.Reset(); |
|
2789 info.iIndexCheckNeeded = ETrue; // set to false when dialog is opened |
|
2790 |
|
2791 TInt currentFolder = iState->CurrentFolder(); |
|
2792 TInt currentIndex = CurrentItemListIndex(); |
|
2793 |
|
2794 TBool isPersistent = EFalse; |
|
2795 TInt iconId = EEIconEmpty; |
|
2796 TInt id = KErrNotFound; |
|
2797 TBuf<KBufSize64> buf; |
|
2798 iState->GetFolderInfo( currentIndex, id, buf, |
|
2799 isPersistent, iconId ); |
|
2800 if ( id == KErrNotFound ) |
|
2801 { |
|
2802 // get media file id |
|
2803 info.iMediaFileId = iMediaFileHandler->Attribute( currentIndex, |
|
2804 CMediaFileHandler::EAttrMediaFileId, currentFolder ); |
|
2805 } |
|
2806 else if ( !isPersistent ) |
|
2807 { |
|
2808 // get non-persistent folder name (eg some album name) |
|
2809 GetListItemText( currentIndex, info.iFolderText ); |
|
2810 } |
|
2811 else |
|
2812 { |
|
2813 // get persistent folder id (eg "Unknown" folder) |
|
2814 info.iFolderId = id; |
|
2815 } |
|
2816 |
|
2817 info.iItemIndex = currentIndex; |
|
2818 |
|
2819 iState->SetQueryInfo( 0, KNullDesC, 0, EEQueryUpdate ); |
|
2820 |
|
2821 TBool databaseChanged = ETrue; |
|
2822 QueryL( currentFolder, databaseChanged ); |
|
2823 } |
|
2824 |
|
2825 |
|
2826 // ----------------------------------------------------------------------------- |
|
2827 // CMediaFileDialog::CheckListboxIndex |
|
2828 // |
|
2829 // Check that current item selection is correct. Function is used in case |
|
2830 // file system has changed (media files added / removed. |
|
2831 // ----------------------------------------------------------------------------- |
|
2832 // |
|
2833 void CMediaFileDialog::CheckListboxIndex() |
|
2834 { |
|
2835 TMFCurrentItemInfo& info = iState->CurrentItemInfo(); |
|
2836 if ( !info.iIndexCheckNeeded ) |
|
2837 { |
|
2838 return; |
|
2839 } |
|
2840 |
|
2841 TInt direction = iState->QueryDirection(); |
|
2842 TInt newListIndex = KErrNotFound; |
|
2843 |
|
2844 if ( direction == EEQueryUp ) |
|
2845 { |
|
2846 FLOG( _L("query up") ); |
|
2847 TInt prevId = iState->PreviousFolderId(); |
|
2848 TInt listIndex = iState->ListIndex( prevId ); |
|
2849 if ( !iState->IsPersistent( prevId ) ) |
|
2850 { |
|
2851 iState->GetText( prevId, info.iFolderText ); |
|
2852 TInt num = iState->LeadingPersistentFolderCount(); |
|
2853 newListIndex = iMediaFileHandler->ItemIndex( |
|
2854 info.iFolderText, listIndex ); |
|
2855 iState->SetCurrentItemIndex( newListIndex + num ); |
|
2856 } |
|
2857 else |
|
2858 { |
|
2859 iState->SetCurrentItemIndex( listIndex ); |
|
2860 } |
|
2861 } |
|
2862 |
|
2863 if ( direction == EEQueryUpdate ) |
|
2864 { |
|
2865 if ( info.iMediaFileId != KErrNotFound ) |
|
2866 { |
|
2867 newListIndex = iMediaFileHandler->ItemIndex( |
|
2868 info.iMediaFileId, info.iItemIndex ); |
|
2869 } |
|
2870 else if ( info.iFolderText.Length() > 0 ) |
|
2871 { |
|
2872 newListIndex = iMediaFileHandler->ItemIndex( |
|
2873 info.iFolderText, info.iItemIndex ); |
|
2874 TInt num = iState->LeadingPersistentFolderCount(); |
|
2875 newListIndex = newListIndex + num; |
|
2876 } |
|
2877 else if ( info.iFolderId != KErrNotFound ) |
|
2878 { |
|
2879 newListIndex = iState->ListIndex( info.iFolderId ); |
|
2880 } |
|
2881 |
|
2882 iState->SetCurrentItemIndex( newListIndex ); |
|
2883 } |
|
2884 } |
|
2885 |
|
2886 |
|
2887 // ----------------------------------------------------------------------------- |
|
2888 // CMediaFileDialog::HandlePreviewEventL (from MPreviewHandlerObserver) |
|
2889 // |
|
2890 // ----------------------------------------------------------------------------- |
|
2891 // |
|
2892 void CMediaFileDialog::HandlePreviewEventL( TInt aEvent, TInt aError ) |
|
2893 { |
|
2894 if ( aEvent == MPreviewHandlerObserver::EAudioPreviewComplete ) |
|
2895 { |
|
2896 ShowPreviewErrorNoteL( aError, CMediaFileHandler::EMediaTypeMusic ); |
|
2897 } |
|
2898 |
|
2899 if ( aEvent == MPreviewHandlerObserver::EVideoPreviewComplete ) |
|
2900 { |
|
2901 ShowPreviewErrorNoteL( aError, CMediaFileHandler::EMediaTypeVideo ); |
|
2902 } |
|
2903 |
|
2904 if ( aEvent == MPreviewHandlerObserver::EPreviewError ) |
|
2905 { |
|
2906 FLOG( _L("### CMediaFileDialog::HandlePreviewEventL (%d) ###"), aError ); |
|
2907 |
|
2908 ShowPreviewErrorNoteL( aError, CMediaFileHandler::EMediaTypeMusic ); |
|
2909 } |
|
2910 } |
|
2911 |
|
2912 |
|
2913 // ----------------------------------------------------------------------------- |
|
2914 // CMediaFileDialog::HandleLosingForeground (from MCoeForegroundObserver) |
|
2915 // |
|
2916 // ----------------------------------------------------------------------------- |
|
2917 // |
|
2918 void CMediaFileDialog::HandleLosingForeground() |
|
2919 { |
|
2920 iForeGround = EFalse; |
|
2921 //Record the current item info |
|
2922 if ( iState && iListBox) |
|
2923 { |
|
2924 iState->SetCurrentItemIndex( CurrentItemListIndex() ); |
|
2925 } |
|
2926 |
|
2927 CancelPreview(); |
|
2928 } |
|
2929 |
|
2930 |
|
2931 // ----------------------------------------------------------------------------- |
|
2932 // CMediaFileDialog::HandleGainingForeground (from MCoeForegroundObserver) |
|
2933 // |
|
2934 // ----------------------------------------------------------------------------- |
|
2935 // |
|
2936 void CMediaFileDialog::HandleGainingForeground() |
|
2937 { |
|
2938 iForeGround = ETrue; |
|
2939 if ( iListBox ) |
|
2940 { |
|
2941 UpdateListBoxL( EFalse ); |
|
2942 } |
|
2943 } |
|
2944 |
|
2945 |
|
2946 // ----------------------------------------------------------------------------- |
|
2947 // CMediaFileDialog::HandleControlEventL (from MCoeControlObserver) |
|
2948 // |
|
2949 // ----------------------------------------------------------------------------- |
|
2950 // |
|
2951 void CMediaFileDialog::HandleControlEventL( CCoeControl* aControl, |
|
2952 TCoeEvent aEventType ) |
|
2953 { |
|
2954 TInt currentFolderId = iState->CurrentFolder(); |
|
2955 |
|
2956 if ( aEventType == EEventStateChanged ) |
|
2957 { |
|
2958 CancelPreview(); |
|
2959 if ( aControl == iListBox ) |
|
2960 { |
|
2961 if ( currentFolderId == EEFolderRoot || |
|
2962 currentFolderId == EEFolderSearch || |
|
2963 currentFolderId == EEFolderVideos ) |
|
2964 { |
|
2965 UpdateCbaL( 0 ); // only these folders need dynamic cba update |
|
2966 } |
|
2967 StartPreviewWithDelay(); |
|
2968 ShowDetailsPopupL(); // show search details in Search view |
|
2969 |
|
2970 // forward listbox state change events to this control's |
|
2971 // observers |
|
2972 ReportEventL( MCoeControlObserver::EEventStateChanged ); |
|
2973 } |
|
2974 |
|
2975 if ( FindBox() && aControl == FindBox() ) |
|
2976 { |
|
2977 User::InfoPrint(_L("find box event arrived")); |
|
2978 |
|
2979 // this event is received when user enters or deletes |
|
2980 // chars in find box. Backspace key in empty find box does not |
|
2981 // generate this event. |
|
2982 |
|
2983 if ( currentFolderId == EEFolderSearch || |
|
2984 currentFolderId == EEFolderRoot || |
|
2985 currentFolderId == EEFolderMusic || |
|
2986 currentFolderId == EEFolderSearchMusic ) |
|
2987 { |
|
2988 StartSearchWithDelay(); |
|
2989 return; |
|
2990 } |
|
2991 |
|
2992 // StartPreviewWithDelay(); |
|
2993 |
|
2994 UpdateCbaL( 0 ); |
|
2995 |
|
2996 //#ifdef _DEBUG |
|
2997 TBuf<KBufSize128> buf; |
|
2998 iState->GetTitle( iState->CurrentFolder(), buf ); |
|
2999 TBuf<KBufSize128> buf2( buf ); |
|
3000 TInt count = iListBox->Model()->NumberOfItems(); |
|
3001 buf.Format( _L("%S (%d)"), &buf2, count ); |
|
3002 iStatusPaneHandler->SetNaviPaneTitle( buf ); |
|
3003 //#endif |
|
3004 |
|
3005 // Forward listbox state change events to this control's |
|
3006 // observers |
|
3007 ReportEventL( MCoeControlObserver::EEventStateChanged ); |
|
3008 } |
|
3009 } |
|
3010 } |
|
3011 |
|
3012 |
|
3013 // ----------------------------------------------------------------------------- |
|
3014 // CMediaFileDialog::HandleWaitNoteL (from MMediaFileWaitNoteObserver) |
|
3015 // |
|
3016 // ----------------------------------------------------------------------------- |
|
3017 // |
|
3018 void CMediaFileDialog::HandleWaitNoteL( TInt /*aButtonId*/ ) |
|
3019 { |
|
3020 iMediaFileHandler->CancelQuery(); |
|
3021 } |
|
3022 |
|
3023 |
|
3024 // ----------------------------------------------------------------------------- |
|
3025 // CMediaFileDialog::AdaptiveSearchTextChanged (from MAdaptiveSearchTextObserver) |
|
3026 // |
|
3027 // ----------------------------------------------------------------------------- |
|
3028 // |
|
3029 void CMediaFileDialog::AdaptiveSearchTextChanged( CAknSearchField* /*aSearchField*/ ) |
|
3030 { |
|
3031 // not used |
|
3032 } |
|
3033 |
|
3034 |
|
3035 // ----------------------------------------------------------------------------- |
|
3036 // CMediaFileDialog::OnPeninputUiDeactivated |
|
3037 // |
|
3038 // ----------------------------------------------------------------------------- |
|
3039 // |
|
3040 void CMediaFileDialog::OnPeninputUiDeactivated() |
|
3041 { |
|
3042 iPeninputActive = EFalse; |
|
3043 |
|
3044 if ( FindBox()->TextLength() == 0 && |
|
3045 ( iState->CurrentFolder() == EEFolderSearch || |
|
3046 iState->CurrentFolder() == EEFolderSearchMusic ) ) |
|
3047 { |
|
3048 HandleBackL(); |
|
3049 } |
|
3050 else |
|
3051 { |
|
3052 // search starts immediately after user closes pen input |
|
3053 TRAP_IGNORE( StartSearchWithDelay() ); |
|
3054 } |
|
3055 } |
|
3056 |
|
3057 |
|
3058 // ----------------------------------------------------------------------------- |
|
3059 // CMediaFileDialog::OnPeninputUiActivated |
|
3060 // |
|
3061 // ----------------------------------------------------------------------------- |
|
3062 // |
|
3063 void CMediaFileDialog::OnPeninputUiActivated() |
|
3064 { |
|
3065 iPeninputActive = ETrue; |
|
3066 CancelPreview(); |
|
3067 } |
|
3068 |
|
3069 |
|
3070 // ----------------------------------------------------------------------------- |
|
3071 // CMediaFileDialog::HandleListBoxEventL (from MEikListBoxObserver) |
|
3072 // |
|
3073 // ----------------------------------------------------------------------------- |
|
3074 // |
|
3075 void CMediaFileDialog::HandleListBoxEventL( CEikListBox* /*aListBox*/, |
|
3076 TListBoxEvent aEventType ) |
|
3077 { |
|
3078 TInt current = iState->CurrentFolder(); |
|
3079 if ( aEventType == EEventPenDownOnItem) |
|
3080 { |
|
3081 iListBox->View()->ItemDrawer()->SetFlags( CListItemDrawer::EPressedDownState ); |
|
3082 return; |
|
3083 } |
|
3084 |
|
3085 if ( aEventType == EEventItemClicked ) |
|
3086 { |
|
3087 iIsDoubleClicked = EFalse; |
|
3088 if ( current != KErrNotFound ) |
|
3089 { |
|
3090 HandleOKL( EAttrOpen ); // open folder item |
|
3091 } |
|
3092 return; |
|
3093 } |
|
3094 |
|
3095 if ( aEventType == EEventItemDoubleClicked || aEventType == EEventEnterKeyPressed ) |
|
3096 { |
|
3097 TBool closeDialog = HandleOKL( EAttrDoubleClicked ); |
|
3098 |
|
3099 if ( closeDialog ) |
|
3100 { |
|
3101 // close after short delay (dialog cannot be closed from this function) |
|
3102 CloseDialogWithDelayL(); |
|
3103 } |
|
3104 iIsDoubleClicked = ETrue; |
|
3105 } |
|
3106 if ( aEventType == EEventItemDraggingActioned ) |
|
3107 { |
|
3108 UpdateCbaL( KErrNone ); |
|
3109 DrawNow(); |
|
3110 } |
|
3111 } |
|
3112 |
|
3113 |
|
3114 // ----------------------------------------------------------------------------- |
|
3115 // CMediaFileDialog::CloseDialogWithDelayL |
|
3116 // |
|
3117 // ----------------------------------------------------------------------------- |
|
3118 // |
|
3119 void CMediaFileDialog::CloseDialogWithDelayL() |
|
3120 { |
|
3121 delete iIdle; |
|
3122 iIdle = NULL; |
|
3123 iIdle = CIdle::NewL( CActive::EPriorityIdle ); |
|
3124 |
|
3125 if ( iIdle ) |
|
3126 { |
|
3127 iIdle->Start( TCallBack( CloseDialog, this ) ); |
|
3128 } |
|
3129 delete iInputBlock; |
|
3130 iInputBlock = NULL; |
|
3131 iInputBlock = CAknInputBlock::NewLC(); |
|
3132 CleanupStack::Pop( iInputBlock ); |
|
3133 } |
|
3134 |
|
3135 |
|
3136 // ----------------------------------------------------------------------------- |
|
3137 // CMediaFileDialog::CloseDialog |
|
3138 // |
|
3139 // ----------------------------------------------------------------------------- |
|
3140 // |
|
3141 TInt CMediaFileDialog::CloseDialog( TAny *aObj ) |
|
3142 { |
|
3143 CMediaFileDialog *dlg = (CMediaFileDialog*) aObj; |
|
3144 delete dlg->iInputBlock; |
|
3145 dlg->iInputBlock = NULL; |
|
3146 |
|
3147 TRAP_IGNORE( dlg->TryExitL( EAknSoftkeyOk ) ); |
|
3148 |
|
3149 return 0; |
|
3150 } |
|
3151 |
|
3152 |
|
3153 // ----------------------------------------------------------------------------- |
|
3154 // CMediaFileDialog::HandleActiveCallL (from MMFActiveCallerObserver) |
|
3155 // |
|
3156 // ----------------------------------------------------------------------------- |
|
3157 // |
|
3158 void CMediaFileDialog::HandleActiveCallL( TInt aCallId ) |
|
3159 { |
|
3160 if ( aCallId == EAttrPreview ) |
|
3161 { |
|
3162 //double click the item of the listbox to select the tones, do not preview it. |
|
3163 if ( iIsDoubleClicked ) |
|
3164 { |
|
3165 iIsDoubleClicked = EFalse; |
|
3166 } |
|
3167 else |
|
3168 { |
|
3169 // start preview after delay |
|
3170 PreviewL( CMediaFileList::EMediaFileTypeAudio ); |
|
3171 } |
|
3172 } |
|
3173 |
|
3174 if ( aCallId == EAttrSearch ) |
|
3175 { |
|
3176 // start search after delay |
|
3177 SearchL(); |
|
3178 } |
|
3179 } |
|
3180 |
|
3181 |
|
3182 |
|
3183 |
|
3184 /****************************************************************************** |
|
3185 * class CMFListHandler |
|
3186 ******************************************************************************/ |
|
3187 |
|
3188 // ----------------------------------------------------------------------------- |
|
3189 // CMFListHandler::NewL |
|
3190 // |
|
3191 // ----------------------------------------------------------------------------- |
|
3192 // |
|
3193 CMFListHandler* CMFListHandler::NewL() |
|
3194 { |
|
3195 CMFListHandler* self = new (ELeave) CMFListHandler(); |
|
3196 CleanupStack::PushL(self); |
|
3197 self->ConstructL(); |
|
3198 CleanupStack::Pop(self); |
|
3199 return self; |
|
3200 } |
|
3201 |
|
3202 |
|
3203 // ----------------------------------------------------------------------------- |
|
3204 // CMFListHandler::~CMFListHandler |
|
3205 // |
|
3206 // ----------------------------------------------------------------------------- |
|
3207 // |
|
3208 CMFListHandler::~CMFListHandler() |
|
3209 { |
|
3210 } |
|
3211 |
|
3212 |
|
3213 // ----------------------------------------------------------------------------- |
|
3214 // CMFListHandler::ConstructL |
|
3215 // |
|
3216 // ----------------------------------------------------------------------------- |
|
3217 // |
|
3218 void CMFListHandler::ConstructL( void ) |
|
3219 { |
|
3220 } |
|
3221 |
|
3222 |
|
3223 // ----------------------------------------------------------------------------- |
|
3224 // CMFListHandler::CMFListHandler |
|
3225 // |
|
3226 // ----------------------------------------------------------------------------- |
|
3227 // |
|
3228 CMFListHandler::CMFListHandler() |
|
3229 { |
|
3230 } |
|
3231 |
|
3232 |
|
3233 // ----------------------------------------------------------------------------- |
|
3234 // CMFListHandler::SetObserver |
|
3235 // |
|
3236 // ----------------------------------------------------------------------------- |
|
3237 // |
|
3238 void CMFListHandler::SetObserver( CMFListHandlerObserver* aObserver ) |
|
3239 { |
|
3240 iObserver = aObserver; |
|
3241 } |
|
3242 |
|
3243 |
|
3244 // ----------------------------------------------------------------------------- |
|
3245 // CMFListHandler::MdcaCount (from MDesCArray) |
|
3246 // |
|
3247 // ----------------------------------------------------------------------------- |
|
3248 // |
|
3249 TInt CMFListHandler::MdcaCount() const |
|
3250 { |
|
3251 return iObserver->ListboxItemCount(); |
|
3252 } |
|
3253 |
|
3254 |
|
3255 // ----------------------------------------------------------------------------- |
|
3256 // CMFListHandler::MdcaPoint (from MDesCArray) |
|
3257 // |
|
3258 // CEikListBox calls this function just before it draws list box item. |
|
3259 // ----------------------------------------------------------------------------- |
|
3260 // |
|
3261 TPtrC16 CMFListHandler::MdcaPoint( TInt aIndex ) const |
|
3262 { |
|
3263 return iObserver->ConstructListboxItem( aIndex ); |
|
3264 } |
|
3265 |
|
3266 |
|
3267 // ----------------------------------------------------------------------------- |
|
3268 // CMFListHandler::Panic |
|
3269 // |
|
3270 // ----------------------------------------------------------------------------- |
|
3271 // |
|
3272 void CMFListHandler::Panic( TInt aReason ) |
|
3273 { |
|
3274 _LIT( KPanicCategory, "CMFListHandler" ); |
|
3275 |
|
3276 User::Panic( KPanicCategory, aReason ); |
|
3277 } |
|
3278 |
|
3279 |
|
3280 |
|
3281 |
|
3282 |
|
3283 |
|
3284 |
|
3285 |
|
3286 // End of File |
|