1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/windowing/windowserver/test/tredir/wsredir.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,129 @@
1.4 +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +/**
1.20 + @file
1.21 + @test
1.22 + @internalComponent - Internal Symbian test code
1.23 +*/
1.24 +
1.25 +#include "wsredir.h"
1.26 +
1.27 +const TUint8 KCmdQuery = 0;
1.28 +const TUint8 KCmdSetGcFront = 1;
1.29 +const TUint8 KCmdSetGcBack = 2;
1.30 +const TUint8 KCmdResetGcFront = 3;
1.31 +const TUint8 KCmdResetGcBack = 4;
1.32 +const TUint8 KCmdSetBackObject = 5;
1.33 +const TUint8 KCmdResetBackObject= 6;
1.34 +
1.35 +const TUid KRedirectorInterfaceId = {0x10281e1d};
1.36 +const TUid KRedirectorImplId = {0x10281e1e};
1.37 +
1.38 +EXPORT_C CWsRedir* CWsRedir::NewL()
1.39 + {
1.40 + return NewL(0);
1.41 + }
1.42 +
1.43 +EXPORT_C CWsRedir* CWsRedir::NewL(TInt aScreenId)
1.44 + {
1.45 + return NewL(aScreenId, EFalse);
1.46 + }
1.47 +
1.48 +EXPORT_C CWsRedir* CWsRedir::NewL(TInt aScreenId, TBool aDisableWin)
1.49 + {
1.50 + CWsRedir* self = new(ELeave) CWsRedir;
1.51 + CleanupStack::PushL(self);
1.52 + TBuf8<2> data;
1.53 + data.Append((TUint8)aScreenId);
1.54 + data.Append((TUint8)aDisableWin);
1.55 + self->BaseConstructL(KRedirectorInterfaceId, KRedirectorImplId, data);
1.56 + CleanupStack::Pop(self);
1.57 + self->iIsReady = ETrue;
1.58 + return self;
1.59 + }
1.60 +
1.61 +EXPORT_C CWsRedir::~CWsRedir()
1.62 + {
1.63 + iIsReady = EFalse;
1.64 + }
1.65 +
1.66 +void CWsRedir::HandleMessage(const TDesC8& aData)
1.67 + {
1.68 + if (aData.Size()>1 && aData[0]==KRedirectorInfoSig)
1.69 + Mem::Copy(iReq, aData.Ptr(), aData.Size());
1.70 + iCallBack.CallBack();
1.71 + }
1.72 +
1.73 +void CWsRedir::OnReplace()
1.74 + {
1.75 + }
1.76 +
1.77 +EXPORT_C TInt CWsRedir::Redirect(TBufferType aWhich, TBool aHow)
1.78 + {
1.79 + if (!iIsReady)
1.80 + return KErrNotReady;
1.81 +
1.82 + TBuf8<1> cmd;
1.83 + if (aWhich==EFrontBuffer)
1.84 + {
1.85 + if (iIsFrontRedirected && aHow)
1.86 + return KErrArgument;
1.87 + iIsFrontRedirected = aHow;
1.88 + cmd.Append(iIsFrontRedirected? KCmdSetGcFront : KCmdResetGcFront);
1.89 + }
1.90 + else
1.91 + {
1.92 + if (iIsBackRedirected && aHow)
1.93 + return KErrArgument;
1.94 + iIsBackRedirected = aHow;
1.95 + cmd.Append(iIsBackRedirected? KCmdSetGcBack : KCmdResetGcBack);
1.96 + }
1.97 +
1.98 + SendMessage(cmd);
1.99 + return Flush();
1.100 + }
1.101 +
1.102 +EXPORT_C TInt CWsRedir::RedirectUsingWsBackBuffer(TBool aHow)
1.103 + {
1.104 + if (!iIsReady)
1.105 + return KErrNotReady;
1.106 +
1.107 + TBuf8<1> cmd;
1.108 + if (iIsBackRedirected && aHow)
1.109 + return KErrArgument;
1.110 + iIsBackRedirected = aHow;
1.111 + cmd.Append(iIsBackRedirected? KCmdSetBackObject : KCmdResetBackObject);
1.112 +
1.113 + SendMessage(cmd);
1.114 + return Flush();
1.115 + }
1.116 +
1.117 +EXPORT_C TInt CWsRedir::QueryPlugin(TRedirectorInfo& aInfo)
1.118 + {
1.119 + TBuf8<1> cmd;
1.120 + cmd.Append(KCmdQuery);
1.121 + SendMessage(cmd);
1.122 + TInt err = Flush();
1.123 + if (err!=KErrNone)
1.124 + return err;
1.125 + iReq = &aInfo;
1.126 + return KErrNone;
1.127 + }
1.128 +
1.129 +EXPORT_C void CWsRedir::SetCallBack(TCallBack aCallBack)
1.130 + {
1.131 + iCallBack = aCallBack;
1.132 + }