|
1 /* |
|
2 * Copyright (c) 2005-2007 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: Navipane renderer. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <aipropertyextension.h> |
|
20 #include <centralrepository.h> |
|
21 #include <ProfileEngineSDKCRKeys.h> |
|
22 |
|
23 #include "ainavipanerenderer.h" |
|
24 #include "ainavipaneanimator.h" |
|
25 #include "aistatuspanel.h" |
|
26 #include "ainativeuimodel.h" |
|
27 #include "ainativeuiplugins.h" |
|
28 #include "contentprioritymap.h" |
|
29 #include <aicontentrequest.h> |
|
30 #include "debug.h" |
|
31 |
|
32 using namespace AiNativeUiController; |
|
33 |
|
34 |
|
35 void CAiNaviPaneRenderer::ConstructL() |
|
36 { |
|
37 iAnimator = CAiNaviPaneAnimator::NewL( iStatusPanel, |
|
38 iRenderingPriorities, |
|
39 *this ); |
|
40 iProfileText = HBufC::NewL(0); |
|
41 iSilentIndicator = HBufC::NewL(0); |
|
42 } |
|
43 |
|
44 |
|
45 CAiNaviPaneRenderer* CAiNaviPaneRenderer::NewLC( |
|
46 CAiStatusPanel& aStatusPanel ) |
|
47 { |
|
48 CAiNaviPaneRenderer* self = new( ELeave ) CAiNaviPaneRenderer( aStatusPanel ); |
|
49 CleanupStack::PushL( self ); |
|
50 self->ConstructL(); |
|
51 return self; |
|
52 } |
|
53 |
|
54 |
|
55 CAiNaviPaneRenderer::~CAiNaviPaneRenderer() |
|
56 { |
|
57 delete iAnimator; |
|
58 delete iProfileText; |
|
59 delete iSilentIndicator; |
|
60 delete iTimedProfileIndicator; |
|
61 } |
|
62 |
|
63 |
|
64 CAiNaviPaneRenderer::CAiNaviPaneRenderer( CAiStatusPanel& aStatusPanel ) |
|
65 : iStatusPanel( aStatusPanel ), |
|
66 iRenderingPriorities( AiNativeUiModel::RenderingPriorities( AiNativeUiModel::KNaviPaneId ) ), |
|
67 iCurrentContent(KAiNullContentId), |
|
68 iCurrentPriority(AiNativeUiModel::KNoPriority) |
|
69 { |
|
70 } |
|
71 |
|
72 |
|
73 void CAiNaviPaneRenderer::DoPublishL( MAiPropertyExtension& aPlugin, |
|
74 TInt aContent, |
|
75 const TDesC16& aText, |
|
76 TInt /*aIndex*/ ) |
|
77 { |
|
78 if( aPlugin.PublisherInfoL()->iUid == KDeviceStatusPluginUid ) |
|
79 { |
|
80 switch( aContent ) |
|
81 { |
|
82 // FALLTHROUGH |
|
83 case EAiDeviceStatusContentDate: |
|
84 case EAiDeviceStatusContentProfileName: |
|
85 case EAiDeviceStatusContentGeneralProfileName: |
|
86 { |
|
87 __PRINT(__DBG_FORMAT("XAI: Render navi pane - %d, %S"), aContent, &aText ); |
|
88 |
|
89 const TInt priority = iRenderingPriorities.RenderingPriority( aContent ); |
|
90 |
|
91 // Get active profile ID |
|
92 CRepository* profileApi; |
|
93 TInt profileId; |
|
94 profileApi = CRepository::NewL( KCRUidProfileEngine ); |
|
95 TInt err = profileApi->Get( KProEngActiveProfile, profileId ); |
|
96 delete profileApi; |
|
97 |
|
98 if ( aContent == EAiDeviceStatusContentGeneralProfileName ) |
|
99 { |
|
100 const TInt KGeneralProfileId( 0 ); |
|
101 if (profileId == KGeneralProfileId) |
|
102 { |
|
103 iAnimator->AddItemL( EAiDeviceStatusContentGeneralIndicator, aText ); |
|
104 } |
|
105 // iAnimator->AddItemL( EAiDeviceStatusContentGeneralIndicator, aText ); |
|
106 // iAnimator->AddItemL( EAiDeviceStatusContentGeneralProfileName, aText ); |
|
107 |
|
108 iAnimator->AnimateL(); |
|
109 } |
|
110 |
|
111 |
|
112 if( (priority >= iCurrentPriority) || !iIsSilent || !iIsTimed ) |
|
113 { |
|
114 if( priority >= iCurrentPriority ) |
|
115 { |
|
116 delete iProfileText; |
|
117 iProfileText = NULL; |
|
118 iProfileText = aText.AllocL(); |
|
119 iIsOldTextChanged = ETrue; |
|
120 |
|
121 iCurrentPriority = priority; |
|
122 iCurrentContent = aContent; |
|
123 } |
|
124 |
|
125 HBufC* newText = ConstructProfileTextLC(); |
|
126 |
|
127 if( !iAnimator->IsActive() ) |
|
128 { |
|
129 iStatusPanel.SetNaviPaneTextL( *newText ); |
|
130 iStatusPanel.RenderNaviPaneL(); |
|
131 } |
|
132 |
|
133 CleanupStack::PopAndDestroy( newText ); |
|
134 } |
|
135 |
|
136 __PRINTS( "XAI: Render navi pane - priority check failed"); |
|
137 break; |
|
138 } |
|
139 |
|
140 case EAiDeviceStatusContentSilentIndicator: |
|
141 { |
|
142 __PRINT(__DBG_FORMAT("XAI: Render navi pane - %d, %S"), aContent, &aText ); |
|
143 |
|
144 const TInt priority = iRenderingPriorities.RenderingPriority( aContent ); |
|
145 |
|
146 if( priority >= iCurrentPriority && iIsOldTextChanged ) |
|
147 { |
|
148 delete iSilentIndicator; |
|
149 iSilentIndicator = NULL; |
|
150 iSilentIndicator = aText.AllocL(); |
|
151 iIsSilent = ETrue; |
|
152 if( !iAnimator->IsActive() ) |
|
153 { |
|
154 HBufC* newText = ConstructProfileTextLC(); |
|
155 iStatusPanel.SetNaviPaneTextL( *newText ); |
|
156 iStatusPanel.RenderNaviPaneL(); |
|
157 CleanupStack::PopAndDestroy( newText ); |
|
158 } |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 // iCurrentContent is not assigned because silent indicator is |
|
164 // rendered within the navi pane text |
|
165 |
|
166 __PRINTS( "XAI: Render navi pane - done"); |
|
167 } |
|
168 __PRINTS( "XAI: Render navi pane - priority check failed"); |
|
169 break; |
|
170 } |
|
171 case EAiDeviceStatusContentTimedProfileIndicator: |
|
172 { |
|
173 __PRINT(__DBG_FORMAT("XAI: Render navi pane - %d, %S"), aContent, &aText ); |
|
174 |
|
175 const TInt priority = iRenderingPriorities.RenderingPriority( aContent ); |
|
176 |
|
177 if( priority >= iCurrentPriority && iIsOldTextChanged ) |
|
178 { |
|
179 delete iTimedProfileIndicator; |
|
180 iTimedProfileIndicator = NULL; |
|
181 iTimedProfileIndicator = aText.AllocL(); |
|
182 iIsTimed = ETrue; |
|
183 |
|
184 if( !iAnimator->IsActive() ) |
|
185 { |
|
186 HBufC* newText = ConstructProfileTextLC(); |
|
187 iStatusPanel.SetNaviPaneTextL( *newText ); |
|
188 iStatusPanel.RenderNaviPaneL(); |
|
189 CleanupStack::PopAndDestroy( newText ); |
|
190 } |
|
191 |
|
192 |
|
193 // iCurrentContent is not assigned because silent indicator is |
|
194 // rendered within the navi pane text |
|
195 |
|
196 __PRINTS( "XAI: Render navi pane - done"); |
|
197 } |
|
198 __PRINTS( "XAI: Render navi pane - priority check failed"); |
|
199 break; |
|
200 } |
|
201 |
|
202 // FALLTHROUGH |
|
203 case EAiDeviceStatusContentMCNIndicator: |
|
204 case EAiDeviceStatusContentVHZIndicator: |
|
205 case EAiDeviceStatusContentCUGIndicator: |
|
206 { |
|
207 iAnimator->AddItemL( aContent, aText ); |
|
208 if( !iAnimator->IsActive() ) |
|
209 { |
|
210 iAnimator->AnimateL(); |
|
211 } |
|
212 iIsChanged = ETrue; |
|
213 break; |
|
214 } |
|
215 |
|
216 default: |
|
217 { |
|
218 User::Leave( KErrNotFound ); |
|
219 break; |
|
220 } |
|
221 }; |
|
222 } |
|
223 else |
|
224 { |
|
225 User::Leave( KErrNotFound ); |
|
226 } |
|
227 } |
|
228 |
|
229 HBufC* CAiNaviPaneRenderer::ConstructProfileTextLC() |
|
230 { |
|
231 TInt bufLen = iProfileText->Length(); |
|
232 if ( iIsSilent ) |
|
233 { |
|
234 bufLen += iSilentIndicator->Length(); |
|
235 } |
|
236 if ( iIsTimed ) |
|
237 { |
|
238 bufLen += iTimedProfileIndicator->Length(); |
|
239 } |
|
240 |
|
241 HBufC *temp = HBufC::NewLC( bufLen ); |
|
242 |
|
243 if ( iIsSilent ) |
|
244 { |
|
245 temp->Des().Append( *iSilentIndicator ); |
|
246 } |
|
247 if ( iIsTimed ) |
|
248 { |
|
249 temp->Des().Append( *iTimedProfileIndicator ); |
|
250 } |
|
251 |
|
252 temp->Des().Append( *iProfileText ); |
|
253 return temp; |
|
254 } |
|
255 |
|
256 void CAiNaviPaneRenderer::DoCleanL( MAiPropertyExtension& aPlugin, TInt aContent ) |
|
257 { |
|
258 if( aPlugin.PublisherInfoL()->iUid == KDeviceStatusPluginUid ) |
|
259 { |
|
260 |
|
261 switch( aContent ) |
|
262 { |
|
263 case EAiDeviceStatusContentNetworkIdentity: |
|
264 { |
|
265 iAnimator->RemoveItem( EAiDeviceStatusContentGeneralIndicator ); |
|
266 break; |
|
267 } |
|
268 |
|
269 // FALLTHROUGH |
|
270 case EAiDeviceStatusContentDate: |
|
271 case EAiDeviceStatusContentProfileName: |
|
272 case EAiDeviceStatusContentGeneralProfileName: |
|
273 case EAiDeviceStatusContentSilentIndicator: |
|
274 case EAiDeviceStatusContentTimedProfileIndicator: |
|
275 { |
|
276 __PRINT(__DBG_FORMAT("XAI: Cleaning navi pane - %d"), aContent ); |
|
277 |
|
278 if ( aContent == EAiDeviceStatusContentSilentIndicator ) |
|
279 { |
|
280 iIsSilent = EFalse; |
|
281 } |
|
282 if ( aContent == EAiDeviceStatusContentTimedProfileIndicator ) |
|
283 { |
|
284 iIsTimed = EFalse; |
|
285 } |
|
286 if ( aContent == EAiDeviceStatusContentGeneralProfileName ) |
|
287 { |
|
288 iAnimator->RemoveItem( EAiDeviceStatusContentGeneralIndicator ); |
|
289 // iAnimator->RemoveItem( EAiDeviceStatusContentGeneralProfileName ); |
|
290 } |
|
291 if ( aContent == EAiDeviceStatusContentProfileName ) |
|
292 { |
|
293 iAnimator->RemoveItem( EAiDeviceStatusContentProfileName ); |
|
294 } |
|
295 |
|
296 TInt currentPriority = iCurrentPriority; |
|
297 |
|
298 if( iCurrentContent == aContent ) |
|
299 { |
|
300 iCurrentContent = KAiNullContentId; |
|
301 iCurrentPriority = AiNativeUiModel::KNoPriority; |
|
302 |
|
303 // Publish empty text |
|
304 iStatusPanel.SetNaviPaneTextL( KNullDesC ); |
|
305 iStatusPanel.RenderNaviPaneL(); |
|
306 |
|
307 MAiContentRequest* contentReq = static_cast<MAiContentRequest*>( |
|
308 aPlugin.GetPropertyL( EAiContentRequest ) ); |
|
309 |
|
310 if ( contentReq ) |
|
311 { |
|
312 TInt nextContentId; |
|
313 while ( iRenderingPriorities.GetNextContentId( |
|
314 nextContentId, |
|
315 currentPriority ) ) |
|
316 { |
|
317 const TBool refreshed = contentReq->RefreshContent( nextContentId ); |
|
318 if ( refreshed ) |
|
319 { |
|
320 break; |
|
321 } |
|
322 } |
|
323 } |
|
324 |
|
325 } |
|
326 __PRINTS( "XAI: Cleaning navi pane - done"); |
|
327 break; |
|
328 } |
|
329 |
|
330 case EAiDeviceStatusContentMCNIndicator: |
|
331 case EAiDeviceStatusContentVHZIndicator: |
|
332 case EAiDeviceStatusContentCUGIndicator: |
|
333 { |
|
334 iAnimator->RemoveItem( aContent ); |
|
335 break; |
|
336 } |
|
337 |
|
338 default: |
|
339 { |
|
340 User::Leave( KErrNotFound ); |
|
341 break; |
|
342 } |
|
343 }; |
|
344 } |
|
345 else |
|
346 { |
|
347 User::Leave( KErrNotFound ); |
|
348 } |
|
349 |
|
350 } |
|
351 |
|
352 |
|
353 void CAiNaviPaneRenderer::FocusObtainedL() |
|
354 { |
|
355 if( !iStatusPanel.IsKeyLockEnabled() ) |
|
356 { |
|
357 iAnimator->AnimateL(); |
|
358 } |
|
359 iFocusObtained = ETrue; |
|
360 } |
|
361 |
|
362 |
|
363 void CAiNaviPaneRenderer::FocusLostL() |
|
364 { |
|
365 iAnimator->CancelAnimationL(); |
|
366 iFocusObtained = EFalse; |
|
367 iCommitted = EFalse; |
|
368 } |
|
369 |
|
370 |
|
371 void CAiNaviPaneRenderer::KeylockDisabledL() |
|
372 { |
|
373 iAnimator->AnimateL(); |
|
374 } |
|
375 |
|
376 |
|
377 void CAiNaviPaneRenderer::KeylockEnabledL() |
|
378 { |
|
379 iAnimator->CancelAnimationL(); |
|
380 } |
|
381 |
|
382 |
|
383 void CAiNaviPaneRenderer::TransactionCommittedL() |
|
384 { |
|
385 if( iIsChanged ) |
|
386 { |
|
387 if( iFocusObtained && !iCommitted && !iStatusPanel.IsKeyLockEnabled() ) |
|
388 { |
|
389 iAnimator->AnimateL(); |
|
390 iCommitted = ETrue; |
|
391 } |
|
392 iIsChanged = EFalse; |
|
393 } |
|
394 } |
|
395 |
|
396 |
|
397 void CAiNaviPaneRenderer::AnimationCompleteL() |
|
398 { |
|
399 // Navi pane animation is now completed -> show original text |
|
400 HBufC* newText = NULL; |
|
401 |
|
402 if ( iProfileText->Length() > 0 ) |
|
403 { |
|
404 newText = ConstructProfileTextLC(); |
|
405 } |
|
406 else |
|
407 { |
|
408 return; |
|
409 } |
|
410 |
|
411 iStatusPanel.SetNaviPaneTextL( *newText ); |
|
412 iStatusPanel.RenderNaviPaneL(); |
|
413 |
|
414 CleanupStack::PopAndDestroy( newText ); |
|
415 } |
|
416 |