author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 21:55:16 +0300 | |
branch | RCL_3 |
changeset 118 | 8baec10861af |
parent 114 | a5a39a295112 |
permissions | -rw-r--r-- |
114 | 1 |
/* |
2 |
* Copyright (c) 2005-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: Operator/Service provider name publisher. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
#include <StringLoader.h> |
|
20 |
#include <centralrepository.h> |
|
21 |
#include <avkondomainpskeys.h> |
|
22 |
#include <e32property.h> |
|
23 |
#include <aidevicestatuscontentmodel.h> |
|
24 |
#include <ProEngFactory.h> |
|
25 |
#include <MProfileEngine.h> |
|
26 |
#include <MProfile.h> |
|
27 |
#include <MProfileName.h> |
|
28 |
#include <MProEngNotifyHandler.h> |
|
29 |
||
30 |
#include <aidevstaplgres.rsg> |
|
31 |
#include "aioperatornamepublisher.h" |
|
32 |
#include "ainetworkinfolistener.h" |
|
33 |
#include "aiprioritizer.h" |
|
34 |
#include "ainwidpriorities.h" |
|
35 |
#include "activeidle2domaincrkeys.h" |
|
118
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
36 |
#include "debug.h" |
114 | 37 |
|
38 |
//Delay used to animate |
|
39 |
const TInt KCleanOperationDelay = 2 * 1000000; |
|
40 |
||
41 |
||
42 |
const TInt KBitShiftByFour = 4; |
|
43 |
const TInt KIsDigitLowLimit = 0; |
|
44 |
const TInt KIsDigitHighLimit = 10; |
|
45 |
const TInt KOfflineProfileId = 5; |
|
46 |
||
47 |
LOCAL_C void AppendDigit( TDes& aCode, TInt aValue ) |
|
48 |
{ |
|
49 |
// add a digit if valid value. |
|
50 |
if ( aValue >= KIsDigitLowLimit && aValue < KIsDigitHighLimit ) |
|
51 |
{ |
|
52 |
aCode.AppendNumUC( static_cast<TUint8>( aValue ) ); |
|
53 |
} |
|
54 |
} |
|
55 |
||
56 |
||
57 |
//Convert string to integer. |
|
58 |
LOCAL_C TInt StrToInt( const TDesC& aDesc ) |
|
59 |
{ |
|
60 |
TLex lex( aDesc ); |
|
61 |
||
62 |
TInt ret; |
|
63 |
TInt err = lex.Val( ret ); |
|
64 |
||
65 |
if( err != KErrNone ) |
|
66 |
{ |
|
67 |
ret = KErrNotFound; |
|
68 |
} |
|
69 |
return ret; |
|
70 |
} |
|
71 |
||
72 |
||
73 |
// ======== MEMBER FUNCTIONS ======== |
|
74 |
||
75 |
CAiOperatorNamePublisher::CAiOperatorNamePublisher() |
|
76 |
: iPriority( EAiInvalidPriority ) |
|
77 |
{ |
|
78 |
} |
|
79 |
||
80 |
||
81 |
void CAiOperatorNamePublisher::ConstructL() |
|
82 |
{ |
|
83 |
iListener = CAiNetworkInfoListener::InstanceL(); |
|
84 |
iPeriodic = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
85 |
iProfileEngine = CreateProfileEngineL(); |
|
86 |
iProfileNotifier = ProEngFactory::NewNotifyHandlerL(); |
|
87 |
iProfileNotifier->RequestProfileActivationNotificationsL( *this ); |
|
88 |
} |
|
89 |
||
90 |
||
91 |
CAiOperatorNamePublisher* CAiOperatorNamePublisher::NewL() |
|
92 |
{ |
|
93 |
CAiOperatorNamePublisher* self = new( ELeave ) CAiOperatorNamePublisher; |
|
94 |
CleanupStack::PushL( self ); |
|
95 |
self->ConstructL(); |
|
96 |
CleanupStack::Pop( self ); |
|
97 |
return self; |
|
98 |
} |
|
99 |
||
100 |
||
101 |
CAiOperatorNamePublisher::~CAiOperatorNamePublisher() |
|
102 |
{ |
|
103 |
if( iListener ) |
|
104 |
{ |
|
105 |
iListener->RemoveObserver( *this ); |
|
106 |
iListener->Release(); |
|
107 |
} |
|
108 |
if( iPeriodic ) |
|
109 |
{ |
|
110 |
iPeriodic->Cancel(); |
|
111 |
delete iPeriodic; |
|
112 |
} |
|
113 |
if ( iProfileNotifier ) |
|
114 |
{ |
|
115 |
iProfileNotifier->CancelAll(); |
|
116 |
delete iProfileNotifier; |
|
117 |
} |
|
118 |
if( iProfileEngine ) |
|
119 |
{ |
|
120 |
iProfileEngine->Release(); |
|
121 |
} |
|
122 |
} |
|
123 |
||
124 |
||
125 |
void CAiOperatorNamePublisher::ResumeL() |
|
126 |
{ |
|
127 |
iListener->AddObserverL( *this ); |
|
128 |
} |
|
129 |
||
130 |
||
131 |
void CAiOperatorNamePublisher::HandleNetworkInfoChange( |
|
132 |
const MNWMessageObserver::TNWMessages& /*aMessage*/, |
|
133 |
const TNWInfo& /*aInfo*/, |
|
134 |
const TBool aShowOpInd ) |
|
135 |
{ |
|
118
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
136 |
__PRINTS("XAI: CAiOperatorNamePublisher::HandleNetworkInfoChange"); |
114 | 137 |
if ( iSuspended ) |
138 |
{ |
|
118
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
139 |
__PRINTS("XAI: suspended"); |
114 | 140 |
return; |
141 |
} |
|
142 |
||
143 |
if( aShowOpInd ) |
|
144 |
{ |
|
145 |
TRAP_IGNORE ( RefreshL( ETrue )); |
|
146 |
} |
|
147 |
else |
|
148 |
{ |
|
149 |
if ( iProfileEngine->ActiveProfileId() != KOfflineProfileId ) |
|
150 |
{ |
|
151 |
TRAP_IGNORE ( |
|
152 |
iPrioritizer->TryToCleanL( *iBroadcaster, |
|
153 |
EAiDeviceStatusContentNetworkIdentity, |
|
154 |
iPriority )); |
|
155 |
} |
|
156 |
} |
|
157 |
} |
|
158 |
||
159 |
||
160 |
void CAiOperatorNamePublisher::Subscribe( MAiContentObserver& /*aObserver*/, |
|
161 |
CHsContentPublisher& aExtension, |
|
162 |
MAiPublishPrioritizer& aPrioritizer, |
|
163 |
MAiPublisherBroadcaster& aBroadcaster ) |
|
164 |
{ |
|
165 |
iExtension = &aExtension; |
|
166 |
iPrioritizer = &aPrioritizer; |
|
167 |
iBroadcaster = &aBroadcaster; |
|
168 |
} |
|
169 |
||
170 |
void CAiOperatorNamePublisher::RefreshIfActiveL( TBool aClean ) |
|
171 |
{ |
|
172 |
if ( !iSuspended ) |
|
173 |
{ |
|
174 |
RefreshL( aClean ); |
|
175 |
} |
|
176 |
} |
|
177 |
||
178 |
void CAiOperatorNamePublisher::RefreshL( TBool aClean ) |
|
179 |
{ |
|
118
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
180 |
__PRINTS("XAI: NamePublisher > RefreshL"); |
114 | 181 |
iSuccess = EFalse; |
182 |
||
183 |
if ( iSuspended ) |
|
184 |
{ |
|
118
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
185 |
__PRINTS("XAI: NamePublisher > RefreshL - iSuspended"); |
114 | 186 |
return; |
187 |
} |
|
188 |
||
189 |
if ( iProfileEngine->ActiveProfileId() == KOfflineProfileId ) |
|
190 |
{ |
|
191 |
MProfile* profile = iProfileEngine->ActiveProfileLC(); |
|
192 |
const MProfileName& name = profile->ProfileName(); |
|
118
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
193 |
iPriority = EAiOfflineProfile; |
114 | 194 |
iPrioritizer->TryToPublishL( *iBroadcaster, |
195 |
EAiDeviceStatusContentNetworkIdentity, |
|
196 |
name.Name(), |
|
197 |
iPriority ); |
|
198 |
iSuccess = ETrue; |
|
199 |
CleanupStack::PopAndDestroy();//profile |
|
200 |
return; |
|
201 |
} |
|
118
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
202 |
else if ( iPriority == EAiOfflineProfile ) |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
203 |
{ |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
204 |
iPrioritizer->TryToCleanL( *iBroadcaster, |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
205 |
EAiDeviceStatusContentNetworkIdentity, |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
206 |
iPriority ); |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
207 |
iPriority = EAiInvalidPriority; |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
208 |
} |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
209 |
else if( aClean ) |
114 | 210 |
{ |
211 |
iPrioritizer->TryToCleanL( *iBroadcaster, |
|
212 |
EAiDeviceStatusContentNetworkIdentity, |
|
213 |
iPriority ); |
|
214 |
} |
|
118
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
215 |
|
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
216 |
__PRINT(__DBG_FORMAT("XAI: NamePublisher > RefreshL - iPriority = %d"), iPriority ); |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
217 |
|
114 | 218 |
const TNWInfo& nwInfo = iListener->NetworkInfo(); |
219 |
||
220 |
#if defined(WINSCW) || defined(__WINS__) |
|
221 |
// Show operator name in emulator |
|
222 |
#else |
|
223 |
if ( nwInfo.iRegistrationStatus == ENWNotRegisteredNoService || |
|
224 |
nwInfo.iRegistrationStatus == ENWRegistrationUnknown || |
|
225 |
!iListener->IsOperatorIndicatorAllowed() ) |
|
226 |
{ |
|
227 |
return; |
|
228 |
} |
|
229 |
#endif |
|
230 |
||
231 |
TBool showSimultaneously = EFalse; |
|
232 |
||
233 |
TUid uid = { KCRUidActiveIdleLV }; |
|
234 |
CRepository* cenRep = CRepository::NewLC( uid ); |
|
235 |
TInt err = cenRep->Get( KAISPNAndEONS, showSimultaneously ); |
|
236 |
if( err ) |
|
237 |
{ |
|
238 |
showSimultaneously = EFalse; |
|
239 |
} |
|
240 |
CleanupStack::PopAndDestroy( cenRep ); |
|
241 |
||
242 |
const TBool isKeyLockEnabled = IsKeyLockEnabled(); |
|
243 |
||
244 |
//Check if PLMN must be shown. |
|
245 |
||
246 |
const TBool showPLMN = nwInfo.iServiceProviderNameDisplayReq & ENWDisplayPLMNRequired; |
|
118
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
247 |
__PRINT(__DBG_FORMAT("XAI: NamePublisher > RefreshL - showPLMN = %d"), showPLMN ); |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
248 |
|
114 | 249 |
TBool isInSPDI = EFalse; |
250 |
TBool showSPN = EFalse; |
|
251 |
||
252 |
//Check if we are in SPDI and SPN (Service Provider Name) must be shown. |
|
253 |
CheckServiceProviderDisplayListStatus( StrToInt( nwInfo.iCountryCode ), |
|
254 |
StrToInt( nwInfo.iNetworkId ), |
|
255 |
showSPN, |
|
256 |
isInSPDI ); |
|
257 |
||
258 |
//SPN must be shown if it is defined in PLMNField or if it is set in service provider name |
|
259 |
//display requirements. |
|
260 |
showSPN = |
|
261 |
showSPN || |
|
262 |
( nwInfo.iServiceProviderNameDisplayReq & ENWDisplaySPNRequired ); |
|
118
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
263 |
|
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
264 |
__PRINT(__DBG_FORMAT("XAI: NamePublisher > RefreshL - showSPN = %d"), showSPN ); |
114 | 265 |
|
266 |
#if defined(WINSCW) || defined(__WINS__) |
|
267 |
_LIT( KOperator, "Operator" ); |
|
268 |
const TPtrC serviceProviderName( KOperator() ); |
|
269 |
#else |
|
270 |
const TPtrC serviceProviderName = nwInfo.iSPName; |
|
271 |
#endif |
|
272 |
||
273 |
if ( ( !IsRoaming() || isInSPDI ) && serviceProviderName.Length() ) |
|
274 |
{ |
|
275 |
if ( showPLMN ) |
|
276 |
{ |
|
277 |
if ( showSimultaneously ) |
|
278 |
{ |
|
279 |
//spn & plmn (SPN.And.EONS) |
|
280 |
HBufC* operatorName = ConstructOperatorNameStringL( serviceProviderName ); |
|
281 |
CleanupStack::PushL( operatorName ); |
|
282 |
||
283 |
iPriority = EAiServiceProviderName; |
|
284 |
iPrioritizer->TryToPublishL( *iBroadcaster, |
|
285 |
EAiDeviceStatusContentNetworkIdentity, |
|
286 |
operatorName->Des(), |
|
287 |
iPriority ); |
|
288 |
CleanupStack::PopAndDestroy(operatorName); |
|
289 |
} |
|
290 |
else if( isKeyLockEnabled ) |
|
291 |
{ |
|
292 |
//only plmn |
|
293 |
ShowNetworkIdentityNameL( ETrue ); |
|
294 |
} |
|
295 |
else |
|
296 |
{ |
|
118
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
297 |
__PRINTS("XAI: NamePublisher > RefreshL (showPLMN)- try publish and start delayed operation "); |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
298 |
//spn & plmn (SPN.And.EONS.No) |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
299 |
if ( !OperatorNamePriority( iPriority ) ) |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
300 |
{ |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
301 |
iPriority = EAiServiceProviderName; |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
302 |
} |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
303 |
|
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
304 |
__PRINT(__DBG_FORMAT("XAI: NamePublisher > RefreshL - try publish with priority %d"), iPriority ); |
114 | 305 |
iPrioritizer->TryToPublishL( *iBroadcaster, |
306 |
EAiDeviceStatusContentNetworkIdentity, |
|
307 |
serviceProviderName, |
|
308 |
iPriority ); |
|
309 |
StartDelayedPLMNOperation();//to publish PLMN name |
|
310 |
} |
|
311 |
} |
|
312 |
else |
|
313 |
{ |
|
314 |
//only spn |
|
315 |
iPriority = EAiServiceProviderName; |
|
316 |
iPrioritizer->TryToPublishL( *iBroadcaster, |
|
317 |
EAiDeviceStatusContentNetworkIdentity, |
|
318 |
serviceProviderName, |
|
319 |
iPriority ); |
|
320 |
iSuccess = ETrue; |
|
321 |
} |
|
322 |
} |
|
323 |
else |
|
324 |
{ |
|
325 |
if ( showSPN && serviceProviderName.Length() ) |
|
326 |
{ |
|
327 |
if ( showSimultaneously ) |
|
328 |
{ |
|
329 |
//spn & plmn (SPN.And.EONS) |
|
330 |
HBufC* operatorName = ConstructOperatorNameStringL( serviceProviderName ); |
|
331 |
CleanupStack::PushL( operatorName ); |
|
332 |
||
333 |
iPriority = EAiServiceProviderName; |
|
334 |
iPrioritizer->TryToPublishL( *iBroadcaster, |
|
335 |
EAiDeviceStatusContentNetworkIdentity, |
|
336 |
operatorName->Des(), |
|
337 |
iPriority ); |
|
338 |
CleanupStack::PopAndDestroy(operatorName); |
|
339 |
} |
|
340 |
else if( isKeyLockEnabled ) |
|
341 |
{ |
|
342 |
//only plmn |
|
343 |
ShowNetworkIdentityNameL( ETrue ); |
|
344 |
} |
|
345 |
else |
|
346 |
{ |
|
118
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
347 |
__PRINTS("XAI: NamePublisher > RefreshL (showSPN)- try publish and start delayed operation "); |
114 | 348 |
//spn & plmn (SPN.And.EONS.No) |
118
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
349 |
if ( !OperatorNamePriority( iPriority ) ) |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
350 |
{ |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
351 |
iPriority = EAiServiceProviderName; |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
352 |
} |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
353 |
|
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
354 |
__PRINT(__DBG_FORMAT("XAI: NamePublisher > RefreshL - try publish with priority %d"), iPriority ); |
114 | 355 |
iPrioritizer->TryToPublishL( *iBroadcaster, |
356 |
EAiDeviceStatusContentNetworkIdentity, |
|
357 |
serviceProviderName, |
|
358 |
iPriority ); |
|
359 |
StartDelayedPLMNOperation();//to publish PLMN name |
|
360 |
} |
|
361 |
} |
|
362 |
else |
|
363 |
{ |
|
364 |
//only plmn |
|
365 |
ShowNetworkIdentityNameL( ETrue ); |
|
366 |
} |
|
367 |
} |
|
368 |
} |
|
369 |
||
370 |
HBufC* CAiOperatorNamePublisher::ConstructOperatorNameStringL( const TDesC& aServiceProviderName ) |
|
371 |
{ |
|
372 |
ShowNetworkIdentityNameL( EFalse ); |
|
373 |
||
374 |
CCoeEnv* coeEnv = CCoeEnv::Static(); |
|
375 |
HBufC* opnSpnFormatString = StringLoader::LoadLC( R_AI_OPN_SPN_SEPARATOR_FORMAT, |
|
376 |
coeEnv ); |
|
377 |
HBufC* opnSpnStringTemp = HBufC::NewLC( iNetworkIdentityName.Length() |
|
378 |
+ opnSpnFormatString->Length() |
|
379 |
+ aServiceProviderName.Length() ); |
|
380 |
||
381 |
HBufC* opnSpnString = HBufC::NewLC( iNetworkIdentityName.Length() |
|
382 |
+ opnSpnFormatString->Length() |
|
383 |
+ aServiceProviderName.Length() ); |
|
384 |
||
385 |
TPtr opnSpnStringTempPtr = opnSpnStringTemp->Des(); |
|
386 |
StringLoader::Format( opnSpnStringTempPtr, |
|
387 |
*opnSpnFormatString, |
|
388 |
1, |
|
389 |
aServiceProviderName ); |
|
390 |
||
391 |
TPtr opnSpnStringPtr = opnSpnString->Des(); |
|
392 |
StringLoader::Format( opnSpnStringPtr, |
|
393 |
opnSpnStringTempPtr, |
|
394 |
0, |
|
395 |
iNetworkIdentityName ); |
|
396 |
||
397 |
CleanupStack::Pop( opnSpnString ); |
|
398 |
CleanupStack::PopAndDestroy( opnSpnStringTemp ); //opnSpnStringTemp, opnSpnFormatString |
|
399 |
CleanupStack::PopAndDestroy( opnSpnFormatString ); |
|
400 |
||
401 |
return opnSpnString; |
|
402 |
} |
|
403 |
||
404 |
||
405 |
||
406 |
void CAiOperatorNamePublisher::ShowNetworkIdentityNameL( TBool aTryToPublish ) |
|
407 |
{ |
|
118
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
408 |
__PRINTS("XAI: NamePublisher > ShowNetworkIdentityNameL"); |
114 | 409 |
const TNWInfo& nwInfo = iListener->NetworkInfo(); |
410 |
||
411 |
iNetworkIdentityName.Set( KNullDesC ); |
|
412 |
||
413 |
iPriority = EAiInvalidPriority; |
|
414 |
||
415 |
// *** Network operator name (CPHS-ONS) *** |
|
416 |
if( nwInfo.iNPName.Length() > 0 && |
|
417 |
nwInfo.iOperatorNameInfo.iType != RMmCustomAPI::EOperatorNameFlexiblePlmn && |
|
418 |
nwInfo.iRegistrationStatus == ENWRegisteredOnHomeNetwork ) |
|
419 |
{ |
|
118
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
420 |
__PRINTS("XAI: NamePublisher > ShowNetworkIdentityNameL - iNPName "); |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
421 |
|
114 | 422 |
//priority |
423 |
iPriority = EAiNetworkOperatorName; |
|
424 |
//name |
|
425 |
iNetworkIdentityName.Set( nwInfo.iNPName ); |
|
426 |
//publish network identity name |
|
427 |
if( aTryToPublish ) |
|
428 |
{ |
|
429 |
iPrioritizer->TryToPublishL( *iBroadcaster, |
|
430 |
EAiDeviceStatusContentNetworkIdentity, |
|
431 |
iNetworkIdentityName, |
|
432 |
iPriority ); |
|
433 |
} |
|
434 |
||
435 |
iSuccess = ETrue; |
|
436 |
return; |
|
437 |
} |
|
438 |
||
439 |
// *** Operator name *** |
|
440 |
if( nwInfo.iOperatorNameInfo.iName.Length() > 0 ) |
|
441 |
{ |
|
118
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
442 |
__PRINTS("XAI: NamePublisher > ShowNetworkIdentityNameL - iOperatorNameInfo.iName "); |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
443 |
|
114 | 444 |
//priority |
445 |
OperatorNamePriority( iPriority ); |
|
446 |
//name |
|
447 |
iNetworkIdentityName.Set( nwInfo.iOperatorNameInfo.iName ); |
|
448 |
//converted name |
|
449 |
HBufC* convertedOperatorName = NULL; |
|
450 |
||
451 |
if ( nwInfo.iOperatorNameInfo.iType == RMmCustomAPI::EOperatorNameFlexiblePlmn ) |
|
452 |
{ |
|
453 |
// Long & short name may be in the same buffer. |
|
454 |
const TInt separatorPos = iNetworkIdentityName.Locate( KFlexibleNameSeparator ); |
|
455 |
if ( separatorPos != KErrNotFound ) |
|
456 |
{ |
|
457 |
convertedOperatorName = nwInfo.iOperatorNameInfo.iName.Left( separatorPos ).AllocLC(); |
|
458 |
} |
|
459 |
} |
|
460 |
else if ( nwInfo.iOperatorNameInfo.iType == |
|
461 |
RMmCustomAPI::EOperatorNameMccMnc || |
|
462 |
nwInfo.iOperatorNameInfo.iType == |
|
463 |
RMmCustomAPI::EOperatorNameCountryMcn ) |
|
464 |
{ |
|
465 |
// Perform display language specific conversion. |
|
466 |
convertedOperatorName = nwInfo.iOperatorNameInfo.iName.AllocLC(); |
|
467 |
TPtr ptr = convertedOperatorName->Des(); |
|
468 |
AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr ); |
|
469 |
} |
|
470 |
else |
|
471 |
{ |
|
472 |
// No changes needed. |
|
473 |
} |
|
474 |
||
475 |
if ( convertedOperatorName ) |
|
476 |
{ |
|
477 |
iNetworkIdentityName.Set( *convertedOperatorName ); |
|
478 |
} |
|
479 |
||
480 |
if( iPriority != EAiInvalidPriority ) |
|
481 |
{ |
|
482 |
//Publish network identity name |
|
483 |
if( aTryToPublish ) |
|
484 |
{ |
|
485 |
iPrioritizer->TryToPublishL( *iBroadcaster, |
|
486 |
EAiDeviceStatusContentNetworkIdentity, |
|
487 |
iNetworkIdentityName, |
|
488 |
iPriority ); |
|
489 |
} |
|
490 |
||
491 |
iSuccess = ETrue; |
|
492 |
} |
|
493 |
||
494 |
if ( convertedOperatorName ) |
|
495 |
{ |
|
496 |
CleanupStack::PopAndDestroy( convertedOperatorName ); |
|
497 |
convertedOperatorName = NULL; |
|
498 |
} |
|
499 |
||
500 |
if( iPriority != EAiInvalidPriority ) |
|
501 |
{ |
|
502 |
return; |
|
503 |
} |
|
504 |
} |
|
505 |
||
506 |
// *** Network info name *** |
|
507 |
if( iPriority == EAiInvalidPriority ) |
|
508 |
{ |
|
509 |
//priority |
|
510 |
iPriority = EAiOperatorNetInfoName; |
|
511 |
||
512 |
if ( nwInfo.iLongName.Length() > 0 ) |
|
513 |
{ |
|
514 |
iNetworkIdentityName.Set( nwInfo.iLongName ); |
|
515 |
} |
|
516 |
else if ( nwInfo.iShortName.Length() > 0 ) |
|
517 |
{ |
|
518 |
iNetworkIdentityName.Set( nwInfo.iShortName ); |
|
519 |
} |
|
520 |
else if ( nwInfo.iDisplayTag.Length() > 0 ) |
|
521 |
{ |
|
522 |
iNetworkIdentityName.Set( nwInfo.iDisplayTag ); |
|
523 |
} |
|
524 |
else |
|
525 |
{ |
|
526 |
iPriority = EAiInvalidPriority; |
|
527 |
} |
|
528 |
||
529 |
//Publish network identity name |
|
530 |
if( aTryToPublish ) |
|
531 |
{ |
|
532 |
iPrioritizer->TryToPublishL( *iBroadcaster, |
|
533 |
EAiDeviceStatusContentNetworkIdentity, |
|
534 |
iNetworkIdentityName, |
|
535 |
iPriority ); |
|
536 |
} |
|
537 |
||
538 |
iSuccess = ETrue; |
|
539 |
return; |
|
540 |
} |
|
541 |
} |
|
542 |
||
543 |
||
544 |
void CAiOperatorNamePublisher::CheckServiceProviderDisplayListStatus( |
|
545 |
TInt aMCC, |
|
546 |
TInt aMNC, |
|
547 |
TBool& aShowSPN, |
|
548 |
TBool& aIsInSPDI ) const |
|
549 |
{ |
|
550 |
||
551 |
// Not in list by default |
|
552 |
aIsInSPDI = EFalse; |
|
553 |
aShowSPN = EFalse; |
|
554 |
||
555 |
if ( !CurrentNetworkOk() ) |
|
556 |
{ |
|
557 |
return; |
|
558 |
} |
|
559 |
||
560 |
||
561 |
const TNWInfo& nwInfo = iListener->NetworkInfo(); |
|
562 |
||
563 |
TInt bufferLength = nwInfo.iPLMNField.Length(); |
|
564 |
if ( !bufferLength ) |
|
565 |
{ |
|
566 |
return; |
|
567 |
} |
|
568 |
||
569 |
const TUint8* field = |
|
570 |
reinterpret_cast< const TUint8* >( nwInfo.iPLMNField.Ptr() ); |
|
571 |
||
572 |
TInt octetIndex = 0; |
|
573 |
||
574 |
// Update SPN showing. (in 3GPP a tag). |
|
575 |
aShowSPN = static_cast<TUint8>( field[ octetIndex ] ) ? EFalse : ETrue ; |
|
576 |
octetIndex++; |
|
577 |
||
578 |
// Number of PLMN pairs. (in 3GPP number of octets). |
|
579 |
const TUint8 length = static_cast<TUint8>( ( field[ octetIndex ] ) ); |
|
580 |
octetIndex++; |
|
581 |
||
582 |
// Empty list (always with SIM and sometimes with UICC) |
|
583 |
if ( !( length > 0 ) ) |
|
584 |
{ |
|
585 |
return; |
|
586 |
} |
|
587 |
||
588 |
// Compare MCC&MNC pairs |
|
589 |
TNWCountryCode mcc; |
|
590 |
TNWIdentity mnc; |
|
591 |
||
592 |
const TUint numberOfPairs = length; // each pair has 3 octets |
|
593 |
||
594 |
for( TUint pair = 0; pair < numberOfPairs; pair++ ) |
|
595 |
{ |
|
596 |
// 1st octet |
|
597 |
AppendDigit( mcc, field[ octetIndex ] & 0x0F ); |
|
598 |
AppendDigit( mcc, ( field[ octetIndex ] & 0xF0 ) >> KBitShiftByFour ); |
|
599 |
octetIndex++; |
|
600 |
||
601 |
// 2nd octet |
|
602 |
AppendDigit( mcc, field[ octetIndex ] & 0x0F ); |
|
603 |
TInt tmp = ( field[ octetIndex ] & 0xF0 ) >> KBitShiftByFour; |
|
604 |
octetIndex++; |
|
605 |
||
606 |
// 3rd octet |
|
607 |
AppendDigit( mnc, field[ octetIndex ] & 0x0F ); |
|
608 |
AppendDigit( mnc, ( field[ octetIndex ] & 0xF0 ) >> KBitShiftByFour ); |
|
609 |
octetIndex++; |
|
610 |
||
611 |
AppendDigit( mnc, tmp ); // mnc 3rd digit. |
|
612 |
||
613 |
TInt imcc = StrToInt( mcc ); |
|
614 |
TInt imnc = StrToInt( mnc ); |
|
615 |
||
616 |
if ( ( aMNC == imnc ) && ( aMCC == imcc ) ) |
|
617 |
{ |
|
618 |
// match. |
|
619 |
aIsInSPDI = ETrue; |
|
620 |
break; |
|
621 |
} |
|
622 |
||
623 |
||
624 |
// Reset |
|
625 |
mnc.Zero(); |
|
626 |
mcc.Zero(); |
|
627 |
} |
|
628 |
} |
|
629 |
||
630 |
||
631 |
TBool CAiOperatorNamePublisher::CurrentNetworkOk() const |
|
632 |
{ |
|
633 |
TBool ok = iListener->MessageReceived( |
|
634 |
MNWMessageObserver::ENWMessageNetworkInfoChange ) || |
|
635 |
iListener->MessageReceived( |
|
636 |
MNWMessageObserver::ENWMessageNetworkRegistrationStatusChange ); |
|
637 |
||
638 |
ok = ok & ( iListener->NetworkInfo().iStatus == ENWStatusCurrent ); |
|
639 |
||
640 |
return ok; |
|
641 |
} |
|
642 |
||
643 |
||
644 |
TBool CAiOperatorNamePublisher::IsRoaming() const |
|
645 |
{ |
|
646 |
const TNWInfo& nwInfo = iListener->NetworkInfo(); |
|
647 |
||
648 |
return iListener->MessageReceived( |
|
649 |
MNWMessageObserver::ENWMessageNetworkRegistrationStatusChange ) && |
|
650 |
( nwInfo.iRegistrationStatus == ENWRegisteredRoaming ); |
|
651 |
} |
|
652 |
||
653 |
||
654 |
||
655 |
void CAiOperatorNamePublisher::StartDelayedPLMNOperation() |
|
656 |
{ |
|
657 |
if( !iPeriodic->IsActive() ) |
|
658 |
{ |
|
659 |
iPeriodic->Start( KCleanOperationDelay, |
|
660 |
KCleanOperationDelay, |
|
661 |
TCallBack( CleanAndShowPLMNOperationCallback, this ) ); |
|
662 |
} |
|
663 |
} |
|
664 |
||
665 |
||
666 |
TInt CAiOperatorNamePublisher::CleanAndShowPLMNOperationCallback( TAny* aPtr ) |
|
667 |
{ |
|
118
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
668 |
__PRINTS("XAI: NamePublisher > CleanAndShowPLMNOperationCallback "); |
114 | 669 |
CAiOperatorNamePublisher* self = |
670 |
static_cast<CAiOperatorNamePublisher*>( aPtr ); |
|
671 |
||
672 |
if( self ) |
|
673 |
{ |
|
674 |
self->iPeriodic->Cancel(); |
|
675 |
// check if got suspended while timer was active |
|
676 |
if ( !self->iSuspended ) |
|
677 |
{ |
|
678 |
TRAP_IGNORE |
|
679 |
( |
|
680 |
//clean |
|
681 |
self->DoCleanOperationL(); |
|
682 |
//show PLMN name |
|
683 |
self->ShowNetworkIdentityNameL( ETrue ); |
|
684 |
); |
|
685 |
} |
|
686 |
} |
|
687 |
||
688 |
return KErrNone; |
|
689 |
} |
|
690 |
||
691 |
||
692 |
void CAiOperatorNamePublisher::DoCleanOperationL() |
|
693 |
{ |
|
118
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
694 |
__PRINTS("XAI: NamePublisher > DoCleanOperationL"); |
114 | 695 |
iPrioritizer->TryToCleanL( *iBroadcaster, |
696 |
EAiDeviceStatusContentNetworkIdentity, |
|
118
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
697 |
iPriority ); |
114 | 698 |
} |
699 |
||
700 |
||
701 |
TBool CAiOperatorNamePublisher::RefreshL( TInt aContentId, TBool aClean ) |
|
702 |
{ |
|
118
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
703 |
__PRINTS("XAI: NamePublisher > RefreshL with content"); |
114 | 704 |
if ( aContentId == EAiDeviceStatusContentNetworkIdentity ) |
705 |
{ |
|
706 |
iSuspended = EFalse; |
|
707 |
||
708 |
RefreshL( aClean ); |
|
709 |
||
710 |
if ( iSuccess ) |
|
711 |
{ |
|
712 |
return ETrue; |
|
713 |
} |
|
714 |
} |
|
715 |
||
716 |
return EFalse; |
|
717 |
} |
|
718 |
||
719 |
TBool CAiOperatorNamePublisher::SuspendL( TInt aContentId, TBool /*aClean*/ ) |
|
720 |
{ |
|
118
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
721 |
__PRINTS("XAI: NamePublisher > SuspendL with content"); |
114 | 722 |
if ( aContentId == EAiDeviceStatusContentNetworkIdentity ) |
723 |
{ |
|
724 |
iSuspended = ETrue; |
|
725 |
iPeriodic->Cancel(); |
|
726 |
return ETrue; |
|
727 |
} |
|
728 |
||
729 |
return EFalse; |
|
730 |
} |
|
731 |
||
732 |
TBool CAiOperatorNamePublisher::RefreshContentWithPriorityL( |
|
733 |
TInt aContentId, |
|
734 |
TInt aPriority ) |
|
735 |
{ |
|
118
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
736 |
__PRINTS("XAI: NamePublisher > RefreshContentWithPriorityL"); |
114 | 737 |
if( aContentId == EAiDeviceStatusContentNetworkIdentity && aPriority == EAiServiceProviderName ) |
738 |
{ |
|
118
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
739 |
__PRINTS("XAI: NamePublisher > identity and priority matched "); |
114 | 740 |
RefreshL( EFalse ); |
741 |
if( iSuccess ) |
|
742 |
{ |
|
743 |
return ETrue; |
|
744 |
} |
|
745 |
} |
|
746 |
return EFalse; |
|
747 |
} |
|
748 |
||
749 |
||
750 |
TBool CAiOperatorNamePublisher::OperatorNamePriority( TInt& aPriority ) |
|
751 |
{ |
|
752 |
TBool succeeded = ETrue; |
|
753 |
||
754 |
const TNWInfo& nwInfo = iListener->NetworkInfo(); |
|
755 |
||
756 |
switch ( nwInfo.iOperatorNameInfo.iType ) |
|
757 |
{ |
|
758 |
case RMmCustomAPI::EOperatorNameFlexiblePlmn: |
|
759 |
aPriority = EAiFlexiblePLMN; |
|
760 |
break; |
|
761 |
||
762 |
case RMmCustomAPI::EOperatorNameNitzFull: |
|
763 |
aPriority = EAiNITZ; |
|
764 |
break; |
|
765 |
||
766 |
case RMmCustomAPI::EOperatorNameNitzShort: |
|
767 |
aPriority = EAiNITZ; |
|
768 |
break; |
|
769 |
||
770 |
case RMmCustomAPI::EOperatorNameProgrammableUcs2: |
|
771 |
aPriority = EAiUnicodeOperatorName; |
|
772 |
break; |
|
773 |
||
774 |
case RMmCustomAPI::EOperatorNameProgrammableLatin: |
|
775 |
aPriority = EAiLatinOperatorName; |
|
776 |
break; |
|
777 |
||
778 |
case RMmCustomAPI::EOperatorNameHardcodedUcs2: |
|
779 |
aPriority = EAiUnicodeOperatorName; |
|
780 |
break; |
|
781 |
||
782 |
case RMmCustomAPI::EOperatorNameHardcodedLatin: |
|
783 |
aPriority = EAiLatinOperatorName; |
|
784 |
break; |
|
785 |
||
786 |
case RMmCustomAPI::EOperatorNameCountryMcn: |
|
787 |
aPriority = EAiCountryMNC; |
|
788 |
break; |
|
789 |
||
790 |
case RMmCustomAPI::EOperatorNameMccMnc: |
|
791 |
aPriority = EAiMCC_MCN; |
|
792 |
break; |
|
793 |
||
794 |
default: |
|
795 |
aPriority = EAiInvalidPriority; |
|
796 |
succeeded = EFalse; |
|
797 |
break; |
|
798 |
} |
|
799 |
return succeeded; |
|
800 |
} |
|
801 |
||
802 |
TBool CAiOperatorNamePublisher::IsKeyLockEnabled() |
|
803 |
{ |
|
804 |
TInt value; |
|
805 |
TInt err = RProperty::Get(KPSUidAvkonDomain, KAknKeyguardStatus, value); |
|
806 |
if ( err != KErrNone ) |
|
807 |
return EFalse; |
|
808 |
switch( value ) |
|
809 |
{ |
|
810 |
case EKeyguardLocked: |
|
811 |
case EKeyguardAutolockEmulation: |
|
812 |
return ETrue; |
|
813 |
case EKeyguardNotActive: |
|
814 |
default: |
|
815 |
return EFalse; |
|
816 |
} |
|
817 |
} |
|
818 |
||
819 |
void CAiOperatorNamePublisher::HandleProfileActivatedL( TInt /*aProfileId*/ ) |
|
820 |
{ |
|
821 |
RefreshL( EFalse ); |
|
822 |
} |
|
823 |