|
1 /* |
|
2 * Copyright (c) 2005-2010 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: SIM registration status publisher |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "aisimregpublisher.h" |
|
20 #include <aicontentobserver.h> |
|
21 #include "ainetworkinfolistener.h" |
|
22 #include <activeidle2domainpskeys.h> |
|
23 #include <e32property.h> |
|
24 #include <featmgr.h> |
|
25 |
|
26 #include <startupdomainpskeys.h> |
|
27 |
|
28 // ======== LOCAL FUNCTIONS ======= |
|
29 |
|
30 TBool AllowedToShowSimRegFailed() |
|
31 { |
|
32 TInt simCardStatus = ESimStatusUninitialized; |
|
33 TInt err = RProperty::Get( KPSUidStartup, KPSSimStatus, simCardStatus ); |
|
34 |
|
35 // Show note only when the SIM is usable |
|
36 if( err == KErrNone && simCardStatus == ESimUsable ) |
|
37 { |
|
38 return ETrue; |
|
39 } |
|
40 return EFalse; |
|
41 } |
|
42 |
|
43 |
|
44 // ======== MEMBER FUNCTIONS ======== |
|
45 |
|
46 CAiSimRegPublisher::CAiSimRegPublisher() |
|
47 { |
|
48 } |
|
49 |
|
50 |
|
51 void CAiSimRegPublisher::ConstructL() |
|
52 { |
|
53 FeatureManager::InitializeLibL(); |
|
54 iListener = CAiNetworkInfoListener::InstanceL(); |
|
55 } |
|
56 |
|
57 |
|
58 CAiSimRegPublisher* CAiSimRegPublisher::NewL() |
|
59 { |
|
60 CAiSimRegPublisher* self = new( ELeave ) CAiSimRegPublisher; |
|
61 CleanupStack::PushL( self ); |
|
62 self->ConstructL(); |
|
63 CleanupStack::Pop( self ); |
|
64 return self; |
|
65 } |
|
66 |
|
67 |
|
68 CAiSimRegPublisher::~CAiSimRegPublisher() |
|
69 { |
|
70 FeatureManager::UnInitializeLib(); |
|
71 if( iListener ) |
|
72 { |
|
73 iListener->RemoveObserver( *this ); |
|
74 iListener->Release(); |
|
75 } |
|
76 } |
|
77 |
|
78 |
|
79 void CAiSimRegPublisher::ResumeL() |
|
80 { |
|
81 iListener->AddObserverL( *this ); |
|
82 } |
|
83 |
|
84 |
|
85 void CAiSimRegPublisher::Subscribe( MAiContentObserver& aObserver, |
|
86 CHsContentPublisher& aExtension, |
|
87 MAiPublishPrioritizer& /*aPrioritizer*/, |
|
88 MAiPublisherBroadcaster& /*aBroadcaster*/ ) |
|
89 { |
|
90 iContentObserver = &aObserver; |
|
91 iExtension = &aExtension; |
|
92 } |
|
93 |
|
94 |
|
95 void CAiSimRegPublisher::RefreshL( TBool /*aClean*/ ) |
|
96 { |
|
97 TInt status = EPSSimRegFailedMessageNotReceived; |
|
98 RProperty::Get( |
|
99 KPSUidAiInformation, |
|
100 KActiveIdleSimRegFailedReceived, |
|
101 status ); |
|
102 //this cannot be refreshed |
|
103 switch( iListener->NetworkInfo().iRegistrationStatus ) |
|
104 { |
|
105 case ENWRegistrationUnknown: |
|
106 case ENWNotRegisteredNoService: |
|
107 case ENWNotRegisteredEmergencyOnly: |
|
108 case ENWRegistrationDenied: // fallthrough |
|
109 { |
|
110 if( status == EPSSimRegFailedMessageReceived && |
|
111 ::AllowedToShowSimRegFailed() ) |
|
112 { |
|
113 iContentObserver->Publish( *iExtension, |
|
114 EAiDeviceStatusContentSIMRegStatus, |
|
115 EAiDeviceStatusResourceSIMRegFail, |
|
116 0 ); |
|
117 } |
|
118 break; |
|
119 } |
|
120 case ENWRegisteredOnHomeNetwork: |
|
121 case ENWRegisteredRoaming: |
|
122 case ENWRegisteredBusy: // fallthrough |
|
123 { |
|
124 if( status == EPSSimRegFailedMessageReceived ) |
|
125 { |
|
126 iContentObserver->Clean( *iExtension, |
|
127 EAiDeviceStatusContentSIMRegStatus, |
|
128 0 ); |
|
129 } |
|
130 break; |
|
131 } |
|
132 default: |
|
133 { |
|
134 // no op |
|
135 break; |
|
136 } |
|
137 } |
|
138 } |
|
139 |
|
140 |
|
141 void CAiSimRegPublisher::HandleNetworkInfoChange( |
|
142 const MNWMessageObserver::TNWMessages& aMessage, |
|
143 const TNWInfo& aInfo, |
|
144 const TBool /*aShowOpInd*/ ) |
|
145 { |
|
146 if ( aMessage == |
|
147 MNWMessageObserver::ENWMessageNetworkConnectionFailure && |
|
148 ::AllowedToShowSimRegFailed()) |
|
149 { |
|
150 |
|
151 // SIM registration failed. Publish SIM registration status. |
|
152 iContentObserver->Publish( *iExtension, |
|
153 EAiDeviceStatusContentSIMRegStatus, |
|
154 EAiDeviceStatusResourceSIMRegFail, |
|
155 0 ); |
|
156 RProperty::Set( |
|
157 KPSUidAiInformation, |
|
158 KActiveIdleSimRegFailedReceived, |
|
159 EPSSimRegFailedMessageReceived ); |
|
160 } |
|
161 |
|
162 else if ( aMessage == |
|
163 MNWMessageObserver::ENWMessageNetworkRegistrationStatusChange ) |
|
164 { |
|
165 switch ( aInfo.iRegistrationStatus ) |
|
166 { |
|
167 case ENWRegisteredOnHomeNetwork: |
|
168 case ENWRegisteredRoaming: |
|
169 case ENWRegisteredBusy: |
|
170 { |
|
171 //Call clean if registration is fine. |
|
172 iContentObserver->Clean( *iExtension, |
|
173 EAiDeviceStatusContentSIMRegStatus, |
|
174 0 ); |
|
175 break; |
|
176 } |
|
177 default: |
|
178 break; |
|
179 } |
|
180 } |
|
181 else if ( FeatureManager::FeatureSupported( KFeatureIdFfManualSelectionPopulatedPlmnList ) |
|
182 && aMessage == |
|
183 static_cast<MNWMessageObserver::TNWMessages>( KErrGsmMMNetworkFailure ) ) |
|
184 { |
|
185 iContentObserver->Publish( *iExtension, |
|
186 EAiDeviceStatusContentNetRegStatus, |
|
187 EAiDeviceStatusResourceNetRegFail, |
|
188 0 ); |
|
189 } |
|
190 } |
|
191 |
|
192 |
|
193 TBool CAiSimRegPublisher::RefreshL( TInt aContentId, TBool aClean ) |
|
194 { |
|
195 if( aContentId == EAiDeviceStatusContentSIMRegStatus ) |
|
196 { |
|
197 RefreshL( aClean ); |
|
198 return ETrue; |
|
199 } |
|
200 |
|
201 return EFalse; |
|
202 } |