|
1 /* |
|
2 * Copyright (c) 2007-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: ESMR UI Factory implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "emailtrace.h" |
|
19 #include "cesmrfieldstorage.h" |
|
20 #include "cesmrfield.h" |
|
21 #include "mesmrcalentry.h" |
|
22 #include "cesmrfieldeventqueue.h" |
|
23 // <cmail> Removed profiling. </cmail> |
|
24 |
|
25 // ======== MEMBER FUNCTIONS ======== |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 // CESMRFieldStorage::CESMRFieldStorage() |
|
29 // --------------------------------------------------------------------------- |
|
30 // |
|
31 CESMRFieldStorage::CESMRFieldStorage( |
|
32 MESMRFieldEventObserver& aEventObserver ): |
|
33 iEventObserver( aEventObserver ) |
|
34 { |
|
35 FUNC_LOG; |
|
36 // Do nothing |
|
37 } |
|
38 |
|
39 void CESMRFieldStorage::BaseConstructL() |
|
40 { |
|
41 FUNC_LOG; |
|
42 // Add event observer to event queue |
|
43 EventQueueL().AddObserverL( &iEventObserver ); |
|
44 } |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // CESMRFieldStorage::~CESMRFieldStorage() |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 CESMRFieldStorage::~CESMRFieldStorage() |
|
51 { |
|
52 FUNC_LOG; |
|
53 iArray.ResetAndDestroy(); |
|
54 |
|
55 delete iPlugin; |
|
56 delete iEventQueue; |
|
57 } |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // CESMRFieldStorage::AddFieldL() |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 void CESMRFieldStorage::AddFieldL( CESMRField* aField ) |
|
64 { |
|
65 FUNC_LOG; |
|
66 if ( aField ) |
|
67 { |
|
68 AddFieldL( aField, ETrue ); |
|
69 } |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // CESMRFieldStorage::AddFieldL() |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 void CESMRFieldStorage::AddFieldL( CESMRField* aField, TBool aVisible ) |
|
77 { |
|
78 FUNC_LOG; |
|
79 if ( aField ) |
|
80 { |
|
81 iArray.ReserveL( iArray.Count() + 1 ); |
|
82 aField->SetEventQueueL( iEventQueue ); |
|
83 aField->MakeVisible( aVisible ); |
|
84 iArray.AppendL( aField ); |
|
85 } |
|
86 } |
|
87 |
|
88 // --------------------------------------------------------------------------- |
|
89 // CESMRFieldStorage::Count() |
|
90 // --------------------------------------------------------------------------- |
|
91 // |
|
92 TInt CESMRFieldStorage::Count() const |
|
93 { |
|
94 FUNC_LOG; |
|
95 return iArray.Count(); |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // CESMRFieldStorage::Field() |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 CESMRField* CESMRFieldStorage::Field( TInt aInd ) const |
|
103 { |
|
104 FUNC_LOG; |
|
105 return iArray[ aInd ]; |
|
106 } |
|
107 |
|
108 // --------------------------------------------------------------------------- |
|
109 // CESMRFieldStorage::FieldById |
|
110 // --------------------------------------------------------------------------- |
|
111 // |
|
112 CESMRField* CESMRFieldStorage::FieldById( TESMREntryFieldId aId ) const |
|
113 { |
|
114 CESMRField* field = NULL; |
|
115 |
|
116 for ( TInt i = 0; i < iArray.Count(); ++i ) |
|
117 { |
|
118 if ( iArray[ i ]->FieldId() == aId ) |
|
119 { |
|
120 field = iArray[ i ]; |
|
121 break; |
|
122 } |
|
123 } |
|
124 |
|
125 return field; |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------------------------- |
|
129 // CESMRFieldStorage::Validate() |
|
130 // --------------------------------------------------------------------------- |
|
131 // |
|
132 TInt CESMRFieldStorage::Validate( |
|
133 TESMREntryFieldId& /*aId */, |
|
134 TBool /*aForceValidation*/ ) |
|
135 { |
|
136 FUNC_LOG; |
|
137 return KErrNone; |
|
138 } |
|
139 |
|
140 // --------------------------------------------------------------------------- |
|
141 // CESMRFieldStorage::InternalizeL() |
|
142 // --------------------------------------------------------------------------- |
|
143 // |
|
144 void CESMRFieldStorage::InternalizeL( MESMRCalEntry& aEntry ) |
|
145 { |
|
146 FUNC_LOG; |
|
147 for ( TInt i(0); i < iArray.Count(); i++ ) |
|
148 { |
|
149 iArray[ i ]->InternalizeL( aEntry ); |
|
150 } |
|
151 } |
|
152 |
|
153 // --------------------------------------------------------------------------- |
|
154 // CESMRFieldStorage::ExternalizeL() |
|
155 // --------------------------------------------------------------------------- |
|
156 // |
|
157 void CESMRFieldStorage::ExternalizeL( MESMRCalEntry& aEntry ) |
|
158 { |
|
159 FUNC_LOG; |
|
160 for ( TInt i(0); i < iArray.Count(); i++ ) |
|
161 { |
|
162 iArray[ i ]->ExternalizeL( aEntry ); |
|
163 } |
|
164 } |
|
165 |
|
166 |
|
167 // ----------------------------------------------------------------------------- |
|
168 // CESMRFieldStorage::FieldBuilderL() |
|
169 // ----------------------------------------------------------------------------- |
|
170 // |
|
171 MESMRFieldBuilder* CESMRFieldStorage::FieldBuilderL() |
|
172 { |
|
173 FUNC_LOG; |
|
174 if(!iFieldBuilder) |
|
175 { |
|
176 LoadPluginL(); |
|
177 } |
|
178 return iFieldBuilder; |
|
179 } |
|
180 |
|
181 // ----------------------------------------------------------------------------- |
|
182 // CESMRFieldStorage::LoadPluginL() |
|
183 // ----------------------------------------------------------------------------- |
|
184 // |
|
185 void CESMRFieldStorage::LoadPluginL() |
|
186 { |
|
187 FUNC_LOG; |
|
188 iFieldBuilder = NULL; |
|
189 CESMRFieldBuilderInterface* plugin = NULL; |
|
190 |
|
191 TRAPD( error, plugin = |
|
192 CESMRFieldBuilderInterface::CreatePluginL( |
|
193 TUid::Uid(KESMRUIFieldBuilderPluginImplUId) ) ); |
|
194 |
|
195 if ( error == KErrNone && plugin) |
|
196 { |
|
197 delete iPlugin; |
|
198 iPlugin = plugin; |
|
199 |
|
200 iFieldBuilder = iPlugin->FieldBuilderL(); |
|
201 } |
|
202 } |
|
203 |
|
204 // ----------------------------------------------------------------------------- |
|
205 // CESMRFieldStorage::CreateEditorFieldL() |
|
206 // ----------------------------------------------------------------------------- |
|
207 // |
|
208 CESMRField* CESMRFieldStorage::CreateEditorFieldL( |
|
209 MESMRFieldValidator* aValidator, |
|
210 TESMREntryField aField ) |
|
211 { |
|
212 FUNC_LOG; |
|
213 CESMRField* field = NULL; |
|
214 |
|
215 if (FieldBuilderL()) |
|
216 { |
|
217 field = FieldBuilderL()->CreateEditorFieldL(aValidator, aField); |
|
218 } |
|
219 |
|
220 return field; |
|
221 } |
|
222 |
|
223 // ----------------------------------------------------------------------------- |
|
224 // CESMRFieldStorage::CreateViewerFieldL() |
|
225 // ----------------------------------------------------------------------------- |
|
226 // |
|
227 CESMRField* CESMRFieldStorage::CreateViewerFieldL( |
|
228 MESMRResponseObserver* aResponseObserver, |
|
229 TESMREntryField aField, |
|
230 TBool aResponseReady ) |
|
231 { |
|
232 FUNC_LOG; |
|
233 CESMRField* field = NULL; |
|
234 |
|
235 if (FieldBuilderL()) |
|
236 { |
|
237 field = FieldBuilderL()->CreateViewerFieldL( |
|
238 aResponseObserver, aField, aResponseReady ); |
|
239 } |
|
240 return field; |
|
241 } |
|
242 |
|
243 // ----------------------------------------------------------------------------- |
|
244 // CESMRFieldStorage::EventQueueL() |
|
245 // ----------------------------------------------------------------------------- |
|
246 // |
|
247 CESMRFieldEventQueue& CESMRFieldStorage::EventQueueL() |
|
248 { |
|
249 FUNC_LOG; |
|
250 if ( !iEventQueue ) |
|
251 { |
|
252 iEventQueue = CESMRFieldEventQueue::NewL(); |
|
253 } |
|
254 return *iEventQueue; |
|
255 } |
|
256 |
|
257 // EOF |
|
258 |