engine/inc/SettingsEngine.h
changeset 2 29cda98b007e
equal deleted inserted replaced
1:5f8e5adbbed9 2:29cda98b007e
       
     1 /*
       
     2 * Copyright (c) 2007-2010 Sebastian Brannstrom, Lars Persson, EmbedDev AB
       
     3 *
       
     4 * All rights reserved.
       
     5 * This component and the accompanying materials are made available
       
     6 * under the terms of the License "Eclipse Public License v1.0"
       
     7 * which accompanies this distribution, and is available
       
     8 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     9 *
       
    10 * Initial Contributors:
       
    11 * EmbedDev AB - initial contribution.
       
    12 *
       
    13 * Contributors:
       
    14 *
       
    15 * Description:
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef SETTINGSENGINE_H_
       
    20 #define SETTINGSENGINE_H_
       
    21 
       
    22 #include <e32base.h>
       
    23 #include "PodcastModel.h"
       
    24 
       
    25 _LIT(KPodcastDir1, "F:\\Podcasts\\"); // memory card on phone with flash disk
       
    26 _LIT(KPodcastDir2, "E:\\Podcasts\\"); // memory card on phone without flash disk
       
    27 _LIT(KPodcastDir3, "C:\\Podcasts\\");
       
    28 
       
    29 _LIT(KConfigImportFile, "config.cfg");
       
    30 _LIT(KDefaultFeedsFile, "defaultfeeds.xml");
       
    31 _LIT(KImportFeedsFile, "feeds.xml");
       
    32 
       
    33 _LIT(KConfigFile, "config.db");
       
    34 
       
    35 // constants
       
    36 const TInt KSettingsUid = 1000;
       
    37 const TInt KDefaultUpdateFeedInterval = 60;
       
    38 const TInt KDefaultMaxListItems = 100;
       
    39 const TInt32 KUseIAPFlag =0x01000000;
       
    40 const TInt32 KUseIAPMask =0x00FFFFFF;
       
    41 
       
    42 enum TAutoUpdateSetting
       
    43 	{
       
    44 	EAutoUpdateOff,
       
    45 	EAutoUpdatePeriod1=60,
       
    46 	EAutoUpdatePeriod2=360,
       
    47 	EAutoUpdatePeriod3=720,
       
    48 	EAutoUpdatePeriod4=1440
       
    49 	};
       
    50 
       
    51 class CSettingsEngine : public CBase
       
    52 	{
       
    53 	public:
       
    54 		static CSettingsEngine* NewL(CPodcastModel& aPodcastModel);
       
    55 		virtual ~CSettingsEngine();
       
    56 	
       
    57 
       
    58 		TFileName DefaultFeedsFileName();
       
    59 		TFileName ImportFeedsFileName();
       
    60 		TFileName PrivatePath();
       
    61 
       
    62 		TInt MaxListItems();
       
    63 
       
    64 		IMPORT_C TFileName& BaseDir();
       
    65 		IMPORT_C void SetBaseDir(TFileName& aFileName);
       
    66 
       
    67 		IMPORT_C TInt UpdateFeedInterval();
       
    68 		IMPORT_C void SetUpdateFeedInterval(TInt aInterval);
       
    69 
       
    70 		IMPORT_C TInt MaxSimultaneousDownloads();
       
    71 		IMPORT_C void SetMaxSimultaneousDownloads(TInt aMaxDownloads);
       
    72 		
       
    73 		IMPORT_C TAutoUpdateSetting UpdateAutomatically();	
       
    74 		IMPORT_C void SetUpdateAutomatically(TAutoUpdateSetting aAutoOn);
       
    75 		
       
    76 		IMPORT_C TBool DownloadAutomatically();
       
    77 		IMPORT_C void SetDownloadAutomatically(TBool aAutoDownloadOn);
       
    78 		
       
    79 		IMPORT_C TBool DownloadSuspended();
       
    80 		IMPORT_C void SetDownloadSuspended(TBool aSuspended);
       
    81 
       
    82 		IMPORT_C TTime UpdateFeedTime();
       
    83 		IMPORT_C void SetUpdateFeedTime(TTime aTime);
       
    84 		
       
    85 		IMPORT_C TInt SpecificIAP();
       
    86 		IMPORT_C void SetSpecificIAP(TInt aIap);
       
    87 			
       
    88 		IMPORT_C void SaveSettingsL();
       
    89 
       
    90 	private:
       
    91 		CSettingsEngine(CPodcastModel& aPodcastModel);
       
    92 		void ConstructL();
       
    93 		void LoadSettingsL();
       
    94 		void GetDefaultBaseDirL(TDes &aBaseDir);
       
    95 
       
    96 
       
    97 	private:
       
    98 		// the settings we serialize
       
    99 		TFileName iBaseDir;
       
   100 		TInt iUpdateFeedInterval;
       
   101 		TAutoUpdateSetting iUpdateAutomatically;
       
   102 		TBool iDownloadAutomatically;
       
   103 		TInt iIap;
       
   104 		TInt iMaxListItems;
       
   105 		TTime iUpdateFeedTime;
       
   106 		TBool iDownloadSuspended;
       
   107 
       
   108 		// Other member variables		
       
   109 		CPodcastModel &iPodcastModel; 	// reference to the model
       
   110 	};
       
   111 
       
   112 #endif /*SETTINGSENGINE_H_*/