// WEBMOD.H
//
// Copyright (c) 1997-1999 Symbian Ltd.  All rights reserved.
//

// Header for the CWebModel class (Supporting Plug Ins)
//
//=============================================================================
// This class forms the rendering engine's interface to the User Interface.
//=============================================================================
//=============================================================================

#ifndef __WEBMOD_H__
#define __WEBMOD_H__

#if defined(__VC32__) && _MSC_VER==1100
// Disable MSVC++ 5.0 aggressive warnings about non-expansion of inline functions. 
#pragma warning(disable : 4710)	// function '...' not expanded
#endif

#if !defined(__W32STD_H__)
#include "w32std.h"     
#endif    
#if !defined(__TXTLAYDC_H__)
#include <txtlaydc.h>
#endif
#if !defined(__FRMTLAY_H__)
#include <frmtlay.h>
#endif
#if !defined(__FRMPRINT_H__)
#include <frmprint.h>
#endif
#if !defined(__PRNSETUP_H__)
#include <prnsetup.h>
#endif
#if !defined(__WEBDEF_H__)
#include "webdef.h"
#endif
#if !defined(__WEBSVMOD_H__)
#include "websvmod.h"
#endif
#if !defined(__WEBMOBSV_H__)
#include "webmobsv.h"
#endif
#if !defined(__WEBEOSRV_H__)
#include "webeosrv.h"
#endif
#if !defined(__WEBEVHDL_H__)
#include "webevhdl.h"
#endif

const KWebModelFrameSetSize = 10000;        // The width and height of all frame sets
const KWebModelMaxFrames = 20;					// The max number of frames allowed

class CAuthenticationData;
class CFbsBitmap;
class CRichText;
class CTextView;
class CWebDataFetch;
class CTextPageRegionPrinter;
class CEmbedObjectInfo;
class CWebPage;
class CWtlDocument;
class CWtlSession;
class CHtmlTokenHandler;
class MDataAccumulator;
class RReadStream;
class RWriteStream;
class RWindow;
class CWebModel;
class CWebFrame;
class CWebFramePool;
class CWebFrameHolder;
class CWebFrameTextStore;
class CWebHotSpotList;
class CWebPlugInRegistry;
class MWebDocumentInfo;
class CWebHistoryManipulator;
class CWebPageChangeList;

//-----------------------------------------------------------------------------
// Class for passing information about embedded objects.
//-----------------------------------------------------------------------------
class CEmbedObjectInfo: public CBase
	{
public:

private:
	};


//The spoof CTestTextLayout class. This gives me the ability to change CTextLayout::iLayoutData.
//This technique, I know, is almost indefensible - but I really need to fix something that is
//otherwise unfixable.
class CTestTextLayout
	{
	public:
	CTestTextLayout(CTextLayout* aTextLayout);
	CLayoutData* LayoutData();

	private:
	CTextLayout* iTextLayout;
	};


//-----------------------------------------------------------------------------
// Used for passing information about a frame from the engine to the UI.
// Only contains information specific to the frame, and not its contents,
// so for example ‘title’ is not included.  Contains information which is
//available after the loading of the frame has begun.
//-----------------------------------------------------------------------------
class CFrameInfo: public CBase
	{
public:

	enum TPageType
		{
		EPageTypeFrame,
		EPageTypeFrameset,
		EPageTypeTerminator,
		EPageTypeUnknown
		};

	static CFrameInfo* NewL(TInt aFrameID, TInt aParentID, CWebModel* aWebModel);

	void ResetInfo();

	IMPORT_C TInt      FrameID();
	IMPORT_C TInt      ParentID();
	IMPORT_C TBool     IsTopPage();
	IMPORT_C TBool     IsFrameSet();
	IMPORT_C TPageType PageType();

	void SetIsFrameSetFlag(TBool  aIsFrameSet);
	void SetPageType(TPageType   aPageType);

#ifdef _DEBUG
	void __LogIt();
#endif _DEBUG

private:
	CFrameInfo(TInt aFrameID, TInt aParentID, CWebModel* aWebModel);

	const TInt iWebClassID;
	CWebModel* iWebModel;

	TInt       iFrameID;					// ID of the frame
	TInt       iParentID;                   // ID of frames' parent. Value of -1 means no parent
	TBool      iIsFrameSet;					// Whether the frame is a frameset (ie contains more frames.)  This flag will be FALSE if an IFRAME is present, so GetFramesList(n) must be used to determine if there is an IFRAME once the frame has been loaded
	TPageType  iPageType;					// What type of object this ‘frame’ is

	__DECLARE_LOG;
	};

//-----------------------------------------------------------------------------
// Used for passing information about a frame from the engine to the UI.
// Only contains information which is known about the frame from the frameset
// or page (in the case of an embedded IFRAME) which contains it - 
// ie information about the frame which is available
// before the loading of the frame itself begins.  Also provides the information
// which is required for the UI to start the load of the frame itself.
//-----------------------------------------------------------------------------
class CFrameSetInfo: public CBase
	{
public:

//Enumerated types
	enum TIFrameAlignment
		{
		EIFrameAlignNone,
		EIFrameAlignVertical,
		EIFrameAlignHorizontal
		};

	enum TFrameScroll
		{
		ETFrameScrollingOn,
		ETFrameScrollingOff,
		ETFrameScrollingAuto
		};

	enum TFrameOrientation
		{
		ETFrameOrientationColumn,
		ETFrameOrientationRow,
		ETFrameOrientationNone,
		ETFrameOrientationGrid, 
		ETFrameOrientationUnKnown
		};

	~CFrameSetInfo();					//Cleans up descriptors holding URL etc.

	static CFrameSetInfo* NewL(TInt aFrameID, TInt aParentID, CWebModel* aWebModel);

	void ResetInfo();

	IMPORT_C TInt         FrameID();
	IMPORT_C TInt         ParentID();

	IMPORT_C TPtrC        FrameName();
	IMPORT_C TPtrC        URL();
	IMPORT_C TPtrC        LongDesc();
	IMPORT_C TBool        IsIFrame();

	IMPORT_C TFrameScroll Scroll();
	IMPORT_C TBool        Border();
	IMPORT_C TUint        BorderSize();
	IMPORT_C TInt         MarginWidth();
	IMPORT_C TInt         MarginHeight();
	IMPORT_C TBool        NoResize();
	IMPORT_C TIFrameAlignment Align();

	IMPORT_C TFrameOrientation Orientation();
	IMPORT_C TInt         LeftFrameID();
	IMPORT_C TInt         RightFrameID();
	IMPORT_C TInt         UpFrameID();
	IMPORT_C TInt         DownFrameID();
	IMPORT_C TInt         HSize();
	IMPORT_C TInt         VSize();

	IMPORT_C TInt         Rows();
	IMPORT_C TInt         Columns();

	void  SetFrameNameL  (TPtrC aFrameName);
	void  SetUrlL        (TPtrC aURL);
	void  SetLongDescL   (TPtrC aLongDesc);
	void  SetIsIFrameFlag(TBool aIsIFrame);

	void  SetScroll      (TFrameScroll aScroll);
	void  SetBorderFlag  (TBool        aBorder);
	void  SetBorderSize  (TUint        aBorderSize);
	void  SetMarginWidth (TInt         aMarginWidth);
	void  SetMarginHeight(TInt         aMarginHeight);
	void  SetNoResizeFlag(TBool        aNoResize);
	void  SetAlignment   (TIFrameAlignment aAlign);
	
	void  SetOrientation (TFrameOrientation aOrientation);
	void  SetLeftFrameID (TInt  aLeftFrameID);
	void  SetRightFrameID(TInt  aRightFrameID);
	void  SetUpFrameID   (TInt  aUpFrameID);
	void  SetDownFrameID (TInt  aDownFrameID);

	IMPORT_C void SetHSize(TInt  aHSize);
	IMPORT_C void SetVSize(TInt  aVSize);

	void  SetRows(TInt aNumRows);
	void  SetColumns(TInt aNumColumns);

	void CopyTopologyL(CFrameSetInfo* aInfo);

#ifdef _DEBUG
	void __LogIt();
#endif _DEBUG

private:
	CFrameSetInfo(TInt aFrameID, TInt aParentID, CWebModel* aWebModel);

	const TInt iWebClassID;
	CWebModel* iWebModel;

protected:
//General params						//Pointers are owned by CFramesetInfo
	TInt   iFrameID;					//Integer id of the frame as used in the engine.  0 is always the top level frame.
	TInt   iParentID;						//The frame ID of the parent of this frame.  Top level frame has iParent=-1

	HBufC* iFrameName;					//Long description of the frame
	HBufC* iUrl;						//The name of the frame as defined in the frameset
	HBufC* iLongDesc;					//URL of the contents of the frame
	TBool  iIsIFrame;					//Is the frame an IFRAME

//Formatting params
	TFrameScroll iScroll;				//Scrolling On, Off or Auto
	TBool iBorder;						//Frame border On or Off
	TUint iBorderSize;					//Size of the frame border
	TInt  iMarginWidth;					//Margin Height in pixels
	TInt  iMarginHeight;				//Margin Width in pixels
	TBool iNoResize;					//Whether the frame may be resized.  Ignored for IFRAME
	TIFrameAlignment iAlign;			//Specifies horizontal or vertical alignment (IFRAME only)

//Layout params
	//If Orientation==row, iUpFrame & iDownFrame are undefined. If col, ileftFrame & iRightFrame are undefined
	
	TFrameOrientation iOrientation;		//Is the frame in a row, column or grid. Ignored for IFRAME

	TInt iLeftFrameID;					//The previous horizontal frame (left). Ignored for IFRAME
	TInt iRightFrameID;					//The next horizontal frame (right). Ignored for IFRAME
	TInt iUpFrameID;					//The previous vertical frame (up). Ignored for IFRAME
	TInt iDownFrameID;					//The next vertical frame (down). Ignored for IFRAME

	TInt iHSize;						//0->KWebModelMaxFrameSize, ratio of frameset horizontal space occupied. Ignored for IFRAME.  1000000 represents full screen width.
	TInt iVSize;						//0->KWebModelMaxFrameSize, ratio of frameset vertical space occupied. Ignored for IFRAME.  1000000 represents full screen width.

	TInt iNumRows;
	TInt iNumColumns;

	__DECLARE_LOG;

	//Engine params
	//CWebObjectLoader* iLoader;			//Pointer to the CWebObjectLoader in the engine which can load the frame
	};

//-----------------------------------------------------------------------------
// The web model class: this is the engine.
//-----------------------------------------------------------------------------
class CWebModel: public CBase, public MWebEmbeddedObjectServices //, public MWebEventHandler
    {
public:

	// text formats
	enum TWebTextStyles
		{
		EWebTextBodyText = 0,
		EWebTextHeading1 = 1,
		EWebTextHeading2 = 2,
		EWebTextHeading3 = 3,
		EWebTextHeading4 = 4,
		EWebTextHeading5 = 5,
		EWebTextHeading6 = 6,
		EWebTextFormats = 7
		};

	// icons used in place of objects
	enum TWebIcons
		{
		EWebIconPlain,			// an ordinary object
		EWebIconLink,			// an object that is also a hypertext link
		EWebIconBrokenPlain,	// an ordinary object that could not be loaded
		EWebIconBrokenLink,	// a hypertext link object that could not be loaded
		EWebIconCount = 4
		};

	// parameters for SelectObjectL
	class TSelectObjectParam
		{
	public:
		IMPORT_C TSelectObjectParam();

									// (values set by constructor are in brackets)
		TBool iForwards;			// search forwards (true)
		TBool iWholeDocument;		// search entire document (false)
		TBool iAllowHypertextLinks;	// include hypertext links in the search (true)
		TBool iAllowImageMaps;		// include image maps in the search (true)
		TBool iAllowFormElements;	// include form elements in the search (true)
		TBool iAllowUnloadedImages;	// include unloaded images in the search (false)
		TBool iAllowLoadedImages;	// include loaded images in the search (false)
		TBool iAllowApplets;	// include applets in the search (false)
		TBool iAllowObjects;	// include objects in the search (false)
		};

	enum TMovementType
		{
		EFNoMovement = TCursorPosition::EFNoMovement,
		EFLeft       = TCursorPosition::EFLeft,
		EFRight      = TCursorPosition::EFRight,
		EFLineUp     = TCursorPosition::EFLineUp,
		EFLineDown   = TCursorPosition::EFLineDown,
		EFPageUp     = TCursorPosition::EFPageUp,
		EFPageDown   = TCursorPosition::EFPageDown,
		EFLineBeg    = TCursorPosition::EFLineBeg,
		EFLineEnd    = TCursorPosition::EFLineEnd,
		EDocumentBeg = 1000,		// so as to be different to all the above even if they change
		EDocumentEnd
		};

	// scrolling parameters
	enum TScrollParam
		{
		EScrollNone,			// perform no scrolling in the specified dimension
		EScrollIntoView,	// scroll the area into view if any part of it is off the display, otherwise do nothing
		EScrollToTopOrLeft	// scroll to the top or left edge of the display
		};

	// text search flags
	enum TWebFindFlags
		{
		EFindBackwards     = 1,
		EFindCaseSensitive = 2,
		EFindWholeWord     = 4
		};

	// network settings flags
	enum TWebNetworkFlags
		{
		ENoLocations  = 1,
		ENoModems     = 2,
		ENoServices   = 4
		};

	// other enums
	enum TWebFlags
		{
		ERelativeFontSizes = 7		// number of entries in iRelativeFontSize
		};
	
	// Various resources held by model for use by plug-ins.
	// These are retrieved via the WebModelResourceItem method
	enum TWebModelResource
		{
		EResourceUnknown,
		EResourceFramePool,
		EResourceFrameHolder,
		EResourceFrame,
		EResourcePictureHolder,
		EResourceFrameTextStore,
		EResourceHotSpotList,
		EResourceLabelTable,
		EResourceAnchorTable,
		EResourceMoversTable,
		EResourcePlugInContext,
		EResourceEngineEvents,
		EResourceHistoryManipulator,
		EResourceClientRefresher
		};

	//EXPORTED PUBLIC FUNCTIONS
	IMPORT_C CFrameInfo*          FrameInfo   (TInt aFrameID);
	IMPORT_C CFrameSetInfo*       FrameSetInfo(TInt aFrameID);
	IMPORT_C CArrayFixFlat<TInt>* FramesList  (TInt aFrameID);

	IMPORT_C TBool CopyToClipboardL(TInt aFrameID);
	IMPORT_C TBool FindTextL(const TDesC& aTarget,TInt aPos, TInt aFrameID, TInt aFlags);

	IMPORT_C void  GetSelection(TInt& aCursor,TInt& aAnchor, TInt aFrameID);
	IMPORT_C TBool GetSelectionInfo(MWebEventHandler::TObjectInfo& aInfo, TInt aFrameID) const;
	IMPORT_C void  SelectAllL(TInt aFrameID);
	IMPORT_C TBool SelectionExists(TInt aFrameID) const;

	IMPORT_C TBool SelectObjectL(const TSelectObjectParam& aParam, TInt aFrameID);

	IMPORT_C TBool AnyImagesToLoad(TInt aFrameID);
	IMPORT_C TBool GettingData(TInt aFrameID) const;

	IMPORT_C void  HandleEventL(const MWebEventHandler::TEventInput& aEventInput,MWebEventHandler::TEventOutput& aEventOutput, TInt aFrameID, TBool aRedraw);
	IMPORT_C TBool HandleRawKeyEventL(const TKeyEvent& aEvent, TInt aFrameID);
	IMPORT_C TBool HandleRawPointerEventL(const TPointerEvent& aEvent,TPoint aObjectPos, TInt aFrameID);
	
	IMPORT_C void  OnPageFocusChangeL(TBool aGainingFocus, TInt aFrameID);

	IMPORT_C void  GetDocumentSize(TInt& aSizeInBytes,TInt& aTotalSizeInBytes, TInt aFrameID) const;

	IMPORT_C const CFbsBitmap* ImageIcon(TInt aIndex) const;

	IMPORT_C MWebModelObserver* Observer() const;

	IMPORT_C void  SetImageIcons(const CFbsBitmap* aPlainIcon, const CFbsBitmap* aLinkIcon, const CFbsBitmap* aBrokenPlainIcon, const CFbsBitmap* aBrokenLinkIcon);
	IMPORT_C void  SetObserver(MWebModelObserver* aObserver);

	IMPORT_C MLayDoc* Text(TInt aFrameID) const;

	IMPORT_C TPtrC Title(TInt aFrameID) const;
	IMPORT_C TPtrC Url(TInt aFrameID) const;

	IMPORT_C HBufC* BaseUrlL(TInt aFrameID) const;

	IMPORT_C const TRect& ViewRect(TInt aFrameID) const;

	IMPORT_C RWindow&    Window(TInt aFrameID) const;
	IMPORT_C RWsSession* WindowSession()       const;

	IMPORT_C void  Disconnect();
	
	IMPORT_C void  FormatFrameL(TInt aFrameID);
	IMPORT_C void  DrawFrameL(const TRect& aRect, TInt aFrameID);

	IMPORT_C void  GotoCharPosL(TInt aPos, TInt aFrameID, TScrollParam aHorizParam = EScrollIntoView, TScrollParam aVertParam = EScrollIntoView);
	IMPORT_C void  GotoLabelL(const TDesC& aLabel, TInt aFrameID);
	IMPORT_C void  GotoTagIDL(const TDesC& aID, TInt aFrameID);
	IMPORT_C void  LoadAllImagesL(TInt aFrameID);
	IMPORT_C void  LoadAllObjectsL(TInt aFrameID);
	IMPORT_C TBool LoadSelectedObjectL(TInt aFrameID);

	IMPORT_C TInt  OpenTopPageL(const TDesC& aUrlName,   TBool aForceReload=EFalse);
	IMPORT_C TInt  OpenTopPageL(CWtlDocument *aDocument);

	IMPORT_C TInt  ReplacePageL(const TDesC& aUrlName,   TInt aOldFrameID, TBool aForceReload=EFalse);
	IMPORT_C TInt  ReplacePageL(CWtlDocument *aDocument, TInt aOldFrameID);

	IMPORT_C void  LoadPageL(const TDesC& aUrlName,   TInt aFrameID, TBool aForceReload=EFalse);
	IMPORT_C void  LoadPageL(CWtlDocument *aDocument, TInt aFrameID);

	IMPORT_C void  ClosePage(TInt aFrameID);

	IMPORT_C TBool PrintL(CGraphicsDevice* aLayoutDevice,TInt aPageNo, const TBandAttributes& aBandInPixels );
	IMPORT_C TBool PrintL(CGraphicsDevice* aLayoutDevice,TInt aPageNo, const TBandAttributes& aBandInPixels, TInt aFrameID);
	IMPORT_C CTextPageRegionPrinter* GetRegionPrinterL( TInt aFrameID ) ;  // require by UI for PrintProgressDialog
	IMPORT_C void SetPrinterDevice( CPrintSetup* aPrintSetup /*CPrinterDevice* aPrinterDevice*/ ) ;  
	
	IMPORT_C void  ReformatL(TInt aFrameID);
	IMPORT_C CWebDataFetch* SaveLC(const TDesC& aUrl,MDataAccumulator* aHandler,TInt aFrameID,MWebModelObserver* aObserver = NULL, 
								   TBool aConvert = EFalse, TBool aDoKeepCached = EFalse) const;
	
	IMPORT_C void  ScrollByL    (TMovementType aMovement, TInt aFrameID);
	IMPORT_C void  ScrollToPosL (TPoint aPosition, TInt aFrameID);
	IMPORT_C void  ScrollToAreaL(TRect aArea, TInt aFrameID);
	IMPORT_C TInt  HorizontalScroll(TInt aFrameID) const;

	IMPORT_C void  StartGettingDataL(TInt aFrameID);
	IMPORT_C void  StopGettingData(TInt aFrameID);

	IMPORT_C void  GetCharFormat(TCharFormat& aFormat,TInt aIndex,TInt aRelativeFontSize = 0) const;
	IMPORT_C void  SetCharFormatL(TInt aIndex, const TCharFormat& aFormat, TBool aReformat = EFalse);

	IMPORT_C void  GetFontSpec(TFontSpec& aFontSpec,TInt aIndex,TInt aRelativeFontSize = 0) const;
	IMPORT_C void  SetFontSpecL(TInt aIndex, const TFontSpec& aFontSpec, TBool aReformat = EFalse);

	IMPORT_C void  GetMonoTypeface(TTypeface& aTypeface) const;
	IMPORT_C void  SetMonoTypefaceL(const TTypeface& aTypeface,TBool aReformat = EFalse);

	IMPORT_C void  GetParaFormatL(CParaFormat& aFormat,TInt aIndex) const;
	IMPORT_C void  SetParaFormatL(TInt aIndex,const CParaFormat& aFormat,TBool aReformat = EFalse);

	IMPORT_C void  SetBaseFontSizeInTwipsL(TInt aSize,TBool aReformat = EFalse);

	IMPORT_C void  SetDisplayAttributesL(TZoomFactor* aZoom,TInt aWidthInPixels, TInt aFrameID);
	IMPORT_C void  SetRelativeFontSizesL(const TInt* aSizesInThousandths,TBool aReformat = EFalse);
	IMPORT_C TBool SetTextLayoutAndView(CTextLayout* aTextLayout,CTextView* aTextView,TInt aFrameID);
	IMPORT_C void  SetWindow(RWindow* aWindow, TInt aFrameID);
	IMPORT_C void  SetWindowSession(RWsSession* aWindowSession);

	IMPORT_C TZoomFactor* ZoomFactor() const;

	IMPORT_C static CWebModel* NewL(TInt aHistoryListSize);
	IMPORT_C ~CWebModel();

	IMPORT_C void  StoreL(CDictionaryStore* aIniFile) const;
	IMPORT_C void  RestoreL(CDictionaryStore* aIniFile);
	IMPORT_C void  ExternalizeL(RWriteStream& aStream) const;
	IMPORT_C void  InternalizeL(RReadStream& aStream);

	IMPORT_C TPtrC Label(TInt aFrameID) const;

	IMPORT_C CWebServicesModel* WebServices() const;

	IMPORT_C CWebPlugInRegistry* PlugInRegistry();
	
	// History list functions
	IMPORT_C TBool  GoForwardL(TInt aFrameID, TInt aSteps = 1);
	IMPORT_C TBool  GoBackL(TInt aFrameID, TInt aSteps = 1);
	IMPORT_C void   AddTopPageToHistoryListL(TInt aFrameID);
	IMPORT_C void   AppendChildPagesToHistoryListL(TInt aFrameID);
	IMPORT_C void   UpdateCurrentPageHistoryListTitleL(const TDesC& aTitle);
	IMPORT_C TBool  GotoHistoryListItemL(TInt aHistoryListIndex, TInt aRootFrameID);
	IMPORT_C TBool  ReloadCurrentHistoryListItemL(TInt aFrameID);

	// Configuration
	IMPORT_C TBool  ConfigItemL(TBoolConfigurationItem aItem) const;
	IMPORT_C TInt   ConfigItemL(TNumericConfigurationItem aItem) const;
	IMPORT_C TPtrC  ConfigItemL(TWebStringConfigurationItem aItem) const;
	IMPORT_C HBufC* ConfigItemL(THBufConfigurationItem aItem) const;
	IMPORT_C void   SetConfigItemL(TBoolConfigurationItem aItem, TBool aValue);
	IMPORT_C void   SetConfigItemL(TNumericConfigurationItem aItem, TInt aValue);
	IMPORT_C void   SetConfigItemL(TWebStringConfigurationItem aItem,const TDesC& aValue);
	IMPORT_C void   SetConfigItemL(THBufConfigurationItem aItem, const TDesC& aValue);

	IMPORT_C HBufC* GetCurrentFullUrlL(TInt aFrameID);
	IMPORT_C HBufC* GetCurrentLeafUrlL(TInt aFrameID);
		
	IMPORT_C void CancelExtraLineHeight(CTextLayout* aTextLayout);

	IMPORT_C TBool GetAuthenticationL(CWtlDocument* aDocument,TBuf<KMaxWebAuthenticationNameLength>& aName,TBuf<KMaxWebAuthenticationPasswordLength>& aPassword, TInt aFrameID) const;
	IMPORT_C TBool CommitAuthenticationL();

	IMPORT_C MWebDocumentInfo* DocumentInfoLC(TInt aFrameID);

	TInt   CharPosOfTopLeftOfDisplayL(TInt aFrameID);
	TPoint DocumentPos(TInt aFrameID);

	CWtlDocument*  Document(TInt aFrameID) const;

	// Provide the printer device to the Frames
	IMPORT_C CPrinterDevice* GetPrinterDevice() ;
	IMPORT_C CPrintSetup* GetPrintSetup() ;
	IMPORT_C TBool IsPrinting() ; // returns iPrinting.
	IMPORT_C TInt NumPagesInDocL( TInt aFrameID ) ; // returns number of pages for printing.

	IMPORT_C TAny* ResourceItem(TWebModelResource aItem, TInt aFrameID) const;
	IMPORT_C TBool SetResourceItemL(TWebModelResource aItem, TAny* aValue, TInt aFrameID);

	IMPORT_C HBufC8* SecurityInfoL (TInt aFrameID);

	IMPORT_C TAny* CallFunctionL(TInt aCode, TAny* aParam1, TAny* aParam2, TInt aFrameID);

	IMPORT_C TInt CWebModel::WebLogLevel(const TInt aWebClassID);

	IMPORT_C TBool IsNestedFrameSet(TInt aFrameID);

	// frame tree info functions
	IMPORT_C TInt RootFrameID(const TInt aFrameID);
	IMPORT_C TBool IsAncestorFrame(TInt aAncestorID, TInt aChildID);	// bottom-up scan, passes even after frame is removed from tree
	IMPORT_C TBool IsInFrameTree(TInt aRootId, TInt aFrameId) const;	// Top down scan, only passes if frame is in tree
	IMPORT_C TPoint FramePosInGrid(TInt aFrameId) const;
	IMPORT_C TBool IsTreeShapeKnown(TInt aFrameId) const;
	IMPORT_C TBool IsTreeGettingAnyData(TInt aFrameId) const;
	IMPORT_C TInt FirstPreorderFrameId(TInt& aFrameId) const;		// returns KErrNone/KErrNotFound
	IMPORT_C TInt NextPreorderFrameId(TInt& aFrameId) const;		// returns KErrNone/KErrNotFound
	IMPORT_C TInt NextPreorderRight(TInt& aFrameId) const;
	IMPORT_C void SetFrameOwnedByWebControl(TInt aFrameID);

private:
	CWebModel();
	void ConstructL(TInt aHistoryListSize);	
	TInt DisplayWidthInPixels( MGraphicsDeviceMap* aMap,  TInt aFrameID) ;
	TInt ReplacePageL(const TDesC& aUrlName, TInt aOldFrameID, CBufBase* aFormData, TBool aForceReload, TInt aHistIndex, TInt aDocPos);
	TBool LoadPageChangesL(CWebPageChangeList* aPageChanges, TBool aForceReload, TBool aHistoryPos);
	void  SendObserverMessageL(TInt aFrameID, MWebModelObserver::TWebModelObserverMessage aType, TAny* aAdditionalData);
	TBool IsFrameSet(TInt aFrameID) const;

private:
	const TInt iWebClassID;                   // Required for class based logging
	CWebModel* iWebModel;                       // Required for class based logging

	CWtlSession* iSession;						// A pointer to the internet session, owned by CWebServicesModel
	HBufC* iAltText;							// alternative text used by default in images
	MWebModelObserver *iObserver;				// if non-null, observer of changes

	TZoomFactor* iZoomFactor;					// the zoom factor - must be set by the UI (SetDisplayAttributesL)
	TInt iLastZoomState ;							// This is the last zoom state - note that it is an integer, not a zoom factor

	const CFbsBitmap* iImageIcon[EWebIconCount];// icons used for unloaded images
	
	CParaFormat* iParaFormat[EWebTextFormats];	// paragraph formats
	TCharFormat  iCharFormat[EWebTextFormats];	// character formats
	TInt iRelativeFontSize[ERelativeFontSizes];	// relative font sizes in thousandths of the base font size
	TTypeface    iMonoTypeface;					// the typeface used for text usually rendered as mono-width

	RWsSession* iWindowSession;

	CWebFramePool* iFramePool;					// The pool of web frame pages and sets

	CWebServicesModel* iServices;				// the web services model
	
	CPrinterDevice* iPrinterDevice ;			// A single printer device is used by all frames.
	CPrintSetup* iPrintSetup ;						// A printer setup (required for telling paginator about margins)

	TBool iPrinting ; // Flag to indicate that printing is in progress.

	TBool iLoadingImages;                       // if true, load images; else show a placeholder
    TBool iAnimating;                           // if true allow image animation
    TBool iUsingColor;                          // use colours set by <body>, <font>, etc. (versus black on white only)? 
	TBool iShowingSelection;					// show selected text by highlighting it?
	TBool iRenderingFrames;
	TBool iShowLinkInNoFrames;

	CWebPlugInRegistry* iPIRegistry;            // The Plug In registry

	CWebHistoryManipulator* iHistoryMan;

	void  GetDebugClassIDsL();
	TInt* iDebugClassIDs;
	TInt  iNumDebugClassIDs;

	__DECLARE_LOG;
	};

#endif	//__WEBMOD_H__
