messagingapp/msgui/msgaudiofetcher/inc/msgaudioselectionengine.h
changeset 37 518b245aa84c
child 48 4f501b74aeb1
equal deleted inserted replaced
25:84d9eb65b26f 37:518b245aa84c
       
     1 /*
       
     2  * Copyright (c) 2010 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 #ifndef MSGAUDIOSELECTIONENGINE_H
       
    19 #define MSGAUDIOSELECTIONENGINE_H
       
    20 
       
    21 // SYSTEM INCLUDES
       
    22 #include <mdesession.h>
       
    23 #include <mdequery.h>
       
    24 #include <mdelogiccondition.h>
       
    25 #include <mdeconstants.h>
       
    26 #include <mdeobjectquery.h>
       
    27 #include <mdccommon.h>
       
    28 #include <mdeitem.h>
       
    29 #include <mdeobject.h>
       
    30 #include <e32base.h>
       
    31 #include <QObject>
       
    32 #include <QStringList>
       
    33 
       
    34 // FORWARD DECLARATIONS
       
    35 
       
    36 /**
       
    37  *  This class is used for quering tones from mde.
       
    38  */
       
    39 class MsgAudioSelectionEngine : public QObject,
       
    40         public CBase,
       
    41         public MMdESessionObserver,
       
    42         public MMdEQueryObserver,
       
    43         public MMdEObjectObserver,
       
    44         public MMdEObjectPresentObserver
       
    45 {
       
    46 Q_OBJECT
       
    47 
       
    48 public:
       
    49 
       
    50     enum TStorageType
       
    51         {
       
    52         EPhoneMemory = 0, ERomStorage, EMassStorage, EMemoryCard
       
    53         };
       
    54 
       
    55     enum TQueryAttribute
       
    56         {
       
    57         EAttrMediaType = 20, // integer
       
    58         EAttrFileSize, // integer
       
    59         EAttrStorageType, // integer
       
    60         EAttrMediaFileId, // integer
       
    61         EAttrFileName, // string
       
    62         EAttrFullName, // string
       
    63         EAttrSongName, // string
       
    64         EAttrArtist, // string
       
    65         EAttrAlbum, // string
       
    66         EAttrGenre, // string
       
    67         EAttrComposer
       
    68         // string
       
    69         };
       
    70 
       
    71 public:
       
    72     MsgAudioSelectionEngine();
       
    73     virtual ~MsgAudioSelectionEngine();
       
    74     void CreateMetaDataSession();
       
    75 signals:
       
    76     void mdeSessionOpened();
       
    77     void mdeSessionError(int error);
       
    78     void queryComplete(QStringList nameList, QStringList uriList);
       
    79     void queryError(int error);
       
    80     void notifyObjectChanged();
       
    81 
       
    82 public:
       
    83     static CMdEPropertyDef& PropertyDefL(CMdESession* aSession, TInt aAttr);
       
    84     void QueryTones();
       
    85     void SetAttr(int attr, int value);
       
    86 
       
    87 private:
       
    88     void LeaveIfSessionClosedL();
       
    89     CMdEPropertyDef& PropertyDefL(TInt aAttr);
       
    90     void QueryTonesL();
       
    91     void HandleQueryCompletedL(CMdEQuery& aQuery, TInt aError);
       
    92 
       
    93 private:
       
    94     // from MMdESessionObserver
       
    95     void HandleSessionOpened(CMdESession& aSession, TInt aError);
       
    96     void HandleSessionError(CMdESession& aSession, TInt aError);
       
    97 
       
    98 private:
       
    99     // from MMdEQueryObserver (mdequery.h)
       
   100     void HandleQueryNewResults(CMdEQuery& aQuery, TInt aFirstNewItemIndex,
       
   101             TInt aNewItemCount);
       
   102     void HandleQueryCompleted(CMdEQuery& aQuery, TInt aError);
       
   103 private:
       
   104     // from MMdEObjectObserver
       
   105     void HandleObjectNotification(CMdESession& aSession,
       
   106             TObserverNotificationType aType,
       
   107             const RArray<TItemId>& aObjectIdArray);
       
   108 
       
   109 private:
       
   110     // from MMdEObjectPresentObserver
       
   111     void HandleObjectPresentNotification(CMdESession& aSession,
       
   112             TBool aPresent, const RArray<TItemId>& aObjectIdArray);
       
   113     void AddObjectObserverL();
       
   114 private:
       
   115 
       
   116 
       
   117     // session to metadata engine
       
   118     CMdESession* iSession;
       
   119 
       
   120     // metadata query
       
   121     CMdEObjectQuery* iQuery;
       
   122 
       
   123     // used for saving the quering result.
       
   124     //both name and uri.
       
   125     QStringList iNameList;
       
   126     QStringList iUriList;
       
   127 
       
   128     // is metadata session open
       
   129     TBool iSessionOpen;
       
   130 
       
   131     // max audio file file size
       
   132     TInt iMaxFileSize;
       
   133 
       
   134     // query error
       
   135     TInt iQueryError;
       
   136 };
       
   137 #endif /* MSGAUDIOSELECTIONENGINE_H */
       
   138