calendarui/commonutils/src/calenentryutil.cpp
branchRCL_3
changeset 86 ed599363c2d7
parent 74 97232defd20e
equal deleted inserted replaced
78:356f28cd5ca0 86:ed599363c2d7
    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>
       
    35 
    33 
    36 
    34 
    37 // Utility functions 
    35 // Utility functions 
    38 
    36 
    39 // ======== LOCAL FUNCTIONS ======== 
    37 // ======== LOCAL FUNCTIONS ======== 
   139     TRACE_ENTRY_POINT;
   137     TRACE_ENTRY_POINT;
   140 
   138 
   141     delete iSummary;
   139     delete iSummary;
   142     delete iLocation;
   140     delete iLocation;
   143     delete iDescription;
   141     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 
       
   153 
   142 
   154     TRACE_EXIT_POINT;
   143     TRACE_EXIT_POINT;
   155     }
   144     }
   156 		
   145 		
   157 // Getters
   146 // Getters
   701 //
   690 //
   702 void CCalenEntryUtil::ConstructL( CCalEntry& aEntry, 
   691 void CCalenEntryUtil::ConstructL( CCalEntry& aEntry, 
   703                                    const TCalTime& aInstanceDateTime )
   692                                    const TCalTime& aInstanceDateTime )
   704     {
   693     {
   705     TRACE_ENTRY_POINT;
   694     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 
       
   712     iEntryType = aEntry.EntryTypeL();
   695     iEntryType = aEntry.EntryTypeL();
   713     iEntryStatus = aEntry.StatusL();
   696     iEntryStatus = aEntry.StatusL();
   714     CopyDataFromEntryL( aEntry, aInstanceDateTime );
   697     CopyDataFromEntryL( aEntry, aInstanceDateTime );
   715 
   698 
   716     TRACE_EXIT_POINT;
   699     TRACE_EXIT_POINT;
   767 
   750 
   768         case CCalEntry::EAnniv:
   751         case CCalEntry::EAnniv:
   769             {
   752             {
   770             TTime event = aInstanceDateTime.TimeLocalL();
   753             TTime event = aInstanceDateTime.TimeLocalL();
   771             SetEventDateL( event );
   754             SetEventDateL( event );
   772             if ( FeatureManager::FeatureSupported( KFeatureIdKorean ) )
       
   773                 {
       
   774 				SetCalendarTypeL( ( TLunarCalendarType )aEntry.UserInt32L() );
       
   775                 }
       
   776             }
   755             }
   777             break;
   756             break;
   778 
   757 
   779         case CCalEntry::ETodo:
   758         case CCalEntry::ETodo:
   780             {
   759             {
   935         	// editing a RDate instance, the alarmDateTime has to be adjusted.
   914         	// editing a RDate instance, the alarmDateTime has to be adjusted.
   936         	for( TInt index = 0; index < count; index++ )
   915         	for( TInt index = 0; index < count; index++ )
   937         		{
   916         		{
   938         		// If the instance matches one of the RDates
   917         		// If the instance matches one of the RDates
   939         		if( (aInstanceDateTime.TimeLocalL()) == (rdates[ index ].TimeLocalL()) )
   918         		if( (aInstanceDateTime.TimeLocalL()) == (rdates[ index ].TimeLocalL()) )
   940                     {
   919         			{
   941                     // instanceAlarmDay = actualAlarmDay + (alarmOffsetStart - alarmOffsetInstance)
   920         			// instanceAlarmDay = actualAlarmDay + (alarmOffsetStart - alarmOffsetInstance)
   942                     deltaDays =  alarmDateTime.DaysFrom( aEntry.StartTimeL().TimeLocalL() ).Int()
   921         			deltaDays =  alarmDateTime.DaysFrom( aEntry.StartTimeL().TimeLocalL() ).Int()
   943                     - alarmDateTime.DaysFrom( aInstanceDateTime.TimeLocalL() ).Int();
   922 								- alarmDateTime.DaysFrom( aInstanceDateTime.TimeLocalL() ).Int();
   944                     alarmDateTime += deltaDays;
   923         			alarmDateTime += deltaDays;
   945                     if ( FeatureManager::FeatureSupported( KFeatureIdKorean ) )
   924         			break;
   946                         {
   925         			}
   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                     }
       
   959         		}
   926         		}
   960         	}        	
   927         	}        	
   961         SetAlarmOnL( alarmDateTime );
   928         SetAlarmOnL( alarmDateTime );
   962         }
   929         }
   963     else
   930     else
  1071     return rDateList;
  1038     return rDateList;
  1072     
  1039     
  1073     TRACE_EXIT_POINT;
  1040     TRACE_EXIT_POINT;
  1074     }
  1041     }
  1075 
  1042 
  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 
       
  1103 // End of file
  1043 // End of file