|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Symbian Foundation License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // TODO - should this be moved somewhere more central (testutils, say)? |
|
15 // |
|
16 // |
|
17 |
|
18 |
|
19 |
|
20 /** |
|
21 @file ctlbsclientgetlkpao.cpp |
|
22 */ |
|
23 |
|
24 #include "ctlbsclientgetlkpao.h" |
|
25 #include <lbs.h> |
|
26 |
|
27 _LIT(KGetLastKnownPosAO, "GetLastKnownPosAO"); |
|
28 |
|
29 CT_LbsClientGetLastKnownPosAO::~CT_LbsClientGetLastKnownPosAO() |
|
30 /** |
|
31 * Destructor |
|
32 */ |
|
33 { |
|
34 Cancel(); |
|
35 } |
|
36 |
|
37 |
|
38 |
|
39 CT_LbsClientGetLastKnownPosAO::CT_LbsClientGetLastKnownPosAO(MT_GetLastKnownPosObserver& aCaller) : CActive(EPriorityIdle), iCaller(aCaller) |
|
40 /** |
|
41 * Constructor - will not leave |
|
42 */ |
|
43 { |
|
44 CActiveScheduler::Add(this); |
|
45 } |
|
46 |
|
47 |
|
48 CT_LbsClientGetLastKnownPosAO* CT_LbsClientGetLastKnownPosAO::NewL(MT_GetLastKnownPosObserver& aUser) |
|
49 /** |
|
50 * 'public constructor' may leave |
|
51 */ |
|
52 { |
|
53 CT_LbsClientGetLastKnownPosAO* self = new(ELeave)CT_LbsClientGetLastKnownPosAO(aUser); |
|
54 |
|
55 return self; |
|
56 } |
|
57 |
|
58 |
|
59 void CT_LbsClientGetLastKnownPosAO::GetLastKnownPosL(RPositioner& aPositioner, TPositionInfo& aPosInfo) |
|
60 /** |
|
61 * wrapper for async positioner function GetLastKnownPosition(). |
|
62 * Will panic if there's another outstanding request. |
|
63 */ |
|
64 { |
|
65 __ASSERT_ALWAYS(!IsActive(), User::Panic(KGetLastKnownPosAO, KErrInUse)); |
|
66 |
|
67 iPositioner = aPositioner; |
|
68 |
|
69 // TO DO: this requestor stuff will be removed when we're using the real Location Server: |
|
70 User::LeaveIfError(iPositioner.SetRequestor( CRequestor::ERequestorService, |
|
71 CRequestor::EFormatApplication, |
|
72 _L("Tom Tom"))); |
|
73 |
|
74 iRequestId = EPositionerGetLastKnownPosition; // required for cancel |
|
75 |
|
76 // Make async call |
|
77 aPositioner.GetLastKnownPosition(aPosInfo, iStatus); |
|
78 |
|
79 // Let the active scheduler know we're waiting (active) |
|
80 SetActive(); |
|
81 } |
|
82 |
|
83 void CT_LbsClientGetLastKnownPosAO::DoCancel() |
|
84 { |
|
85 iPositioner.CancelRequest(iRequestId); |
|
86 } |
|
87 |
|
88 void CT_LbsClientGetLastKnownPosAO::RunL() |
|
89 { |
|
90 // iStatus will contain error code eg KErrUnknown if no position cached |
|
91 // async request completed. Notify caller via callback: |
|
92 iCaller.GetLastKnownPositionCallback(iStatus); |
|
93 } |
|
94 |
|
95 TInt CT_LbsClientGetLastKnownPosAO::RunError(TInt aError) |
|
96 { // called if RunL leaves. aError contains the error code |
|
97 return aError; |
|
98 } |
|
99 // EOF |