|
1 /* |
|
2 * Copyright (c) 2002-2009 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: Client-Server communication |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <s32mem.h> |
|
19 #include <e32std.h> |
|
20 #include <lbspositioninfo.h> |
|
21 |
|
22 #include <epos_suplterminalconstants.h> |
|
23 #include <epos_suplterminal.h> |
|
24 #include <epos_suplterminalparams.h> |
|
25 |
|
26 #include "epos_suplterminalipc.h" |
|
27 #include "epos_suplterminalerrors.h" |
|
28 #include "epos_startsuplserver.h" |
|
29 #include "epos_suplterminalptrholder.h" |
|
30 #include "epos_suplterminalqop.h" |
|
31 #include "epos_suplparameters.h" |
|
32 |
|
33 #include "epos_csuplsettings.h" |
|
34 #include "epos_csuplsettingparams.h" |
|
35 |
|
36 const TUint KFirstReq = 0x1000; |
|
37 const TInt KMaxBufLength = 255; |
|
38 |
|
39 //----------------------------------------------------------------------------- |
|
40 // RSuplTerminalServer |
|
41 //----------------------------------------------------------------------------- |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // RSuplTerminalServer::RSuplTerminalServer() |
|
45 // C++ default constructor can NOT contain any code, that might leave. |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 EXPORT_C RSuplTerminalServer::RSuplTerminalServer() |
|
49 : RSessionBase(), |
|
50 iReserved(NULL) |
|
51 { |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // RSuplTerminalServer::ConstructL |
|
56 // Symbian 2nd phase constructor can leave. |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 void RSuplTerminalServer::ConstructL() |
|
60 { |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------- |
|
64 // RSuplTerminalServer::Destruct |
|
65 // |
|
66 // Destruction method for RSuplTerminalServer. |
|
67 // --------------------------------------------------------- |
|
68 // |
|
69 void RSuplTerminalServer::Destruct() |
|
70 { |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------- |
|
74 // RSuplTerminalServer::Connect |
|
75 // |
|
76 // (other items were commented in a header). |
|
77 // --------------------------------------------------------- |
|
78 // |
|
79 EXPORT_C TInt RSuplTerminalServer::Connect() |
|
80 { |
|
81 __ASSERT_ALWAYS(Handle() == 0, |
|
82 User::Panic(KSuplClientFault, ESuplServerHandleNotClosed)); |
|
83 |
|
84 TRAPD(ret, ConstructL()); |
|
85 |
|
86 if (ret == KErrNone) |
|
87 { |
|
88 //TInt retry = 200; |
|
89 TInt retry = 3; |
|
90 for (;;) // FOREVER |
|
91 { |
|
92 ret = CreateSession(KSuplServerName, Version(), KDefaultMessageSlots); |
|
93 |
|
94 if (ret != KErrNotFound && ret != KErrServerTerminated) |
|
95 { |
|
96 break; |
|
97 } |
|
98 |
|
99 if (--retry == 0) |
|
100 { |
|
101 break; |
|
102 } |
|
103 |
|
104 ret = StartServer(); |
|
105 |
|
106 if (ret != KErrAlreadyExists && ret != KErrNone) |
|
107 { |
|
108 break; |
|
109 } |
|
110 } |
|
111 } |
|
112 |
|
113 if (ret != KErrNone) |
|
114 { |
|
115 Destruct(); |
|
116 } |
|
117 |
|
118 return ret; |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------- |
|
122 // RSuplTerminalServer::Close |
|
123 // |
|
124 // (other items were commented in a header). |
|
125 // --------------------------------------------------------- |
|
126 // |
|
127 EXPORT_C void RSuplTerminalServer::Close() |
|
128 { |
|
129 RSessionBase::Close(); |
|
130 Destruct(); |
|
131 } |
|
132 |
|
133 // --------------------------------------------------------- |
|
134 // RSuplTerminalServer::Version |
|
135 // |
|
136 // (other items were commented in a header). |
|
137 // --------------------------------------------------------- |
|
138 // |
|
139 EXPORT_C TVersion RSuplTerminalServer::Version() const |
|
140 { |
|
141 return TVersion( |
|
142 KSuplMajorVersionNumber, |
|
143 KSuplMinorVersionNumber, |
|
144 KSuplBuildVersionNumber); |
|
145 } |
|
146 // --------------------------------------------------------- |
|
147 // RSuplTerminalServer::Connect |
|
148 // |
|
149 // (other items were commented in a header). |
|
150 // --------------------------------------------------------- |
|
151 // |
|
152 EXPORT_C TInt RSuplTerminalServer::Connect(TRequestStatus& aStatus) |
|
153 { |
|
154 __ASSERT_ALWAYS(Handle() == 0, User::Panic(KSuplClientFault, ESuplServerHandleNotClosed)); |
|
155 TRAPD(ret, ConstructL()); |
|
156 |
|
157 if (ret == KErrNone) |
|
158 { |
|
159 TInt retry = 200; |
|
160 for (;;) // FOREVER |
|
161 { |
|
162 ret = CreateSession(KSuplServerName, Version(), KDefaultMessageSlots, EIpcSession_Unsharable, (TSecurityPolicy*)0, &aStatus); |
|
163 |
|
164 if (ret != KErrNotFound && ret != KErrServerTerminated) |
|
165 { |
|
166 break; |
|
167 } |
|
168 |
|
169 if (--retry == 0) |
|
170 { |
|
171 break; |
|
172 } |
|
173 |
|
174 ret = StartServer(); |
|
175 |
|
176 if (ret != KErrAlreadyExists && ret != KErrNone) |
|
177 { |
|
178 break; |
|
179 } |
|
180 } |
|
181 } |
|
182 |
|
183 if (ret != KErrNone) |
|
184 { |
|
185 Destruct(); |
|
186 } |
|
187 |
|
188 return ret; |
|
189 } |
|
190 //----------------------------------------------------------------------------- |
|
191 // RSuplTerminalSubSession |
|
192 //----------------------------------------------------------------------------- |
|
193 |
|
194 // --------------------------------------------------------- |
|
195 // RSuplTerminalSubSession::RSuplTerminalSubSession |
|
196 // |
|
197 // (other items were commented in a header). |
|
198 // --------------------------------------------------------- |
|
199 // |
|
200 EXPORT_C RSuplTerminalSubSession::RSuplTerminalSubSession() |
|
201 : RSubSessionBase(), |
|
202 iPtrHolder(NULL), |
|
203 iReserved(NULL), |
|
204 isTriggeringUsed(EFalse), |
|
205 iNotifyRequestCtr(0) |
|
206 { |
|
207 } |
|
208 |
|
209 // --------------------------------------------------------- |
|
210 // RSuplTerminalSubSession::ConstructL |
|
211 // |
|
212 // (other items were commented in a header). |
|
213 // --------------------------------------------------------- |
|
214 // |
|
215 EXPORT_C void RSuplTerminalSubSession::ConstructL() |
|
216 { |
|
217 __ASSERT_ALWAYS(iPtrHolder == NULL, |
|
218 User::Panic(KSuplClientFault, ESuplServerHandleNotClosed)); |
|
219 |
|
220 iPtrHolder = CSuplSubSessnPtrHolder::NewL(1, 1); |
|
221 } |
|
222 |
|
223 // --------------------------------------------------------- |
|
224 // RSuplTerminalSubSession::Destruct |
|
225 // |
|
226 // (other items were commented in a header). |
|
227 // --------------------------------------------------------- |
|
228 // |
|
229 EXPORT_C void RSuplTerminalSubSession::Destruct() |
|
230 { |
|
231 delete iPtrHolder; |
|
232 iPtrHolder = NULL; |
|
233 } |
|
234 |
|
235 // --------------------------------------------------------- |
|
236 // RSuplTerminalSubSession::Open |
|
237 // |
|
238 // (other items were commented in a header). |
|
239 // --------------------------------------------------------- |
|
240 // |
|
241 EXPORT_C TInt RSuplTerminalSubSession::Open( |
|
242 RSuplTerminalServer& aSuplServer, |
|
243 TSuplServiceType aSuplService) |
|
244 { |
|
245 __ASSERT_ALWAYS(aSuplServer.Handle() != 0, |
|
246 User::Panic(KSuplClientFault, ESuplServerBadHandle)); |
|
247 |
|
248 iSuplService = aSuplService; |
|
249 |
|
250 TInt suplVersion; |
|
251 |
|
252 switch( aSuplService ) |
|
253 { |
|
254 case ESUPL_1_0: |
|
255 { |
|
256 suplVersion = 1; |
|
257 break; |
|
258 } |
|
259 case ESUPL_2_0: |
|
260 { |
|
261 suplVersion = 2; |
|
262 break; |
|
263 } |
|
264 default: |
|
265 { |
|
266 suplVersion = 1; |
|
267 break; |
|
268 } |
|
269 } |
|
270 |
|
271 TIpcArgs args; |
|
272 args.Set(0, suplVersion); |
|
273 |
|
274 TRAPD(ret, ConstructL()); |
|
275 if (ret == KErrNone) |
|
276 { |
|
277 ret = CreateSubSession(aSuplServer, ESuplTerminalSubssnOpen, args); |
|
278 } |
|
279 if (ret != KErrNone) |
|
280 { |
|
281 Destruct(); |
|
282 } |
|
283 |
|
284 return ret; |
|
285 } |
|
286 |
|
287 // --------------------------------------------------------- |
|
288 // RSuplTerminalSubSession::RunSession |
|
289 // |
|
290 // (other items were commented in a header). |
|
291 // --------------------------------------------------------- |
|
292 // |
|
293 EXPORT_C void RSuplTerminalSubSession::RunSession( |
|
294 TRequestStatus& aStatus, |
|
295 TInt aSETCaps, |
|
296 TInt aRequestId, |
|
297 TBool aFirstReq) |
|
298 { |
|
299 __ASSERT_ALWAYS(SubSessionHandle(), User::Panic(KSuplClientFault, ESuplServerBadHandle)); |
|
300 |
|
301 if(aRequestId < 0 ) |
|
302 { |
|
303 TRequestStatus *status = &aStatus; |
|
304 User::RequestComplete(status,KErrArgument); |
|
305 return; |
|
306 } |
|
307 |
|
308 if(aSETCaps < 0 ) |
|
309 { |
|
310 TRequestStatus *status = &aStatus; |
|
311 User::RequestComplete(status,KErrArgument); |
|
312 return; |
|
313 } |
|
314 |
|
315 TInt setCaps; |
|
316 |
|
317 if (aFirstReq) |
|
318 setCaps = aSETCaps | KFirstReq; |
|
319 else |
|
320 setCaps = aSETCaps; |
|
321 |
|
322 TIpcArgs args; |
|
323 args.Set(0, setCaps); |
|
324 args.Set(1, aRequestId); |
|
325 |
|
326 SendReceive(ESuplTerminalSubssnAsyncRunsession, args, aStatus); |
|
327 } |
|
328 |
|
329 //---------------TDESC METHODS START HERE--------------------------------------- |
|
330 // --------------------------------------------------------- |
|
331 // RSuplTerminalSubSession::RunSession |
|
332 // |
|
333 // (other items were commented in a header). |
|
334 // --------------------------------------------------------- |
|
335 // |
|
336 EXPORT_C void RSuplTerminalSubSession::RunSession( |
|
337 TRequestStatus& aStatus, |
|
338 TSuplTerminalQop& aQop, |
|
339 const TDesC& aHslpAddress, |
|
340 TBool aFallBack, |
|
341 TInt aSETCaps, |
|
342 TInt aRequestId, |
|
343 TBool aFirstReq) |
|
344 { |
|
345 __ASSERT_ALWAYS(SubSessionHandle(), |
|
346 User::Panic(KSuplClientFault, ESuplServerBadHandle)); |
|
347 |
|
348 if(aRequestId < 0 ) |
|
349 { |
|
350 TRequestStatus *status = &aStatus; |
|
351 User::RequestComplete(status,KErrArgument); |
|
352 return; |
|
353 } |
|
354 |
|
355 if(aSETCaps < 0 ) |
|
356 { |
|
357 TRequestStatus *status = &aStatus; |
|
358 User::RequestComplete(status,KErrArgument); |
|
359 return; |
|
360 } |
|
361 |
|
362 if(aHslpAddress.Length() < 0 || aHslpAddress.Length() > KMaxHslpAddressLength ) |
|
363 { |
|
364 TRequestStatus *status = &aStatus; |
|
365 User::RequestComplete(status,KErrArgument); |
|
366 return; |
|
367 } |
|
368 |
|
369 //Check if the passed HSLPAddress exists or not! |
|
370 TInt serverExists = CheckIfSlpExists(aHslpAddress); |
|
371 if(serverExists != KErrNone) |
|
372 { |
|
373 TRequestStatus *status = &aStatus; |
|
374 User::RequestComplete(status,serverExists); |
|
375 return; |
|
376 } |
|
377 |
|
378 TReal32 aHorAcc,aVerAcc; |
|
379 TInt aDelay,aMaxAge; |
|
380 if((aQop.GetHorizontalAccuracy(aHorAcc)==KErrNotFound)&& |
|
381 (aQop.GetVerticalAccuracy(aVerAcc)==KErrNotFound)&& |
|
382 (aQop.GetDelay(aDelay)==KErrNotFound)&& |
|
383 (aQop.GetMaxLocationAge(aMaxAge)==KErrNotFound)) |
|
384 { |
|
385 TRequestStatus *status = &aStatus; |
|
386 User::RequestComplete(status,KErrArgument); |
|
387 return; |
|
388 } |
|
389 |
|
390 iSuplParameters.qop = aQop; |
|
391 iSuplParameters.HslpAddress = aHslpAddress; |
|
392 iSuplParameters.FallBack = aFallBack; |
|
393 |
|
394 iPtrHolder->Ptr(0).Set( |
|
395 reinterpret_cast<TUint8*>(&iSuplParameters), |
|
396 sizeof(iSuplParameters),sizeof(iSuplParameters)); |
|
397 |
|
398 TInt setCaps; |
|
399 |
|
400 if (aFirstReq) |
|
401 setCaps = aSETCaps | KFirstReq; |
|
402 else |
|
403 setCaps = aSETCaps; |
|
404 |
|
405 TIpcArgs args; |
|
406 |
|
407 args.Set(0, setCaps); |
|
408 args.Set(1,aRequestId); |
|
409 args.Set(2,&iPtrHolder->Ptr(0)); |
|
410 |
|
411 SendReceive(ESuplTerminalSubssnASyncRunsessionWithServernameQop, args, aStatus); |
|
412 } |
|
413 |
|
414 //-------------------2ND METHOD(SYNCHRONOUS)-------------------------- |
|
415 // --------------------------------------------------------- |
|
416 // RSuplTerminalSubSession::RunSession |
|
417 // |
|
418 // (other items were commented in a header). |
|
419 // --------------------------------------------------------- |
|
420 // |
|
421 EXPORT_C TInt RSuplTerminalSubSession::RunSession( |
|
422 TSuplTerminalQop& aQop, |
|
423 const TDesC& aHslpAddress, |
|
424 TBool aFallBack, |
|
425 TInt aSETCaps, |
|
426 TInt aRequestId, |
|
427 TBool aFirstReq) |
|
428 { |
|
429 __ASSERT_ALWAYS(SubSessionHandle(), |
|
430 User::Panic(KSuplClientFault, ESuplServerBadHandle)); |
|
431 |
|
432 if(aRequestId < 0 ) |
|
433 { |
|
434 return KErrArgument; |
|
435 } |
|
436 |
|
437 if(aSETCaps < 0 ) |
|
438 { |
|
439 return KErrArgument; |
|
440 } |
|
441 |
|
442 if(aHslpAddress.Length() < 0 || aHslpAddress.Length() > KMaxHslpAddressLength ) |
|
443 { |
|
444 return KErrArgument; |
|
445 } |
|
446 |
|
447 //Check if the passed HSLPAddress exists or not! |
|
448 TInt serverExists = CheckIfSlpExists(aHslpAddress); |
|
449 if(serverExists != KErrNone) |
|
450 { |
|
451 return serverExists; |
|
452 } |
|
453 |
|
454 TReal32 aHorAcc,aVerAcc; |
|
455 TInt aDelay,aMaxAge; |
|
456 if((aQop.GetHorizontalAccuracy(aHorAcc)==KErrNotFound) |
|
457 &&(aQop.GetVerticalAccuracy(aVerAcc)==KErrNotFound) |
|
458 &&(aQop.GetDelay(aDelay)==KErrNotFound) |
|
459 &&(aQop.GetMaxLocationAge(aMaxAge)==KErrNotFound)) |
|
460 { |
|
461 return KErrArgument; |
|
462 } |
|
463 |
|
464 iSuplParameters.qop = aQop; |
|
465 iSuplParameters.HslpAddress = aHslpAddress; |
|
466 iSuplParameters.FallBack = aFallBack; |
|
467 |
|
468 iPtrHolder->Ptr(0).Set( |
|
469 reinterpret_cast<TUint8*>(&iSuplParameters), |
|
470 sizeof(iSuplParameters),sizeof(iSuplParameters)); |
|
471 |
|
472 TInt setCaps; |
|
473 |
|
474 if (aFirstReq) |
|
475 setCaps = aSETCaps | KFirstReq; |
|
476 else |
|
477 setCaps = aSETCaps; |
|
478 |
|
479 TIpcArgs args; |
|
480 |
|
481 args.Set(0, setCaps); |
|
482 args.Set(1,aRequestId); |
|
483 args.Set(2,&iPtrHolder->Ptr(0)); |
|
484 return SendReceive(ESuplTerminalSubssnSyncRunsessionWithServernameQop, args); |
|
485 } |
|
486 |
|
487 //------------------------------ASYNC WITHOUT QOP-------------------------------------------------------------- |
|
488 // --------------------------------------------------------- |
|
489 // RSuplTerminalSubSession::RunSession |
|
490 // |
|
491 // (other items were commented in a header). |
|
492 // --------------------------------------------------------- |
|
493 // |
|
494 EXPORT_C void RSuplTerminalSubSession::RunSession( |
|
495 TRequestStatus& aStatus, |
|
496 const TDesC& aHslpAddress, |
|
497 TBool aFallBack, |
|
498 TInt aSETCaps, |
|
499 TInt aRequestId, |
|
500 TBool aFirstReq) |
|
501 { |
|
502 __ASSERT_ALWAYS(SubSessionHandle(), User::Panic(KSuplClientFault, ESuplServerBadHandle)); |
|
503 |
|
504 if(aRequestId < 0 ) |
|
505 { |
|
506 TRequestStatus *status = &aStatus; |
|
507 User::RequestComplete(status,KErrArgument); |
|
508 return; |
|
509 } |
|
510 |
|
511 if(aSETCaps < 0 ) |
|
512 { |
|
513 TRequestStatus *status = &aStatus; |
|
514 User::RequestComplete(status,KErrArgument); |
|
515 return; |
|
516 } |
|
517 |
|
518 if(aHslpAddress.Length() < 0 || aHslpAddress.Length() > KMaxHslpAddressLength ) |
|
519 { |
|
520 TRequestStatus *status = &aStatus; |
|
521 User::RequestComplete(status,KErrArgument); |
|
522 return; |
|
523 } |
|
524 |
|
525 //Check if the passed HSLPAddress exists or not! |
|
526 TInt serverExists = CheckIfSlpExists(aHslpAddress); |
|
527 if(serverExists != KErrNone) |
|
528 { |
|
529 TRequestStatus *status = &aStatus; |
|
530 User::RequestComplete(status,serverExists); |
|
531 return; |
|
532 } |
|
533 |
|
534 iSuplParameters.HslpAddress = aHslpAddress; |
|
535 iSuplParameters.FallBack = aFallBack; |
|
536 |
|
537 iPtrHolder->Ptr(0).Set( |
|
538 reinterpret_cast<TUint8*>(&iSuplParameters), |
|
539 sizeof(iSuplParameters),sizeof(iSuplParameters)); |
|
540 |
|
541 TInt setCaps; |
|
542 |
|
543 if (aFirstReq) |
|
544 setCaps = aSETCaps | KFirstReq; |
|
545 else |
|
546 setCaps = aSETCaps; |
|
547 |
|
548 TIpcArgs args; |
|
549 |
|
550 args.Set(0, setCaps); |
|
551 args.Set(1,aRequestId); |
|
552 args.Set(2,&iPtrHolder->Ptr(0)); |
|
553 SendReceive(ESuplTerminalSubssnASyncRunsessionServernameWithoutQop, args, aStatus); |
|
554 } |
|
555 |
|
556 //--------------------------------SYNC WITHOUT QOP-------------------------------------------------------- |
|
557 // --------------------------------------------------------- |
|
558 // RSuplTerminalSubSession::RunSession |
|
559 // |
|
560 // (other items were commented in a header). |
|
561 // --------------------------------------------------------- |
|
562 // |
|
563 EXPORT_C TInt RSuplTerminalSubSession::RunSession( |
|
564 const TDesC& aHslpAddress, |
|
565 TBool aFallBack, |
|
566 TInt aSETCaps, |
|
567 TInt aRequestId, |
|
568 TBool aFirstReq) |
|
569 { |
|
570 __ASSERT_ALWAYS(SubSessionHandle(), |
|
571 User::Panic(KSuplClientFault, ESuplServerBadHandle)); |
|
572 |
|
573 if(aRequestId < 0 ) |
|
574 { |
|
575 return KErrArgument; |
|
576 } |
|
577 |
|
578 if(aSETCaps < 0 ) |
|
579 { |
|
580 return KErrArgument; |
|
581 } |
|
582 |
|
583 if(aHslpAddress.Length() < 0 || aHslpAddress.Length() > KMaxHslpAddressLength ) |
|
584 { |
|
585 return KErrArgument; |
|
586 } |
|
587 |
|
588 //Check if the passed HSLPAddress exists or not! |
|
589 TInt serverExists = CheckIfSlpExists(aHslpAddress); |
|
590 if(serverExists != KErrNone) |
|
591 { |
|
592 return serverExists; |
|
593 } |
|
594 |
|
595 iSuplParameters.HslpAddress = aHslpAddress; |
|
596 iSuplParameters.FallBack = aFallBack; |
|
597 |
|
598 iPtrHolder->Ptr(0).Set( |
|
599 reinterpret_cast<TUint8*>(&iSuplParameters), |
|
600 sizeof(iSuplParameters),sizeof(iSuplParameters)); |
|
601 |
|
602 TInt setCaps; |
|
603 |
|
604 if (aFirstReq) |
|
605 setCaps = aSETCaps | KFirstReq; |
|
606 else |
|
607 setCaps = aSETCaps; |
|
608 |
|
609 TIpcArgs args; |
|
610 |
|
611 args.Set(0, setCaps); |
|
612 args.Set(1,aRequestId); |
|
613 args.Set(2,&iPtrHolder->Ptr(0)); |
|
614 return SendReceive(ESuplTerminalSubssnSyncRunsessionServernameWithoutQop, args); |
|
615 } |
|
616 |
|
617 // --------------------------------------------------------- |
|
618 // RSuplTerminalSubSession::RunSession |
|
619 // |
|
620 // (other items were commented in a header). |
|
621 // --------------------------------------------------------- |
|
622 // |
|
623 EXPORT_C void RSuplTerminalSubSession::RunSession( |
|
624 TRequestStatus& aStatus, |
|
625 TSuplTerminalQop& aQop, |
|
626 TInt aSETCaps, |
|
627 TInt aRequestId, |
|
628 TBool aFirstReq) |
|
629 { |
|
630 __ASSERT_ALWAYS(SubSessionHandle(), |
|
631 User::Panic(KSuplClientFault, ESuplServerBadHandle)); |
|
632 |
|
633 if(aRequestId < 0 ) |
|
634 { |
|
635 TRequestStatus *status = &aStatus; |
|
636 User::RequestComplete(status,KErrArgument); |
|
637 return; |
|
638 } |
|
639 |
|
640 if(aSETCaps < 0 ) |
|
641 { |
|
642 TRequestStatus *status = &aStatus; |
|
643 User::RequestComplete(status,KErrArgument); |
|
644 return; |
|
645 } |
|
646 |
|
647 TReal32 aHorAcc,aVerAcc; |
|
648 TInt aDelay,aMaxAge; |
|
649 if((aQop.GetHorizontalAccuracy(aHorAcc)==KErrNotFound) |
|
650 &&(aQop.GetVerticalAccuracy(aVerAcc)==KErrNotFound) |
|
651 &&(aQop.GetDelay(aDelay)==KErrNotFound) |
|
652 &&(aQop.GetMaxLocationAge(aMaxAge)==KErrNotFound)) |
|
653 { |
|
654 TRequestStatus *status = &aStatus; |
|
655 User::RequestComplete(status,KErrArgument); |
|
656 return; |
|
657 } |
|
658 |
|
659 iQoP = aQop; |
|
660 |
|
661 iPtrHolder->Ptr(0).Set( |
|
662 reinterpret_cast<TUint8*>(&iQoP), |
|
663 sizeof(iQoP),sizeof(iQoP)); |
|
664 |
|
665 TInt setCaps; |
|
666 |
|
667 if (aFirstReq) |
|
668 setCaps = aSETCaps | KFirstReq; |
|
669 else |
|
670 setCaps = aSETCaps; |
|
671 |
|
672 TIpcArgs args; |
|
673 |
|
674 args.Set(0, setCaps); |
|
675 args.Set(1,aRequestId); |
|
676 args.Set(2,&iPtrHolder->Ptr(0)); |
|
677 |
|
678 SendReceive(ESuplTerminalSubssnAsyncRunsessionWithQop, args, aStatus); |
|
679 } |
|
680 |
|
681 // --------------------------------------------------------- |
|
682 // RSuplTerminalSubSession::RunSession |
|
683 // |
|
684 // (other items were commented in a header). |
|
685 // --------------------------------------------------------- |
|
686 // |
|
687 EXPORT_C TInt RSuplTerminalSubSession::RunSession( |
|
688 TInt aSETCaps, |
|
689 TInt aRequestId, |
|
690 TBool aFirstReq) |
|
691 { |
|
692 __ASSERT_ALWAYS(SubSessionHandle(), |
|
693 User::Panic(KSuplClientFault, ESuplServerBadHandle)); |
|
694 |
|
695 if(aRequestId < 0 ) |
|
696 { |
|
697 return KErrArgument; |
|
698 } |
|
699 |
|
700 if(aSETCaps < 0 ) |
|
701 { |
|
702 return KErrArgument; |
|
703 } |
|
704 TInt setCaps; |
|
705 |
|
706 if (aFirstReq) |
|
707 setCaps = aSETCaps | KFirstReq; |
|
708 else |
|
709 setCaps = aSETCaps; |
|
710 |
|
711 TIpcArgs args; |
|
712 args.Set(0, setCaps); |
|
713 args.Set(1, aRequestId); |
|
714 return SendReceive(ESuplTerminalSubssnSyncRunsession, args); |
|
715 } |
|
716 |
|
717 // --------------------------------------------------------- |
|
718 // RSuplTerminalSubSession::RunSession |
|
719 // |
|
720 // (other items were commented in a header). |
|
721 // --------------------------------------------------------- |
|
722 // |
|
723 EXPORT_C TInt RSuplTerminalSubSession::RunSession( |
|
724 TSuplTerminalQop& aQop, |
|
725 TInt aSETCaps, |
|
726 TInt aRequestId, |
|
727 TBool aFirstReq) |
|
728 { |
|
729 __ASSERT_ALWAYS(SubSessionHandle(), |
|
730 User::Panic(KSuplClientFault, ESuplServerBadHandle)); |
|
731 |
|
732 if(aRequestId < 0 ) |
|
733 { |
|
734 return KErrArgument; |
|
735 } |
|
736 |
|
737 if(aSETCaps < 0 ) |
|
738 { |
|
739 return KErrArgument; |
|
740 } |
|
741 |
|
742 TReal32 aHorAcc,aVerAcc; |
|
743 TInt aDelay,aMaxAge; |
|
744 if((aQop.GetHorizontalAccuracy(aHorAcc)==KErrNotFound) |
|
745 &&(aQop.GetVerticalAccuracy(aVerAcc)==KErrNotFound) |
|
746 &&(aQop.GetDelay(aDelay)==KErrNotFound) |
|
747 &&(aQop.GetMaxLocationAge(aMaxAge)==KErrNotFound)) |
|
748 { |
|
749 return KErrArgument; |
|
750 } |
|
751 |
|
752 iQoP = aQop; |
|
753 |
|
754 TInt setCaps; |
|
755 |
|
756 if (aFirstReq) |
|
757 setCaps = aSETCaps | KFirstReq; |
|
758 else |
|
759 setCaps = aSETCaps; |
|
760 |
|
761 TIpcArgs args; |
|
762 TPtrC8 ptr( |
|
763 reinterpret_cast<const TUint8*>(&iQoP), |
|
764 sizeof(TSuplTerminalQop)); |
|
765 |
|
766 args.Set(0, setCaps); |
|
767 args.Set(1, aRequestId); |
|
768 args.Set(2,&ptr); |
|
769 |
|
770 return SendReceive(ESuplTerminalSubssnSyncRunsessionWithQop, args); |
|
771 } |
|
772 |
|
773 // --------------------------------------------------------- |
|
774 // RSuplTerminalSubSession::GetPosition |
|
775 // |
|
776 // (other items were commented in a header). |
|
777 // --------------------------------------------------------- |
|
778 // |
|
779 EXPORT_C TInt RSuplTerminalSubSession::GetPosition(TPositionInfoBase& aSuplPosInfo) |
|
780 { |
|
781 __ASSERT_ALWAYS(SubSessionHandle(), |
|
782 User::Panic(KSuplClientFault, ESuplServerBadHandle)); |
|
783 |
|
784 if( isTriggeringUsed ) |
|
785 { |
|
786 return KErrNotSupported; |
|
787 } |
|
788 |
|
789 iPtrHolder->Ptr(0).Set( |
|
790 reinterpret_cast<TUint8*>(&aSuplPosInfo), |
|
791 aSuplPosInfo.PositionClassSize(), |
|
792 aSuplPosInfo.PositionClassSize()); |
|
793 |
|
794 return SendReceive(ESuplTerminalSubssnGetPosition, TIpcArgs(&iPtrHolder->Ptr(0))); |
|
795 } |
|
796 |
|
797 // --------------------------------------------------------- |
|
798 // RSuplTerminalSubSession::GetServerAddress |
|
799 // |
|
800 // (other items were commented in a header). |
|
801 // --------------------------------------------------------- |
|
802 |
|
803 EXPORT_C TInt RSuplTerminalSubSession::GetServerAddress(TDes& aHslpAddress) |
|
804 { |
|
805 __ASSERT_ALWAYS(SubSessionHandle(), |
|
806 User::Panic(KSuplClientFault, ESuplServerBadHandle)); |
|
807 |
|
808 iPtrHolder->Ptr(0).Set( |
|
809 reinterpret_cast<TUint8*>(&aHslpAddress), |
|
810 aHslpAddress.MaxSize(), |
|
811 aHslpAddress.MaxSize() |
|
812 ); |
|
813 |
|
814 return SendReceive(ESuplTerminalSubssnGetServerAddress, |
|
815 TIpcArgs(&iPtrHolder->Ptr(0))); |
|
816 } |
|
817 |
|
818 //------------------------------------------------------------------------------------ |
|
819 |
|
820 // --------------------------------------------------------- |
|
821 // RSuplTerminalSubSession::GetSlpList |
|
822 // |
|
823 // (other items were commented in a header). |
|
824 // --------------------------------------------------------- |
|
825 EXPORT_C TInt RSuplTerminalSubSession::GetSlpList( |
|
826 RPointerArray<CSuplTerminalParams> &aParamValues) |
|
827 { |
|
828 __ASSERT_ALWAYS(SubSessionHandle(), |
|
829 User::Panic(KSuplClientFault, ESuplServerBadHandle)); |
|
830 |
|
831 RPointerArray<CServerParams> parValues; |
|
832 |
|
833 TInt64 slpId; |
|
834 HBufC* serverAddress = HBufC::New(KMaxBufLength); |
|
835 HBufC* iapName = HBufC::New(KMaxBufLength); |
|
836 TBool serverEnabled; |
|
837 TBool simChangeRemove; |
|
838 TBool usageInHomeNw; |
|
839 TBool editable; |
|
840 |
|
841 if (!serverAddress || !iapName) |
|
842 { |
|
843 return KErrNoMemory; |
|
844 } |
|
845 delete iSuplStorageSettings; |
|
846 iSuplStorageSettings = NULL; |
|
847 |
|
848 // create local object iSuplStorageSettings |
|
849 TRAPD(err,iSuplStorageSettings = CSuplSettings::NewL()); |
|
850 if(err!=KErrNone) |
|
851 { |
|
852 delete serverAddress; |
|
853 delete iapName; |
|
854 parValues.Close(); |
|
855 parValues.ResetAndDestroy(); |
|
856 return err; |
|
857 } |
|
858 |
|
859 parValues.ResetAndDestroy(); |
|
860 aParamValues.ResetAndDestroy(); |
|
861 TInt error = iSuplStorageSettings->GetAllSlp(parValues); //handle return value... |
|
862 if (error!=KErrNone) |
|
863 { |
|
864 delete serverAddress; |
|
865 delete iapName; |
|
866 parValues.Close(); |
|
867 parValues.ResetAndDestroy(); |
|
868 return error; |
|
869 } |
|
870 TInt count = parValues.Count(); |
|
871 for(TInt i = 0; i < count; i++ ) |
|
872 { |
|
873 CSuplTerminalParams *params = NULL; |
|
874 TRAPD(err,params = CSuplTerminalParams::NewL()); |
|
875 if(err!=KErrNone) |
|
876 { |
|
877 delete serverAddress; |
|
878 delete iapName; |
|
879 parValues.Close(); |
|
880 parValues.ResetAndDestroy(); |
|
881 return err; |
|
882 } |
|
883 parValues[i]->Get( |
|
884 slpId, |
|
885 serverAddress->Des(), |
|
886 iapName->Des(), |
|
887 serverEnabled, |
|
888 simChangeRemove, |
|
889 usageInHomeNw, |
|
890 editable); |
|
891 |
|
892 params->Set( |
|
893 *serverAddress, |
|
894 *iapName, |
|
895 serverEnabled, |
|
896 simChangeRemove, |
|
897 usageInHomeNw, |
|
898 editable, |
|
899 slpId); |
|
900 |
|
901 aParamValues.Append(params); |
|
902 } |
|
903 delete serverAddress; |
|
904 delete iapName; |
|
905 aParamValues.Close(); |
|
906 if (iSuplStorageSettings) |
|
907 { |
|
908 delete iSuplStorageSettings; |
|
909 iSuplStorageSettings = NULL; |
|
910 } |
|
911 |
|
912 return KErrNone; |
|
913 } |
|
914 |
|
915 //------------------------------------------------------------------------------------ |
|
916 |
|
917 |
|
918 // --------------------------------------------------------- |
|
919 // RSuplTerminalSubSession::CheckIfSlpExists |
|
920 // |
|
921 // (other items were commented in a header). |
|
922 // --------------------------------------------------------- |
|
923 |
|
924 TInt RSuplTerminalSubSession::CheckIfSlpExists(const TDesC& aHslpAddress) |
|
925 { |
|
926 if(iSuplStorageSettings) |
|
927 { |
|
928 delete iSuplStorageSettings; |
|
929 iSuplStorageSettings = NULL; |
|
930 } |
|
931 |
|
932 //Check if the passed HSLPAddress exists or not! |
|
933 TRAPD(err1,iSuplStorageSettings = CSuplSettings::NewL()); |
|
934 if(err1!=KErrNone) |
|
935 { |
|
936 return err1; |
|
937 } |
|
938 CServerParams *paramValues = NULL; |
|
939 TRAPD(err,paramValues = CServerParams::NewL()); |
|
940 if(err!=KErrNone) |
|
941 { |
|
942 delete iSuplStorageSettings; |
|
943 iSuplStorageSettings = NULL; |
|
944 return err; |
|
945 } |
|
946 TInt retValue = iSuplStorageSettings->GetSlpInfoAddress(aHslpAddress,paramValues); |
|
947 |
|
948 if(retValue == KErrNotFound) |
|
949 { |
|
950 delete iSuplStorageSettings; |
|
951 iSuplStorageSettings = NULL; |
|
952 delete paramValues; |
|
953 paramValues = NULL; |
|
954 return KErrNotFound; |
|
955 } |
|
956 delete paramValues; |
|
957 paramValues = NULL; |
|
958 |
|
959 delete iSuplStorageSettings; |
|
960 iSuplStorageSettings = NULL; |
|
961 |
|
962 return KErrNone; |
|
963 } |
|
964 |
|
965 // --------------------------------------------------------- |
|
966 // RSuplTerminalSubSession::CancelRunSession |
|
967 // |
|
968 // (other items were commented in a header). |
|
969 // --------------------------------------------------------- |
|
970 // |
|
971 EXPORT_C void RSuplTerminalSubSession::CancelRunSession() |
|
972 { |
|
973 __ASSERT_ALWAYS(SubSessionHandle(), |
|
974 User::Panic(KSuplClientFault, ESuplServerBadHandle)); |
|
975 |
|
976 if( !isTriggeringUsed ) |
|
977 { |
|
978 SendReceive(ESuplTerminalSubssnCancelRunsession); |
|
979 } |
|
980 } |
|
981 |
|
982 // --------------------------------------------------------- |
|
983 // RSuplTerminalSubSession::Close |
|
984 // |
|
985 // (other items were commented in a header). |
|
986 // --------------------------------------------------------- |
|
987 // |
|
988 EXPORT_C void RSuplTerminalSubSession::Close() |
|
989 { |
|
990 CloseSubSession(ESuplTerminalSubssnClose); |
|
991 //Destruct(); |
|
992 } |
|
993 |
|
994 // --------------------------------------------------------- |
|
995 // This method is used to allow polymorphic extensions to the API without breaking |
|
996 // BC. See documentation for explanation. |
|
997 // |
|
998 // @publishedAll |
|
999 // @param aFunctionNumber contains the Id of the function to be invoked. |
|
1000 // @param aPtr1 a pointer to any data |
|
1001 // @param aPtr2 a pointer to any data. |
|
1002 // --------------------------------------------------------- |
|
1003 // |
|
1004 EXPORT_C TAny* RSuplTerminalSubSession::ExtendedInterface(TInt /* aFunctionNumber */, |
|
1005 TAny* /* aPtr1 */, |
|
1006 TAny* /* aPtr2 */) |
|
1007 { |
|
1008 return NULL; |
|
1009 } |
|
1010 |
|
1011 // --------------------------------------------------------- |
|
1012 // RSuplTerminalSubSession::StartSuplTriggerSession |
|
1013 // without supl server address |
|
1014 // (other items were commented in a header). |
|
1015 // --------------------------------------------------------- |
|
1016 // |
|
1017 EXPORT_C void RSuplTerminalSubSession::StartSuplTriggerSession( |
|
1018 TRequestStatus& aStatus, |
|
1019 TSuplTerminalPeriodicTrigger& aPeriodicTrigger, |
|
1020 TInt aSETCaps, |
|
1021 TInt aRequestId |
|
1022 ) |
|
1023 { |
|
1024 __ASSERT_ALWAYS(SubSessionHandle(), |
|
1025 User::Panic(KSuplClientFault, ESuplServerBadHandle)); |
|
1026 |
|
1027 if( iSuplService != ESUPL_2_0 ) |
|
1028 { |
|
1029 TRequestStatus *status = &aStatus; |
|
1030 User::RequestComplete(status,KErrNotSupported); |
|
1031 return; |
|
1032 } |
|
1033 |
|
1034 if(aRequestId < 0 ) |
|
1035 { |
|
1036 TRequestStatus *status = &aStatus; |
|
1037 User::RequestComplete(status,KErrArgument); |
|
1038 return; |
|
1039 } |
|
1040 |
|
1041 if(aSETCaps < 0 ) |
|
1042 { |
|
1043 TRequestStatus *status = &aStatus; |
|
1044 User::RequestComplete(status,KErrArgument); |
|
1045 return; |
|
1046 } |
|
1047 |
|
1048 TUint noOfFixes, interval, startTime; |
|
1049 if( aPeriodicTrigger.Get(noOfFixes,interval,startTime) != KErrNone ) |
|
1050 { |
|
1051 TRequestStatus *status = &aStatus; |
|
1052 User::RequestComplete(status,KErrArgument); |
|
1053 return; |
|
1054 } |
|
1055 |
|
1056 iPeriodicTrigger = aPeriodicTrigger; |
|
1057 |
|
1058 iPtrHolder->Ptr(0).Set( |
|
1059 reinterpret_cast<TUint8*>(&iPeriodicTrigger), |
|
1060 sizeof(iPeriodicTrigger),sizeof(iPeriodicTrigger)); |
|
1061 |
|
1062 TIpcArgs args; |
|
1063 |
|
1064 args.Set(0, aSETCaps); |
|
1065 args.Set(1, aRequestId); |
|
1066 args.Set(2, &iPtrHolder->Ptr(0)); |
|
1067 |
|
1068 isTriggeringUsed = ETrue; |
|
1069 |
|
1070 // resetting the counter |
|
1071 iNotifyRequestCtr = 0; |
|
1072 |
|
1073 return SendReceive( |
|
1074 ESuplTerminalSubssnStartPeriodicTrigger, args, aStatus); |
|
1075 } |
|
1076 |
|
1077 // --------------------------------------------------------- |
|
1078 // RSuplTerminalSubSession::StartSuplTriggerSession |
|
1079 // with supl server address |
|
1080 // (other items were commented in a header). |
|
1081 // --------------------------------------------------------- |
|
1082 // |
|
1083 EXPORT_C void RSuplTerminalSubSession::StartSuplTriggerSession( |
|
1084 TRequestStatus& aStatus, |
|
1085 TSuplTerminalPeriodicTrigger& aPeriodicTrigger, |
|
1086 const TDesC& aHslpAddress, |
|
1087 TBool aFallBack, |
|
1088 TInt aSETCaps, |
|
1089 TInt aRequestId |
|
1090 ) |
|
1091 { |
|
1092 __ASSERT_ALWAYS(SubSessionHandle(), |
|
1093 User::Panic(KSuplClientFault, ESuplServerBadHandle)); |
|
1094 |
|
1095 if( iSuplService != ESUPL_2_0 ) |
|
1096 { |
|
1097 TRequestStatus *status = &aStatus; |
|
1098 User::RequestComplete(status,KErrNotSupported); |
|
1099 return; |
|
1100 } |
|
1101 |
|
1102 if(aRequestId < 0 ) |
|
1103 { |
|
1104 TRequestStatus *status = &aStatus; |
|
1105 User::RequestComplete(status,KErrArgument); |
|
1106 return; |
|
1107 } |
|
1108 |
|
1109 if(aSETCaps < 0 ) |
|
1110 { |
|
1111 TRequestStatus *status = &aStatus; |
|
1112 User::RequestComplete(status,KErrArgument); |
|
1113 return; |
|
1114 } |
|
1115 |
|
1116 TUint noOfFixes, interval, startTime; |
|
1117 if( aPeriodicTrigger.Get(noOfFixes,interval,startTime) != KErrNone ) |
|
1118 { |
|
1119 TRequestStatus *status = &aStatus; |
|
1120 User::RequestComplete(status,KErrArgument); |
|
1121 return; |
|
1122 } |
|
1123 |
|
1124 if(aHslpAddress.Length() < 0 || aHslpAddress.Length() > KMaxHslpAddressLength ) |
|
1125 { |
|
1126 TRequestStatus *status = &aStatus; |
|
1127 User::RequestComplete(status,KErrArgument); |
|
1128 return; |
|
1129 } |
|
1130 |
|
1131 //Check if the passed HSLPAddress exists or not! |
|
1132 TInt serverExists = CheckIfSlpExists(aHslpAddress); |
|
1133 if(serverExists != KErrNone) |
|
1134 { |
|
1135 TRequestStatus *status = &aStatus; |
|
1136 User::RequestComplete(status,serverExists); |
|
1137 return; |
|
1138 } |
|
1139 |
|
1140 iSuplParameters.PeriodicTrigger = aPeriodicTrigger; |
|
1141 iSuplParameters.HslpAddress = aHslpAddress; |
|
1142 iSuplParameters.FallBack = aFallBack; |
|
1143 |
|
1144 iPeriodicTrigger = aPeriodicTrigger; |
|
1145 |
|
1146 iPtrHolder->Ptr(0).Set( |
|
1147 reinterpret_cast<TUint8*>(&iSuplParameters), |
|
1148 sizeof(iSuplParameters),sizeof(iSuplParameters)); |
|
1149 |
|
1150 TIpcArgs args; |
|
1151 |
|
1152 args.Set(0, aSETCaps); |
|
1153 args.Set(1, aRequestId); |
|
1154 args.Set(2, &iPtrHolder->Ptr(0)); |
|
1155 |
|
1156 isTriggeringUsed = ETrue; |
|
1157 // resetting the counter |
|
1158 iNotifyRequestCtr = 0; |
|
1159 |
|
1160 return SendReceive( |
|
1161 ESuplTerminalSubssnStartPeriodicTriggerWithServer, args, aStatus); |
|
1162 } |
|
1163 |
|
1164 // --------------------------------------------------------- |
|
1165 // RSuplTerminalSubSession::StopSuplTriggerring |
|
1166 // |
|
1167 // (other items were commented in a header). |
|
1168 // --------------------------------------------------------- |
|
1169 // |
|
1170 EXPORT_C void RSuplTerminalSubSession::StopSuplTriggerSession() |
|
1171 { |
|
1172 __ASSERT_ALWAYS(SubSessionHandle(), |
|
1173 User::Panic(KSuplClientFault, ESuplServerBadHandle)); |
|
1174 if( isTriggeringUsed ) |
|
1175 { |
|
1176 SendReceive(ESuplTerminalSubssnStopTriggerSession); |
|
1177 isTriggeringUsed = EFalse; |
|
1178 } |
|
1179 } |
|
1180 |
|
1181 // --------------------------------------------------------- |
|
1182 // RSuplTerminalSubSession::NotifyTriggerFired |
|
1183 // |
|
1184 // (other items were commented in a header). |
|
1185 // --------------------------------------------------------- |
|
1186 // |
|
1187 EXPORT_C void RSuplTerminalSubSession::NotifyTriggerFired( |
|
1188 TRequestStatus& aStatus, |
|
1189 TSuplTriggerFireInfo& aFireInfo) |
|
1190 { |
|
1191 __ASSERT_ALWAYS(SubSessionHandle(), |
|
1192 User::Panic(KSuplClientFault, ESuplServerBadHandle)); |
|
1193 |
|
1194 if( iSuplService != ESUPL_2_0 ) |
|
1195 { |
|
1196 TRequestStatus *status = &aStatus; |
|
1197 User::RequestComplete(status,KErrNotSupported); |
|
1198 return; |
|
1199 } |
|
1200 |
|
1201 if ( !isTriggeringUsed ) |
|
1202 { |
|
1203 TRequestStatus *status = &aStatus; |
|
1204 User::RequestComplete(status,KErrNotFound); |
|
1205 return; |
|
1206 } |
|
1207 |
|
1208 TUint noOfFixes,interval,startTime; |
|
1209 if( iPeriodicTrigger.Get(noOfFixes,interval,startTime) != KErrNone ) |
|
1210 { |
|
1211 if( iNotifyRequestCtr >= noOfFixes ) |
|
1212 { |
|
1213 TRequestStatus *status = &aStatus; |
|
1214 User::RequestComplete(status,KErrNotFound); |
|
1215 return; |
|
1216 } |
|
1217 } |
|
1218 |
|
1219 aStatus=KRequestPending; |
|
1220 |
|
1221 TIpcArgs args; |
|
1222 |
|
1223 TPckg<TSuplTriggerFireInfo> fireInfo(aFireInfo); |
|
1224 |
|
1225 iPtrHolder->Ptr(0).Set(fireInfo); |
|
1226 args.Set(2, &iPtrHolder->Ptr(0)); |
|
1227 |
|
1228 iNotifyRequestCtr++; |
|
1229 |
|
1230 SendReceive(ESuplTerminalSubssnNotifyTriggerFired, args, aStatus); |
|
1231 } |
|
1232 |
|
1233 // end of file |