williamr@2: /*
williamr@2: * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
williamr@2: * All rights reserved.
williamr@2: * This component and the accompanying materials are made available
williamr@4: * under the terms of "Eclipse Public License v1.0"
williamr@2: * which accompanies this distribution, and is available
williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@2: *
williamr@2: * Initial Contributors:
williamr@2: * Nokia Corporation - initial contribution.
williamr@2: *
williamr@2: * Contributors:
williamr@2: *
williamr@2: * Description: History Log info
williamr@2: *
williamr@2: */
williamr@2: ///////////////////////////////////////////////////////////////////////////////
williamr@2: // SyncMLHistory.h
williamr@2: //
williamr@2: // v05
williamr@2: //
williamr@2: ///////////////////////////////////////////////////////////////////////////////
williamr@2: #ifndef __SYNCMLHISTORY_H__
williamr@2: #define __SYNCMLHISTORY_H__
williamr@2: //
williamr@2: #include <e32base.h>
williamr@2: #include <s32strm.h>
williamr@2: #include <hash.h>
williamr@2: //
williamr@4: #include <SyncMLDef.h>
williamr@2: //
williamr@2: class CSmlAlertInfo;
williamr@2: class CSmlHistoryEntrySet;
williamr@2: //
williamr@2: /** Unique ID for Sync Job entry type. */
williamr@2: const TInt KSmlHistoryEntryJobTypeValue = 0x10009FA9;
williamr@2: const TUid KUidSmlHistoryEntryJob = { KSmlHistoryEntryJobTypeValue };
williamr@2: //
williamr@2: /** Unique ID for Push Msg entry type. */
williamr@2: const TInt KSmlHistoryEntryPushMsgTypeValue = 0x10009FAA;
williamr@2: const TUid KUidSmlHistoryEntryPushMsg = { KSmlHistoryEntryPushMsgTypeValue };
williamr@2: //
williamr@2: /** Panic codes for shared History Log classes. */
williamr@2: enum TSmlPanicHistoryShared
williamr@2: 	{
williamr@2: 	ESmlPanicHistoryShared_BadTaskId,
williamr@2: 	ESmlPanicHistoryShared_BadSortOrdering
williamr@2: 	};
williamr@2: //
williamr@2: 
williamr@2: ///////////////////////////////////////////////////////////////////////////////
williamr@2: // CSyncMLHistoryEntry
williamr@2: ///////////////////////////////////////////////////////////////////////////////
williamr@2: class CSyncMLHistoryEntry : public CBase
williamr@2: /**
williamr@2: 	Base class for a history log entry.
williamr@2: 
williamr@2: 	Not intended for user derivation. Derived classes: 
williamr@2: 	@see CSyncMLHistoryJob 
williamr@2: 
williamr@2: 	@publishedAll
williamr@2: 	@released
williamr@2:   */
williamr@2: 	{
williamr@2: public:
williamr@2: 	/** An ordering of History Entries. */
williamr@2: 	enum TSortOrder
williamr@2: 		{
williamr@2: 		/** Ordered by Time Stamp. */
williamr@2: 		ESortByTime,
williamr@2: 		/** Ordered by Entry Type. */
williamr@2: 		ESortByType
williamr@2: 		};
williamr@2: public:
williamr@2: 	// Factory methods based upon entry type.
williamr@2: 	IMPORT_C static CSyncMLHistoryEntry* NewL(TUid aEntryType);
williamr@2: 	IMPORT_C static CSyncMLHistoryEntry* NewL(RReadStream&);
williamr@2: 	IMPORT_C static CSyncMLHistoryEntry* NewL(const CSyncMLHistoryEntry&);
williamr@2: public:
williamr@2: 	IMPORT_C virtual ~CSyncMLHistoryEntry();
williamr@2: 	IMPORT_C virtual void ExternalizeL(RWriteStream&) const;
williamr@2: 	IMPORT_C TUid EntryType() const;
williamr@2: 	IMPORT_C TInt EntryId() const;
williamr@2: 	virtual TSmlProfileId Profile() const = 0;
williamr@2: 	virtual TTime TimeStamp() const = 0;
williamr@2: 	virtual TInt ResultCode() const = 0;
williamr@2: 
williamr@2: protected:
williamr@2: 	CSyncMLHistoryEntry(TUid);
williamr@2: 	/** @internalTechnology */
williamr@2: 	IMPORT_C static CSyncMLHistoryEntry* DoDynamicCast(TUid aEntryType, CSyncMLHistoryEntry*);
williamr@2: 	/** @internalTechnology */
williamr@2: 	IMPORT_C static const CSyncMLHistoryEntry* DoDynamicCast(TUid aEntryType, const CSyncMLHistoryEntry*);
williamr@2: 	virtual void InternalizeL(RReadStream&);
williamr@2: private:
williamr@2: 	friend class CEntrySet;
williamr@2: 	IMPORT_C void SetEntryId(TInt);
williamr@2: 	IMPORT_C virtual TAny* Reserved(TUid);
williamr@2: private:
williamr@2: 	TUid iEntryType;
williamr@2: 	TInt iEntryId;
williamr@2: 	TInt iSpare;
williamr@2: 	};
williamr@2: 
williamr@2: ///////////////////////////////////////////////////////////////////////////////
williamr@2: ///////////////////////////////////////////////////////////////////////////////
williamr@2: 
williamr@2: ///////////////////////////////////////////////////////////////////////////////
williamr@2: // CSyncMLHistoryJob
williamr@2: ///////////////////////////////////////////////////////////////////////////////
williamr@2: class CSyncMLHistoryJob : public CSyncMLHistoryEntry
williamr@2: /**
williamr@2: 	This class holds the result of a session with a server.
williamr@2: 	@publishedAll
williamr@2: 	@released
williamr@2: */
williamr@2: 	{
williamr@2: public:
williamr@2: 	class TTaskInfo
williamr@2: 	/**
williamr@2: 		This class identifies a sync task within the profile,
williamr@2: 		and the result of the attempt to synchronise it.
williamr@2: 	*/
williamr@2: 		{
williamr@2: 	public:
williamr@2: 		IMPORT_C TTaskInfo();
williamr@2: 		IMPORT_C void InternalizeL(RReadStream&);
williamr@2: 		IMPORT_C void ExternalizeL(RWriteStream&) const;
williamr@2: 	public:
williamr@2: 		/** Identifies the profile sync task */
williamr@2: 		TSmlTaskId iTaskId;
williamr@2: 		/** Indicates the synchronisation result */
williamr@2: 		TInt iError;
williamr@2: 		/** Indicates the number of items added to the db */
williamr@2: 		TInt iItemsAdded;
williamr@2: 		/** Indicates the number of items modified in the db */
williamr@2: 		TInt iItemsChanged;
williamr@2: 		/** Indicates the number of items deleted from the db */
williamr@2: 		TInt iItemsDeleted;
williamr@2: 		/** Indicates the number of items moved in the db */
williamr@2: 		TInt iItemsMoved;
williamr@2: 		/** Indicates the number of items failed to modify the db */
williamr@2: 		TInt iItemsFailed;
williamr@2: 		/** Indicates the number of items added to the server's db */
williamr@2: 		TInt iServerItemsAdded;
williamr@2: 		/** Indicates the number of items modified in the server's db */
williamr@2: 		TInt iServerItemsChanged;
williamr@2: 		/** Indicates the number of items deleted from the server's db */
williamr@2: 		TInt iServerItemsDeleted;
williamr@2: 		/** Indicates the number of items moved in the server's db */
williamr@2: 		TInt iServerItemsMoved;
williamr@2: 		/** Indicates the number of items failed to modify the server's db */
williamr@2: 		TInt iServerItemsFailed;
williamr@2: 		/** Indicates the actual SyncType used for the synchronisation */
williamr@2: 		TSmlSyncType iSyncType;
williamr@2: 		};
williamr@2: public:
williamr@2: 	inline static CSyncMLHistoryJob* DynamicCast(CSyncMLHistoryEntry*);
williamr@2: 	inline static const CSyncMLHistoryJob* DynamicCast(const CSyncMLHistoryEntry*);
williamr@2: 	IMPORT_C static CSyncMLHistoryJob* NewL();
williamr@2: 	IMPORT_C static CSyncMLHistoryJob* NewL(TSmlProfileId, const RArray<TSmlTaskId>&);
williamr@2: 	IMPORT_C virtual ~CSyncMLHistoryJob();
williamr@2: 	IMPORT_C virtual void ExternalizeL(RWriteStream&) const;
williamr@2: public:
williamr@2: 	IMPORT_C virtual TSmlProfileId Profile() const;
williamr@2: 	IMPORT_C virtual TTime TimeStamp() const;
williamr@2: 	IMPORT_C TTime LastSuccessSyncTime() const; 
williamr@2: 	IMPORT_C virtual TInt ResultCode() const;
williamr@2: 	IMPORT_C TTime FinishTime() const;
williamr@2: 	IMPORT_C TInt TaskCount() const;
williamr@2: 	IMPORT_C const TTaskInfo& TaskAt(TInt) const;
williamr@2: public:
williamr@2: 	IMPORT_C TTaskInfo& TaskById(TSmlTaskId);
williamr@2: 	IMPORT_C void SetResult(TTime aFinishTime, TInt aResultCode);
williamr@2: 	IMPORT_C void SetLastSyncResult(TTime aSuccessSyncTime );
williamr@2: private:
williamr@2: 	CSyncMLHistoryJob();
williamr@2: 	void ConstructL(TSmlProfileId, const RArray<TSmlTaskId>&);
williamr@2: 	virtual void InternalizeL(RReadStream&);
williamr@2: private:
williamr@2: 	TTime iStartTime;
williamr@2: 	TTime iFinishTime;
williamr@2: 	TInt iResultCode;
williamr@2: 	TSmlProfileId iProfileId;
williamr@2: 	RArray<TTaskInfo> iTaskInfo;
williamr@2: 	TTime iLastSuccessSync;
williamr@2: 	};
williamr@2: 
williamr@2: ///////////////////////////////////////////////////////////////////////////////
williamr@2: inline CSyncMLHistoryJob* CSyncMLHistoryJob::DynamicCast(CSyncMLHistoryEntry* aEntry)
williamr@2: 	{
williamr@2: 	return static_cast<CSyncMLHistoryJob*>(CSyncMLHistoryEntry::DoDynamicCast(KUidSmlHistoryEntryJob, aEntry));
williamr@2: 	}
williamr@2: 
williamr@2: inline const CSyncMLHistoryJob* CSyncMLHistoryJob::DynamicCast(const CSyncMLHistoryEntry* aEntry)
williamr@2: 	{
williamr@2: 	return static_cast<const CSyncMLHistoryJob*>(CSyncMLHistoryEntry::DoDynamicCast(KUidSmlHistoryEntryJob, aEntry));
williamr@2: 	}
williamr@2: 
williamr@2: ///////////////////////////////////////////////////////////////////////////////
williamr@2: ///////////////////////////////////////////////////////////////////////////////
williamr@2: 
williamr@2: ///////////////////////////////////////////////////////////////////////////////
williamr@2: // CSyncMLHistoryPushMsg
williamr@2: ///////////////////////////////////////////////////////////////////////////////
williamr@2: class CSyncMLHistoryPushMsg : public CSyncMLHistoryEntry
williamr@2: /**
williamr@2: 	This class holds the result of a parsing a push msg.
williamr@2: 	This class contains a counter that stores how many times the same message has been received.
williamr@2: 	@publishedAll
williamr@2: 	@released
williamr@2: */
williamr@2: 	{
williamr@2: public:
williamr@2: 	inline static CSyncMLHistoryPushMsg* DynamicCast(CSyncMLHistoryEntry*);
williamr@2: 	inline static const CSyncMLHistoryPushMsg* DynamicCast(const CSyncMLHistoryEntry*);
williamr@2: 	IMPORT_C static CSyncMLHistoryPushMsg* NewL();
williamr@2: 	IMPORT_C virtual ~CSyncMLHistoryPushMsg();
williamr@2: 	IMPORT_C virtual void ExternalizeL(RWriteStream&) const;
williamr@2: public:
williamr@2: 	IMPORT_C virtual TSmlProfileId Profile() const;
williamr@2: 	IMPORT_C virtual TTime TimeStamp() const;
williamr@2: 	IMPORT_C virtual TInt ResultCode() const;
williamr@2: 	IMPORT_C TInt ReceivedCount() const;
williamr@2: 	IMPORT_C const TDesC8& MsgDigest() const;
williamr@2: 	IMPORT_C TInt AlertCount() const;
williamr@2: 	IMPORT_C const CSmlAlertInfo& Alert(TInt aIndex) const;
williamr@2: public:
williamr@2: 	IMPORT_C void IncReceivedCount();
williamr@2: 	IMPORT_C void SetMsgDigest(const TDesC8&);
williamr@2: 	IMPORT_C void AddAlertsL(RPointerArray<CSmlAlertInfo>&); // Ownership of CSmlAlertInfo objects is transferred.
williamr@2: 	IMPORT_C void ResetAlerts();
williamr@2: 	IMPORT_C void SetResultCode(TInt aResultCode);
williamr@2: 
williamr@2: private:
williamr@2: 	CSyncMLHistoryPushMsg();
williamr@2: 	virtual void InternalizeL(RReadStream&);
williamr@2: private:
williamr@2: 	TTime iTimeStamp;
williamr@2: 	TInt iResultCode;
williamr@2: 	TInt iRcvCount;
williamr@2: 	TBuf8<MD5_HASH> iDigest;
williamr@2: 	RPointerArray<CSmlAlertInfo> iAlerts;
williamr@2: 	};
williamr@2: 
williamr@2: ///////////////////////////////////////////////////////////////////////////////
williamr@2: inline CSyncMLHistoryPushMsg* CSyncMLHistoryPushMsg::DynamicCast(CSyncMLHistoryEntry* aEntry)
williamr@2: 	{
williamr@2: 	return static_cast<CSyncMLHistoryPushMsg*>(CSyncMLHistoryEntry::DoDynamicCast(KUidSmlHistoryEntryPushMsg, aEntry));
williamr@2: 	}
williamr@2: 
williamr@2: inline const CSyncMLHistoryPushMsg* CSyncMLHistoryPushMsg::DynamicCast(const CSyncMLHistoryEntry* aEntry)
williamr@2: 	{
williamr@2: 	return static_cast<const CSyncMLHistoryPushMsg*>(CSyncMLHistoryEntry::DoDynamicCast(KUidSmlHistoryEntryPushMsg, aEntry));
williamr@2: 	}
williamr@2: 
williamr@2: ///////////////////////////////////////////////////////////////////////////////
williamr@2: ///////////////////////////////////////////////////////////////////////////////
williamr@2: 
williamr@2: ///////////////////////////////////////////////////////////////////////////////
williamr@2: ///////////////////////////////////////////////////////////////////////////////
williamr@2: ///////////////////////////////////////////////////////////////////////////////
williamr@2: #endif
williamr@2: 
williamr@2: