496 //<cmail> |
751 //<cmail> |
497 // ---------------------------------------------------------------------------- |
752 // ---------------------------------------------------------------------------- |
498 // ESMRHelper::CreateAndAppendPrivateDirToFileName |
753 // ESMRHelper::CreateAndAppendPrivateDirToFileName |
499 // ---------------------------------------------------------------------------- |
754 // ---------------------------------------------------------------------------- |
500 // |
755 // |
501 EXPORT_C TInt ESMRHelper::CreateAndAppendPrivateDirToFileName(TFileName& aFileName) |
756 EXPORT_C TInt ESMRHelper::CreateAndAppendPrivateDirToFileName( |
502 { |
757 TFileName& aFileName) |
503 TFileName KPath; |
758 { |
|
759 FUNC_LOG; |
|
760 |
|
761 TFileName path; |
504 RFs fsSession; |
762 RFs fsSession; |
505 TInt result = fsSession.Connect(); |
763 TInt result = fsSession.Connect(); |
506 if(result==KErrNone) |
764 if ( KErrNone == result ) |
507 { |
765 { |
508 fsSession.PrivatePath(KPath); |
766 TBool createPrivatePath( ETrue ); |
|
767 |
|
768 fsSession.PrivatePath(path); |
|
769 |
509 TFindFile findFile(fsSession); |
770 TFindFile findFile(fsSession); |
510 |
771 result = findFile.FindByDir(path, KNullDesC); |
511 result = findFile.FindByDir(KPath, KNullDesC); |
772 if (KErrNone == result ) |
512 if (result != KErrNone) //create path if doesn't exists |
773 { |
513 { |
774 // Check that we are able to drive into private path location |
514 fsSession.CreatePrivatePath(TDriveUnit(PathInfo::PhoneMemoryRootPath())); |
775 createPrivatePath = EFalse; |
515 result = findFile.FindByDir(KPath, KNullDesC); |
776 |
516 } |
777 path = findFile.File(); |
517 KPath = findFile.File(); |
778 TInt drive = TDriveUnit( path ); |
518 aFileName.Insert(0,KPath); |
779 TInt KRomDrive = TDriveUnit( PathInfo::RomRootPath() ); |
|
780 |
|
781 if ( drive == KRomDrive ) |
|
782 { |
|
783 // Private path locates in ROM |
|
784 createPrivatePath = ETrue; |
|
785 } |
|
786 } |
|
787 |
|
788 TPtrC phoneMemoryPath( PathInfo::PhoneMemoryRootPath() ); |
|
789 |
|
790 if ( createPrivatePath ) |
|
791 { |
|
792 //create path if doesn't exists |
|
793 TInt drive = TDriveUnit(phoneMemoryPath); |
|
794 fsSession.CreatePrivatePath( drive ); |
|
795 } |
|
796 |
|
797 result = findFile.FindByDir(path, KNullDesC); |
|
798 path = findFile.File(); |
|
799 path[0] = phoneMemoryPath[0]; |
|
800 aFileName.Insert(0,path); |
|
801 |
519 fsSession.MkDirAll(aFileName); |
802 fsSession.MkDirAll(aFileName); |
520 fsSession.Close(); |
803 result = KErrNone; |
521 } |
804 } |
|
805 |
|
806 // fsSession |
|
807 fsSession.Close(); |
522 return result; |
808 return result; |
523 } |
809 } |
524 //</cmail> |
810 //</cmail> |
525 |
811 |
|
812 // ---------------------------------------------------------------------------- |
|
813 // ESMRHelper::CreateAndAppendOthersDirToFileName |
|
814 // ---------------------------------------------------------------------------- |
|
815 // |
|
816 EXPORT_C TInt ESMRHelper::CreateAndAppendOthersDirToFileName( |
|
817 TFileName& aFileName) |
|
818 { |
|
819 FUNC_LOG; |
|
820 |
|
821 TFileName path; |
|
822 RFs fsSession; |
|
823 TInt result = fsSession.Connect(); |
|
824 if ( KErrNone == result ) |
|
825 { |
|
826 aFileName.Insert(0, PathInfo::OthersPath() ); |
|
827 aFileName.Insert(0, PathInfo::PhoneMemoryRootPath() ); |
|
828 |
|
829 fsSession.MkDirAll(aFileName); |
|
830 |
|
831 result = KErrNone; |
|
832 } |
|
833 |
|
834 // fsSession |
|
835 fsSession.Close(); |
|
836 return result; |
|
837 } |
|
838 |
|
839 // ---------------------------------------------------------------------------- |
|
840 // ESMRHelper::CopyEntryAndSwitchTypeL |
|
841 // ---------------------------------------------------------------------------- |
|
842 // |
|
843 CCalEntry* ESMRHelper::CopyEntryAndSwitchTypeL( |
|
844 const CCalEntry& aSourceEntry, |
|
845 TESMRCalendarEventType aTargetType ) |
|
846 { |
|
847 FUNC_LOG; |
|
848 CCalEntry* entry = NULL; |
|
849 |
|
850 TESMRSwitchEventType switchType; |
|
851 |
|
852 switchType = ResolveSwitchType( |
|
853 ESMREntryHelper::EventTypeL( aSourceEntry ), aTargetType ); |
|
854 |
|
855 switch ( switchType ) |
|
856 { |
|
857 case EMRSwitchMRToMeeting: |
|
858 { |
|
859 entry = SwitchToMeetingL( aSourceEntry ); |
|
860 break; |
|
861 } |
|
862 case EMRSwitchMRToMemo: |
|
863 { |
|
864 entry = SwitchToMemoL( aSourceEntry ); |
|
865 break; |
|
866 } |
|
867 case EMRSwitchMRToAnniversary: |
|
868 { |
|
869 entry = SwitchToAnniversaryL( aSourceEntry ); |
|
870 break; |
|
871 } |
|
872 case EMRSwitchMRToTodo: |
|
873 { |
|
874 entry = SwitchToTodoL( aSourceEntry ); |
|
875 break; |
|
876 } |
|
877 case EMRSwitchMeetingToMR: |
|
878 { |
|
879 entry = SwitchToMRL( aSourceEntry ); |
|
880 break; |
|
881 } |
|
882 case EMRSwitchMeetingToMemo: |
|
883 { |
|
884 entry = SwitchToMemoL( aSourceEntry ); |
|
885 break; |
|
886 } |
|
887 case EMRSwitchMeetingToAnniversary: |
|
888 { |
|
889 entry = SwitchToAnniversaryL( aSourceEntry ); |
|
890 break; |
|
891 } |
|
892 case EMRSwitchMeetingToTodo: |
|
893 { |
|
894 entry = SwitchToTodoL( aSourceEntry ); |
|
895 break; |
|
896 } |
|
897 case EMRSwitchMemoToMR: |
|
898 { |
|
899 entry = SwitchToMRL( aSourceEntry ); |
|
900 break; |
|
901 } |
|
902 case EMRSwitchMemoToMeeting: |
|
903 { |
|
904 entry = SwitchToMeetingL( aSourceEntry ); |
|
905 break; |
|
906 } |
|
907 case EMRSwitchMemoToAnniversary: |
|
908 { |
|
909 entry = SwitchToAnniversaryL( aSourceEntry ); |
|
910 break; |
|
911 } |
|
912 case EMRSwitchMemoToTodo: |
|
913 { |
|
914 entry = SwitchToTodoL( aSourceEntry ); |
|
915 break; |
|
916 } |
|
917 case EMRSwitchAnniversaryToMR: |
|
918 { |
|
919 entry = SwitchToMRL( aSourceEntry ); |
|
920 break; |
|
921 } |
|
922 case EMRSwitchAnniversaryToMeeting: |
|
923 { |
|
924 entry = SwitchToMeetingL( aSourceEntry ); |
|
925 break; |
|
926 } |
|
927 case EMRSwitchAnniversaryToMemo: |
|
928 { |
|
929 entry = SwitchToMemoL( aSourceEntry ); |
|
930 break; |
|
931 } |
|
932 case EMRSwitchAnniversaryToTodo: |
|
933 { |
|
934 entry = SwitchToTodoL( aSourceEntry ); |
|
935 break; |
|
936 } |
|
937 case EMRSwitchTodoToMR: |
|
938 { |
|
939 entry = SwitchToMRL( aSourceEntry ); |
|
940 break; |
|
941 } |
|
942 case EMRSwitchTodoToMeeting: |
|
943 { |
|
944 entry = SwitchToMeetingL( aSourceEntry ); |
|
945 break; |
|
946 } |
|
947 case EMRSwitchTodoToMemo: |
|
948 { |
|
949 entry = SwitchToMemoL( aSourceEntry ); |
|
950 break; |
|
951 } |
|
952 case EMRSwitchTodoToAnniversary: |
|
953 { |
|
954 entry = SwitchToAnniversaryL( aSourceEntry ); |
|
955 break; |
|
956 } |
|
957 |
|
958 default: |
|
959 { |
|
960 __ASSERT_DEBUG( EFalse, Panic( EInvalidEntryType ) ); |
|
961 } |
|
962 } |
|
963 |
|
964 return entry; |
|
965 } |
|
966 |
|
967 // ---------------------------------------------------------------------------- |
|
968 // ESMRHelper::ResolveSwitchType |
|
969 // ---------------------------------------------------------------------------- |
|
970 // |
|
971 ESMRHelper::TESMRSwitchEventType ESMRHelper::ResolveSwitchType( |
|
972 TESMRCalendarEventType aSourceType, |
|
973 TESMRCalendarEventType aTargetType ) |
|
974 { |
|
975 FUNC_LOG; |
|
976 |
|
977 TESMRSwitchEventType type( EMRSwitchUnknown ); |
|
978 |
|
979 if( aSourceType == EESMREventTypeMeetingRequest ) // Meeting request |
|
980 { |
|
981 if( aTargetType == EESMREventTypeAppt ) |
|
982 { |
|
983 type = EMRSwitchMRToMeeting; |
|
984 } |
|
985 |
|
986 if( aTargetType == EESMREventTypeEEvent ) |
|
987 { |
|
988 type = EMRSwitchMRToMemo; |
|
989 } |
|
990 |
|
991 if( aTargetType == EESMREventTypeEAnniv ) |
|
992 { |
|
993 type = EMRSwitchMRToAnniversary; |
|
994 } |
|
995 |
|
996 if( aTargetType == EESMREventTypeETodo ) |
|
997 { |
|
998 type = EMRSwitchMRToTodo; |
|
999 } |
|
1000 } |
|
1001 |
|
1002 if( aSourceType == EESMREventTypeAppt ) // Meeting |
|
1003 { |
|
1004 if( aTargetType == EESMREventTypeMeetingRequest ) |
|
1005 { |
|
1006 type = EMRSwitchMeetingToMR; |
|
1007 } |
|
1008 |
|
1009 if( aTargetType == EESMREventTypeEEvent ) |
|
1010 { |
|
1011 type = EMRSwitchMeetingToMemo; |
|
1012 } |
|
1013 |
|
1014 if( aTargetType == EESMREventTypeEAnniv ) |
|
1015 { |
|
1016 type = EMRSwitchMeetingToAnniversary; |
|
1017 } |
|
1018 |
|
1019 if( aTargetType == EESMREventTypeETodo ) |
|
1020 { |
|
1021 type = EMRSwitchMeetingToTodo; |
|
1022 } |
|
1023 } |
|
1024 |
|
1025 if( aSourceType == EESMREventTypeEEvent ) // Memo |
|
1026 { |
|
1027 if( aTargetType == EESMREventTypeMeetingRequest ) |
|
1028 { |
|
1029 type = EMRSwitchMemoToMR; |
|
1030 } |
|
1031 |
|
1032 if( aTargetType == EESMREventTypeAppt ) |
|
1033 { |
|
1034 type = EMRSwitchMemoToMeeting; |
|
1035 } |
|
1036 |
|
1037 if( aTargetType == EESMREventTypeEAnniv ) |
|
1038 { |
|
1039 type = EMRSwitchMemoToAnniversary; |
|
1040 } |
|
1041 |
|
1042 if( aTargetType == EESMREventTypeETodo ) |
|
1043 { |
|
1044 type = EMRSwitchMemoToTodo; |
|
1045 } |
|
1046 } |
|
1047 |
|
1048 if( aSourceType == EESMREventTypeEAnniv ) // Anniversary |
|
1049 { |
|
1050 if( aTargetType == EESMREventTypeMeetingRequest ) |
|
1051 { |
|
1052 type = EMRSwitchAnniversaryToMR; |
|
1053 } |
|
1054 |
|
1055 if( aTargetType == EESMREventTypeAppt ) |
|
1056 { |
|
1057 type = EMRSwitchAnniversaryToMeeting; |
|
1058 } |
|
1059 |
|
1060 if( aTargetType == EESMREventTypeEEvent ) |
|
1061 { |
|
1062 type = EMRSwitchAnniversaryToMemo; |
|
1063 } |
|
1064 |
|
1065 if( aTargetType == EESMREventTypeETodo ) |
|
1066 { |
|
1067 type = EMRSwitchAnniversaryToTodo; |
|
1068 } |
|
1069 } |
|
1070 |
|
1071 if( aSourceType == EESMREventTypeETodo ) // To-do |
|
1072 { |
|
1073 if( aTargetType == EESMREventTypeMeetingRequest ) |
|
1074 { |
|
1075 type = EMRSwitchTodoToMR; |
|
1076 } |
|
1077 |
|
1078 if( aTargetType == EESMREventTypeAppt ) |
|
1079 { |
|
1080 type = EMRSwitchTodoToMeeting; |
|
1081 } |
|
1082 |
|
1083 if( aTargetType == EESMREventTypeEEvent ) |
|
1084 { |
|
1085 type = EMRSwitchTodoToMemo; |
|
1086 } |
|
1087 |
|
1088 if( aTargetType == EESMREventTypeEAnniv ) |
|
1089 { |
|
1090 type = EMRSwitchTodoToAnniversary; |
|
1091 } |
|
1092 } |
|
1093 |
|
1094 __ASSERT_DEBUG( type != EMRSwitchUnknown, Panic( EInvalidSwitchType ) ); |
|
1095 |
|
1096 return type; |
|
1097 } |
|
1098 |
|
1099 // ---------------------------------------------------------------------------- |
|
1100 // ESMRHelper::SwitchToMemoL |
|
1101 // ---------------------------------------------------------------------------- |
|
1102 // |
|
1103 CCalEntry* ESMRHelper::SwitchToMemoL( |
|
1104 const CCalEntry& aSourceEntry ) |
|
1105 { |
|
1106 FUNC_LOG; |
|
1107 CCalEntry* entry = CreateEntryL( |
|
1108 CCalEntry::EEvent, |
|
1109 aSourceEntry.UidL(), |
|
1110 CCalEntry::EMethodNone, |
|
1111 CalCommon::EThisOnly ); |
|
1112 |
|
1113 CleanupStack::PushL( entry ); |
|
1114 |
|
1115 // Copy all data from existing entry to new entry |
|
1116 entry->CopyFromL( aSourceEntry ); |
|
1117 // We must re-set the method to the original value |
|
1118 entry->SetMethodL( CCalEntry::EMethodNone ); |
|
1119 |
|
1120 #ifdef RD_USE_PS2_APIS |
|
1121 // If source entry is a meeting request... |
|
1122 if( CCalenInterimUtils2::IsMeetingRequestL( *entry ) ) |
|
1123 { |
|
1124 // ... we need to clear all MR specific data |
|
1125 entry->ClearMRSpecificDataL(); |
|
1126 } |
|
1127 #endif // RD_USE_PS2_APIS |
|
1128 |
|
1129 // Memo is never a repeating event |
|
1130 entry->ClearRepeatingPropertiesL(); |
|
1131 |
|
1132 // Memo has start and stop date without time value. |
|
1133 // Let's change the entry's start and stop times to memo specific |
|
1134 // Setting start date and stop date |
|
1135 TDateTime start = entry->StartTimeL().TimeLocalL().DateTime(); |
|
1136 start.SetHour( 0 ); |
|
1137 start.SetMinute( 0 ); |
|
1138 start.SetSecond( 0 ); |
|
1139 |
|
1140 TTime tempEnd = entry->EndTimeL().TimeLocalL(); |
|
1141 |
|
1142 if( ESMREntryHelper::IsAllDayEventL( aSourceEntry ) ) |
|
1143 { |
|
1144 // If source is all day event, we need to reduce one from the day, |
|
1145 // otherwise the new memo would be spanned over one day too long |
|
1146 tempEnd -= TTimeIntervalDays( 1 ); |
|
1147 } |
|
1148 |
|
1149 TDateTime end = tempEnd.DateTime(); |
|
1150 end.SetHour( KMaxHoursForMemo ); |
|
1151 end.SetMinute( KMaxMinutesForMemo ); |
|
1152 end.SetSecond( KMaxSecondsForMemo ); |
|
1153 |
|
1154 TCalTime startDate; |
|
1155 startDate.SetTimeLocalFloatingL( start ); |
|
1156 TCalTime stopDate; |
|
1157 stopDate.SetTimeLocalFloatingL( end ); |
|
1158 entry->SetStartAndEndTimeL( startDate, stopDate ); |
|
1159 |
|
1160 // Memo does not have any alarm value |
|
1161 entry->SetAlarmL( NULL ); |
|
1162 |
|
1163 // If source entry is to-do, we need to convert the |
|
1164 // priority from to-do priority to normal priority |
|
1165 if( aSourceEntry.EntryTypeL() == CCalEntry::ETodo ) |
|
1166 { |
|
1167 ConvertTodoPriorityToNormalL( *entry ); |
|
1168 } |
|
1169 |
|
1170 CleanupStack::Pop( entry ); // ownership transferred to caller |
|
1171 return entry; |
|
1172 } |
|
1173 |
|
1174 // ---------------------------------------------------------------------------- |
|
1175 // ESMRHelper::SwitchToAnniversaryL |
|
1176 // ---------------------------------------------------------------------------- |
|
1177 // |
|
1178 CCalEntry* ESMRHelper::SwitchToAnniversaryL( |
|
1179 const CCalEntry& aSourceEntry ) |
|
1180 { |
|
1181 FUNC_LOG; |
|
1182 // Create an entry |
|
1183 CCalEntry* entry = CreateEntryL( |
|
1184 CCalEntry::EAnniv, |
|
1185 aSourceEntry.UidL(), |
|
1186 CCalEntry::EMethodNone, |
|
1187 CalCommon::EThisOnly ); |
|
1188 |
|
1189 CleanupStack::PushL( entry ); |
|
1190 |
|
1191 // Copy all data from existing entry to new entry |
|
1192 entry->CopyFromL( aSourceEntry ); |
|
1193 // We must re-set the method to the original value |
|
1194 entry->SetMethodL( CCalEntry::EMethodNone ); |
|
1195 |
|
1196 #ifdef RD_USE_PS2_APIS |
|
1197 // If source entry is a meeting request... |
|
1198 if( CCalenInterimUtils2::IsMeetingRequestL( *entry ) ) |
|
1199 { |
|
1200 // ... we need to clear all MR specific data |
|
1201 entry->ClearMRSpecificDataL(); |
|
1202 } |
|
1203 #endif // RD_USE_PS2_APIS |
|
1204 |
|
1205 // Anniversary repeats once a year, so |
|
1206 // we clear existing repeating rules... |
|
1207 entry->ClearRepeatingPropertiesL(); |
|
1208 |
|
1209 // ... and create a new rule, to repeat once a year |
|
1210 TCalRRule rrule( TCalRRule::EYearly ); |
|
1211 rrule.SetDtStart( entry->StartTimeL() ); |
|
1212 rrule.SetInterval( 1 ); |
|
1213 rrule.SetCount( 0 ); |
|
1214 entry->SetRRuleL( rrule ); |
|
1215 |
|
1216 // Anniversary default alarm is previous day at noon. |
|
1217 // Let's set that also. |
|
1218 TTime eventTime = entry->StartTimeL().TimeLocalL(); |
|
1219 TTime alarmTime = eventTime - TTimeIntervalDays( 1 ); |
|
1220 TDateTime alarmDateTime = alarmTime.DateTime(); |
|
1221 alarmDateTime.SetHour( KDefaultAnniversaryAlarmHours ); |
|
1222 alarmDateTime.SetMinute( 0 ); |
|
1223 alarmDateTime.SetSecond( 0 ); |
|
1224 alarmDateTime.SetMicroSecond( 0 ); |
|
1225 alarmTime = alarmDateTime; |
|
1226 |
|
1227 // Calculating alarm offset |
|
1228 TTimeIntervalMinutes alarmOffset( 0 ); |
|
1229 eventTime.MinutesFrom( alarmTime, alarmOffset ); |
|
1230 |
|
1231 // Creating alarm |
|
1232 CCalAlarm* alarm = CCalAlarm::NewL(); |
|
1233 CleanupStack::PushL( alarm ); |
|
1234 alarm->SetTimeOffset( alarmOffset ); |
|
1235 |
|
1236 // Setting alarm |
|
1237 entry->SetAlarmL( alarm ); |
|
1238 CleanupStack::PopAndDestroy( alarm ); |
|
1239 alarm = NULL; |
|
1240 |
|
1241 // If source entry is to-do, we need to convert the |
|
1242 // priority from to-do priority to normal priority |
|
1243 if( aSourceEntry.EntryTypeL() == CCalEntry::ETodo ) |
|
1244 { |
|
1245 ConvertTodoPriorityToNormalL( *entry ); |
|
1246 } |
|
1247 |
|
1248 CleanupStack::Pop( entry ); // ownership transferred to caller |
|
1249 return entry; |
|
1250 } |
|
1251 |
|
1252 // ---------------------------------------------------------------------------- |
|
1253 // ESMRHelper::SwitchToTodoL |
|
1254 // ---------------------------------------------------------------------------- |
|
1255 // |
|
1256 CCalEntry* ESMRHelper::SwitchToTodoL( |
|
1257 const CCalEntry& aSourceEntry ) |
|
1258 { |
|
1259 FUNC_LOG; |
|
1260 CCalEntry* entry = CreateEntryL( |
|
1261 CCalEntry::ETodo, |
|
1262 aSourceEntry.UidL(), |
|
1263 CCalEntry::EMethodNone, |
|
1264 CalCommon::EThisOnly ); |
|
1265 |
|
1266 CleanupStack::PushL( entry ); |
|
1267 |
|
1268 // Copy all data from existing entry to new entry |
|
1269 entry->CopyFromL( aSourceEntry ); |
|
1270 // We must re-set the method to the original value |
|
1271 entry->SetMethodL( CCalEntry::EMethodNone ); |
|
1272 |
|
1273 #ifdef RD_USE_PS2_APIS |
|
1274 // If source entry is a meeting request... |
|
1275 if( CCalenInterimUtils2::IsMeetingRequestL( *entry ) ) |
|
1276 { |
|
1277 // ... we need to clear all MR specific data |
|
1278 entry->ClearMRSpecificDataL(); |
|
1279 } |
|
1280 #endif // RD_USE_PS2_APIS |
|
1281 |
|
1282 // To-do is never a repeating event |
|
1283 entry->ClearRepeatingPropertiesL(); |
|
1284 |
|
1285 // To-do has a due date only. Let's change the entry's start and stop |
|
1286 // times to To-do specific ones |
|
1287 TTime tempEnd = entry->EndTimeL().TimeLocalL(); |
|
1288 |
|
1289 if( ESMREntryHelper::IsAllDayEventL( aSourceEntry ) ) |
|
1290 { |
|
1291 // If source is all day event, we need to reduce one from the day, |
|
1292 // otherwise the new todos due date would be one day late |
|
1293 tempEnd -= TTimeIntervalDays( 1 ); |
|
1294 } |
|
1295 |
|
1296 TDateTime tempDue = tempEnd.DateTime(); |
|
1297 |
|
1298 tempDue.SetHour( KMaxHoursForTodo ); |
|
1299 tempDue.SetMinute( KMaxMinutesForTodo ); |
|
1300 tempDue.SetSecond( KMaxSecondsForTodo ); |
|
1301 |
|
1302 TCalTime dueDate; |
|
1303 dueDate.SetTimeLocalFloatingL( tempDue ); |
|
1304 |
|
1305 entry->SetStartAndEndTimeL( dueDate, dueDate ); |
|
1306 |
|
1307 // Setting to-do specific alarm |
|
1308 if( entry->AlarmL() ) |
|
1309 { |
|
1310 // Setting default To-do alarm for entry |
|
1311 TTime eventTime = entry->EndTimeL().TimeLocalL(); |
|
1312 |
|
1313 // Calculate alarm time (due date at 12:00am) |
|
1314 TTime alarmTime = eventTime; |
|
1315 TDateTime alarmDateTime = alarmTime.DateTime(); |
|
1316 alarmDateTime.SetHour( KDefaultTodoAlarmHours ); |
|
1317 alarmDateTime.SetMinute( 0 ); |
|
1318 alarmDateTime.SetSecond( 0 ); |
|
1319 alarmDateTime.SetMicroSecond( 0 ); |
|
1320 alarmTime = alarmDateTime; |
|
1321 |
|
1322 TTime currentTime; |
|
1323 currentTime.HomeTime(); |
|
1324 |
|
1325 // If alarm is in the future |
|
1326 if ( alarmTime > currentTime ) |
|
1327 { |
|
1328 CCalAlarm* alarm = CCalAlarm::NewL(); |
|
1329 CleanupStack::PushL( alarm ); |
|
1330 TTimeIntervalMinutes alarmOffset( 0 ); |
|
1331 eventTime.MinutesFrom( alarmTime, alarmOffset ); |
|
1332 alarm->SetTimeOffset( alarmOffset ); |
|
1333 entry->SetAlarmL( alarm ); |
|
1334 CleanupStack::PopAndDestroy( alarm ); |
|
1335 } |
|
1336 // Alarm is in the past, let's set it to NULL |
|
1337 else |
|
1338 { |
|
1339 entry->SetAlarmL( NULL ); |
|
1340 } |
|
1341 } |
|
1342 |
|
1343 // Setting to-do specific priority |
|
1344 TInt priority( 0 ); |
|
1345 if( entry->PriorityL() == EFSCalenMRPriorityHigh ) |
|
1346 { |
|
1347 priority = EFSCalenTodoPriorityHigh; |
|
1348 } |
|
1349 |
|
1350 else if( entry->PriorityL() == EFSCalenMRPriorityNormal ) |
|
1351 { |
|
1352 priority = EFSCalenTodoPriorityNormal; |
|
1353 } |
|
1354 |
|
1355 else if( entry->PriorityL() == EFSCalenMRPriorityLow ) |
|
1356 { |
|
1357 priority = EFSCalenTodoPriorityLow; |
|
1358 } |
|
1359 |
|
1360 else |
|
1361 { |
|
1362 // Priority unknown, let's set it to normal then |
|
1363 priority = EFSCalenTodoPriorityNormal; |
|
1364 } |
|
1365 |
|
1366 entry->SetPriorityL( priority ); |
|
1367 |
|
1368 CleanupStack::Pop( entry ); // ownership transferred to caller |
|
1369 return entry; |
|
1370 } |
|
1371 |
|
1372 // ---------------------------------------------------------------------------- |
|
1373 // ESMRHelper::SwitchToMeetingL |
|
1374 // ---------------------------------------------------------------------------- |
|
1375 // |
|
1376 CCalEntry* ESMRHelper::SwitchToMeetingL( |
|
1377 const CCalEntry& aSourceEntry ) |
|
1378 { |
|
1379 FUNC_LOG; |
|
1380 |
|
1381 CCalEntry* entry = CreateEntryL( |
|
1382 CCalEntry::EAppt, |
|
1383 aSourceEntry.UidL(), |
|
1384 CCalEntry::EMethodNone, |
|
1385 CalCommon::EThisOnly ); |
|
1386 |
|
1387 CleanupStack::PushL( entry ); |
|
1388 |
|
1389 // Copy all data from existing entry to new entry |
|
1390 entry->CopyFromL( aSourceEntry ); |
|
1391 |
|
1392 // If source was to-do, priority needs converting |
|
1393 if( aSourceEntry.EntryTypeL() == CCalEntry::ETodo ) |
|
1394 { |
|
1395 ConvertTodoPriorityToNormalL( *entry ); |
|
1396 } |
|
1397 |
|
1398 // We must re-set the method to the original value |
|
1399 entry->SetMethodL( CCalEntry::EMethodNone ); |
|
1400 |
|
1401 #ifdef RD_USE_PS2_APIS |
|
1402 // If source entry is a meeting request... |
|
1403 if( CCalenInterimUtils2::IsMeetingRequestL( *entry ) ) |
|
1404 { |
|
1405 // ... we need to clear all MR specific data, |
|
1406 // but otherwise the enrty is now converted |
|
1407 // correctly from MR to meeting |
|
1408 entry->ClearMRSpecificDataL(); |
|
1409 } |
|
1410 else |
|
1411 #endif // RD_USE_PS2_APIS |
|
1412 { |
|
1413 // Repeating rules from memo, to-do and anniversary |
|
1414 // are not compatible with a meeting |
|
1415 entry->ClearRepeatingPropertiesL(); |
|
1416 |
|
1417 // Setting meeting time, since memo, to-do and anniversary |
|
1418 // start / end times are not compatible with meeting's corresponding |
|
1419 // values |
|
1420 SetMeetingTimeL( *entry, aSourceEntry ); |
|
1421 |
|
1422 // If source is not an appointment, we'll set default |
|
1423 // alarm for meeting, since memo, to-do and anniversary |
|
1424 // alarms are not compatible with meeting alarm |
|
1425 if( entry->AlarmL() && |
|
1426 aSourceEntry.EntryTypeL() != CCalEntry::EAppt ) |
|
1427 { |
|
1428 SetDefaultAlarmForMeetingL( *entry ); |
|
1429 } |
|
1430 |
|
1431 // If source entry is to-do, we need to convert the |
|
1432 // priority from to-do priority to normal priority |
|
1433 if( aSourceEntry.EntryTypeL() == CCalEntry::ETodo ) |
|
1434 { |
|
1435 ConvertTodoPriorityToNormalL( *entry ); |
|
1436 } |
|
1437 } |
|
1438 |
|
1439 CleanupStack::Pop( entry ); // ownership transferred to caller |
|
1440 return entry; |
|
1441 } |
|
1442 |
|
1443 // ---------------------------------------------------------------------------- |
|
1444 // ESMRHelper::SwitchToMRL |
|
1445 // ---------------------------------------------------------------------------- |
|
1446 // |
|
1447 CCalEntry* ESMRHelper::SwitchToMRL( |
|
1448 const CCalEntry& aSourceEntry ) |
|
1449 { |
|
1450 FUNC_LOG; |
|
1451 CCalEntry* entry = CreateEntryL( |
|
1452 CCalEntry::EAppt, |
|
1453 aSourceEntry.UidL(), |
|
1454 CCalEntry::EMethodRequest, |
|
1455 CalCommon::EThisOnly ); |
|
1456 |
|
1457 CleanupStack::PushL( entry ); |
|
1458 |
|
1459 // Copy all data from existing entry to new entry |
|
1460 entry->CopyFromL( aSourceEntry ); |
|
1461 |
|
1462 // If source was to-do, priority needs converting |
|
1463 if( aSourceEntry.EntryTypeL() == CCalEntry::ETodo ) |
|
1464 { |
|
1465 ConvertTodoPriorityToNormalL( *entry ); |
|
1466 } |
|
1467 |
|
1468 // We must re-set the method to the original value |
|
1469 entry->SetMethodL( CCalEntry::EMethodRequest ); |
|
1470 |
|
1471 // If source is a meeting... |
|
1472 if( aSourceEntry.EntryTypeL() != CCalEntry::EAppt ) |
|
1473 { |
|
1474 // Repeating rules from memo, to-do and anniversary |
|
1475 // are not compatible with MR |
|
1476 entry->ClearRepeatingPropertiesL(); |
|
1477 |
|
1478 // Setting meeting time, since memo, to-do and anniversary |
|
1479 // start / end times are not compatible with MR's corresponding |
|
1480 // values |
|
1481 SetMeetingTimeL( *entry, aSourceEntry ); |
|
1482 |
|
1483 // If source is not an appointment, we'll set default |
|
1484 // alarm for MR, since memo, to-do and anniversary |
|
1485 // alarms are not compatible with MR alarm |
|
1486 if( entry->AlarmL() && |
|
1487 aSourceEntry.EntryTypeL() != CCalEntry::EAppt ) |
|
1488 { |
|
1489 SetDefaultAlarmForMeetingL( *entry ); |
|
1490 } |
|
1491 |
|
1492 // If source entry is to-do, we need to convert the |
|
1493 // priority from to-do priority to normal priority |
|
1494 if( aSourceEntry.EntryTypeL() == CCalEntry::ETodo ) |
|
1495 { |
|
1496 ConvertTodoPriorityToNormalL( *entry ); |
|
1497 } |
|
1498 } |
|
1499 |
|
1500 // Add organizer |
|
1501 AddOrganizerL( *entry ); |
|
1502 |
|
1503 // Set organizer as phone owner |
|
1504 entry->SetPhoneOwnerL( entry->OrganizerL() ); |
|
1505 |
|
1506 CleanupStack::Pop( entry ); // ownership transferred to caller |
|
1507 return entry; |
|
1508 } |
|
1509 |
|
1510 // ---------------------------------------------------------------------------- |
|
1511 // ESMRHelper::CreateEntryL |
|
1512 // ---------------------------------------------------------------------------- |
|
1513 // |
|
1514 CCalEntry* ESMRHelper::CreateEntryL( |
|
1515 CCalEntry::TType aType, |
|
1516 const TDesC8& aUid, |
|
1517 CCalEntry::TMethod aMethod, |
|
1518 CalCommon::TRecurrenceRange aRange ) |
|
1519 { |
|
1520 FUNC_LOG; |
|
1521 |
|
1522 HBufC8* guid = aUid.AllocLC(); |
|
1523 CCalEntry* entry = CCalEntry::NewL( aType, guid, aMethod, aRange ); |
|
1524 CleanupStack::Pop( guid ); |
|
1525 |
|
1526 return entry; |
|
1527 } |
|
1528 |
|
1529 // ---------------------------------------------------------------------------- |
|
1530 // ESMRHelper::SetMeetingTimeL |
|
1531 // ---------------------------------------------------------------------------- |
|
1532 // |
|
1533 void ESMRHelper::SetMeetingTimeL( |
|
1534 CCalEntry& aTargetEntry, |
|
1535 const CCalEntry& aSourceEntry ) |
|
1536 { |
|
1537 FUNC_LOG; |
|
1538 TCalTime start; |
|
1539 TCalTime end; |
|
1540 |
|
1541 TDateTime tempStart; |
|
1542 TDateTime tempEnd; |
|
1543 |
|
1544 CCalEntry::TType type = aSourceEntry.EntryTypeL(); |
|
1545 |
|
1546 switch ( type ) |
|
1547 { |
|
1548 case CCalEntry::EAppt: |
|
1549 { |
|
1550 start.SetTimeLocalL( aSourceEntry.StartTimeL().TimeLocalL() ); |
|
1551 end.SetTimeLocalL( aSourceEntry.EndTimeL().TimeLocalL() ); |
|
1552 break; |
|
1553 } |
|
1554 case CCalEntry::ETodo: |
|
1555 { |
|
1556 // Todo has only due date => Adding date from that, |
|
1557 // Hour, minute and second as default values |
|
1558 tempStart = aSourceEntry.StartTimeL().TimeLocalL().DateTime(); |
|
1559 tempStart.SetHour( KDefaultMeetingStartHour ); |
|
1560 tempStart.SetMinute( 0 ); |
|
1561 tempStart.SetSecond( 0 ); |
|
1562 |
|
1563 tempEnd = aSourceEntry.StartTimeL().TimeLocalL().DateTime(); |
|
1564 tempEnd.SetHour( KDefaultMeetingEndHour ); |
|
1565 tempEnd.SetMinute( 0 ); |
|
1566 tempEnd.SetSecond( 0 ); |
|
1567 |
|
1568 start.SetTimeLocalL( tempStart ); |
|
1569 end.SetTimeLocalL( tempEnd ); |
|
1570 break; |
|
1571 } |
|
1572 case CCalEntry::EEvent: //Memo |
|
1573 { |
|
1574 // Memo is one day event with start time as 00:00 and end as 23:59 |
|
1575 // Let's add start date from that, and set hour, minute and second |
|
1576 // as default values |
|
1577 tempStart = aSourceEntry.StartTimeL().TimeLocalL().DateTime(); |
|
1578 tempStart.SetHour( KDefaultMeetingStartHour ); |
|
1579 tempStart.SetMinute( 0 ); |
|
1580 tempStart.SetSecond( 0 ); |
|
1581 |
|
1582 tempEnd = aSourceEntry.StartTimeL().TimeLocalL().DateTime(); |
|
1583 tempEnd.SetHour( KDefaultMeetingEndHour ); |
|
1584 tempEnd.SetMinute( 0 ); |
|
1585 tempEnd.SetSecond( 0 ); |
|
1586 |
|
1587 start.SetTimeLocalL( tempStart ); |
|
1588 end.SetTimeLocalL( tempEnd ); |
|
1589 |
|
1590 break; |
|
1591 } |
|
1592 case CCalEntry::EAnniv: |
|
1593 { |
|
1594 // Anniversary has start date, which is taken as date of the meeting. |
|
1595 // Hour, minute and second are set as teh default values. |
|
1596 tempStart = aSourceEntry.StartTimeL().TimeLocalL().DateTime(); |
|
1597 tempStart.SetHour( KDefaultMeetingStartHour ); |
|
1598 tempStart.SetMinute( 0 ); |
|
1599 tempStart.SetSecond( 0 ); |
|
1600 |
|
1601 tempEnd = aSourceEntry.StartTimeL().TimeLocalL().DateTime(); |
|
1602 tempEnd.SetHour( KDefaultMeetingEndHour ); |
|
1603 tempEnd.SetMinute( 0 ); |
|
1604 tempEnd.SetSecond( 0 ); |
|
1605 |
|
1606 start.SetTimeLocalL( tempStart ); |
|
1607 end.SetTimeLocalL( tempEnd ); |
|
1608 break; |
|
1609 } |
|
1610 |
|
1611 default: |
|
1612 { |
|
1613 __ASSERT_DEBUG( EFalse, Panic( EInvalidEntryType ) ); |
|
1614 } |
|
1615 } |
|
1616 |
|
1617 aTargetEntry.SetStartAndEndTimeL( start, end ); |
|
1618 } |
|
1619 |
|
1620 // ---------------------------------------------------------------------------- |
|
1621 // ESMRHelper::SetDefaultAlarmForMetingL |
|
1622 // ---------------------------------------------------------------------------- |
|
1623 // |
|
1624 void ESMRHelper::SetDefaultAlarmForMeetingL( |
|
1625 CCalEntry& aTargetEntry ) |
|
1626 { |
|
1627 FUNC_LOG; |
|
1628 |
|
1629 // Get default alarm time from central repository |
|
1630 TInt defaultAlarmTime; |
|
1631 CRepository* repository = CRepository::NewLC( KCRUidCalendar ); |
|
1632 TInt err = repository->Get( KCalendarDefaultAlarmTime, defaultAlarmTime ); |
|
1633 CleanupStack::PopAndDestroy( repository ); |
|
1634 |
|
1635 if ( err != KErrNone ) |
|
1636 { |
|
1637 defaultAlarmTime = KDefaultMeetingAlarmMinutes; |
|
1638 } |
|
1639 |
|
1640 // Getting current time |
|
1641 TTime currentTime; |
|
1642 currentTime.HomeTime(); |
|
1643 |
|
1644 // Getting meeting start time |
|
1645 TTime start = aTargetEntry.StartTimeL().TimeLocalL(); |
|
1646 |
|
1647 // Create default alarm |
|
1648 CCalAlarm* alarm = CCalAlarm::NewL(); |
|
1649 CleanupStack::PushL( alarm ); |
|
1650 |
|
1651 TTimeIntervalMinutes alarmOffset( defaultAlarmTime ); |
|
1652 |
|
1653 // If alarm time is in past |
|
1654 if ( ( start - alarmOffset ) < currentTime ) |
|
1655 { |
|
1656 // Setting alarm off |
|
1657 aTargetEntry.SetAlarmL( NULL ); |
|
1658 } |
|
1659 else |
|
1660 { |
|
1661 // Set default alarm time |
|
1662 alarm->SetTimeOffset( alarmOffset ); |
|
1663 aTargetEntry.SetAlarmL( alarm ); |
|
1664 } |
|
1665 CleanupStack::PopAndDestroy( alarm ); |
|
1666 |
|
1667 } |
|
1668 |
|
1669 // --------------------------------------------------------------------------- |
|
1670 // ESMRHelper::AddOrganizerL |
|
1671 // --------------------------------------------------------------------------- |
|
1672 // |
|
1673 void ESMRHelper::AddOrganizerL( CCalEntry& aTargetEntry ) |
|
1674 { |
|
1675 FUNC_LOG; |
|
1676 CMRMailboxUtils* mbUtils = CMRMailboxUtils::NewL( NULL ); |
|
1677 CleanupStack::PushL( mbUtils ); |
|
1678 |
|
1679 CMRMailboxUtils::TMailboxInfo defaultMailBox; |
|
1680 TInt err = mbUtils->GetDefaultMRMailBoxL( defaultMailBox ); |
|
1681 |
|
1682 if ( KErrNone != err ) |
|
1683 { |
|
1684 RArray<CMRMailboxUtils::TMailboxInfo> mailBoxes; |
|
1685 CleanupClosePushL( mailBoxes ); |
|
1686 |
|
1687 SupportedMailboxesL( *mbUtils, mailBoxes ); |
|
1688 |
|
1689 TInt selectedMailbox( PromptForDefaultMailboxL(mailBoxes) ); |
|
1690 |
|
1691 if ( KErrCancel != selectedMailbox ) |
|
1692 { |
|
1693 mbUtils->SetDefaultMRMailBoxL( |
|
1694 mailBoxes[selectedMailbox].iEntryId ); // codescanner::accessArrayElementWithoutCheck2 |
|
1695 mbUtils->GetDefaultMRMailBoxL(defaultMailBox); |
|
1696 } |
|
1697 CleanupStack::PopAndDestroy( &mailBoxes ); |
|
1698 |
|
1699 // This will leave if user cancelled the mailbox selection |
|
1700 User::LeaveIfError( selectedMailbox ); |
|
1701 } |
|
1702 |
|
1703 //Set the organizer from the selected mailbox |
|
1704 CCalUser* organizer = CCalUser::NewL( defaultMailBox.iEmailAddress ); |
|
1705 CleanupStack::PushL( organizer ); |
|
1706 aTargetEntry.SetOrganizerL( organizer ); |
|
1707 CleanupStack::Pop( organizer ); // Ownership trasferred |
|
1708 |
|
1709 CleanupStack::PopAndDestroy( mbUtils ); |
|
1710 } |
|
1711 |
526 // EOF |
1712 // EOF |
|
1713 |