|
1 /* |
|
2 * Copyright (c) 2006-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: AVKON internal publisher for system owned status pane data. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "aknstatuspanedatapublisher.h" |
|
21 #include <aknglobalpopupprioritycontroller.h> |
|
22 #include "aknstatuspanedata.h" |
|
23 #include "avkoninternalpskeys.h" |
|
24 #include <e32property.h> |
|
25 #include <AknIndicator.h> |
|
26 #include <avkon.rsg> |
|
27 #include <AknStatuspaneUtils.h> |
|
28 #include <AknUtils.h> |
|
29 #include <AknIndicatorPlugin.h> |
|
30 #include <AknIndicatorPluginImplUIDs.hrh> |
|
31 #include <AknPreviewPopUpController.h> |
|
32 #include <eikenv.h> |
|
33 #include <gulicon.h> |
|
34 #include "aknindicatorpopup.h" |
|
35 #include <layoutmetadata.cdl.h> |
|
36 #include <coreapplicationuisdomainpskeys.h> // KCoreAppUIsAutolockStatus |
|
37 #include <aknlayoutscalable_avkon.cdl.h> |
|
38 |
|
39 // CONSTANTS |
|
40 const TUint KEmpty = 0xFFFFFFFF; |
|
41 const TInt KNoIndicatorPriority = 0xFFFF; |
|
42 const TInt KIndicTextBufferSize = 128; |
|
43 const TInt KAknSignalLength = EAknSignalCommonPacketDataIndicatorOff - EAknSignalGprsIndicatorOff; |
|
44 |
|
45 class CAknStatusPanePublisherData : public CBase |
|
46 { |
|
47 public: |
|
48 CAknStatusPanePublisherData():iDisabledByInput( EFalse ), iDisabledByPopup( EFalse ), |
|
49 iCoeEnv( NULL ),iProcessList(5){}; |
|
50 ~CAknStatusPanePublisherData(){ iProcessList.Close(); }; |
|
51 public: |
|
52 TAknStatusPaneStateData iData; |
|
53 TBool iDisabledByInput; |
|
54 TBool iDisabledByPopup; |
|
55 CCoeEnv* iCoeEnv; |
|
56 RArray<TUint64> iProcessList; |
|
57 }; |
|
58 |
|
59 // ============================ MEMBER FUNCTIONS =============================== |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CAknStatusPaneDataPublisher::NewL |
|
63 // (other items were commented in a header). |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 EXPORT_C CAknStatusPaneDataPublisher* CAknStatusPaneDataPublisher::NewL() |
|
67 { |
|
68 CAknStatusPaneDataPublisher* self = |
|
69 new (ELeave) CAknStatusPaneDataPublisher(); |
|
70 CleanupStack::PushL( self ); |
|
71 self->ConstructL(); |
|
72 CleanupStack::Pop( self ); |
|
73 return self; |
|
74 } |
|
75 |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CAknStatusPaneDataPublisher::ConstructL |
|
79 // (other items were commented in a header). |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 void CAknStatusPaneDataPublisher::ConstructL() |
|
83 { |
|
84 User::LeaveIfError( RProperty::Define( KPSUidAvkonInternal, |
|
85 KAknStatusPaneSystemData, |
|
86 RProperty::EByteArray ) ); |
|
87 |
|
88 User::LeaveIfError( iProperty.Attach( KPSUidAvkonInternal, |
|
89 KAknStatusPaneSystemData ) ); |
|
90 |
|
91 iStatusPaneStateData = new (ELeave) CAknStatusPanePublisherData(); |
|
92 ClearIndicatorStates(); |
|
93 |
|
94 iPopup = CAknIndicatorPopup::NewL(); |
|
95 iPopup->SetObserverL( *this ); |
|
96 |
|
97 // Get a handle to the P&S property containing Autolock state. |
|
98 iAutolockStateProperty.Attach( KPSUidCoreApplicationUIs, |
|
99 KCoreAppUIsAutolockStatus ); |
|
100 } |
|
101 |
|
102 |
|
103 // ----------------------------------------------------------------------------- |
|
104 // CAknStatusPaneDataPublisher::CAknStatusPaneDataPublisher |
|
105 // C++ default constructor can NOT contain any code, that |
|
106 // might leave. |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 CAknStatusPaneDataPublisher::CAknStatusPaneDataPublisher() |
|
110 { |
|
111 } |
|
112 |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // Destructor |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 CAknStatusPaneDataPublisher::~CAknStatusPaneDataPublisher() |
|
119 { |
|
120 iProperty.Close(); |
|
121 TInt count = iIndicators.Count(); |
|
122 TBool pluginDeleted = EFalse; |
|
123 for ( TInt i = 0; i < count; i++ ) |
|
124 { |
|
125 if ( AknLayoutUtils::PenEnabled() && iIndicators[i].iPluginLoaded ) |
|
126 { |
|
127 iIndicators[i].iPluginLoaded = EFalse; |
|
128 delete iIndicators[i].iPlugin; |
|
129 pluginDeleted = ETrue; |
|
130 } |
|
131 } |
|
132 |
|
133 if ( pluginDeleted ) |
|
134 { |
|
135 REComSession::FinalClose(); |
|
136 } |
|
137 |
|
138 iIndicators.Close(); |
|
139 delete iStatusPaneStateData; |
|
140 |
|
141 if ( iPopup ) |
|
142 { |
|
143 iPopup->RemoveObserver( *this ); |
|
144 } |
|
145 |
|
146 delete iPopup; |
|
147 |
|
148 iAutolockStateProperty.Close(); |
|
149 } |
|
150 |
|
151 |
|
152 // ----------------------------------------------------------------------------- |
|
153 // CAknStatusPaneDataPublisher::PublishUpdateL |
|
154 // (other items were commented in a header). |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 EXPORT_C void CAknStatusPaneDataPublisher::PublishDataL() |
|
158 { |
|
159 // check if the bubble is disabled by either popup or input |
|
160 if ( iStatusPaneStateData->iDisabledByPopup |
|
161 || iStatusPaneStateData->iDisabledByInput ) |
|
162 { |
|
163 iStatusPaneStateData->iData.iIndicatorState.iIncallBubbleDisabled = ETrue; |
|
164 } |
|
165 else |
|
166 { |
|
167 iStatusPaneStateData->iData.iIndicatorState.iIncallBubbleDisabled = EFalse; |
|
168 } |
|
169 TAknStatusPaneStateData::TAknStatusPaneStateDataPckg |
|
170 statusPaneStateDataPckg( iStatusPaneStateData->iData ); |
|
171 iProperty.Set( statusPaneStateDataPckg ); |
|
172 } |
|
173 |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // CAknStatusPaneDataPublisher::SetForegroundSubscriberId |
|
177 // (other items were commented in a header). |
|
178 // ----------------------------------------------------------------------------- |
|
179 // |
|
180 EXPORT_C void CAknStatusPaneDataPublisher::SetForegroundSubscriberId( TInt aId ) |
|
181 { |
|
182 if ( iStatusPaneStateData->iData.iForegroundSubscriberId != aId && |
|
183 iPopup ) |
|
184 { |
|
185 // Hide the indicator popup if it's visible when an |
|
186 // applications loses foreground, |
|
187 iPopup->HidePopup(); |
|
188 } |
|
189 |
|
190 iStatusPaneStateData->iData.iForegroundSubscriberId = aId; |
|
191 } |
|
192 |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // CAknStatusPaneDataPublisher::SetBatteryLevel |
|
196 // (other items were commented in a header). |
|
197 // ----------------------------------------------------------------------------- |
|
198 // |
|
199 EXPORT_C void CAknStatusPaneDataPublisher::SetBatteryLevel( TInt aLevel ) |
|
200 { |
|
201 iStatusPaneStateData->iData.iBatteryState.iBatteryStrength = aLevel; |
|
202 } |
|
203 |
|
204 |
|
205 // ----------------------------------------------------------------------------- |
|
206 // CAknStatusPaneDataPublisher::SetRecharge |
|
207 // (other items were commented in a header). |
|
208 // ----------------------------------------------------------------------------- |
|
209 // |
|
210 EXPORT_C void CAknStatusPaneDataPublisher::SetRecharge( TBool aRecharging ) |
|
211 { |
|
212 iStatusPaneStateData->iData.iBatteryState.iRecharging = aRecharging; |
|
213 } |
|
214 |
|
215 |
|
216 // ----------------------------------------------------------------------------- |
|
217 // CAknStatusPaneDataPublisher::SetSignalLevel |
|
218 // (other items were commented in a header). |
|
219 // ----------------------------------------------------------------------------- |
|
220 // |
|
221 EXPORT_C void CAknStatusPaneDataPublisher::SetSignalLevel( TInt aLevel ) |
|
222 { |
|
223 iStatusPaneStateData->iData.iSignalState.iSignalStrength = aLevel; |
|
224 } |
|
225 |
|
226 |
|
227 // ----------------------------------------------------------------------------- |
|
228 // CAknStatusPaneDataPublisher::SetSignalIcon |
|
229 // (other items were commented in a header). |
|
230 // ----------------------------------------------------------------------------- |
|
231 // |
|
232 EXPORT_C void CAknStatusPaneDataPublisher::SetSignalIcon( TInt aIcon ) |
|
233 { |
|
234 TBool iconChanged( ETrue ); |
|
235 |
|
236 if ( !( aIcon % KAknSignalLength ) ) // Signal off state |
|
237 { |
|
238 // If the off state signal type is not the same type signal as |
|
239 // the currently active one, no need to change signal. |
|
240 // This is done to filter out unnecessary signal state changes |
|
241 // sent by SysAp, since the icon for off state of all signal types |
|
242 // is the same. |
|
243 iconChanged = aIcon / KAknSignalLength == |
|
244 iStatusPaneStateData->iData.iSignalState.iIconState / KAknSignalLength; |
|
245 } |
|
246 |
|
247 if ( iconChanged ) |
|
248 { |
|
249 iStatusPaneStateData->iData.iSignalState.iIconState = aIcon; |
|
250 } |
|
251 } |
|
252 |
|
253 |
|
254 // ----------------------------------------------------------------------------- |
|
255 // CAknStatusPaneDataPublisher::SetIncallBubbleFlags |
|
256 // (other items were commented in a header). |
|
257 // ----------------------------------------------------------------------------- |
|
258 // |
|
259 EXPORT_C void CAknStatusPaneDataPublisher::SetIncallBubbleFlags( TInt aFlags ) |
|
260 { |
|
261 // if the flag is ESBTouchInput, do not remove previous setting |
|
262 if ( aFlags & EAknStatusBubbleInputShow || aFlags & EAknStatusBubbleInputHide ) |
|
263 { |
|
264 TInt bBubbleDisabled = ( ( aFlags & EAknStatusBubbleInputShow ) == EAknStatusBubbleInputShow )? ETrue : EFalse; |
|
265 iStatusPaneStateData->iDisabledByInput = bBubbleDisabled; |
|
266 } |
|
267 else |
|
268 { |
|
269 iStatusPaneStateData->iData.iIndicatorState.iIncallBubbleFlags = aFlags; |
|
270 } |
|
271 } |
|
272 |
|
273 |
|
274 // ----------------------------------------------------------------------------- |
|
275 // CAknStatusPaneDataPublisher::SetIncallBubbleAllowedInUsual |
|
276 // (other items were commented in a header). |
|
277 // ----------------------------------------------------------------------------- |
|
278 // |
|
279 EXPORT_C void CAknStatusPaneDataPublisher::SetIncallBubbleAllowedInUsual( |
|
280 TBool aAllowed ) |
|
281 { |
|
282 iStatusPaneStateData->iData.iIndicatorState.iIncallBubbleAllowedInUsual = |
|
283 aAllowed; |
|
284 } |
|
285 |
|
286 // ----------------------------------------------------------------------------- |
|
287 // CAknStatusPaneDataPublisher::SetIncallBubbleAllowedInUsual |
|
288 // (other items were commented in a header). |
|
289 // ----------------------------------------------------------------------------- |
|
290 // |
|
291 EXPORT_C void CAknStatusPaneDataPublisher::SetIncallBubbleAllowedInUsual( TBool aAllowed, const TUint64& aClientId ) |
|
292 { |
|
293 if ( aClientId == 0 ) |
|
294 { |
|
295 iStatusPaneStateData->iData.iIndicatorState.iIncallBubbleAllowedInUsual = aAllowed ; |
|
296 return; |
|
297 } |
|
298 |
|
299 // To store the list when switch from a view disabling the bubble to the other view disabling |
|
300 // the buble,too. Currently, this list will not bu used not. |
|
301 if ( !aAllowed ) |
|
302 { |
|
303 if( iStatusPaneStateData->iProcessList.Find( aClientId ) == KErrNotFound ) |
|
304 { |
|
305 iStatusPaneStateData->iProcessList.Append( aClientId ); |
|
306 } |
|
307 } |
|
308 else |
|
309 { |
|
310 TInt index = iStatusPaneStateData->iProcessList.Find( aClientId ); |
|
311 if( index != KErrNotFound ) |
|
312 { |
|
313 iStatusPaneStateData->iProcessList.Remove( index ); |
|
314 } |
|
315 |
|
316 // if the focused process has disabled the bubble ,ignore the bubble enable flag |
|
317 if ( !iStatusPaneStateData->iCoeEnv ) |
|
318 { |
|
319 iStatusPaneStateData->iCoeEnv = CCoeEnv::Static( ); |
|
320 } |
|
321 RWsSession &ws = iStatusPaneStateData->iCoeEnv->WsSession(); |
|
322 TInt focusId = ws.GetFocusWindowGroup(); |
|
323 RThread focusThread; |
|
324 TThreadId threadId = 0; |
|
325 if ( KErrNone == ws.GetWindowGroupClientThreadId( focusId, threadId ) ) |
|
326 { |
|
327 // if focused window has disable the bubble,ignore it |
|
328 if ( KErrNotFound != iStatusPaneStateData->iProcessList.Find( threadId.Id() ) ) |
|
329 { |
|
330 aAllowed = EFalse; |
|
331 } |
|
332 } |
|
333 // reset the process list |
|
334 iStatusPaneStateData->iProcessList.Reset(); |
|
335 } |
|
336 iStatusPaneStateData->iData.iIndicatorState.iIncallBubbleAllowedInUsual = aAllowed ; |
|
337 } |
|
338 |
|
339 // ----------------------------------------------------------------------------- |
|
340 // CAknStatusPaneDataPublisher::SetIncallBubbleAllowedInIdle |
|
341 // (other items were commented in a header). |
|
342 // ----------------------------------------------------------------------------- |
|
343 // |
|
344 EXPORT_C void CAknStatusPaneDataPublisher::SetIncallBubbleAllowedInIdle( |
|
345 TBool aAllowed ) |
|
346 { |
|
347 iStatusPaneStateData->iData.iIndicatorState.iIncallBubbleAllowedInIdle = |
|
348 aAllowed; |
|
349 } |
|
350 |
|
351 |
|
352 // ----------------------------------------------------------------------------- |
|
353 // CAknStatusPaneDataPublisher::SetIndicatorState |
|
354 // (other items were commented in a header). |
|
355 // ----------------------------------------------------------------------------- |
|
356 // |
|
357 EXPORT_C void CAknStatusPaneDataPublisher::SetIndicatorState( TUid aUid, |
|
358 TInt aState ) |
|
359 { |
|
360 TRAP_IGNORE( SetIndicatorStateL( aUid, aState ) ); |
|
361 } |
|
362 |
|
363 |
|
364 // ----------------------------------------------------------------------------- |
|
365 // CAknStatusPaneDataPublisher::SetIndicatorStateL |
|
366 // (other items were commented in a header). |
|
367 // ----------------------------------------------------------------------------- |
|
368 // |
|
369 void CAknStatusPaneDataPublisher::SetIndicatorStateL( TUid aUid, TInt aState ) |
|
370 { |
|
371 TBool indicatorExists = EFalse; |
|
372 TBool found = EFalse; |
|
373 TInt count = iIndicators.Count(); |
|
374 // Whether or not an indicator is added to or removed from the popup. |
|
375 TBool resizePopup = EFalse; |
|
376 |
|
377 for ( TInt i = 0; i < count; i++ ) |
|
378 { |
|
379 if ( iIndicators[i].iUid == aUid.iUid ) |
|
380 { |
|
381 indicatorExists = ETrue; |
|
382 iIndicators[i].iState = aState; |
|
383 if ( aState == EAknIndicatorStateOff ) |
|
384 { |
|
385 if ( AknLayoutUtils::PenEnabled() && |
|
386 iIndicators[i].iPluginLoaded ) |
|
387 { |
|
388 if ( iPopup && iIndicators[i].iPopupItemExists ) |
|
389 { |
|
390 iPopup->RemoveItem( aUid.iUid ); |
|
391 iIndicators[i].iPopupItemExists = EFalse; |
|
392 resizePopup = ETrue; |
|
393 } |
|
394 |
|
395 // We don't delete the ECOM plugins here, as they don't |
|
396 // have such a major impact on memory consumption. |
|
397 // If the plugin would be destroyed here, |
|
398 // REComSession::FinalClose() should also be called |
|
399 // to avoid leaking memory, and it could cause |
|
400 // KERN-EXEC panics with certain plugin implementations |
|
401 // in which part of the plugin DLL is still on the |
|
402 // call stack when the library is unloaded. |
|
403 } |
|
404 } |
|
405 break; |
|
406 } |
|
407 } |
|
408 |
|
409 if ( !indicatorExists ) |
|
410 { |
|
411 TInt widePriority = KNoIndicatorPriority; |
|
412 TInt narrowPriority = KNoIndicatorPriority; |
|
413 |
|
414 TResourceReader res; |
|
415 |
|
416 // Check first the status indicators |
|
417 CCoeEnv::Static()->CreateResourceReaderLC( |
|
418 res, |
|
419 R_AVKON_STATUS_PANE_INDICATOR_DEFAULT ); |
|
420 |
|
421 TInt indicatorCount = res.ReadInt16(); |
|
422 for ( TInt ii = 0; ii < indicatorCount; ii++ ) |
|
423 { |
|
424 TInt foundUid = res.ReadInt16(); |
|
425 if ( foundUid == aUid.iUid ) |
|
426 { |
|
427 found = ETrue; |
|
428 widePriority = res.ReadInt16(); |
|
429 narrowPriority = res.ReadInt16(); |
|
430 break; |
|
431 } |
|
432 else |
|
433 { |
|
434 res.ReadInt16(); |
|
435 res.ReadInt16(); |
|
436 HBufC* bitmapFile = res.ReadHBufCL(); // bmp filename |
|
437 delete bitmapFile; |
|
438 bitmapFile = NULL; |
|
439 TInt numberOfStates = res.ReadInt16(); // Number of states |
|
440 for ( TInt i = 0; i < numberOfStates; i++ ) |
|
441 { |
|
442 res.ReadInt16(); // State id |
|
443 TInt numberOfIcons = res.ReadInt16(); |
|
444 for ( TInt iii = 0; iii < numberOfIcons; iii++ ) |
|
445 { |
|
446 for ( TInt jj = 0; jj <= 1; jj++ ) |
|
447 { |
|
448 res.ReadInt16(); // bitmaps |
|
449 res.ReadInt16(); // mask |
|
450 } |
|
451 } |
|
452 } |
|
453 } |
|
454 } |
|
455 CleanupStack::PopAndDestroy(); // res |
|
456 |
|
457 // If not found then check the editor indicators |
|
458 if ( !indicatorExists && !found ) |
|
459 { |
|
460 CCoeEnv::Static()->CreateResourceReaderLC( res, R_AVKON_NAVI_PANE_EDITOR_INDICATORS ); |
|
461 |
|
462 indicatorCount = res.ReadInt16(); |
|
463 for (TInt ii = 0; ii < indicatorCount; ii++) |
|
464 { |
|
465 TInt foundUid = res.ReadInt16(); |
|
466 if (foundUid == aUid.iUid) |
|
467 { |
|
468 found = ETrue; |
|
469 widePriority = res.ReadInt16(); |
|
470 narrowPriority = res.ReadInt16(); |
|
471 break; |
|
472 } |
|
473 else |
|
474 { |
|
475 res.ReadInt16(); |
|
476 res.ReadInt16(); |
|
477 HBufC* bitmapFile = res.ReadHBufCL(); // bmp filename |
|
478 delete bitmapFile; |
|
479 bitmapFile = NULL; |
|
480 TInt numberOfStates = res.ReadInt16(); // Number of states |
|
481 for (TInt i = 0; i < numberOfStates; i++) |
|
482 { |
|
483 res.ReadInt16(); // State id |
|
484 TInt numberOfIcons = res.ReadInt16(); |
|
485 for (TInt ii = 0; ii < numberOfIcons; ii++) |
|
486 { |
|
487 for (TInt jj = 0; jj <= 1; jj++) |
|
488 { |
|
489 res.ReadInt16(); // bitmaps |
|
490 res.ReadInt16(); // mask |
|
491 } |
|
492 } |
|
493 } |
|
494 } |
|
495 } |
|
496 CleanupStack::PopAndDestroy(); // res |
|
497 } |
|
498 |
|
499 TAknStatusIndicator newIndicator; |
|
500 newIndicator.iUid = aUid.iUid; |
|
501 newIndicator.iNarrowPriority = narrowPriority; |
|
502 newIndicator.iWidePriority = widePriority; |
|
503 newIndicator.iState = aState; |
|
504 |
|
505 iIndicators.AppendL( newIndicator ); |
|
506 } |
|
507 |
|
508 PrioritizeIndicatorsL(); |
|
509 |
|
510 ClearIndicatorStates(); |
|
511 |
|
512 TInt prioritizedIndicatorCount = iIndicators.Count(); |
|
513 TInt publishedCount = 0; |
|
514 |
|
515 for ( TInt ii = 0; ii < prioritizedIndicatorCount; ii++ ) |
|
516 { |
|
517 if ( publishedCount < TAknIndicatorState::EMaxVisibleIndicators ) |
|
518 { |
|
519 if ( iIndicators[ii].iState != MAknIndicator::EIndicatorOff ) |
|
520 { |
|
521 iStatusPaneStateData->iData.iIndicatorState.visibleIndicators[publishedCount] = |
|
522 iIndicators[ii].iUid; |
|
523 iStatusPaneStateData->iData.iIndicatorState.visibleIndicatorStates[publishedCount] = |
|
524 iIndicators[ii].iState; |
|
525 publishedCount++; |
|
526 |
|
527 if ( iPopup ) |
|
528 { |
|
529 if ( !iIndicators[ii].iPluginLoaded ) |
|
530 { |
|
531 LoadIndicatorPlugin( iIndicators[ii] ); |
|
532 } |
|
533 |
|
534 if ( iIndicators[ii].iPlugin ) |
|
535 { |
|
536 if ( !iIndicators[ii].iPopupItemExists ) |
|
537 { |
|
538 TInt textType( 0 ); |
|
539 HBufC* text = iIndicators[ii].iPlugin->TextL( iIndicators[ii].iUid, textType ); |
|
540 if ( text ) |
|
541 { |
|
542 // Ownership is transferred here. |
|
543 CleanupStack::PushL( text ); |
|
544 } |
|
545 |
|
546 // If plugin does not provide the text, the we use the |
|
547 // default string for the indicator. |
|
548 if ( textType == 0 || !text ) |
|
549 { |
|
550 if ( !text ) |
|
551 { |
|
552 text = HBufC::NewLC( KIndicTextBufferSize ); |
|
553 } |
|
554 else |
|
555 { |
|
556 text->ReAllocL( KIndicTextBufferSize ); |
|
557 } |
|
558 |
|
559 TPtr ptr( text->Des() ); |
|
560 GetDefaultIndicatorTextL( iIndicators[ii].iUid, ptr ); |
|
561 |
|
562 if ( textType == 0 ) |
|
563 { |
|
564 // Set the text type to information text |
|
565 // only if the type is not specified by |
|
566 // the plugin. This enables the plugins |
|
567 // to use the default string as link text. |
|
568 textType = CAknIndicatorPlugin::EAknIndicatorPluginInformationText; |
|
569 } |
|
570 } |
|
571 |
|
572 if ( text->Length() ) // Only add item if it has description. |
|
573 { |
|
574 const CGulIcon* icon = NULL; |
|
575 TRAPD( err, icon = |
|
576 iIndicators[ii].iPlugin->IconL( |
|
577 iIndicators[ii].iUid ) ); |
|
578 |
|
579 if ( err ) |
|
580 { |
|
581 icon = NULL; |
|
582 } |
|
583 |
|
584 iPopup->AddItemL( iIndicators[ii].iUid, |
|
585 *text, |
|
586 textType, |
|
587 icon, |
|
588 iIndicators[ii].iPlugin, |
|
589 iIndicators[ii].iNarrowPriority != KNoIndicatorPriority ? |
|
590 iIndicators[ii].iNarrowPriority : |
|
591 iIndicators[ii].iWidePriority ); |
|
592 |
|
593 iIndicators[ii].iPopupItemExists = ETrue; |
|
594 |
|
595 resizePopup = ETrue; |
|
596 } |
|
597 |
|
598 CleanupStack::PopAndDestroy( text ); |
|
599 } |
|
600 else if ( aUid.iUid == iIndicators[ii].iUid ) |
|
601 { |
|
602 // Indicator already exists in the popup, try to update it. |
|
603 iPopup->UpdatePopupIndicatorL( aUid.iUid ); |
|
604 } |
|
605 } |
|
606 else if ( !iIndicators[ii].iPopupItemExists ) |
|
607 { |
|
608 // Indicator doesn't have a plugin, so show the default content |
|
609 // for it in the popup. |
|
610 HBufC* text = HBufC::NewLC( KIndicTextBufferSize ); |
|
611 TPtr ptr( text->Des() ); |
|
612 GetDefaultIndicatorTextL( iIndicators[ii].iUid, ptr ); |
|
613 |
|
614 if ( ptr.Length() ) // Only add item if it has description. |
|
615 { |
|
616 iPopup->AddItemL( iIndicators[ii].iUid, |
|
617 *text, |
|
618 CAknIndicatorPlugin::EAknIndicatorPluginInformationText, |
|
619 NULL, |
|
620 NULL, |
|
621 iIndicators[ii].iNarrowPriority != KNoIndicatorPriority ? |
|
622 iIndicators[ii].iNarrowPriority : |
|
623 iIndicators[ii].iWidePriority ); |
|
624 |
|
625 iIndicators[ii].iPopupItemExists = ETrue; |
|
626 resizePopup = ETrue; |
|
627 } |
|
628 |
|
629 CleanupStack::PopAndDestroy( text ); |
|
630 } |
|
631 } |
|
632 } |
|
633 } |
|
634 else |
|
635 { |
|
636 break; |
|
637 } |
|
638 } |
|
639 |
|
640 if ( resizePopup ) |
|
641 { |
|
642 // Popup position needs to be reset if in current layout the popup |
|
643 // grows upwards as indicators are added. |
|
644 if ( Layout_Meta_Data::IsLandscapeOrientation() && |
|
645 AknLayoutUtils::CbaLocation() == |
|
646 AknLayoutUtils::EAknCbaLocationBottom ) |
|
647 { |
|
648 SetIndicatorPopupPosition(); |
|
649 } |
|
650 } |
|
651 } |
|
652 |
|
653 |
|
654 // ----------------------------------------------------------------------------- |
|
655 // CAknStatusPaneDataPublisher::ClearIndicatorStates |
|
656 // (other items were commented in a header). |
|
657 // ----------------------------------------------------------------------------- |
|
658 // |
|
659 void CAknStatusPaneDataPublisher::ClearIndicatorStates() |
|
660 { |
|
661 Mem::Fill(&(iStatusPaneStateData->iData.iIndicatorState.visibleIndicators[0]), |
|
662 (sizeof(TInt)*TAknIndicatorState::EMaxVisibleIndicators), |
|
663 KEmpty); |
|
664 Mem::Fill(&(iStatusPaneStateData->iData.iIndicatorState.visibleIndicatorStates[0]), |
|
665 (sizeof(TInt)*TAknIndicatorState::EMaxVisibleIndicators), |
|
666 KEmpty); |
|
667 } |
|
668 |
|
669 |
|
670 // --------------------------------------------------------------------------- |
|
671 // CAknStatusPaneDataPublisher::SetBatteryIcon |
|
672 // (other items were commented in a header). |
|
673 // --------------------------------------------------------------------------- |
|
674 // |
|
675 EXPORT_C void CAknStatusPaneDataPublisher::SetBatteryIcon( TInt aIcon ) |
|
676 { |
|
677 iStatusPaneStateData->iData.iBatteryState.iIconState = aIcon; |
|
678 } |
|
679 |
|
680 // ---------------------------------------------------------------------------- |
|
681 // CAknStatusPaneDataPublisher::SetIndicatorPopupPosition |
|
682 // (other items were commented in the header |
|
683 // ---------------------------------------------------------------------------- |
|
684 EXPORT_C void CAknStatusPaneDataPublisher::SetIndicatorPopupPosition() |
|
685 { |
|
686 // Position is read from the LAF data. |
|
687 // Application window should be the parent rectangle, but |
|
688 // in nHD landscape it's not correct. |
|
689 // In that case the parent has to be adjusted somewhat. |
|
690 // Also, the layout data doesn't currently mirror the |
|
691 // popup_uni_indicator_window, so it must be done here. |
|
692 TRect applicationWindow; |
|
693 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EApplicationWindow, |
|
694 applicationWindow ); |
|
695 |
|
696 TRect mainPane; |
|
697 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, |
|
698 mainPane ); |
|
699 |
|
700 TBool layoutMirrored( AknLayoutUtils::LayoutMirrored() ); |
|
701 TBool isLandscape( Layout_Meta_Data::IsLandscapeOrientation() ); |
|
702 |
|
703 // This defines if the popup should be located on the bottom of the screen |
|
704 // and grown upwards when content is added. |
|
705 TBool positionIsBottomLeft( EFalse ); |
|
706 |
|
707 if ( isLandscape && AknStatuspaneUtils::HDLayoutActive() ) |
|
708 { |
|
709 // In nHD landscape A&H layout the right pane area |
|
710 // is not mirrored so this is sufficient. |
|
711 applicationWindow.iBr.iX = mainPane.iBr.iX; |
|
712 } |
|
713 |
|
714 TInt statusPaneLayoutId = AknStatuspaneUtils::CurrentStatusPaneLayoutResId(); |
|
715 TAknLayoutRect layoutRect; |
|
716 if ( isLandscape && |
|
717 ( statusPaneLayoutId == R_AVKON_STATUS_PANE_LAYOUT_USUAL_FLAT || |
|
718 statusPaneLayoutId == R_AVKON_STATUS_PANE_LAYOUT_IDLE_FLAT ) ) |
|
719 { |
|
720 layoutRect.LayoutRect( |
|
721 applicationWindow, |
|
722 AknLayoutScalable_Avkon::popup_uni_indicator_window( 6 ) ); |
|
723 positionIsBottomLeft = ETrue; |
|
724 } |
|
725 else if ( statusPaneLayoutId == R_AVKON_WIDESCREEN_PANE_LAYOUT_USUAL || |
|
726 statusPaneLayoutId == R_AVKON_WIDESCREEN_PANE_LAYOUT_IDLE ) |
|
727 { |
|
728 layoutRect.LayoutRect( |
|
729 applicationWindow, |
|
730 AknLayoutScalable_Avkon::popup_uni_indicator_window( 6 ) ); |
|
731 } |
|
732 else if ( statusPaneLayoutId == R_AVKON_WIDESCREEN_PANE_LAYOUT_USUAL_FLAT || |
|
733 statusPaneLayoutId == R_AVKON_WIDESCREEN_PANE_LAYOUT_IDLE_FLAT || |
|
734 statusPaneLayoutId == R_AVKON_WIDESCREEN_PANE_LAYOUT_USUAL_FLAT_NO_SOFTKEYS || |
|
735 statusPaneLayoutId == R_AVKON_WIDESCREEN_PANE_LAYOUT_IDLE_FLAT_NO_SOFTKEYS ) |
|
736 { |
|
737 layoutRect.LayoutRect( |
|
738 applicationWindow, |
|
739 AknLayoutScalable_Avkon::popup_uni_indicator_window( 5 ) ); |
|
740 } |
|
741 else |
|
742 { |
|
743 layoutRect.LayoutRect( |
|
744 applicationWindow, |
|
745 AknLayoutScalable_Avkon::popup_uni_indicator_window( 0 ) ); |
|
746 |
|
747 } |
|
748 TRect popupRect( layoutRect.Rect() ); |
|
749 |
|
750 TInt popupWidth( popupRect.Width() ); |
|
751 TInt xyOffset( popupRect.iTl.iY ); |
|
752 TInt xPoint( 0 ); |
|
753 |
|
754 // Preview popup's size contains also the frames, so the |
|
755 // difference between that size and the content's size |
|
756 // has to be taken into account in the positioning. |
|
757 // Frame width is read from the LAF because preview popup's |
|
758 // size may not be correct at this point. |
|
759 TAknWindowLineLayout previewPopupSideFrameLayout( |
|
760 AknLayoutScalable_Avkon::bg_popup_preview_window_pane_g9().LayoutLine() ); |
|
761 TInt frameOffset = previewPopupSideFrameLayout.iW; |
|
762 |
|
763 if ( isLandscape ) |
|
764 { |
|
765 if ( !layoutMirrored ) |
|
766 { |
|
767 xPoint = popupRect.iBr.iX + frameOffset; |
|
768 } |
|
769 else |
|
770 { |
|
771 xPoint = applicationWindow.iBr.iX - popupRect.iTl.iX + frameOffset; |
|
772 } |
|
773 } |
|
774 else |
|
775 { |
|
776 if ( !layoutMirrored ) |
|
777 { |
|
778 xPoint = applicationWindow.iBr.iX - xyOffset; |
|
779 } |
|
780 else |
|
781 { |
|
782 xPoint = xyOffset + popupWidth + frameOffset * 2; |
|
783 } |
|
784 } |
|
785 |
|
786 if ( positionIsBottomLeft ) |
|
787 { |
|
788 iPopup->SetBottomPosition( TPoint( xPoint, popupRect.iBr.iY ) ); |
|
789 } |
|
790 else |
|
791 { |
|
792 iPopup->SetPosition( TPoint( xPoint, xyOffset ) ); |
|
793 } |
|
794 } |
|
795 // ----------------------------------------------------------------------------- |
|
796 // From class MAknPreviewPopUpObserver. |
|
797 // CAknStatusPaneDataPublisher::HandlePreviewPopUpEventL |
|
798 // ----------------------------------------------------------------------------- |
|
799 // |
|
800 void CAknStatusPaneDataPublisher::HandlePreviewPopUpEventL( |
|
801 CAknPreviewPopUpController* aController, |
|
802 TPreviewPopUpEvent aEvent ) |
|
803 { |
|
804 if ( AknGlobalPopupPriorityController::GlobalPopupsAllowed() && |
|
805 iPopup && aController == iPopup->Controller() ) |
|
806 { |
|
807 TInt incallBubbleFlags = |
|
808 iStatusPaneStateData->iData.iIndicatorState.iIncallBubbleFlags; |
|
809 |
|
810 TBool incallBubbleDisabled = |
|
811 iStatusPaneStateData->iData.iIndicatorState.iIncallBubbleDisabled; |
|
812 |
|
813 switch ( aEvent ) |
|
814 { |
|
815 case EPreviewPopUpShown: |
|
816 if ( ( incallBubbleFlags & EAknStatusBubbleVisible ) && |
|
817 !incallBubbleDisabled ) |
|
818 { |
|
819 // Hide the incall status bubble if |
|
820 // it's visible when indicator popup is shown. |
|
821 iStatusPaneStateData->iDisabledByPopup = ETrue; |
|
822 PublishDataL(); |
|
823 } |
|
824 iPopup->SetContentVisible( ETrue ); |
|
825 break; |
|
826 |
|
827 case EPreviewPopUpHidden: |
|
828 if ( incallBubbleDisabled ) |
|
829 { |
|
830 iStatusPaneStateData->iDisabledByPopup = EFalse; |
|
831 PublishDataL(); |
|
832 } |
|
833 iPopup->SetContentVisible( EFalse ); |
|
834 break; |
|
835 |
|
836 default: |
|
837 break; |
|
838 } |
|
839 } |
|
840 } |
|
841 |
|
842 |
|
843 // ----------------------------------------------------------------------------- |
|
844 // CAknStatusPaneDataPublisher::PrioritizeIndicatorsL |
|
845 // (other items were commented in a header). |
|
846 // ----------------------------------------------------------------------------- |
|
847 // |
|
848 void CAknStatusPaneDataPublisher::PrioritizeIndicatorsL() |
|
849 { |
|
850 TInt count = iIndicators.Count(); |
|
851 if ( count < 2 ) |
|
852 { |
|
853 // Nothing to prioritize. |
|
854 return; |
|
855 } |
|
856 |
|
857 // Assume that narrow/wide priorities are the same. |
|
858 TBool sortByWidePriority = AknStatuspaneUtils::IdleLayoutActive(); |
|
859 |
|
860 TAknStatusIndicator temp; |
|
861 for ( TInt ii = 1; ii < count; ii++ ) |
|
862 { |
|
863 temp = iIndicators[ii]; |
|
864 TInt tempPriority = temp.iNarrowPriority; |
|
865 |
|
866 if ( tempPriority == KNoIndicatorPriority ) |
|
867 { |
|
868 tempPriority = temp.iWidePriority; |
|
869 } |
|
870 |
|
871 if ( tempPriority >= 0 ) |
|
872 { |
|
873 for ( TInt jj = 0; jj <= ii; jj++ ) |
|
874 { |
|
875 TInt indicatorPriority = iIndicators[jj].iNarrowPriority; |
|
876 if ( indicatorPriority == KNoIndicatorPriority ) |
|
877 { |
|
878 indicatorPriority = iIndicators[jj].iWidePriority; |
|
879 } |
|
880 |
|
881 if ( tempPriority < indicatorPriority ) |
|
882 { |
|
883 iIndicators.Remove( ii ); |
|
884 iIndicators.InsertL( temp, jj ); |
|
885 break; |
|
886 } |
|
887 else if ( jj == ( ii - 1 ) ) |
|
888 { |
|
889 break; |
|
890 } |
|
891 } |
|
892 } |
|
893 } |
|
894 } |
|
895 |
|
896 |
|
897 // ----------------------------------------------------------------------------- |
|
898 // CAknStatusPaneDataPublisher::HandleIndicatorTapL |
|
899 // (other items were commented in a header). |
|
900 // ----------------------------------------------------------------------------- |
|
901 // |
|
902 EXPORT_C void CAknStatusPaneDataPublisher::HandleIndicatorTapL( |
|
903 TUid /*aIndicatorUid*/ ) |
|
904 { |
|
905 if ( AknLayoutUtils::PenEnabled() && iPopup ) |
|
906 { |
|
907 // Do not display the universal indicator popup |
|
908 // if device lock is active. |
|
909 TInt autolockState; |
|
910 TInt err = iAutolockStateProperty.Get( autolockState ); |
|
911 |
|
912 if ( err != KErrNone || autolockState <= EAutolockOff ) |
|
913 { |
|
914 // This is called to ensure correct information on the popup |
|
915 // and to lessen the need for indicator plugins to have |
|
916 // change listeners for indicator data. |
|
917 iPopup->UpdateAllPopupIndicatorsL(); |
|
918 |
|
919 iPopup->ShowPopup(); |
|
920 } |
|
921 } |
|
922 } |
|
923 |
|
924 |
|
925 // ----------------------------------------------------------------------------- |
|
926 // CAknStatusPaneDataPublisher::LoadIndicatorPlugin |
|
927 // (other items were commented in a header). |
|
928 // ----------------------------------------------------------------------------- |
|
929 // |
|
930 void CAknStatusPaneDataPublisher::LoadIndicatorPlugin( |
|
931 TAknStatusIndicator& aIndicator ) |
|
932 { |
|
933 if ( AknLayoutUtils::PenEnabled() ) |
|
934 { |
|
935 CAknIndicatorPlugin* indicatorPlugin = NULL; |
|
936 TUid pluginUid = { KErrNotFound }; |
|
937 |
|
938 switch ( aIndicator.iUid ) |
|
939 { |
|
940 // Status pane's indicators |
|
941 case EAknIndicatorIrActive: |
|
942 { |
|
943 pluginUid.iUid = KImplUIDIRIndicatorsPlugin; |
|
944 break; |
|
945 } |
|
946 case EAknIndicatorEnvelope: |
|
947 case EAknIndicatorEmailMessage: |
|
948 case EAknIndicatorDataMessage: |
|
949 case EAknIndicatorFaxMessage: |
|
950 case EAknIndicatorOtherMessage: |
|
951 case EAknIndicatorOutbox: |
|
952 case EAknIndicatorVoiceMailWaiting: |
|
953 case EAknIndicatorVoiceMailWaitingOnLine1: |
|
954 case EAknIndicatorVoiceMailWaitingOnLine2: |
|
955 case EAknIndicatorVoiceMailWaitingOnBothLines: |
|
956 case EAknIndicatorRemoteMailboxEmailMessage: |
|
957 { |
|
958 pluginUid.iUid = KImplUIDMessagingIndicatorsPlugin; |
|
959 break; |
|
960 } |
|
961 case EAknIndicatorBluetooth: |
|
962 case EAknIndicatorBluetoothVisible: |
|
963 case EAknIndicatorBluetoothModuleOn: |
|
964 case EAknIndicatorBluetoothModuleOnVisible: |
|
965 { |
|
966 pluginUid.iUid = KImplUIDBTIndicatorsPlugin; |
|
967 break; |
|
968 } |
|
969 case EAknIndicatorMissedCalls: |
|
970 { |
|
971 pluginUid.iUid = KImplUIDCallRelatedIndicatorsPlugin; |
|
972 break; |
|
973 } |
|
974 case EAknIndicatorAlarmClock: |
|
975 { |
|
976 pluginUid.iUid = KImplUIDClockIndicatorsPlugin; |
|
977 break; |
|
978 } |
|
979 case EAknIndicatorStopWatch: |
|
980 { |
|
981 pluginUid.iUid = KImplUIDStopwatchIndicatorsPlugin; |
|
982 break; |
|
983 } |
|
984 case EAknIndicatorUSBConnection: |
|
985 { |
|
986 pluginUid.iUid = KImplUIDUSBIndicatorsPlugin; |
|
987 break; |
|
988 } |
|
989 case EAknIndicatorLocation: |
|
990 case EAknIndicatorLocationOn: |
|
991 case EAknIndicatorLocationOff: |
|
992 case EAknIndicatorGPS: |
|
993 { |
|
994 pluginUid.iUid = KImplUIDLocationIndicatorsPlugin; |
|
995 break; |
|
996 } |
|
997 case EAknIndicatorInstantMessage: |
|
998 { |
|
999 pluginUid.iUid = KImplUIDInstantMessageIndicatorsPlugin; |
|
1000 break; |
|
1001 } |
|
1002 |
|
1003 case EAknIndicatorPoC: |
|
1004 case EAknIndicatorPoCMissed: |
|
1005 case EAknIndicatorPoCDnD: |
|
1006 { |
|
1007 pluginUid.iUid = KImplUIDPoCIndicatorsPlugin; |
|
1008 break; |
|
1009 } |
|
1010 |
|
1011 case EAknIndicatorWlanAvailable: |
|
1012 case EAknIndicatorWlanActive: |
|
1013 case EAknIndicatorWlanActiveSecure: |
|
1014 { |
|
1015 pluginUid.iUid = KImplUIDWlanIndicatorPlugin; |
|
1016 break; |
|
1017 } |
|
1018 case EAknIndicatorMissedCalendarAlarm: |
|
1019 { |
|
1020 pluginUid.iUid = KImplUIDMissedCalendarAlarmIndicatorPlugin; |
|
1021 break; |
|
1022 } |
|
1023 case EAknIndicatorFMTxSending: |
|
1024 case EAknIndicatorFMTxEnabled: |
|
1025 { |
|
1026 pluginUid.iUid = KImplUIDFMTxIndicatorPlugin; |
|
1027 break; |
|
1028 } |
|
1029 case EAknIndicatorMecoServiceTab: |
|
1030 { |
|
1031 pluginUid.iUid = KImplUIDMecoServiceTabIndicatorPlugin; |
|
1032 break; |
|
1033 } |
|
1034 case EAknIndicatorUSBMemActive: |
|
1035 case EAknIndicatorUSBMemConnected: |
|
1036 { |
|
1037 pluginUid.iUid = KImplUIDUSBMEMIndicatorsPlugin; |
|
1038 break; |
|
1039 } |
|
1040 // currently uncategorized: |
|
1041 case EAknIndicatorKeyguard: |
|
1042 case EAknIndicatorHomeZone: |
|
1043 case EAknIndicatorSecuredConnection: |
|
1044 case EAknIndicatorHeadset: |
|
1045 case EAknIndicatorLoopset: |
|
1046 case EAknIndicatorIHFActive: |
|
1047 case EAknIndicatorTTY: |
|
1048 case EAknIndicatorHeadsetUnavailable: |
|
1049 case EAknIndicatorRoaming: |
|
1050 case EAknIndicatorCarkit: |
|
1051 case EAknIndicatorTvOut: |
|
1052 case EAknIndicatorHDMI: |
|
1053 case EAknIndicatorMobileTV: |
|
1054 case EAknIndicatorTARM: |
|
1055 case EAknIndicatorTARMModuleOn: |
|
1056 case EAknIndicatorVideoSharing: |
|
1057 case EAknIndicatorSynchronization: |
|
1058 case EAknIndicatorVoIP: |
|
1059 case EAknIndicatorAllCallsForwarded: |
|
1060 case EAknIndicatorCallsForwardedOnLine1: |
|
1061 case EAknIndicatorCallsForwardedOnLine2: |
|
1062 case EAknIndicatorCallsForwardedOnBothLines: |
|
1063 case EAknIndicatorCallsForwardedToVoiceMailbox: |
|
1064 case EAknIndicatorSelectedLine: |
|
1065 default: |
|
1066 { |
|
1067 break; |
|
1068 } |
|
1069 } |
|
1070 |
|
1071 TRAPD( err, indicatorPlugin = CAknIndicatorPlugin::NewL( pluginUid ) ); |
|
1072 aIndicator.iPluginLoaded = ETrue; |
|
1073 if ( err == KErrNone ) |
|
1074 { |
|
1075 aIndicator.iPlugin = indicatorPlugin; |
|
1076 } |
|
1077 } |
|
1078 } |
|
1079 |
|
1080 |
|
1081 // ----------------------------------------------------------------------------- |
|
1082 // CAknStatusPaneDataPublisher::GetDefaultIndicatorText |
|
1083 // (other items were commented in a header). |
|
1084 // ----------------------------------------------------------------------------- |
|
1085 // |
|
1086 void CAknStatusPaneDataPublisher::GetDefaultIndicatorTextL( TInt aUid, |
|
1087 TDes& aText ) |
|
1088 { |
|
1089 CCoeEnv* env = CCoeEnv::Static(); |
|
1090 |
|
1091 TResourceReader reader; |
|
1092 env->CreateResourceReaderLC( reader, R_AVKON_INDICATOR_POPUP_DEFAULTS ); |
|
1093 |
|
1094 TInt itemCount( reader.ReadInt16() ); |
|
1095 TInt uid( KErrNotFound ); |
|
1096 |
|
1097 for ( TInt i = 0; i < itemCount; i++ ) |
|
1098 { |
|
1099 uid = reader.ReadInt16(); |
|
1100 |
|
1101 if ( uid == aUid ) |
|
1102 { |
|
1103 aText = reader.ReadTPtrC16(); |
|
1104 break; |
|
1105 } |
|
1106 else |
|
1107 { |
|
1108 reader.ReadTPtrC16(); // text |
|
1109 reader.ReadInt32(); // extension |
|
1110 } |
|
1111 } |
|
1112 |
|
1113 CleanupStack::PopAndDestroy(); // reader |
|
1114 } |