// IMAPSET.H
//
// Copyright (c) 1998 Symbian Ltd.  All rights reserved. 
//

#if !defined (__IMAPSET_H__)
#define __IMAPSET_H__

#if !defined (__MSVUIDS_H__)
#include <MSVUIDS.H>
#endif

#if !defined (__MIUTSET_H__)
#include "miutset.h"
#endif


const TUint16 KImImapSettingsVersion = 1;	// identify which version of this class has been stored
const TUint32 KIMAPDefaultPortNumber = 143;

class CMsvStore;
class RMsvWriteStream;
class RMsvReadStream;

// Types of folder list sync
enum TFolderSyncType
	{
	EUseCombination=0,
	EUseLocal,
	EUseRemote
	};

// What to do with new subscription data
enum TFolderSubscribeType
	{
	EUpdateNeither=0,
	EUpdateLocal,
	EUpdateRemote,
	EUpdateBoth
	};

class TImap4Progress
	{
public:
	// What operation is currently in progress
	enum
		{
		EDisconnected=0,
		EConnecting,
		EIdle,
		EBusy,
		ESyncInbox,
		EFolderTreeSync,
		ECheckRemoteSubscription,
		EUpdateRemoteSubscription,
		ESyncOther,
		EFetching,
		ECopying,
		EMoving,
		EAppending,
		EDisconnecting
		};
	TInt		iOperation;

	// Raw byte counts for connection
	TInt		iTXbytes;
	TInt		iRXbytes;

	// Folder count for synchronisation
	TInt		iFoldersToDo;
	TInt		iFoldersDone;

	// Message count for synchronisation
	TInt		iMsgsToDo;
	TInt		iMsgsDone;

	// Fetching counts
	TInt		iPartsToDo;
	TInt		iPartsDone;
	TInt		iBytesToDo;	// This is for *whole* multipart fetch in a single op
	TInt		iBytesDone;

	// Overall sync stats: silly to pass these all the time really, but...
	TInt		iHeadersFetched;
	TInt		iOrphanedFolders;
	TInt		iNewFolders;
	TInt		iOrphanedMessages;
	TInt		iRemoteMessagesDeleteTagged;

	// Overall queued op stats
	TInt		iMessagesFetchedOK;
	TInt		iMessagePartsFetchedOK;
	TInt		iMessagePartsNotFound;
	TInt		iFoldersNotFound;

	TInt		iErrorCode; // client side needs to be informed of an error

	// A way of passing back a TMsvId to the client side: eg, when we create a
	// new folder
	TMsvId		iReturnedMsvId;
	};

class CImImap4Settings : public CImBaseEmailSettings
	{
public:
	IMPORT_C CImImap4Settings();
	IMPORT_C ~CImImap4Settings();
	IMPORT_C void Reset();

	// streaming operations
	IMPORT_C void InternalizeL( RMsvReadStream&  );
	IMPORT_C void ExternalizeL( RMsvWriteStream& ) const;
	IMPORT_C void RestoreL( CMsvStore& aMessageStore );
	IMPORT_C void StoreL  ( CMsvStore& aMessageStore ) const;

	// User name
	IMPORT_C const TPtrC8 LoginName() const;
	IMPORT_C void SetLoginNameL( const TDesC8& );

	// Password
	IMPORT_C const TPtrC8 Password() const;
	IMPORT_C void SetPasswordL( const TDesC8& );

	// Folder path
	IMPORT_C const TPtrC8 FolderPath() const;
	IMPORT_C void SetFolderPathL( const TDesC8& );

	// Path separator
	IMPORT_C const TText8 PathSeparator() const;
	IMPORT_C void SetPathSeparator( const TText8 );

	IMPORT_C const TBool DisconnectedUserMode() const;
	IMPORT_C void SetDisconnectedUserMode( TBool aMode );

	// Synchronise strategy & subscription strategy
	IMPORT_C void SetSynchronise( const TFolderSyncType );
	IMPORT_C void SetSubscribe( const TFolderSubscribeType );
	IMPORT_C const TFolderSyncType Synchronise() const;
	IMPORT_C const TFolderSubscribeType Subscribe() const;

	IMPORT_C CImImap4Settings& CopyL(const CImImap4Settings& aCImImap4Settings);
	IMPORT_C TBool operator==(const CImImap4Settings& aCImImap4Settings) const;

	// Auto send on connection or not
	IMPORT_C const TBool AutoSendOnConnect() const;
	IMPORT_C void SetAutoSendOnConnect( TBool );

private:
	enum TImImap4EmailSettings
		{
		KImap4EmailSettingsClearFlag		= 0x00000000,
		KImap4EmailSettingsFirstUnusedFlag	= CImBaseEmailSettings::EBaseEmailSettingsFirstUnusedFlag,
		KImap4EmailDisconnectedModeFlag		= KImap4EmailSettingsFirstUnusedFlag,
		KImap4EmailAutoSendFlag,		
		KImap4EmailSettingsLastUsedFlag	= KImap4EmailAutoSendFlag
		};

	HBufC8* iLoginName;
	HBufC8* iPassword;
	HBufC8* iFolderPath;
	TText8 iPathSeparator;
	TFolderSyncType iSynchroniseStrategy;
	TFolderSubscribeType iSubscriptionStrategy;
	};

#endif // #define __IMAPSET_H__