|
1 /* |
|
2 * Copyright (c) 2007-2008 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 CWsfDetailsContainer. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <aknnavi.h> |
|
20 #include <aknnavide.h> |
|
21 #include <wlansniffer.rsg> |
|
22 #include <aknnavilabel.h> |
|
23 #include "wsfdetailscontainer.h" |
|
24 #include "wsfdetailsviewcontrollerpartner.h" |
|
25 #include "wsfappui.h" |
|
26 #include "wsfdetailsviewmodel.h" |
|
27 #include "wsfactivetimeupdater.h" |
|
28 |
|
29 #include "wsflogger.h" |
|
30 |
|
31 // CONSTANTS |
|
32 LOCAL_D const TInt KUpdateInterval = 10000000; // in micro seconds (10 sec) |
|
33 |
|
34 |
|
35 // ======== MEMBER FUNCTIONS ======== |
|
36 // --------------------------------------------------------- |
|
37 // CCSnifferDetailsContainer::NewL() |
|
38 // --------------------------------------------------------- |
|
39 // |
|
40 CWsfDetailsContainer* CWsfDetailsContainer::NewL( |
|
41 const TRect& aRect, |
|
42 MWsfActiveTimerHandler& aController ) |
|
43 { |
|
44 LOG_ENTERFN( "CWsfDetailsContainer::NewL" ); |
|
45 CWsfDetailsContainer* self = CWsfDetailsContainer::NewLC( aRect, |
|
46 aController ); |
|
47 CleanupStack::Pop( self ); |
|
48 return self; |
|
49 } |
|
50 |
|
51 // --------------------------------------------------------- |
|
52 // CCSnifferDetailsContainer::NewLC() |
|
53 // --------------------------------------------------------- |
|
54 // |
|
55 CWsfDetailsContainer* CWsfDetailsContainer::NewLC( |
|
56 const TRect& aRect, |
|
57 MWsfActiveTimerHandler& aController ) |
|
58 { |
|
59 LOG_ENTERFN( "CWsfDetailsContainer::NewLC" ); |
|
60 CWsfDetailsContainer* self = new( ELeave ) CWsfDetailsContainer; |
|
61 CleanupStack::PushL( self ); |
|
62 self->ConstructL( aRect, aController ); |
|
63 return self; |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------- |
|
67 // CWsfDetailsContainer::~CCSnifferDetailsContainer |
|
68 // --------------------------------------------------------- |
|
69 // |
|
70 CWsfDetailsContainer::~CWsfDetailsContainer() |
|
71 { |
|
72 LOG_ENTERFN( "CWsfDetailsContainer::~CWsfDetailsContainer" ); |
|
73 PopNaviPane(); |
|
74 delete iListBox; |
|
75 delete iNaviDecorator; |
|
76 |
|
77 if( iActiveUpdater ) |
|
78 { |
|
79 iActiveUpdater->Stop(); |
|
80 } |
|
81 delete iActiveUpdater; |
|
82 } |
|
83 |
|
84 // --------------------------------------------------------- |
|
85 // CCSnifferDetailsContainer::ConstructL() |
|
86 // --------------------------------------------------------- |
|
87 // |
|
88 void CWsfDetailsContainer::ConstructL( const TRect& aRect, |
|
89 MWsfActiveTimerHandler& aController ) |
|
90 { |
|
91 LOG_ENTERFN( "CWsfDetailsContainer::ConstructL" ); |
|
92 CreateWindowL(); |
|
93 |
|
94 iListBox = new( ELeave ) CAknSingleHeadingStyleListBox; |
|
95 iListBox->SetContainerWindowL( *this ); |
|
96 TInt flags = 0; |
|
97 flags |= EAknListBoxViewerFlags; |
|
98 iListBox->ConstructL( this, flags ); |
|
99 iListBox->CreateScrollBarFrameL( ETrue ); |
|
100 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
101 CEikScrollBarFrame::EOff, |
|
102 CEikScrollBarFrame::EAuto ); |
|
103 |
|
104 iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray ); |
|
105 |
|
106 SetRect( aRect ); |
|
107 |
|
108 // Create and start Active Object 'Active Updater' |
|
109 iActiveUpdater = CWsfActiveTimeUpdater::NewL( &aController ); |
|
110 iActiveUpdater->Start( KUpdateInterval ); |
|
111 |
|
112 ActivateL(); |
|
113 } |
|
114 |
|
115 |
|
116 // --------------------------------------------------------- |
|
117 // CWsfDetailsContainer::CConnectionMonitorUiContainer |
|
118 // --------------------------------------------------------- |
|
119 // |
|
120 CWsfDetailsContainer::CWsfDetailsContainer() : iDetailsModel( NULL ) |
|
121 { |
|
122 } |
|
123 |
|
124 // --------------------------------------------------------- |
|
125 // CWsfDetailsContainer::CConnectionMonitorUiContainer |
|
126 // --------------------------------------------------------- |
|
127 // |
|
128 void CWsfDetailsContainer::SetDetailsModel( CWsfDetailsViewModel* aModel ) |
|
129 { |
|
130 iDetailsModel = aModel; |
|
131 } |
|
132 |
|
133 // --------------------------------------------------------- |
|
134 // CWsfDetailsContainer::SizeChanged() |
|
135 // --------------------------------------------------------- |
|
136 // |
|
137 void CWsfDetailsContainer::SizeChanged() |
|
138 { |
|
139 iListBox->SetRect( Rect() ); |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------- |
|
143 // CWsfDetailsContainer::CountComponentControls() |
|
144 // --------------------------------------------------------- |
|
145 // |
|
146 TInt CWsfDetailsContainer::CountComponentControls() const |
|
147 { |
|
148 return 1; // return nbr of controls inside this container |
|
149 } |
|
150 |
|
151 // --------------------------------------------------------- |
|
152 // CWsfDetailsContainer::ComponentControl() |
|
153 // --------------------------------------------------------- |
|
154 // |
|
155 CCoeControl* CWsfDetailsContainer::ComponentControl( TInt aIndex ) const |
|
156 { |
|
157 LOG_ENTERFN( "CWsfDetailsContainer::ComponentControl" ); |
|
158 switch ( aIndex ) |
|
159 { |
|
160 case 0: |
|
161 return iListBox; |
|
162 default: |
|
163 return NULL; |
|
164 } |
|
165 } |
|
166 |
|
167 // --------------------------------------------------------- |
|
168 // CWsfDetailsContainer::OfferKeyEventL |
|
169 // --------------------------------------------------------- |
|
170 // |
|
171 TKeyResponse CWsfDetailsContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
172 TEventCode aType ) |
|
173 { |
|
174 LOG_ENTERFN( "CWsfDetailsContainer::OfferKeyEventL" ); |
|
175 TKeyResponse result = EKeyWasNotConsumed; |
|
176 |
|
177 if ( aType == EEventKey || aType == EEventKeyDown ) |
|
178 { |
|
179 result = iListBox->OfferKeyEventL( aKeyEvent, aType ); |
|
180 |
|
181 if ( aKeyEvent.iCode == EKeyLeftArrow ) |
|
182 { |
|
183 if ( iPartner ) |
|
184 { |
|
185 iPartner->HandleLeftKeyPressedL(); |
|
186 result = EKeyWasConsumed; |
|
187 } |
|
188 } |
|
189 else if ( aKeyEvent.iCode == EKeyRightArrow ) |
|
190 { |
|
191 if ( iPartner ) |
|
192 { |
|
193 iPartner->HandleRightKeyPressedL(); |
|
194 result = EKeyWasConsumed; |
|
195 } |
|
196 } |
|
197 else if ( aKeyEvent.iCode == EKeyOK ) |
|
198 { |
|
199 if ( iPartner ) |
|
200 { |
|
201 iPartner->HandleSelectionKeyPressedL(); |
|
202 } |
|
203 } |
|
204 } |
|
205 |
|
206 return result; |
|
207 } |
|
208 |
|
209 // --------------------------------------------------------- |
|
210 // CWsfDetailsContainer::GetPanesL |
|
211 // --------------------------------------------------------- |
|
212 // |
|
213 void CWsfDetailsContainer::GetPanesL() |
|
214 { |
|
215 LOG_ENTERFN( "CWsfDetailsContainer::GetPanesL" ); |
|
216 if( !iNaviPane ) |
|
217 { |
|
218 CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane(); |
|
219 |
|
220 iNaviPane = static_cast<CAknNavigationControlContainer*>( |
|
221 statusPane->ControlL( |
|
222 TUid::Uid(EEikStatusPaneUidNavi ) ) ); |
|
223 } |
|
224 } |
|
225 |
|
226 // --------------------------------------------------------- |
|
227 // CWsfDetailsContainer::UpdateNaviPaneL |
|
228 // --------------------------------------------------------- |
|
229 // |
|
230 void CWsfDetailsContainer::UpdateNaviPaneL( const TDesC& aPaneText ) |
|
231 { |
|
232 LOG_ENTERFN( "CWsfDetailsContainer::UpdateNaviPaneL" ); |
|
233 LOG_WRITEF("UpdateNaviPaneL - aPaneTest: %S", &aPaneText ); |
|
234 if ( !( ( CWsfAppUi *)( iEikonEnv->AppUi() ) )->Foreground() ) |
|
235 { |
|
236 return; |
|
237 } |
|
238 |
|
239 GetPanesL(); |
|
240 |
|
241 if ( !iNaviDecorator ) |
|
242 { |
|
243 delete iNaviDecorator; |
|
244 iNaviDecorator = NULL; |
|
245 if( iNaviPane ) |
|
246 { |
|
247 iNaviDecorator = iNaviPane->CreateNavigationLabelL( aPaneText ); |
|
248 iNaviPane->PushL( *iNaviDecorator ); |
|
249 } |
|
250 } |
|
251 else |
|
252 { |
|
253 CAknNaviLabel* naviLabel = static_cast<CAknNaviLabel*>( |
|
254 iNaviDecorator->DecoratedControl() ); |
|
255 naviLabel->SetTextL( aPaneText ); |
|
256 // make sure at top and redraw |
|
257 iNaviPane->PushL( *iNaviDecorator ); |
|
258 } |
|
259 |
|
260 if ( iNaviDecorator ) |
|
261 { |
|
262 // Set the Observer of the NaviDecorator |
|
263 iNaviDecorator->SetNaviDecoratorObserver( this ); |
|
264 // Show or hide the left and right arrow button |
|
265 iNaviDecorator->SetScrollButtonDimmed( |
|
266 CAknNavigationDecorator::ELeftButton, |
|
267 iDetailsModel->FormatLeftScrollButton() ); |
|
268 iNaviDecorator->SetScrollButtonDimmed( |
|
269 CAknNavigationDecorator::ERightButton, |
|
270 iDetailsModel->FormatRightScrollButton() ); |
|
271 // Set the visibility of the buttons |
|
272 iNaviDecorator->MakeScrollButtonVisible( ETrue ); |
|
273 } |
|
274 } |
|
275 |
|
276 // --------------------------------------------------------- |
|
277 // CWsfDetailsContainer::UpdateListBoxL |
|
278 // --------------------------------------------------------- |
|
279 // |
|
280 void CWsfDetailsContainer::UpdateListBoxL( MDesCArray* aItemTextArray ) |
|
281 { |
|
282 LOG_ENTERFN( "CWsfDetailsContainer::UpdateListBoxL" ); |
|
283 for( TInt i = 0; i < aItemTextArray->MdcaCount(); i++) |
|
284 { |
|
285 TPtrC temp = aItemTextArray->MdcaPoint( i ); |
|
286 TBuf<100> tempElement = temp; |
|
287 LOG_WRITEF( "aItemTextArray: %S", &tempElement ); |
|
288 } |
|
289 |
|
290 iListBox->Reset(); |
|
291 iListBox->Model()->SetItemTextArray( aItemTextArray ); |
|
292 iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
293 iListBox->HandleItemAdditionL(); |
|
294 } |
|
295 |
|
296 // --------------------------------------------------------- |
|
297 // CWsfDetailsContainer::SetPartner |
|
298 // --------------------------------------------------------- |
|
299 // |
|
300 void CWsfDetailsContainer::SetPartner( |
|
301 MWsfDetailsViewControllerPartner& aPartner ) |
|
302 { |
|
303 iPartner = &aPartner; |
|
304 } |
|
305 |
|
306 // --------------------------------------------------------- |
|
307 // CWsfDetailsContainer::PopNaviPane |
|
308 // --------------------------------------------------------- |
|
309 // |
|
310 void CWsfDetailsContainer::PopNaviPane() |
|
311 { |
|
312 LOG_ENTERFN( "CWsfDetailsContainer::PopNaviPane" ); |
|
313 if ( iNaviPane && iNaviDecorator ) |
|
314 { |
|
315 iNaviPane->Pop( iNaviDecorator ); |
|
316 delete iNaviDecorator; |
|
317 iNaviDecorator = NULL; |
|
318 } |
|
319 } |
|
320 |
|
321 |
|
322 // --------------------------------------------------------- |
|
323 // CCSnifferDetailsContainer::HandleResourceChange |
|
324 // --------------------------------------------------------- |
|
325 // |
|
326 void CWsfDetailsContainer::HandleResourceChange( TInt aType ) |
|
327 { |
|
328 LOG_ENTERFN( "CWsfDetailsContainer::HandleResourceChange" ); |
|
329 CCoeControl::HandleResourceChange( aType ); |
|
330 if( aType == KEikDynamicLayoutVariantSwitch ) |
|
331 { |
|
332 TRect mainPaneRect; |
|
333 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, |
|
334 mainPaneRect ); |
|
335 SetRect( mainPaneRect ); |
|
336 DrawNow(); |
|
337 } |
|
338 } |
|
339 |
|
340 // --------------------------------------------------------- |
|
341 // CWsfDetailsContainer::FocusChanged |
|
342 // --------------------------------------------------------- |
|
343 // |
|
344 void CWsfDetailsContainer::FocusChanged( TDrawNow aDrawNow ) |
|
345 { |
|
346 LOG_ENTERFN( "CWsfDetailsContainer::FocusChanged" ); |
|
347 CCoeControl::FocusChanged( aDrawNow ); |
|
348 if( iListBox ) |
|
349 { |
|
350 iListBox->SetFocus( IsFocused() ); |
|
351 } |
|
352 } |
|
353 |
|
354 // -------------------------------------------------------------------------- |
|
355 // CWsfDetailsContainer::HandleNaviDecoratorEventL |
|
356 // -------------------------------------------------------------------------- |
|
357 // |
|
358 void CWsfDetailsContainer::HandleNaviDecoratorEventL( TInt aEventID ) |
|
359 { |
|
360 LOG_ENTERFN( "CWsfDetailsContainer::HandleNaviDecoratorEventL" ); |
|
361 if ( AknLayoutUtils::PenEnabled() ) |
|
362 { |
|
363 switch ( aEventID ) |
|
364 { |
|
365 case EAknNaviDecoratorEventRightTabArrow: |
|
366 { |
|
367 if( iPartner && !iDetailsModel->FormatRightScrollButton() ) |
|
368 { |
|
369 iPartner->HandleRightKeyPressedL(); |
|
370 } |
|
371 break; |
|
372 } |
|
373 case EAknNaviDecoratorEventLeftTabArrow: |
|
374 { |
|
375 if( iPartner && !iDetailsModel->FormatLeftScrollButton() ) |
|
376 { |
|
377 iPartner->HandleLeftKeyPressedL(); |
|
378 } |
|
379 break; |
|
380 } |
|
381 default: |
|
382 return; |
|
383 } |
|
384 } |
|
385 } |
|
386 |
|
387 // End of File |
|
388 |