|
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 // ao wrapper around the a-gps mgr function NotifyPositionUpdate |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file ctlbsx3pdotransmitpos.cpp |
|
20 */ |
|
21 |
|
22 #include <lbs/lbsx3p.h> |
|
23 |
|
24 #include "ctlbsx3pdotransmitpos.h" |
|
25 |
|
26 |
|
27 CT_LbsX3PDoTransmitPos* CT_LbsX3PDoTransmitPos::NewL(MT_LbsX3PDoTransmitPosObserver* aObserver, RLbsTransmitPosition& aPositionTransmitter) |
|
28 /** |
|
29 * 'public constructor' may leave |
|
30 */ |
|
31 { |
|
32 CT_LbsX3PDoTransmitPos* doTransmitPos = new(ELeave)CT_LbsX3PDoTransmitPos(aObserver, aPositionTransmitter); |
|
33 CleanupStack::PushL(doTransmitPos); |
|
34 doTransmitPos->ConstructL(); |
|
35 CleanupStack::Pop(doTransmitPos); |
|
36 |
|
37 return doTransmitPos; |
|
38 } |
|
39 |
|
40 |
|
41 CT_LbsX3PDoTransmitPos::CT_LbsX3PDoTransmitPos(MT_LbsX3PDoTransmitPosObserver* aObserver, RLbsTransmitPosition& aPositionTransmitter) : CActive(EPriorityStandard), iObserver(aObserver), iPositionTransmitter(aPositionTransmitter) |
|
42 /** |
|
43 * Constructor - will not leave |
|
44 */ |
|
45 { |
|
46 CActiveScheduler::Add(this); |
|
47 } |
|
48 |
|
49 |
|
50 void CT_LbsX3PDoTransmitPos::ConstructL() |
|
51 { |
|
52 iRefLocWaiter = CT_LbsX3pRefLocWaiter::NewL(iObserver); |
|
53 } |
|
54 |
|
55 |
|
56 CT_LbsX3PDoTransmitPos::~CT_LbsX3PDoTransmitPos() |
|
57 /** |
|
58 * Destructor |
|
59 */ |
|
60 { |
|
61 Cancel(); |
|
62 delete iRefLocWaiter; |
|
63 iPositionTransmitter.Close(); |
|
64 } |
|
65 |
|
66 void CT_LbsX3PDoTransmitPos::TransmitPosition(const TDesC& aDestinationID, TUint aTransmitPriority, TPositionInfo & aTransmittedPosInfo) |
|
67 /** |
|
68 * wrapper for async function RLbsPositionUpdates::NotifyPositionUpdate(). |
|
69 * Will panic if there's another outstanding request. |
|
70 */ |
|
71 { |
|
72 __ASSERT_ALWAYS(!IsActive(), User::Panic(KCT_LbsX3PDoTransmitPos, KErrInUse)); |
|
73 |
|
74 // Invoke the position update. |
|
75 iPositionTransmitter.TransmitPosition(aDestinationID, aTransmitPriority, iStatus, aTransmittedPosInfo); |
|
76 SetActive(); |
|
77 } |
|
78 |
|
79 void CT_LbsX3PDoTransmitPos::TransmitPositionReportingRefLoc(const TDesC& aDestinationID, TUint aTransmitPriority, TPositionInfo & aTransmittedPosInfo) |
|
80 /** |
|
81 * wrapper for async function RLbsPositionUpdates::NotifyPositionUpdate(). |
|
82 * Will panic if there's another outstanding request. |
|
83 */ |
|
84 { |
|
85 __ASSERT_ALWAYS(!IsActive(), User::Panic(KCT_LbsX3PDoTransmitPos, KErrInUse)); |
|
86 |
|
87 // Invoke the position update. |
|
88 iPositionTransmitter.TransmitPosition(aDestinationID, aTransmitPriority, iRefLocWaiter->iStatus, iRefLocWaiter->iRefPosInfo, iStatus, aTransmittedPosInfo); |
|
89 iRefLocWaiter->Activate(); |
|
90 SetActive(); |
|
91 } |
|
92 |
|
93 void CT_LbsX3PDoTransmitPos::DoCancel() |
|
94 { |
|
95 iPositionTransmitter.CancelTransmitPosition(); |
|
96 } |
|
97 |
|
98 void CT_LbsX3PDoTransmitPos::RunL() |
|
99 { |
|
100 // iStatus will contain error code |
|
101 // async request completed. Notify caller via callback: |
|
102 if (iObserver) |
|
103 { |
|
104 iObserver->MT_LbsX3PDoTransmitPosCallback(iStatus, this); |
|
105 } |
|
106 } |
|
107 |
|
108 TInt CT_LbsX3PDoTransmitPos::RunError(TInt aError) |
|
109 { |
|
110 return aError; |
|
111 } |
|
112 |
|
113 |
|
114 |
|
115 CT_LbsX3pRefLocWaiter* CT_LbsX3pRefLocWaiter::NewL(MT_LbsX3PDoTransmitPosObserver* aObserver) |
|
116 { |
|
117 CT_LbsX3pRefLocWaiter* self = new(ELeave)CT_LbsX3pRefLocWaiter(aObserver); |
|
118 CleanupStack::PushL(self); |
|
119 self->ConstructL(); |
|
120 CleanupStack::Pop(self); |
|
121 return self; |
|
122 } |
|
123 |
|
124 CT_LbsX3pRefLocWaiter::CT_LbsX3pRefLocWaiter(MT_LbsX3PDoTransmitPosObserver* aObserver):CActive(EPriorityStandard), |
|
125 iObserver(aObserver) |
|
126 { |
|
127 CActiveScheduler::Add(this); |
|
128 } |
|
129 |
|
130 void CT_LbsX3pRefLocWaiter::ConstructL() |
|
131 { |
|
132 } |
|
133 |
|
134 CT_LbsX3pRefLocWaiter::~CT_LbsX3pRefLocWaiter() |
|
135 { |
|
136 Cancel(); |
|
137 } |
|
138 |
|
139 void CT_LbsX3pRefLocWaiter::RunL() |
|
140 { |
|
141 // Let the test know the returned status and the position in iRefPosInfo, |
|
142 // which is the Reference Location if the iStatus is KErrNone. |
|
143 if (iObserver) |
|
144 { |
|
145 iObserver->MT_LbsX3PDoRefPosCallback(iStatus, iRefPosInfo); |
|
146 } |
|
147 } |
|
148 |
|
149 void CT_LbsX3pRefLocWaiter::DoCancel() |
|
150 { |
|
151 // Nothing to do. The ref loc request is cancelled when |
|
152 // TransmitPosition is cancelled. |
|
153 } |
|
154 |
|
155 TInt CT_LbsX3pRefLocWaiter::RunError(TInt aError) |
|
156 { |
|
157 return aError; |
|
158 } |
|
159 |
|
160 void CT_LbsX3pRefLocWaiter::Activate() |
|
161 { |
|
162 __ASSERT_ALWAYS(!IsActive(), User::Panic(KCT_LbsX3PDoTransmitPos, KErrInUse)); |
|
163 SetActive(); |
|
164 } |