pimappservices/calendar/shared/src/agmentry.cpp
branchRCL_3
changeset 30 bd7edf625bdd
parent 29 12af337248b1
child 31 97232defd20e
equal deleted inserted replaced
29:12af337248b1 30:bd7edf625bdd
    33 
    33 
    34 //---------------------------------- CAgnEntry ------------------------------------------
    34 //---------------------------------- CAgnEntry ------------------------------------------
    35 
    35 
    36 EXPORT_C CAgnEntry* CAgnEntry::NewL(CCalEntry::TType aType)
    36 EXPORT_C CAgnEntry* CAgnEntry::NewL(CCalEntry::TType aType)
    37 	{
    37 	{
    38 	__ASSERT_ALWAYS(aType>=CCalEntry::EAppt && aType<=CCalEntry::ENote, Panic(EAgmErrBadTypeEntry));
    38 	__ASSERT_ALWAYS(aType>=CCalEntry::EAppt && aType<=CCalEntry::EAnniv, Panic(EAgmErrBadTypeEntry));
    39 	// allocate a CAgnEntry object, which invokes the CAgnSimpleEntry new operator, but passing no allocator
    39 	// allocate a CAgnEntry object, which invokes the CAgnSimpleEntry new operator, but passing no allocator
    40 	// this makes the CAgnSimpleEntry new operator use the default new operator
    40 	// this makes the CAgnSimpleEntry new operator use the default new operator
    41 	
    41 	
    42 	return new (ELeave, NULL) CAgnEntry(aType);;
    42 	return new (ELeave, NULL) CAgnEntry(aType);;
    43 	}
    43 	}
    50 		
    50 		
    51 	CCalEntry::TType type=CCalEntry::TType(typeData);
    51 	CCalEntry::TType type=CCalEntry::TType(typeData);
    52 	
    52 	
    53 	__ASSERT_ALWAYS(type==CCalEntry::EAppt || type==CCalEntry::EEvent ||
    53 	__ASSERT_ALWAYS(type==CCalEntry::EAppt || type==CCalEntry::EEvent ||
    54 					type==CCalEntry::EAnniv || type==CCalEntry::ETodo ||
    54 					type==CCalEntry::EAnniv || type==CCalEntry::ETodo ||
    55 					type==CCalEntry::EReminder || type == CCalEntry::ENote,
    55 					type==CCalEntry::EReminder, User::Leave(KErrCorrupt));
    56 					User::Leave(KErrCorrupt));
       
    57 
    56 
    58 	CAgnEntry* entry = CAgnEntry::NewL(type);
    57 	CAgnEntry* entry = CAgnEntry::NewL(type);
    59 	CleanupStack::PushL(entry);
    58 	CleanupStack::PushL(entry);
    60 	entry->InternalizeL(aStream);
    59 	entry->InternalizeL(aStream);
    61 	CleanupStack::Pop();
    60 	CleanupStack::Pop();
   236 		return EFalse;
   235 		return EFalse;
   237 		}	
   236 		}	
   238 		
   237 		
   239 	// Compare the user integer.
   238 	// Compare the user integer.
   240 	if (UserInt() != aEntry.UserInt())
   239 	if (UserInt() != aEntry.UserInt())
   241 		{
   240 	    {
   242 		return EFalse;
   241 	    return EFalse;
   243 		}	
   242 	    }	
   244 	
   243 	
   245 	if ( DTStampUtcL() != aEntry.DTStampUtcL() )
   244 	if ( DTStampUtcL() != aEntry.DTStampUtcL() )
   246 		{
   245 		{
   247 		return EFalse;
   246 		return EFalse;
   248 		}
   247 		}
   684 			{
   683 			{
   685 			aStream << Attachment(i);
   684 			aStream << Attachment(i);
   686 			}
   685 			}
   687 		}
   686 		}
   688 
   687 
   689 	// Set the user integer of the stream.
   688     // Set the user integer of the stream.
   690 	aStream.WriteInt32L( UserInt() );
   689 	aStream.WriteInt32L( UserInt() );
   691 	
   690 	
   692 	// future DC proofing
   691 	// future DC proofing
   693 	aStream.WriteUint32L(0); // number of bytes until end of entry
   692 	aStream.WriteUint32L(0); // number of bytes until end of entry
   694 	}
   693 	}
  1853 
  1852 
  1854 @param aUserInt The new value of the user integer. 
  1853 @param aUserInt The new value of the user integer. 
  1855 @internalComponent
  1854 @internalComponent
  1856 */
  1855 */
  1857 EXPORT_C void CAgnEntry::SetUserInt( TUint32 aUserInt )
  1856 EXPORT_C void CAgnEntry::SetUserInt( TUint32 aUserInt )
  1858 	{
  1857     {
  1859 	CAgnSimpleEntry::SetUserInt(aUserInt);
  1858     CAgnSimpleEntry::SetUserInt(aUserInt);
  1860 	}
  1859     }
  1861 
  1860 
  1862 /**
  1861 /**
  1863 Gets the user integer of this entry.
  1862 Gets the user integer of this entry.
  1864 
  1863 
  1865 @return The user integer.
  1864 @return The user integer.
  1866 @internalComponent
  1865 @internalComponent
  1867 */
  1866 */
  1868 EXPORT_C TUint32 CAgnEntry::UserInt() const
  1867 EXPORT_C TUint32 CAgnEntry::UserInt() const
  1869 	{
  1868     {
  1870 	return CAgnSimpleEntry::UserInt();
  1869     return CAgnSimpleEntry::UserInt();
  1871 	}
  1870     }
  1872 
  1871 
  1873 EXPORT_C void CAgnEntry::ExternalizeToBufferL(RWriteStream& aWriteStream) const
  1872 EXPORT_C void CAgnEntry::ExternalizeToBufferL(RWriteStream& aWriteStream) const
  1874 /** Used for passing the data to the between client and server
  1873 /** Used for passing the data to the between client and server
  1875 @internalComponent
  1874 @internalComponent
  1876 */
  1875 */
  2008 	}
  2007 	}
  2009 
  2008 
  2010 // verify entry is valid before storing it
  2009 // verify entry is valid before storing it
  2011 EXPORT_C void CAgnEntry::VerifyBeforeStoreL()
  2010 EXPORT_C void CAgnEntry::VerifyBeforeStoreL()
  2012 	{
  2011 	{
  2013 	// check for entry type note
       
  2014 	if( Type() == CCalEntry::ENote  && !StartTime().IsSet())
       
  2015 		{
       
  2016 		// read the modfication time from simple entry
       
  2017 		TAgnCalendarTime agnStartTime;
       
  2018 		agnStartTime.SetUtcL(CAgnSimpleEntry::LastModifiedDateUtc());
       
  2019 
       
  2020 		TAgnCalendarTime agnEndTime = agnStartTime;
       
  2021 		// set the modification time as start and end time
       
  2022 		CAgnSimpleEntry::SetStartAndEndTimeL(agnStartTime, agnEndTime);
       
  2023 		}
       
  2024 
       
  2025 	//Check entry time
  2012 	//Check entry time
  2026 	if ( Type() != CCalEntry::ETodo )
  2013 	if ( Type() != CCalEntry::ETodo )
  2027 		{
  2014 		{
  2028 		__ASSERT_ALWAYS(StartTime().IsSet(), Panic(EAgmErrTimeNotSet));
  2015 		__ASSERT_ALWAYS(StartTime().IsSet(), Panic(EAgmErrTimeNotSet));
  2029 		if ( Type() != CCalEntry::EReminder )
  2016 		if ( Type() != CCalEntry::EReminder )