calendarui/commonutils/src/calenentryutil.cpp
branchRCL_3
changeset 31 97232defd20e
parent 30 bd7edf625bdd
equal deleted inserted replaced
30:bd7edf625bdd 31:97232defd20e
    28 
    28 
    29 #include <calalarm.h>
    29 #include <calalarm.h>
    30 #include <calentry.h>
    30 #include <calentry.h>
    31 #include <calrrule.h>
    31 #include <calrrule.h>
    32 #include <calattachment.h>
    32 #include <calattachment.h>
       
    33 #include <bldvariant.hrh> // for feature definitions
       
    34 #include <featmgr.h>
    33 
    35 
    34 
    36 
    35 // Utility functions 
    37 // Utility functions 
    36 
    38 
    37 // ======== LOCAL FUNCTIONS ======== 
    39 // ======== LOCAL FUNCTIONS ======== 
   137     TRACE_ENTRY_POINT;
   139     TRACE_ENTRY_POINT;
   138 
   140 
   139     delete iSummary;
   141     delete iSummary;
   140     delete iLocation;
   142     delete iLocation;
   141     delete iDescription;
   143     delete iDescription;
       
   144     
       
   145     // Do not call UnInitializeLib() if InitalizeLib() leaves.
       
   146     if ( iFeatMgrInitialized )
       
   147         {
       
   148         // Frees the TLS. Must be done after FeatureManager is used.
       
   149         FeatureManager::UnInitializeLib();  
       
   150         }  
       
   151     
       
   152 
   142 
   153 
   143     TRACE_EXIT_POINT;
   154     TRACE_EXIT_POINT;
   144     }
   155     }
   145 		
   156 		
   146 // Getters
   157 // Getters
   690 //
   701 //
   691 void CCalenEntryUtil::ConstructL( CCalEntry& aEntry, 
   702 void CCalenEntryUtil::ConstructL( CCalEntry& aEntry, 
   692                                    const TCalTime& aInstanceDateTime )
   703                                    const TCalTime& aInstanceDateTime )
   693     {
   704     {
   694     TRACE_ENTRY_POINT;
   705     TRACE_ENTRY_POINT;
       
   706     // Sets up TLS, must be done before FeatureManager is used.
       
   707     FeatureManager::InitializeLibL();
       
   708     // Used in destructor. 
       
   709     iFeatMgrInitialized = ETrue;
       
   710      
       
   711 
   695     iEntryType = aEntry.EntryTypeL();
   712     iEntryType = aEntry.EntryTypeL();
   696     iEntryStatus = aEntry.StatusL();
   713     iEntryStatus = aEntry.StatusL();
   697     CopyDataFromEntryL( aEntry, aInstanceDateTime );
   714     CopyDataFromEntryL( aEntry, aInstanceDateTime );
   698 
   715 
   699     TRACE_EXIT_POINT;
   716     TRACE_EXIT_POINT;
   750 
   767 
   751         case CCalEntry::EAnniv:
   768         case CCalEntry::EAnniv:
   752             {
   769             {
   753             TTime event = aInstanceDateTime.TimeLocalL();
   770             TTime event = aInstanceDateTime.TimeLocalL();
   754             SetEventDateL( event );
   771             SetEventDateL( event );
       
   772             if ( FeatureManager::FeatureSupported( KFeatureIdKorean ) )
       
   773                 {
       
   774 				SetCalendarTypeL( ( TLunarCalendarType )aEntry.UserInt32L() );
       
   775                 }
   755             }
   776             }
   756             break;
   777             break;
   757 
   778 
   758         case CCalEntry::ETodo:
   779         case CCalEntry::ETodo:
   759             {
   780             {
   914         	// editing a RDate instance, the alarmDateTime has to be adjusted.
   935         	// editing a RDate instance, the alarmDateTime has to be adjusted.
   915         	for( TInt index = 0; index < count; index++ )
   936         	for( TInt index = 0; index < count; index++ )
   916         		{
   937         		{
   917         		// If the instance matches one of the RDates
   938         		// If the instance matches one of the RDates
   918         		if( (aInstanceDateTime.TimeLocalL()) == (rdates[ index ].TimeLocalL()) )
   939         		if( (aInstanceDateTime.TimeLocalL()) == (rdates[ index ].TimeLocalL()) )
   919         			{
   940                     {
   920         			// instanceAlarmDay = actualAlarmDay + (alarmOffsetStart - alarmOffsetInstance)
   941                     // instanceAlarmDay = actualAlarmDay + (alarmOffsetStart - alarmOffsetInstance)
   921         			deltaDays =  alarmDateTime.DaysFrom( aEntry.StartTimeL().TimeLocalL() ).Int()
   942                     deltaDays =  alarmDateTime.DaysFrom( aEntry.StartTimeL().TimeLocalL() ).Int()
   922 								- alarmDateTime.DaysFrom( aInstanceDateTime.TimeLocalL() ).Int();
   943                     - alarmDateTime.DaysFrom( aInstanceDateTime.TimeLocalL() ).Int();
   923         			alarmDateTime += deltaDays;
   944                     alarmDateTime += deltaDays;
   924         			break;
   945                     if ( FeatureManager::FeatureSupported( KFeatureIdKorean ) )
   925         			}
   946                         {
       
   947                         if ( aEntry.EntryTypeL() == CCalEntry::EAnniv && CalendarType() != ESolar )
       
   948                             {
       
   949                             alarmDateTime = aEntry.StartTimeL().TimeLocalL(); 
       
   950                             CCalAlarm* alarm = aEntry.AlarmL();
       
   951                             if(alarm)
       
   952                                 {
       
   953                                 alarmDateTime = aInstanceDateTime.TimeLocalL() - alarm->TimeOffset();
       
   954                                 }
       
   955                             }
       
   956                         }
       
   957                     break;
       
   958                     }
   926         		}
   959         		}
   927         	}        	
   960         	}        	
   928         SetAlarmOnL( alarmDateTime );
   961         SetAlarmOnL( alarmDateTime );
   929         }
   962         }
   930     else
   963     else
  1038     return rDateList;
  1071     return rDateList;
  1039     
  1072     
  1040     TRACE_EXIT_POINT;
  1073     TRACE_EXIT_POINT;
  1041     }
  1074     }
  1042 
  1075 
       
  1076 // ---------------------------------------------------------------------------
       
  1077 // CalenViewUtils::CalendarType
       
  1078 // (other items were commented in a header)
       
  1079 // ---------------------------------------------------------------------------
       
  1080 //
       
  1081 EXPORT_C TLunarCalendarType CCalenEntryUtil::CalendarType() const
       
  1082     { 
       
  1083 	TRACE_ENTRY_POINT;
       
  1084 	TRACE_EXIT_POINT;
       
  1085 
       
  1086     return iCalendarType;
       
  1087     }
       
  1088 
       
  1089 // ---------------------------------------------------------------------------
       
  1090 // CalenViewUtils::SetCalendarTypeL
       
  1091 // (other items were commented in a header)
       
  1092 // ---------------------------------------------------------------------------
       
  1093 //
       
  1094 EXPORT_C void CCalenEntryUtil::SetCalendarTypeL(TLunarCalendarType aCalendarType)
       
  1095     {
       
  1096 	TRACE_ENTRY_POINT;
       
  1097 
       
  1098     iCalendarType = aCalendarType;
       
  1099 	TRACE_EXIT_POINT;
       
  1100 
       
  1101     }
       
  1102 
  1043 // End of file
  1103 // End of file