// ----------------------------------------------------------------------------- // CPIMAgnToDoAdapter::AddDefaultValuesToEntryL // (other items were commented in a header) // ----------------------------------------------------------------------------- // void CPIMAgnToDoAdapter::AddDefaultValuesToEntryL(const MPIMItemData& aData, CCalEntry& aEntry) const { JELOG2(EPim); // Calendar creates medium priority ToDos by default if (!aData.CountValues(EPIMToDoPriority)) { aEntry.SetPriorityL(EPIMToDoNativePriorityMedium); } // Calendar uses private synchronization by default if (!aData.CountValues(EPIMToDoClass)) { aEntry.SetReplicationStatusL(CCalEntry::EPrivate); } // Calendar does not support timed ToDo so the time is set to 00:00 o'clock if (!aData.CountValues(EPIMToDoDue)) { TTime thisTime; thisTime.HomeTime(); // Set time to calendar specific due time. Currently this is the start // of the date. Note that No conversion needed since time is local TCalTime calThisTime; // Set time as local time since acquired above as local time calThisTime.SetTimeLocalL(StartOfDay(thisTime)); aEntry.SetStartAndEndTimeL(calThisTime, calThisTime); } if (!aData.CountValues(EPIMToDoCompletionDate) && !aData.CountValues( EPIMToDoCompleted)) { aEntry.SetCompletedL(EFalse, aEntry.CompletedTimeL()); } }
// ----------------------------------------------------------------------------- // CPIMAgnToDoAdapter::ConvertDateToAgnL // Makes date conversion from framework PIM item data field to To-do item field. // ----------------------------------------------------------------------------- // void CPIMAgnToDoAdapter::ConvertDateToAgnL(TPIMToDoField aField, // Date field to be converted TInt aIndex, // Index of the date field CCalEntry& aEntry, const MPIMItemData& aItem) // The PIM item to read the field from { JELOG2(EPim); const TPIMFieldData fieldData = aItem.ValueL(aField, aIndex); const TPIMDate& date = fieldData.DateValue(); switch (aField) { case EPIMToDoDue: { // Because undated to-dos are possible, the due date can be set // to a null value. if (date != Time::NullTTime() && !IsDateInValidAgendaRange(date)) { User::Leave(KErrAbort); } // Java dates cannot be set to native null TTime else { // Convert due date and time to calendar specific due time // Note that PIM API dates are in UTC time format -> convert TTime dueDate(date); ConvertTimeL(dueDate, EPIMDateLocal); // Set time to native entry. Note that the time is local TCalTime calDate; calDate.SetTimeLocalL(StartOfDay(dueDate)); aEntry.SetStartAndEndTimeL(calDate, calDate); } break; } case EPIMToDoCompletionDate: { if (date != Time::NullTTime()) { __ASSERT_ALWAYS(IsDateInValidAgendaRange(date), User::Leave( KErrAbort)); TCalTime calDate; calDate.SetTimeUtcL(date); aEntry.SetCompletedL(ETrue, calDate); } else { aEntry.SetCompletedL(EFalse, aEntry.CompletedTimeL()); } break; } default: { __ASSERT_DEBUG(EFalse, User::Panic(KPIMPanicCategory, EPIMPanicUnsupportedField)); } } }
// ----------------------------------------------------------------------------- // CPIMAgnEventAdapter::ConvertDateFieldToAgnL // Converts a PIM date field to native Calendar entry // ----------------------------------------------------------------------------- // void CPIMAgnEventAdapter::ConvertDateFieldToAgnL(const MPIMEventItem& aItem, CCalEntry& aEntry, const TPIMEventField aField) { JELOG2(EPim); __ASSERT_DEBUG(aField == EPIMEventStart || aField == EPIMEventEnd, User::Panic(KPIMPanicCategory, EPIMPanicUnsupportedDateField)); TCalTime end; TCalTime start; // Get date from the Java item const MPIMItemData& itemData = aItem.ItemData(); // Get date from index 0 since native entries support only one value const TPIMFieldData fieldData = itemData.ValueL(aField, 0); const TPIMDate date = fieldData.DateValue(); // Check that the date is inside the valid range __ASSERT_ALWAYS(IsDateInValidAgendaRange(date), User::Leave(KErrAbort)); // By default, set both end and start to the same time and check if there // is the other part of the date field present in the item start.SetTimeUtcL(date); end.SetTimeUtcL(date); if (aField == EPIMEventStart && itemData.CountValues(EPIMEventEnd) > 0 && itemData.ValueL(EPIMEventEnd, 0).DateValue() >= date) { const TPIMFieldData endData = itemData.ValueL(EPIMEventEnd, 0); const TPIMDate endDate = endData.DateValue(); // Check that the date is inside the valid range __ASSERT_ALWAYS(IsDateInValidAgendaRange(endDate), User::Leave( KErrAbort)); // Set end date to the calendar date in UTC since // PIM API does not support local time format end.SetTimeUtcL(endDate); } else if (aField == EPIMEventEnd && itemData.CountValues(EPIMEventStart) > 0 && itemData.ValueL(EPIMEventStart, 0).DateValue() <= date) { const TPIMFieldData startData = itemData.ValueL(EPIMEventStart, 0); const TPIMDate startDate = startData.DateValue(); // Check that the date is inside the valid range __ASSERT_ALWAYS(IsDateInValidAgendaRange(startDate), User::Leave( KErrAbort)); // Set end date to the calendar date in UTC since // PIM API does not support local time format start.SetTimeUtcL(startDate); } // Set values to the native calendar entry aEntry.SetStartAndEndTimeL(start, end); }
void CDummyCalendarApp::AddFloatingEntryWithMinStartTimeL() {//Defect fix for PDEF111562 - when a floating entry with miniman start time will never get deleted. iEntries.ResetAndDestroy(); _LIT8(KUid, "UID_MinEntry"); HBufC8* guid = KUid().AllocLC(); CCalEntry* entry = iTestLib->CreateCalEntryL(CCalEntry::EReminder, guid); CleanupStack::Pop(guid); CleanupStack::PushL(entry); TCalTime caltimestart,caltimeend; TTime min(TDateTime(1900, EJanuary, 0, 0, 0, 0, 0)); caltimestart.SetTimeLocalFloatingL(min); entry->SetStartAndEndTimeL(caltimestart,caltimestart); iEntries.AppendL(entry); CleanupStack::Pop(entry); TInt entriesStored(0); SynCGetEntryViewL().StoreL(iEntries, entriesStored); //temp iEntries.ResetAndDestroy(); }
CCalAlarm* CCalAlarmAttachTest::StoreEntryWithAlarmContentLC(const TDesC8& aUid) { test.Printf(_L("Store an alarmed entry with alarm content\n")); // Create an attachment to the alarm. CCalAlarm* alarm = CCalAlarm::NewL(); CleanupStack::PushL(alarm); alarm->SetTimeOffset(1); CCalContent* almContent = CCalContent::NewL(); CleanupStack::PushL(almContent); // Add content and mimetype for the alarm. HBufC8* content = KContent().AllocLC(); HBufC8* mimetype = KMimeType().AllocLC(); almContent->SetContentL(content, mimetype, CCalContent::EDispositionInline); CleanupStack::Pop(mimetype); CleanupStack::Pop(content); alarm->SetAlarmAction(almContent); // Takes ownership of almContent. CleanupStack::Pop(almContent); //Create the entry with the alarm and store it RPointerArray<CCalEntry> entries; CleanupResetAndDestroyPushL(entries); HBufC8* guid = aUid.AllocLC(); CCalEntry* entry = CCalEntry::NewL(CCalEntry::EEvent, guid, CCalEntry::EMethodNone, 0); CleanupStack::Pop(guid); CleanupStack::PushL(entry); entries.AppendL(entry); CleanupStack::Pop(entry); TCalTime calTime; calTime.SetTimeUtcL(TDateTime(2007,EFebruary,15, 13, 30, 0, 0)); entry->SetStartAndEndTimeL(calTime, calTime); entry->SetSummaryL(KSummary()); entry->SetDescriptionL(KDescription()); entry->SetAlarmL(alarm); TInt entriesStored = 0; iTestLib->SynCGetEntryViewL().StoreL(entries, entriesStored); CleanupStack::PopAndDestroy(&entries); return alarm; }
// ----------------------------------------------------------------------------- // CPIMAgnMemoAdapter::AddDefaultValuesToEntryL // ----------------------------------------------------------------------------- // void CPIMAgnMemoAdapter::AddDefaultValuesToEntryL(const MPIMEventItem& aItem, CCalEntry& aEntry) const { JELOG2(EPim); // Add common event default values to the native entry CPIMAgnEventAdapter::AddDefaultValuesToEntryL(aItem, aEntry); const MPIMItemData& data = aItem.ItemData(); // Set default start and end time if these are not present in the Java item if (data.CountValues(EPIMEventStart) == 0 && data.CountValues(EPIMEventEnd) == 0) { TCalTime defaultTime; TTime currentTime; // Get current time in universal time currentTime.UniversalTime(); defaultTime.SetTimeUtcL(currentTime); aEntry.SetStartAndEndTimeL(defaultTime, defaultTime); } }
void CBadRRule::CreateToDoEntryL() { RPointerArray<CCalEntry> entryarr ; CleanupResetAndDestroyPushL(entryarr); TInt num ; HBufC8* guid = KGUID1().AllocLC(); // ownership of guid gets transferred CCalEntry *entry = CCalEntry::NewL(CCalEntry::ETodo, guid, CCalEntry::EMethodNone, 0) ; CleanupStack::Pop(guid); CleanupStack::PushL(entry) ; TCalTime startTime ; TCalTime endTime ; startTime.SetTimeUtcL(TTime(TDateTime(2006, EJanuary, 8, 10, 30, 0, 0))) ; endTime.SetTimeUtcL(startTime.TimeUtcL() + TTimeIntervalDays(1)) ; entry->SetStartAndEndTimeL(startTime, endTime) ; TCalTime endTime1 ; endTime1.SetTimeUtcL(TTime(TDateTime(2006, EJanuary, 23, 10, 5, 0, 0))) ; TCalRRule rrule(TCalRRule::EWeekly) ; rrule.SetDtStart(startTime); rrule.SetUntil(endTime1); rrule.SetInterval(1); RArray<TDay> days; CleanupClosePushL(days); days.AppendL(ETuesday); rrule.SetByDay(days); CleanupStack::PopAndDestroy(&days); entry->SetRRuleL(rrule) ; // both entry and rrule start time should be aligned to the first instance TCalRRule setRRule ; entry->GetRRuleL(setRRule) ; test(setRRule.DtStart().TimeUtcL() == rrule.DtStart().TimeUtcL()) ; entryarr.AppendL(entry) ; CleanupStack::Pop(entry); iCalEntryView->StoreL(entryarr, num) ; entryarr.ResetAndDestroy(); TCalTime recId; recId.SetTimeUtcL(TTime(TDateTime(2006, EJanuary, 9, 10, 30, 0, 0))); // creating recurrence id guid = KGUID1().AllocLC(); // ownership of guid gets transferred entry = CCalEntry::NewL(CCalEntry::ETodo, guid, CCalEntry::EMethodNone, 0, recId, CalCommon::EThisOnly); CleanupStack::Pop(guid); CleanupStack::PushL(entry) ; TCalTime startTime3 ; TCalTime endTime3 ; startTime3.SetTimeUtcL(TTime(TDateTime(2006, EJanuary, 7, 10, 2, 0, 0))) ; endTime3.SetTimeUtcL(startTime3.TimeUtcL() + TTimeIntervalHours(1)) ; entry->SetStartAndEndTimeL(startTime3, endTime3) ; entryarr.AppendL(entry) ; CleanupStack::Pop(entry) ; iCalEntryView->StoreL(entryarr, num) ; CleanupStack::PopAndDestroy(&entryarr); RArray<TTime> insTimes ; insTimes.Append(TTime(TDateTime(2006, EJanuary, 7, 11, 2, 0, 0))) ; insTimes.Append(TTime(TDateTime(2006, EJanuary, 16, 10, 30, 0, 0))) ; CleanupClosePushL(insTimes) ; CheckInstancesL(insTimes) ; CleanupStack::PopAndDestroy(&insTimes) ; // time portion of repeat's end eliminates the third instance }
void CBadRRule::ModifyEntriesL() { TInt num, err ; RPointerArray<CCalEntry> entryarr3 ; iCalEntryView->FetchL(KGUID(), entryarr3) ; test(entryarr3.Count() == 3) ; /* got 3 entries - EThisAndAll of second child do not have any special effect */ CleanupStack::PushL(TCleanupItem(CleanupCCalEntryArray, &entryarr3)); TCalTime startTime4 ; TCalTime endTime4 ; startTime4.SetTimeUtcL(TTime(TDateTime(2006, EJanuary, 1, 10, 1, 0, 0))) ; endTime4.SetTimeUtcL(startTime4.TimeUtcL() + TTimeIntervalHours(1)) ; entryarr3[0]->SetStartAndEndTimeL(startTime4, endTime4) ; //The repeating starting time will not be adjusted until the entry is stored test(entryarr3[0]->StartTimeL().TimeUtcL() == startTime4.TimeUtcL()) ; TCalRRule savedRRule ; entryarr3[0]->GetRRuleL(savedRRule) ; //The repeating starting time will not be adjusted until the entry is stored test(savedRRule.DtStart().TimeUtcL() == startTime4.TimeUtcL()) ; iCalEntryView->StoreL(entryarr3, num) ; // store succeeds, because children are still aligned to an instance CleanupStack::PopAndDestroy(&entryarr3) ; RArray<TTime> insTimes ; insTimes.Append(TTime(TDateTime(2006, EJanuary, 2, 10, 1, 0, 0))) ; insTimes.Append(TTime(TDateTime(2006, EJanuary, 7, 10, 2, 0, 0))) ; insTimes.Append(TTime(TDateTime(2006, EJanuary, 8, 11, 2, 0, 0))) ; insTimes.Append(TTime(TDateTime(2006, EJanuary, 23, 10, 1, 0, 0))) ; CleanupClosePushL(insTimes) ; CheckInstancesL(insTimes) ; CleanupStack::PopAndDestroy(&insTimes) ; // this is interesting - there could be 4 instance, but as the count value of the // repeat rule has been kept intact, we still get 3 instances, // but they are shifted . /* store is successful with modified time - now we shall change rrule */ RPointerArray<CCalEntry> entryarr4 ; iCalEntryView->FetchL(KGUID(), entryarr4) ; test(entryarr4.Count() == 3) ; CleanupStack::PushL(TCleanupItem(CleanupCCalEntryArray, &entryarr4)); CCalEntry *entry = entryarr4[0] ; TCalTime startTime1 ; TCalTime endTime1 ; TCalTime untilTime1 ; startTime1.SetTimeUtcL(TTime(TDateTime(2006, EJanuary, 16, 10, 1, 0, 0))) ; endTime1.SetTimeUtcL(TTime(TDateTime(2006, EJanuary, 16, 11, 1, 0, 0))) ; untilTime1.SetTimeUtcL(TTime(TDateTime(2006, EJanuary, 26, 10, 5, 0, 0))) ; TCalRRule rrule(TCalRRule::EWeekly) ; rrule.SetDtStart(startTime1); rrule.SetUntil(untilTime1); rrule.SetInterval(1); RArray<TDay> days; CleanupClosePushL(days); days.AppendL(ETuesday); rrule.SetByDay(days); CleanupStack::PopAndDestroy(&days); entry->SetStartAndEndTimeL(startTime1, endTime1); entry->SetRRuleL(rrule) ; TRAP(err, iCalEntryView->StoreL(entryarr4, num)) ; test(err == -1) ; // due to change in rrule store should fail test(num == 2) ; // only parent + child2 have been saved CleanupStack::PopAndDestroy(&entryarr4) ; }
void CBadRRule::CreateParentL() { RPointerArray<CCalEntry> entryarr ; CleanupResetAndDestroyPushL(entryarr); TInt num ; HBufC8* guid = KGUID().AllocLC(); // ownership of guid gets transferred CCalEntry *entry = CCalEntry::NewL(CCalEntry::EEvent, guid, CCalEntry::EMethodNone, 0) ; CleanupStack::Pop(guid); CleanupStack::PushL(entry) ; TCalTime startTime ; TCalTime endTime ; startTime.SetTimeUtcL(TTime(TDateTime(2006, EJanuary, 7, 10, 1, 0, 0))) ; endTime.SetTimeUtcL(startTime.TimeUtcL() + TTimeIntervalHours(1)) ; entry->SetStartAndEndTimeL(startTime, endTime) ; TCalTime endTime1; endTime1.SetTimeUtcL(TTime(TDateTime(2006, EJanuary, 23, 10, 5, 0, 0))) ; TCalRRule rrule(TCalRRule::EWeekly) ; rrule.SetDtStart(startTime); rrule.SetUntil(endTime1); rrule.SetInterval(1); RArray<TDay> days; CleanupClosePushL(days); days.AppendL(ETuesday); rrule.SetByDay(days); CleanupStack::PopAndDestroy(&days); entry->SetRRuleL(rrule) ; TCalRRule setRRule ; entry->GetRRuleL(setRRule) ; test(setRRule.DtStart().TimeUtcL() == rrule.DtStart().TimeUtcL()) ; entryarr.AppendL(entry) ; CleanupStack::Pop(entry); iCalEntryView->StoreL(entryarr, num) ; entryarr.ResetAndDestroy() ; iCalEntryView->FetchL(KGUID(), entryarr); TCalRRule savedRRule ; entryarr[0]->GetRRuleL(savedRRule) ; TCalTime matchTime ; /* Jan 10, 2006 is the first Tuesday */ matchTime.SetTimeUtcL(TTime(TDateTime(2006, EJanuary, 9, 10, 1, 0, 0))) ; //When the entry is stored, the repeat start time is adjusted so that it fits the rule (10th January is Tuesday test(savedRRule.DtStart().TimeUtcL() == matchTime.TimeUtcL()) ; test(entryarr[0]->StartTimeL().TimeUtcL() == (matchTime.TimeUtcL())) ; CleanupStack::PopAndDestroy(&entryarr) ; RArray<TTime> insTimes ; insTimes.Append(TTime(TDateTime(2006, EJanuary, 9, 10, 1, 0, 0))) ; insTimes.Append(TTime(TDateTime(2006, EJanuary, 16, 10, 1, 0, 0))) ; insTimes.Append(TTime(TDateTime(2006, EJanuary, 23, 10, 1, 0, 0))) ; CleanupClosePushL(insTimes) ; CheckInstancesL(insTimes) ; CleanupStack::PopAndDestroy(&insTimes) ; }
void CDummyCalendarApp::Add3ReminderAnd1ApptL() { test.Next(_L("Create some entries including day note and delete them")); //Create entries iEntries.ResetAndDestroy(); //create reminder 1 TBuf8<255> buf; buf.Append(_L("GuidId_Reminder_1")); HBufC8* guid = buf.AllocLC(); CCalEntry* reminder1 = CCalEntry::NewL(CCalEntry::EReminder, guid, CCalEntry::EMethodAdd, 0); CleanupStack::Pop(guid); iEntries.AppendL(reminder1); TCalTime starttime; starttime.SetTimeLocalL(TDateTime(2006, EMarch, 5, 0, 0, 0, 0)); reminder1->SetStartAndEndTimeL(starttime, starttime); TBuf<50> summary; RandomText(summary); reminder1->SetSummaryL(summary); //create reminder 2 buf.Delete(buf.Length()-1,1); buf.Append(2); guid = buf.AllocLC(); CCalEntry* reminder2 = CCalEntry::NewL(CCalEntry::EReminder, guid, CCalEntry::EMethodAdd, 0); CleanupStack::Pop(guid); iEntries.AppendL(reminder2); starttime.SetTimeLocalL(TDateTime(2006, EMarch, 6, 0, 0, 0, 0)); reminder2->SetStartAndEndTimeL(starttime, starttime); RandomText(summary); reminder2->SetSummaryL(summary); //create reminder 3 buf.Delete(buf.Length()-1,1); buf.Append(3); guid = buf.AllocLC(); CCalEntry* reminder3 = CCalEntry::NewL(CCalEntry::EReminder, guid, CCalEntry::EMethodAdd, 0); CleanupStack::Pop(guid); iEntries.AppendL(reminder3); starttime.SetTimeLocalL(TDateTime(2006, EMarch, 7, 0, 0, 0, 0)); reminder3->SetStartAndEndTimeL(starttime, starttime); RandomText(summary); reminder3->SetSummaryL(summary); //Create appt buf.Zero(); buf.Append(_L("GuidId_Appt")); guid = buf.AllocLC(); CCalEntry* appt = CCalEntry::NewL(CCalEntry::EAppt, guid, CCalEntry::EMethodAdd, 0); CleanupStack::Pop(guid); iEntries.AppendL(appt); starttime.SetTimeLocalL(TDateTime(2006, EMarch, 7, 14, 0, 0, 0)); TTime endtimetime(TDateTime(2006, EMarch, 7, 14, 0, 0, 0)); endtimetime +=TTimeIntervalHours(1); TCalTime endtime; endtime.SetTimeLocalL(endtimetime); appt->SetStartAndEndTimeL(starttime, endtime); RandomText(summary); appt->SetSummaryL(summary); //store 4 entries TInt entriesStored(0); SynCGetEntryViewL().StoreL(iEntries, entriesStored); test(entriesStored == 4); iEntries.ResetAndDestroy(); }
void CCalAlarmAttachTest::TestUpdateEntryHavingAlarmcontentL() { test.Printf(_L("Test updating an entry having AlarmContent \n")); //Create a Calendar entry with Alarm Content RPointerArray<CCalEntry> entries; CleanupResetAndDestroyPushL(entries); HBufC8* guid = KGUID1().AllocLC(); CCalEntry* calentry = CCalEntry::NewL(CCalEntry::EEvent, guid, CCalEntry::EMethodNone, 0); CleanupStack::Pop(guid); CleanupStack::PushL(calentry); TCalTime calTime1; calTime1.SetTimeUtcL(TDateTime(2007,EFebruary,15, 13, 30, 0, 0)); TCalTime calTime2; calTime2.SetTimeUtcL(TDateTime(2007,EFebruary,15, 14, 30, 0, 0)); calentry->SetStartAndEndTimeL(calTime1, calTime2); calentry->SetSummaryL(_L("Test for Alarms")); CCalAlarm* alarm = CCalAlarm::NewL(); CleanupStack::PushL(alarm); alarm->SetTimeOffset(1); CCalContent* almContent = CCalContent::NewL(); CleanupStack::PushL(almContent); // Add content and mimetype for the alarm. HBufC8* content = KContent().AllocLC(); HBufC8* mimetype = KMimeType().AllocLC(); // Takes ownership of content and mimetype. almContent->SetContentL(content, mimetype, CCalContent::EDispositionInline); alarm->SetAlarmAction(almContent); // Takes ownership of almContent. calentry->SetAlarmL(alarm); CleanupStack::Pop(mimetype); CleanupStack::Pop(content); CleanupStack::Pop(almContent); CleanupStack::PopAndDestroy(alarm); TCalRRule rptRule; rptRule.SetDtStart( calTime1 ); rptRule.SetType( TCalRRule::EYearly ); rptRule.SetCount(5); calentry->SetRRuleL(rptRule); entries.AppendL(calentry); // Store entry with Alarm content TInt entriesStored = 0; iTestLib->SynCGetEntryViewL().StoreL(entries, entriesStored); CleanupStack::Pop(calentry); CleanupStack::PopAndDestroy(&entries); //Fetch stored entry and modify alarm time. CleanupResetAndDestroyPushL(entries); iTestLib->SynCGetEntryViewL().FetchL(KGUID1(), entries); CCalEntry* entry = entries[0]; alarm = entry->AlarmL(); CleanupStack::PushL(alarm); alarm->SetTimeOffset(1); entry->SetAlarmL(alarm); CleanupStack::PopAndDestroy(alarm); //Update the entry with changes. iTestLib->SynCGetEntryViewL().UpdateL(entries, entriesStored); CleanupStack::PopAndDestroy(&entries); //Fetch updated entry and check if Alarm content is intact. CleanupResetAndDestroyPushL(entries); iTestLib->SynCGetEntryViewL().FetchL(KGUID1(), entries); TestAlarmL(entries[0], KContent(), KMimeType()); CleanupStack::PopAndDestroy(&entries); }
/** * Tests behaviour of the alarm attachments. * * Create 3 entries, a parent, and two child entries. The first child entry has * an alarm attachment and stores the entry. The second child also has an * attachment and stores the entry. The second child's alarm attachment data * should overwrite the first child's alarm data. */ void CCalAlarmAttachTest::CreateEntriesL() { //----------------------------------------------------------------------- // Create parent entry with repeat rule //----------------------------------------------------------------------- RPointerArray<CCalEntry> entries; CleanupResetAndDestroyPushL(entries); HBufC8* guid = KGUID1().AllocLC(); CCalEntry* parentEntry = CCalEntry::NewL(CCalEntry::EEvent, guid, CCalEntry::EMethodNone, 0); CleanupStack::Pop(guid); CleanupStack::PushL(parentEntry); TCalTime calTime1; calTime1.SetTimeUtcL(TDateTime(2007,EFebruary,15, 13, 30, 0, 0)); TCalTime calTime2; calTime2.SetTimeUtcL(TDateTime(2007,EFebruary,15, 14, 30, 0, 0)); parentEntry->SetStartAndEndTimeL(calTime1, calTime2); parentEntry->SetSummaryL(_L("Test for Alarms")); TCalRRule rptRule; rptRule.SetDtStart( calTime1 ); rptRule.SetType( TCalRRule::EDaily ); rptRule.SetInterval( 1 ); rptRule.SetCount(5); parentEntry->SetRRuleL(rptRule); entries.AppendL(parentEntry); // Store parent entry. TInt entriesStored = 0; iTestLib->SynCGetEntryViewL().StoreL(entries, entriesStored); CleanupStack::Pop(parentEntry); CleanupStack::PopAndDestroy(&entries); //----------------------------------------------------------------------- // Create child entry with recurrence id on 17th and with alarm attachment. //----------------------------------------------------------------------- RPointerArray<CCalEntry> entriesToStore1; CleanupResetAndDestroyPushL(entriesToStore1); TCalTime recurrenceId; recurrenceId.SetTimeUtcL(TDateTime(2007,EFebruary,17, 13, 30, 0, 0)); HBufC8* parentGuid = KGUID1().AllocLC(); CCalEntry* childEntry1 = CCalEntry::NewL(CCalEntry::EEvent, parentGuid, CCalEntry::EMethodNone, 0, recurrenceId, CalCommon::EThisOnly); CleanupStack::Pop(parentGuid); CleanupStack::PushL(childEntry1); TCalTime calTime3; calTime3.SetTimeUtcL(TDateTime(2007,EFebruary,21, 13, 30, 0, 0)); TCalTime calTime4; calTime4.SetTimeUtcL(TDateTime(2007,EFebruary,21, 14, 30, 0, 0)); childEntry1->SetStartAndEndTimeL(calTime3, calTime4); // Add an attachment to the alarm. CCalAlarm* alarm = CCalAlarm::NewL(); CleanupStack::PushL(alarm); alarm->SetTimeOffset(1); CCalContent* almContent = CCalContent::NewL(); CleanupStack::PushL(almContent); // Add content and mimetype for the alarm. _LIT8(KContent, "C:\\test.jpg"); _LIT8(KMimeType, "mime type"); HBufC8* content = KContent().AllocLC(); HBufC8* mimetype = KMimeType().AllocLC(); // Takes ownership of content and mimetype. almContent->SetContentL(content, mimetype, CCalContent::EDispositionInline); alarm->SetAlarmAction(almContent); // Takes ownership of almContent. childEntry1->SetAlarmL(alarm); CleanupStack::Pop(mimetype); CleanupStack::Pop(content); CleanupStack::Pop(almContent); CleanupStack::PopAndDestroy(alarm); TInt entriesStored1 = 0; entriesToStore1.AppendL(childEntry1); iTestLib->SynCGetEntryViewL().StoreL(entriesToStore1, entriesStored1); CleanupStack::Pop(childEntry1); // Test if the alarm details retrieved are as expected. CCalEntry* entry1 = entriesToStore1[0]; TestAlarmL(entry1, KContent(), KMimeType()); // Fetch the entry and ensure the alarm details are still as expected. FetchEntryL( KContent(), KMimeType() ); CleanupStack::PopAndDestroy(&entriesToStore1); //----------------------------------------------------------------------- // Create another child entry with recurrence id and range same as above. // The entry should be updated. //----------------------------------------------------------------------- RPointerArray<CCalEntry> entriesToStore2; CleanupResetAndDestroyPushL(entriesToStore2); HBufC8* parentGuid1 = KGUID1().AllocLC(); TCalTime recurrenceId1; recurrenceId1.SetTimeUtcL(TDateTime(2007,EFebruary,17, 13, 30, 0, 0)); CCalEntry* childEntry2 = CCalEntry::NewL(CCalEntry::EEvent, parentGuid1, CCalEntry::EMethodNone, 0, recurrenceId1, CalCommon::EThisOnly); CleanupStack::Pop(parentGuid1); CleanupStack::PushL(childEntry2); TCalTime calTime5; calTime5.SetTimeUtcL(TDateTime(2007,EFebruary,22, 13, 30, 0, 0)); TCalTime calTime6; calTime6.SetTimeUtcL(TDateTime(2007,EFebruary,22, 14, 30, 0, 0)); childEntry2->SetStartAndEndTimeL(calTime5, calTime6); childEntry2->SetSummaryL(_L("Update the child entry1")); childEntry2->SetPriorityL(2); // Add attachment to the alarm. CCalAlarm* alarm1 = CCalAlarm::NewL(); CleanupStack::PushL(alarm1); alarm1->SetTimeOffset(1); CCalContent* almContent1 = CCalContent::NewL(); CleanupStack::PushL(almContent1); // Add alarm attachment to the entry. _LIT8(KContent1, "C:\\longtail.jpg"); _LIT8(KMimeType1, "mime type 2"); HBufC8* content1 = KContent1().AllocLC(); HBufC8* mimetype1 = KMimeType1().AllocLC(); almContent1->SetContentL(content1, mimetype1, CCalContent::EDispositionInline); alarm1->SetAlarmAction(almContent1); childEntry2->SetAlarmL(alarm1); CleanupStack::Pop(mimetype1); CleanupStack::Pop(content1); CleanupStack::Pop(almContent1); CleanupStack::PopAndDestroy(alarm1); entriesToStore2.AppendL(childEntry2); // Store the child entry. TInt entriesStored2 = 0; iTestLib->SynCGetEntryViewL().StoreL(entriesToStore2, entriesStored2); // Store the entry again. The stream id for the alarm action will be // re-used (in CAgnEntry). RAgendaServ::UpdateEntryL() will call // CAgnEntry::UpdateAlarmAction() instead of StoreAlarmAction(). iTestLib->SynCGetEntryViewL().StoreL(entriesToStore2, entriesStored2); CleanupStack::Pop(childEntry2); CCalEntry* entry2 = entriesToStore2[0]; // Test if the alarm details are retrieved as expected. TestAlarmL(entry2, KContent1(), KMimeType1()); // Fetch the entry and ensure the alarm details are still as expected. FetchEntryL( KContent1(), KMimeType1() ); CleanupStack::PopAndDestroy(&entriesToStore2); }
void CCalAlarmAttachTest::TestDeleteAlarmL() { CCalEntryView &view = iTestLib->SynCGetEntryViewL() ; CCalEntryView *calentryview = &view ; TInt num ; ClearAllAlarmsL() ; test.Printf(_L("Going to check deletion of non-snoozed alarms\n")) ; /* create repeating parent entry */ HBufC8* guid = KGUID3().AllocLC(); // ownership of guid gets transferred CCalEntry *entry = CCalEntry::NewL(CCalEntry::ETodo, guid, CCalEntry::EMethodNone, 0) ; CleanupStack::Pop(guid); CleanupStack::PushL(entry) ; TTime now1; now1.UniversalTime(); now1 += TTimeIntervalSeconds(30); TCalTime startTime ; TCalTime endTime ; startTime.SetTimeUtcL(now1) ; endTime.SetTimeUtcL(now1 + TTimeIntervalSeconds(30)) ; entry->SetStartAndEndTimeL(startTime, endTime) ; TCalRRule rrule(TCalRRule::EDaily) ; rrule.SetDtStart(startTime); TCalTime endRTime ; endRTime.SetTimeUtcL(now1 + TTimeIntervalDays(7)) ; rrule.SetUntil(endRTime); rrule.SetInterval(1); entry->SetRRuleL(rrule) ; CCalAlarm *alarm = CCalAlarm::NewL() ; CleanupStack::PushL(alarm) ; alarm->SetTimeOffset(TTimeIntervalMinutes(0)) ; entry->SetAlarmL(alarm) ; //ownership does not get transferred RPointerArray<CCalEntry> entryarr ; entryarr.AppendL(entry) ; //ownership does not got transferred calentryview->StoreL(entryarr, num) ; entryarr.Close() ; CleanupStack::PopAndDestroy(alarm) ; CleanupStack::PopAndDestroy(entry) ; /* Now let the alarm go off */ RArray< TAlarmId > alarmIdArr ; iAlarmServer.GetAlarmIdListL(alarmIdArr) ; TInt cnt = alarmIdArr.Count() ; test(cnt > 0) ; TRequestStatus status = 0; TAlarmId alarmId = alarmIdArr[0]; alarmIdArr.Close() ; test.Printf(_L("Waiting one minute for the alarm to go off...\n")) ; for(;;) { iAlarmServer.NotifyChange(status, alarmId); User::WaitForRequest(status); PrintEventDetails(status.Int()); if (status.Int() == EAlarmChangeEventTimerExpired) { break; // alarm expired } } /* delete this entry - without snoozing */ RPointerArray< CCalEntry > calEntryArray ; calentryview->FetchL(KGUID3(), calEntryArray) ; test(calEntryArray.Count() == 1) ; CCalEntry *entry1 = calEntryArray[0] ; entry1->SetCompletedL(ETrue, startTime) ; calentryview->StoreL(calEntryArray, num) ; delete entry1 ; calEntryArray.Close() ; /* now check if the alarm still exists or not */ RArray< TAlarmId > alarmIdArr1 ; iAlarmServer.GetAlarmIdListL(alarmIdArr1) ; TInt cnt1 = alarmIdArr1.Count() ; test(cnt1 < cnt) ; if (cnt1 > 0) { TAlarmId alarmId1 = alarmIdArr1[0]; test(alarmId != alarmId1) ; } alarmIdArr1.Close() ; ClearAllAlarmsL() ; test.Printf(_L("Checking of non snoozed alarms successful\n")) ; }
void CTestAgendaAddAppt::AddEntriesL( void ) { TInt count=1; if ( !GetIntFromConfig(ConfigSection(), KCount, count) ) count=1; TBuf<KMaxTestExecuteCommandLength> tempStore; TInt year; TInt month; TInt day; TInt hour; TInt minute; TInt duration; TInt alarm; TPtrC ptrAlarmSound; TPtrC ptrMessage; TBuf<KMaxDateStringLength> dateString; _LIT(KDateString,"%*E%*D%X%*N%*Y %1 %2 '%3"); RPointerArray<CCalEntry> array; CleanupStack::PushL(TCleanupItem(DestroyRPointerArray, &array)); for (TInt entry=0; entry<count && TestStepResult() == EPass; ) { TTime today; today.HomeTime(); tempStore.Format(KYear(), ++entry); if ( !GetIntFromConfig(ConfigSection(), tempStore, year) ) year=today.DateTime().Year(); tempStore.Format(KMonth(), entry); if ( !GetIntFromConfig(ConfigSection(), tempStore, month) ) month=today.DateTime().Month(); tempStore.Format(KDay(), entry); if ( !GetIntFromConfig(ConfigSection(), tempStore, day) ) day=today.DateTime().Day(); else --day; tempStore.Format(KHour(), entry); if ( !GetIntFromConfig(ConfigSection(), tempStore, hour) ) hour=today.DateTime().Hour(); tempStore.Format(KMinute(), entry); if ( !GetIntFromConfig(ConfigSection(), tempStore, minute) ) minute=0; tempStore.Format(KDuration(), entry); if ( !GetIntFromConfig(ConfigSection(), tempStore, duration) ) duration=30; tempStore.Format(KMessage(), entry); GetStringFromConfig(ConfigSection(), tempStore, ptrMessage); TTime startTime(TDateTime(year, TMonth(month-1+EJanuary), day, hour, minute,0,0)); startTime.FormatL(dateString,KDateString); INFO_PRINTF2(_L("Start date is %S"), &dateString); TTime endTime = startTime + TTimeIntervalMinutes(duration); endTime.FormatL(dateString,KDateString); INFO_PRINTF2(_L("End date is %S"), &dateString); HBufC8* uid = HBufC8::NewLC(255); TPtr8 uidP = uid->Des(); uidP.Append(count); CCalEntry* calEntry = CCalEntry::NewL(CCalEntry::EAppt, uid, CCalEntry::EMethodNone, 0); CleanupStack::Pop(); //uid CleanupStack::PushL(calEntry); TCalTime calStartTime, calEndTime; calStartTime.SetTimeLocalL(startTime); calEndTime.SetTimeLocalL(endTime); calEntry->SetStartAndEndTimeL(calStartTime, calEndTime); tempStore.Format(KAlarm(), entry); if ( GetIntFromConfig(ConfigSection(), tempStore, alarm) ) { TTimeIntervalMinutes currentTime((hour*60) + minute); TTimeIntervalMinutes alarmTime(currentTime.Int()); CCalAlarm* calAlarm = CCalAlarm::NewL(); CleanupStack::PushL(calAlarm); calAlarm->SetTimeOffset(alarmTime); tempStore.Format(KAlarmSound(), entry); if ( GetStringFromConfig(ConfigSection(), tempStore, ptrAlarmSound) ) calAlarm->SetAlarmSoundNameL(ptrAlarmSound); else calAlarm->SetAlarmSoundNameL(_L("Bells")); calEntry->SetAlarmL(calAlarm); CleanupStack::PopAndDestroy(); //calAlarm } //Store in the array array.AppendL(calEntry); CleanupStack::Pop(); //calEntry } INFO_PRINTF1(_L("About to store appointments now")); TInt success(0); TRAPD(storeError, iCalEntryViewBase->StoreL(array, success)); INFO_PRINTF2(_L("Store result is %d"), storeError); if (success != count && storeError == KErrNone) { SetTestStepResult(EFail); } CleanupStack::PopAndDestroy(&array); }
void CCalOOMTest::CreateEntriesL() { _LIT8(KGuid1, "Reminder-1"); _LIT8(KGuid2, "Appt-1"); _LIT(KEntryStartTime, "20121119:013000.000000"); // 20-12-2012 01.30 _LIT(KEntryEndTime, "20121119:090000.000000"); // 20-12-2012 09.00 _LIT(KTimeUntil, "20131119:013000.000000"); // 20-12-2013 01.30 _LIT(KSummary1, "THIS SUMMARY"); _LIT(KSummary2, "Appt summary"); //entry 1 HBufC8* guid8 = HBufC8::NewL(KGuid1().Length()); guid8->Des().Copy(KGuid1); CleanupStack::PushL(guid8); CCalEntry* entry = CCalEntry::NewL(CCalEntry::EReminder, guid8, CCalEntry::EMethodAdd, (TUint)0); CleanupStack::Pop(guid8); entry->SetSummaryL(KSummary1); // entry2 guid8 = HBufC8::NewL(KGuid2().Length()); guid8->Des().Copy(KGuid2); CleanupStack::PushL(guid8); CCalEntry* entry2 = CCalEntry::NewL(CCalEntry::EAppt, guid8, CCalEntry::EMethodAdd, (TUint)0); CleanupStack::Pop(guid8); entry2->SetSummaryL(KSummary2); TTime time1(KEntryStartTime()); TTime time2(KEntryEndTime()); TCalTime st; st.SetTimeUtcL(time1); TCalTime end; end.SetTimeUtcL(time2); entry->SetStartAndEndTimeL(st, end); entry2->SetStartAndEndTimeL(st, end); TCalRRule* rRule=new (ELeave) TCalRRule(TCalRRule::EDaily); TCalTime calTime = entry->StartTimeL(); rRule->SetDtStart(calTime); rRule->SetInterval(1); TTime until(KTimeUntil()); TCalTime untilTime; untilTime.SetTimeUtcL(until); rRule->SetUntil(untilTime); entry->SetRRuleL(*rRule); entry2->SetRRuleL(*rRule); TInt entriesStored(0); RPointerArray<CCalEntry> entriesToStore; CleanupResetAndDestroyPushL(entriesToStore); entriesToStore.AppendL(entry); entriesToStore.AppendL(entry2); iTestLib->SynCGetEntryViewL().StoreL(entriesToStore, entriesStored); delete rRule; CleanupStack::PopAndDestroy(&entriesToStore); // Find _LIT(KFindSt, "20131117:013000.000000"); // The event "overlaps" with this search range, hence must be caught. The reminder must not be caught (its end time = start time). _LIT(KFindEnd, "20131119:093000.000000"); CalCommon::TCalViewFilter filter = CalCommon::EIncludeAll; TestFindInstancesL(KFindSt, KFindEnd, filter); // calling OOM test function }