68
|
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: Header file of mediafiledialog. UI control of mediafilelist
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
#ifndef MEDIALFILEDIALOG_H
|
|
22 |
#define MEDIALFILEDIALOG_H
|
|
23 |
|
|
24 |
|
|
25 |
// INCLUDES
|
|
26 |
#include "mediafiledialogutils.h"
|
|
27 |
#include "mediafilepreview.h"
|
|
28 |
#include "mediafilehandler.h"
|
|
29 |
#include "mediafiledialogstate.h"
|
|
30 |
#include "mediafilewaitnote.h"
|
|
31 |
|
|
32 |
|
|
33 |
#include <e32base.h>
|
|
34 |
#include <aknlists.h>
|
|
35 |
#include <AknDialog.h>
|
|
36 |
#include <AknInfoPopupNoteController.h> // CAknInfoPopupNoteController
|
|
37 |
#include <eikedwin.h>
|
|
38 |
#include <aknsfld.h>
|
|
39 |
#include <peninputsrveventhandler.h>
|
|
40 |
#include <peninputclient.h>
|
|
41 |
|
|
42 |
|
|
43 |
// CONSTANTS
|
|
44 |
|
|
45 |
// CLASS DECLARATION
|
|
46 |
class CMFDialogTest;
|
|
47 |
class CMFProtectionHandler;
|
|
48 |
class CAknInputBlock;
|
|
49 |
class CVideoPreviewDialog;
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
/**
|
|
54 |
* CMFListHandlerObserver
|
|
55 |
*
|
|
56 |
* CMFListHandler uses CMFListHandlerObserver to get listbox item texts.
|
|
57 |
*/
|
|
58 |
NONSHARABLE_CLASS (CMFListHandlerObserver)
|
|
59 |
{
|
|
60 |
public:
|
|
61 |
virtual TPtrC ConstructListboxItem( TInt aListIndex ) = 0;
|
|
62 |
virtual TInt ListboxItemCount() = 0;
|
|
63 |
};
|
|
64 |
|
|
65 |
|
|
66 |
/**
|
|
67 |
* CMFListHandler
|
|
68 |
*
|
|
69 |
* This class is used as listbox model's item array. Listbox uses it to draw
|
|
70 |
* list items. CMFListHandler gets list item texts from CMediaFileHandler
|
|
71 |
* (metadata query result). This way there is no need to copy all list items
|
|
72 |
* into listbox model.
|
|
73 |
*/
|
|
74 |
NONSHARABLE_CLASS (CMFListHandler) : public MDesCArray
|
|
75 |
{
|
|
76 |
public:
|
|
77 |
static CMFListHandler* NewL();
|
|
78 |
~CMFListHandler();
|
|
79 |
private:
|
|
80 |
void ConstructL(void);
|
|
81 |
CMFListHandler();
|
|
82 |
|
|
83 |
public: // from MDesCArray
|
|
84 |
TInt MdcaCount() const;
|
|
85 |
TPtrC16 MdcaPoint(TInt aIndex) const;
|
|
86 |
|
|
87 |
public:
|
|
88 |
void SetObserver( CMFListHandlerObserver* aObserver );
|
|
89 |
static void Panic( TInt aReason );
|
|
90 |
|
|
91 |
private:
|
|
92 |
CMFListHandlerObserver* iObserver; // does not own
|
|
93 |
};
|
|
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
|
99 |
|
|
100 |
/**
|
|
101 |
* CMediaFileDialog
|
|
102 |
*
|
|
103 |
* CMediaFileDialog provides UI for selecting/previewing media files.
|
|
104 |
*/
|
|
105 |
NONSHARABLE_CLASS (CMediaFileDialog) : public CAknDialog,
|
|
106 |
public MEikListBoxObserver,
|
|
107 |
public MCoeForegroundObserver,
|
|
108 |
public CMFListHandlerObserver,
|
|
109 |
public MMediaFileHandlerObserver,
|
|
110 |
public MMFActiveCallerObserver,
|
|
111 |
public MPreviewHandlerObserver,
|
|
112 |
public MMediaFileWaitNoteObserver,
|
|
113 |
public MAdaptiveSearchTextObserver, // not used
|
|
114 |
public MPenUiActivationHandler
|
|
115 |
|
|
116 |
{
|
|
117 |
|
|
118 |
#ifdef _DEBUG
|
|
119 |
friend class CMFDialogTest;
|
|
120 |
#endif
|
|
121 |
|
|
122 |
enum TListOperationType
|
|
123 |
{
|
|
124 |
EAttrSelect,
|
|
125 |
EAttrOpen,
|
|
126 |
EAttrClicked,
|
|
127 |
EAttrDoubleClicked
|
|
128 |
};
|
|
129 |
|
|
130 |
enum TDelayedOperationType
|
|
131 |
{
|
|
132 |
EAttrPreview,
|
|
133 |
EAttrSearch,
|
|
134 |
EAttrChangeCba
|
|
135 |
};
|
|
136 |
|
|
137 |
|
|
138 |
public:// Constructors and destructor
|
|
139 |
|
|
140 |
/**
|
|
141 |
* Two-phased constructor.
|
|
142 |
*/
|
|
143 |
static CMediaFileDialog* NewL();
|
|
144 |
|
|
145 |
/**
|
|
146 |
* Destructor.
|
|
147 |
*/
|
|
148 |
virtual ~CMediaFileDialog();
|
|
149 |
|
|
150 |
private:
|
|
151 |
|
|
152 |
/**
|
|
153 |
* C++ default constructor.
|
|
154 |
*/
|
|
155 |
CMediaFileDialog();
|
|
156 |
|
|
157 |
/**
|
|
158 |
* By default Symbian OS constructor is private.
|
|
159 |
*/
|
|
160 |
void ConstructL();
|
|
161 |
|
|
162 |
public:
|
|
163 |
TBool ShowDialogL( TDes* aFileName, TInt* aNullItem,
|
|
164 |
TInt* aInfo, TDes* aDesInfo );
|
|
165 |
|
|
166 |
void SetAttrL( TInt aAttr, TInt aValue );
|
|
167 |
void SetAttrL( TInt aAttr, const TDesC& aValue );
|
|
168 |
void SetAttrL( TInt aAttr, TAny* aValue );
|
|
169 |
void SetNullItemL( const TDesC& aText, const TDesC& aMediaFile,
|
|
170 |
TInt aMediaFileType, TInt aIconId );
|
|
171 |
|
|
172 |
private:
|
|
173 |
/**
|
|
174 |
* From MEikListBoxObserver, called by framework.
|
|
175 |
* @param aListBox.
|
|
176 |
* @param aEventType.
|
|
177 |
* @return None
|
|
178 |
*/
|
|
179 |
void HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType );
|
|
180 |
|
|
181 |
/**
|
|
182 |
* From the base class.
|
|
183 |
* Called by framework before the dialog is shown.
|
|
184 |
* @param None
|
|
185 |
* @return None
|
|
186 |
*/
|
|
187 |
void PreLayoutDynInitL();
|
|
188 |
|
|
189 |
/**
|
|
190 |
* From the base class.
|
|
191 |
* Called by framework before exiting the dialog.
|
|
192 |
* @param aButtonId Button id.
|
|
193 |
* @return ETrue to exit\ EFalse to not to exit.
|
|
194 |
*/
|
|
195 |
TBool OkToExitL( TInt aButtonId );
|
|
196 |
|
|
197 |
/**
|
|
198 |
* From the base class.
|
|
199 |
* Called by framework for key event handling.
|
|
200 |
* @param aKeyEvent.
|
|
201 |
* @param aType.
|
|
202 |
* @return Return code.
|
|
203 |
*/
|
|
204 |
TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
|
|
205 |
|
|
206 |
/**
|
|
207 |
* From the base class.
|
|
208 |
* Called by framework when dialog is activated.
|
|
209 |
* @param None.
|
|
210 |
* @return None.
|
|
211 |
*/
|
|
212 |
void ActivateL();
|
|
213 |
|
|
214 |
/**
|
|
215 |
* From the base class.
|
|
216 |
* Called by framework before menu is shown.
|
|
217 |
* @param aResourceId Menu resource id.
|
|
218 |
* @param aMenuPane Pointer to the menu.
|
|
219 |
* @return None.
|
|
220 |
*/
|
|
221 |
void DynInitMenuPaneL( TInt aResourceID, CEikMenuPane* aMenuPane );
|
|
222 |
|
|
223 |
/**
|
|
224 |
* From the base class.
|
|
225 |
* Handles menu events.
|
|
226 |
* @param aCommandId Command id.
|
|
227 |
* @return None.
|
|
228 |
*/
|
|
229 |
void ProcessCommandL( TInt aCommandId );
|
|
230 |
|
|
231 |
/**
|
|
232 |
* From base class.
|
|
233 |
* Called when UI layout changes.
|
|
234 |
* @param aType.
|
|
235 |
* @return None.
|
|
236 |
*/
|
|
237 |
void HandleResourceChange( TInt aType );
|
|
238 |
|
|
239 |
/** SetSizeAndPosition
|
|
240 |
* From CAknDialog.
|
|
241 |
* Sets dialog's size to whole main pane.
|
|
242 |
* @param aSize ignored
|
|
243 |
*/
|
|
244 |
void SetSizeAndPosition( const TSize &aSize );
|
|
245 |
|
|
246 |
SEikControlInfo CreateCustomControlL( TInt aControlType );
|
|
247 |
|
|
248 |
virtual CCoeControl* ComponentControl( TInt aIndex ) const;
|
|
249 |
virtual TInt CountComponentControls() const;
|
|
250 |
|
|
251 |
|
|
252 |
private:
|
|
253 |
TBool DoHandleOKL( TInt aAttr );
|
|
254 |
TBool HandleOKL( TInt aAttr );
|
|
255 |
TBool DoHandleBackL();
|
|
256 |
TBool HandleBackL();
|
|
257 |
void SearchL();
|
|
258 |
void DoSearchL();
|
|
259 |
static TInt StartRomScaning( TAny* aInstance );
|
|
260 |
void StartRomScan();
|
|
261 |
|
|
262 |
private:
|
|
263 |
void ResetDialogL( TInt aError);
|
|
264 |
void QueryL( TInt aFolderId, TBool aDatabaseChanged = EFalse );
|
|
265 |
void GetSelectedItemFileName( TInt aListboxIndex, TDes& aFileName );
|
|
266 |
TInt CurrentItemListIndex();
|
|
267 |
void SetIconsL();
|
|
268 |
CAknSearchField* FindBox() const;
|
|
269 |
void ResetFindBoxL();
|
|
270 |
void FindBoxCursorMoveL( TInt aType );
|
|
271 |
void ShowContextMenuL( TInt aResource );
|
|
272 |
void PreviewL( TInt aMediaType );
|
|
273 |
void PreviewVideoL( const TDesC& aFileName );
|
|
274 |
void PreviewNullItemL( TInt aFolderId );
|
|
275 |
void StartPreviewWithDelay();
|
|
276 |
void CancelPreview();
|
|
277 |
void StartSearchWithDelay();
|
|
278 |
TBool IsVideoFile( TInt aCurrentIndex );
|
|
279 |
TBool IsValidVideoFileL( TInt aCurrentIndex, TInt aIntention );
|
|
280 |
TInt MediaTypeIcon( TInt aListboxIndex );
|
|
281 |
TInt StorageTypeIcon( TInt aListboxIndex );
|
|
282 |
void GetListItemText( TInt aListboxIndex, TDes& aText );
|
|
283 |
|
|
284 |
private:
|
|
285 |
void CheckListboxIndex();
|
|
286 |
void HandleMediaFileChanged();
|
|
287 |
|
|
288 |
private:
|
|
289 |
void UpdateListBoxL( TBool aRestFindBox = ETrue );
|
|
290 |
void DoUpdateListBoxL( TBool aRestFindBox );
|
|
291 |
void UpdateCbaL( TInt aAttr );
|
|
292 |
TInt MapAttribute( TInt aFolderId );
|
|
293 |
|
|
294 |
void ShowErrorNoteL( TInt aError );
|
|
295 |
void ShowPreviewErrorNoteL( TInt aError, TInt aMediaType );
|
|
296 |
void DeleteMenuItem( CEikMenuPane* aMenuPane, TInt aCommandId );
|
|
297 |
CGulIcon* IconL(TAknsItemID aId, const TDesC& aFileName, TInt aFileIndex,
|
|
298 |
TInt aFileMaskIndex);
|
|
299 |
CGulIcon* IconL(TAknsItemID aId, const TDesC& aFileName, TInt aFileIndex,
|
|
300 |
TInt aFileMaskIndex, TAknsQsnIconColorsIndex colorIndex);
|
|
301 |
static TInt CloseDialog( TAny *aObj );
|
|
302 |
void CloseDialogWithDelayL();
|
|
303 |
|
|
304 |
private:
|
|
305 |
void ShowWaitNoteL( TBool aDatabaseChanged );
|
|
306 |
void ShowPopupNoteL( const TDesC& aText );
|
|
307 |
void ShowDetailsPopupL();
|
|
308 |
void GetPopupText( CMediaFileData* aData, TDes& aText );
|
|
309 |
TBool MatchFound( const TDesC& aAttribute, const TDesC& aText );
|
|
310 |
|
|
311 |
|
|
312 |
private:
|
|
313 |
static void Panic( TInt aReason );
|
|
314 |
|
|
315 |
private: // from CMFListHandlerObserver
|
|
316 |
TPtrC ConstructListboxItem( TInt aListboxIndex );
|
|
317 |
TInt ListboxItemCount();
|
|
318 |
|
|
319 |
private: // from MPreviewHandlerObserver
|
|
320 |
void HandlePreviewEventL( TInt aEvent, TInt aError );
|
|
321 |
|
|
322 |
private: // from MMediaFileHandlerObserver
|
|
323 |
void HandleMFEventL( TInt aEvent, TInt aError );
|
|
324 |
|
|
325 |
private: // from MMFActiveCallerObserver
|
|
326 |
void HandleActiveCallL( TInt aCallId );
|
|
327 |
|
|
328 |
private: //from MCoeControlObserver
|
|
329 |
void HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType );
|
|
330 |
|
|
331 |
private: // from MCoeForegroundObserver
|
|
332 |
void HandleGainingForeground();
|
|
333 |
void HandleLosingForeground();
|
|
334 |
|
|
335 |
private: // from MAdaptiveSearchTextObserver
|
|
336 |
void AdaptiveSearchTextChanged( CAknSearchField* aSearchField );
|
|
337 |
|
|
338 |
private: // from MPenUiActivationHandler
|
|
339 |
void OnPeninputUiDeactivated();
|
|
340 |
void OnPeninputUiActivated();
|
|
341 |
|
|
342 |
private: // MMediaFileWaitNoteObserver
|
|
343 |
void HandleWaitNoteL( TInt aButtonId );
|
|
344 |
|
|
345 |
#ifdef _DEBUG
|
|
346 |
private: // test code
|
|
347 |
CMFDialogTest* iTest;
|
|
348 |
#endif
|
|
349 |
|
|
350 |
private:
|
|
351 |
// listbox
|
|
352 |
CAknSingleGraphicStyleListBox* iListBox;
|
|
353 |
|
|
354 |
// for title and icon handling
|
|
355 |
CStatusPaneHandler* iStatusPaneHandler;
|
|
356 |
|
|
357 |
// long buffer for string handling
|
|
358 |
TBuf<KBufSize256> iBuf;
|
|
359 |
|
|
360 |
// long buffer for string handling
|
|
361 |
TBuf<KBufSize256> iPopupText;
|
|
362 |
|
|
363 |
// long buffers for listbox items
|
|
364 |
TBuf<KBufSize128> iListboxItemText1;
|
|
365 |
TBuf<KBufSize256> iListboxItemText2;
|
|
366 |
|
|
367 |
// text from search field
|
|
368 |
TBuf<KBufSize128> iSearchText;
|
|
369 |
|
|
370 |
// long buffers for icon file names
|
|
371 |
TFileName iIconFileName;
|
|
372 |
|
|
373 |
// list box model item array
|
|
374 |
CMFListHandler* iMFListHandler;
|
|
375 |
|
|
376 |
// dialog state
|
|
377 |
CMediaFileDialogState* iState;
|
|
378 |
|
|
379 |
// metadata engine wrapper
|
|
380 |
CMediaFileHandler* iMediaFileHandler;
|
|
381 |
|
|
382 |
// search box
|
|
383 |
CAknSearchField* iFindCtrl;
|
|
384 |
|
|
385 |
// for generating active object calls
|
|
386 |
CMFActiveCaller* iCaller;
|
|
387 |
CMFActiveCaller* iSearchCaller;
|
|
388 |
|
|
389 |
// for previewing video files
|
|
390 |
CMFVideoPreviewHandler* iVideoPreviewHandler;
|
|
391 |
|
|
392 |
// for previewing audio files
|
|
393 |
CMFAudioPreviewHandler* iAudioPreviewHandler;
|
|
394 |
|
|
395 |
// popup note
|
|
396 |
CAknInfoPopupNoteController* iPopupNote;
|
|
397 |
|
|
398 |
// cancel note in case database query takes more than 2 seconds
|
|
399 |
CMediaFileWaitNote* iWaitNote;
|
|
400 |
|
|
401 |
// needed for finding out whether search field is in pen input mode
|
|
402 |
RPeninputServer iPeninputServer;
|
|
403 |
|
|
404 |
// for file protection information (drm etc)
|
|
405 |
CMFProtectionHandler* iProtectionHandler;
|
|
406 |
|
|
407 |
// for closing dialog
|
|
408 |
CIdle* iIdle;
|
|
409 |
|
|
410 |
TBool ifilevalid;
|
|
411 |
// is dialog in foreground (visible)
|
|
412 |
TBool iForeGround;
|
|
413 |
|
|
414 |
// dll resource file id
|
|
415 |
TInt iResourceFileId;
|
|
416 |
|
|
417 |
// is metadata databse open
|
|
418 |
TBool iDatabaseOpen;
|
|
419 |
|
|
420 |
// is pen input active
|
|
421 |
TBool iPeninputActive;
|
|
422 |
|
|
423 |
// dialog attribute values
|
|
424 |
HBufC* iNullItemFileNameOne;
|
|
425 |
HBufC* iNullItemFileNameTwo;
|
|
426 |
TInt iNullItemFileTypeOne;
|
|
427 |
TInt iNullItemFileTypeTwo;
|
|
428 |
TBuf<KBufSize128> iDialogTitle;
|
|
429 |
|
|
430 |
CAknInputBlock* iInputBlock;
|
|
431 |
|
|
432 |
// dialog output parameters
|
|
433 |
|
|
434 |
// selected media file
|
|
435 |
TDes* iFileName;
|
|
436 |
// selected null item
|
|
437 |
TInt*iNullItem;
|
|
438 |
// extra parameter for later use
|
|
439 |
TInt* iInfo;
|
|
440 |
// extra parameter for later use
|
|
441 |
TDes* iDesInfo;
|
|
442 |
//is double clicked the item of the listbox
|
|
443 |
TBool iIsDoubleClicked;
|
|
444 |
TBool iFileisvalid;
|
|
445 |
// Video preview dialogue, model dialog
|
|
446 |
CVideoPreviewDialog* iVideoPreviewDlg;
|
|
447 |
};
|
|
448 |
|
|
449 |
|
|
450 |
|
|
451 |
/**
|
|
452 |
* CFindControl
|
|
453 |
*
|
|
454 |
* Search field functionality (CFindControl) is copied from
|
|
455 |
* AknSelectionLis (s60/mw/classicui/uifw/AvKon/src/AknSelectionList.cpp).
|
|
456 |
* Example code can also be found in
|
|
457 |
* s60/app/imppapplications/wvuing/wvuiave/AppSrc/CCAContactSelectionDialog.cpp
|
|
458 |
*/
|
|
459 |
NONSHARABLE_CLASS (CFindControl) : public CCoeControl
|
|
460 |
{
|
|
461 |
public:
|
|
462 |
CAknSearchField *iFind;
|
|
463 |
~CFindControl() { delete iFind; }
|
|
464 |
void Draw(const TRect &) const
|
|
465 |
{
|
|
466 |
// this removes flicker from CEikDialog's Draw().
|
|
467 |
}
|
|
468 |
void SizeChanged()
|
|
469 |
{
|
|
470 |
TRect mainPane;
|
|
471 |
AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPane );
|
|
472 |
|
|
473 |
TAknLayoutRect listRect;
|
|
474 |
|
|
475 |
listRect.LayoutRect( mainPane, AknLayout::list_gen_pane(0) );
|
|
476 |
|
|
477 |
TRect r( listRect.Rect() );
|
|
478 |
iPosition = TPoint( r.iTl );
|
|
479 |
iSize.SetSize( r.Width(), r.Height() );
|
|
480 |
}
|
|
481 |
|
|
482 |
TSize MinimumSize()
|
|
483 |
{
|
|
484 |
if ( iFind )
|
|
485 |
{
|
|
486 |
if ( iFind->Size() != TSize( 0, 0 ) )
|
|
487 |
{
|
|
488 |
return iFind->Size();
|
|
489 |
}
|
|
490 |
}
|
|
491 |
|
|
492 |
return iSize;
|
|
493 |
}
|
|
494 |
};
|
|
495 |
|
|
496 |
|
|
497 |
|
|
498 |
|
|
499 |
#endif // MEDIALFILEDIALOG_H
|
|
500 |
|
|
501 |
// End of File
|