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