|
1 /* |
|
2 * Copyright (c) 2002-2005 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: Class for handling SUPL_INIT message. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <utf.h> |
|
21 #include "epos_comasuplinit.h" |
|
22 #include "epos_comasuplnotification.h" |
|
23 #include "epos_comasuplsessionid.h" |
|
24 #include "lbs/epos_eomasuplposerrors.h" |
|
25 #include "epos_tomasuplposmethod.h" |
|
26 |
|
27 #include "epos_comasuplinitstate.h" |
|
28 #include "epos_comasupltimeouttimer.h" |
|
29 #include "epos_omasuplconstants.h" |
|
30 #include "epos_momasuplprivacyobserver.h" |
|
31 #include "epos_comasupltrace.h" |
|
32 #include <featmgr.h> //APE CENTRIC |
|
33 |
|
34 _LIT(KTraceFileName,"SUPL_OMA_SESSION::EPos_COMASuplInitState.cpp"); |
|
35 |
|
36 const TInt KSUPLAPECentricArchSupport = 258; //APE CENTRIC KFeatureIdFfLocationMwApeCentricArchSupport = 258 |
|
37 |
|
38 // ============================ MEMBER FUNCTIONS =============================== |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // COMASuplInitState::COMASuplInitState |
|
42 // C++ constructor can NOT contain any code, that might leave. |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 COMASuplInitState::COMASuplInitState(TInt aMsgTimeout,const TDesC8& aHSLPAddress, |
|
46 MOMASuplPrivacyObserver &aPrivacyObserver,TInt aSupportedMode, CPosNetworkPrivacy* aNetworkPrivacy): |
|
47 iHSLPAddress(aHSLPAddress), |
|
48 iPrivacyObserver(aPrivacyObserver) |
|
49 { |
|
50 iMessageTimeOut = aMsgTimeout * KSecond; |
|
51 iNoPosition = EFalse; |
|
52 iCurrentState = ESUPL_INIT; |
|
53 iSupportedMode = aSupportedMode; |
|
54 iNetworkPrivacy = aNetworkPrivacy; |
|
55 iGSMRequestId = KErrNotFound; |
|
56 iIsNotificationOnly = EFalse; //APE Centric |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // COMASuplInitState::~COMASuplInitState |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 COMASuplInitState::~COMASuplInitState() |
|
64 { |
|
65 //delete iNetworkPrivacy; |
|
66 if(iTrace) |
|
67 iTrace->Trace(_L("COMASuplInitState::~COMASuplInitState..."), KTraceFileName, __LINE__); |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // COMASuplInitState::ConstructL |
|
72 // Symbian 2nd phase constructor can leave. |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 void COMASuplInitState::ConstructL() |
|
76 { |
|
77 COMASuplState::BaseConstructL(); |
|
78 // Create an instance of Network Privacy that later are |
|
79 // used to make privacy calls on. |
|
80 //iNetworkPrivacy = CPosNetworkPrivacy::NewL(); |
|
81 ReadRequestIDFeatureFlagL(); |
|
82 iTrace->Trace(_L("COMASuplInitState::ConstructL..."), KTraceFileName, __LINE__); |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // COMASuplInitState::NewL |
|
87 // Two-phased constructor. |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 COMASuplInitState* COMASuplInitState::NewL(TInt aMsgTimeout,const TDesC8& aHSLPAddress, |
|
91 MOMASuplPrivacyObserver &aPrivacyObserver, |
|
92 TInt aSupportedMode, CPosNetworkPrivacy* aNetworkPrivacy) |
|
93 { |
|
94 COMASuplInitState* self = new ( ELeave ) COMASuplInitState(aMsgTimeout,aHSLPAddress, |
|
95 aPrivacyObserver,aSupportedMode,aNetworkPrivacy); |
|
96 CleanupStack::PushL( self ); |
|
97 self->ConstructL(); |
|
98 CleanupStack::Pop(self); |
|
99 return self; |
|
100 } |
|
101 |
|
102 |
|
103 // ----------------------------------------------------------------------------- |
|
104 // COMASuplState::ProcessMessage |
|
105 // process message... |
|
106 // (other items were commented in a header). |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 TInt COMASuplInitState::ProcessMessageL(COMASuplAsnMessageBase* aDecodedMessage) |
|
110 { |
|
111 TInt error = KErrNone; |
|
112 iSuplInit = static_cast <COMASuplInit *>(aDecodedMessage); |
|
113 iNotification = NULL; |
|
114 |
|
115 error = CheckForModeSupport(); |
|
116 if(error == KErrOMANonProxyModeNotSupported) |
|
117 return error; |
|
118 |
|
119 // Check for the presence of SET Session ID |
|
120 error = CheckForSetSessionID(); |
|
121 |
|
122 if(KErrNone != error) |
|
123 { |
|
124 return error; |
|
125 } |
|
126 |
|
127 error = CheckForSLPSessionID(); |
|
128 if(KErrNone != error) |
|
129 { |
|
130 return error; |
|
131 } |
|
132 |
|
133 |
|
134 CheckForPositioningMethod(); |
|
135 |
|
136 error = iSuplInit->Notification(iNotification); |
|
137 if(!error) |
|
138 { |
|
139 error = HandlePrivacyL(); |
|
140 return error; |
|
141 } |
|
142 else |
|
143 { |
|
144 if(iNoPosition) |
|
145 { |
|
146 return KErrOMASuplNoPosition; |
|
147 } |
|
148 else |
|
149 { |
|
150 iCompletionCode = KErrNone; |
|
151 iPrivacyObserver.PrivacyCheckCompleteL(iCompletionCode); |
|
152 return KErrNone; |
|
153 } |
|
154 } |
|
155 |
|
156 } |
|
157 // ----------------------------------------------------------------------------- |
|
158 // COMASuplInitState::HandlePrivacy |
|
159 // Cancels the generation if SUPL INIT |
|
160 // (other items were commented in a header). |
|
161 // ----------------------------------------------------------------------------- |
|
162 // |
|
163 TInt COMASuplInitState::HandlePrivacyL() |
|
164 { |
|
165 iTrace->Trace(_L("COMASuplInitState::HandlePrivacy..."), KTraceFileName, __LINE__); |
|
166 |
|
167 COMASuplNotification::TOMASuplNotificationType notifyType = iNotification->SuplNotification(); |
|
168 switch(notifyType) |
|
169 { |
|
170 case COMASuplNotification::ENoNotificationNoVerification: |
|
171 case COMASuplNotification::EPrivacyOverride: |
|
172 { |
|
173 iTrace->Trace(_L("COMASuplInitState::Privacy rule: No notification and no verification"), KTraceFileName, __LINE__); |
|
174 if(iNoPosition) |
|
175 { |
|
176 iCompletionCode = KErrOMASuplInformationOnly; |
|
177 } |
|
178 else |
|
179 { |
|
180 iCompletionCode = KErrNone; |
|
181 } |
|
182 iPrivacyObserver.PrivacyCheckCompleteL(iCompletionCode); |
|
183 return KErrNone; |
|
184 } |
|
185 case COMASuplNotification::ENotificationOnly: |
|
186 { |
|
187 iTrace->Trace(_L("COMASuplInitState::Privacy rule: Notification Only"), KTraceFileName, __LINE__); |
|
188 iIsNotificationOnly = ETrue; //APE Centric |
|
189 MakeGSMNotificationL(); |
|
190 |
|
191 if(iNoPosition) |
|
192 { |
|
193 iCompletionCode = KErrOMASuplInformationOnly; |
|
194 } |
|
195 else |
|
196 { |
|
197 iCompletionCode = KErrNone; |
|
198 } |
|
199 iPrivacyObserver.PrivacyCheckCompleteL(iCompletionCode); |
|
200 return KErrNone; |
|
201 } |
|
202 case COMASuplNotification::ENotificationAndVerficationAllowedNA: |
|
203 { |
|
204 iTrace->Trace(_L("COMASuplInitState::Privacy rule: Notification & Verification, Allowed on no answer"), KTraceFileName, __LINE__); |
|
205 return MakeGSMVerificationL(CPosNetworkPrivacy::EDecisionAccepted); |
|
206 } |
|
207 case COMASuplNotification::ENotificationAndVerficationDeniedNA: |
|
208 { |
|
209 iTrace->Trace(_L("COMASuplInitState::Privacy rule: Notification & Verification, Denied on no answer"), KTraceFileName, __LINE__); |
|
210 return MakeGSMVerificationL(CPosNetworkPrivacy::EDecisionRejected); |
|
211 } |
|
212 default: |
|
213 { |
|
214 return KErrArgument; |
|
215 } |
|
216 } |
|
217 } |
|
218 // --------------------------------------------------------- |
|
219 // COMASuplInitState::MakeGSMNotificationL |
|
220 // |
|
221 // (other items were commented in a header). |
|
222 // --------------------------------------------------------- |
|
223 // |
|
224 TInt COMASuplInitState::MakeGSMNotificationL() |
|
225 { |
|
226 // Constructing GSM Privacy Request Information object |
|
227 CPosSUPLPrivacyRequestInfo* suplReqInfo = |
|
228 CPosSUPLPrivacyRequestInfo::NewLC(); |
|
229 |
|
230 HBufC* requestor = NULL; |
|
231 TInt reqError = RequestorL(requestor); |
|
232 if(!reqError) |
|
233 { |
|
234 // Set name of Requestor |
|
235 if(requestor) |
|
236 suplReqInfo->SetRequestorL(*requestor,iIdType); |
|
237 |
|
238 delete requestor; |
|
239 } |
|
240 |
|
241 HBufC* client = NULL; |
|
242 TInt clientError = ClientL(client); |
|
243 if(!clientError) |
|
244 { |
|
245 // Set name of Client |
|
246 if(client) |
|
247 { |
|
248 suplReqInfo->SetLCSClientL(*client,iIdType); |
|
249 } |
|
250 |
|
251 |
|
252 delete client; |
|
253 } |
|
254 |
|
255 if(!reqError || !clientError) |
|
256 { |
|
257 // Notify Network Privacy of the request information |
|
258 // Synchronous call |
|
259 TInt RequestId; |
|
260 iNetworkPrivacy->NotifyLocationRequestL(*suplReqInfo,RequestId); |
|
261 |
|
262 if(iIsNotificationOnly) |
|
263 { |
|
264 iGSMRequestId = RequestId; |
|
265 TBuf<64> msg; |
|
266 msg.Copy(_L("1.0 Privacy Fw Generated Notification Request id:")); |
|
267 msg.AppendNum(iGSMRequestId); |
|
268 iTrace->Trace(msg, KTraceFileName, __LINE__); |
|
269 } |
|
270 CleanupStack::PopAndDestroy(suplReqInfo); |
|
271 return KErrNone; |
|
272 } |
|
273 else |
|
274 { |
|
275 CleanupStack::PopAndDestroy(suplReqInfo); |
|
276 return KErrArgument; |
|
277 } |
|
278 } |
|
279 |
|
280 // --------------------------------------------------------- |
|
281 // COMASuplInitState::MakeGSMVerificationL |
|
282 // |
|
283 // (other items were commented in a header). |
|
284 // --------------------------------------------------------- |
|
285 // |
|
286 TInt COMASuplInitState::MakeGSMVerificationL(CPosNetworkPrivacy::TRequestDecision aTimeOutStrategy) |
|
287 { |
|
288 // Constructing GSM Privacy Request Information object |
|
289 CPosSUPLPrivacyRequestInfo* suplReqInfo = |
|
290 CPosSUPLPrivacyRequestInfo::NewLC(); |
|
291 |
|
292 HBufC* requestor = NULL; |
|
293 TInt reqError = RequestorL(requestor); |
|
294 if(!reqError) |
|
295 { |
|
296 // Set name of Requestor |
|
297 if(requestor) |
|
298 suplReqInfo->SetRequestorL(*requestor,iIdType); |
|
299 delete requestor; |
|
300 } |
|
301 |
|
302 HBufC* client = NULL; |
|
303 TInt clientError = ClientL(client); |
|
304 if(!clientError) |
|
305 { |
|
306 // Set name of Client |
|
307 |
|
308 if(client) |
|
309 { |
|
310 suplReqInfo->SetLCSClientL(*client,iIdType); |
|
311 } |
|
312 |
|
313 delete client; |
|
314 } |
|
315 |
|
316 if(!reqError || !clientError) |
|
317 { |
|
318 // Verify the request information using Network Privacy |
|
319 // asynchronous call with callback function HandleVerifyComplete. |
|
320 // Argument CPosNetworkPrivacy::EDecisionRejected is to show to the user |
|
321 // what decision the GSM Network will make if the user won't answer before |
|
322 // a timeout comes in from GSM Network. In this case verification will |
|
323 // be rejected. |
|
324 iNetworkPrivacy->VerifyLocationRequestL(*suplReqInfo, |
|
325 iGSMRequestId, *this, aTimeOutStrategy); |
|
326 TBuf<64> msg; |
|
327 msg.Copy(_L("1.0 Privacy Fw Generated Verification Request id:")); |
|
328 msg.AppendNum(iGSMRequestId); |
|
329 iTrace->Trace(msg, KTraceFileName, __LINE__); |
|
330 |
|
331 StartTimer(); |
|
332 CleanupStack::PopAndDestroy(suplReqInfo); |
|
333 return KErrNone; |
|
334 } |
|
335 else |
|
336 { |
|
337 CleanupStack::PopAndDestroy(suplReqInfo); |
|
338 return KErrArgument; |
|
339 } |
|
340 } |
|
341 |
|
342 // --------------------------------------------------------- |
|
343 // COMASuplInitState::ConverttoUniCodeL |
|
344 // |
|
345 // (other items were commented in a header). |
|
346 // --------------------------------------------------------- |
|
347 // |
|
348 TInt COMASuplInitState::ConverttoUniCodeL(HBufC*& aUniCode,HBufC8& aRequstor) |
|
349 { |
|
350 COMASuplNotification::TOMASuplEncodingType encodingType; |
|
351 TInt error = iNotification->EncodingType(encodingType); |
|
352 if(error) |
|
353 { |
|
354 return KErrArgument; |
|
355 } |
|
356 else |
|
357 { |
|
358 |
|
359 for(TInt i = 0; i < aRequstor.Length(); i++) |
|
360 { |
|
361 TBuf<32> printBuffer; |
|
362 TUint16 FirstChar = aRequstor[i]; |
|
363 printBuffer.AppendNum(FirstChar); |
|
364 iTrace->Trace(printBuffer,KTraceFileName, __LINE__); |
|
365 } |
|
366 |
|
367 switch(encodingType) |
|
368 { |
|
369 case COMASuplNotification::EUCS2: |
|
370 { |
|
371 iTrace->Trace(_L("Notification Encoding Type : EUCS2"), KTraceFileName, __LINE__); |
|
372 aUniCode = HBufC::NewL(aRequstor.Length()); |
|
373 TPtr16 requestId = aUniCode->Des(); |
|
374 FormUCS2String(aRequstor,requestId); |
|
375 break; |
|
376 } |
|
377 case COMASuplNotification::EUtf8: |
|
378 { |
|
379 iTrace->Trace(_L("Notification Encoding Type : EUtf8"), KTraceFileName, __LINE__); |
|
380 aUniCode = HBufC::NewL(aRequstor.Length()); |
|
381 TPtr16 requestId = aUniCode->Des(); |
|
382 error = CnvUtfConverter::ConvertToUnicodeFromUtf8(requestId,aRequstor); |
|
383 break; |
|
384 } |
|
385 case COMASuplNotification::EGsmDefault: |
|
386 { |
|
387 iTrace->Trace(_L("Notification Encoding Type : EGsmDefault"), KTraceFileName, __LINE__); |
|
388 aUniCode = HBufC::NewL(aRequstor.Length() * 2); |
|
389 TPtr16 requestId = aUniCode->Des(); |
|
390 RBuf8 destString; |
|
391 destString.CreateL(aRequstor.Length() * 2); |
|
392 TBuf<64> temp; |
|
393 temp.Copy(aRequstor); |
|
394 iTrace->Trace(temp, KTraceFileName, __LINE__); |
|
395 GsmDefaultDecode(aRequstor,destString); |
|
396 requestId.Copy(destString); |
|
397 destString.Close(); |
|
398 break; |
|
399 } |
|
400 default: |
|
401 { |
|
402 error = KErrArgument; |
|
403 } |
|
404 } |
|
405 } |
|
406 return error; |
|
407 } |
|
408 // --------------------------------------------------------- |
|
409 // COMASuplInitState::Requestor |
|
410 // |
|
411 // (other items were commented in a header). |
|
412 // --------------------------------------------------------- |
|
413 // |
|
414 TInt COMASuplInitState::RequestorL(HBufC*& aRequestor) |
|
415 { |
|
416 |
|
417 COMASuplNotification::TOMASuplFormatIndicator requestType; |
|
418 HBufC8* requestor = NULL; |
|
419 // Eventhough requestor id is empty...we have to show the Privacy verification note |
|
420 TInt error = iNotification->RequestorId(requestor,requestType); |
|
421 if(error == KErrNone || error == KErrOMASuplParamNotSet ) |
|
422 { |
|
423 error = KErrNone; |
|
424 if(requestor) |
|
425 { |
|
426 error = ConverttoUniCodeL(aRequestor,*requestor); |
|
427 } |
|
428 |
|
429 switch(requestType) |
|
430 { |
|
431 case COMASuplNotification::ELogicalName: |
|
432 { |
|
433 iTrace->Trace(_L("COMASuplInitState::RequestorL Requestor type - Logical Name"), KTraceFileName, __LINE__); |
|
434 iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeLogicalName; |
|
435 break; |
|
436 } |
|
437 case COMASuplNotification::EEMailAddress: |
|
438 { |
|
439 iTrace->Trace(_L("COMASuplInitState::RequestorL Requestor type - EMail Addr"), KTraceFileName, __LINE__); |
|
440 iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeEmailAddress; |
|
441 break; |
|
442 } |
|
443 case COMASuplNotification::EMsisdn: |
|
444 { |
|
445 iTrace->Trace(_L("COMASuplInitState::RequestorL Requestor type - MSISDN"), KTraceFileName, __LINE__); |
|
446 iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeMSISDN; |
|
447 break; |
|
448 } |
|
449 case COMASuplNotification::EUrl: |
|
450 { |
|
451 iTrace->Trace(_L("COMASuplInitState::RequestorL Requestor type - URL"), KTraceFileName, __LINE__); |
|
452 iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeURL; |
|
453 break; |
|
454 } |
|
455 case COMASuplNotification::ESipUrl: |
|
456 { |
|
457 iTrace->Trace(_L("COMASuplInitState::RequestorL Requestor type - SIP URL"), KTraceFileName, __LINE__); |
|
458 iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeSIPURL; |
|
459 break; |
|
460 } |
|
461 case COMASuplNotification::EMin: |
|
462 { |
|
463 iTrace->Trace(_L("COMASuplInitState::RequestorL Requestor type - MIN"), KTraceFileName, __LINE__); |
|
464 iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeMIN; |
|
465 break; |
|
466 } |
|
467 case COMASuplNotification::EMdn: |
|
468 { |
|
469 iTrace->Trace(_L("COMASuplInitState::RequestorL Requestor type - MDN"), KTraceFileName, __LINE__); |
|
470 iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeMDN; |
|
471 break; |
|
472 } |
|
473 case COMASuplNotification::EIMSPublicIdentity: |
|
474 { |
|
475 iTrace->Trace(_L("COMASuplInitState::RequestorL Requestor type - IMS Public Identity"), KTraceFileName, __LINE__); |
|
476 iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeIMSPublicIdentity; |
|
477 break; |
|
478 } |
|
479 default: |
|
480 { |
|
481 error = KErrArgument; |
|
482 break; |
|
483 } |
|
484 } |
|
485 } |
|
486 |
|
487 return error; |
|
488 } |
|
489 // --------------------------------------------------------- |
|
490 // COMASuplInitState::Client |
|
491 // |
|
492 // (other items were commented in a header). |
|
493 // --------------------------------------------------------- |
|
494 // |
|
495 TInt COMASuplInitState::ClientL(HBufC*& aClient) |
|
496 { |
|
497 COMASuplNotification::TOMASuplFormatIndicator clientType; |
|
498 HBufC8* client = NULL; |
|
499 |
|
500 TInt error = iNotification->ClientName(client,clientType); |
|
501 //if(!error) |
|
502 if(error == KErrNone || error == KErrOMASuplParamNotSet ) |
|
503 { |
|
504 |
|
505 error = KErrNone; |
|
506 if(client) |
|
507 { |
|
508 error = ConverttoUniCodeL(aClient,*client); |
|
509 } |
|
510 |
|
511 switch(clientType) |
|
512 { |
|
513 case COMASuplNotification::ELogicalName: |
|
514 { |
|
515 iTrace->Trace(_L("COMASuplInitState::ClientL Client type - Logical Name"), KTraceFileName, __LINE__); |
|
516 iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeLogicalName; |
|
517 break; |
|
518 } |
|
519 case COMASuplNotification::EEMailAddress: |
|
520 { |
|
521 iTrace->Trace(_L("COMASuplInitState::ClientL Client type - EMail Addr"), KTraceFileName, __LINE__); |
|
522 iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeEmailAddress; |
|
523 break; |
|
524 } |
|
525 case COMASuplNotification::EMsisdn: |
|
526 { |
|
527 iTrace->Trace(_L("COMASuplInitState::ClientL Client type - MSISDN"), KTraceFileName, __LINE__); |
|
528 iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeMSISDN; |
|
529 break; |
|
530 } |
|
531 case COMASuplNotification::EUrl: |
|
532 { |
|
533 iTrace->Trace(_L("COMASuplInitState::ClientL Client type - URL"), KTraceFileName, __LINE__); |
|
534 iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeURL; |
|
535 break; |
|
536 } |
|
537 case COMASuplNotification::ESipUrl: |
|
538 { |
|
539 iTrace->Trace(_L("COMASuplInitState::ClientL Client type - SIP URL"), KTraceFileName, __LINE__); |
|
540 iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeSIPURL; |
|
541 break; |
|
542 } |
|
543 case COMASuplNotification::EMin: |
|
544 { |
|
545 iTrace->Trace(_L("COMASuplInitState::ClientL Client type - MIN"), KTraceFileName, __LINE__); |
|
546 iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeMIN; |
|
547 break; |
|
548 } |
|
549 case COMASuplNotification::EMdn: |
|
550 { |
|
551 iTrace->Trace(_L("COMASuplInitState::ClientL Client type - MDN"), KTraceFileName, __LINE__); |
|
552 iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeMDN; |
|
553 break; |
|
554 } |
|
555 case COMASuplNotification::EIMSPublicIdentity: |
|
556 { |
|
557 iTrace->Trace(_L("COMASuplInitState::ClientL Client type - IMS Public Identity"), KTraceFileName, __LINE__); |
|
558 iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeIMSPublicIdentity; |
|
559 break; |
|
560 } |
|
561 default: |
|
562 { |
|
563 error = KErrArgument; |
|
564 break; |
|
565 } |
|
566 } |
|
567 } |
|
568 |
|
569 return error; |
|
570 } |
|
571 // --------------------------------------------------------- |
|
572 // COMASuplInitState::HandleVerifyComplete |
|
573 // |
|
574 // (other items were commented in a header). |
|
575 // --------------------------------------------------------- |
|
576 // |
|
577 void COMASuplInitState::HandleVerifyComplete( |
|
578 TInt /*aRequestId*/, TInt aCompletionCode) |
|
579 { |
|
580 StopTimer(); |
|
581 iCompletionCode = aCompletionCode; |
|
582 |
|
583 if(iNoPosition) |
|
584 { |
|
585 if(aCompletionCode) |
|
586 { |
|
587 iCompletionCode = KErrOMASuplDenied; |
|
588 } |
|
589 else |
|
590 { |
|
591 iCompletionCode = KErrOMASuplAccepted; |
|
592 } |
|
593 } |
|
594 |
|
595 if(KErrNone == iCompletionCode || KErrOMASuplAccepted == iCompletionCode) |
|
596 { |
|
597 TRAP_IGNORE(MakeGSMNotificationL()); |
|
598 |
|
599 } |
|
600 |
|
601 TRAP_IGNORE(iPrivacyObserver.PrivacyCheckCompleteL(iCompletionCode)); |
|
602 |
|
603 } |
|
604 |
|
605 // ----------------------------------------------------------------------------- |
|
606 // COMASuplInitState::TimerExpired |
|
607 // TimerExpired...Gets called when time out occurs . |
|
608 // (other items were commented in a header). |
|
609 // ----------------------------------------------------------------------------- |
|
610 // |
|
611 void COMASuplInitState::TimerExpiredL() |
|
612 { |
|
613 iTrace->Trace(_L("COMASuplState::TimerExpired..."), KTraceFileName, __LINE__); |
|
614 |
|
615 COMASuplNotification::TOMASuplNotificationType notifyType = iNotification->SuplNotification(); |
|
616 if(notifyType == COMASuplNotification::ENotificationAndVerficationAllowedNA) |
|
617 { |
|
618 iCompletionCode = KErrNone; |
|
619 } |
|
620 else if(notifyType == COMASuplNotification::ENotificationAndVerficationDeniedNA ) |
|
621 { |
|
622 iCompletionCode = KErrAccessDenied; |
|
623 } |
|
624 |
|
625 if(iNoPosition) |
|
626 { |
|
627 if(iCompletionCode) |
|
628 { |
|
629 iCompletionCode = KErrOMASuplDenied; |
|
630 } |
|
631 else |
|
632 { |
|
633 iCompletionCode = KErrOMASuplAccepted; |
|
634 } |
|
635 } |
|
636 // Cancel ongoing verification using Network Privacy |
|
637 iNetworkPrivacy->CancelVerifyLocationRequest(iGSMRequestId); |
|
638 if(KErrNone == iCompletionCode || KErrOMASuplAccepted == iCompletionCode) |
|
639 { |
|
640 MakeGSMNotificationL(); |
|
641 } |
|
642 iPrivacyObserver.PrivacyCheckCompleteL(iCompletionCode); |
|
643 } |
|
644 |
|
645 // ----------------------------------------------------------------------------- |
|
646 // COMASuplInitState::CheckForVersion |
|
647 // CheckForVersion...Checks version of protocol & received message |
|
648 // (other items were commented in a header). |
|
649 // ----------------------------------------------------------------------------- |
|
650 // |
|
651 TInt COMASuplInitState::CheckForVersion() |
|
652 { |
|
653 TOMASuplVersion version; |
|
654 COMASuplSessionID* SessionID = NULL; |
|
655 iSuplInit->MessageBase(version,SessionID); |
|
656 |
|
657 TInt recMajor,recMinor,recServInd; |
|
658 TInt actMajor,actMinor,actServInd; |
|
659 |
|
660 version.SuplVersion(recMajor,recMinor,recServInd); |
|
661 iOMASuplVersion.SuplVersion(actMajor,actMinor,actServInd); |
|
662 if(recMajor == actMajor ) |
|
663 { |
|
664 return KErrNone; |
|
665 } |
|
666 else |
|
667 { |
|
668 return KErrOMASuplVersionNotMatching; |
|
669 } |
|
670 } |
|
671 |
|
672 // ----------------------------------------------------------------------------- |
|
673 // COMASuplInitState::CheckForModeSupport |
|
674 // CheckForModeSupport...Checks modes of protocol & received message |
|
675 // (other items were commented in a header). |
|
676 // ----------------------------------------------------------------------------- |
|
677 // |
|
678 TInt COMASuplInitState::CheckForModeSupport() |
|
679 { |
|
680 COMASuplInit::TOMASuplSLPMode SLPMode; |
|
681 |
|
682 iSuplInit->SuplInit(iPosMethod,SLPMode); |
|
683 |
|
684 COMASuplInit::TOMASuplSLPMode SupportedMode = (COMASuplInit::TOMASuplSLPMode)iSupportedMode; |
|
685 |
|
686 if(SLPMode == SupportedMode ) |
|
687 { |
|
688 return KErrNone; |
|
689 } |
|
690 else |
|
691 { |
|
692 return KErrOMANonProxyModeNotSupported; |
|
693 } |
|
694 } |
|
695 |
|
696 // ----------------------------------------------------------------------------- |
|
697 // COMASuplInitState::CheckForSetSessionID |
|
698 // CheckForModeSupport...Checks if Set session ID is present in the SUPL INT |
|
699 // message received |
|
700 // (other items were commented in a header). |
|
701 // ----------------------------------------------------------------------------- |
|
702 // |
|
703 TInt COMASuplInitState::CheckForSetSessionID() |
|
704 { |
|
705 iTrace->Trace(_L("Start COMASuplInitState::CheckForSetSessionID"), KTraceFileName, __LINE__); |
|
706 COMASuplSessionID* retrivedSessionID = NULL; |
|
707 iSuplInit->SessionId(retrivedSessionID); |
|
708 if(retrivedSessionID) |
|
709 { |
|
710 COMASuplSETSessionID *setSessionId = NULL; |
|
711 retrivedSessionID->SETSessionID(setSessionId); |
|
712 if(setSessionId) |
|
713 { |
|
714 iTrace->Trace(_L("COMASuplInitState::CheckForSetSessionID, SET Session ID present"), KTraceFileName, __LINE__); |
|
715 return KErrSuplInvalidSessionID; |
|
716 } |
|
717 else |
|
718 { |
|
719 return KErrNone; |
|
720 } |
|
721 } |
|
722 else |
|
723 { |
|
724 return KErrSuplInvalidSessionID; |
|
725 } |
|
726 } |
|
727 |
|
728 // ----------------------------------------------------------------------------- |
|
729 // COMASuplInitState::CheckForSetSessionID |
|
730 // CheckForModeSupport...Checks if Set session ID is present in the SUPL INT |
|
731 // message received |
|
732 // (other items were commented in a header). |
|
733 // ----------------------------------------------------------------------------- |
|
734 // |
|
735 TInt COMASuplInitState::CheckForSLPSessionID() |
|
736 { |
|
737 COMASuplSessionID* retrivedSessionID = NULL; |
|
738 iSuplInit->SessionId(retrivedSessionID); |
|
739 if(retrivedSessionID) |
|
740 { |
|
741 TBuf8<KSLPSessionID> sessionId; |
|
742 COMASuplSLPAddress* slpIPAddress = NULL; |
|
743 COMASuplSLPSessionID* retrivedSuplSLPID =NULL; |
|
744 retrivedSessionID->SLPSessionID(retrivedSuplSLPID); |
|
745 if(retrivedSuplSLPID) |
|
746 { |
|
747 retrivedSuplSLPID->SuplSLPSessionID(sessionId,slpIPAddress); |
|
748 if(sessionId.Length() == 0 ) |
|
749 return KErrSuplInvalidSessionID; |
|
750 else |
|
751 return KErrNone; |
|
752 } |
|
753 else |
|
754 { |
|
755 return KErrSuplInvalidSessionID; |
|
756 } |
|
757 } |
|
758 else |
|
759 { |
|
760 return KErrSuplInvalidSessionID; |
|
761 } |
|
762 } |
|
763 |
|
764 // ----------------------------------------------------------------------------- |
|
765 // COMASuplInitState::CheckForPositioningMethod |
|
766 // CheckForPositioningMethod... |
|
767 // (other items were commented in a header). |
|
768 // ----------------------------------------------------------------------------- |
|
769 // |
|
770 void COMASuplInitState::CheckForPositioningMethod() |
|
771 { |
|
772 COMASuplInit::TOMASuplSLPMode SLPMode; |
|
773 iSuplInit->SuplInit(iPosMethod,SLPMode); |
|
774 if(EOMANoPosition == iPosMethod) |
|
775 { |
|
776 iNoPosition = ETrue; |
|
777 } |
|
778 } |
|
779 TInt ConvertHexToGSMDefault(TInt aHex) |
|
780 { |
|
781 TInt GSMDefaultEquivalentHex = aHex; |
|
782 switch(aHex) |
|
783 { |
|
784 case 0x00:GSMDefaultEquivalentHex = 0x40;break; |
|
785 case 0x01:GSMDefaultEquivalentHex = 0xA3;break; |
|
786 case 0x02:GSMDefaultEquivalentHex = 0x24;break; |
|
787 case 0x03:GSMDefaultEquivalentHex = 0xA5;break; |
|
788 case 0x04:GSMDefaultEquivalentHex = 0xE8;break; |
|
789 case 0x05:GSMDefaultEquivalentHex = 0xE9;break; |
|
790 case 0x06:GSMDefaultEquivalentHex = 0xF9;break; |
|
791 case 0x07:GSMDefaultEquivalentHex = 0xEC;break; |
|
792 case 0x08:GSMDefaultEquivalentHex = 0xF2;break; |
|
793 case 0x09:GSMDefaultEquivalentHex = 0xE7;break; |
|
794 case 0x0a:GSMDefaultEquivalentHex = 0x0A;break; |
|
795 case 0x0b:GSMDefaultEquivalentHex = 0xD8;break; |
|
796 case 0x0c:GSMDefaultEquivalentHex = 0xF8;break; |
|
797 case 0x0d:GSMDefaultEquivalentHex = 0x0D;break; |
|
798 case 0x0e:GSMDefaultEquivalentHex = 0xC5;break; |
|
799 case 0x0f:GSMDefaultEquivalentHex = 0xE5;break; |
|
800 case 0x10:GSMDefaultEquivalentHex = 0x0394;break; |
|
801 case 0x11:GSMDefaultEquivalentHex = 0x5F;break; |
|
802 case 0x12:GSMDefaultEquivalentHex = 0x03A6;break; |
|
803 case 0x13:GSMDefaultEquivalentHex = 0x0393;break; |
|
804 case 0x14:GSMDefaultEquivalentHex = 0x039B;break; |
|
805 case 0x15:GSMDefaultEquivalentHex = 0x03A9;break; |
|
806 case 0x16:GSMDefaultEquivalentHex = 0x03A0;break; |
|
807 case 0x17:GSMDefaultEquivalentHex = 0x03A8;break; |
|
808 case 0x18:GSMDefaultEquivalentHex = 0x03A3;break; |
|
809 case 0x19:GSMDefaultEquivalentHex = 0x0398;break; |
|
810 case 0x1a:GSMDefaultEquivalentHex = 0x039E;break; |
|
811 case 0x1c:GSMDefaultEquivalentHex = 0x00C6;break; |
|
812 case 0x1d:GSMDefaultEquivalentHex = 0x00E6;break; |
|
813 case 0x1e:GSMDefaultEquivalentHex = 0x00DF;break; |
|
814 case 0x1f:GSMDefaultEquivalentHex = 0x00C9;break; |
|
815 case 0x24:GSMDefaultEquivalentHex = 0xA4;break; |
|
816 |
|
817 case 0x40:GSMDefaultEquivalentHex = 0xA1;break; |
|
818 case 0x5b:GSMDefaultEquivalentHex = 0xC4;break; |
|
819 case 0x5c:GSMDefaultEquivalentHex = 0xD6;break; |
|
820 case 0x5d:GSMDefaultEquivalentHex = 0xD1;break; |
|
821 case 0x5e:GSMDefaultEquivalentHex = 0xDC;break; |
|
822 case 0x5f:GSMDefaultEquivalentHex = 0xA7;break; |
|
823 case 0x60:GSMDefaultEquivalentHex = 0xBF;break; |
|
824 |
|
825 case 0x7b:GSMDefaultEquivalentHex = 0xE4;break; |
|
826 case 0x7c:GSMDefaultEquivalentHex = 0xF6;break; |
|
827 case 0x7d:GSMDefaultEquivalentHex = 0xF1;break; |
|
828 case 0x7e:GSMDefaultEquivalentHex = 0xFC;break; |
|
829 case 0x7f:GSMDefaultEquivalentHex = 0xE0;break; |
|
830 default:break; |
|
831 } |
|
832 |
|
833 return GSMDefaultEquivalentHex; |
|
834 } |
|
835 |
|
836 // ----------------------------------------------------------------------------- |
|
837 // COMASuplInitState::GsmDefaultDecode |
|
838 // GsmDefaultDecode... |
|
839 // This function takes packed 7 bit data and pads it out to 8 bit data |
|
840 // Function will actually append data onto end of an existing buffer. |
|
841 // (other items were commented in a header). |
|
842 // ----------------------------------------------------------------------------- |
|
843 // |
|
844 void COMASuplInitState::GsmDefaultDecode( const TDesC8& aIn, TDes8& aOut ) |
|
845 { |
|
846 |
|
847 TInt length = aIn.Length(); |
|
848 TInt count = ( length * 8 ) / 7; |
|
849 |
|
850 // Get raw pointers and do unpacking |
|
851 TUint8* outPtr = (TUint8*)aOut.Ptr() + aOut.Length(); |
|
852 const TUint8* inPtr = aIn.Ptr(); |
|
853 |
|
854 TInt startBit = 0; |
|
855 // Iterate over each 7 bit element |
|
856 for ( TInt ii = 0; ii < count; ii++ ) |
|
857 { |
|
858 TInt from = ( *inPtr >> startBit ) & 0x7F; |
|
859 if ( startBit ) |
|
860 { |
|
861 inPtr++; |
|
862 from |= ( *inPtr << ( 8 - startBit ) ) & 0x7F; |
|
863 } |
|
864 outPtr[ ii ] = (TUint8)from; |
|
865 startBit = ( startBit + 7 ) % 8; |
|
866 } |
|
867 aOut.SetLength( aOut.Length() + count ); |
|
868 length = aOut.Length(); |
|
869 |
|
870 for(TInt Index = 0 ; Index < length; Index++ ) |
|
871 { |
|
872 if( Index == length - 1 && (aOut[Index] == 0x0000 || aOut[Index] == 0x000D)) |
|
873 { |
|
874 aOut.SetLength( Index ); |
|
875 break; |
|
876 } |
|
877 |
|
878 aOut[Index] = ConvertHexToGSMDefault(aOut[Index]); |
|
879 } |
|
880 |
|
881 } |
|
882 |
|
883 // ----------------------------------------------------------------------------- |
|
884 // COMASuplInitState::FormUCS2String |
|
885 // FormUCS2String... |
|
886 // This function takes two consecuative characters from input string and combine them to form |
|
887 // single character of 16-bit. |
|
888 // (other items were commented in a header). |
|
889 // ----------------------------------------------------------------------------- |
|
890 // |
|
891 void COMASuplInitState::FormUCS2String( const TDesC8& aIn, TDes& aOut ) |
|
892 { |
|
893 TUint16 Res; |
|
894 TUint16 FirstChar; |
|
895 TUint16 SecondChar; |
|
896 aOut.Zero(); |
|
897 TInt Len = aIn.Length() / 2; |
|
898 TInt Index = 0; |
|
899 TBool IsBigEndian = ETrue; |
|
900 TInt Count = 0; |
|
901 if(aIn.Length() >= 2 && ((aIn[Index] != 0xFF || aIn[Index + 1] != 0xFE ) && (aIn[Index + 1] != 0xFF || aIn[Index] != 0xFE ))) // Since this is not following algorithm |
|
902 { |
|
903 aOut.Zero(); |
|
904 return; |
|
905 } |
|
906 |
|
907 if(aIn.Length() >= 2 && aIn[Index] == 0xFE && aIn[Index + 1] == 0xFF) // Big Endian |
|
908 { |
|
909 Index = 2; |
|
910 Count = 1; |
|
911 } |
|
912 |
|
913 if(aIn.Length() >= 2 && aIn[Index] == 0xFF && aIn[Index + 1] == 0xFE) // Little Endian |
|
914 { |
|
915 Index = 2; |
|
916 IsBigEndian = EFalse; |
|
917 Count = 1; |
|
918 } |
|
919 |
|
920 |
|
921 for(;Count < Len; Count++) |
|
922 { |
|
923 if(IsBigEndian) |
|
924 { |
|
925 FirstChar = aIn[Index]; |
|
926 SecondChar = aIn[Index + 1]; |
|
927 } |
|
928 else |
|
929 { |
|
930 FirstChar = aIn[Index + 1]; |
|
931 SecondChar = aIn[Index]; |
|
932 } |
|
933 FirstChar = FirstChar << 8; |
|
934 Res = FirstChar | SecondChar; |
|
935 aOut.Append(Res); |
|
936 Index = Index + 2; |
|
937 } |
|
938 |
|
939 } |
|
940 |
|
941 TOMASuplPosMethod COMASuplInitState::GetPosMethod() |
|
942 { |
|
943 TBuf<128> msg(_L("SuplInitState::GetPosMethod():")); |
|
944 msg.AppendNum(iPosMethod); |
|
945 iTrace->Trace(msg, KTraceFileName, __LINE__); |
|
946 return iPosMethod; |
|
947 } |
|
948 |
|
949 // ----------------------------------------------------------------------------- |
|
950 // COMASuplInitState::GetRequestorID |
|
951 // |
|
952 // |
|
953 // ----------------------------------------------------------------------------- |
|
954 void COMASuplInitState::GetRequestorID(TInt& aRequestorId) //APE Centric |
|
955 { |
|
956 if ( iRequestIDFeatureFlag ) |
|
957 { |
|
958 aRequestorId = iGSMRequestId; |
|
959 } |
|
960 else |
|
961 { |
|
962 aRequestorId = 0; |
|
963 } |
|
964 } |
|
965 // ----------------------------------------------------------------------------- |
|
966 // COMASuplInitState::ReadRequestIDFeatureFlagL |
|
967 // |
|
968 // |
|
969 // ----------------------------------------------------------------------------- |
|
970 |
|
971 void COMASuplInitState::ReadRequestIDFeatureFlagL() //APE CENTRIC |
|
972 { |
|
973 |
|
974 iRequestIDFeatureFlag = EFalse; |
|
975 FeatureManager::InitializeLibL(); |
|
976 |
|
977 // Feature flag check provided for Product profile bits specific variation |
|
978 |
|
979 |
|
980 iRequestIDFeatureFlag = FeatureManager::FeatureSupported(KSUPLAPECentricArchSupport); |
|
981 FeatureManager::UnInitializeLib(); |
|
982 |
|
983 if (iRequestIDFeatureFlag) |
|
984 { |
|
985 iTrace->Trace(_L("Real: Supl 1.0..APE Flag is ON..."), KTraceFileName, __LINE__); |
|
986 } |
|
987 else |
|
988 { |
|
989 iTrace->Trace(_L("Real: Supl 1.0..APE Flag is OFF..."), KTraceFileName, __LINE__); |
|
990 } |
|
991 |
|
992 iRequestIDFeatureFlag = ETrue; |
|
993 |
|
994 if (iRequestIDFeatureFlag) |
|
995 { |
|
996 iTrace->Trace(_L("Supl 1.0..APE Centric Arch Feature Flag is ON..."), KTraceFileName, __LINE__); |
|
997 } |
|
998 else |
|
999 { |
|
1000 iTrace->Trace(_L("Supl 1.0..APE Centric Arch Feature Flag is OFF..."), KTraceFileName, __LINE__); |
|
1001 } |
|
1002 |
|
1003 } |
|
1004 // End of File |