// SMSSERV.H
//
// Copyright (c) 1998 Symbian Ltd.  All rights reserved.
//


#if !defined(__SMSSERV_H__)
#define __SMSSERV_H__

#if !defined(__MTSR_H__)
#include <mtsr.h>
#endif
#if !defined(__SMUTSET_H__)
#include <smutset.h>
#endif
#if !defined(__ETEL_H__)
#include <etel.h>
#endif
#if !defined(__ETELBGSM_H__)
#include <etelpgsm.h>
#endif


class CSmsOutboxSend;
class CSmsInboxReceive;
class CSmsNewMessageRead;



class CSmsServerMtm : public CBaseServerMtm
	{
public:
	enum TSmsServerMtmState
		{
		ESmsServerMtmStateWaiting,	

		ESmsServerMtmStateSending,

		ESmsServerMtmStateSettingCommandExpected,

		ESmsServerMtmStateReadingServiceCenterAddress,
		ESmsServerMtmStateWritingServiceCenterAddress,
		ESmsServerMtmStateEnumeratingStores,
		ESmsServerMtmStateReadingNewMessage
		};

public:
	IMPORT_C static CSmsServerMtm* NewL(CRegisteredMtmDll& aRegisteredMtmDll);
	~CSmsServerMtm();

	void CopyToLocalL(const CMsvEntrySelection& aSelection,TMsvId aDestination, TRequestStatus& aStatus);
	void CopyFromLocalL(const CMsvEntrySelection& aSelection,TMsvId aDestination, TRequestStatus& aStatus);
	void CopyWithinServiceL(const CMsvEntrySelection& aSelection,TMsvId aDestination, TRequestStatus& aStatus);
	void MoveToLocalL(const CMsvEntrySelection& aSelection,TMsvId aDestination, TRequestStatus& aStatus);
	void MoveFromLocalL(const CMsvEntrySelection& aSelection,TMsvId aDestination, TRequestStatus& aStatus);
	void MoveWithinServiceL(const CMsvEntrySelection& aSelection,TMsvId aDestination, TRequestStatus& aStatus);
	void DeleteL(const CMsvEntrySelection& aSelection, TRequestStatus& aStatus);
	void DeleteAllL(const CMsvEntrySelection& aSelection, TRequestStatus& aStatus);
	void CreateL(TMsvEntry aNewEntry, TRequestStatus& aStatus);
	void ChangeL(TMsvEntry aNewEntry, TRequestStatus& aStatus);
	//
	void StartCommandL(CMsvEntrySelection& aSelection, TInt aCommand, const TDesC8& aParameter, TRequestStatus& aStatus);
	//
	TBool CommandExpected();
	//
	const TDesC8& Progress();
	//
	void SetInitialEntry(CMsvServerEntry* aEntry);

protected:
	void DoCancel();
	void DoRunL();
	void Queue(TRequestStatus& aStatus);
	void CompleteCommand(TInt aError);
	void DoComplete(TInt aError);

private:
	CSmsServerMtm(CRegisteredMtmDll& aRegisteredMtmDll);
	void ConstructL();
	void CopySelectionL(const CMsvEntrySelection& aSelection);
	void DoCopySelectionL(const CMsvEntrySelection& aSelection);
	void RestoreSettingsL();
	void EnumerateStoresL();
	void ReadNewMessageL(const TDesC8& aParameter);

private:
	CMsvServerEntry* iServerEntry;

	RTelServer iServer;
	RBasicGsmPhone iPhone;
	RSmsMessaging iSmsMessaging;

	TMsvId iSmsServiceId;
	TSmsSettings iSmsSettings;
	TSmsProgress iProgress;
	TSmsProgressBuf iProgressBuf;	
	CMsvEntrySelection* iMsvEntrySelection;
	CSmsOutboxSend* iSmsOutboxSend;
	CSmsInboxReceive* iSmsInboxReceive;
	CSmsNewMessageRead* iSmsNewMessageRead;
	TSmsServerMtmState iState;
	TBool iCommandExpected;
	TRequestStatus* iReport;
	};

#endif