controlpanelui/src/tonefetcher/tonefetcherengine/private/CToneSelection.h
branchRCL_3
changeset 14 5f281e37a2f5
parent 13 90fe62538f66
equal deleted inserted replaced
13:90fe62538f66 14:5f281e37a2f5
     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:
       
    15  *     The header file for mde tone fetcher.
       
    16  *     
       
    17  */
       
    18 
       
    19 #ifndef CTONESELECTION_H
       
    20 #define CTONESELECTION_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <mdesession.h>
       
    24 #include <mdequery.h>
       
    25 #include <mdelogiccondition.h>
       
    26 #include <mdeconstants.h>
       
    27 #include <mdeobjectquery.h>
       
    28 #include <mdccommon.h>
       
    29 #include <mdeitem.h>
       
    30 #include <mdeobject.h>
       
    31 
       
    32 // FORWARD DECLARATIONS
       
    33 class MToneSelectionWatcher;
       
    34 class CToneSelection;
       
    35 
       
    36 /**
       
    37 * CMFActiveCaller
       
    38 *
       
    39 * CMFActiveCaller is used for generating a call from active scheduler.
       
    40 * Typical use is to start some operation after a short delay.
       
    41 */
       
    42 NONSHARABLE_CLASS (CMFActiveCaller) : public CActive
       
    43     {
       
    44     public:
       
    45         static CMFActiveCaller* NewL( CToneSelection* aObserver );
       
    46         virtual ~CMFActiveCaller();
       
    47 
       
    48     private:
       
    49         CMFActiveCaller( CToneSelection* aObserver );
       
    50         void ConstructL();
       
    51 
       
    52     public:
       
    53         void Start( TInt aMilliseconds );
       
    54         void Stop();
       
    55         void Request();
       
    56 
       
    57     private:
       
    58         void RunL();
       
    59         void DoCancel();
       
    60         
       
    61     private:
       
    62         // timer
       
    63         RTimer iTimer;
       
    64 
       
    65         // observer that gets called
       
    66         CToneSelection* iObserver;
       
    67     };
       
    68 
       
    69 // CLASS DECLARATION
       
    70 /**
       
    71  *  This class is used for quering tones from mde.
       
    72  *
       
    73  */
       
    74 class CToneSelection : public CBase, 
       
    75                        public MMdESessionObserver,
       
    76                        public MMdEQueryObserver,
       
    77                        public MMdEObjectObserver,
       
    78                        public MMdEObjectPresentObserver                            
       
    79     {
       
    80     public:
       
    81         enum TStorageType
       
    82             {
       
    83             EPhoneMemory = 0, ERomStorage, EMassStorage, EMemoryCard
       
    84             };
       
    85         
       
    86         enum TQueryAttribute
       
    87             {
       
    88             EAttrMediaType = 20, // integer
       
    89             EAttrFileSize, // integer
       
    90             EAttrStorageType, // integer
       
    91             EAttrMediaFileId, // integer
       
    92             EAttrFileName, // string
       
    93             EAttrFullName, // string
       
    94             EAttrSongName, // string
       
    95             EAttrArtist, // string
       
    96             EAttrAlbum, // string
       
    97             EAttrGenre, // string
       
    98             EAttrComposer
       
    99             };
       
   100     
       
   101     public:
       
   102         static CToneSelection* NewL( MToneSelectionWatcher *aWatcher );
       
   103         static CToneSelection* NewLC( MToneSelectionWatcher *aWatcher );
       
   104         
       
   105         virtual ~CToneSelection();
       
   106         //iTimer's callback function.
       
   107         void ChangeObject();
       
   108         void QueryTonesL();   
       
   109         void SetAttr( int attr, int value );
       
   110         TBool QueryReady();
       
   111     
       
   112     private:   
       
   113         CToneSelection(  MToneSelectionWatcher *aWatcher );
       
   114         void ConstructL(); 
       
   115         void ExcludeMusicPropertiesL( CMdELogicCondition& aCondition );    
       
   116         void LeaveIfSessionClosedL();
       
   117         CMdEPropertyDef& PropertyDefL(TInt aAttr);
       
   118         CMdEPropertyDef& PropertyDefL(CMdESession* aSession, TInt aAttr);
       
   119     
       
   120     private:
       
   121         // from MMdESessionObserver
       
   122         void HandleSessionOpened( CMdESession& aSession, TInt aError );
       
   123         void HandleSessionError( CMdESession& aSession, TInt aError );
       
   124     
       
   125     private:
       
   126         // from MMdEQueryObserver (mdequery.h)
       
   127         void HandleQueryNewResults( CMdEQuery& aQuery, TInt aFirstNewItemIndex,
       
   128                 TInt aNewItemCount );
       
   129         void HandleQueryCompleted( CMdEQuery& aQuery, TInt aError );    
       
   130     private:
       
   131         // from MMdEObjectObserver
       
   132         void HandleObjectNotification( CMdESession& aSession,
       
   133                 TObserverNotificationType aType,
       
   134                 const RArray<TItemId>& aObjectIdArray );
       
   135     
       
   136     private:
       
   137         // from MMdEObjectPresentObserver
       
   138         void HandleObjectPresentNotification( CMdESession& aSession,
       
   139                 TBool aPresent, const RArray<TItemId>& aObjectIdArray);
       
   140         void AddObjectObserverL();
       
   141         void HandleObjectChanged();
       
   142     private:
       
   143     
       
   144         MToneSelectionWatcher* iToneSelectionWatcher;
       
   145     
       
   146         // session to metadata engine
       
   147         CMdESession* iSession;
       
   148         
       
   149         CMdENamespaceDef* iDefNS; 
       
   150     
       
   151         // metadata query
       
   152         CMdEObjectQuery* iQuery;
       
   153         TBool iIsQuerying;
       
   154     
       
   155         // used for saving the quering result.
       
   156         RPointerArray<TDesC> iResultArray;
       
   157     
       
   158         // is metadata session open
       
   159         TBool iSessionOpen;
       
   160     
       
   161         // max audio file file size
       
   162         TInt iMaxFileSize;
       
   163         
       
   164         TInt iMediaFileCounter;
       
   165         // for generating active object calls
       
   166         CMFActiveCaller* iObjectNotificationCaller;
       
   167         
       
   168     };
       
   169 #endif /* CTONESELECTION_H */
       
   170