|
1 // Copyright (c) 2001-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 // |
|
15 |
|
16 |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "ctlbsportedstepbase.h" |
|
20 #include "ctlbsclientrequestor.h" |
|
21 #include "mctlbsrequestobserver.h" |
|
22 |
|
23 // CONSTANTS |
|
24 |
|
25 // ================= MEMBER FUNCTIONS ======================= |
|
26 |
|
27 // Two-phased constructor. |
|
28 CT_LbsClientRequestor* CT_LbsClientRequestor::NewL( |
|
29 TUid aPsyUid, |
|
30 MCT_LbsRequestObserver* aObserver, |
|
31 const TDesC& aClientName, |
|
32 CTestExecuteLogger& aLogger |
|
33 ) |
|
34 { |
|
35 CT_LbsClientRequestor* self = new (ELeave) CT_LbsClientRequestor(aObserver, aPsyUid); |
|
36 CleanupStack::PushL(self); |
|
37 self->ConstructL(aClientName, aLogger); |
|
38 CleanupStack::Pop(); |
|
39 return self; |
|
40 } |
|
41 |
|
42 // Destructor |
|
43 CT_LbsClientRequestor::~CT_LbsClientRequestor() |
|
44 { |
|
45 iObserver = NULL; |
|
46 Cancel(); |
|
47 iPosServer.Close(); |
|
48 } |
|
49 |
|
50 // C++ default constructor can NOT contain any code, that |
|
51 // might leave. |
|
52 // |
|
53 CT_LbsClientRequestor::CT_LbsClientRequestor( |
|
54 MCT_LbsRequestObserver* aObserver, |
|
55 TUid aPsyUid) |
|
56 : CActive(EPriorityStandard), iObserver(aObserver), iCompletionCode(KNoEvent), |
|
57 iPsyUid(aPsyUid), iContinueEventRequesting(FALSE) |
|
58 { |
|
59 } |
|
60 |
|
61 // EPOC default constructor can leave. |
|
62 void CT_LbsClientRequestor::ConstructL( |
|
63 const TDesC& aClientName, |
|
64 CTestExecuteLogger& aLogger |
|
65 ) |
|
66 { |
|
67 iName = aClientName; |
|
68 iLogger = aLogger; |
|
69 User::LeaveIfError(iPosServer.Connect()); |
|
70 iModuleInfo = TPositionInfo(); |
|
71 CActiveScheduler::Add(this); |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------- |
|
75 // CRequester::CompletionTimeUTC |
|
76 // |
|
77 // (other items were commented in a header). |
|
78 // --------------------------------------------------------- |
|
79 // |
|
80 const TTime& CT_LbsClientRequestor::CompletionTimeUTC() const |
|
81 { |
|
82 return iCompletionTimeUTC; |
|
83 } |
|
84 |
|
85 // --------------------------------------------------------- |
|
86 // CRequester::CompletionCode |
|
87 // |
|
88 // (other items were commented in a header). |
|
89 // --------------------------------------------------------- |
|
90 // |
|
91 TInt CT_LbsClientRequestor::CompletionCode() const |
|
92 { |
|
93 return iCompletionCode; |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------- |
|
97 // CT_LbsClientRequestor::ResetCompletionCode |
|
98 // |
|
99 // (other items were commented in a header). |
|
100 // --------------------------------------------------------- |
|
101 // |
|
102 void CT_LbsClientRequestor::ResetCompletionCode() |
|
103 { |
|
104 iCompletionCode = KNoEvent; |
|
105 } |
|
106 |
|
107 // --------------------------------------------------------- |
|
108 // CRequester::StartRequest |
|
109 // |
|
110 // (other items were commented in a header). |
|
111 // --------------------------------------------------------- |
|
112 // |
|
113 void CT_LbsClientRequestor::StartRequestL(TBool aDefaultPsy) |
|
114 { |
|
115 _LIT(KService, "SAAA"); |
|
116 if (aDefaultPsy == FALSE) |
|
117 { |
|
118 User::LeaveIfError(iPositioner.Open(iPosServer, iPsyUid)); |
|
119 } |
|
120 else |
|
121 { |
|
122 User::LeaveIfError(iPositioner.Open(iPosServer)); |
|
123 } |
|
124 |
|
125 |
|
126 iPositioner.SetRequestor(CRequestor::ERequestorService, |
|
127 CRequestor::EFormatApplication, |
|
128 KService); |
|
129 |
|
130 iPositioner.NotifyPositionUpdate(iModuleInfo, iStatus); |
|
131 SetActive(); |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------- |
|
135 // CRequester::RunL |
|
136 // |
|
137 // (other items were commented in a header). |
|
138 // --------------------------------------------------------- |
|
139 // |
|
140 void CT_LbsClientRequestor::RunL() |
|
141 { |
|
142 iCompletionCode = iStatus.Int(); |
|
143 RequestComplete(); |
|
144 if (iContinueEventRequesting) |
|
145 { |
|
146 iContinueEventRequesting = FALSE; |
|
147 RequestModuleStatusEvent(); |
|
148 } |
|
149 } |
|
150 |
|
151 // --------------------------------------------------------- |
|
152 // CT_LbsClientRequestor::DoCancel |
|
153 // |
|
154 // (other items were commented in a header). |
|
155 // --------------------------------------------------------- |
|
156 // |
|
157 void CT_LbsClientRequestor::DoCancel() |
|
158 { |
|
159 iPosServer.CancelRequest(EPositionServerNotifyModuleStatusEvent/*EPositionServerGetModuleStatus*/); |
|
160 } |
|
161 |
|
162 // --------------------------------------------------------- |
|
163 // CT_LbsClientRequestor::RequestComplete |
|
164 // |
|
165 // (other items were commented in a header). |
|
166 // --------------------------------------------------------- |
|
167 // |
|
168 void CT_LbsClientRequestor::RequestComplete() |
|
169 { |
|
170 if (iObserver) |
|
171 { |
|
172 TRAPD(err, iObserver->RequestCompleteL()); |
|
173 if(KErrNone != err) |
|
174 { |
|
175 _LIT(KClientRequestor, "Error in LbsClientRequestor: %d"); |
|
176 ERR_PRINTF2(KClientRequestor, err); |
|
177 } |
|
178 } |
|
179 } |
|
180 |
|
181 // --------------------------------------------------------- |
|
182 // CT_LbsClientRequestor::RequestModuleStatusEvent |
|
183 // |
|
184 // (other items were commented in a header). |
|
185 // --------------------------------------------------------- |
|
186 // |
|
187 void CT_LbsClientRequestor::RequestModuleStatusEvent() |
|
188 { |
|
189 istatusEvent.SetRequestedEvents(TPositionModuleStatusEvent::EEventAll); |
|
190 iPosServer.NotifyModuleStatusEvent(istatusEvent, iStatus, iPsyUid); |
|
191 if (!IsActive()) |
|
192 { |
|
193 SetActive(); |
|
194 } |
|
195 } |
|
196 |
|
197 // --------------------------------------------------------- |
|
198 // CT_LbsClientRequestor::CancelModuleStatusEvent |
|
199 // |
|
200 // (other items were commented in a header). |
|
201 // --------------------------------------------------------- |
|
202 // |
|
203 void CT_LbsClientRequestor::CancelModuleStatusEvent() |
|
204 { |
|
205 iPosServer.CancelRequest(EPositionServerGetModuleStatus); |
|
206 } |
|
207 |
|
208 // --------------------------------------------------------- |
|
209 // CT_LbsClientRequestor::ReadModuleStatusEvent |
|
210 // |
|
211 // (other items were commented in a header). |
|
212 // --------------------------------------------------------- |
|
213 // |
|
214 TInt CT_LbsClientRequestor::ReadModuleStatusEvent() |
|
215 { |
|
216 TPositionModuleStatus modstatus = TPositionModuleStatus(); |
|
217 istatusEvent.GetModuleStatus(modstatus); |
|
218 return modstatus.DeviceStatus(); |
|
219 } |
|
220 |
|
221 // --------------------------------------------------------- |
|
222 // CT_LbsClientRequestor::ReadModuleStatusClientApi |
|
223 // |
|
224 // (other items were commented in a header). |
|
225 // --------------------------------------------------------- |
|
226 // |
|
227 TInt CT_LbsClientRequestor::ReadModuleStatusClientApi(TPositionModuleId aModuleId) |
|
228 { |
|
229 //Module status from Client API |
|
230 TPositionModuleStatus moduleStatus = TPositionModuleStatus(); |
|
231 iPosServer.GetModuleStatus(moduleStatus, aModuleId); |
|
232 return moduleStatus.DeviceStatus(); |
|
233 } |
|
234 |
|
235 // --------------------------------------------------------- |
|
236 // CT_LbsClientRequestor::ReadModuleStatusModulesApi |
|
237 // |
|
238 // (other items were commented in a header). |
|
239 // --------------------------------------------------------- |
|
240 // |
|
241 TBool CT_LbsClientRequestor::ReadModuleStatusModulesApi(CPosModules* aDb, TPositionModuleId aModuleId) |
|
242 { |
|
243 //Module info from Modules API |
|
244 TPositionModuleInfo moduleInfo; |
|
245 CPosModuleIdList* prioList = aDb->ModuleIdListLC(); |
|
246 TInt modnr = prioList->Find(aModuleId); |
|
247 aDb->GetModuleInfoL(prioList->At(modnr), moduleInfo); |
|
248 CleanupStack::PopAndDestroy(prioList); |
|
249 return moduleInfo.IsAvailable(); |
|
250 } |
|
251 |
|
252 // --------------------------------------------------------- |
|
253 // CT_LbsClientRequestor::ContinueRequesting |
|
254 // |
|
255 // (other items were commented in a header). |
|
256 // --------------------------------------------------------- |
|
257 // |
|
258 void CT_LbsClientRequestor::ContinueRequesting() |
|
259 { |
|
260 iContinueEventRequesting = TRUE;; |
|
261 } |
|
262 |
|
263 // --------------------------------------------------------- |
|
264 // CT_LbsClientRequestor::ClosePositioner |
|
265 // |
|
266 // (other items were commented in a header). |
|
267 // --------------------------------------------------------- |
|
268 // |
|
269 void CT_LbsClientRequestor::ClosePositioner() |
|
270 { |
|
271 iPositioner.Close(); |
|
272 } |
|
273 |
|
274 // End of File |