|
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 // This is the class implementation for the Notify position update tests |
|
15 // TODO - should this be moved somewhere more central (testutils, say)? |
|
16 // |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 /** |
|
22 @file ctlbsclientnotifyposupdao.cpp |
|
23 */ |
|
24 |
|
25 #include "ctlbsclientnotifyposupdao.h" |
|
26 #include <lbs.h> |
|
27 #include <lbsadmin.h> |
|
28 |
|
29 _LIT(KNotifyPosUpdAO, "NotifyPosUpdAO"); |
|
30 |
|
31 CT_LbsClientNotifyPosUpdAO::~CT_LbsClientNotifyPosUpdAO() |
|
32 /** |
|
33 * Destructor |
|
34 */ |
|
35 { |
|
36 Cancel(); |
|
37 } |
|
38 |
|
39 |
|
40 |
|
41 CT_LbsClientNotifyPosUpdAO::CT_LbsClientNotifyPosUpdAO(MT_NotifyPosUpdateObserver& aCaller) : CActive(EPriorityIdle), iCaller(aCaller) |
|
42 /** |
|
43 * Constructor - will not leave |
|
44 */ |
|
45 { |
|
46 CActiveScheduler::Add(this); |
|
47 } |
|
48 |
|
49 |
|
50 CT_LbsClientNotifyPosUpdAO* CT_LbsClientNotifyPosUpdAO::NewL(MT_NotifyPosUpdateObserver& aCaller) |
|
51 /** |
|
52 * 'public constructor' may leave |
|
53 */ |
|
54 { |
|
55 CT_LbsClientNotifyPosUpdAO* me = new(ELeave)CT_LbsClientNotifyPosUpdAO(aCaller); |
|
56 |
|
57 return me; |
|
58 } |
|
59 |
|
60 |
|
61 void CT_LbsClientNotifyPosUpdAO::NotifyPosUpdateL(RPositioner& aPositioner, TPositionInfo& aPosInfo) |
|
62 /** |
|
63 * wrapper for async positioner function NotifyPositionUpdate(). |
|
64 * Will panic if there's another outstanding request. |
|
65 */ |
|
66 { |
|
67 __ASSERT_ALWAYS(!IsActive(), User::Panic(KNotifyPosUpdAO, KErrInUse)); |
|
68 |
|
69 iPositioner = aPositioner; |
|
70 iRequestId = EPositionerNotifyPositionUpdate; // required for cancel |
|
71 |
|
72 // TO DO: this requestor stuff will be removed when we're using the real Location Server: |
|
73 User::LeaveIfError(iPositioner.SetRequestor(CRequestor::ERequestorService, |
|
74 CRequestor::EFormatApplication, |
|
75 _L("Tom Tom"))); |
|
76 |
|
77 |
|
78 // Make async call |
|
79 aPositioner.NotifyPositionUpdate(aPosInfo, iStatus); |
|
80 |
|
81 // Let the active scheduler know we're waiting (active) |
|
82 SetActive(); |
|
83 } |
|
84 |
|
85 void CT_LbsClientNotifyPosUpdAO::DoCancel() |
|
86 { |
|
87 TInt err = iPositioner.CancelRequest(iRequestId); |
|
88 } |
|
89 |
|
90 |
|
91 void CT_LbsClientNotifyPosUpdAO::RunL() |
|
92 { |
|
93 // iStatus will contain error code eg KErrUnknown if no position cached |
|
94 // async request completed. Notify caller via callback: |
|
95 iCaller.NotifyPositionUpdateCallback(iStatus); |
|
96 } |
|
97 |
|
98 TInt CT_LbsClientNotifyPosUpdAO::RunError(TInt aError) |
|
99 { // called if RunL leaves. aError contains the error code |
|
100 return aError; |
|
101 } |
|
102 // EOF |