sl@0: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #ifndef __DEBUGLOG_H__ sl@0: #define __DEBUGLOG_H__ sl@0: sl@0: #pragma warning( disable : 4710 ) //function abc not expanded sl@0: sl@0: #include "../SERVER/w32cmd.h" sl@0: sl@0: typedef TBuf<32> TShortBuf; sl@0: typedef TBuf<64> TLongBuf; sl@0: sl@0: enum {LogTBufSize=0xA0}; sl@0: sl@0: sl@0: class TDebugLogOverflow : public TDes16Overflow sl@0: { sl@0: public: sl@0: inline TDebugLogOverflow(); sl@0: inline void Reset(); sl@0: inline TBool IsError(); sl@0: //Pure virtual function from TDesNnOverflow sl@0: void Overflow(TDes &aDes); sl@0: private: sl@0: TBool iError; sl@0: }; sl@0: sl@0: class TWsDecoder sl@0: { sl@0: public: sl@0: enum {ENewClientClass=0x9999}; sl@0: union TWsCmdUnion sl@0: { sl@0: const TAny *any; sl@0: TWsClCmdUnion client; sl@0: TWsWinCmdUnion window; sl@0: TWsGcCmdUnion gc; sl@0: TWsSdCmdUnion sd; sl@0: TWsAnimDllCmdUnion anim; sl@0: }; sl@0: TDesC &CommandBuf(TInt aApp); sl@0: TDesC &Command(TInt aClass, TInt aOpcode, const TAny *aCmdData, TInt aHandle); sl@0: TDesC &CommandReply(TInt aData); sl@0: TDesC &CommandReplyBuf(const TDesC8 &aDes); sl@0: TDesC &CommandReplyBuf(const TDesC16 &aDes); sl@0: TDesC &NewClient(TUint aConnectionHandle); sl@0: TDesC &SignalEvent(TInt aApp); sl@0: TDesC &Panic(TInt aApp, TInt aReason); sl@0: TDesC &MiscMessage(const TDesC &aFormat,TInt aParam); sl@0: void Disable(); sl@0: void Enable(); sl@0: private: sl@0: void UnKnown(); sl@0: void UnKnownOpcode(TBuf &aText, TInt aOpcode); sl@0: void UnKnownReplyBuf(TBuf &aText, TInt aOpcode); sl@0: void AppendPoint(TBuf &aText, const TDesC8 *aReplyDes8); sl@0: void AppendRect(TBuf &aText, const TDesC8 *aReplyDes8); sl@0: void AppendDesc(TBuf &aText, const TDesC8 *aReplyDes8); sl@0: void AppendDesc(TBuf &aText, const TDesC16 *aReplyDes16); sl@0: void decodeWindow(TBuf &aText,TInt aOpcode,const TAny *aCmdData); sl@0: void DecodeWindowGroup(TBuf &aText, TInt aOpcode, const TAny *aCmdData, TInt aHandle); sl@0: void DecodeClient(TBuf &aText, TInt aOpcode, const TAny *aCmdData, TInt aHandle); sl@0: void DecodeWindow(TBuf &aText, TInt aOpcode, const TAny *aCmdData, TInt aHandle); sl@0: void DecodeGc(TBuf &aText, TInt aOpcode, const TAny *aCmdData, TInt aHandle); sl@0: void DecodeGc1(TBuf &aText, TInt aOpcode, const TAny *aCmdData); sl@0: void DecodeGc2(TBuf &aText, TInt aOpcode, const TAny *aCmdData); sl@0: void DecodeGc3(TBuf &aText, TInt aOpcode, const TAny *aCmdData); sl@0: void DecodeScreenDevice(TBuf &aText, TInt aOpcode, const TAny *aCmdData, TInt aHandle); sl@0: void DecodeAnimDll(TBuf &aText, TInt aOpcode, const TAny *aCmdData, TInt aHandle); sl@0: void DecodeSpriteBase(TBuf &aText, TInt aOpcode, const TAny *aCmdData, TInt aHandle); sl@0: void DecodeBitmap(TBuf &aText, TInt aOpcode, const TAny *aCmdData, TInt aHandle); sl@0: void DecodeDirect(TBuf &aText, TInt aOpcode, const TAny *aCmdData, TInt aHandle); sl@0: void DecodeClick(TBuf &aText, TInt aOpcode, const TAny *aCmdData, TInt aHandle); sl@0: void ReplyBufWindowGroup(TBuf &aText, TInt aOpcode, const TDesC8 *aReplyDes8, const TDesC *aReplyDesText); sl@0: void ReplyBufWindow(TBuf &aText, TInt aOpcode, const TDesC8 *aReplyDes8, const TDesC *aReplyDesText); sl@0: void ReplyBufClient(TBuf &aText, TInt aOpcode, const TDesC8 *aReplyDes8, const TDesC *aReplyDesText); sl@0: void ReplyBufScreenDevice(TBuf &aText, TInt aOpcode, const TDesC8 *aReplyDes8, const TDesC *aReplyDesText); sl@0: TDesC &commandDetails(TInt aClass, TInt aOpcode, const TAny *aCmdData, TInt aHandle); sl@0: TDesC &eventDetails(const TWsEvent *aWsEvent); sl@0: TDesC &eventDetails(const TRawEvent *aEvent); sl@0: TDesC &replyBufDetails(TInt aClass, TInt aOpcode, const TDesC8 *aReplyDes8, const TDesC *aReplyDesText); sl@0: private: sl@0: TBuf iEventDetailsText; sl@0: TBuf iCommandDetailsText; sl@0: TBuf iText; sl@0: TUint iCommandCount; sl@0: TUint iEventCount; sl@0: TInt iRequestFuncClass; sl@0: TInt iHandle; sl@0: TInt iPrevOpcode; sl@0: TDebugLogOverflow iOverflowHandler; sl@0: }; sl@0: sl@0: class TDebugLogTextHandler sl@0: { sl@0: public: sl@0: enum TArrayType sl@0: { sl@0: EInt, sl@0: ERgb sl@0: }; sl@0: static void Append(TDes &aBuf1, const TDesC &aBuf2); sl@0: static void TestAppend(); sl@0: static TBuf<20> FormatBool(TBool aBool); sl@0: static TBuf<32> FormatPoint(const TPoint &aPoint); sl@0: static TBuf<32> FormatSize(const TSize &aSize); sl@0: static TBuf<64> FormatRect(const TRect &aRect); sl@0: static TBuf<40> FormatRgb(const TRgb &aRgb); sl@0: static TBuf<20> PointerEventType(TPointerEvent::TType aType); sl@0: static TBuf FormatArray(TArrayType aArrayType, const TUint8 *aArrayPtr, TUint aNumElems); sl@0: private: sl@0: static TBuf<0x20> formatArrayElement(TArrayType aArrayType, const TUint8 *aArrayPtr); sl@0: static void panic(TInt aReason); sl@0: }; sl@0: sl@0: class CDebugLogDevice : public CBase sl@0: { sl@0: public: sl@0: virtual void ConstructL(TBool aIsFirst, TDesC &aParams)=0; sl@0: virtual void WriteToLogL(const TDesC &aDes, const TDesC &aDes2)=0; sl@0: virtual void WriteToLog8L(const TDesC8 &aDes, const TDesC8 &aDes2)=0; sl@0: }; sl@0: sl@0: class CDebugLog: public CDebugLogBase sl@0: { sl@0: private: sl@0: enum {KNumProfiles=10}; sl@0: public: sl@0: IMPORT_C CDebugLog(CDebugLogDevice *aDevice); sl@0: ~CDebugLog(); sl@0: IMPORT_C void ConstructL(TBool aIsFirst, TDesC &aParams); sl@0: //Pure virtual functions from CDebugLogBase sl@0: void CommandBuf(TInt aApp); sl@0: void Command(TInt aClass, TInt aOpcode, const TAny *aCmdData, TInt aHandle); sl@0: void NewClient(TUint aConnectionHandle); sl@0: void Reply(TInt aData); sl@0: void ReplyBuf(const TDesC8 &aDes); sl@0: void ReplyBuf(const TDesC16 &aDes); sl@0: void SignalEvent(TInt aApp); sl@0: void Panic(TInt aApp, TInt aReason); sl@0: void MiscMessage(TInt aPriority,const TDesC &aFmt,TInt aParam=0); sl@0: void HeapDump(); sl@0: void SetLoggingLevel(TInt aLevel); sl@0: void IniFileSettingRead(TInt aScreen, const TDesC& aVarName, TBool aFound, const TDesC& aResult); sl@0: sl@0: private: sl@0: void AppendProfileNum(TDes &aDes, TInt aNum); sl@0: void AppendProfileCount(TDes &aDes, TInt aNum); sl@0: void LogProfiles(); sl@0: void WriteToLog(const TDesC &aDes,TInt aLevel=ELogEverything); sl@0: void MiscMessage(const TDesC &aFmt,TInt aParam=0); sl@0: sl@0: private: sl@0: CDebugLogDevice *iDevice; sl@0: TWsDecoder iWsDecoder; sl@0: TBool iIsDisabled; sl@0: TInt iErr; sl@0: TTime iPrevTime; sl@0: TInt iExtraLen; sl@0: TInt iLevel; //The current logging level sl@0: TInt iLastApp; sl@0: }; sl@0: sl@0: GLREF_C TInt hHandleToValue(TUint32 handle); sl@0: sl@0: sl@0: // Inline functions sl@0: /*TDebugLogOverflow*/ sl@0: inline TDebugLogOverflow::TDebugLogOverflow() :iError(EFalse) sl@0: {} sl@0: inline void TDebugLogOverflow::Reset() sl@0: {iError=EFalse;} sl@0: inline TBool TDebugLogOverflow::IsError() sl@0: {return iError;} sl@0: sl@0: #endif sl@0: