// -----------------------------------------------------------------------------
// 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::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);
}
Пример #3
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;
			}
		}
	}
// -----------------------------------------------------------------------------
// CPIMAgnToDoAdapter::ConvertIntToAgnL
// Makes int conversion from framework PIM item data field to To-do item field.
// -----------------------------------------------------------------------------
//
void CPIMAgnToDoAdapter::ConvertIntToAgnL(TPIMToDoField aField, // Int field to be converted
        TInt aIndex, // Index of the date field
        CCalEntry& aEntry, // The Agenda model entry typecasted to a Todo item
        const MPIMItemData& aItemData) // The PIM item to read the field from
{
    JELOG2(EPim);
    const TPIMFieldData fieldData = aItemData.ValueL(aField, aIndex);
    switch (aField)
    {
    case EPIMToDoPriority:
    {
        TInt intField = fieldData.IntegerValue();

        if ((EPIMToDoPriorityHigh <= intField) && (intField
                < EPIMToDoPriorityMedium))
        {
            aEntry.SetPriorityL(EPIMToDoNativePriorityHigh);
        }
        else if ((EPIMToDoPriorityMedium <= intField) && (intField
                 < EPIMToDoPriorityLow))
        {
            aEntry.SetPriorityL(EPIMToDoNativePriorityMedium);
        }
        else if ((EPIMToDoPriorityLow <= intField) && (intField
                 <= EPIMToDoPriorityMaxValue))
        {
            aEntry.SetPriorityL(EPIMToDoNativePriorityLow);
        }
        else
        {
            // From requirement specification: Imported to-do items with
            // priority set to zero must be mapped to the native priority
            // value Medium.
            aEntry.SetPriorityL(EPIMToDoNativePriorityMedium);
        }
        break;
    }
    case EPIMToDoClass:
    {
        CCalEntry::TReplicationStatus replicationStatus = CCalEntry::EPrivate;

        // Single value assumed
        TInt classValue = fieldData.IntegerValue();

        switch (classValue)
        {
        case EPIMToDoClassPrivate:
        {
            replicationStatus = CCalEntry::EPrivate;
            break;
        }
        case EPIMToDoClassConfidential:
        {
            replicationStatus = CCalEntry::ERestricted;
            break;
        }
        case EPIMToDoClassPublic:
        {
            replicationStatus = CCalEntry::EOpen;
            break;
        }
        default:
        {
            User::Leave(KErrArgument);
            break;
        }
        }
        aEntry.SetReplicationStatusL(replicationStatus);
        break;
    }
    case EPIMToDoExtAlarm:
    {
        CCalAlarm* agnAlarm = CCalAlarm::NewL();
        CleanupStack::PushL(agnAlarm);
        agnAlarm->SetTimeOffset(AlarmOffsetL(aItemData, aEntry));
        aEntry.SetAlarmL(agnAlarm);
        CleanupStack::PopAndDestroy(agnAlarm);
        break;
    }
    default:
    {
        // Should not happen
        __ASSERT_DEBUG(EFalse, User::Invariant());
    }
    }
}