Пример #1
0
void OrganizerItemTypeTransform::transformToDetailL(const CCalEntry& entry, QOrganizerItem *item)
{
    CCalEntry::TType entryType = entry.EntryTypeL();
    QString itemType;

    if (entryType == CCalEntry::ETodo) {
        // Assume this is an occurrence if the recurrence id is set
        if (entry.RecurrenceIdL().TimeUtcL() != Time::NullTTime())
            itemType = QLatin1String(QOrganizerItemType::TypeTodoOccurrence);
        else
            itemType = QLatin1String(QOrganizerItemType::TypeTodo);
    }
    else if (entryType == CCalEntry::EEvent || entryType == CCalEntry::EAppt) {
        // Assume this is an occurrence if the recurrence id is set
        if (entry.RecurrenceIdL().TimeUtcL() != Time::NullTTime())
            itemType = QLatin1String(QOrganizerItemType::TypeEventOccurrence);
        else
            itemType = QLatin1String(QOrganizerItemType::TypeEvent);
    }
    else if (entryType == CCalEntry::EAnniv)
        itemType = QLatin1String(QOrganizerItemType::TypeEvent);
#ifdef AGENDA_EXT_SUPPORT
    else if (CCalEntry::ENote == entryType) {
        itemType = QLatin1String(QOrganizerItemType::TypeNote);
    }
#endif
    else
        User::Leave(KErrUnknown); // unknown type

    item->setType(itemType);
}
/** Fetch the entry and check the properties that are set.
@param	aGuid Data for fetching the entry.
@param	aEntryProperties Structure containing the entry properties
*/
void CTestCalInterimApiFetchEntryAndCheckData::FetchAndCheckDataL(const TPtrC& aGuid, const TInt& aExpectedCount,
															   const TEntryProperties& aEntryProperties, const TPtrC& aTimeMode)
	{
	RPointerArray<CCalEntry>	entriesFetched;
	CleanupStack::PushL(TCleanupItem(ResetAndDestroyEntryArray, &entriesFetched));
	HBufC8*		entryId = HBufC8::NewLC(aGuid.Length());
	entryId->Des().Copy(aGuid);
	iCalEntryView->FetchL(entryId->Des(), entriesFetched);
	CleanupStack::PopAndDestroy(entryId);
	TBool	matchInRecurrenceId = EFalse;
	if ( entriesFetched.Count() == aExpectedCount )
		{
		for ( TInt i = 0; i < entriesFetched.Count(); i++ )
			{
			CCalEntry*	calEntry = entriesFetched[i];
			if ( aEntryProperties.iRecurrenceId == KNullDesC16() ) // Parent Entry
				{
				if ( calEntry->RecurrenceIdL().TimeUtcL() == Time::NullTTime() )
					{
					// Checks the data for the parent entry
					CheckDataL(calEntry, aEntryProperties);
					}
				}
			else // Child Entry
				{
				TTime		recurrenceIdValue;
				recurrenceIdValue.Set(aEntryProperties.iRecurrenceId);
				TCalTime	recurrenceId;
				// Sets the time mode to floating or Utc based on the time mode given
				SetCalTimeL(recurrenceIdValue, iRecurrenceId, SetTimeMode(aTimeMode));
				if (iRecurrenceId.TimeUtcL() == (calEntry->RecurrenceIdL().TimeUtcL()) )
					{
					matchInRecurrenceId = ETrue;
					// Checks the data for the child entry
					CheckDataL(calEntry, aEntryProperties);
					}
				}
			}
		INFO_PRINTF3(KInfoEntryFetched, entriesFetched.Count(), aExpectedCount)	;
		}
	else
		{
		ERR_PRINTF3(KErrExpectedCount, entriesFetched.Count(), aExpectedCount);
		SetTestStepResult(EFail);
		}
	/* If the recurrence Id doesn't match with the recurrenceId of the child entry
	then, print a warning message */
	if (aEntryProperties.iRecurrenceId != KNullDesC16() && matchInRecurrenceId == 0)
		{
		WARN_PRINTF1(KWarnNoMatchInRecurrenceId);
		}
	CleanupStack::PopAndDestroy(&entriesFetched);
	}
Пример #3
0
// Helper method
// Extract all entries given by Guids in iCurrentTestData
void CDummyCalendarApp::ExtractEntriesL(TBool aCompareWithExpectedNum, TInt aExpectedNum)
	{
	// Extract entries by the GUIDs given in current-test-data's iGuids
	for(TInt a = 0; a < iCurrentTestData->iGuidsToExtract.Count(); a++)
		{
		TPtrC8 guid = iCurrentTestData->iGuidsToExtract[a];
		
		RPointerArray<CCalEntry> entryArray;
		CleanupStack::PushL(TCleanupItem(ResetAndDestroyCalEntryArray, &entryArray));
		iEntryView->FetchL(guid, entryArray);
		
		test.Printf(_L("%d GS entries fetched\n"), entryArray.Count());

        if (aCompareWithExpectedNum)
            {
            test.Printf(_L("%d entries were expected"), aExpectedNum);
            test(entryArray.Count() == aExpectedNum);
            }

		CCalEntry* entryPtr;
		for(TInt a = 0; a < entryArray.Count(); a++)
			{
			entryPtr = entryArray[a];
			if(a==0)
				{
				test.Printf(_L("Parent -> SeqNum:%d\n"), entryPtr->SequenceNumberL());
				}
			else
				{
				TBuf<16> recIdTimeBuf;
				TTime recIdTime = entryPtr->RecurrenceIdL().TimeLocalL();
				recIdTime.FormatL(recIdTimeBuf, KFormatDate());
				
				test.Printf(_L("Child  -> SeqNum:%d, RecID: %S\n"), entryPtr->SequenceNumberL(), &recIdTimeBuf);
				}
			}
		
		CleanupStack::Pop(); // TCleanupItem(ResetAndDestroyCalEntryArray, &entryArray)
		entryArray.ResetAndDestroy();
		}
	}
Пример #4
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());
	}