// AGMXENTR.H
//
// Copyright (c) 1997-1999 Symbian Ltd.  All rights reserved.
//


#if !defined(__AGMXENTR_H__)
#define __AGMXENTR_H__

#if !defined(__E32BASE_H__)
#include <e32base.h>
#endif

#if !defined(__S32STD_H__)
#include <s32std.h>
#endif

#include "agmdate.h"

const TInt KMaxGlobalIDLength = 32;


typedef TBuf<KMaxGlobalIDLength> TAgnGlobalId;

/////////////////////////
//// CAgnAttendee



class CAgnAttendee : public CBase
	{
public:
	// role : default is attendee
	enum TAgnRole {EAttendee, EOrganizer, EOwner, EDelegate};
	// status : default is needs action
	enum TAgnStatus {EAccepted, ENeedsAction, ESent, ETentative,
					 EConfirmed, EDeclined, ECompleted,
					 EDelegated};
	// expect : a priority indication - default is FYI
	enum TAgnExpect {EFyi, ERequire, ERequest, EImmediate};

public:
	// construct / destruct functions
	CAgnAttendee();
	IMPORT_C static CAgnAttendee* NewL(const TDesC& aAddress);
	static CAgnAttendee* NewL(RReadStream& aStream);
	static CAgnAttendee* NewL();
	void ConstructL(const TDesC& aAddress);
	~CAgnAttendee();

	// Get functions
	inline TAgnRole Role() const;
	inline TAgnStatus Status() const;
	inline TBool ResponseRequested() const;
	inline TAgnExpect Expect() const;
	IMPORT_C TPtrC Address() const;

	// Set functions
	IMPORT_C void SetRole(TAgnRole aRole);
	IMPORT_C void SetStatus(TAgnStatus aStatus);
	IMPORT_C void SetResponseRequested(TBool aRsvp);	// default is no
	IMPORT_C void SetExpect(TAgnExpect aExpect);

	// Persistence
	void ExternalizeL(RWriteStream& aStream) const;
	void InternalizeL(RReadStream& aStream);
	IMPORT_C void Copy(CAgnAttendee* aSource);
private:
	TAgnRole				iRole;
	TAgnStatus				iStatus;
	TBool					iRsvp;
	TAgnExpect				iExpect;
	HBufC*					iAddress;
	};




/////////////////////////
/// CAgnExtendedEntry

class CAgnExtendedEntry : public CBase
	{
public:
	CAgnExtendedEntry();
	~CAgnExtendedEntry();
	static CAgnExtendedEntry* NewL();

	// Attendee functions
	TBool HasAttendees();
	TInt AttendeeCount();
	void AddAttendeeL(CAgnAttendee* aAttendee);
	CAgnAttendee* FetchAttendee(TInt aIndex);
	void DeleteAttendee(TInt aIndex);

	// Global ID functions
	void SetGlobalId(const TDesC& aGlobalId);
	TDesC& GlobalId();
	TBool HasGlobalId();

	// Location functions
	void SetLocationL(const TDesC& aLocation);
	TPtrC Location();


	// Persistence
	void ExternalizeL(RWriteStream& aStream) const;
	void InternalizeL(RReadStream& aStream);
	void CopyL(CAgnExtendedEntry* aSource);
	void SetCreationDate(TAgnDate aCreationDate);
	inline TAgnDate CreationDate() const;
private:
	CArrayPtrFlat<CAgnAttendee>*	iAttendeeList;
	TAgnGlobalId					iGlobalId;
	HBufC*							iLocation;
	TAgnDate						iCreationDate;
	};



// Inline functions

CAgnAttendee::TAgnRole CAgnAttendee::Role() const
	{
	return iRole;
	}

CAgnAttendee::TAgnStatus CAgnAttendee::Status() const
	{
	return iStatus;
	}

TBool CAgnAttendee::ResponseRequested() const
	{
	return iRsvp;
	}

CAgnAttendee::TAgnExpect CAgnAttendee::Expect() const
	{
	return iExpect;
	}


TAgnDate CAgnExtendedEntry::CreationDate() const
	{
	return iCreationDate;
	}

#endif
