// -----------------------------------------------------------------------------
// CPIMAgnToDoAdapter::ConvertStringToAgnL
// Makes string conversion from framework PIM item data field to To-do item field
// -----------------------------------------------------------------------------
//
void CPIMAgnToDoAdapter::ConvertStringToAgnL(TPIMToDoField aField, // String field to be converted
        TInt aIndex, // Index of the date field
        CCalEntry& aEntry, // The Agenda Model entry
        const MPIMItemData& aItem) // The PIM item to read the field from
{
    JELOG2(EPim);
    const TPIMFieldData fieldData = aItem.ValueL(aField, aIndex);
    const TDesC& string = fieldData.StringValue();

    // Check that string is not too long
    __ASSERT_ALWAYS(string.Length() <= KPIMToDoStringValueMaxLength,
                    User::Leave(KErrTooBig));

    switch (aField)
    {
    case EPIMToDoSummary:
    {
        aEntry.SetSummaryL(string);
        break;
    }
    case EPIMToDoNote:
    {
        aEntry.SetDescriptionL(string);
        break;
    }
    default:
    {
        // Should not happen
    }
    }

}
// -----------------------------------------------------------------------------
// CPIMAgnToDoAdapter::ExportItemL
// (other items were commented in a header)
// -----------------------------------------------------------------------------
//
void CPIMAgnToDoAdapter::ExportItemL(const MPIMToDoItem& aItem,
                                     CCalEntry& aEntry, TBool aResetEntry)
{
    JELOG2(EPim);
    if (aResetEntry)
    {
        // Reset native entry for exporting new data
        aEntry.SetSummaryL(KNullDesC());
        aEntry.SetDescriptionL(KNullDesC());
        aEntry.SetPriorityL(0);
        aEntry.SetCompletedL(EFalse, aEntry.CompletedTimeL());
    }

    // Export item data to the native ToDo calendar entry
    const MPIMItemData& itemData = aItem.ItemData();
    CArrayFix<TPIMField>* fields = itemData.FieldsLC();

    // Add default values to the calendar entry
    AddDefaultValuesToEntryL(itemData, aEntry);

    // Convert each field to the native ToDo calendar entry
    TInt count = fields->Count();
    for (TInt i = 0; i < count; i++)
    {
        TPIMToDoField field = static_cast<TPIMToDoField>(fields->At(i));
        ConvertToAgnL(field, aEntry, itemData);
    }
    CleanupStack::PopAndDestroy(fields);
}
void CMultiThreadTestApp::AddEntryL(CCalEntryView& aView, const TInt aNumToAdd)
	{
	// Add Entries for Test
	RTest test(KTestName);
	test.Next(_L("Adding entries"));

	
	TBuf<50> summary;
	TBuf<50> location;
	TBuf<50> description;


	RPointerArray<CCalEntry> entriesToStore;
	CleanupResetAndDestroyPushL(entriesToStore);
	
	for (TInt index = 0; index < aNumToAdd; ++index)
		{
		CCalEntry* entry;
		HBufC8*    guid = HBufC8::NewL(255);
		TPtr8      uidP = guid->Des();
		
		RandomText8(uidP);
		
		if( (index %2) == 0 )
			{
			entry = CreateCalEntryL(CCalEntry::ETodo, guid);
			}
		else
			{
			entry = CreateCalEntryL(CCalEntry::EAppt, guid);
			}
	
		TInt err = entriesToStore.Append(entry);
		test(err == KErrNone);
		
		SetEntryStartAndEndTimeL(entry);
				
		RandomText(summary);
		entry->SetSummaryL(summary);
		
		RandomText(location);
		entry->SetLocationL(location);
		
		RandomText(description);
		entry->SetDescriptionL(description);
		}

	TInt entriesStored(0);
	aView.StoreL(entriesToStore, entriesStored); //temp
	test(entriesStored == aNumToAdd);
	test.Close();
	
	CleanupStack::PopAndDestroy(&entriesToStore);
	}
Пример #4
0
void CDummyCalendarApp::RepeatExceptedEntryCreateL()
	{
	test.Next(_L("Add entry, repeat twice, set excepted and delete"));

	iEntries.ResetAndDestroy();	
	
	// Create new calendar entry.
	CCalEntry* entry = NULL;
	HBufC8* guid = KGUIDInc081869().AllocLC();	
	entry = CreateCalEntryL(CCalEntry::EAppt, guid);
	CleanupStack::Pop(guid);
	
	iEntries.AppendL(entry);	

    // Set start and end date.
	TTime start(TDateTime(2006, EMarch, 6, 10, 0, 0, 0));
	TTime end(TDateTime(2006, EMarch, 6, 14, 0, 0, 0));
	SetEntryStartAndEndTimeL(entry, start, end);
	
	TBuf<50> summary;			
	RandomText(summary);
	entry->SetSummaryL(summary);

	TBuf<50> location;
	RandomText(location);
	entry->SetLocationL(location);

	TBuf<50> description;		
	RandomText(description);
	entry->SetDescriptionL(description);	

	// Create a daily repeating rule that occurs for 2 days.
	TCalRRule rpt(TCalRRule::EDaily);
	rpt.SetInterval(1);
	rpt.SetCount(2);	
	
	// Make sure the repeat time is within the delete time range.
	TCalTime repeatStart;
	TCalTime repeatEnd;
	repeatStart.SetTimeLocalL(TDateTime(2006, EMarch, 6, 0, 0, 0, 0));
	repeatEnd.SetTimeLocalL(TDateTime(2006, EMarch, 8, 0, 0, 0, 0));
	rpt.SetDtStart(repeatStart); 
	rpt.SetUntil(repeatEnd);
	entry->SetRRuleL(rpt);

    // Store the entry. Because it repeats over 2 days, there will
    // be 2 entries.
	TInt entriesStored(0);
	SynCGetEntryViewL().StoreL(iEntries, entriesStored);
	test(entriesStored == iEntries.Count());
	}
// -----------------------------------------------------------------------------
// CPIMAgnEventAdapter::ClearPIMFieldsL
// Clears the fields supported by PIM API from this Agenda Model entry.
// -----------------------------------------------------------------------------
//
void CPIMAgnEventAdapter::ClearPIMFieldsL(CCalEntry& aEntry,
        const TPIMField aSupportedFields[], // Array of supported field types
        TInt aSize) // Size of the array of supported fields
{
    JELOG2(EPim);
    for (int i = 0; i < aSize; i++)
    {
        switch (aSupportedFields[i])
        {
        case EPIMEventSummary:
        {
            aEntry.SetSummaryL(KNullDesC);
            break;
        }
        case EPIMEventLocation:
        {
            aEntry.SetLocationL(KNullDesC);
            break;
        }
        case EPIMEventNote:
        {
            aEntry.SetDescriptionL(KNullDesC);
            break;
        }
        case EPIMEventAlarm:
        {
            aEntry.SetAlarmL(NULL);
            break;
        }
        case EPIMEventStart: // Fallthrough
        case EPIMEventEnd: // Fallthrough
        case EPIMEventUid: // Fallthrough
        case EPIMEventClass: // Fallthrough
        case EPIMEventRevision:
        {
            break; // For these fields there is no need to do anything
        }
        default:
        {
            User::Leave(KErrArgument);
        }
        }
    }
}
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;
    }
// -----------------------------------------------------------------------------
// CPIMAgnEventAdapter::ConvertStringFieldToAgnL
// Makes string conversion from framework PIM item data field to Appt item field
// -----------------------------------------------------------------------------
//
void CPIMAgnEventAdapter::ConvertStringFieldToAgnL(const MPIMEventItem& aItem,
        CCalEntry& aEntry, const TPIMEventField aField) const
{
    JELOG2(EPim);
    const MPIMItemData& itemData = aItem.ItemData();
    TInt amount = itemData.CountValues(aField);
    for (TInt i = 0; i < amount; i++)
    {
        const TPIMFieldData fieldData = itemData.ValueL(aField, i);
        const TDesC& stringValue = fieldData.StringValue();
        EnsureValidStringValueL(stringValue);
        // Add correct data to the field
        switch (aField)
        {
        case EPIMEventNote:
        {
            aEntry.SetDescriptionL(stringValue);
            break;
        }
        case EPIMEventSummary:
        {
            aEntry.SetSummaryL(stringValue);
            break;
        }
        case EPIMEventLocation:
        {
            aEntry.SetLocationL(stringValue);
            break;
        }
        default:
        {
            __ASSERT_DEBUG(EFalse, User::Panic(KPIMPanicCategory,
                                               EPIMPanicUnsupportedStringField));
            break;
        }
        }

    }
}
Пример #8
0
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();
	}
Пример #9
0
void CDummyCalendarApp::AddEntryL(TInt aNumToAdd, TBool isParent, TBool isRepeat)
	{
	test.Next(_L("Adding entries"));

	TBuf<50> summary;
	TBuf<50> location;
	TBuf<50> description;

    

	iEntries.ResetAndDestroy();
	for (TInt index=0; index<aNumToAdd; index++)
		{
		TBuf8<255> buf;
		buf.Append(_L("GuidId"));
		buf.AppendNum(index);
		HBufC8* guid = buf.AllocLC();   // need to be pushed to ...

		CCalEntry::TType entryType=(index%2==0)?CCalEntry::ETodo:CCalEntry::EAppt;

		CCalEntry* entry = NULL;
		if(isParent)
			{
			entry = CreateCalEntryL(entryType, guid);
			}
		else
			{
			TTime localTime(KRecurrIdLocalTime);
			TCalTime recurrenceId;
			recurrenceId.SetTimeLocalL(localTime);
			entry = CCalEntry::NewL(entryType, guid, CCalEntry::EMethodAdd, 1, recurrenceId, CalCommon::EThisAndFuture);
			}
		CleanupStack::Pop(guid);
		iEntries.AppendL(entry);

		TInt year = -1;
		TInt month = -1;
		TInt day = -1;
		
		if (isParent)
		    {
    		year = index % 5 + 2001;    // Any year in the range: 2001 - 2005
    		month = index % 12;         
    		day = index % 28;
		    }
        else
            {
            // if this is a child entry, use the recurrence local time as the entry start time 
            // so it won't be out of range
            TCalTime recurrId = entry->RecurrenceIdL(); 
            TDateTime localTime = recurrId.TimeLocalL().DateTime();               
            year = localTime.Year();
            month = localTime.Month();
            day = localTime.Day();    
            }
		
		TTime start(TDateTime(year, (TMonth)month, day, 0, 0, 0, 0));
		TTime end(TDateTime(year, (TMonth)month, day, 0, 0, 0, 0));
		end += TTimeIntervalDays(1);

		SetEntryStartAndEndTimeL(entry,start,end);
				
		RandomText(summary);
		entry->SetSummaryL(summary);
		
		RandomText(location);
		entry->SetLocationL(location);
		
		RandomText(description);
		entry->SetDescriptionL(description);

		if(isRepeat)
			{
			//create a daily repeat rule and make sure its repeat start\end date is within the deleting time range
			TCalRRule rpt(TCalRRule::EDaily);
			rpt.SetInterval(1);
			TCalTime repeatStart;
			TCalTime repeatend;
			if(isParent)
				{
				//make sure the repeat time is within the delete time range
				repeatStart.SetTimeLocalL(TDateTime(2000, EJune, 0, 0, 0, 0, 0));
				repeatend.SetTimeLocalL(TDateTime(2006, EJune, 0, 0, 0, 0, 0));
				}
			else if (index<aNumToAdd/2)
				{
                // if this is a child entry, use the entry's recurrance time as repeating rule
                // start time 
                TCalTime recurrId = entry->RecurrenceIdL(); 
				
				// make sure the repeat time is within the delete time range for the first half entries
				repeatStart.SetTimeLocalL(recurrId.TimeLocalL());	// June 1, 2003 00:00:00
				repeatend.SetTimeLocalL(recurrId.TimeLocalL() + TTimeIntervalMonths(1));  // July 1, 2003 00:00:00
				}
			else
				{
				//make sure the repeat time is out of the delete time range for the second half entries
				repeatStart.SetTimeLocalL(TDateTime(2003, EJune, 0, 0, 0, 0, 0));
				repeatend.SetTimeLocalL(TDateTime(2007, EJune, 0, 0, 0, 0, 0));
				}

			rpt.SetDtStart(repeatStart); 
			rpt.SetUntil(repeatend);
			entry->SetRRuleL(rpt);
			}
		}
	
	TInt entriesStored(0);
	iLocalEntryView->StoreL(iEntries, entriesStored); //temp
	test(entriesStored == iEntries.Count());
	}
Пример #10
0
void CTestApp::FillEntryL(CCalEntry& aEntry)
	{
	switch (aEntry.EntryTypeL())
		{
		case CCalEntry::EAppt:
			{
			aEntry.SetSummaryL(_L("appt"));

			// the appt spans midnight
			iCalTestLib->SetEntryStartAndEndTimeL(&aEntry, TTime(TDateTime(1995,EJanuary,0,20,15,0,0)), TTime(TDateTime(1995,EJanuary,1,5,15,0,0)) );

			// it repeats every 2 days and has and exception
			TCalRRule rRuleAppt(TCalRRule::EDaily);
			TCalTime dtStartAppt;
			dtStartAppt.SetTimeLocalL(TTime(TDateTime(1995,EJanuary,0,0,0,0,0)));
			TCalTime untilAppt;
			untilAppt.SetTimeLocalL(TTime(TDateTime(1995,EJanuary,9,0,0,0,0)));
			rRuleAppt.SetDtStart(dtStartAppt);
			rRuleAppt.SetUntil(untilAppt);
			rRuleAppt.SetInterval(2);
			aEntry.SetRRuleL(rRuleAppt);
			
			TCalTime exception;
			exception.SetTimeLocalL(TTime(TDateTime(1995,EJanuary,4,0,0,0,0)));
			RArray<TCalTime> exceptions;
			CleanupClosePushL(exceptions);
			exceptions.AppendL(exception);
			aEntry.SetExceptionDatesL(exceptions);
			CleanupStack::PopAndDestroy(&exceptions);
			break;
			}
	case CCalEntry::EEvent:
			{
			aEntry.SetSummaryL(_L("event"));
			iCalTestLib->SetEntryStartAndEndTimeL(&aEntry, TTime(TDateTime(1995,EJanuary,0,0,0,0,0)), TTime(TDateTime(1995,EJanuary,0,0,0,0,0)));
			break;
			}
	case CCalEntry::EAnniv:
			{
			aEntry.SetSummaryL(_L("anniv"));
			iCalTestLib->SetEntryStartAndEndTimeL(&aEntry, TTime(TDateTime(1995,EJanuary,0,0,0,0,0)), TTime(TDateTime(1995,EJanuary,0,0,0,0,0)));  // !!! WHAT'S THIS FOR ???
			
			TCalRRule rRuleAnniv(TCalRRule::EYearly);
			TCalTime dtStartAnniv;
			dtStartAnniv.SetTimeLocalL(TTime(TDateTime(1994,EJanuary,0,0,0,0,0)));
			TCalTime untilAnniv;
			untilAnniv.SetTimeLocalL(TCalTime::MaxTime());
			rRuleAnniv.SetDtStart(dtStartAnniv);
			rRuleAnniv.SetUntil(untilAnniv);
			rRuleAnniv.SetInterval(1);
			aEntry.SetRRuleL(rRuleAnniv);
			break;
			}
	case CCalEntry::ETodo:
			{
			aEntry.SetSummaryL(_L("todo"));
			aEntry.SetPriorityL(1);
			break;
			}
		}
	}
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);
	}
Пример #13
0
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
	}