|
1 /* |
|
2 * Copyright (c) 2003-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: Implementation of class CCertManUIContainerMain |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <eikclbd.h> |
|
21 #include <AknIconArray.h> |
|
22 #include <certmanui.rsg> |
|
23 #include <csxhelp/cm.hlp.hrh> // for help context of CertManUI |
|
24 |
|
25 #include "CertmanuiCertificateHelper.h" |
|
26 #include "CertmanuiKeeper.h" |
|
27 #include "CertmanuicontainerMain.h" |
|
28 #include "CertmanuiSyncWrapper.h" |
|
29 #include "Certmanui.hrh" |
|
30 #include "CertManUILogger.h" |
|
31 #include "CertmanuiCommon.h" |
|
32 |
|
33 #include "Certmanuidll.h" // for applicationUID |
|
34 |
|
35 |
|
36 // ================= MEMBER FUNCTIONS ======================= |
|
37 |
|
38 // --------------------------------------------------------- |
|
39 // CCertManUIContainerMain::CCertManUIContainerMain( |
|
40 // CCertManUIViewPersonal& aParent, CCertManUIKeeper& aKeeper) |
|
41 // Constructor with parent |
|
42 // --------------------------------------------------------- |
|
43 // |
|
44 CCertManUIContainerMain::CCertManUIContainerMain( |
|
45 CCertManUIViewMain& aParent, CCertManUIKeeper& aKeeper ) |
|
46 : iParent( aParent ), iKeeper( aKeeper ) |
|
47 { |
|
48 CERTMANUILOGGER_WRITE_TIMESTAMP( |
|
49 "CCertManUIContainerMain::CCertManUIContainerMain" ); |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------- |
|
53 // CCertManUIContainerMain::~CCertManUIContainerMain() |
|
54 // Destructor |
|
55 // --------------------------------------------------------- |
|
56 // |
|
57 CCertManUIContainerMain::~CCertManUIContainerMain() |
|
58 { |
|
59 CERTMANUILOGGER_ENTERFN( |
|
60 " CCertManUIContainerMain::~CCertManUIContainerMain" ); |
|
61 |
|
62 delete iListBox; |
|
63 |
|
64 CERTMANUILOGGER_LEAVEFN( |
|
65 " CCertManUIContainerMain::~CCertManUIContainerMain" ); |
|
66 } |
|
67 |
|
68 // --------------------------------------------------------- |
|
69 // CCertManUIContainerMain::ConstructL( |
|
70 // const TRect& aRect, TInt aCurrentPosition, TInt aTopItem) |
|
71 // EPOC two phased constructor |
|
72 // --------------------------------------------------------- |
|
73 // |
|
74 void CCertManUIContainerMain::ConstructL( |
|
75 const TRect& aRect, TInt /*aCurrentPosition*/, TInt /*aTopItem*/ ) |
|
76 { |
|
77 CERTMANUILOGGER_ENTERFN( " CCertManUIContainerMain::ConstructL" ); |
|
78 |
|
79 CreateWindowL(); |
|
80 CreateListBoxL(); |
|
81 |
|
82 if ( iListBox ) |
|
83 { |
|
84 // Creates graphic. |
|
85 iListBox->ItemDrawer()->ColumnData()-> |
|
86 SetIconArray( iIconHandler->CreateIconArrayL() ); |
|
87 } |
|
88 |
|
89 SetRect( aRect ); |
|
90 |
|
91 CERTMANUILOGGER_LEAVEFN( " CCertManUIContainerMain::ConstructL" ); |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------- |
|
95 // CCertManUIContainerMain::SizeChanged() |
|
96 // Called by framework when the view size is changed |
|
97 // --------------------------------------------------------- |
|
98 // |
|
99 void CCertManUIContainerMain::SizeChanged() |
|
100 { |
|
101 iListBox->SetRect( Rect() ); |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------- |
|
105 // CCertManUIContainerMain::FocusChanged(TDrawNow aDrawNow) |
|
106 // --------------------------------------------------------- |
|
107 // |
|
108 void CCertManUIContainerMain::FocusChanged( TDrawNow aDrawNow ) |
|
109 { |
|
110 if ( iListBox ) |
|
111 { |
|
112 iListBox->SetFocus( IsFocused(), aDrawNow ); |
|
113 } |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------- |
|
117 // CCertManUIContainerMain::HandleListBoxEventL( |
|
118 // CEikListBox* /*aListBox*/, TListBoxEvent aEventType) |
|
119 // --------------------------------------------------------- |
|
120 // |
|
121 void CCertManUIContainerMain::HandleListBoxEventL( |
|
122 CEikListBox* /*aListBox*/, TListBoxEvent aEventType ) |
|
123 { |
|
124 CERTMANUILOGGER_ENTERFN( " CCertManUIContainerMain::HandleListBoxEventL" ); |
|
125 |
|
126 switch( aEventType ) |
|
127 { |
|
128 case EEventItemDoubleClicked: |
|
129 case EEventItemSingleClicked: |
|
130 case EEventEnterKeyPressed: |
|
131 { |
|
132 TInt index = iListBox->CurrentItemIndex(); |
|
133 |
|
134 if ( index == 0 ) |
|
135 { |
|
136 ((CAknViewAppUi*)iAvkonAppUi)->ActivateLocalViewL( KCertManUIViewAuthorityId ); |
|
137 } |
|
138 else if ( index == 1 ) |
|
139 { |
|
140 ((CAknViewAppUi*)iAvkonAppUi)->ActivateLocalViewL( KCertManUIViewTrustedSiteId ); |
|
141 } |
|
142 else if ( index == 2 ) |
|
143 { |
|
144 ((CAknViewAppUi*)iAvkonAppUi)->ActivateLocalViewL( KCertManUIViewPersonalId ); |
|
145 } |
|
146 else if ( index == 3 ) |
|
147 { |
|
148 ((CAknViewAppUi*)iAvkonAppUi)->ActivateLocalViewL( KCertManUIViewDeviceId ); |
|
149 } |
|
150 |
|
151 break; |
|
152 } |
|
153 default: |
|
154 { |
|
155 break; |
|
156 } |
|
157 } |
|
158 |
|
159 CERTMANUILOGGER_LEAVEFN( " CCertManUIContainerMain::HandleListBoxEventL" ); |
|
160 } |
|
161 |
|
162 // --------------------------------------------------------- |
|
163 // CCertManUIContainerMain::CountComponentControls() const |
|
164 // --------------------------------------------------------- |
|
165 // |
|
166 TInt CCertManUIContainerMain::CountComponentControls() const |
|
167 { |
|
168 // return number of controls inside this container |
|
169 return 1; |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------- |
|
173 // CCertManUIContainerMain::ComponentControl(TInt /*aIndex*/) const |
|
174 // --------------------------------------------------------- |
|
175 // |
|
176 CCoeControl* CCertManUIContainerMain::ComponentControl( TInt /*aIndex*/ ) const |
|
177 { |
|
178 return iListBox; |
|
179 } |
|
180 |
|
181 // --------------------------------------------------------- |
|
182 // CCertManUIContainerMain::Draw(const TRect& aRect) const |
|
183 // --------------------------------------------------------- |
|
184 // |
|
185 void CCertManUIContainerMain::Draw( const TRect& aRect ) const |
|
186 { |
|
187 CWindowGc& gc = SystemGc(); |
|
188 gc.SetPenStyle( CGraphicsContext::ENullPen ); |
|
189 gc.SetBrushColor( KRgbGray ); |
|
190 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
191 gc.DrawRect( aRect ); |
|
192 } |
|
193 |
|
194 // --------------------------------------------------------- |
|
195 // CCertManUIContainerMain::HandleControlEventL( |
|
196 // CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/) |
|
197 // Cannot be changed to non-leaving function. |
|
198 // L-function is required by the class definition, even if empty. |
|
199 // --------------------------------------------------------- |
|
200 // |
|
201 void CCertManUIContainerMain::HandleControlEventL( |
|
202 CCoeControl* /*aControl*/, TCoeEvent /*aEventType*/ ) |
|
203 { |
|
204 } |
|
205 |
|
206 // --------------------------------------------------------- |
|
207 // CCertManUIContainerMain::OfferKeyEventL( |
|
208 // const TKeyEvent& aKeyEvent, TEventCode aType) |
|
209 // Handles the key events OK button, arrow keys, delete key. |
|
210 // OK button functionality is different depending on the number of marked items |
|
211 // in the list; zero marked -> show details view, one or more marked -> show |
|
212 // OKOptions list, list empty -> OK inactive. |
|
213 // Delete active only if list not empty. |
|
214 // --------------------------------------------------------- |
|
215 // |
|
216 TKeyResponse CCertManUIContainerMain::OfferKeyEventL( |
|
217 const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
218 { |
|
219 CERTMANUILOGGER_ENTERFN( " CCertManUIContainerMain::OfferKeyEventL" ); |
|
220 TKeyResponse retval = EKeyWasNotConsumed; |
|
221 |
|
222 retval = iListBox->OfferKeyEventL( aKeyEvent, aType ); |
|
223 |
|
224 CERTMANUILOGGER_LEAVEFN( " CCertManUIContainerMain::OfferKeyEventL" ); |
|
225 |
|
226 return retval; |
|
227 } |
|
228 |
|
229 // --------------------------------------------------------- |
|
230 // CCertManUIContainerMain::CreateListBoxL() |
|
231 // Creates listbox, sets empty listbox text. |
|
232 // --------------------------------------------------------- |
|
233 // |
|
234 void CCertManUIContainerMain::CreateListBoxL() |
|
235 { |
|
236 CERTMANUILOGGER_ENTERFN( " CCertManUIContainerMain::CreateListBoxL" ); |
|
237 |
|
238 iKeeper.ActivateTitleL( KViewTitleCertManUI ); |
|
239 |
|
240 iListBox = new( ELeave ) CAknSettingStyleListBox; |
|
241 iListBox->SetContainerWindowL( *this ); |
|
242 iListBox->ConstructL( this, EAknListBoxMarkableList ); |
|
243 iListBox->CreateScrollBarFrameL( ETrue ); |
|
244 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
245 CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto ); |
|
246 iListBox->SetListBoxObserver( this ); |
|
247 |
|
248 |
|
249 MDesCArray* itemList = iListBox->Model()->ItemTextArray(); |
|
250 CDesCArray* itemArray = ( CDesCArray* )itemList; |
|
251 |
|
252 HBufC* stringHolder = StringLoader::LoadLC( |
|
253 R_TEXT_RESOURCE_MAIN_VIEW_AUTHORITY ); |
|
254 itemArray->AppendL( *stringHolder ); |
|
255 CleanupStack::PopAndDestroy(); // stringHolder |
|
256 |
|
257 stringHolder = StringLoader::LoadLC( |
|
258 R_TEXT_RESOURCE_MAIN_VIEW_TRUSTED ); |
|
259 itemArray->AppendL( *stringHolder ); |
|
260 CleanupStack::PopAndDestroy(); // stringHolder |
|
261 |
|
262 stringHolder = StringLoader::LoadLC( |
|
263 R_TEXT_RESOURCE_MAIN_VIEW_PERSONAL ); |
|
264 itemArray->AppendL( *stringHolder ); |
|
265 CleanupStack::PopAndDestroy(); // stringHolder |
|
266 |
|
267 stringHolder = StringLoader::LoadLC( |
|
268 R_TEXT_RESOURCE_MAIN_VIEW_DEVICE ); |
|
269 itemArray->AppendL( *stringHolder ); |
|
270 CleanupStack::PopAndDestroy(); // stringHolder |
|
271 |
|
272 iListBox->HandleItemAdditionL(); |
|
273 |
|
274 CERTMANUILOGGER_LEAVEFN( " CCertManUIContainerMain::CreateListBoxL" ); |
|
275 } |
|
276 |
|
277 // --------------------------------------------------------- |
|
278 // CCertManUIContainerMain::DrawListBoxL(TInt aCurrentPosition, TInt aTopItem) |
|
279 // Draws listbox, fetches graphic icons for markable list |
|
280 // --------------------------------------------------------- |
|
281 // |
|
282 void CCertManUIContainerMain::DrawListBoxL( TInt aCurrentPosition, TInt aTopItem ) |
|
283 { |
|
284 CERTMANUILOGGER_ENTERFN( " CCertManUIContainerMain::DrawListBoxL" ); |
|
285 |
|
286 if ( aCurrentPosition >= 0 ) |
|
287 { |
|
288 iListBox->SetTopItemIndex( aTopItem ); |
|
289 iListBox->SetCurrentItemIndex( aCurrentPosition ); |
|
290 } |
|
291 ActivateL(); |
|
292 DrawNow(); |
|
293 |
|
294 CERTMANUILOGGER_LEAVEFN( " CCertManUIContainerMain::DrawListBoxL" ); |
|
295 } |
|
296 |
|
297 // --------------------------------------------------------- |
|
298 // CCertManUIContainerAuthority::HandleResourceChange |
|
299 // |
|
300 // --------------------------------------------------------- |
|
301 // |
|
302 void CCertManUIContainerMain::HandleResourceChange(TInt aType) |
|
303 { |
|
304 CCoeControl::HandleResourceChange(aType); |
|
305 |
|
306 if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
307 { |
|
308 TRect mainPaneRect; |
|
309 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect ); |
|
310 SetRect( mainPaneRect ); |
|
311 DrawNow(); |
|
312 } |
|
313 } |
|
314 |
|
315 // --------------------------------------------------------- |
|
316 // CCertManUIContainerMain::IconArrayResourceId |
|
317 // Loads Mark/Unmark icons from resource |
|
318 // --------------------------------------------------------- |
|
319 // |
|
320 TInt CCertManUIContainerMain::IconArrayResourceId() const |
|
321 { |
|
322 return R_CERTMANUI_CERTIFICATE_LISTBOX_MARK_ICONS; |
|
323 } |
|
324 |
|
325 // --------------------------------------------------------- |
|
326 // CCertManUIContainerMain::CreateIconArrayL |
|
327 // Creates Icon Array |
|
328 // --------------------------------------------------------- |
|
329 // |
|
330 CAknIconArray* CCertManUIContainerMain::CreateIconArrayL() const |
|
331 { |
|
332 CAknIconArray* icons = new ( ELeave ) CAknIconArray( KGranularity ); |
|
333 CleanupStack::PushL( icons ); |
|
334 icons->ConstructFromResourceL( IconArrayResourceId() ); |
|
335 CleanupStack::Pop(); // icons |
|
336 return icons; |
|
337 } |
|
338 |
|
339 |
|
340 // --------------------------------------------------------- |
|
341 // CCertManUIContainerMain::GetHelpContext |
|
342 // This function is called when Help application is launched. |
|
343 // (other items were commented in a header). |
|
344 // --------------------------------------------------------- |
|
345 // |
|
346 |
|
347 void CCertManUIContainerMain::GetHelpContext( TCoeHelpContext& aContext ) const |
|
348 { |
|
349 aContext.iMajor = KUidCM; |
|
350 aContext.iContext = KCM_HLP_MAIN; |
|
351 } |
|
352 |
|
353 // End of File |