author | sl@SLION-WIN7.fritz.box |
Fri, 15 Jun 2012 03:10:57 +0200 | |
changeset 0 | bde4ae8d615e |
permissions | -rw-r--r-- |
sl@0 | 1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
sl@0 | 2 |
// All rights reserved. |
sl@0 | 3 |
// This component and the accompanying materials are made available |
sl@0 | 4 |
// under the terms of "Eclipse Public License v1.0" |
sl@0 | 5 |
// which accompanies this distribution, and is available |
sl@0 | 6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
sl@0 | 7 |
// |
sl@0 | 8 |
// Initial Contributors: |
sl@0 | 9 |
// Nokia Corporation - initial contribution. |
sl@0 | 10 |
// |
sl@0 | 11 |
// Contributors: |
sl@0 | 12 |
// |
sl@0 | 13 |
// Description: |
sl@0 | 14 |
// |
sl@0 | 15 |
|
sl@0 | 16 |
/** |
sl@0 | 17 |
@file |
sl@0 | 18 |
@test |
sl@0 | 19 |
@internalComponent - Internal Symbian test code |
sl@0 | 20 |
*/ |
sl@0 | 21 |
|
sl@0 | 22 |
#include "wsredir.h" |
sl@0 | 23 |
|
sl@0 | 24 |
const TUint8 KCmdQuery = 0; |
sl@0 | 25 |
const TUint8 KCmdSetGcFront = 1; |
sl@0 | 26 |
const TUint8 KCmdSetGcBack = 2; |
sl@0 | 27 |
const TUint8 KCmdResetGcFront = 3; |
sl@0 | 28 |
const TUint8 KCmdResetGcBack = 4; |
sl@0 | 29 |
const TUint8 KCmdSetBackObject = 5; |
sl@0 | 30 |
const TUint8 KCmdResetBackObject= 6; |
sl@0 | 31 |
|
sl@0 | 32 |
const TUid KRedirectorInterfaceId = {0x10281e1d}; |
sl@0 | 33 |
const TUid KRedirectorImplId = {0x10281e1e}; |
sl@0 | 34 |
|
sl@0 | 35 |
EXPORT_C CWsRedir* CWsRedir::NewL() |
sl@0 | 36 |
{ |
sl@0 | 37 |
return NewL(0); |
sl@0 | 38 |
} |
sl@0 | 39 |
|
sl@0 | 40 |
EXPORT_C CWsRedir* CWsRedir::NewL(TInt aScreenId) |
sl@0 | 41 |
{ |
sl@0 | 42 |
return NewL(aScreenId, EFalse); |
sl@0 | 43 |
} |
sl@0 | 44 |
|
sl@0 | 45 |
EXPORT_C CWsRedir* CWsRedir::NewL(TInt aScreenId, TBool aDisableWin) |
sl@0 | 46 |
{ |
sl@0 | 47 |
CWsRedir* self = new(ELeave) CWsRedir; |
sl@0 | 48 |
CleanupStack::PushL(self); |
sl@0 | 49 |
TBuf8<2> data; |
sl@0 | 50 |
data.Append((TUint8)aScreenId); |
sl@0 | 51 |
data.Append((TUint8)aDisableWin); |
sl@0 | 52 |
self->BaseConstructL(KRedirectorInterfaceId, KRedirectorImplId, data); |
sl@0 | 53 |
CleanupStack::Pop(self); |
sl@0 | 54 |
self->iIsReady = ETrue; |
sl@0 | 55 |
return self; |
sl@0 | 56 |
} |
sl@0 | 57 |
|
sl@0 | 58 |
EXPORT_C CWsRedir::~CWsRedir() |
sl@0 | 59 |
{ |
sl@0 | 60 |
iIsReady = EFalse; |
sl@0 | 61 |
} |
sl@0 | 62 |
|
sl@0 | 63 |
void CWsRedir::HandleMessage(const TDesC8& aData) |
sl@0 | 64 |
{ |
sl@0 | 65 |
if (aData.Size()>1 && aData[0]==KRedirectorInfoSig) |
sl@0 | 66 |
Mem::Copy(iReq, aData.Ptr(), aData.Size()); |
sl@0 | 67 |
iCallBack.CallBack(); |
sl@0 | 68 |
} |
sl@0 | 69 |
|
sl@0 | 70 |
void CWsRedir::OnReplace() |
sl@0 | 71 |
{ |
sl@0 | 72 |
} |
sl@0 | 73 |
|
sl@0 | 74 |
EXPORT_C TInt CWsRedir::Redirect(TBufferType aWhich, TBool aHow) |
sl@0 | 75 |
{ |
sl@0 | 76 |
if (!iIsReady) |
sl@0 | 77 |
return KErrNotReady; |
sl@0 | 78 |
|
sl@0 | 79 |
TBuf8<1> cmd; |
sl@0 | 80 |
if (aWhich==EFrontBuffer) |
sl@0 | 81 |
{ |
sl@0 | 82 |
if (iIsFrontRedirected && aHow) |
sl@0 | 83 |
return KErrArgument; |
sl@0 | 84 |
iIsFrontRedirected = aHow; |
sl@0 | 85 |
cmd.Append(iIsFrontRedirected? KCmdSetGcFront : KCmdResetGcFront); |
sl@0 | 86 |
} |
sl@0 | 87 |
else |
sl@0 | 88 |
{ |
sl@0 | 89 |
if (iIsBackRedirected && aHow) |
sl@0 | 90 |
return KErrArgument; |
sl@0 | 91 |
iIsBackRedirected = aHow; |
sl@0 | 92 |
cmd.Append(iIsBackRedirected? KCmdSetGcBack : KCmdResetGcBack); |
sl@0 | 93 |
} |
sl@0 | 94 |
|
sl@0 | 95 |
SendMessage(cmd); |
sl@0 | 96 |
return Flush(); |
sl@0 | 97 |
} |
sl@0 | 98 |
|
sl@0 | 99 |
EXPORT_C TInt CWsRedir::RedirectUsingWsBackBuffer(TBool aHow) |
sl@0 | 100 |
{ |
sl@0 | 101 |
if (!iIsReady) |
sl@0 | 102 |
return KErrNotReady; |
sl@0 | 103 |
|
sl@0 | 104 |
TBuf8<1> cmd; |
sl@0 | 105 |
if (iIsBackRedirected && aHow) |
sl@0 | 106 |
return KErrArgument; |
sl@0 | 107 |
iIsBackRedirected = aHow; |
sl@0 | 108 |
cmd.Append(iIsBackRedirected? KCmdSetBackObject : KCmdResetBackObject); |
sl@0 | 109 |
|
sl@0 | 110 |
SendMessage(cmd); |
sl@0 | 111 |
return Flush(); |
sl@0 | 112 |
} |
sl@0 | 113 |
|
sl@0 | 114 |
EXPORT_C TInt CWsRedir::QueryPlugin(TRedirectorInfo& aInfo) |
sl@0 | 115 |
{ |
sl@0 | 116 |
TBuf8<1> cmd; |
sl@0 | 117 |
cmd.Append(KCmdQuery); |
sl@0 | 118 |
SendMessage(cmd); |
sl@0 | 119 |
TInt err = Flush(); |
sl@0 | 120 |
if (err!=KErrNone) |
sl@0 | 121 |
return err; |
sl@0 | 122 |
iReq = &aInfo; |
sl@0 | 123 |
return KErrNone; |
sl@0 | 124 |
} |
sl@0 | 125 |
|
sl@0 | 126 |
EXPORT_C void CWsRedir::SetCallBack(TCallBack aCallBack) |
sl@0 | 127 |
{ |
sl@0 | 128 |
iCallBack = aCallBack; |
sl@0 | 129 |
} |