sl@0: // Copyright (c) 2000-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: // Definition of Direct Screen Access class sl@0: // sl@0: // sl@0: sl@0: #ifndef __DIRECT_H__ sl@0: #define __DIRECT_H__ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include "w32cmd.h" sl@0: #include "OBJECT.H" sl@0: #include "CLIENT.H" sl@0: #include sl@0: sl@0: class CWsClientWindow; sl@0: class CWsDirectScreenAccess; sl@0: class CDsaMsgQueue; sl@0: sl@0: NONSHARABLE_CLASS(CWsAbortDirect) : public CActive sl@0: { sl@0: public: sl@0: CWsAbortDirect(CWsDirectScreenAccess* aDirect,CDsaMsgQueue* aParent); sl@0: ~CWsAbortDirect(); sl@0: void Started(); sl@0: void Complete(TInt aReason); sl@0: private: sl@0: //Pure virtual function from CActive sl@0: void RunL(); sl@0: void DoCancel(); sl@0: private: sl@0: CWsDirectScreenAccess* iDirect; sl@0: CDsaMsgQueue* iParent; sl@0: }; sl@0: sl@0: NONSHARABLE_CLASS(CDsaMsgQueue) : public CBase sl@0: { sl@0: public: sl@0: static CDsaMsgQueue* NewL(CWsDirectScreenAccess* aDirect); sl@0: ~CDsaMsgQueue(); sl@0: TInt CreateSendQueue(); sl@0: TInt CreateRecQueue(); sl@0: RMsgQueueBase* SendQueue(); sl@0: RMsgQueueBase* RecQueue(); sl@0: void Cancel(); sl@0: void Complete(); sl@0: void CompleteAbort(); sl@0: void Started(); sl@0: TInt Send(TInt aData); sl@0: TInt ReceiveData(); sl@0: TRequestStatus& Status() sl@0: { sl@0: return iAborted->iStatus; sl@0: } sl@0: sl@0: private: sl@0: CDsaMsgQueue(); sl@0: void ConstructL(CWsDirectScreenAccess* aDirect); sl@0: private: sl@0: RMsgQueueBase iSendQueue; sl@0: RMsgQueueBase iRecQueue; sl@0: CWsAbortDirect* iAborted; sl@0: }; sl@0: sl@0: class CWsDirectScreenAccess : public CWsScreenObject sl@0: { sl@0: public: sl@0: enum TStatus sl@0: { sl@0: EDirectStatusTimeNotCreated, sl@0: EDirectStatusNone, sl@0: EDirectStatusInitialising, sl@0: EDirectStatusRunning, sl@0: EDirectStatusCompleted, sl@0: EDirectStatusCanceling, sl@0: EDirectStatusAbortedWindow, sl@0: EDirectStatusAbortedGlobal, sl@0: EDirectStatusAborted=EDirectStatusAbortedWindow, sl@0: }; sl@0: public: sl@0: static CWsDirectScreenAccess* NewL(CWsClient* aOwner); sl@0: ~CWsDirectScreenAccess(); sl@0: void Request(TInt handle); sl@0: void GetRegion(TInt aNumRects); sl@0: void Cancel(); sl@0: void Aborted(); sl@0: void AbortNow(); sl@0: TInt GetSendQueue(); sl@0: TInt GetRecQueue(); sl@0: void SignalAbort(RDirectScreenAccess::TTerminationReasons aReason); sl@0: inline TRequestStatus& AbortStatus() {return iMsgQueue->Status();} sl@0: void CancelAbortObject(); sl@0: void Abort(); sl@0: //Pure virtual function from CWsObject sl@0: void CommandL(TInt aOpcode, const TAny* aCmdData); sl@0: inline TBool IsVisible() const; sl@0: TBool IsAbortRequired(const TRegion& aTopVisibleRegion) const; sl@0: inline RWsRegion& VisibleRegion(); sl@0: inline CWsClientWindow* ClientWindow() const; sl@0: public: sl@0: TSglQueLink iLink; sl@0: TSglQueLink iMultipleDSALink; sl@0: TSglQueLink iAbortLink; // Used to build a list of DSA objects that need to be aborted on a specific window sl@0: private: sl@0: inline CWsDirectScreenAccess(CWsClient* aOwner): CWsScreenObject(aOwner,WS_HANDLE_DIRECT, aOwner->Screen()) {} sl@0: void ConstructL(); sl@0: void Initiate(); sl@0: void Terminate1(); sl@0: void Terminate2(); sl@0: void CorrectScreen(); sl@0: #if defined(_DEBUG) sl@0: TBool OnQueue(); sl@0: #endif sl@0: private: sl@0: CWsClientWindow* iWin; sl@0: RWsRegion iVisible; sl@0: CDsaMsgQueue* iMsgQueue; sl@0: TStatus iStatus; sl@0: RDirectScreenAccess::TTerminationReasons iAbortReason; sl@0: public: sl@0: TBool IsSyncTimeoutPending() const; sl@0: inline RRegion& RegionUnderSync(); sl@0: public: sl@0: class CDSARegionSyncTimer : public CTimer sl@0: { sl@0: sl@0: public: sl@0: enum TConsts sl@0: { sl@0: KRegionSyncTimeoutMicrosec = 100000 // 0.1 sec sl@0: }; sl@0: sl@0: public: sl@0: static CDSARegionSyncTimer* NewL(CWsDirectScreenAccess& aDSA); sl@0: sl@0: private: sl@0: void RunL(); sl@0: CDSARegionSyncTimer(CWsDirectScreenAccess& aDSA); sl@0: sl@0: private: sl@0: CWsDirectScreenAccess& iDSA; sl@0: }; sl@0: sl@0: private: sl@0: void DeleteRegionSyncWatchcat(); sl@0: void CancelFrozenRegion(); sl@0: void RegionSyncTimeout(); sl@0: sl@0: private: sl@0: CDSARegionSyncTimer* iRegionSync; sl@0: RRegion iFrozenRegion; sl@0: sl@0: friend class CWsDirectScreenAccess::CDSARegionSyncTimer; sl@0: }; sl@0: sl@0: inline TBool CWsDirectScreenAccess::IsVisible() const sl@0: { sl@0: return !iVisible.IsEmpty(); sl@0: } sl@0: sl@0: inline CWsClientWindow* CWsDirectScreenAccess::ClientWindow() const sl@0: { sl@0: return iWin; sl@0: } sl@0: sl@0: inline RRegion& CWsDirectScreenAccess::RegionUnderSync() sl@0: { sl@0: return iFrozenRegion; sl@0: } sl@0: #endif