|
1 /* |
|
2 * Copyright (c) 2006-2006 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: Updates the signal level control in status pane. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "aknsignaldataobserver.h" |
|
21 #include "aknstatuspanedata.h" |
|
22 #include "AknSignal.h" |
|
23 #include "AknSignalStrength.h" |
|
24 |
|
25 #include "aknstatuspanedatasubscriber.h" |
|
26 #include <eikspane.h> |
|
27 #include <avkon.hrh> |
|
28 #include <eikapp.h> |
|
29 #include <eikappui.h> |
|
30 |
|
31 |
|
32 // ============================ MEMBER FUNCTIONS =============================== |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CAknSignalDataObserver::CAknSignalDataObserver |
|
36 // C++ default constructor can NOT contain any code, that |
|
37 // might leave. |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 CAknSignalDataObserver::CAknSignalDataObserver(CAknSignalPane* aSignalPane) |
|
41 { |
|
42 iSignalPane = aSignalPane; |
|
43 iSignalPane->MopGetObject(iDataSubscriber); |
|
44 if (iDataSubscriber) |
|
45 { |
|
46 iDataSubscriber->AddObserver(this); |
|
47 } |
|
48 } |
|
49 |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // Destructor |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 CAknSignalDataObserver::~CAknSignalDataObserver() |
|
56 { |
|
57 if (iDataSubscriber) |
|
58 { |
|
59 iDataSubscriber->RemoveObserver(this); |
|
60 } |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CAknSignalDataObserver::HandleUpdateL |
|
65 // Updates UI control. |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 void CAknSignalDataObserver::HandleUpdateL(const TAknStatusPaneStateData& aData) |
|
69 { |
|
70 if (!iDataSubscriber) |
|
71 return; |
|
72 |
|
73 TAknSignalState state = aData.iSignalState; |
|
74 |
|
75 // If this pane is not in current layout, no update. Update happens |
|
76 // when status pane layout is changed. |
|
77 CEikStatusPaneBase* statusPane = CEikStatusPaneBase::Current(); |
|
78 if (!statusPane || |
|
79 !statusPane->PaneCapabilities(TUid::Uid(EEikStatusPaneUidSignal)).IsInCurrentLayout()) |
|
80 { |
|
81 return; |
|
82 } |
|
83 |
|
84 // Animation is not shown in the background unless update level has been |
|
85 // set above ERefreshLevelMedium. |
|
86 TBool updateAnimation = |
|
87 (!iDataSubscriber->IsBackground() || |
|
88 iDataSubscriber->RefreshLevel() > CAknStatusPaneDataSubscriber::ERefreshLevelMedium); |
|
89 |
|
90 // Update only if changed to avoid unncessary redraws etc. |
|
91 TBool strengthChanged = state.iSignalStrength != iSignalPane->SignalLevel(); |
|
92 TBool iconChanged = state.iIconState != iSignalPane->SignalState(); |
|
93 |
|
94 // Set signal strenght (this handles also Offline status) |
|
95 if (strengthChanged) |
|
96 iSignalPane->SetSignalLevel(state.iSignalStrength); |
|
97 |
|
98 // Set signal icon |
|
99 if (iconChanged) |
|
100 { |
|
101 if (state.iIconState >= EAknSignalGprsIndicatorOff && |
|
102 state.iIconState < EAknSignalCommonPacketDataIndicatorOff) |
|
103 { |
|
104 // GPRS |
|
105 iSignalPane->ShowGprsIcon(state.iIconState); |
|
106 } |
|
107 else if (state.iIconState >= EAknSignalCommonPacketDataIndicatorOff && |
|
108 state.iIconState < EAknSignalWcdmaIndicatorOff) |
|
109 { |
|
110 // Common packet data |
|
111 iSignalPane->ShowCommonPacketDataIcon(state.iIconState); |
|
112 } |
|
113 else if (state.iIconState >= EAknSignalWcdmaIndicatorOff && |
|
114 state.iIconState < EAknSignalCdmaIndicatorOff) |
|
115 { |
|
116 // WCDMA |
|
117 iSignalPane->ShowWcdmaIcon(state.iIconState); |
|
118 } |
|
119 else if (state.iIconState >= EAknSignalCdmaIndicatorOff && |
|
120 state.iIconState < EAknSignalEdgeIndicatorOff) |
|
121 { |
|
122 // CDMA |
|
123 iSignalPane->ShowCdmaIcon(state.iIconState); |
|
124 } |
|
125 else if (state.iIconState >= EAknSignalEdgeIndicatorOff && |
|
126 state.iIconState <= EAknSignalEdgeIndicatorMultipdp) |
|
127 { |
|
128 // EDGE |
|
129 iSignalPane->ShowEdgeIcon(state.iIconState); |
|
130 } |
|
131 else if (state.iIconState >= EAknSignalHsdpaIndicatorOff && |
|
132 state.iIconState <= EAknSignalHsdpaIndicatorMultipdp) |
|
133 { |
|
134 // HSPDA |
|
135 iSignalPane->ShowHsdpaIcon(state.iIconState); |
|
136 } |
|
137 } |
|
138 |
|
139 if (!updateAnimation) |
|
140 { |
|
141 iSignalPane->DisableAnimation(); |
|
142 } |
|
143 |
|
144 if (iconChanged || strengthChanged) |
|
145 iSignalPane->DrawDeferred(); |
|
146 } |
|
147 |
|
148 |
|
149 // End of File |