|
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 "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-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 @file ctlbsclientgetlkpao.cpp |
|
20 */ |
|
21 |
|
22 #include "ctlbsclientgetlkpao.h" |
|
23 #include <lbs.h> |
|
24 |
|
25 _LIT(KGetLastKnownPosAO, "GetLastKnownPosAO"); |
|
26 |
|
27 CT_LbsClientGetLastKnownPosAO::~CT_LbsClientGetLastKnownPosAO() |
|
28 /** |
|
29 * Destructor |
|
30 */ |
|
31 { |
|
32 Cancel(); |
|
33 } |
|
34 |
|
35 |
|
36 |
|
37 CT_LbsClientGetLastKnownPosAO::CT_LbsClientGetLastKnownPosAO(MT_GetLastKnownPosObserver& aCaller) : CActive(EPriorityIdle), iCaller(aCaller) |
|
38 /** |
|
39 * Constructor - will not leave |
|
40 */ |
|
41 { |
|
42 CActiveScheduler::Add(this); |
|
43 } |
|
44 |
|
45 |
|
46 CT_LbsClientGetLastKnownPosAO* CT_LbsClientGetLastKnownPosAO::NewL(MT_GetLastKnownPosObserver& aUser) |
|
47 /** |
|
48 * 'public constructor' may leave |
|
49 */ |
|
50 { |
|
51 CT_LbsClientGetLastKnownPosAO* self = new(ELeave)CT_LbsClientGetLastKnownPosAO(aUser); |
|
52 |
|
53 return self; |
|
54 } |
|
55 |
|
56 |
|
57 void CT_LbsClientGetLastKnownPosAO::GetLastKnownPosL(RPositioner& aPositioner, TPositionInfo& aPosInfo) |
|
58 /** |
|
59 * wrapper for async positioner function GetLastKnownPosition(). |
|
60 * Will panic if there's another outstanding request. |
|
61 */ |
|
62 { |
|
63 __ASSERT_ALWAYS(!IsActive(), User::Panic(KGetLastKnownPosAO, KErrInUse)); |
|
64 |
|
65 iPositioner = aPositioner; |
|
66 |
|
67 // TO DO: this requestor stuff will be removed when we're using the real Location Server: |
|
68 User::LeaveIfError(iPositioner.SetRequestor( CRequestor::ERequestorService, |
|
69 CRequestor::EFormatApplication, |
|
70 _L("Tom Tom"))); |
|
71 |
|
72 iRequestId = EPositionerGetLastKnownPosition; // required for cancel |
|
73 |
|
74 // Make async call |
|
75 aPositioner.GetLastKnownPosition(aPosInfo, iStatus); |
|
76 |
|
77 // Let the active scheduler know we're waiting (active) |
|
78 SetActive(); |
|
79 } |
|
80 |
|
81 void CT_LbsClientGetLastKnownPosAO::DoCancel() |
|
82 { |
|
83 iPositioner.CancelRequest(iRequestId); |
|
84 } |
|
85 |
|
86 void CT_LbsClientGetLastKnownPosAO::RunL() |
|
87 { |
|
88 // iStatus will contain error code eg KErrUnknown if no position cached |
|
89 // async request completed. Notify caller via callback: |
|
90 iCaller.GetLastKnownPositionCallback(iStatus); |
|
91 } |
|
92 |
|
93 TInt CT_LbsClientGetLastKnownPosAO::RunError(TInt aError) |
|
94 { // called if RunL leaves. aError contains the error code |
|
95 return aError; |
|
96 } |
|
97 // EOF |
|
98 |