|
1 /* |
|
2 * Copyright (c) 2009 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: creates fetcher plugin dialog |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDES |
|
20 #include <eikclbd.h> // for CColumnListBoxData |
|
21 #include <coecobs.h> // MCoeControlObserver |
|
22 #include <AknUtils.h> // AknTextUtils AknFind |
|
23 #include <AknIconArray.h> // for GulArray |
|
24 #include <AknWaitDialog.h> |
|
25 #include <textresolver.h> |
|
26 #include <StringLoader.h> |
|
27 #include <akninputblock.h> // CAknInputBlock |
|
28 #include <eikon.hrh> |
|
29 |
|
30 #include <aknappui.h> |
|
31 #include <akntoolbar.h> |
|
32 #include <eikdialg.h> |
|
33 #include <eikdialogext.h> |
|
34 #include <aknselectionlist.h> // AknSelectionList.cpp |
|
35 #include <aknsfld.h> // CAknSearchField |
|
36 #include <eikcapc.h> // CEikCaptionedControl |
|
37 |
|
38 #include <aknconsts.h> // KAvkonBitmapFile, KAvkonVariatedBitmapsFile |
|
39 #include <AknsConstants.h> // icon constants |
|
40 #include <aknmemorycardui.mbg> // memory card icon |
|
41 #include <avkon.mbg> |
|
42 #include <StringLoader.h> |
|
43 |
|
44 #include <MMGFetchVerifier.h> // For VerifySelectionL() |
|
45 |
|
46 #include <audiofetcher.mbg> |
|
47 #include <audiofetcherdialog.rsg> |
|
48 #include "audiofetcherdialog.h" |
|
49 #include "audiofetcherfilehandler.h" |
|
50 |
|
51 #include "audiofetcher.hrh" |
|
52 #include "audiofetcherlog.h" |
|
53 |
|
54 #include <data_caging_path_literals.hrh> // KDC_APP_RESOURCE_DIR |
|
55 |
|
56 |
|
57 //----------------------------------------------------------------------------- |
|
58 // C++ default constructor. |
|
59 //----------------------------------------------------------------------------- |
|
60 // |
|
61 inline CAudioFetcherDialog::CAudioFetcherDialog( |
|
62 CDesCArray& aSelectedFiles, |
|
63 MMGFetchVerifier* aVerifier, |
|
64 const TDesC& aTitle, |
|
65 TBool aMultiSelectionEnabled, |
|
66 TMediaFileType aMediaType) |
|
67 : iSelectedFiles( aSelectedFiles ), |
|
68 iVerifier( aVerifier ), |
|
69 iTitle( aTitle ), |
|
70 iMultiSelectionEnabled(aMultiSelectionEnabled), |
|
71 iMediaType(aMediaType) |
|
72 { |
|
73 WLOG("CAudioFetcherDialog::CAudioFetcherDialog"); |
|
74 // No implementation required |
|
75 } |
|
76 |
|
77 //----------------------------------------------------------------------------- |
|
78 // Two-phased constructor. |
|
79 //----------------------------------------------------------------------------- |
|
80 // |
|
81 CAudioFetcherDialog* CAudioFetcherDialog::NewL(CDesCArray& aSelectedFiles, |
|
82 MMGFetchVerifier* aVerifier, const TDesC& aTitle, TBool aMultiSelectionEnabled, |
|
83 TMediaFileType aMediaType) |
|
84 { |
|
85 WLOG("CAudioFetcherDialog::NewL"); |
|
86 CAudioFetcherDialog* self= |
|
87 new( ELeave ) CAudioFetcherDialog( |
|
88 aSelectedFiles, aVerifier, aTitle, aMultiSelectionEnabled, aMediaType ); |
|
89 CleanupStack::PushL( self ); |
|
90 self->ConstructL(); |
|
91 CleanupStack::Pop( self ); |
|
92 return self; |
|
93 } |
|
94 |
|
95 //----------------------------------------------------------------------------- |
|
96 // Destructor |
|
97 //----------------------------------------------------------------------------- |
|
98 // |
|
99 CAudioFetcherDialog::~CAudioFetcherDialog() |
|
100 { |
|
101 WLOG("CAudioFetcherDialog::~CAudioFetcherDialog >"); |
|
102 |
|
103 delete iStatusPaneHandler; |
|
104 delete iListHandler; |
|
105 delete iFileHandler; |
|
106 delete iListBox; |
|
107 delete iEmptyListText; |
|
108 delete iIdle; |
|
109 delete iInputBlock; |
|
110 |
|
111 // Restore the Toolbar as it was in the Calling application |
|
112 if( iAvkonAppUi->CurrentFixedToolbar() ) // there is Hardware Specific Output for Fixed ToolBar |
|
113 { |
|
114 iAvkonAppUi->CurrentFixedToolbar()->SetToolbarVisibility( ETrue ); |
|
115 } |
|
116 |
|
117 if ( iAvkonAppUi ) |
|
118 { |
|
119 iAvkonAppUi->RemoveFromStack( this ); |
|
120 } |
|
121 |
|
122 WLOG("CAudioFetcherDialog::~CAudioFetcherDialog <"); |
|
123 } |
|
124 |
|
125 //----------------------------------------------------------------------------- |
|
126 // Symbian 2nd phase constructor can leave. |
|
127 // Create the alfscreenbuffer with a generic buffer screen id |
|
128 //----------------------------------------------------------------------------- |
|
129 // |
|
130 void CAudioFetcherDialog::ConstructL() |
|
131 { |
|
132 WLOG("CAudioFetcherDialog::ConstructL >"); |
|
133 // always first call the base class |
|
134 CAknDialog::ConstructL( R_AUDIOFETCHER_MENUBAR ); //R_MULTISELECT_AUDIOFETCHER_MENUBAR ); |
|
135 |
|
136 // Get the Instance of the toolbar and disable it as it is not required in the fetcher dialog |
|
137 if( iAvkonAppUi->CurrentFixedToolbar() ) // there is hardware specific output for fixed toolBar |
|
138 { |
|
139 iAvkonAppUi->CurrentFixedToolbar()->SetToolbarVisibility( EFalse ); |
|
140 } |
|
141 |
|
142 // get previous title so it can be restored |
|
143 iStatusPaneHandler = CStatusPaneHandler::NewL( iAvkonAppUi ); |
|
144 iStatusPaneHandler->StoreOriginalTitleL(); |
|
145 |
|
146 // MdS query handler |
|
147 iFileHandler = CAudioFetcherFileHandler::NewL(); |
|
148 iFileHandler->SetObserver( this ); |
|
149 |
|
150 // List model |
|
151 iListHandler = CAudioFetcherListHandler::NewL(); |
|
152 iListHandler->SetObserver( this ); |
|
153 |
|
154 WLOG("CAudioFetcherDialog::ConstructL <"); |
|
155 } |
|
156 |
|
157 //----------------------------------------------------------------------------- |
|
158 // CAudioFetcherDialog::ProcessCommandL |
|
159 // This processes the events to the OkToExitL |
|
160 //----------------------------------------------------------------------------- |
|
161 // |
|
162 void CAudioFetcherDialog::ProcessCommandL(TInt aCommandId) |
|
163 { |
|
164 WLOG("CAudioFetcherDialog::ProcessCommandL"); |
|
165 switch( aCommandId ) |
|
166 { |
|
167 case EAknSoftkeyCancel : |
|
168 { |
|
169 TryExitL( aCommandId ); |
|
170 break; |
|
171 } |
|
172 case EAknSoftkeySelect : |
|
173 case ECmdSelectMarked : |
|
174 case EAknSoftkeyOk : |
|
175 { |
|
176 TryExitL( aCommandId ); |
|
177 break; |
|
178 } |
|
179 default : |
|
180 { |
|
181 break; |
|
182 } |
|
183 } |
|
184 } |
|
185 //----------------------------------------------------------------------------- |
|
186 // CAudioFetcherDialog::OkToExitL |
|
187 //----------------------------------------------------------------------------- |
|
188 // |
|
189 TBool CAudioFetcherDialog::OkToExitL(TInt aKeycode) |
|
190 { |
|
191 WLOG("CAudioFetcherDialog::OkToExitL"); |
|
192 TBool retVal = EFalse; |
|
193 |
|
194 switch( aKeycode ) |
|
195 { |
|
196 case EAknSoftkeySelect : |
|
197 { |
|
198 TInt index = CurrentItemListIndex(); |
|
199 TBuf<128> fileName; |
|
200 |
|
201 iFileHandler->GetAttribute( index, CAudioFetcherFileHandler::EAttrFullName, fileName, 0 ); |
|
202 iSelectedFiles.AppendL( fileName ); |
|
203 |
|
204 // Retreives the uri's of the selected files and verifies if it is a |
|
205 // supported format |
|
206 if ( iVerifier && !iVerifier->VerifySelectionL( &iSelectedFiles ) ) |
|
207 { |
|
208 iSelectedFiles.Reset(); |
|
209 retVal = EFalse; |
|
210 } |
|
211 else |
|
212 { |
|
213 retVal = ETrue; |
|
214 } |
|
215 break; |
|
216 } |
|
217 case EAknSoftkeyOk: |
|
218 { |
|
219 retVal = ETrue; |
|
220 } |
|
221 case EAknSoftkeyCancel : // exit dialog |
|
222 case EAknCmdExit : |
|
223 { |
|
224 retVal = ETrue; |
|
225 break; |
|
226 } |
|
227 default : |
|
228 break; |
|
229 } |
|
230 return retVal; |
|
231 } |
|
232 |
|
233 //----------------------------------------------------------------------------- |
|
234 // CAudioFetcherDialog::SizeChanged |
|
235 //----------------------------------------------------------------------------- |
|
236 // |
|
237 void CAudioFetcherDialog::SizeChanged() |
|
238 { |
|
239 WLOG("CAudioFetcherDialog::SizeChanged"); |
|
240 // Can be implemented based on the use. |
|
241 CAknDialog::SizeChanged(); |
|
242 |
|
243 TRect parentRect( Rect() ); |
|
244 if ( iListBox ) |
|
245 { |
|
246 iListBox->SetRect( parentRect ); |
|
247 } |
|
248 } |
|
249 |
|
250 //----------------------------------------------------------------------------- |
|
251 // CAudioFetcherDialog::PreLayoutDynInitL |
|
252 //----------------------------------------------------------------------------- |
|
253 // |
|
254 void CAudioFetcherDialog::PreLayoutDynInitL() |
|
255 { |
|
256 WLOG("CAudioFetcherDialog::PreLayoutDynInitL >"); |
|
257 |
|
258 iListBox = new ( ELeave ) CAknSingleGraphicStyleListBox; |
|
259 iListBox->ConstructL( this, EAknListBoxSelectionList ); |
|
260 |
|
261 iListBox->Model()->SetItemTextArray( iListHandler ); |
|
262 iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
263 |
|
264 iListBox->SetListBoxObserver( this ); |
|
265 iListBox->CreateScrollBarFrameL( ETrue ); |
|
266 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
267 CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto ); |
|
268 |
|
269 iListBox->SetListBoxObserver( this ); |
|
270 |
|
271 SetIconsL(); |
|
272 |
|
273 iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue ); |
|
274 |
|
275 if ( iMediaType == EAnyMediaFile ) |
|
276 { |
|
277 iEmptyListText = StringLoader::LoadL( R_AUDIOFETCHER_EMPTY_LIST_TEXT_NO_MEDIA ); |
|
278 } |
|
279 else |
|
280 { |
|
281 iEmptyListText = StringLoader::LoadL( R_AUDIOFETCHER_EMPTY_LIST_TEXT_NO_AUDIO ); |
|
282 } |
|
283 |
|
284 |
|
285 |
|
286 iListBox->View()->SetListEmptyTextL( *iEmptyListText ); |
|
287 |
|
288 iStatusPaneHandler->SetTitleL( iTitle ); |
|
289 iStatusPaneHandler->SetNaviPaneTitleL( KNullDesC ); |
|
290 |
|
291 CEikButtonGroupContainer& dialogCba = ButtonGroupContainer(); |
|
292 dialogCba.MakeCommandVisible(EAknSoftkeySelect, EFalse); |
|
293 |
|
294 WLOG("CAudioFetcherDialog::PreLayoutDynInitL <"); |
|
295 } |
|
296 |
|
297 //----------------------------------------------------------------------------- |
|
298 // CAudioFetcherDialog::PostLayoutDynInitL |
|
299 //----------------------------------------------------------------------------- |
|
300 // |
|
301 void CAudioFetcherDialog::PostLayoutDynInitL() |
|
302 { |
|
303 WLOG("CAudioFetcherDialog::PostLayoutDynInitL"); |
|
304 } |
|
305 |
|
306 // ---------------------------------------------------------------------------- |
|
307 // CAudioFetcherDialog::SetIconsL |
|
308 // ---------------------------------------------------------------------------- |
|
309 // |
|
310 void CAudioFetcherDialog::SetIconsL() |
|
311 { |
|
312 WLOG("CAudioFetcherDialog::SetIconsL >"); |
|
313 |
|
314 _LIT( KBitmapFile, "AudioFetcher.mbm" ); |
|
315 |
|
316 |
|
317 if ( !iListBox ) |
|
318 { |
|
319 return; |
|
320 } |
|
321 |
|
322 SetIconFileNameL( KBitmapFile, iIconFileName ); |
|
323 |
|
324 CArrayPtr<CGulIcon>* icons = new (ELeave) CAknIconArray(1); |
|
325 CleanupStack::PushL( icons ); |
|
326 |
|
327 // NOTE: append order must match TListIcons |
|
328 // |
|
329 |
|
330 // music item icon |
|
331 icons->AppendL( IconL( KAknsIIDQgnIndiAiNtMusic, iIconFileName, |
|
332 EMbmAudiofetcherQgn_indi_ai_nt_music, |
|
333 EMbmAudiofetcherQgn_indi_ai_nt_music_mask ) ); |
|
334 |
|
335 // tone item icon, default tone icon |
|
336 icons->AppendL( IconL( KAknsIIDQgnPropMupAudio, iIconFileName, |
|
337 EMbmAudiofetcherQgn_prop_mup_audio, |
|
338 EMbmAudiofetcherQgn_prop_mup_audio_mask ) ); |
|
339 |
|
340 // video item icon |
|
341 icons->AppendL( IconL( KAknsIIDQgnPropFmgrFileVideo, iIconFileName, |
|
342 EMbmAudiofetcherQgn_prop_fmgr_file_video, |
|
343 EMbmAudiofetcherQgn_prop_fmgr_file_video_mask ) ); |
|
344 |
|
345 // recording item icon |
|
346 icons->AppendL( IconL( KAknsIIDQgnPropFmgrFileVoicerec, iIconFileName, |
|
347 EMbmAudiofetcherQgn_prop_fmgr_file_voicerec, |
|
348 EMbmAudiofetcherQgn_prop_fmgr_file_voicerec_mask ) ); |
|
349 |
|
350 // artist icon |
|
351 icons->AppendL( IconL( KAknsIIDQgnPropMupArtist, iIconFileName, |
|
352 EMbmAudiofetcherQgn_prop_mup_artist, |
|
353 EMbmAudiofetcherQgn_prop_mup_artist_mask ) ); |
|
354 |
|
355 // album icon |
|
356 icons->AppendL( IconL( KAknsIIDQgnPropMupAlbum, iIconFileName, |
|
357 EMbmAudiofetcherQgn_prop_mup_album, |
|
358 EMbmAudiofetcherQgn_prop_mup_album_mask ) ); |
|
359 |
|
360 // genre icon |
|
361 icons->AppendL( IconL( KAknsIIDQgnPropMupGenre, iIconFileName, |
|
362 EMbmAudiofetcherQgn_prop_mup_genre, |
|
363 EMbmAudiofetcherQgn_prop_mup_genre_mask ) ); |
|
364 |
|
365 // composer icon |
|
366 icons->AppendL( IconL( KAknsIIDQgnPropMupComposer, iIconFileName, |
|
367 EMbmAudiofetcherQgn_prop_mup_composer, |
|
368 EMbmAudiofetcherQgn_prop_mup_composer_mask ) ); |
|
369 |
|
370 // folder icon (tones, music, videos, recordings, all music, artist, |
|
371 // album, genre, composer, artist all) |
|
372 icons->AppendL( IconL( KAknsIIDQgnPropFolderSmall, iIconFileName, |
|
373 EMbmAudiofetcherQgn_prop_folder_small, |
|
374 EMbmAudiofetcherQgn_prop_folder_small_mask ) ); |
|
375 |
|
376 // unknown folder icon |
|
377 icons->AppendL( IconL( KAknsIIDQgnPropMceUnknownRead, iIconFileName, |
|
378 EMbmAudiofetcherQgn_prop_mce_unknown_read, |
|
379 EMbmAudiofetcherQgn_prop_mce_unknown_read ) ); |
|
380 |
|
381 // download item icon (null item) |
|
382 icons->AppendL( IconL( KAknsIIDQgnPropLinkEmbdSmall, iIconFileName, |
|
383 EMbmAudiofetcherQgn_prop_link_embd_small, |
|
384 EMbmAudiofetcherQgn_prop_link_embd_small_mask ) ); |
|
385 |
|
386 // off item icon (null item) |
|
387 icons->AppendL( IconL( KAknsIIDQgnPropSmlSyncOff, iIconFileName, |
|
388 EMbmAudiofetcherQgn_prop_sml_sync_off, |
|
389 EMbmAudiofetcherQgn_prop_sml_sync_off_mask ) ); |
|
390 |
|
391 // memory card icon |
|
392 icons->AppendL( IconL( KAknsIIDQgnIndiMmcAdd, iIconFileName, |
|
393 EMbmAudiofetcherQgn_indi_mmc_add, |
|
394 EMbmAudiofetcherQgn_indi_mmc_add_mask ) ); |
|
395 |
|
396 // mass storage icon |
|
397 icons->AppendL( IconL( KAknsIIDQgnPropLinkEmbdSmall, iIconFileName, |
|
398 EMbmAudiofetcherQgn_indi_fmgr_ms_add, |
|
399 EMbmAudiofetcherQgn_indi_fmgr_ms_add_mask ) ); |
|
400 |
|
401 // empty icon |
|
402 icons->AppendL( IconL( KAknsIIDQgnPropEmpty, KAvkonBitmapFile, |
|
403 EMbmAvkonQgn_prop_empty, |
|
404 EMbmAvkonQgn_prop_empty_mask ) ); |
|
405 |
|
406 // image item icon |
|
407 icons->AppendL( IconL( KAknsIIDQgnPropFmgrFileImage, iIconFileName, |
|
408 EMbmAudiofetcherQgn_prop_fmgr_file_image, |
|
409 EMbmAudiofetcherQgn_prop_fmgr_file_image_mask ) ); |
|
410 |
|
411 // delete old icons |
|
412 CArrayPtr<CGulIcon>* arr = iListBox->ItemDrawer()->ColumnData()->IconArray(); |
|
413 if ( arr ) |
|
414 { |
|
415 arr->ResetAndDestroy(); |
|
416 delete arr; |
|
417 arr = NULL; |
|
418 } |
|
419 |
|
420 iListBox->ItemDrawer()->ColumnData()->SetIconArray( icons ); |
|
421 CleanupStack::Pop( icons ); |
|
422 |
|
423 WLOG("CAudioFetcherDialog::SetIconsL <"); |
|
424 } |
|
425 |
|
426 // ---------------------------------------------------------------------------- |
|
427 // CAudioFetcherDialog::SetIconFileNameL |
|
428 // |
|
429 // ---------------------------------------------------------------------------- |
|
430 // |
|
431 void CAudioFetcherDialog::SetIconFileNameL( const TDesC& aName, TDes& aFullName ) |
|
432 { |
|
433 WLOG("CAudioFetcherDialog::SetIconFileNameL >"); |
|
434 _LIT( KDriveZ, "z:" ); |
|
435 |
|
436 aFullName = KNullDesC; |
|
437 |
|
438 aFullName.Append( KDriveZ ); |
|
439 aFullName.Append( KDC_APP_RESOURCE_DIR ); |
|
440 aFullName.Append( aName ); |
|
441 |
|
442 WLOG("CAudioFetcherDialog::SetIconFileNameL <"); |
|
443 } |
|
444 |
|
445 // ----------------------------------------------------------------------------- |
|
446 // CMediaFileDialog::IconL |
|
447 // |
|
448 // ----------------------------------------------------------------------------- |
|
449 // |
|
450 CGulIcon* CAudioFetcherDialog::IconL(TAknsItemID aId, const TDesC& aFileName, |
|
451 TInt aFileIndex, TInt aFileMaskIndex) |
|
452 { |
|
453 WLOG("CAudioFetcherDialog::IconL"); |
|
454 CGulIcon* icon = AknsUtils::CreateGulIconL(AknsUtils::SkinInstance(), aId, |
|
455 aFileName, aFileIndex, aFileMaskIndex); |
|
456 return icon; |
|
457 } |
|
458 |
|
459 |
|
460 // ----------------------------------------------------------------------------- |
|
461 // CMediaFileDialog::UpdateListBoxL |
|
462 // ----------------------------------------------------------------------------- |
|
463 // |
|
464 void CAudioFetcherDialog::UpdateListBoxL() |
|
465 { |
|
466 WLOG("CAudioFetcherDialog::UpdateListBoxL >"); |
|
467 |
|
468 if ( !iListBox ) |
|
469 { |
|
470 return; |
|
471 } |
|
472 |
|
473 TInt resultCount = iFileHandler->ResultCount(); |
|
474 |
|
475 if(resultCount > 0){ |
|
476 CEikButtonGroupContainer& dialogCba = ButtonGroupContainer(); |
|
477 dialogCba.MakeCommandVisible(EAknSoftkeySelect, ETrue); |
|
478 } |
|
479 iListBox->HandleItemAdditionL(); |
|
480 iListBox->SetCurrentItemIndex( 0 ); |
|
481 DrawNow(); |
|
482 |
|
483 WLOG("CAudioFetcherDialog::UpdateListBoxL <"); |
|
484 } |
|
485 |
|
486 //------------------------------------------------------------------------------ |
|
487 // CAudioFetcherDialog::ActivateL |
|
488 // |
|
489 // Called by system when dialog is activated. |
|
490 //------------------------------------------------------------------------------ |
|
491 // |
|
492 void CAudioFetcherDialog::ActivateL() |
|
493 { |
|
494 WLOG("CAudioFetcherDialog::ActivateL >"); |
|
495 CAknDialog::ActivateL(); |
|
496 |
|
497 // this cannot be in ConstructL which is executed before dialog is launched |
|
498 iAvkonAppUi->AddToStackL( this ); |
|
499 WLOG("CAudioFetcherDialog::ActivateL <"); |
|
500 } |
|
501 |
|
502 //----------------------------------------------------------------------------- |
|
503 // CAudioFetcherDialog::DynInitMenuPaneL |
|
504 //----------------------------------------------------------------------------- |
|
505 void CAudioFetcherDialog::DynInitMenuPaneL( |
|
506 TInt /*aResourceId*/, CEikMenuPane* /*aMenuPane*/ ) |
|
507 { |
|
508 WLOG("CAudioFetcherDialog::DynInitMenuPaneL"); |
|
509 // No Implementation |
|
510 } |
|
511 |
|
512 |
|
513 // --------------------------------------------------------------------------- |
|
514 // CAudioFetcherDialog::CountComponentControls |
|
515 // |
|
516 // Gets the number of controls contained in a compound control. |
|
517 // --------------------------------------------------------------------------- |
|
518 // |
|
519 TInt CAudioFetcherDialog::CountComponentControls() const |
|
520 { |
|
521 return iListBox ? 1 : 0; |
|
522 } |
|
523 |
|
524 |
|
525 // --------------------------------------------------------------------------- |
|
526 // CAudioFetcherDialog::CountComponentControls |
|
527 // |
|
528 // --------------------------------------------------------------------------- |
|
529 // |
|
530 CCoeControl* CAudioFetcherDialog::ComponentControl( TInt /*aIndex*/ ) const |
|
531 { |
|
532 return iListBox; |
|
533 } |
|
534 |
|
535 //----------------------------------------------------------------------------- |
|
536 // CAudioFetcherDialog::OfferKeyEventL |
|
537 //----------------------------------------------------------------------------- |
|
538 TKeyResponse CAudioFetcherDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) |
|
539 { |
|
540 WLOG("CAudioFetcherDialog::OfferKeyEventL"); |
|
541 TKeyResponse keyResponse( EKeyWasNotConsumed ); |
|
542 |
|
543 // Escape key was pressed and dialog needs to close |
|
544 if ( aKeyEvent.iCode == EKeyEscape && aType == EEventKey ) |
|
545 { |
|
546 TryExitL( EAknSoftkeyCancel ); |
|
547 keyResponse = EKeyWasConsumed; |
|
548 } |
|
549 else |
|
550 { |
|
551 keyResponse = iListBox->OfferKeyEventL( aKeyEvent, aType ); |
|
552 } |
|
553 return keyResponse; |
|
554 } |
|
555 |
|
556 // ----------------------------------------------------------------------------- |
|
557 // CAudioFetcherDialog::HandleListBoxEventL (from MEikListBoxObserver) |
|
558 // ----------------------------------------------------------------------------- |
|
559 // |
|
560 void CAudioFetcherDialog::HandleListBoxEventL( CEikListBox* /*aListBox*/, |
|
561 TListBoxEvent aEventType ) |
|
562 { |
|
563 WLOG("CAudioFetcherDialog::HandleListBoxEventL"); |
|
564 |
|
565 switch ( aEventType ) |
|
566 { |
|
567 case EEventItemDoubleClicked: // fallthrough |
|
568 case EEventEnterKeyPressed: |
|
569 { |
|
570 TBool closeDialog = HandleListSelectionL(); |
|
571 if ( closeDialog ) |
|
572 { |
|
573 // close after short delay (dialog cannot be closed from this function) |
|
574 CloseDialogWithDelayL(); |
|
575 } |
|
576 break; |
|
577 } |
|
578 default: |
|
579 break; |
|
580 } |
|
581 } |
|
582 |
|
583 // ----------------------------------------------------------------------------- |
|
584 // CAudioFetcherDialog::CloseDialogWithDelayL |
|
585 // ----------------------------------------------------------------------------- |
|
586 // |
|
587 void CAudioFetcherDialog::CloseDialogWithDelayL() |
|
588 { |
|
589 delete iIdle; |
|
590 iIdle = NULL; |
|
591 iIdle = CIdle::NewL( CActive::EPriorityIdle ); |
|
592 |
|
593 if ( iIdle ) |
|
594 { |
|
595 iIdle->Start( TCallBack( CloseDialog, this ) ); |
|
596 } |
|
597 delete iInputBlock; |
|
598 iInputBlock = NULL; |
|
599 iInputBlock = CAknInputBlock::NewLC(); |
|
600 CleanupStack::Pop( iInputBlock ); |
|
601 } |
|
602 |
|
603 // ----------------------------------------------------------------------------- |
|
604 // CAudioFetcherDialog::CloseDialog |
|
605 // ----------------------------------------------------------------------------- |
|
606 // |
|
607 TInt CAudioFetcherDialog::CloseDialog( TAny *aObj ) |
|
608 { |
|
609 CAudioFetcherDialog *dlg = (CAudioFetcherDialog*) aObj; |
|
610 delete dlg->iInputBlock; |
|
611 dlg->iInputBlock = NULL; |
|
612 |
|
613 TRAP_IGNORE( dlg->TryExitL( EAknSoftkeyOk ) ); |
|
614 |
|
615 return 0; |
|
616 } |
|
617 |
|
618 // ----------------------------------------------------------------------------- |
|
619 // CAudioFetcherDialog::ConstructListboxItem |
|
620 // ----------------------------------------------------------------------------- |
|
621 // |
|
622 TPtrC CAudioFetcherDialog::ConstructListboxItem( TInt aListboxIndex ) |
|
623 { |
|
624 WLOG("CAudioFetcherDialog::ConstructListboxItem"); |
|
625 _LIT( KFormat2, "%d\t%S\t%d" ); |
|
626 |
|
627 TInt mediaTypeIcon = EEIconEmpty; |
|
628 TInt storageTypeIcon = EEIconEmpty; |
|
629 |
|
630 GetListItemText( aListboxIndex, iListboxItemText1 ); |
|
631 mediaTypeIcon = MediaTypeIcon( aListboxIndex ); |
|
632 storageTypeIcon = StorageTypeIcon( aListboxIndex ); |
|
633 |
|
634 iListboxItemText2.Format( KFormat2, mediaTypeIcon, &iListboxItemText1, storageTypeIcon ); |
|
635 return iListboxItemText2; |
|
636 } |
|
637 |
|
638 |
|
639 // ----------------------------------------------------------------------------- |
|
640 // CAudioFetcherDialog::StorageTypeIcon |
|
641 // ----------------------------------------------------------------------------- |
|
642 // |
|
643 TInt CAudioFetcherDialog::StorageTypeIcon( TInt aListboxIndex ) |
|
644 { |
|
645 WLOG("CAudioFetcherDialog::StorageTypeIcon"); |
|
646 if ( aListboxIndex < 0 ) |
|
647 { |
|
648 return EEIconEmpty; |
|
649 } |
|
650 |
|
651 TInt storageType = iFileHandler->Attribute( aListboxIndex, |
|
652 CAudioFetcherFileHandler::EAttrStorageType, 0 ); |
|
653 TInt iconId = EEIconEmpty; |
|
654 |
|
655 if ( storageType == CAudioFetcherFileHandler::EMemoryCard ) |
|
656 { |
|
657 iconId = EEIconMemoryCard; |
|
658 } |
|
659 else if ( storageType == CAudioFetcherFileHandler::EMassStorage ) |
|
660 { |
|
661 iconId = EEIconMassStorage; |
|
662 } |
|
663 |
|
664 return iconId; |
|
665 } |
|
666 |
|
667 |
|
668 // ----------------------------------------------------------------------------- |
|
669 // CAudioFetcherDialog::MediaTypeIcon |
|
670 // ----------------------------------------------------------------------------- |
|
671 // |
|
672 TInt CAudioFetcherDialog::MediaTypeIcon( TInt aListboxIndex ) |
|
673 { |
|
674 WLOG("CAudioFetcherDialog::MediaTypeIcon"); |
|
675 if ( aListboxIndex < 0 ) |
|
676 { |
|
677 return EEIconEmpty; |
|
678 } |
|
679 |
|
680 TInt mediaType = iFileHandler->Attribute( aListboxIndex, |
|
681 CAudioFetcherFileHandler::EAttrMediaType, 0 ); |
|
682 |
|
683 TInt iconId = EEIconEmpty; |
|
684 |
|
685 switch ( mediaType ) |
|
686 { |
|
687 case CAudioFetcherFileHandler::EMediaTypeImage: |
|
688 { |
|
689 iconId = EEIconImage; |
|
690 break; |
|
691 } |
|
692 case CAudioFetcherFileHandler::EMediaTypeVideo: |
|
693 { |
|
694 iconId = EEIconVideo; |
|
695 break; |
|
696 } |
|
697 case CAudioFetcherFileHandler::EMediaTypeTone: |
|
698 { |
|
699 iconId = EEIconTone; |
|
700 break; |
|
701 } |
|
702 case CAudioFetcherFileHandler::EMediaTypeRecording: |
|
703 { |
|
704 iconId = EEIconRecording; |
|
705 break; |
|
706 } |
|
707 case CAudioFetcherFileHandler::EMediaTypeMusic: |
|
708 { |
|
709 iconId = EEIconMusic; |
|
710 break; |
|
711 } |
|
712 default: |
|
713 break; |
|
714 } |
|
715 |
|
716 return iconId; |
|
717 } |
|
718 |
|
719 // ----------------------------------------------------------------------------- |
|
720 // CAudioFetcherDialog::ListboxItemCount (from MAudioFetcherListHandlerObserver) |
|
721 // ----------------------------------------------------------------------------- |
|
722 // |
|
723 TInt CAudioFetcherDialog::ListboxItemCount() |
|
724 { |
|
725 WLOG("CAudioFetcherDialog::ListboxItemCount"); |
|
726 return iFileHandler->ResultCount(); |
|
727 } |
|
728 |
|
729 |
|
730 |
|
731 // ----------------------------------------------------------------------------- |
|
732 // CAudioFetcherDialog::HandleFileEventL (from MAudioFetcherFileHandlerObserver) |
|
733 // ----------------------------------------------------------------------------- |
|
734 // |
|
735 void CAudioFetcherDialog::HandleFileEventL( TInt aEvent, TInt aError ) |
|
736 { |
|
737 WLOG("CAudioFetcherDialog::HandleFileEventL >"); |
|
738 // handle cancel button |
|
739 if ( aEvent == MAudioFetcherFileHandlerObserver::EQueryCanceled ) |
|
740 { |
|
741 WLOG("CAudioFetcherDialog::HandleFileEventL == EQueryCanceled"); |
|
742 UpdateListBoxL(); |
|
743 return; |
|
744 } |
|
745 |
|
746 // handle error |
|
747 if ( aError != KErrNone ) |
|
748 { |
|
749 WLOG1("### CAudioFetcherDialog::HandleFileEventL (%d) ###", aError ); |
|
750 return; |
|
751 } |
|
752 |
|
753 if ( aEvent != MAudioFetcherFileHandlerObserver::EUnknownQueryComplete ) |
|
754 { |
|
755 WLOG("CAudioFetcherDialog::HandleFileEventL != EUnknownQueryComplete"); |
|
756 } |
|
757 |
|
758 if ( aEvent == MAudioFetcherFileHandlerObserver::EUnknownQueryComplete ) |
|
759 { |
|
760 WLOG("CAudioFetcherDialog::HandleFileEventL == EUnknownQueryComplete"); |
|
761 } |
|
762 |
|
763 if ( aEvent == MAudioFetcherFileHandlerObserver::EQueryComplete ) |
|
764 { |
|
765 WLOG("CAudioFetcherDialog::HandleFileEventL == EQueryComplete"); |
|
766 |
|
767 |
|
768 if ( iMediaType == EAnyMediaFile ) |
|
769 { |
|
770 // in case of all media files, fetch video files next |
|
771 if ( iFileHandler->QueryType() == CAudioFetcherFileHandler::EMediaTypeMusic ) |
|
772 { |
|
773 iFileHandler->QueryVideoL(); |
|
774 } |
|
775 else if ( iFileHandler->QueryType() == CAudioFetcherFileHandler::EMediaTypeVideo ) |
|
776 { |
|
777 iFileHandler->QueryImageL(); |
|
778 } |
|
779 else |
|
780 { |
|
781 UpdateListBoxL(); |
|
782 } |
|
783 |
|
784 } |
|
785 else |
|
786 { |
|
787 UpdateListBoxL(); |
|
788 } |
|
789 } |
|
790 |
|
791 if ( aEvent == MAudioFetcherFileHandlerObserver::EMediaFileChanged ) |
|
792 { |
|
793 WLOG("CAudioFetcherDialog::HandleFileEventL == EMediaFileChanged"); |
|
794 } |
|
795 |
|
796 if ( aEvent == MAudioFetcherFileHandlerObserver::EInitComplete ) |
|
797 { |
|
798 WLOG("CAudioFetcherDialog::HandleFileEventL == EInitComplete"); |
|
799 iDatabaseOpen = ETrue; |
|
800 QueryL(); |
|
801 } |
|
802 |
|
803 WLOG("CAudioFetcherDialog::HandleFileEventL <"); |
|
804 } |
|
805 |
|
806 |
|
807 // ----------------------------------------------------------------------------- |
|
808 // CAudioFetcherDialog::GetListItemText |
|
809 // |
|
810 // ----------------------------------------------------------------------------- |
|
811 // |
|
812 void CAudioFetcherDialog::GetListItemText( TInt aListboxIndex, TDes& aText ) |
|
813 { |
|
814 WLOG("CAudioFetcherDialog::GetListItemText"); |
|
815 iFileHandler->GetAttribute( aListboxIndex, |
|
816 CAudioFetcherFileHandler::EAttrSongName, aText, 0 ); |
|
817 } |
|
818 |
|
819 |
|
820 |
|
821 // ----------------------------------------------------------------------------- |
|
822 // CAudioFetcherDialog::CurrentItemListIndex |
|
823 // |
|
824 // ----------------------------------------------------------------------------- |
|
825 // |
|
826 TInt CAudioFetcherDialog::CurrentItemListIndex() |
|
827 { |
|
828 WLOG("CAudioFetcherDialog::CurrentItemListIndex"); |
|
829 TInt itemCount = iListBox->Model()->NumberOfItems(); |
|
830 TInt currentIndex = iListBox->CurrentItemIndex(); |
|
831 |
|
832 if ( itemCount == 0 || currentIndex < 0 ) |
|
833 { |
|
834 return KErrNotFound; // list or find box is empty |
|
835 } |
|
836 return currentIndex; |
|
837 } |
|
838 |
|
839 |
|
840 //------------------------------------------------------------------------------ |
|
841 // CMediaFileDialog::QueryL |
|
842 // |
|
843 //------------------------------------------------------------------------------ |
|
844 // |
|
845 void CAudioFetcherDialog::QueryL() |
|
846 { |
|
847 WLOG("CAudioFetcherDialog::QueryL >"); |
|
848 if ( !iFileHandler->QueryReady() || !iDatabaseOpen ) |
|
849 { |
|
850 WLOG("CAudioFetcherDialog::QueryL: query in progress"); |
|
851 return; |
|
852 } |
|
853 |
|
854 iFileHandler->EnableObserverCall( ETrue ); |
|
855 iFileHandler->SetQueryId( 0 ); |
|
856 iFileHandler->QueryAudioL(); |
|
857 |
|
858 WLOG("CAudioFetcherDialog::QueryL <"); |
|
859 } |
|
860 |
|
861 // ---------------------------------------------------------------------------- |
|
862 // CAudioFetcherDialog::HandleResourceChange |
|
863 // ---------------------------------------------------------------------------- |
|
864 // |
|
865 void CAudioFetcherDialog::HandleResourceChange(TInt aType) |
|
866 { |
|
867 WLOG("CAudioFetcherDialog::HandleResourceChange"); |
|
868 if (aType == KAknsMessageSkinChange) |
|
869 { |
|
870 TRAP_IGNORE( SetIconsL() ); |
|
871 } |
|
872 else if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
873 { |
|
874 TRect mainPaneRect; |
|
875 AknLayoutUtils::LayoutMetricsRect( |
|
876 AknLayoutUtils::EMainPane, mainPaneRect ); |
|
877 SetRect( mainPaneRect ); |
|
878 TRAP_IGNORE( iStatusPaneHandler->SetTitleL( iTitle ) ); |
|
879 TRAP_IGNORE( iStatusPaneHandler->SetNaviPaneTitleL( KNullDesC ) ); |
|
880 DrawDeferred(); |
|
881 } |
|
882 |
|
883 CCoeControl::HandleResourceChange( aType ); |
|
884 } |
|
885 |
|
886 |
|
887 // ---------------------------------------------------------------------------- |
|
888 // CAudioFetcherDialog::HandleListSelection |
|
889 // ---------------------------------------------------------------------------- |
|
890 // |
|
891 TBool CAudioFetcherDialog::HandleListSelectionL() |
|
892 { |
|
893 TBool closeDialog = EFalse; |
|
894 |
|
895 TInt index = CurrentItemListIndex(); |
|
896 TBuf<128> fileName; |
|
897 |
|
898 iFileHandler->GetAttribute( index, CAudioFetcherFileHandler::EAttrFullName, fileName, 0 ); |
|
899 iSelectedFiles.AppendL( fileName ); |
|
900 |
|
901 // Retreives the uri's of the selected files and verifies if it is a |
|
902 // supported format |
|
903 if ( iVerifier && !iVerifier->VerifySelectionL( &iSelectedFiles ) ) |
|
904 { |
|
905 iSelectedFiles.Reset(); |
|
906 closeDialog = EFalse; |
|
907 } |
|
908 else |
|
909 { |
|
910 closeDialog = ETrue; |
|
911 } |
|
912 return closeDialog; |
|
913 } |
|
914 |
|
915 // End of File |