// WEBFETCH.H
//
// Copyright (c) 1997-1999 Symbian Ltd.  All rights reserved.
//
#if !defined(__WEBFETCH_H__)
#define __WEBFETCH_H__

#if !defined(__F32FILE_H__)
#include <f32file.h>
#endif
#if !defined(__S32STD_H__)
#include <s32std.h>
#endif
#if !defined(__BADESCA_H__)
#include <badesca.h>
#endif
#if !defined(__WEBMOBSV_H__)
#include "webmobsv.h" 
#endif
#if !defined(__WEBEOSRV_H__)
#include "webeosrv.h"
#endif


class CWtlDocument;
class CWebFetcher;
class MWebModelObserver;

class MDataAccumulator
	{
public:
	virtual void AppendL(const TDesC8& aData)=0;
	IMPORT_C virtual void MDataAccumulator_Reserved1();
	IMPORT_C virtual void MDataAccumulator_Reserved2();
	};

class RWebFileFetcher : public MDataAccumulator
	{
public:
	IMPORT_C TInt Open(RFs& aFs,const TDesC& aFileName);
	IMPORT_C void Close();
	IMPORT_C operator TCleanupItem();
private:
	IMPORT_C void AppendL(const TDesC8& aData);
	IMPORT_C static void Cleanup(TAny* aObject);
private:
	RFile iFile;
	TFileName iFileName;
	TBool iFileOpened;
	RFs iFs;
	};

class CWebDataFetch : public CBase
	{
	friend class CWebFetcher;

public:
	IMPORT_C static CWebDataFetch* NewLC(TInt aPriority,CWtlDocument* aDocument,
		                                 MDataAccumulator* aData,
										 MWebModelObserver* aObserver,
										 MWebEmbeddedObjectServices* aServices,
										 TBool aDoKeepCachedCopy, CWebLogger* aLogPtr);
			// Takes ownership of aDocument immediately
	IMPORT_C ~CWebDataFetch();
	IMPORT_C void CancelFetch();

	IMPORT_C HBufC* UrlL() const;
	IMPORT_C TInt Size() const;
	IMPORT_C TInt TotalSize() const;
private:
	CWebDataFetch(CWtlDocument* aDocument,MDataAccumulator* aData,MWebModelObserver* aObserver,
				  MWebEmbeddedObjectServices* aServices);
	void ConstructL(TInt aPriority,TBool aDoKeepCachedCopy, CWebLogger* aLogPtr);
	CWtlDocument* Document() const;
	void NotifyDataL(const TDesC8& aData);
	void NotifyErrorL(TInt aError);
	void NotifyChangeL(MWebModelObserver::TWebModelObserverMessage aMessage);
	void NotifyStatusL(MWebModelObserver::TWebModelObserverStatus aStatus);
private:
	CWebFetcher* iFetcher;
	CWtlDocument* iDocument;
	MDataAccumulator* iData;
	MWebModelObserver* iObserver;
	MWebEmbeddedObjectServices* iEOServices;
	};

#endif

