videofeeds/livetvutils/inc/CIptvSettingsDatabase.h
changeset 0 96612d01cf9f
equal deleted inserted replaced
-1:000000000000 0:96612d01cf9f
       
     1 /*
       
     2 * Copyright (c) 2006 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 the License "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 for CIptvSettingsDatabase class*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __CIPTVSETTINGSDATABASE_H__
       
    21 #define __CIPTVSETTINGSDATABASE_H__
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <d32dbms.h>
       
    26 #include <f32file.h>
       
    27 
       
    28 // CONSTANTS
       
    29 // Settings table
       
    30 _LIT( KIptvSettingsTable, 					"Settings" );   
       
    31 _LIT( KIptvSettingsDbKeyCol, 				"Key" );
       
    32 _LIT( KIptvParentalControlCol,				"ParentalControl" );
       
    33 _LIT( KIptvRecordingTimeCol,				"RecordingTime" );
       
    34 _LIT( KIptvReminderTimeCol,					"ReminderTime" );
       
    35 _LIT( KIptvLastUsedServiceCol,				"LastService" );
       
    36 _LIT( KIptvLastUsedChannelCol,				"LastChannel" );
       
    37 _LIT( KIptvIsLastUsedCol,			        "IsLast" );
       
    38 _LIT( KIptvQuerySettingsSql, "SELECT ParentalControl, RecordingTime, ReminderTime, LastService, LastChannel, IsLast FROM Settings" );
       
    39 
       
    40 // Default setting values
       
    41 const TInt KIptvDefaultParentalControl = 0;
       
    42 const TInt KIptvDefaultRecordingTimeReserve = 0;
       
    43 const TInt KIptvDefaultReminderTime = 0;
       
    44 const TUint32 KIptvDefaultLastUsedServiceId = 0;
       
    45 const TInt64 KIptvDefaultLastUsedChannelId = 0;
       
    46 const TInt KIptvDefaultIsLastUsed = 0;
       
    47 
       
    48 // FORWARD DECLARATIONS
       
    49 // CLASS DECLARATIONS
       
    50 /**
       
    51 * Live TV specific settings class.
       
    52 */
       
    53 class TIptvLiveUISettings
       
    54 	{
       
    55 	public: 
       
    56 
       
    57 		TInt    iParentalControl; 			// 0 = Off, or "%N Years"
       
    58 		TInt    iRecordingTimeReserve;   	// 0 = Off, or "%N min"
       
    59 		TInt    iReminderTime;				// 0 = Off, or "%N min"
       
    60   		TUint32 iLastUsedServiceId;         // 0 = Not used
       
    61   		TInt64  iLastUsedChannelId;         // 0 = Not used
       
    62   		TInt    iIsLastUsed;                // 0 = No (default), 1 = Yes
       
    63 	};
       
    64 
       
    65 /**
       
    66  * Class:       CIptvSettingsDatabase
       
    67  *
       
    68  * Description: An instance of class CIptvSettingsDatabase provides settings
       
    69  *              database access: creating & manipulating settings database
       
    70  *              files and database entries.
       
    71  * 
       
    72  */
       
    73 class CIptvSettingsDatabase : public CBase
       
    74     {
       
    75     public:  // Constructors and destructor
       
    76 
       
    77          /**
       
    78          * Two-phased constructor.
       
    79          * @param aDbFile Database file name.
       
    80          */
       
    81         IMPORT_C static CIptvSettingsDatabase* NewL( const TFileName& aDbFile );
       
    82     
       
    83         /**
       
    84          * Destructor.
       
    85          */
       
    86         IMPORT_C virtual ~CIptvSettingsDatabase();
       
    87 
       
    88 	    
       
    89 	public: // Public API for database operations
       
    90     
       
    91 		/**
       
    92 		* Save settings to the database.
       
    93 		* @param aSettings Settings object.
       
    94 		*/
       
    95 		IMPORT_C void SaveSettingsL( const TIptvLiveUISettings& aSettings );
       
    96 
       
    97 		/**
       
    98 		* Read settings from database.
       
    99 		* @param aSettings On return, contains current settings.
       
   100 		*/
       
   101 		IMPORT_C void ReadSettingsL( TIptvLiveUISettings& aSettings );
       
   102 
       
   103 		/**
       
   104 		* Save last used service and channel ids to database.
       
   105 		* @param aSettings Settings object.
       
   106 		*/
       
   107 		IMPORT_C void SaveLastUsageL( const TIptvLiveUISettings& aSettings );
       
   108 
       
   109 		/**
       
   110 		* Read last used service and channel ids from database.
       
   111 		* @param aServiceId current service id		
       
   112 		* @param aSettings On return, contains current settings.
       
   113 		*/
       
   114 		IMPORT_C void ReadLastUsageByServiceL( const TUint32 aServiceId, 
       
   115 		                                TIptvLiveUISettings& aSettings );
       
   116 		
       
   117 		/**
       
   118 		* Reads the actual last watched channel and service from the database.		
       
   119 		* @param aSettings On return, contains current settings (=last usage)
       
   120 		*/		                                
       
   121         IMPORT_C void ReadLastUsageL( TIptvLiveUISettings& aSettings );		                                
       
   122 
       
   123     private: // Constructors
       
   124     
       
   125         /**
       
   126         *	Constructor
       
   127         *	@param	aDbFile		Filename of the database to be used
       
   128         */
       
   129         CIptvSettingsDatabase( const TFileName& aDbFile );
       
   130 
       
   131         /**
       
   132         *	Symbian second phase constructor. All code that might leave
       
   133         *	during construction is placed in here.
       
   134         *	@param	None
       
   135         *	@return	None
       
   136         */
       
   137     	void ConstructL();
       
   138     	
       
   139 	private: // Methods
       
   140 	
       
   141         /**
       
   142     	* Create table for Settings and last used service and channel.
       
   143 		* @param aDatabase Database.
       
   144     	*/
       
   145     	void CreateTableL( RDbNamedDatabase& aDatabase ) const;
       
   146     	
       
   147         /**
       
   148          * 
       
   149          * Create new database if DB file is not found. 
       
   150          */
       
   151         void CreateDbL();
       
   152 
       
   153         /**        
       
   154          * Creates session to iptv database
       
   155          */
       
   156         void CreateDbSessionL();
       
   157     
       
   158 		/**
       
   159 		* Put in default settings.
       
   160 		* @param aDatabase Database.
       
   161 		*/
       
   162 		void SetDefaultValuesL( RDbNamedDatabase& aDatabase ) const;
       
   163 
       
   164         /**               
       
   165          * Initialise database   
       
   166          */     
       
   167         void InitDbL();
       
   168         
       
   169         
       
   170     private: // Data
       
   171 
       
   172 		/** File server session is connected in construction and closed in
       
   173 			destruction */
       
   174     	RFs              iFsSession;
       
   175     	
       
   176     	/** File name of the database which to handle */
       
   177 		TFileName        iDbFile;
       
   178 
       
   179         /** DB session */
       
   180         RDbs iDbSession;
       
   181         
       
   182         /** database */
       
   183         RDbNamedDatabase iDb;
       
   184         
       
   185     };
       
   186 
       
   187 #endif // __CIPTVSETTINGSDATABASE_H__
       
   188             
       
   189 // End of File