internetradio2.0/songhistoryinc/irsonghistoryengine.h
changeset 14 896e9dbc5f19
parent 12 608f67c22514
child 15 065198191975
equal deleted inserted replaced
12:608f67c22514 14:896e9dbc5f19
     1 /*
       
     2 * Copyright (c) 2006-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:  Engine class to notify channel name/metadata changes to SongHistoryDb and UI
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 /* ---------------------------------------------------------------------------
       
    20 *  Version history:
       
    21 *  Template version:
       
    22 *  <ccm_history>
       
    23 *
       
    24 *  Version: 3, Thu Apr 14 12:00:00 2008 by Rohit
       
    25 *  Ref:
       
    26 *  Pc lint fixes
       
    27 *
       
    28 *  Version: 2, Thu Apr 10 20:00:00 2008 by Rohit
       
    29 *  Ref:
       
    30 *  Implemented SongHistory changes for channelwise songs
       
    31 *
       
    32 *  </ccm_history>
       
    33 * ============================================================================
       
    34 */
       
    35 
       
    36 
       
    37 #ifndef CIRSONGHISTORYENGINE_H
       
    38 #define CIRSONGHISTORYENGINE_H
       
    39 
       
    40 #include "irsonghistoryengpubsubnotifyhandler.h"
       
    41 #include "irsonghistorydb.h"
       
    42 
       
    43 
       
    44 class CIRSongHistoryEngPubSub;
       
    45 class MSongHistoryUINotifyHandler;
       
    46 class CIRMetaData;
       
    47 class CIRSongHistoryInfo;
       
    48 class RSongHistoryDb;
       
    49 class MIRSongHistoryEngPubSubNotifyHandler;
       
    50 
       
    51 
       
    52 enum TSongHistoryItemChange
       
    53 {
       
    54 	ENOCHANGE = 0,
       
    55 	ECHANNELCHANGED,
       
    56 	EMETADATACHANGED,
       
    57 	EBLANKENTRIES
       
    58 };
       
    59 
       
    60 /**
       
    61 * Engine component for Internet Radio SongHistory.
       
    62 * This class is responsible for listening to relevant P&S keys and notifying the UI code whenever the listened keys change.
       
    63 */
       
    64 NONSHARABLE_CLASS(CIRSongHistoryEngine) : public CBase,public MIRSongHistoryEngPubSubNotifyHandler
       
    65     {
       
    66     public:
       
    67 
       
    68     /**
       
    69     * Static constructor.
       
    70     * @param    aUiObserver   The observer to be notified of the changes in the keys.
       
    71     * @return   The newly created CIRSongHistoryEngine object.
       
    72     */
       
    73     	IMPORT_C static CIRSongHistoryEngine* NewL( MSongHistoryUINotifyHandler& aUiObserver );
       
    74 
       
    75     /**
       
    76     * Static constructor.
       
    77     * @param    aUiObserver   The observer to be notified of the changes in the keys.
       
    78     * @return   The newly created CIRSongHistoryEngine object.
       
    79     */
       
    80 
       
    81     	IMPORT_C static CIRSongHistoryEngine* NewLC( MSongHistoryUINotifyHandler& aUiObserver );
       
    82 
       
    83     /**
       
    84     * Destructor.
       
    85     */
       
    86  	   IMPORT_C ~CIRSongHistoryEngine();
       
    87 
       
    88     /**
       
    89     * Construction finalizer.
       
    90     * Must be called after CIRSongHistoryEngine::NewL.
       
    91     */
       
    92 	   void ConstructL();
       
    93 
       
    94 
       
    95 	//APIs to serve UI request
       
    96 
       
    97     /**
       
    98     * Invoked when UI request.
       
    99     * @param    aArray<CIRSongHistoryInfo>
       
   100     */
       
   101     	IMPORT_C void GetAllHistoryL( RPointerArray<CIRSongHistoryInfo>& aSongHistoryInfo );
       
   102 
       
   103     /**
       
   104     * Invoked when UI request.
       
   105     */
       
   106     	IMPORT_C TInt ClearAllHistory( );
       
   107 
       
   108     /**
       
   109     * Invoked when UI request.
       
   110     */
       
   111     	IMPORT_C TInt GetHistoryCount( );
       
   112     	
       
   113     /**
       
   114     * Called by the UI when a particular channel has been removed from the ISDS.
       
   115     */
       
   116         IMPORT_C TInt SyncHistory(TInt aChannelId);
       
   117         
       
   118     /**
       
   119     * Called by the UI when a particular channel has been changed in the ISDS.
       
   120     */
       
   121         
       
   122         IMPORT_C void UpdateSongHistoryDb( TInt aChannelId,
       
   123     	                          const TDesC& aChannelName, 
       
   124 						          const TDesC& aChannelUrl,
       
   125 							      const TDesC& aMusicFlag);
       
   126         
       
   127         /* called by the UI when delete a particular channel
       
   128          * */
       
   129         IMPORT_C TInt DeleteOneHistory(TInt aIndex);
       
   130 
       
   131 
       
   132   public:
       
   133   //this function made public for our internal testing. Has to be private without IMPORT_C
       
   134 		/**
       
   135 		* Invoked when the listened key is changed.
       
   136 		* @param    aCategory   The category of the key that changed.
       
   137 		* @param    aKey        The key that changed.
       
   138 		* @param    aText       The new value of the key.
       
   139 		*/
       
   140 
       
   141 			IMPORT_C void HandleMetaDataReceivedL( const CIRMetaData& aMetaData );
       
   142 
       
   143 	private:
       
   144 
       
   145 		/**
       
   146 		* Invoked when the listened key is changed.
       
   147 		* @param    aCategory   The category of the key that changed.
       
   148 		* @param    aKey        The key that changed.
       
   149 		* @param    aText       The new value of the key.
       
   150 		* Single wrapper function to be implemented in the engine class instead of two.
       
   151 		*/
       
   152 			void HandlePropertyChangeL( const TUid& aCategory, TUint aKey,
       
   153 											   const TDesC8& aText ) ;
       
   154 
       
   155 
       
   156 		/**
       
   157 		* Invoked when the listened key is changed.
       
   158 		* @param    aCategory   The category of the key that changed.
       
   159 		* @param    aKey        The key that changed.
       
   160 		* @param    aError      The error value.
       
   161 		*/
       
   162 			void HandlePropertyChangeErrorL( const TUid& aCategory, TUint aKey,
       
   163 										 TInt aError );
       
   164 
       
   165 		/**
       
   166 		 * Invoked when data needs to be added
       
   167 		 * @param	aMetaData	MetaData that needs to be added
       
   168 		 * @param	aChannelName Channel name that needs to be added
       
   169 		 */
       
   170 		TSongHistoryItemChange DetectSongHistoryItemChangesL(const CIRMetaData& aMetaData,
       
   171 					 const RBuf& aChannelName, const RBuf& aChannelUrl);
       
   172 
       
   173 	private:
       
   174 
       
   175 		/**
       
   176 		* Constructor.
       
   177 		* @param    aObserver   The observer to be notified of the changes
       
   178 		* in the keys.
       
   179 		*/
       
   180 			CIRSongHistoryEngine( MSongHistoryUINotifyHandler & aUiObserver );
       
   181 
       
   182 
       
   183     private:
       
   184 
       
   185 		/** An instance of songhistory database. */
       
   186 		CIRSongHistoryDb* iSongHistoryDb;
       
   187 
       
   188 
       
   189         /** The observer to be notified of the database changes to the UI */
       
   190 		MSongHistoryUINotifyHandler & iUiObserver;
       
   191 
       
   192         /** CIRSongHistoryEngPubSub objects subscribing for propery change */
       
   193         CIRSongHistoryEngPubSub *iChannelNameSub;
       
   194         
       
   195         CIRSongHistoryEngPubSub *iMetaDataSub;
       
   196 
       
   197     };
       
   198 
       
   199 #endif//CIRSONGHISTORYENGINE_H