// -----------------------------------------------------------------------------
// CPIMAgnToDoAdapter::ReadIntFieldsL
// (other items were commented in a header)
// -----------------------------------------------------------------------------
//
void CPIMAgnToDoAdapter::ReadIntFieldsL(MPIMItemData& aData, CCalEntry& aEntry)
{
    JELOG2(EPim);
    // Convert synchornization field to PIM API. The default value is private
    // and unrecognized priority values are mapped also to private due to
    // security reasons
    TPIMToDoClassValue value = EPIMToDoClassPrivate;
    const CCalEntry::TReplicationStatus status = aEntry.ReplicationStatusL();
    if (status == CCalEntry::EOpen)
    {
        // Open is mapped as public synhronization
        value = EPIMToDoClassPublic;
    }
    else if (status == CCalEntry::ERestricted)
    {
        // Open is mapped as user confidential synhronization
        value = EPIMToDoClassConfidential;
    }
    // Note that boolean and integer fields must be identified in the constructor
    TPIMFieldData classData(EPIMToDoClass, EPIMFieldInt, KPIMAttrNone, value);
    aData.AddValueL(classData);

    // Default value is zero acording to vCalendar specification. PIM API default
    // priority is medium which indicates normal native priority
    // See common/pimtodo.h for platform-specific native priorities.
    TUint nativePriority = aEntry.PriorityL();
    TPIMToDoPriority priority = EPIMToDoPriorityMedium;
    if (nativePriority == EPIMToDoNativePriorityHigh)
    {
        // Native priority value High is mapped to value 1
        priority = EPIMToDoPriorityHigh;
    }
    else if (nativePriority == EPIMToDoNativePriorityLow)
    {
        // Native priority value Low is mapped to value 7
        priority = EPIMToDoPriorityLow;
    }
    // Note that boolean and integer fields must be identified in the constructor
    TPIMFieldData
    prData(EPIMToDoPriority, EPIMFieldInt, KPIMAttrNone, priority);
    aData.AddValueL(prData);
}
// -----------------------------------------------------------------------------
// CPIMAgnEventAdapter::ReadClassFromAgnL
// Reads entry's class details and converts them into PIM class.
// -----------------------------------------------------------------------------
//
void CPIMAgnEventAdapter::ReadClassFromAgnL(MPIMEventItem& aItem,
        CCalEntry& aEntry)
{
    JELOG2(EPim);
    TPIMEventClassValue eClassValue = EPIMEventClassPrivate;
    const CCalEntry::TReplicationStatus replicationStatus =
        aEntry.ReplicationStatusL();

    // Map calendar entry values to pim value
    switch (replicationStatus)
    {
    case CCalEntry::EOpen:
    {
        eClassValue = EPIMEventClassPublic;
        break;
    }
    case CCalEntry::EPrivate:
    {
        eClassValue = EPIMEventClassPrivate;
        break;
    }
    case CCalEntry::ERestricted:
    {
        eClassValue = EPIMEventClassConfidential;
        break;
    }
    default:
    {
        User::Leave(KErrArgument);
        break;
    }
    }
    TPIMFieldData fieldData(EPIMEventClass, EPIMFieldInt, KPIMAttrNone,
                            eClassValue);
    // Set value for the class item
    aItem.ItemData().AddValueL(fieldData);
}