132 } |
134 } |
133 |
135 |
134 void AgendaUtilPrivate::Completed(TInt aError) |
136 void AgendaUtilPrivate::Completed(TInt aError) |
135 { |
137 { |
136 iError = aError; |
138 iError = aError; |
|
139 static bool isInstanceViewDeleted = false; |
|
140 static bool isEntryViewDeleted = false; |
137 |
141 |
138 if (mIsDeleting) { |
142 if (mIsDeleting) { |
139 // If deletion was in progress, then it is completed now |
143 // If deletion was in progress, then it is completed now |
140 // emit the signal to the clients. |
144 // emit the signal to the clients. |
141 mIsDeleting = false; |
145 mIsDeleting = false; |
142 emit q->entriesDeleted(iError); |
146 emit q->entriesDeleted(iError); |
143 } |
147 } |
144 |
148 |
145 if (KErrNone != iError) { |
149 if (KErrNone != iError) { |
146 // Something has gone wrong, return |
150 // Something has gone wrong, return |
147 if (iCalEntryView) { |
151 if (iCalEntryView && !isEntryViewDeleted) { |
|
152 isEntryViewDeleted = true; |
148 delete iCalEntryView; |
153 delete iCalEntryView; |
149 iCalEntryView = NULL; |
154 iCalEntryView = NULL; |
150 } |
155 } |
151 if (iCalInstanceView) { |
156 if (iCalInstanceView && !isInstanceViewDeleted) { |
|
157 isInstanceViewDeleted = true; |
152 delete iCalInstanceView; |
158 delete iCalInstanceView; |
153 iCalInstanceView = NULL; |
159 iCalInstanceView = NULL; |
154 } |
160 } |
155 return; |
161 return; |
156 } |
162 } |
204 if (AgendaEntry::TypeNote == entry.type()) { |
210 if (AgendaEntry::TypeNote == entry.type()) { |
205 TRAP( |
211 TRAP( |
206 iError, |
212 iError, |
207 |
213 |
208 RPointerArray<CCalEntry> entryArray; |
214 RPointerArray<CCalEntry> entryArray; |
209 CleanupClosePushL(entryArray); |
215 CleanupResetAndDestroyPushL(entryArray); |
210 |
216 |
211 // Get the global uid. |
217 // Get the global uid. |
212 TTime homeTime; |
218 CCalenInterimUtils2* calenInterimUtils2 = CCalenInterimUtils2::NewL(); |
213 homeTime.HomeTime(); |
219 HBufC8* globalUid = calenInterimUtils2->GlobalUidL(); |
214 TInt64 seed = homeTime.Int64(); |
220 CleanupStack::PushL(globalUid); |
215 TInt randumNumber = Math::Rand(seed); |
221 delete calenInterimUtils2; |
216 HBufC8* globalUid = HBufC8::NewLC(KGuidLength); |
|
217 globalUid->Des().Num(randumNumber); |
|
218 |
222 |
219 // Construct a CCalEntry object and start filling the details. |
223 // Construct a CCalEntry object and start filling the details. |
220 CCalEntry* newEntry = 0; |
224 CCalEntry* newEntry = 0; |
221 newEntry = CCalEntry::NewL( |
225 newEntry = CCalEntry::NewL( |
222 static_cast<CCalEntry::TType>(entry.type()), |
226 static_cast<CCalEntry::TType>(entry.type()), |
223 globalUid, |
227 globalUid, |
224 static_cast<CCalEntry::TMethod>(entry.method()), |
228 static_cast<CCalEntry::TMethod>(entry.method()), |
225 0); |
229 0); |
226 |
230 |
227 CleanupStack::Pop(globalUid); |
231 CleanupStack::Pop(globalUid); |
228 CleanupStack::PushL(newEntry); |
|
229 |
232 |
230 // Add description. |
233 // Add description. |
231 TPtrC description(reinterpret_cast<const TUint16*>( |
234 TPtrC description(reinterpret_cast<const TUint16*>( |
232 entry.description().utf16())); |
235 entry.description().utf16())); |
233 newEntry->SetDescriptionL(description); |
236 newEntry->SetDescriptionL(description); |
456 if (AgendaEntry::TypeNote == type) { |
456 if (AgendaEntry::TypeNote == type) { |
457 TRAP( |
457 TRAP( |
458 iError, |
458 iError, |
459 |
459 |
460 RPointerArray<CCalEntry> entryArray; |
460 RPointerArray<CCalEntry> entryArray; |
461 CleanupClosePushL(entryArray); |
461 CleanupResetAndDestroyPushL(entryArray); |
462 |
462 |
463 // Construct a CCalEntry object and start filling the details. |
463 // Construct a CCalEntry object and start filling the details. |
464 CCalEntry* newEntry = 0; |
464 CCalEntry* newEntry = 0; |
465 newEntry = CCalEntry::NewL( |
465 newEntry = CCalEntry::NewL( |
466 static_cast<CCalEntry::TType>(type), |
466 static_cast<CCalEntry::TType>(type), |
467 globalUid, |
467 globalUid, |
468 static_cast<CCalEntry::TMethod>(entry.method()), |
468 static_cast<CCalEntry::TMethod>(entry.method()), |
469 0); |
469 0); |
470 CleanupStack::PushL(newEntry); |
|
471 |
470 |
472 // Add description. |
471 // Add description. |
473 TPtrC description(reinterpret_cast<const TUint16*>( |
472 TPtrC description(reinterpret_cast<const TUint16*>( |
474 entry.description().utf16())); |
473 entry.description().utf16())); |
475 newEntry->SetDescriptionL(description); |
474 newEntry->SetDescriptionL(description); |
481 entryArray.AppendL(newEntry); |
480 entryArray.AppendL(newEntry); |
482 iCalEntryView->StoreL(entryArray, success); |
481 iCalEntryView->StoreL(entryArray, success); |
483 localUid = newEntry->LocalUidL(); |
482 localUid = newEntry->LocalUidL(); |
484 |
483 |
485 // Cleanup. |
484 // Cleanup. |
486 CleanupStack::PopAndDestroy(newEntry); |
|
487 CleanupStack::PopAndDestroy(&entryArray); |
485 CleanupStack::PopAndDestroy(&entryArray); |
488 ) |
486 ) |
489 } else { |
487 } else { |
490 TRAP( |
488 TRAP( |
491 iError, |
489 iError, |
492 |
490 |
493 RPointerArray<CCalEntry> entryArray; |
491 RPointerArray<CCalEntry> entryArray; |
494 CleanupClosePushL(entryArray); |
492 CleanupResetAndDestroyPushL(entryArray); |
495 |
493 |
496 // Construct a CCalEntry object and start filling the details. |
494 // Construct a CCalEntry object and start filling the details. |
497 CCalEntry* newEntry = 0; |
495 CCalEntry* newEntry = 0; |
498 newEntry = CCalEntry::NewL( |
496 newEntry = CCalEntry::NewL( |
499 static_cast<CCalEntry::TType>(type), |
497 static_cast<CCalEntry::TType>(type), |
500 globalUid, |
498 globalUid, |
501 static_cast<CCalEntry::TMethod>(entry.method()), |
499 static_cast<CCalEntry::TMethod>(entry.method()), |
502 0); |
500 0); |
503 CleanupStack::PushL(newEntry); |
|
504 |
501 |
505 // Add the summary. |
502 // Add the summary. |
506 if (!entry.summary().isNull()) { |
503 if (!entry.summary().isNull()) { |
507 TPtrC summary(reinterpret_cast<const TUint16*>( |
504 TPtrC summary(reinterpret_cast<const TUint16*>( |
508 entry.summary().utf16())); |
505 entry.summary().utf16())); |
682 |
678 |
683 // Fetch the entries based on the global uid of the entry, as |
679 // Fetch the entries based on the global uid of the entry, as |
684 // the exceptional entries share the global uid with the parent |
680 // the exceptional entries share the global uid with the parent |
685 // entry. |
681 // entry. |
686 RPointerArray<CCalEntry> entries; |
682 RPointerArray<CCalEntry> entries; |
687 CleanupClosePushL(entries); |
683 CleanupResetAndDestroyPushL(entries); |
688 iCalEntryView->FetchL(calEntry->UidL(), entries); |
684 iCalEntryView->FetchL(calEntry->UidL(), entries); |
689 if (entries.Count()) { |
685 if (entries.Count()) { |
690 iCalEntryView->DeleteL(*entries[0]); |
686 iCalEntryView->DeleteL(*entries[0]); |
691 } |
687 } |
692 |
688 |
693 // Cleanup. |
|
694 int count = entries.Count(); |
|
695 for (int i = count - 1; i >= 0; --i) { |
|
696 CCalEntry *entry = entries[i]; |
|
697 delete entry; |
|
698 } |
|
699 CleanupStack::PopAndDestroy(&entries); |
689 CleanupStack::PopAndDestroy(&entries); |
700 CleanupStack::PopAndDestroy(); |
690 CleanupStack::PopAndDestroy(); |
701 } |
691 } |
702 ) |
692 ) |
703 |
693 |
785 calEntry->SetFavouriteL(entry.favourite()); |
774 calEntry->SetFavouriteL(entry.favourite()); |
786 } |
775 } |
787 |
776 |
788 // Update the entry using the CCalEntryView. |
777 // Update the entry using the CCalEntryView. |
789 RPointerArray<CCalEntry> entryArray; |
778 RPointerArray<CCalEntry> entryArray; |
790 CleanupClosePushL(entryArray); |
779 CleanupResetAndDestroyPushL(entryArray); |
791 entryArray.AppendL(calEntry); |
780 entryArray.AppendL(calEntry); |
792 iCalEntryView->UpdateL(entryArray, success); |
781 iCalEntryView->UpdateL(entryArray, success); |
793 |
782 |
794 // Cleanup. |
783 // Cleanup. |
795 CleanupStack::PopAndDestroy(2, calEntry); |
784 CleanupStack::PopAndDestroy( &entryArray ); |
796 ) |
785 ) |
797 } else { |
786 } else { |
798 TRAP( |
787 TRAP( |
799 iError, |
788 iError, |
800 |
789 |
801 // Get the entry corresponding to the id. |
790 // Get the entry corresponding to the id. |
802 AgendaEntry storedEntry = fetchById(entry.id()); |
791 AgendaEntry storedEntry = fetchById(entry.id()); |
803 CCalEntry* calEntry = iCalEntryView->FetchL(entry.id()); |
792 CCalEntry* calEntry = iCalEntryView->FetchL(entry.id()); |
804 CleanupStack::PushL(calEntry); |
|
805 |
793 |
806 // Update the attendees. |
794 // Update the attendees. |
807 if (!entry.isNull() |
795 if (!entry.isNull() |
808 && (entry.d->m_attendees != storedEntry.attendees())) { |
796 && (entry.d->m_attendees != storedEntry.attendees())) { |
809 |
797 |
810 RPointerArray<CCalAttendee> attendeesArray = |
798 RPointerArray<CCalAttendee>& attendeesArray = |
811 calEntry->AttendeesL(); |
799 calEntry->AttendeesL(); |
812 CleanupClosePushL(attendeesArray); |
|
813 int iterator = 0; |
800 int iterator = 0; |
814 while (attendeesArray.Count() > iterator) { |
801 while (attendeesArray.Count() > iterator) { |
815 calEntry->DeleteAttendeeL(iterator); |
802 calEntry->DeleteAttendeeL(iterator); |
816 iterator++; |
803 iterator++; |
817 } |
804 } |
818 // Cleanup. |
|
819 CleanupStack::PopAndDestroy(&attendeesArray); |
|
820 |
805 |
821 addAttendeesToEntry(entry.d->m_attendees, *calEntry); |
806 addAttendeesToEntry(entry.d->m_attendees, *calEntry); |
822 } |
807 } |
823 |
808 |
824 // Update the categories. |
809 // Update the categories. |
825 if (entry.d->m_categories != storedEntry.categories()) { |
810 if (entry.d->m_categories != storedEntry.categories()) { |
826 |
811 |
827 RPointerArray<CCalCategory> categories = |
812 RPointerArray<CCalCategory> categories = |
828 calEntry->CategoryListL(); |
813 calEntry->CategoryListL(); |
829 CleanupClosePushL(categories); |
|
830 int iterator = 0; |
814 int iterator = 0; |
831 while (categories.Count() > iterator) { |
815 while (categories.Count() > iterator) { |
832 calEntry->DeleteCategoryL(iterator); |
816 calEntry->DeleteCategoryL(iterator); |
833 iterator++; |
817 iterator++; |
834 } |
818 } |
835 // Cleanup. |
|
836 CleanupStack::PopAndDestroy(&categories); |
|
837 |
819 |
838 addCategoriesToEntry(entry.d->m_categories, *calEntry); |
820 addCategoriesToEntry(entry.d->m_categories, *calEntry); |
839 } |
821 } |
840 |
822 |
841 // Update the alarm. |
823 // Update the alarm. |
952 geoValue->SetLatLongL(latitude, longitude); |
934 geoValue->SetLatLongL(latitude, longitude); |
953 |
935 |
954 // set it to CCalentry |
936 // set it to CCalentry |
955 calEntry->SetGeoValueL(*geoValue); |
937 calEntry->SetGeoValueL(*geoValue); |
956 delete geoValue; |
938 delete geoValue; |
|
939 } else if (entryGeoValue.isNull()) { |
|
940 // Clear the geo values if any |
|
941 calEntry->ClearGeoValueL(); |
957 } |
942 } |
958 |
943 |
959 // Update the entry using the calen entry view. |
944 // Update the entry using the calen entry view. |
960 RPointerArray<CCalEntry> entryArray; |
945 RPointerArray<CCalEntry> entryArray; |
961 CleanupClosePushL(entryArray); |
946 CleanupResetAndDestroyPushL(entryArray); |
962 entryArray.AppendL(calEntry); |
947 entryArray.AppendL(calEntry); |
963 if (!isChild) { |
948 if (!isChild) { |
964 iCalEntryView->UpdateL(entryArray, success); |
949 iCalEntryView->UpdateL(entryArray, success); |
965 } else { |
950 } else { |
966 iCalEntryView->StoreL(entryArray, success); |
951 iCalEntryView->StoreL(entryArray, success); |
967 } |
952 } |
968 // Cleanup. |
953 // Cleanup. |
969 CleanupStack::PopAndDestroy(2, calEntry); |
954 CleanupStack::PopAndDestroy( &entryArray ); |
970 ) |
955 ) |
971 } |
956 } |
972 |
957 |
973 // Emit the signal to notify the clients. |
958 // Emit the signal to notify the clients. |
974 if (0 < success) { |
959 if (0 < success) { |
1172 CleanupStack::PushL(calEntry); |
1161 CleanupStack::PushL(calEntry); |
1173 // We are creating an exception, hence get the global Uid |
1162 // We are creating an exception, hence get the global Uid |
1174 HBufC8* guid = calEntry->UidL().AllocLC(); |
1163 HBufC8* guid = calEntry->UidL().AllocLC(); |
1175 // create new (child) entry |
1164 // create new (child) entry |
1176 // Use original instance time for recurrenceID as this entry hasn't got one. |
1165 // Use original instance time for recurrenceID as this entry hasn't got one. |
1177 TCalTime originalCalTime = calEntry->StartTimeL(); |
1166 TCalTime originalCalTime; |
|
1167 TDateTime originalDateTime(instanceOriginalDateTime.date().year(), |
|
1168 TMonth(instanceOriginalDateTime.date().month() - 1), |
|
1169 instanceOriginalDateTime.date().day() -1, 0, 0, 0, 0); |
|
1170 TTime originalDateTimeTTime(originalDateTime); |
|
1171 originalCalTime.SetTimeLocalL(originalDateTimeTTime); |
1178 // create the new child now |
1172 // create the new child now |
1179 CCalEntry* newEntry = CCalEntry::NewL( calEntry->EntryTypeL(), |
1173 CCalEntry* newEntry = CCalEntry::NewL( calEntry->EntryTypeL(), |
1180 guid, |
1174 guid, |
1181 calEntry->MethodL(), |
1175 calEntry->MethodL(), |
1182 calEntry->SequenceNumberL(), |
1176 calEntry->SequenceNumberL(), |
1183 originalCalTime, |
1177 originalCalTime, |
1184 CalCommon::EThisOnly ); |
1178 CalCommon::EThisOnly ); |
1185 |
1179 |
1186 CleanupStack::Pop(guid); |
1180 CleanupStack::Pop(guid); |
1187 CleanupStack::PopAndDestroy(calEntry); |
1181 CleanupStack::PopAndDestroy(calEntry); |
1188 CleanupStack::PushL(newEntry); |
|
1189 |
1182 |
1190 // Update the description. |
1183 // Update the description. |
1191 if (!entry.description().isNull()) { |
1184 if (!entry.description().isNull()) { |
1192 newEntry->SetDescriptionL( |
1185 newEntry->SetDescriptionL( |
1193 TPtrC(reinterpret_cast<const TUint16 *> ( |
1186 TPtrC(reinterpret_cast<const TUint16 *> ( |
1238 CleanupStack::PushL(calEntry); |
1231 CleanupStack::PushL(calEntry); |
1239 // We are creating an exception, hence get the global Uid |
1232 // We are creating an exception, hence get the global Uid |
1240 HBufC8* guid = calEntry->UidL().AllocLC(); |
1233 HBufC8* guid = calEntry->UidL().AllocLC(); |
1241 // create new (child) entry |
1234 // create new (child) entry |
1242 // Use original instance time for recurrenceID as this entry hasn't got one. |
1235 // Use original instance time for recurrenceID as this entry hasn't got one. |
1243 TCalTime originalCalTime = calEntry->StartTimeL(); |
1236 TCalTime originalCalTime; |
|
1237 TDateTime originalDateTime(instanceOriginalDateTime.date().year(), |
|
1238 TMonth(instanceOriginalDateTime.date().month() - 1), |
|
1239 instanceOriginalDateTime.date().day() -1, 0, 0, 0, 0); |
|
1240 TTime originalDateTimeTTime(originalDateTime); |
|
1241 originalCalTime.SetTimeLocalL(originalDateTimeTTime); |
1244 // create the new child now |
1242 // create the new child now |
1245 CCalEntry* newEntry = CCalEntry::NewL( calEntry->EntryTypeL(), |
1243 CCalEntry* newEntry = CCalEntry::NewL( calEntry->EntryTypeL(), |
1246 guid, |
1244 guid, |
1247 calEntry->MethodL(), |
1245 calEntry->MethodL(), |
1248 calEntry->SequenceNumberL(), |
1246 calEntry->SequenceNumberL(), |
1249 originalCalTime, |
1247 originalCalTime, |
1250 CalCommon::EThisOnly ); |
1248 CalCommon::EThisOnly ); |
1251 |
1249 |
1252 CleanupStack::Pop(guid); |
1250 CleanupStack::Pop(guid); |
1253 CleanupStack::PopAndDestroy(calEntry); |
1251 CleanupStack::PopAndDestroy(calEntry); |
1254 CleanupStack::PushL(newEntry); |
|
1255 // Store the attendees. |
1252 // Store the attendees. |
1256 if (!entry.isNull()) { |
1253 if (!entry.isNull()) { |
1257 addAttendeesToEntry(entry.d->m_attendees, *newEntry); |
1254 addAttendeesToEntry(entry.d->m_attendees, *newEntry); |
1258 addCategoriesToEntry(entry.d->m_categories, *newEntry); |
1255 addCategoriesToEntry(entry.d->m_categories, *newEntry); |
1259 } |
1256 } |
1357 |
1354 |
1358 // clear repeat rule properties |
1355 // clear repeat rule properties |
1359 newEntry->ClearRepeatingPropertiesL(); |
1356 newEntry->ClearRepeatingPropertiesL(); |
1360 // Update the entry using the calen entry view. |
1357 // Update the entry using the calen entry view. |
1361 RPointerArray<CCalEntry> entryArray; |
1358 RPointerArray<CCalEntry> entryArray; |
1362 CleanupClosePushL(entryArray); |
1359 CleanupResetAndDestroyPushL(entryArray); |
1363 entryArray.AppendL(newEntry); |
1360 entryArray.AppendL(newEntry); |
1364 iCalEntryView->StoreL(entryArray, success); |
1361 iCalEntryView->StoreL(entryArray, success); |
1365 |
1362 |
1366 localUid = newEntry->LocalUidL(); |
1363 localUid = newEntry->LocalUidL(); |
1367 // Cleanup. |
1364 // Cleanup. |
1368 CleanupStack::PopAndDestroy(&entryArray); |
1365 CleanupStack::PopAndDestroy(&entryArray); |
1369 CleanupStack::PopAndDestroy(newEntry); |
|
1370 ) |
1366 ) |
1371 } |
1367 } |
1372 |
1368 |
1373 // Emit the signal to notify the clients. |
1369 // Emit the signal to notify the clients. |
1374 if (0 < success) { |
1370 if (0 < success) { |
1632 CalCommon::TCalTimeRange searchTimeRange( |
1611 CalCommon::TCalTimeRange searchTimeRange( |
1633 startDateForInstanceSearch, |
1612 startDateForInstanceSearch, |
1634 endDateForInstanceSearch); |
1613 endDateForInstanceSearch); |
1635 |
1614 |
1636 iCalInstanceView->FindInstanceL(instanceList, filters, searchTimeRange); |
1615 iCalInstanceView->FindInstanceL(instanceList, filters, searchTimeRange); |
1637 |
1616 |
1638 // Parse thru the list and mark the dates which have events |
1617 // Parse thru the list and mark the dates which have events |
1639 for (int i = 0; i < instanceList.Count(); i++) { |
1618 for (int i = 0; i < instanceList.Count(); i++) { |
1640 CCalEntry::TType type = instanceList[i]->Entry().EntryTypeL(); |
1619 CCalEntry::TType type = instanceList[i]->Entry().EntryTypeL(); |
1641 // Get the start time and end time of the events |
1620 // Get the start time and end time of the events |
1642 TCalTime startCalTime = instanceList[i]->StartTimeL(); |
1621 TCalTime startCalTime = instanceList[i]->StartTimeL(); |
1643 TCalTime endCalTime = instanceList[i]->EndTimeL(); |
1622 TCalTime endCalTime = instanceList[i]->EndTimeL(); |
1644 TDateTime startDateTime = startCalTime.TimeLocalL().DateTime(); |
1623 TDateTime startDateTime = startCalTime.TimeLocalL().DateTime(); |
1645 TDateTime endDateTime = endCalTime.TimeLocalL().DateTime(); |
1624 TDateTime endDateTime = endCalTime.TimeLocalL().DateTime(); |
1646 QDate startDate(startDateTime.Year(), startDateTime.Month()+1, |
1625 QDate startDate(startDateTime.Year(), startDateTime.Month()+1, |
1647 startDateTime.Day() + 1); |
1626 startDateTime.Day() + 1); |
1648 QDate endDate(endDateTime.Year(), endDateTime.Month()+1, |
1627 QDate endDate(endDateTime.Year(), endDateTime.Month()+1, |
1649 endDateTime.Day() + 1); |
1628 endDateTime.Day() + 1); |
1650 if (type == CCalEntry::EEvent || type == CCalEntry::EAppt || |
1629 if (type == CCalEntry::EEvent || type == CCalEntry::EAppt || |
1651 type == CCalEntry::EReminder) { |
1630 type == CCalEntry::EReminder) { |
1652 if(endsAtStartOfDay(instanceList[i], endCalTime.TimeLocalL())) { |
1631 if(endsAtStartOfDay(instanceList[i], endCalTime.TimeLocalL())) { |
1653 // instance ends at start of endtime day, month view doesnt |
|
1654 // want to show event on this day |
|
1655 TDateTime endDateTime = endCalTime.TimeLocalL().DateTime(); |
1632 TDateTime endDateTime = endCalTime.TimeLocalL().DateTime(); |
|
1633 // prevent problems with items ending tomorrow at 00:00 |
1656 endDateTime.SetMinute(endDateTime.Minute() - 1); |
1634 endDateTime.SetMinute(endDateTime.Minute() - 1); |
1657 TTime time(endDateTime); |
1635 TTime time(endDateTime); |
|
1636 // If it is ending before the start of the grid |
1658 if (time <= startDateForInstanceSearch.TimeLocalL()) { |
1637 if (time <= startDateForInstanceSearch.TimeLocalL()) { |
1659 continue; |
1638 continue; |
1660 } |
1639 } |
1661 } |
1640 } |
1662 // Mark the required dates frm start date to end date |
1641 // Mark the required dates frm start date to end date |
1663 TTimeIntervalDays days ; |
1642 TTimeIntervalDays days ; |
|
1643 int numOfDays = 0; |
1664 //check if the start date of the entry is before the start day of the grid |
1644 //check if the start date of the entry is before the start day of the grid |
1665 if(startDate < rangeStart.date()){ |
1645 if(startDate < rangeStart.date()){ |
1666 if(endDate<=rangeEnd.date()){ |
1646 if(endDate<=rangeEnd.date()){ |
1667 //if the end date of entry is lying in the grid , |
1647 //if the end date of entry is lying in the grid , |
1668 //then mark the entry from start day of the grid to the end date of the entry |
1648 //then mark the entry from start day of the grid to the end date of the entry |
1669 days = endCalTime.TimeLocalL().DaysFrom(startDateForInstanceSearch.TimeLocalL()); |
1649 days = endCalTime.TimeLocalL().DaysFrom(startDateForInstanceSearch.TimeLocalL()); |
|
1650 numOfDays = days.Int(); |
1670 } |
1651 } |
1671 else{ |
1652 else{ |
1672 //if end date of the entry is greater then the last date of grid, |
1653 //if end date of the entry is greater then the last date of grid, |
1673 //then mark all the date of the grid with the entry |
1654 //then mark all the date of the grid with the entry |
1674 days = endDateForInstanceSearch.TimeLocalL().DaysFrom(startDateForInstanceSearch.TimeLocalL()) ; |
1655 days = endDateForInstanceSearch.TimeLocalL().DaysFrom(startDateForInstanceSearch.TimeLocalL()) ; |
|
1656 numOfDays = days.Int(); |
1675 } |
1657 } |
|
1658 // Check if the event is all-day |
|
1659 if (instanceList[i]->Entry().EntryTypeL() == CCalEntry::EEvent) { |
|
1660 // no need to consider the date on which it ends |
|
1661 // reduce days count by 1 |
|
1662 numOfDays--; |
|
1663 } |
1676 //start the entries from the first day of the grid |
1664 //start the entries from the first day of the grid |
1677 for (int j = 0; j <= days.Int(); j++) { |
1665 for (int j = 0; j <= numOfDays; j++) { |
1678 QDate date = rangeStart.date().addDays(j); |
1666 QDate date = rangeStart.date().addDays(j); |
1679 if (date <= rangeEnd.date()) { |
1667 if (date <= rangeEnd.date()) { |
1680 dates.append(date); |
1668 dates.append(date); |
1681 } else { |
1669 } else { |
1682 break; |
1670 break; |
1687 else{ |
1675 else{ |
1688 if(endDate<=rangeEnd.date()){ |
1676 if(endDate<=rangeEnd.date()){ |
1689 //if the end date of entry is lying in the grid , |
1677 //if the end date of entry is lying in the grid , |
1690 //then mark the entry from start date of the entry to the end date of the entry |
1678 //then mark the entry from start date of the entry to the end date of the entry |
1691 days = endCalTime.TimeLocalL().DaysFrom(startCalTime.TimeLocalL()) ; |
1679 days = endCalTime.TimeLocalL().DaysFrom(startCalTime.TimeLocalL()) ; |
|
1680 numOfDays = days.Int(); |
1692 } |
1681 } |
1693 else{ |
1682 else{ |
1694 //if end date of the entry is greater then the last date of grid, |
1683 //if end date of the entry is greater then the last date of grid, |
1695 //then mark all the date from start date of the entry to the end date of the grid |
1684 //then mark all the date from start date of the entry to the end date of the grid |
1696 days = endDateForInstanceSearch.TimeLocalL().DaysFrom(startCalTime.TimeLocalL()) ; |
1685 days = endDateForInstanceSearch.TimeLocalL().DaysFrom(startCalTime.TimeLocalL()) ; |
|
1686 numOfDays = days.Int(); |
1697 } |
1687 } |
1698 for (int j = 0; j <= days.Int(); j++) { |
1688 // Check if the event is all-day |
|
1689 if (instanceList[i]->Entry().EntryTypeL() == CCalEntry::EEvent) { |
|
1690 // no need to consider the date on which it ends |
|
1691 // reduce days count by 1 |
|
1692 numOfDays--; |
|
1693 } |
|
1694 for (int j = 0; j <= numOfDays; j++) { |
1699 QDate date = startDate.addDays(j); |
1695 QDate date = startDate.addDays(j); |
1700 if (date <= rangeEnd.date()) { |
1696 if (date <= rangeEnd.date()) { |
1701 dates.append(date); |
1697 dates.append(date); |
1702 } else { |
1698 } else { |
1703 break; |
1699 break; |
1779 } |
1770 } |
1780 else |
1771 else |
1781 { |
1772 { |
1782 iCalInstanceView->FindInstanceL(instanceList, filters, dayRange); |
1773 iCalInstanceView->FindInstanceL(instanceList, filters, dayRange); |
1783 } |
1774 } |
|
1775 |
|
1776 // In this list, check if any all day events are there |
|
1777 // As all day events end at 12.00AM of next day, we should not show it again on next day |
|
1778 TCalTime calTime; |
|
1779 TDateTime dateTime( |
|
1780 day.date().year(), |
|
1781 static_cast<TMonth>(day.date().month() - 1), |
|
1782 day.date().day() - 1, day.time().hour(), |
|
1783 day.time().minute(), 0, 0); |
|
1784 TTime time(dateTime); |
|
1785 for (int i(0); i < instanceList.Count(); i++) { |
|
1786 if ((endsAtStartOfDay(instanceList[i], time)) && |
|
1787 instanceList[i]->Entry().EntryTypeL() == CCalEntry::EEvent) { |
|
1788 // Previous day all-day event has been found, we are not supposed to |
|
1789 // show it on current day, hence remove it from the instance list |
|
1790 instanceList.Remove(i); |
|
1791 i--; |
|
1792 } |
|
1793 } |
|
1794 |
1784 // Sort the list |
1795 // Sort the list |
1785 sortInstanceList(instanceList); |
1796 sortInstanceList(instanceList); |
1786 for(TInt i = 0; i<instanceList.Count(); i++) |
1797 for(TInt i = 0; i<instanceList.Count(); i++) |
1787 { |
1798 { |
1788 entryList.append(createAgendaEntryFromCalEntry( |
1799 entryList.append(createAgendaEntryFromCalEntry( |
1789 instanceList[i]->Entry(), instanceList[i])); |
1800 instanceList[i]->Entry(), instanceList[i])); |
1790 } |
1801 } |
1791 int count = instanceList.Count(); |
1802 CleanupStack::PopAndDestroy( &instanceList ); |
1792 for (int i = count - 1; i >= 0; --i) { |
|
1793 CCalInstance *instance = instanceList[i]; |
|
1794 delete instance; |
|
1795 } |
|
1796 CleanupStack::PopAndDestroy(); |
|
1797 ) |
1803 ) |
1798 |
1804 |
1799 return entryList; |
1805 return entryList; |
1800 } |
1806 } |
1801 |
1807 |
1923 |
1929 |
1924 calTime.SetTimeLocalL(time); |
1930 calTime.SetTimeLocalL(time); |
1925 |
1931 |
1926 // Fetch the calentry |
1932 // Fetch the calentry |
1927 CCalEntry* calEntry = iCalEntryView->FetchL(entry.id()); |
1933 CCalEntry* calEntry = iCalEntryView->FetchL(entry.id()); |
1928 CleanupStack::PushL(calEntry); |
|
1929 calEntry->SetCompletedL(complete, calTime); |
1934 calEntry->SetCompletedL(complete, calTime); |
1930 |
1935 |
1931 // Update the entry in the Database |
1936 // Update the entry in the Database |
1932 RPointerArray<CCalEntry> array; |
1937 RPointerArray<CCalEntry> array; |
1933 CleanupClosePushL(array); |
1938 CleanupResetAndDestroyPushL(array); |
1934 array.AppendL(calEntry); |
1939 array.AppendL(calEntry); |
1935 iCalEntryView->UpdateL(array, success); |
1940 iCalEntryView->UpdateL(array, success); |
1936 |
1941 |
1937 // Cleanup. |
1942 // Cleanup. |
1938 CleanupStack::PopAndDestroy(&array); |
1943 CleanupStack::PopAndDestroy( &array ); |
1939 CleanupStack::PopAndDestroy(calEntry); |
|
1940 ) |
1944 ) |
1941 |
1945 |
1942 if (0 < success) { |
1946 if (0 < success) { |
1943 emit q->entryUpdated(entry.id()); |
1947 emit q->entryUpdated(entry.id()); |
1944 } |
1948 } |
2170 break; |
2174 break; |
2171 } |
2175 } |
2172 // Is currentInstanceDate before parent dt start? |
2176 // Is currentInstanceDate before parent dt start? |
2173 if (currentInstanceDate.TimeLocalL() < |
2177 if (currentInstanceDate.TimeLocalL() < |
2174 entries[0]->StartTimeL().TimeLocalL()) { |
2178 entries[0]->StartTimeL().TimeLocalL()) { |
|
2179 TBool exceptionEntryBeforeParentStartPresent = EFalse; |
|
2180 for (TInt i=0; i<exdates.Count(); ++i) { |
|
2181 if( exdates[i].TimeLocalL() < currentInstanceDate.TimeLocalL() ) { |
|
2182 exceptionEntryBeforeParentStartPresent = ETrue; |
|
2183 } |
|
2184 } |
|
2185 if (!exceptionEntryBeforeParentStartPresent) { |
|
2186 currentInstanceDate.SetTimeLocalL(Time::NullTTime()); |
|
2187 previousStartTime = currentInstanceDate; |
|
2188 } |
2175 // There are no instances before the exception |
2189 // There are no instances before the exception |
2176 keepLooking = EFalse; |
2190 keepLooking = EFalse; |
2177 } else { |
2191 } else { |
2178 // TODO: Put the rest of this function into a separate function, as it's identical |
2192 // TODO: Put the rest of this function into a separate function, as it's identical |
2179 // to GetNextInstanceTimeL(). |
2193 // to GetNextInstanceTimeL(). |
2212 } |
2226 } |
2213 } |
2227 } |
2214 } |
2228 } |
2215 CleanupStack::PopAndDestroy(&exdates); |
2229 CleanupStack::PopAndDestroy(&exdates); |
2216 } |
2230 } |
2217 // Convert TCalTimes to QDateTimes |
2231 |
2218 TDateTime prevStart = previousStartTime.TimeLocalL().DateTime(); |
2232 if(previousStartTime.TimeUtcL() != Time::NullTTime()) { |
2219 TDateTime prevEnd = previousEndTime.TimeLocalL().DateTime(); |
2233 // Convert TCalTimes to QDateTimes |
2220 startTime.setDate(QDate(prevStart.Year(), prevStart.Month()+1, |
2234 TDateTime prevStart = previousStartTime.TimeLocalL().DateTime(); |
2221 prevStart.Day() + 1)); |
2235 TDateTime prevEnd = previousEndTime.TimeLocalL().DateTime(); |
2222 startTime.setTime(QTime(prevStart.Hour(), prevStart.Minute(), 0, 0)); |
2236 startTime.setDate(QDate(prevStart.Year(), prevStart.Month()+1, |
2223 endTime.setDate(QDate(prevEnd.Year(), prevEnd.Month()+1, |
2237 prevStart.Day() + 1)); |
2224 prevEnd.Day() + 1)); |
2238 startTime.setTime(QTime(prevStart.Hour(), prevStart.Minute(), 0, 0)); |
2225 endTime.setTime(QTime(prevEnd.Hour(), prevEnd.Minute(), 0, 0)); |
2239 endTime.setDate(QDate(prevEnd.Year(), prevEnd.Month()+1, |
2226 |
2240 prevEnd.Day() + 1)); |
|
2241 endTime.setTime(QTime(prevEnd.Hour(), prevEnd.Minute(), 0, 0)); |
|
2242 } else { |
|
2243 QDateTime nullDateTime; |
|
2244 startTime = nullDateTime; |
|
2245 endTime = nullDateTime; |
|
2246 } |
2227 delete calEntry; |
2247 delete calEntry; |
2228 int count = entries.Count(); |
|
2229 for (int i = count - 1; i >= 0; --i) { |
|
2230 CCalEntry *instance = entries[i]; |
|
2231 delete instance; |
|
2232 } |
|
2233 CleanupStack::PopAndDestroy(&entries); |
2248 CleanupStack::PopAndDestroy(&entries); |
2234 } |
2249 } |
2235 |
2250 |
2236 /*! |
2251 /*! |
2237 Returns the start and end times of next occurence of a particular |
2252 Returns the start and end times of next occurence of a particular |
2357 default: |
2372 default: |
2358 case notRepeated: |
2373 case notRepeated: |
2359 keepLooking = EFalse; |
2374 keepLooking = EFalse; |
2360 break; |
2375 break; |
2361 } |
2376 } |
2362 // Is currentInstanceDate before parent dt start? |
2377 // Is currentInstanceDate after repeat until date? |
2363 if (currentInstanceDate.TimeLocalL() < |
2378 if (currentInstanceDate.TimeLocalL() > |
2364 entries[0]->StartTimeL().TimeLocalL()) { |
2379 rrule.Until().TimeLocalL()) { |
|
2380 TBool exceptionEntryAfterRepeatUntilPresent = EFalse; |
|
2381 for (TInt i=0; i<exdates.Count(); ++i) { |
|
2382 if(exdates[i].TimeLocalL() > rrule.Until().TimeLocalL()) { |
|
2383 exceptionEntryAfterRepeatUntilPresent = ETrue; |
|
2384 } |
|
2385 } |
|
2386 if (!exceptionEntryAfterRepeatUntilPresent) { |
|
2387 currentInstanceDate.SetTimeLocalL(Time::NullTTime()); |
|
2388 nextStartTime = currentInstanceDate; |
|
2389 } |
2365 // There are no instances before the exception |
2390 // There are no instances before the exception |
2366 keepLooking = EFalse; |
2391 keepLooking = EFalse; |
2367 } else { |
2392 } else { |
2368 // TODO: Put the rest of this function into a separate function, as it's identical |
2393 // TODO: Put the rest of this function into a separate function, as it's identical |
2369 // to GetNextInstanceTimeL(). |
2394 // to GetNextInstanceTimeL(). |
2402 } |
2427 } |
2403 } |
2428 } |
2404 CleanupStack::PopAndDestroy( &exdates ); |
2429 CleanupStack::PopAndDestroy( &exdates ); |
2405 } |
2430 } |
2406 } |
2431 } |
2407 // Convert TCalTimes to QDateTimes |
2432 |
2408 TDateTime nextStart = nextStartTime.TimeLocalL().DateTime(); |
2433 if (nextStartTime.TimeUtcL() != Time::NullTTime()) { |
2409 TDateTime nextEnd = nextEndTime.TimeLocalL().DateTime(); |
2434 // Convert TCalTimes to QDateTimes |
2410 startTime.setDate(QDate(nextStart.Year(), nextStart.Month()+1, |
2435 TDateTime nextStart = nextStartTime.TimeLocalL().DateTime(); |
2411 nextStart.Day() + 1)); |
2436 TDateTime nextEnd = nextEndTime.TimeLocalL().DateTime(); |
2412 startTime.setTime(QTime(nextStart.Hour(), nextStart.Minute(), 0, 0)); |
2437 startTime.setDate(QDate(nextStart.Year(), nextStart.Month()+1, |
2413 endTime.setDate(QDate(nextEnd.Year(), nextEnd.Month()+1, |
2438 nextStart.Day() + 1)); |
2414 nextEnd.Day() + 1)); |
2439 startTime.setTime(QTime(nextStart.Hour(), nextStart.Minute(), 0, 0)); |
2415 endTime.setTime(QTime(nextEnd.Hour(), nextEnd.Minute(), 0, 0)); |
2440 endTime.setDate(QDate(nextEnd.Year(), nextEnd.Month()+1, |
2416 |
2441 nextEnd.Day() + 1)); |
|
2442 endTime.setTime(QTime(nextEnd.Hour(), nextEnd.Minute(), 0, 0)); |
|
2443 } else { |
|
2444 QDateTime nullDateTime; |
|
2445 startTime = nullDateTime; |
|
2446 endTime = nullDateTime; |
|
2447 } |
2417 delete calEntry; |
2448 delete calEntry; |
2418 int count = entries.Count(); |
2449 |
2419 for (int i = count - 1; i >= 0; --i) { |
|
2420 CCalEntry *instance = entries[i]; |
|
2421 delete instance; |
|
2422 } |
|
2423 CleanupStack::PopAndDestroy(&entries); |
2450 CleanupStack::PopAndDestroy(&entries); |
2424 } |
2451 } |
2425 |
2452 |
2426 /*! |
2453 /*! |
2427 Returns true if there are no entries in the database else returns false |
2454 Returns true if there are no entries in the database else returns false |
3682 entry.UidL().AllocL(), |
3702 entry.UidL().AllocL(), |
3683 oldEntries[i]->MethodL(), |
3703 oldEntries[i]->MethodL(), |
3684 oldEntries[i]->SequenceNumberL(), |
3704 oldEntries[i]->SequenceNumberL(), |
3685 recId, |
3705 recId, |
3686 oldEntries[i]->RecurrenceRangeL() ); |
3706 oldEntries[i]->RecurrenceRangeL() ); |
3687 CleanupStack::PushL(exception); |
|
3688 exception->CopyFromL(*oldEntries[i]); |
3707 exception->CopyFromL(*oldEntries[i]); |
3689 exception->SetLastModifiedDateL(); |
3708 exception->SetLastModifiedDateL(); |
3690 TInt successCount=0; |
3709 TInt successCount=0; |
3691 RPointerArray<CCalEntry> entries; |
3710 RPointerArray<CCalEntry> entries; |
3692 CleanupClosePushL( entries ); |
3711 CleanupResetAndDestroyPushL(entries); |
3693 entries.Append( exception ); |
3712 entries.Append( exception ); |
3694 iCalEntryView->StoreL( entries, successCount ); |
3713 iCalEntryView->StoreL( entries, successCount ); |
3695 CleanupStack::PopAndDestroy( &entries ); |
3714 CleanupStack::PopAndDestroy( &entries ); |
3696 CleanupStack::PopAndDestroy(exception); |
|
3697 } |
3715 } |
3698 else |
3716 else |
3699 { |
3717 { |
3700 // If the start time of the series has been changed, the call below will |
3718 // If the start time of the series has been changed, the call below will |
3701 // leave with -1, and the child entries will be lost. To prevent this |
3719 // leave with -1, and the child entries will be lost. To prevent this |
3704 // Fixing this may cause issues with sync though, as some servers delete the |
3722 // Fixing this may cause issues with sync though, as some servers delete the |
3705 // children when changing the start time of the series anyway. |
3723 // children when changing the start time of the series anyway. |
3706 oldEntries[i]->SetLastModifiedDateL(); |
3724 oldEntries[i]->SetLastModifiedDateL(); |
3707 TInt successCount=0; |
3725 TInt successCount=0; |
3708 RPointerArray<CCalEntry> entries; |
3726 RPointerArray<CCalEntry> entries; |
3709 CleanupClosePushL( entries ); |
3727 CleanupClosePushL(entries); |
3710 entries.Append( oldEntries[i] ); |
3728 entries.Append( oldEntries[i] ); |
3711 iCalEntryView->StoreL( entries, successCount ); |
3729 iCalEntryView->StoreL( entries, successCount ); |
3712 CleanupStack::PopAndDestroy( &entries ); |
3730 CleanupStack::Pop( &entries ); |
3713 } |
3731 } |
3714 } |
3732 } |
3715 } |
3733 } |
3716 |
3734 |
3717 TCalTime AgendaUtilPrivate::generateRecurrenceIdFromEntry( CCalEntry& entry, |
3735 TCalTime AgendaUtilPrivate::generateRecurrenceIdFromEntry( CCalEntry& entry, |