// TBACKCLI.H
//
// Copyright (c) 1997-1999 Symbian Ltd.  All rights reserved.
//


#if !defined(__TBACKCLI_H__)
#define __TBACKCLI_H__

#include <badesca.h>
//
//	Callback Interface
//

class MBackupObserver
	{
public:
	virtual TBool OnListOpenFiles(TInt aRes, CDesCArray *aArray)=0;
	virtual void OnStopDocument(TInt aRes)=0;
	virtual void OnCheckDocument(TInt aRes, TBool b)=0;
	virtual void OnRetreiveOwnerInfo(TInt aRes, const TDesC &aInfo)=0;
	};

//
//	The BackupServer client side
//
class RPlpBackSvrClient : public RSessionBase
//
//	A "mits off" class
//	Only to be used by below active object wrapper
//
	{
protected:
	RPlpBackSvrClient();
	//
	TInt DocumentListOpen(TUint32 &aHandle);
	TInt DocumentListRead(const TUint32 aHandle, TDes &anApp, TDes &aDoc, TInt& aId);
	TInt DocumentListClose(const TUint32 aHandle);
	//
	TInt DocumentStop(const TDesC &aDocPath);
	TInt DocumentIsOpen(const TDesC &aDocPath);
	TInt DocumentStart(const TDesC &aDocPath);
	//
	TInt AppStop(const TDesC &aApp, TInt aId);
	TInt AppIsRunning(const TDesC &aApp, TInt aId);
	TInt DetailsFromApp(const TDesC &aApp, TInt aId, TDes& aDll, TDes& aDocument);
	TInt AppStart(const TDesC &aCommandLine);
	//
	TInt OwnerInfoAsText(TDes &aBuf);
	friend class CBackupClient;
	};

//
//	A nice active object wrapper arround it
//

class CBackupClient : public CActive
	{
public:
	static CBackupClient *NewL(MBackupObserver *aObserver);
	~CBackupClient();
	//
	void ListOpenFilesL();
	void StopDocumentL(const TDesC &aDocument);
	void CheckDocumentL(const TDesC &aDocument);
	void RetreiveOwnerInfoL();
	//
protected:
	CBackupClient(MBackupObserver *aObserver);
	void ConstructL();
	//
	virtual void RunL();
	virtual void DoCancel();
	//
	RPlpBackSvrClient	iClient;
	//
	MBackupObserver *iObserver;
	CDesCArray		*iArray;
	//
	enum TBakSvState
		{
		EStateIdle,
		EStateListOpenFiles,
		EStateStopDoc,
		EStateCheckDoc,
		EStateStartDoc,
		EStateOwnerInfo,
		} iState;
	};


#endif
