clock2/clockengines/clocktimezoneresolver/inc/clocktimezoneresolverimpl.h
changeset 89 b57382753122
parent 0 f979ecb2b13e
equal deleted inserted replaced
83:5aadd1120515 89:b57382753122
       
     1 /*
       
     2 * Copyright (c) 2008 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:   This is the header file of the CClockTimeZoneResolverImpl class.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __CLOCK_TIMEZONE_RESOLVER_IMPL_H__ 
       
    19 #define __CLOCK_TIMEZONE_RESOLVER_IMPL_H__
       
    20 
       
    21 // System includes
       
    22 #include <e32base.h>
       
    23 #include <etelmm.h>
       
    24 #include <tz.h>
       
    25 #include <tzconverter.h>
       
    26 #include <tzlocalizationdatatypes.h>
       
    27 #include <vtzrules.h>
       
    28 
       
    29 // User includes
       
    30 #include "clocktimesourceinterface.hrh"
       
    31 
       
    32 // Forward declarations
       
    33 class CClockMCCTzIdMapper;
       
    34 
       
    35 // Class declaration
       
    36 /** 
       
    37 * @class CClockTimeZoneResolverImpl
       
    38 * @brief An instance of class CClockTimeZoneResolverImpl which is the actual implementation of timezone mapper.
       
    39 * @dll clocktimezoneresolver.dll
       
    40 */
       
    41 class CClockTimeZoneResolverImpl : public CBase
       
    42 	{
       
    43 	public:				// Constructor and destructor
       
    44 	
       
    45 		/**
       
    46 		* @brief Creates a CClockTimeZoneResolverImpl object
       
    47 		* @return CClockTimeZoneResolverImpl*
       
    48 		*/
       
    49     	static CClockTimeZoneResolverImpl* NewL();
       
    50 		
       
    51 		/**
       
    52 		* @brief Destroy the object and release all memory objects
       
    53 		*/
       
    54 	  	~CClockTimeZoneResolverImpl();
       
    55 	    
       
    56 	public:				// New functions
       
    57 	
       
    58 		/**
       
    59 		* @brief Gets the timezone based on the MCC and NITZ info.
       
    60 		* @param aTimeInfo Time information got from the plugin.
       
    61 		* @param aMcc Mobile country code.
       
    62 		* @param aTzId The matching timezone ID.
       
    63 		* @return KErrNone if a matching timezone ID is found, KErrNotFound otherwise.
       
    64 		*/
       
    65 		TInt GetTimeZoneL( const STimeAttributes& aTimeInfo, 
       
    66 						   const RMobilePhone::TMobilePhoneNetworkCountryCode& aMcc,
       
    67 						   TInt& aTzId );
       
    68 		
       
    69 		/**
       
    70 		* @brief Find all TzIds for a given MCC with optional matching StdTimeOffset
       
    71 		* @param aMCC Mobile Country Code to search for
       
    72 		* @param aTzIdArray Array of CTzID objects to add matching zones to.
       
    73 		* @param aStdTimeOffset Limit returned zones to zones with a matching offset
       
    74 		*/
       
    75 		void TzIdFromMccL( const RMobilePhone::TMobilePhoneNetworkCountryCode& aMCC,
       
    76 						   RArray< CTzId >& aTzIdArray,
       
    77 						   const TTimeIntervalMinutes& aStdTimeOffset = -1 );
       
    78 		
       
    79 		/**
       
    80 		* @brief Find the MCC for a given TzId
       
    81 		* @param aTzId CTzId to search for
       
    82 		* @return the MCC of the DST zone, or KErrNotFound if not found.
       
    83 		*/
       
    84 		TInt MCCFromTzIdL( const CTzId& aTzId );
       
    85 		
       
    86 	private:			// Constructor
       
    87 	
       
    88 		/**
       
    89 		* @brief C++ default constructor
       
    90 		*/
       
    91 	  	CClockTimeZoneResolverImpl();
       
    92 		
       
    93 		/** 
       
    94 		* @brief Symbian OS 2nd phase constructor is private.
       
    95 		*/
       
    96 		void ConstructL();
       
    97 	  
       
    98 	private:			// New functions
       
    99 		
       
   100 		/** 
       
   101 		* @brief Uses the received Nitz UTC offset in conjunction with the
       
   102 		* 		 Mobile Country Code to calculate which DST zone we are in.
       
   103 		* @param aTimeInfo Time information got from any of the plugins.
       
   104 		* @param aMcc Mobile Country code got from MCC Listener. 
       
   105 		* @param aTzId Contains the valid timezone ID, -1 otherwise.
       
   106 		* @return TInt KErrNone if successful, KErrNotFound otherwise.
       
   107 		*/
       
   108 		TInt FindDstZoneIdFromMccAndUtcOffsetL( const STimeAttributes& aTimeInfo, 
       
   109 										  	    const RMobilePhone::TMobilePhoneNetworkCountryCode& aMcc,
       
   110 										  	    TInt& aTzId );
       
   111 										  	   
       
   112 		/** 
       
   113 		* @brief Gets all the localized timezones for the corresponding mcc and timezone offset.
       
   114 		* @param aMcc Mobile Country code got from MCC Listener.
       
   115 		* @param aTimezoneOffset The standard offset got from the plugin.
       
   116 		* @param aTzLocalisedArray Contains all the matching localized timezones.
       
   117 		*/
       
   118 		void GetLocalizedZonesL( const RMobilePhone::TMobilePhoneNetworkCountryCode& aMcc,
       
   119                                	 const TTimeIntervalMinutes& aTimezoneOffset,                                            
       
   120                                  CTzLocalizedTimeZoneArray& aTzLocalisedArray );
       
   121         
       
   122         /** 
       
   123 		* @brief Gets the list of timezone ID's given an array of localized timezones.
       
   124 		* @param aLocTimeZones List of localized timezones.
       
   125 		* @param aZoneIdArray Array containing all matching timezone ID's.
       
   126 		* @param aNwLocalTime Local time.
       
   127 		* @param aNwUtcTime UTC time.
       
   128 		*/                       
       
   129         void FindMatchingLocalisedZoneL( CTzLocalizedTimeZoneArray& aLocTimeZones, 
       
   130                            	    		 RPointerArray<CTzId>& aZoneIdArray, 
       
   131                                 		 TTime& aNwLocalTime, 
       
   132                                 		 TTime& aNwUtcTime );
       
   133 	    
       
   134        	/** 
       
   135 		* @brief Gets all the timezones for the corresponding mcc and timezone offset.
       
   136 		* @param aMcc Mobile Country code got from MCC Listener.
       
   137 		* @param aTimezoneOffset The standard offset got from the plugin.
       
   138 		* @param aTzUnLocalizedArray Contains all the matching timezones.
       
   139 		*/
       
   140 
       
   141         void GetAllUnLocalizedZonesL( const RMobilePhone::TMobilePhoneNetworkCountryCode& aMcc,
       
   142                                       const TTimeIntervalMinutes& aTimezoneOffset,                                                                                        
       
   143                                       RArray< CTzId >& aTzUnLocalizedArray);
       
   144 
       
   145 
       
   146         /** 
       
   147 		* @brief Gets the list of timezone ID's given an array of unlocalized timezones.
       
   148 		* @param aUnLocalizedTzArray List of unlocalized timezones.
       
   149 		* @param aZoneIdArray Array containing all matching timezone ID's.
       
   150 		* @param aNwLocalTime Local time.
       
   151 		* @param aNwUtcTime UTC time.
       
   152 		*/                       
       
   153  
       
   154         void FindMatchingUnLocalizedZoneL( RArray< CTzId >& aUnLocalizedTzArray, 
       
   155                                            RPointerArray<CTzId>& aZoneIdArray, 
       
   156                                            TTime& aNwLocalTime, 
       
   157                                            TTime& aNwUtcTime );
       
   158                                            
       
   159         /**
       
   160         * @brief Find DstOffset and standard Offset for the time zone aTzId using CTzRules
       
   161         * @param aDstOffset referance to DstOffset
       
   162         * @param aStdOffset referance to Standard Offset
       
   163         * @param aTzId time zone Id for which DstOffset and StdOffset is to be found
       
   164         */
       
   165         void GetStdOffSetAndDstOffSetL( TInt32& aDstOffset, 
       
   166                                       	TInt32& aStdOffset,
       
   167                                       	const CTzId& aTzId );                                    
       
   168         
       
   169         /**
       
   170         * @brief Finds the matching timezone ID with the specified offset.
       
   171         * @param aTzOffset The offset for which we are trying to find the timezone ID.
       
   172         * @param aTzId Contains the timezone ID matching the offset.
       
   173         * @return KErrNotFound if no matches were found, KErrNone otherwise.
       
   174         */
       
   175         TInt GetTimeZoneIdWithOffsetL( const TTimeIntervalMinutes& aTzOffset,
       
   176                                        TInt& aTzId );
       
   177         /**
       
   178         * @brief Finds the matching timezone ID with the specified MCC.
       
   179         * @param aMcc The MCC for which we are trying to find the timezone ID.
       
   180         * @param aTzOffset The offset for which we are trying to find the timezone ID.
       
   181         * @param aTzId Contains the timezone ID matching the MCC.
       
   182         * @return KErrNotFound if no matches were found, KErrNone otherwise.
       
   183         */
       
   184         TInt GetTimeZoneIdWithMccL( const RMobilePhone::TMobilePhoneNetworkCountryCode& aMcc,
       
   185                                     const TTimeIntervalMinutes& aTzOffset,
       
   186                                     TInt& aTzId );
       
   187         
       
   188         /**
       
   189         * @brief Tries to narrow down to a single timezone ID from the timezone array
       
   190         * @param aLocTimeZones The array which contains all matching timezones.
       
   191         * @param aTzId Contains the timezone ID, if found.
       
   192         * @return KErrNotFound if no matches were found, KErrNone otherwise.
       
   193         */
       
   194         TInt ProcessMatchingZones( CTzLocalizedTimeZoneArray& aLocTimeZones, TInt& aTzId );
       
   195         
       
   196         
       
   197         /**
       
   198         * @brief Tries to get timezone ID based on the dstoffset.
       
   199         * @param aLocTimeZones The array which contains all matching timezones.
       
   200         * @param aTzOffset The offset for which we are trying to find the timezone ID.
       
   201         * @param aDstOffset The DST offset for which we are trying to find the timezone ID.
       
   202         * @return KErrNotFound if no matches were found, KErrNone otherwise.
       
   203         */
       
   204         TInt GetCorrectZone( CTzLocalizedTimeZoneArray& aLocTimeZones, 
       
   205                              const TTimeIntervalMinutes& aTzOffset,
       
   206                              const TTimeIntervalMinutes& aDstOffset, TInt& aTzId );
       
   207         
       
   208         /**
       
   209         * @brief Gets the localized timezones for each zone that matches.
       
   210         * @param aLocTimeZones The array which contains all matching timezones.
       
   211         * @param aTzId Contains the timezone ID, if found.
       
   212         * @return KErrNone if we have only one matching zone.
       
   213         */
       
   214         TInt GetMatchingZonesL( CTzLocalizedTimeZoneArray* aLocTimeZones, TInt& aTzId );
       
   215  
       
   216 	private:			// Data
       
   217 		
       
   218 		/**
       
   219 		* @var iMccTzIdMapper 
       
   220 		* @brief Interface to the MCC->TzIDMapper of type CMCCTzIdMapper*
       
   221 		*/
       
   222 		CClockMCCTzIdMapper*		iMccTzIdMapper;
       
   223 		
       
   224 		/**
       
   225 		* @var iTempZoneIds 
       
   226 		* @brief Array of timezone id's.
       
   227 		*/
       
   228 		RPointerArray< CTzId >		iTempZoneIds;
       
   229 		
       
   230 		/**
       
   231 		* @var iRtz 
       
   232 		* @brief Object of type RTz.
       
   233 		*/
       
   234 		RTz 						iRtz;
       
   235 
       
   236 	};
       
   237 
       
   238 #endif		// __CLOCK_TIMEZONE_RESOLVER_IMPL_H__
       
   239 
       
   240 // End of file