1 /* |
|
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "T_DataWindowInfo.h" |
|
19 |
|
20 /*@{*/ |
|
21 /// Commands |
|
22 _LIT(KCmdnew, "new"); |
|
23 _LIT(KCmdDestructor, "~"); |
|
24 _LIT(KCmdGetRedrawRegionAndRedrawShadowRegion, "GetRedrawRegionAndRedrawShadowRegion"); |
|
25 |
|
26 /// Fields |
|
27 _LIT(KFldNullExpected, "nullexpected"); |
|
28 |
|
29 /// Logging |
|
30 _LIT(KLogError, "Error=%d"); |
|
31 /*@}*/ |
|
32 |
|
33 ////////////////////////////////////////////////////////////////////// |
|
34 // Construction/Destruction |
|
35 ////////////////////////////////////////////////////////////////////// |
|
36 |
|
37 CT_DataWindowInfo* CT_DataWindowInfo::NewL() |
|
38 /** |
|
39 * Two phase constructor |
|
40 */ |
|
41 { |
|
42 CT_DataWindowInfo* ret=new (ELeave) CT_DataWindowInfo(); |
|
43 CleanupStack::PushL(ret); |
|
44 ret->ConstructL(); |
|
45 CleanupStack::Pop(ret); |
|
46 return ret; |
|
47 } |
|
48 |
|
49 CT_DataWindowInfo::CT_DataWindowInfo() |
|
50 /** |
|
51 * Protected constructor. First phase construction |
|
52 */ |
|
53 : CDataWrapperBase() |
|
54 , iWindowInfo(NULL) |
|
55 , iRedrawRegion(NULL) |
|
56 , iRedrawShadowRegion(NULL) |
|
57 { |
|
58 } |
|
59 |
|
60 void CT_DataWindowInfo::ConstructL() |
|
61 /** |
|
62 * Second phase construction |
|
63 */ |
|
64 { |
|
65 } |
|
66 |
|
67 CT_DataWindowInfo::~CT_DataWindowInfo() |
|
68 /** |
|
69 * Public destructor |
|
70 */ |
|
71 { |
|
72 DestroyData(); |
|
73 } |
|
74 |
|
75 TAny* CT_DataWindowInfo::GetObject() |
|
76 /** |
|
77 * Return a pointer to the object that the data wraps |
|
78 * |
|
79 * @return pointer to the object that the data wraps |
|
80 */ |
|
81 { |
|
82 return iWindowInfo; |
|
83 } |
|
84 |
|
85 void CT_DataWindowInfo::SetObjectL(TAny* aAny) |
|
86 /** |
|
87 * Set the object that the data wraps |
|
88 * |
|
89 * @param aObject object that the wrapper is testing |
|
90 * |
|
91 */ |
|
92 { |
|
93 DestroyData(); |
|
94 iWindowInfo = static_cast<TWindowInfo*> (aAny); |
|
95 } |
|
96 |
|
97 void CT_DataWindowInfo::DisownObjectL() |
|
98 /** |
|
99 * The object will no longer be owned by this |
|
100 * |
|
101 * @leave KErrNotSupported if the the function is not supported |
|
102 */ |
|
103 { |
|
104 iWindowInfo = NULL; |
|
105 } |
|
106 |
|
107 void CT_DataWindowInfo::DestroyData() |
|
108 { |
|
109 delete iWindowInfo; |
|
110 iWindowInfo=NULL; |
|
111 } |
|
112 |
|
113 |
|
114 /** |
|
115 * Process a command read from the ini file |
|
116 * |
|
117 * @param aCommand the command to process |
|
118 * @param aSection the entry in the ini file requiring the command to be processed |
|
119 * @param aAsyncErrorIndex index of command. used for async calls |
|
120 * |
|
121 * @return ETrue if the command is processed |
|
122 */ |
|
123 TBool CT_DataWindowInfo::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/) |
|
124 { |
|
125 TBool ret = ETrue; |
|
126 |
|
127 if ( aCommand==KCmdDestructor ) |
|
128 { |
|
129 DoCmdDestructor(); |
|
130 } |
|
131 else if ( aCommand==KCmdnew ) |
|
132 { |
|
133 DoCmdnew(); |
|
134 } |
|
135 else if ( aCommand==KCmdGetRedrawRegionAndRedrawShadowRegion ) |
|
136 { |
|
137 DoCmdGetRedrawRegionAndRedrawShadowRegion(aSection); |
|
138 } |
|
139 else |
|
140 { |
|
141 ret=EFalse; |
|
142 } |
|
143 |
|
144 return ret; |
|
145 } |
|
146 |
|
147 |
|
148 void CT_DataWindowInfo::DoCmdnew() |
|
149 { |
|
150 DestroyData(); |
|
151 |
|
152 // Execute command and log parameters |
|
153 INFO_PRINTF1(_L("execute new()")); |
|
154 TRAPD(err, iWindowInfo=new (ELeave) TWindowInfo()); |
|
155 if ( err != KErrNone ) |
|
156 { |
|
157 ERR_PRINTF2(KLogError, err); |
|
158 SetError(err); |
|
159 } |
|
160 } |
|
161 |
|
162 void CT_DataWindowInfo::DoCmdDestructor() |
|
163 { |
|
164 INFO_PRINTF1(_L("execute ~")); |
|
165 DestroyData(); |
|
166 } |
|
167 |
|
168 void CT_DataWindowInfo::DoCmdGetRedrawRegionAndRedrawShadowRegion(const TDesC& aSection) |
|
169 { |
|
170 INFO_PRINTF1(_L("GetRedrawRegionAndRedrawShadowRegion")); |
|
171 iWindowInfo->GetRedrawRegionAndRedrawShadowRegion(iRedrawRegion, iRedrawShadowRegion); |
|
172 |
|
173 TBool nullExpected; |
|
174 if ( GetBoolFromConfig(aSection, KFldNullExpected(), nullExpected) ) |
|
175 { |
|
176 if ( nullExpected ) |
|
177 { |
|
178 if ( (iRedrawRegion!=NULL) || (iRedrawShadowRegion!=NULL) ) |
|
179 { |
|
180 ERR_PRINTF3(_L("NULL pointers expected. RedrawRegion=0x%x, RedrawShadowRegion=0x%x"), iRedrawRegion, iRedrawShadowRegion); |
|
181 SetBlockResult(EFail); |
|
182 } |
|
183 } |
|
184 else |
|
185 { |
|
186 if ( (iRedrawRegion==NULL) || (iRedrawShadowRegion==NULL) ) |
|
187 { |
|
188 ERR_PRINTF3(_L("Non NULL pointers expected. RedrawRegion=0x%x, RedrawShadowRegion=0x%x"), iRedrawRegion, iRedrawShadowRegion); |
|
189 SetBlockResult(EFail); |
|
190 } |
|
191 } |
|
192 } |
|
193 } |
|