pimappservices/calendar/shared/src/agmentry.cpp
changeset 89 b57382753122
parent 18 c198609911f9
equal deleted inserted replaced
83:5aadd1120515 89:b57382753122
    27 #include <calentry.h>
    27 #include <calentry.h>
    28 //#include "calentryimpl.h"
    28 //#include "calentryimpl.h"
    29 #include <e32math.h>
    29 #include <e32math.h>
    30 
    30 
    31 #include <asshddefs.h>
    31 #include <asshddefs.h>
    32 
    32 #define KUserDataInt 4 
    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 		}
   410 	if ( Location() != aEntry.Location() )
   409 	if ( Location() != aEntry.Location() )
   411 		{
   410 		{
   412 		return EFalse;
   411 		return EFalse;
   413 		}
   412 		}
   414 	
   413 	
       
   414     if ( UserDataInt() != aEntry.UserDataInt() )     
       
   415         {       
       
   416         return EFalse;       
       
   417         }   
       
   418     
   415 	return ETrue;
   419 	return ETrue;
   416 	}
   420 	}
   417 
   421 
   418 
   422 
   419 EXPORT_C const TDesC& CAgnEntry::AlarmSoundName() const
   423 EXPORT_C const TDesC& CAgnEntry::AlarmSoundName() const
   684 			{
   688 			{
   685 			aStream << Attachment(i);
   689 			aStream << Attachment(i);
   686 			}
   690 			}
   687 		}
   691 		}
   688 
   692 
   689 	// Set the user integer of the stream.
   693     // Set the user integer of the stream.
   690 	aStream.WriteInt32L( UserInt() );
   694 	aStream.WriteInt32L( UserInt() );
   691 	
   695 
   692 	// future DC proofing
   696     TInt skipCount( 0 );
   693 	aStream.WriteUint32L(0); // number of bytes until end of entry
   697     //skip count(4) for UserDataInt is added
       
   698     //to read those many bytes after fixed length of agmentry.
       
   699     skipCount += KUserDataInt; 
       
   700     
       
   701     // Number of bytes until end of entry 
       
   702     aStream.WriteUint32L( skipCount );
       
   703     aStream.WriteInt32L( UserDataInt() );      
   694 	}
   704 	}
   695 
   705 
   696 
   706 
   697 EXPORT_C void CAgnEntry::InternalizeL(RReadStream& aStream)
   707 EXPORT_C void CAgnEntry::InternalizeL(RReadStream& aStream)
   698 	{
   708 	{
   827 		}
   837 		}
   828 	
   838 	
   829 	// Set the user integer of this entry from the stream.
   839 	// Set the user integer of this entry from the stream.
   830 	SetUserInt(aStream.ReadInt32L());
   840 	SetUserInt(aStream.ReadInt32L());
   831 	
   841 	
   832 	// future DC proofing
       
   833 	size = aStream.ReadUint32L(); // number of bytes until end of entry
   842 	size = aStream.ReadUint32L(); // number of bytes until end of entry
       
   843 	
       
   844 	if ( size >= KUserDataInt )       
       
   845         {       
       
   846         SetUserDataInt( aStream.ReadInt32L() );
       
   847 		size -= KUserDataInt;
       
   848         }  
   834 	while (size > 0)
   849 	while (size > 0)
   835 		{
   850 		{
   836 		aStream.ReadUint8L(); // ignore data
   851 			aStream.ReadUint8L(); // ignore data
   837 		size--;
   852 			size--;
   838 		}
   853 		}     
   839 	}
   854 	}
   840 
   855 
   841 EXPORT_C CAgnEntry* CAgnEntry::CloneL() const
   856 EXPORT_C CAgnEntry* CAgnEntry::CloneL() const
   842 	{
   857 	{
   843 	CAgnEntry* entry = NULL;
   858 	CAgnEntry* entry = NULL;
  1006 	if(aCopyType == CCalEntry::ECopyAll)
  1021 	if(aCopyType == CCalEntry::ECopyAll)
  1007 		{
  1022 		{
  1008 		HBufC8* guid = aSource.Guid().AllocL();
  1023 		HBufC8* guid = aSource.Guid().AllocL();
  1009 		SetGuid(guid);
  1024 		SetGuid(guid);
  1010 		}		
  1025 		}		
       
  1026 	// copy int       
       
  1027 	iUserDataInt = aSource.UserDataInt();   
  1011 	}
  1028 	}
  1012 	
  1029 	
  1013 EXPORT_C CCalEntry::TReplicationStatus CAgnEntry::ReplicationStatus() const
  1030 EXPORT_C CCalEntry::TReplicationStatus CAgnEntry::ReplicationStatus() const
  1014 /** Get ReplicationStatus
  1031 /** Get ReplicationStatus
  1015 
  1032 
  1233 		}
  1250 		}
  1234 		
  1251 		
  1235 	iPhoneOwner = aAttendee;
  1252 	iPhoneOwner = aAttendee;
  1236 	}
  1253 	}
  1237 
  1254 
       
  1255 EXPORT_C void CAgnEntry::ClearMRSpecificData()
       
  1256     {
       
  1257     // clears the iMeetingOrganizer and iAttendeeList.
       
  1258     if( iMeetingOrganizer )
       
  1259         {
       
  1260         delete iMeetingOrganizer;
       
  1261         iMeetingOrganizer = NULL;
       
  1262 
       
  1263         }
       
  1264     if( iPhoneOwner )
       
  1265         {
       
  1266         iPhoneOwner = NULL;
       
  1267         }
       
  1268 
       
  1269     if( iAttendeeList )
       
  1270         {
       
  1271         iAttendeeList->ResetAndDestroy();
       
  1272         delete iAttendeeList;
       
  1273         iAttendeeList = NULL;
       
  1274         }
       
  1275     }
  1238 
  1276 
  1239 EXPORT_C void CAgnEntry::SetDTStampUtcL(const TTime& aDTStampUtc)
  1277 EXPORT_C void CAgnEntry::SetDTStampUtcL(const TTime& aDTStampUtc)
  1240 /**
  1278 /**
  1241 @internalComponent
  1279 @internalComponent
  1242 */
  1280 */
  1853 
  1891 
  1854 @param aUserInt The new value of the user integer. 
  1892 @param aUserInt The new value of the user integer. 
  1855 @internalComponent
  1893 @internalComponent
  1856 */
  1894 */
  1857 EXPORT_C void CAgnEntry::SetUserInt( TUint32 aUserInt )
  1895 EXPORT_C void CAgnEntry::SetUserInt( TUint32 aUserInt )
  1858 	{
  1896     {
  1859 	CAgnSimpleEntry::SetUserInt(aUserInt);
  1897     CAgnSimpleEntry::SetUserInt(aUserInt);
  1860 	}
  1898     }
  1861 
  1899 
  1862 /**
  1900 /**
  1863 Gets the user integer of this entry.
  1901 Gets the user integer of this entry.
  1864 
  1902 
  1865 @return The user integer.
  1903 @return The user integer.
  1866 @internalComponent
  1904 @internalComponent
  1867 */
  1905 */
  1868 EXPORT_C TUint32 CAgnEntry::UserInt() const
  1906 EXPORT_C TUint32 CAgnEntry::UserInt() const
  1869 	{
  1907     {
  1870 	return CAgnSimpleEntry::UserInt();
  1908     return CAgnSimpleEntry::UserInt();
  1871 	}
  1909     }
  1872 
  1910 
  1873 EXPORT_C void CAgnEntry::ExternalizeToBufferL(RWriteStream& aWriteStream) const
  1911 EXPORT_C void CAgnEntry::ExternalizeToBufferL(RWriteStream& aWriteStream) const
  1874 /** Used for passing the data to the between client and server
  1912 /** Used for passing the data to the between client and server
  1875 @internalComponent
  1913 @internalComponent
  1876 */
  1914 */
  2008 	}
  2046 	}
  2009 
  2047 
  2010 // verify entry is valid before storing it
  2048 // verify entry is valid before storing it
  2011 EXPORT_C void CAgnEntry::VerifyBeforeStoreL()
  2049 EXPORT_C void CAgnEntry::VerifyBeforeStoreL()
  2012 	{
  2050 	{
  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
  2051 	//Check entry time
  2026 	if ( Type() != CCalEntry::ETodo )
  2052 	if ( Type() != CCalEntry::ETodo )
  2027 		{
  2053 		{
  2028 		__ASSERT_ALWAYS(StartTime().IsSet(), Panic(EAgmErrTimeNotSet));
  2054 		__ASSERT_ALWAYS(StartTime().IsSet(), Panic(EAgmErrTimeNotSet));
  2029 		if ( Type() != CCalEntry::EReminder )
  2055 		if ( Type() != CCalEntry::EReminder )
  2097 
  2123 
  2098 TBool CAgnEntry::IsFlagSet(TFlags aFlag) const
  2124 TBool CAgnEntry::IsFlagSet(TFlags aFlag) const
  2099 	{
  2125 	{
  2100 	return (iFlags & aFlag);
  2126 	return (iFlags & aFlag);
  2101 	}
  2127 	}
       
  2128 
       
  2129 EXPORT_C void CAgnEntry::SetUserDataInt( TUint32 aUserInt )       
       
  2130     {       
       
  2131     iUserDataInt = aUserInt;       
       
  2132     }       
       
  2133 
       
  2134 EXPORT_C TUint32 CAgnEntry::UserDataInt() const       
       
  2135     {       
       
  2136     return iUserDataInt;       
       
  2137     }