// -----------------------------------------------------------------------------
// 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);
    }
}
Пример #2
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);
}
Пример #3
0
void OrganizerItemTimeStampTransform::transformToDetailL(const CCalEntry& entry, QOrganizerItem *item)
{
    QOrganizerItemTimestamp timeStamp = item->detail<QOrganizerItemTimestamp>();
    timeStamp.setCreated(toQDateTimeL(entry.DTStampL()));
    timeStamp.setLastModified(toQDateTimeL(entry.LastModifiedDateL()));
    item->saveDetail(&timeStamp);
}
// -----------------------------------------------------------------------------
// 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
    }
    }

}
void CCalAlarmAttachTest::TestFetchEntryAlarmContentL()
    {
    test.Printf(_L("Test fetching entry twice and check it alarm conten\n"));
    _LIT8(KEntryUidFetchEntry, "FetchEntryUid");
    CCalAlarm* alarm = StoreEntryWithAlarmContentLC(KEntryUidFetchEntry());
    RPointerArray<CCalEntry> entries;
    CleanupResetAndDestroyPushL(entries);

    //Fetch the entry and test the alarm  content
    iTestLib->SynCGetEntryViewL().FetchL(KEntryUidFetchEntry(), entries);
    TInt entriesStored = 0;
    iTestLib->SynCGetEntryViewL().StoreL(entries, entriesStored);
    entries.ResetAndDestroy();
    iTestLib->SynCGetEntryViewL().FetchL(KEntryUidFetchEntry(), entries);
    CCalEntry* entry = entries[0];
    test( KSummary() == entry->SummaryL() );
    test( KDescription() == entry->DescriptionL());
    TestAlarmL(entry, KContent(), KMimeType());
    entries.ResetAndDestroy();

    //Close the serve and fetch the entry again
    iTestLib->CloseAgendaServer();
    iTestLib->OpenFileL(KCalName());

    iTestLib->SynCGetEntryViewL().FetchL(KEntryUidFetchEntry(), entries);
    TestAlarmL(entries[0], KContent(), KMimeType());
    CleanupStack::PopAndDestroy(&entries);
    CleanupStack::PopAndDestroy(alarm);
    }
Пример #6
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);
	}
// -----------------------------------------------------------------------------
// 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);
}
// -----------------------------------------------------------------------------
// CPIMAgnToDoAdapter::ReadDateFieldsL
// (other items were commented in a header)
// -----------------------------------------------------------------------------
//
void CPIMAgnToDoAdapter::ReadDateFieldsL(MPIMItemData& aData, CCalEntry& aEntry)
{
    JELOG2(EPim);
    TTime nullTime = Time::NullTTime();
    // The Agenda todo entry end field is the due date
    TTime due(aEntry.EndTimeL().TimeLocalL());
    if (due != nullTime)
    {
        // Set due to the PIM API specific due date, in this case, the start of date
        // Note that PIM API uses times as UTC times so the due date must be in
        // correct format. Previously requested as local time -> do not change
        TPIMDate pimDueDate(StartOfDay(due));
        // Date must be converted UTC time because acquired as local above
        ConvertTimeL(pimDueDate, EPIMDateUTC);
        TPIMFieldData dueFieldData(EPIMToDoDue, KPIMAttrNone, pimDueDate);
        aData.AddValueL(dueFieldData);

        // Get alarm. Ownership is transferred to the caller. Alarm cannot be set
        // if the due date is not set because the calculation is done as an offset
        // from the ToDo due date.
        CCalAlarm* calAlarm = aEntry.AlarmL();
        if (calAlarm)
        {
            TTimeIntervalMinutes nativeValue = calAlarm->TimeOffset();
            // The alarm is not needed anymore so it can be deleted
            delete calAlarm;
            calAlarm = NULL;
            // Change the time to the start of the due date
            TTime startOfDayLocal(StartOfDay(due));
            // Calculate the difference from the start of due date and start time including
            // the original alarm offset which was previously read
            TTimeIntervalMinutes temp(0);
            User::LeaveIfError(startOfDayLocal.MinutesFrom(due, 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...
            TInt alarm = (nativeValue.Int() + temp.Int()) * KPIMSecondsInMinute;
            // Add alarm value to the item
            TPIMFieldData fieldData(EPIMToDoExtAlarm, EPIMFieldInt,
                                    KPIMAttrNone, alarm);
            // Add value to the PIM item data
            aData.AddValueL(fieldData);
        }
    }

    // Completion date. If the item has a completion date, the item is then completed
    // and completed flag is set to true in PIM API. Null time if not crossed out.
    TTime completed = aEntry.CompletedTimeL().TimeUtcL();
    if (completed != nullTime)
    {
        TPIMFieldData dateData(EPIMToDoCompletionDate, KPIMAttrNone, completed);
        aData.AddValueL(dateData);
        // Note that boolean and integer fields must be identified in the constructor
        TPIMFieldData flag(EPIMToDoCompleted, EPIMFieldBoolean, KPIMAttrNone,
                           ETrue);
        aData.AddValueL(flag);
    }
}
// -----------------------------------------------------------------------------
// CPIMAgnEventAdapter::ConvertAlarmToAgnL
// Converts alarm from PIM item to a native entry. The alarm is calculated
// from the start date of the event and if it is not present, the alarm field
// is ignored because there is no possibility to calculate it
// -----------------------------------------------------------------------------
//
void CPIMAgnEventAdapter::ConvertAlarmToAgnL(const MPIMEventItem& aItem,
        CCalEntry& aEntry)
{
    JELOG2(EPim);
    const MPIMItemData& itemData = aItem.ItemData();

    // Note that start time must be set before alarm can be calculated
    // Add start to the item so alarm can be properly converted. The
    // native entry does not accept alarm value if start is not present

    if (itemData.CountValues(EPIMEventStart) == 0)
    {
        User::Leave(KErrArgument);
    }
    else
    {
        ConvertDateFieldToAgnL(aItem, aEntry, EPIMEventStart);
    }

    __ASSERT_DEBUG(aEntry.StartTimeL().TimeUtcL() != Time::NullTTime(),
                   User::Panic(KPIMPanicCategory, EPIMPanicInvalidState));

    // Get alarm value from the Java item. There should be only one alarm
    // value supported by the PIM API because native entries do not support
    // multiple alarm values.
    const TPIMFieldData alarmData = itemData.ValueL(EPIMEventAlarm, 0);
    TInt value = alarmData.IntegerValue();

    // Count the alarm value from the start date of the event
    TTime entryStart = aEntry.StartTimeL().TimeLocalL();
    const TPIMFieldData startData = itemData.ValueL(EPIMEventStart, 0);
    TPIMDate startTime = startData.DateValue();
    ConvertTimeL(startTime, EPIMDateLocal);
    TTimeIntervalSeconds temp(0);
    User::LeaveIfError(entryStart.SecondsFrom(startTime, temp));

    // Add difference between PIM API start and start which has been
    // converted to the item (in case if the date has been changed, it is
    // reflected here)
    value += temp.Int();

    // Check that if the alarm has passed to the following day. In this case,
    // the alarm is transferred back to 12 o'clock of the current start date
    TTime alarmTime(entryStart - TTimeIntervalSeconds(value));
    // Temporary date. This date is used when calculating if the alarm
    // value has passed to the following date.
    TTime startOfNextDay(StartOfDay(startTime + TTimeIntervalDays(1)));
    if (alarmTime >= startOfNextDay)
    {
        alarmTime = StartOfDay(entryStart);
        alarmTime += TTimeIntervalSeconds(KPIMDefaultAlarmInterval);
        User::LeaveIfError(entryStart.SecondsFrom(alarmTime, temp));
        value = temp.Int();
    }
    // Convert the alarm value to the native entry
    SetAlarmToEntryL(aEntry, value);
}
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;
    }
}
// -----------------------------------------------------------------------------
// CPIMAgnToDoAdapter::ConvertDateToAgnL
// Makes date conversion from framework PIM item data field to To-do item field.
// -----------------------------------------------------------------------------
//
void CPIMAgnToDoAdapter::ConvertDateToAgnL(TPIMToDoField aField, // Date field to be converted
        TInt aIndex, // Index of the date field
        CCalEntry& aEntry, const MPIMItemData& aItem) // The PIM item to read the field from
{
    JELOG2(EPim);
    const TPIMFieldData fieldData = aItem.ValueL(aField, aIndex);
    const TPIMDate& date = fieldData.DateValue();
    switch (aField)
    {
    case EPIMToDoDue:
    {
        // Because undated to-dos are possible, the due date can be set
        // to a null value.
        if (date != Time::NullTTime() && !IsDateInValidAgendaRange(date))
        {
            User::Leave(KErrAbort);
        }
        // Java dates cannot be set to native null TTime
        else
        {
            // Convert due date and time to calendar specific due time
            // Note that PIM API dates are in UTC time format -> convert
            TTime dueDate(date);
            ConvertTimeL(dueDate, EPIMDateLocal);
            // Set time to native entry. Note that the time is local
            TCalTime calDate;
            calDate.SetTimeLocalL(StartOfDay(dueDate));
            aEntry.SetStartAndEndTimeL(calDate, calDate);
        }
        break;
    }
    case EPIMToDoCompletionDate:
    {
        if (date != Time::NullTTime())
        {
            __ASSERT_ALWAYS(IsDateInValidAgendaRange(date), User::Leave(
                                KErrAbort));
            TCalTime calDate;
            calDate.SetTimeUtcL(date);
            aEntry.SetCompletedL(ETrue, calDate);
        }
        else
        {
            aEntry.SetCompletedL(EFalse, aEntry.CompletedTimeL());
        }
        break;
    }
    default:
    {
        __ASSERT_DEBUG(EFalse, User::Panic(KPIMPanicCategory,
                                           EPIMPanicUnsupportedField));
    }
    }
}
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);
	}
/** 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);
	}
void OrganizerJournalTimeTransform::transformToDetailL(const CCalEntry& entry, QOrganizerItem *item)
{
    if (item->type() == QOrganizerItemType::TypeJournal)
    {
        TCalTime dtstamp = entry.DTStampL(); // TODO: is DTStamp correct?
        if (dtstamp.TimeUtcL() != Time::NullTTime()) {
            QOrganizerJournalTime range;
            range.setEntryDateTime(toQDateTimeL(entry.DTStampL()));
            item->saveDetail(&range);
        }
    }
}
Пример #16
0
TInt CheckTimezoneRules(const CCalEntry& aCalEntry)
	{
	//See if timezone rules are present, if they are then times should be UTC and not floating
	//
	CTzRules* tzRules = aCalEntry.TzRulesL();
	TCalTime startTime = aCalEntry.StartTimeL();
	if (tzRules)
		{
		test (startTime.TimeMode() !=  TCalTime::EFloating);
		}
	
	return KErrNone;
	}
Пример #17
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());
	}
// -----------------------------------------------------------------------------
// CPIMAgnToDoAdapter::ConvertBooleanToAgnL
// Makes boolean conversion from framework PIM item data field to To-do item field
// -----------------------------------------------------------------------------
//
void CPIMAgnToDoAdapter::ConvertBooleanToAgnL(TPIMToDoField aField, // Boolean field to be converted
        TInt aIndex, // Index of the date field
        CCalEntry& aEntry, // The Agenda model entry typecasted to a Todo item
        const MPIMItemData& aItem) // The PIM item to read the field from
{
    JELOG2(EPim);
    const TPIMFieldData fieldData = aItem.ValueL(aField, aIndex);
    TBool booleanField = fieldData.BooleanValue();

    if (booleanField) // completed flag is set to value TRUE
    {
        // Check if the completed date field is present
        if (aItem.CountValues(EPIMToDoCompletionDate) == 0)
        {
            // If completed date is not present, use the current time.
            TTime currentTime;
            currentTime.HomeTime();
            TCalTime calCurrentTime;
            // Set time as local time since acquired above as local time
            calCurrentTime.SetTimeLocalL(currentTime);
            aEntry.SetCompletedL(ETrue, calCurrentTime);
        }
        else
        {
            TPIMFieldData completionData = aItem.ValueL(EPIMToDoCompletionDate,
                                           aIndex);
            const TPIMDate& date = completionData.DateValue();
            if (date != Time::NullTTime())
            {
                TCalTime calDate;
                calDate.SetTimeUtcL(date);
                aEntry.SetCompletedL(ETrue, calDate);
            }
            else
            {
                // If completed date is set to null time, use the current time.
                TTime currentTime;
                currentTime.HomeTime();
                TCalTime calCurrentTime;
                // Set time as local time since acquired above as local time
                calCurrentTime.SetTimeLocalL(currentTime);
                aEntry.SetCompletedL(ETrue, calCurrentTime);
            }
        }
    }
    else // completed flag is set to value FALSE
    {
        aEntry.SetCompletedL(EFalse, aEntry.CompletedTimeL());
    }
}
// -----------------------------------------------------------------------------
// 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);
}
// -----------------------------------------------------------------------------
// CPIMAgnApptAdapter::UpdateItemToAgnL
// Reads an Agenda Model Appt item and updates it based on the PIM item data.
// -----------------------------------------------------------------------------
//
void CPIMAgnApptAdapter::UpdateItemToAgnL(const MPIMEventItem& aItem, // PIM Item Data
        CCalEntry& aEntry) // Agenda Model entry
{
    JELOG2(EPim);
    // Before updating values, empty the fields or set default values for the
    // fields that PIM api supports
    ClearPIMFieldsL(aEntry, KPIMSupportedApptFields,
                    KPIMSupportedApptFieldsCount);

    // Convert fields from Java side to the native side
    ConvertFieldsToAgnL(aItem, aEntry);
    // If there is a defined repeat rule, convert it also
    if (aItem.IsRepeating())
    {
        if (aItem.GetRepeat()->IsModified())
        {
            ConvertRepeatToAgnL(aItem, aEntry);
        }
    }
    else
    {
        // Clear the repeat, as it might have been removed.
        aEntry.ClearRepeatingPropertiesL();
    }
}
void OrganizerTodoTimeTransform::transformToDetailL(const CCalEntry& entry, QOrganizerItem *item)
{
    if(item->type() == QOrganizerItemType::TypeTodo
        || item->type() == QOrganizerItemType::TypeTodoOccurrence)
    {
        TCalTime startTime = entry.StartTimeL();
        TCalTime endTime = entry.EndTimeL();

        QOrganizerTodoTime range;
        if (startTime.TimeUtcL() != Time::NullTTime())
            range.setStartDateTime(toQDateTimeL(startTime));
        if (endTime.TimeUtcL() != Time::NullTTime())
            range.setDueDateTime(toQDateTimeL(endTime));

        if (!range.isEmpty())
            item->saveDetail(&range);
    }
}
// -----------------------------------------------------------------------------
// 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);
        }
        }
    }
}
Пример #23
0
void CDummyCalendarApp::AddFloatingEntryWithMinStartTimeL()
	{//Defect fix for PDEF111562  - when a floating entry with miniman start time will never get deleted.
	iEntries.ResetAndDestroy();

	_LIT8(KUid, "UID_MinEntry");
	HBufC8* guid = KUid().AllocLC();
	CCalEntry* entry = iTestLib->CreateCalEntryL(CCalEntry::EReminder, guid);
	CleanupStack::Pop(guid);
	CleanupStack::PushL(entry);
	TCalTime caltimestart,caltimeend;
	TTime min(TDateTime(1900, EJanuary, 0, 0, 0, 0, 0));
	caltimestart.SetTimeLocalFloatingL(min);
	entry->SetStartAndEndTimeL(caltimestart,caltimestart);
	iEntries.AppendL(entry);
	CleanupStack::Pop(entry);
	TInt entriesStored(0);
	SynCGetEntryViewL().StoreL(iEntries, entriesStored); //temp
	iEntries.ResetAndDestroy();	
	}
// -----------------------------------------------------------------------------
// 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);
    }
}
// -----------------------------------------------------------------------------
// 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);
}
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::AddDefaultValuesToEntryL
// -----------------------------------------------------------------------------
//
void CPIMAgnEventAdapter::AddDefaultValuesToEntryL(const MPIMEventItem& aItem,
        CCalEntry& aEntry) const
{
    JELOG2(EPim);
    const MPIMItemData& data = aItem.ItemData();
    // Default calendar synchronisation is private
    if (data.CountValues(EPIMEventClass) == 0)
    {
        aEntry.SetReplicationStatusL(CCalEntry::EPrivate);
    }
}
// -----------------------------------------------------------------------------
// CPIMAgnApptAdapter::ReadEndFromAgnL
// Reads Agenda entry's end field and converts it into PIM Item field.
// -----------------------------------------------------------------------------
//
void CPIMAgnApptAdapter::ReadEndFromAgnL(MPIMEventItem& aItem,
        CCalEntry& aEntry)
{
    JELOG2(EPim);
    TTime agnEndTime = aEntry.EndTimeL().TimeUtcL();
    if (agnEndTime != Time::NullTTime())
    {
        TPIMFieldData fieldData(EPIMEventEnd, KPIMAttrNone, agnEndTime);
        aItem.ItemData().AddValueL(fieldData);
    }
}
// -----------------------------------------------------------------------------
// CPIMAgnEventAdapter::SetAlarmToEntryL
// Sets the native entry alarm field.
// -----------------------------------------------------------------------------
//
void CPIMAgnEventAdapter::SetAlarmToEntryL(CCalEntry& aEntry, const TInt aValue) const
{
    JELOG2(EPim);
    TTimeIntervalMinutes offMin(aValue / KPIMSecondsInMinute);
    CCalAlarm* agnAlarm = CCalAlarm::NewL();
    agnAlarm->SetTimeOffset(offMin);

    CleanupStack::PushL(agnAlarm);
    aEntry.SetAlarmL(agnAlarm);
    CleanupStack::PopAndDestroy(agnAlarm);
}
Пример #30
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();
		}
	}