748
|
1 |
// Copyright (c) 2000-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 "ctlbsrequester.h"
|
|
20 |
#include "mctlbsrequestobserver.h"
|
|
21 |
|
|
22 |
// CONSTANTS
|
|
23 |
|
|
24 |
// ================= MEMBER FUNCTIONS =======================
|
|
25 |
|
|
26 |
// Two-phased constructor.
|
|
27 |
CT_LbsRequester* CT_LbsRequester::NewL(
|
|
28 |
TUid aPsyUid,
|
|
29 |
MCT_LbsRequestObserver* aObserver,
|
|
30 |
CTestExecuteLogger& aLogger
|
|
31 |
)
|
|
32 |
{
|
|
33 |
CT_LbsRequester* self = new (ELeave) CT_LbsRequester(aObserver);
|
|
34 |
CleanupStack::PushL(self);
|
|
35 |
self->ConstructL(aPsyUid, aLogger);
|
|
36 |
CleanupStack::Pop();
|
|
37 |
return self;
|
|
38 |
}
|
|
39 |
|
|
40 |
// Two-phased constructor.
|
|
41 |
CT_LbsRequester* CT_LbsRequester::NewL(
|
|
42 |
MCT_LbsRequestObserver* aObserver,
|
|
43 |
TTimeIntervalMicroSeconds aInterval,
|
|
44 |
CTestExecuteLogger& aLogger
|
|
45 |
)
|
|
46 |
{
|
|
47 |
CT_LbsRequester* self = new (ELeave) CT_LbsRequester(aObserver);
|
|
48 |
CleanupStack::PushL(self);
|
|
49 |
self->ConstructL(aInterval, aLogger);
|
|
50 |
CleanupStack::Pop();
|
|
51 |
return self;
|
|
52 |
}
|
|
53 |
|
|
54 |
// Destructor
|
|
55 |
CT_LbsRequester::~CT_LbsRequester()
|
|
56 |
{
|
|
57 |
iObserver = NULL;
|
|
58 |
Cancel();
|
|
59 |
iPositioner.Close();
|
|
60 |
iPosServer.Close();
|
|
61 |
}
|
|
62 |
|
|
63 |
// C++ default constructor can NOT contain any code, that
|
|
64 |
// might leave.
|
|
65 |
//
|
|
66 |
CT_LbsRequester::CT_LbsRequester(
|
|
67 |
MCT_LbsRequestObserver* aObserver)
|
|
68 |
: CActive(EPriorityStandard), iObserver(aObserver)
|
|
69 |
{
|
|
70 |
}
|
|
71 |
|
|
72 |
// EPOC default constructor can leave.
|
|
73 |
void CT_LbsRequester::ConstructL(
|
|
74 |
TUid aPsyUid,
|
|
75 |
CTestExecuteLogger& aLogger
|
|
76 |
)
|
|
77 |
{
|
|
78 |
iLogger = aLogger;
|
|
79 |
User::LeaveIfError(iPosServer.Connect());
|
|
80 |
iModuleInfo = TPositionInfo();
|
|
81 |
iCompletionCode = KErrNone;
|
|
82 |
User::LeaveIfError(iPositioner.Open(iPosServer, aPsyUid));
|
|
83 |
_LIT(KService, "SAAA");
|
|
84 |
iPositioner.SetRequestor(CRequestor::ERequestorService,
|
|
85 |
CRequestor::EFormatApplication,
|
|
86 |
KService);
|
|
87 |
CActiveScheduler::Add(this);
|
|
88 |
}
|
|
89 |
|
|
90 |
void CT_LbsRequester::ConstructL(
|
|
91 |
TTimeIntervalMicroSeconds aInterval,
|
|
92 |
CTestExecuteLogger& aLogger
|
|
93 |
)
|
|
94 |
{
|
|
95 |
iLogger = aLogger;
|
|
96 |
User::LeaveIfError(iPosServer.Connect());
|
|
97 |
iModuleInfo = TPositionInfo();
|
|
98 |
iCompletionCode = KErrNone;
|
|
99 |
User::LeaveIfError(iPositioner.Open(iPosServer));
|
|
100 |
TPositionUpdateOptions posOption;
|
|
101 |
posOption.SetUpdateInterval(aInterval);
|
|
102 |
User::LeaveIfError(iPositioner.SetUpdateOptions(posOption));
|
|
103 |
_LIT(KService, "SAAA");
|
|
104 |
iPositioner.SetRequestor(CRequestor::ERequestorService,
|
|
105 |
CRequestor::EFormatApplication,
|
|
106 |
KService);
|
|
107 |
CActiveScheduler::Add(this);
|
|
108 |
}
|
|
109 |
|
|
110 |
// ---------------------------------------------------------
|
|
111 |
// CT_LbsRequester::CompletionTimeUTC
|
|
112 |
//
|
|
113 |
// (other items were commented in a header).
|
|
114 |
// ---------------------------------------------------------
|
|
115 |
//
|
|
116 |
const TTime& CT_LbsRequester::CompletionTimeUTC() const
|
|
117 |
{
|
|
118 |
return iCompletionTimeUTC;
|
|
119 |
}
|
|
120 |
|
|
121 |
// ---------------------------------------------------------
|
|
122 |
// CT_LbsRequester::CompletionCode
|
|
123 |
//
|
|
124 |
// (other items were commented in a header).
|
|
125 |
// ---------------------------------------------------------
|
|
126 |
//
|
|
127 |
TInt CT_LbsRequester::CompletionCode() const
|
|
128 |
{
|
|
129 |
return iCompletionCode;
|
|
130 |
}
|
|
131 |
|
|
132 |
// ---------------------------------------------------------
|
|
133 |
// CT_LbsRequester::StartRequest
|
|
134 |
//
|
|
135 |
// (other items were commented in a header).
|
|
136 |
// ---------------------------------------------------------
|
|
137 |
//
|
|
138 |
void CT_LbsRequester::SetUpdateIntervalL(TTimeIntervalMicroSeconds aInterval)
|
|
139 |
{
|
|
140 |
TPositionUpdateOptions posOption;
|
|
141 |
posOption.SetUpdateInterval(aInterval);
|
|
142 |
User::LeaveIfError(iPositioner.SetUpdateOptions(posOption));
|
|
143 |
}
|
|
144 |
|
|
145 |
// ---------------------------------------------------------
|
|
146 |
// CT_LbsRequester::StartRequest
|
|
147 |
//
|
|
148 |
// (other items were commented in a header).
|
|
149 |
// ---------------------------------------------------------
|
|
150 |
void CT_LbsRequester::StartRequest()
|
|
151 |
{
|
|
152 |
iPositioner.NotifyPositionUpdate(iModuleInfo, iStatus);
|
|
153 |
SetActive();
|
|
154 |
}
|
|
155 |
|
|
156 |
// LOCAL FUNCTIONS
|
|
157 |
void CleanOpRequestorStack(TAny* aAnArray)
|
|
158 |
{
|
|
159 |
// Cleanup function the requestor stack
|
|
160 |
RRequestorStack* theStack = reinterpret_cast <RRequestorStack*> (aAnArray);
|
|
161 |
theStack->ResetAndDestroy();
|
|
162 |
}
|
|
163 |
|
|
164 |
// ---------------------------------------------------------
|
|
165 |
// CT_LbsRequester::SetRequestorStackL
|
|
166 |
//
|
|
167 |
// (other items were commented in a header).
|
|
168 |
// ---------------------------------------------------------
|
|
169 |
//
|
|
170 |
TInt CT_LbsRequester::SetRequestorStackL(const TDesC& aService, const TDesC& aContact)
|
|
171 |
{
|
|
172 |
CRequestor* contactId =
|
|
173 |
CRequestor::New(CRequestor::ERequestorContact, CRequestor::EFormatTelephone,
|
|
174 |
aContact);
|
|
175 |
|
|
176 |
CRequestor* servId =
|
|
177 |
CRequestor::New(CRequestor::ERequestorService, CRequestor::EFormatApplication,
|
|
178 |
aService);
|
|
179 |
|
|
180 |
// Create a requestor stack containing one contact and one service (the service must be last added)
|
|
181 |
RRequestorStack stack = RRequestorStack();
|
|
182 |
CleanupStack::PushL(TCleanupItem(CleanOpRequestorStack ,&stack));
|
|
183 |
stack.Append(contactId);
|
|
184 |
stack.Append(servId);
|
|
185 |
|
|
186 |
CleanupStack::PushL(contactId);
|
|
187 |
CleanupStack::PushL(servId);
|
|
188 |
|
|
189 |
TInt err = iPositioner.SetRequestor(stack);
|
|
190 |
|
|
191 |
CleanupStack::PopAndDestroy(servId);
|
|
192 |
CleanupStack::PopAndDestroy(contactId);
|
|
193 |
stack.Close();
|
|
194 |
CleanupStack::PopAndDestroy(1); // CleanOpTp226 stack
|
|
195 |
|
|
196 |
return err;
|
|
197 |
}
|
|
198 |
|
|
199 |
// ---------------------------------------------------------
|
|
200 |
// CT_LbsRequester::RunL
|
|
201 |
//
|
|
202 |
// (other items were commented in a header).
|
|
203 |
// ---------------------------------------------------------
|
|
204 |
//
|
|
205 |
void CT_LbsRequester::RunL()
|
|
206 |
{
|
|
207 |
iCompletionCode = iStatus.Int();
|
|
208 |
iCompletionTimeUTC.UniversalTime();
|
|
209 |
RequestComplete();
|
|
210 |
}
|
|
211 |
|
|
212 |
// ---------------------------------------------------------
|
|
213 |
// CT_LbsRequester::DoCancel
|
|
214 |
//
|
|
215 |
// (other items were commented in a header).
|
|
216 |
// ---------------------------------------------------------
|
|
217 |
//
|
|
218 |
void CT_LbsRequester::DoCancel()
|
|
219 |
{
|
|
220 |
iPositioner.CancelRequest(EPositionerNotifyPositionUpdate);
|
|
221 |
iCompletionTimeUTC.UniversalTime();
|
|
222 |
RequestComplete();
|
|
223 |
}
|
|
224 |
|
|
225 |
// ---------------------------------------------------------
|
|
226 |
// CT_LbsRequester::RequestComplete
|
|
227 |
//
|
|
228 |
// (other items were commented in a header).
|
|
229 |
// ---------------------------------------------------------
|
|
230 |
//
|
|
231 |
void CT_LbsRequester::RequestComplete()
|
|
232 |
{
|
|
233 |
if (iObserver)
|
|
234 |
{
|
|
235 |
TRAPD(err, iObserver->RequestCompleteL());
|
|
236 |
if(KErrNone != err)
|
|
237 |
{
|
|
238 |
_LIT(KRequestCompleteError, "Error in LbsRequester: %d");
|
|
239 |
ERR_PRINTF2(KRequestCompleteError, err);
|
|
240 |
}
|
|
241 |
}
|
|
242 |
}
|
|
243 |
|
|
244 |
void CT_LbsRequester::GetPositionInfo(
|
|
245 |
TPositionInfo& aModuleInfo)
|
|
246 |
{
|
|
247 |
aModuleInfo = iModuleInfo;
|
|
248 |
}
|
|
249 |
|
|
250 |
// ---------------------------------------------------------
|
|
251 |
// CT_LbsRequester::SetUpdateType
|
|
252 |
//
|
|
253 |
// (other items were commented in a header).
|
|
254 |
// ---------------------------------------------------------
|
|
255 |
//
|
|
256 |
void CT_LbsRequester::SetUpdateType(const TInt& aUpdateType)
|
|
257 |
{
|
|
258 |
iModuleInfo.SetUpdateType(aUpdateType);
|
|
259 |
}
|
|
260 |
|
|
261 |
// End of File
|