tzservices/tzserver/Server/Include/ReadOnlyTzDb.h
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef __READONLYTZDB_H__
       
    17 #define __READONLYTZDB_H__
       
    18 
       
    19 #include <f32file.h>
       
    20 #include "MBackupRestoreNotificationObserver.h"
       
    21 #include "mtimezonedataaccess.h"
       
    22 #include "tzdbentities.h"
       
    23 #include "tzswiobserver.h"
       
    24 
       
    25 class CTzDbChangeNotifier;
       
    26 class CVTzRules;
       
    27 
       
    28 //
       
    29 // CReadOnlyTzDb: class to manage the Read-Only TimeZone Database
       
    30 //
       
    31 class CReadOnlyTzDb : public CBase, public MTzDataObserver
       
    32 	{
       
    33 public:
       
    34 	static CReadOnlyTzDb* NewL(RFs& aFs, CTzSwiObserver& aSwiObserver, MTzDataObserver& aTzDataObserver);
       
    35 	~CReadOnlyTzDb();
       
    36 	void ReleaseData();	// releases the data without destroying the object 
       
    37 						// (so that it can keep watching for changes to the database)
       
    38 
       
    39 	//
       
    40 	// Public methods to extract information from the database
       
    41 	// 
       
    42 	void GetTzRulesL(CTzRules& aRules, CTzId& aTzId);
       
    43 	CBufFlat* GetTzRuleDesignationL(CTzId& aTzId, const TDateTime& aDateTime, TTzTimeReference aTimeRef);
       
    44 	CTzId* GetDefaultTimeZoneIdL();
       
    45 	TInt GetOffsetForTimeZoneIdL(const TTime& aTime, TInt aTzId);
       
    46 	TBool IsIdInDbL(TUint aTzId);
       
    47 	
       
    48 public:
       
    49 	// methods to handle backup-restore
       
    50 	void BackupBeginningL();
       
    51 	void BackupCompletedL();
       
    52 	void RestoreBeginningL();
       
    53 	void RestoreCompletedL();
       
    54 	TInt StartAddress() const;
       
    55 
       
    56 	CTzDbZone* GetZoneL(TUint aReference) const;
       
    57 	CTzDbRuleSet* GetRuleSetL(TUint aReference) const;
       
    58 
       
    59 	const TTzZone& GetTZone(TUint aReference) const;
       
    60 	const TTzRegionalZoneIndex& GetTRegionalZoneIndex(TUint aReference) const;
       
    61 	const TTzStdTimeAlignment& GetTStdTimeAlignment(TUint aReference) const;
       
    62 	const TTzRuleUse& GetTRuleUse(TUint aReference) const;
       
    63 
       
    64 	TPtrC8 GetStringL(TUint aOffset) const;
       
    65 	const TTzRuleDefinition& GetTRuleDefinition(TUint aOffset) const;
       
    66 
       
    67 	// inherited from MTzDataObserver
       
    68 	void NotifyTZDataStatusChangeL(RTz::TTzChanges);
       
    69 	
       
    70 private:
       
    71 	CReadOnlyTzDb(RFs& aFs, CTzSwiObserver& aSwiObserver, MTzDataObserver& aTzDataObserver);
       
    72 	void ConstructL();
       
    73 	void InitialiseL();
       
    74 	
       
    75 	TInt CopyDatabaseToRam(const TDesC &aTzDbFileName);
       
    76 	TInt InvalidateFlashDatabaseL();
       
    77 	void DoGetTzRulesL(CTzRules& aRules, CTzId& aTzId);
       
    78 	
       
    79 	CTzDbZone* FindZoneL(CTzId& aTzId, TBool aFillInLocationIDs);
       
    80 	CTzDbZone* FindZoneByNameL(const TDesC8& aName);
       
    81 	CTzDbZone* FindZoneByNumericIdL(TUint aNumericId);
       
    82 	CTzDbStdTimeAlignment* FindStdTimeAlignmentL(const TDesC8& aZone, const TDateTime& aDateTime);
       
    83 
       
    84 	void HandleDatabaseChangeL(RTz::TTzChanges aChange);
       
    85 
       
    86 	inline void SetRestoreInProcess();
       
    87 	inline void ResetRestoreInProcess();
       
    88 
       
    89 private:
       
    90 	RFs& iFs;
       
    91 	CTzSwiObserver& iSwiObserver;
       
    92 
       
    93 	// detect and notify changes in the flash-based TZ Database
       
    94 	MTzDataObserver& iTzDataObserver;
       
    95 	
       
    96 	// DB entity tables (will be created when the object is constructed)
       
    97 	CTzDbStringsTable*				iStringsTable;
       
    98 	CTzDbRegionsTable*				iRegionsTable;
       
    99 	CTzDbRegionalZonesTable*		iRegionalZonesTable;
       
   100 	CTzDbZonesTable*				iZonesTable;
       
   101 	CTzDbLinksTable*				iLinksTable;
       
   102 	CTzDbStdTimeAlignmentsTable*	iStdTimeAlignmentsTable;
       
   103 	CTzDbRuleSetsTable*				iRuleSetsTable;
       
   104 	CTzDbRuleUsesTable*				iRuleUsesTable;
       
   105 	CTzDbRuleDefinitionsTable*		iRuleDefinitionsTable;
       
   106 
       
   107 	// Start address of RAM copy of TZ Database file
       
   108 	TInt	iStartAddress;
       
   109 	// RAM copy of TZ Database file
       
   110 	TUint8*	iTzDbData;
       
   111 	RChunk	iChunk;
       
   112 	// If true, RAM copy of TZ Database file was copied from Flash (C: drive)
       
   113 	// otherwise was copied from ROM (Z: drive).
       
   114 	TBool iTzDbDataFromFlash;
       
   115 
       
   116 	TBool	iRestoreInProcess;
       
   117 	};
       
   118 
       
   119 inline void CReadOnlyTzDb::SetRestoreInProcess()	
       
   120 	{ 
       
   121 	iRestoreInProcess = ETrue;	
       
   122 	}
       
   123  
       
   124 inline void CReadOnlyTzDb::ResetRestoreInProcess()	
       
   125 	{ 
       
   126 	iRestoreInProcess = EFalse;	
       
   127 	} 
       
   128 
       
   129 #endif // __READONLYTZDB_H__