qtinternetradio/irqsonghistory/inc/irqsonghistoryengine.h
changeset 0 09774dfdd46b
child 5 0930554dc389
equal deleted inserted replaced
-1:000000000000 0:09774dfdd46b
       
     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 *
       
    16 */
       
    17 #ifndef IRQSONGHISTORYENGINE_H_
       
    18 #define IRQSONGHISTORYENGINE_H_
       
    19 
       
    20 #include <QObject>
       
    21 
       
    22 class IRQMetaData;
       
    23 class IRQPreset;
       
    24 class IRQSongHistoryInfo;
       
    25 class CIRSongHistoryDb;
       
    26 class IRQSongInfo;
       
    27 
       
    28 /**
       
    29 * Engine component for Internet Radio SongHistory.
       
    30 */
       
    31 class IRQSongHistoryEngine : public QObject
       
    32 {
       
    33     Q_OBJECT
       
    34 
       
    35 public:
       
    36 
       
    37     IMPORT_C static IRQSongHistoryEngine* openInstance();
       
    38     IMPORT_C void closeInstance();
       
    39 
       
    40     /**
       
    41     * Get all history from daba base
       
    42     * @param    QList<IRQSongHistoryInfo *>
       
    43     */
       
    44     IMPORT_C void getAllHistory(QList<IRQSongHistoryInfo *>& aSongHistoryArr);
       
    45     
       
    46     /**
       
    47      * this is songs' get, the above will be changed to the stations only
       
    48      */
       
    49     IMPORT_C void getAllSongHistory(QList<IRQSongInfo *>& aSongHistoryArr);
       
    50 
       
    51     /**
       
    52     * Clear all history in data base
       
    53     */
       
    54     IMPORT_C int clearAllHistory();
       
    55     
       
    56     IMPORT_C int clearAllSongHistory();
       
    57 
       
    58     /**
       
    59     * Called by the UI when a particular channel has been removed from the ISDS.
       
    60     */
       
    61     IMPORT_C void syncHistory(int aChannelId);
       
    62 
       
    63     /**
       
    64     * Called by the UI when a particular channel has been changed in the ISDS.
       
    65     */
       
    66 
       
    67     IMPORT_C void updateSongHistoryDb(int aChannelId,
       
    68                                       const QString& aChannelName,
       
    69                                       const QString& aChannelUrl,
       
    70                                       const QString& aImageUrl,
       
    71                                       const QString& aMusicFlag);
       
    72 
       
    73     /**
       
    74     * Connected with play controller with the song name changed.
       
    75     * @param    aMetaData   The meta data contains song name, artist and bitrate.
       
    76     * @param    aPreset     The preset contains other information.
       
    77     */
       
    78     IMPORT_C void handleMetaDataReceived(const IRQMetaData& aMetaData, const IRQPreset& aPreset);
       
    79     /**
       
    80     * Connected with play controller with the song name changed.
       
    81     * @param    aMetaData   The meta data contains song name, artist and bitrate.
       
    82     * @param    aMusicshopStatus     The music shop status of the song
       
    83     */
       
    84     IMPORT_C void handleSongMetaDataReceived(const IRQMetaData& aMetaData, QString& aMusicshopStatus);
       
    85     
       
    86     /*
       
    87      * delete one item from the station history db
       
    88      * @param   aIndex    the index of the item need deleted
       
    89      */
       
    90     IMPORT_C bool deleteOneItem(int aIndex);
       
    91 
       
    92 private:
       
    93 
       
    94     enum TSongHistoryItemChange
       
    95     {
       
    96         ENOCHANGE = 0,
       
    97         ECHANNELCHANGED,
       
    98         EMETADATACHANGED,
       
    99         EBLANKENTRIES
       
   100     };
       
   101 
       
   102 private:
       
   103 
       
   104     /**
       
   105      *  Creates IRQSongHistoryEngine instance
       
   106      */
       
   107     static IRQSongHistoryEngine* createInstanceL();
       
   108     
       
   109     void constructL();
       
   110 
       
   111     /**
       
   112     * Constructor.
       
   113     */
       
   114     IRQSongHistoryEngine();
       
   115 
       
   116     /**
       
   117     * Destructor.
       
   118     */
       
   119     ~IRQSongHistoryEngine();
       
   120     
       
   121     TSongHistoryItemChange detectSongHistoryItemChangesL(const IRQMetaData& aMetaData, const QString& aChannelName);
       
   122     
       
   123     void handleMetaDataReceivedL(const IRQMetaData& aMetaData, const IRQPreset& aPreset);
       
   124 	void getAllHistoryL(QList<IRQSongHistoryInfo *>& aSongHistoryArr);
       
   125 	void handleSongMetaDataReceivedL(const IRQMetaData& aMetaData, QString& aMusicshopStatus);
       
   126     void getAllSongHistoryL(QList<IRQSongInfo *>& aSongHistoryArr);
       
   127 
       
   128 private:
       
   129 
       
   130     /** An instance of songhistory database. */
       
   131     CIRSongHistoryDb* iSongHistoryDb;
       
   132 
       
   133     /**
       
   134      * Number of objects currently referring to the singleton object IRQSongHistoryEngine
       
   135      */
       
   136     int iSingletonInstances;
       
   137 };
       
   138 
       
   139 #endif //IRQSONGHISTORYENGINE_H_