Пример #1
0
TBool CDummyCalendarApp::CheckEntryNumL(TEntryType aType, TInt aNumEntry)
	{
	CCalIter& iter = GetIterL();	
	
	TPtrC8 Uid(iter.FirstL());

	TInt ii=0;
	while (Uid!=KNullDesC8())
		{
		++ii;
		
		RPointerArray<CCalEntry> entryList;
		CleanupResetAndDestroyPushL(entryList);
		iLocalEntryView->FetchL(Uid, entryList);
		CCalEntry* entry = entryList[0];
		if(aType==EApp)
			{
			test(entry->EntryTypeL()==CCalEntry::EAppt);
			}
		else if (aType==ETodo)
			{
			test(entry->EntryTypeL()==CCalEntry::ETodo);
			}
		else if(aType == EReminder)
			{
			test(entry->EntryTypeL()==CCalEntry::EReminder);
			}
			
		CleanupStack::PopAndDestroy(&entryList);
	    
		Uid.Set(iter.NextL());
		}

	return (ii==aNumEntry);
	}
// -----------------------------------------------------------------------------
// CPIMAgnEventAdapter::ReadRepeatFromAgnL
// Reads entry's repeat details and converts them into PIM repeat rule.
// -----------------------------------------------------------------------------
//
void CPIMAgnEventAdapter::ReadRepeatFromAgnL(MPIMEventItem& aItem,
        CCalEntry& aEntry)
{
    JELOG2(EPim);
    MPIMRepeatRuleData* repeatRuleData = aItem.GetRepeat();

    TCalRRule agnRRule;
    if (aEntry.GetRRuleL(agnRRule))
    {
        repeatRuleData->clear();

        PIMRepeatRuleConverter::ConvertSupportedRepeatToPIML(*repeatRuleData,
                agnRRule);

        CopyExceptionDatesToPimL(aEntry, *repeatRuleData);

        // Anniv does not need to have an end date, so clear that field to be sure
        if (aEntry.EntryTypeL() == CCalEntry::EAnniv)
        {
            repeatRuleData->ClearFieldL(EPIMRepeatRuleEnd);
        }

        aItem.SetRepeating(ETrue);
    }
    else
    {
        repeatRuleData->clear();
        aItem.SetRepeating(EFalse);
    }
}
Пример #3
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);
}
void CPIMAgnListAdapter::DoExternalItemModificationsByEntryTypeL(
    CCalEntry::TType aEntryType)
{
    JELOG2(EPim);
    EnsureOpenSessionL();

    if (!iChangesRead)
    {
        if (!iItemChangeArray)
        {
            iItemChangeArray
            = new(ELeave) RPointerArray<CPIMItemStateChange> (10);
        }

        // Read all the entries in the agenda file
        RPointerArray<CCalEntry> entryArray;
        CCalIter* iterator = CCalIter::NewL(*iCalSession);
        CleanupStack::PushL(iterator);

        const TDesC8* entryId = &(iterator->FirstL());
        while ((*entryId) != KNullDesC8())
        {
            iCalEntryView->FetchL(*entryId, entryArray);
            CleanupResetAndDestroyPushL(entryArray);

            // There should be at least one entry in the array. Other instances
            // will be ignored since child entries are currently not supported
            if (entryArray.Count() > 0)
            {
                // Get only the parent item from the array. Other items are
                // simply ignored since PIM API does not support them
                CCalEntry* entry = entryArray[0];
                // Check that the entry type is correct and add the item
                // to the change list
                if (entry->EntryTypeL() == aEntryType)
                {
                    HBufC8* changeId = entryId->AllocLC();
                    CPIMItemStateChange
                    * change =
                        new(ELeave) CPIMItemStateChange(changeId, EPIMExternalChangeNew);
                    CleanupStack::Pop(changeId);
                    CleanupStack::PushL(change);
                    iItemChangeArray->AppendL(change);
                    CleanupStack::Pop(change);
                }
            }
            CleanupStack::PopAndDestroy(&entryArray);
            // Get next calendar entry from the iterator
            entryId = &(iterator->NextL());
        }
        CleanupStack::PopAndDestroy(iterator);

        iChangesRead = ETrue;
    }
}
// -----------------------------------------------------------------------------
// CPIMAgnEventAdapter::ConvertRepeatToAgnL
// Makes conversion from framework PIM item repeat rule to native entry repeat.
// -----------------------------------------------------------------------------
//
void CPIMAgnEventAdapter::ConvertRepeatToAgnL(
    const MPIMEventItem& aEventItemData, CCalEntry& aAgnEntry)
{
    JELOG2(EPim);
    const MPIMRepeatRuleData* repeatRuleData = aEventItemData.GetRepeat();

    TTime eventStart = aAgnEntry.StartTimeL().TimeUtcL();

    TCalRRule agnRRule = PIMRepeatRuleConverter::ConvertSupportedRepeatToAgnL(
                             *repeatRuleData, eventStart);

    if ((aAgnEntry.EntryTypeL() == CCalEntry::EAnniv) && (agnRRule.Type()
            != TCalRRule::EYearly))
    {
        User::Leave(KErrArgument);
    }

    if (agnRRule.Type() == TCalRRule::EWeekly)
    {
        __ASSERT_ALWAYS(agnRRule.Interval() <= 2, User::Leave(KErrArgument));
    }
    else // other than weekly
    {
        __ASSERT_ALWAYS(agnRRule.Interval() == 1, User::Leave(KErrArgument));
    }

    // Use local time to check the day since UTC times provide incorrect
    // results if the compared dates are near midnight
    TTime untilLocal = agnRRule.Until().TimeLocalL();
    TTime startLocal = aAgnEntry.StartTimeL().TimeLocalL();
    // Validate that repeat rule is correct. The end of the repeat rule
    // must be greater than the event start and it must not be within
    // the same day as the start of the event
    if (untilLocal != Time::NullTTime())
    {
        __ASSERT_ALWAYS(untilLocal >= startLocal, User::Leave(KErrAbort));
        TTimeIntervalDays intervalDays = untilLocal.DaysFrom(startLocal);
        // Interval smaller than one day. Check that the day is not the same
        if (intervalDays < TTimeIntervalDays(1))
        {
            __ASSERT_ALWAYS(untilLocal.DateTime().Day()
                            != startLocal.DateTime().Day(), User::Leave(KErrAbort));
        }
    }

    // Repeat Rules OK
    aAgnEntry.SetRRuleL(agnRRule);
    CopyExceptionDatesToAgnL(*repeatRuleData, aAgnEntry);
}
// -----------------------------------------------------------------------------
// CPIMAgnEventAdapter::ReadAlarmFromAgnL
// Reads alarm offset from the native Calendar entry. In case of Anniversary,
// the offset is calculated from the midnight since native Calendar supports
// only dates in these types of entries
// -----------------------------------------------------------------------------
//
void CPIMAgnEventAdapter::ReadAlarmFromAgnL(MPIMEventItem& aItem,
        CCalEntry& aEntry)
{
    JELOG2(EPim);
    CCalAlarm* calAlarm = aEntry.AlarmL();
    // The previous function call returns NULL if there is no alarm
    // set in the item. The ownership is transferred to the caller
    // if the alarm values has been added to the item.
    if (calAlarm)
    {
        TTimeIntervalMinutes nativeValue = calAlarm->TimeOffset();
        // The alarm is not needed anymore so it can be deleted
        delete calAlarm;
        calAlarm = NULL;
        //            nativeValue.Int() );
        // Convert the alarm value based on the start time of the entry
        CCalEntry::TType entryType = aEntry.EntryTypeL();
        // Events (memos) and anniversaries do not have time in the native
        // side, therefore alarm field in those entries need to be calculated
        // from the end of the day
        if (entryType == CCalEntry::EAnniv)
        {
            TTime start(aEntry.StartTimeL().TimeLocalL());
            // Change the time to the end of the start date
            TTime startOfDayLocal(start);
            startOfDayLocal = StartOfDay(startOfDayLocal);
            // Calculate the difference from end of day and start time including
            // the original alarm offset which was previously read
            TTimeIntervalMinutes temp(0);
            User::LeaveIfError(startOfDayLocal.MinutesFrom(start, temp));
            // Since it is not possible to substract TTimeIntervalMinutes
            // from TTime (probably a Symbian error), the difference has
            // to be calculated using the following way...
            nativeValue = nativeValue.Int() + temp.Int();
        }
        TInt alarmValue = nativeValue.Int() * KPIMSecondsInMinute;
        //            alarmValue );
        // Add alarm value to the item
        TPIMFieldData fieldData(EPIMEventAlarm, EPIMFieldInt, KPIMAttrNone,
                                alarmValue);
        aItem.ItemData().AddValueL(fieldData);
    }
}
void CMultiThreadTestApp::DeleteEntryL(CCalEntryView& aView, CCalEntry::TType aType, TBool aIsSynchronous)
	{
	TCalTime minTime;
	minTime.SetTimeUtcL(TCalTime::MinTime());
	TCalTime maxTime;
	maxTime.SetTimeUtcL(TCalTime::MaxTime());

	if(aIsSynchronous)
		{
		RPointerArray<CCalEntry> entries;
		CleanupResetAndDestroyPushL(entries);
		FetchEntryL(aView, entries);
		TInt count = entries.Count();
		for (TInt ii = 0; ii < count; ++ii)
			{
			CCalEntry* entry = entries[ii];
			if(entry->EntryTypeL() == aType)
				{
				aView.DeleteL(*entry);	
				}
			}
		CleanupStack::PopAndDestroy(&entries);
		}
	else
		{
		const CalCommon::TCalTimeRange timeRange(minTime, maxTime);
		CalCommon::TCalViewFilter filter;
		if(aType==CCalEntry::EAppt)
			{
			filter = CalCommon::EIncludeAppts;	
			}
		else
			{
			filter = ~ (CalCommon::EIncludeAll & CalCommon::EIncludeAppts);	
			}
		aView.DeleteL(timeRange, filter, *this);	
		}
	}
Пример #8
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;
			}
		}
	}