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 |
// INCLUDES
|
|
19 |
#include "ctlbsposclient.h"
|
|
20 |
#include "ctlbsposclientholder.h"
|
|
21 |
#include <e32svr.h>
|
|
22 |
#include <LbsIpc.h>
|
|
23 |
|
|
24 |
// CONSTANTS
|
|
25 |
|
|
26 |
// ================= MEMBER FUNCTIONS =======================
|
|
27 |
|
|
28 |
// C++ default constructor can NOT contain any code, that
|
|
29 |
// might leave.
|
|
30 |
//
|
|
31 |
CT_LbsPosClient::CT_LbsPosClient(CT_LbsPosClientHolder* aParent)
|
|
32 |
: CActive(EPriorityHigh), iParent(aParent)
|
|
33 |
{
|
|
34 |
CActiveScheduler::Add(this);
|
|
35 |
}
|
|
36 |
|
|
37 |
// Destructor
|
|
38 |
CT_LbsPosClient::~CT_LbsPosClient()
|
|
39 |
{
|
|
40 |
Cancel();
|
|
41 |
iPositioner.Close();
|
|
42 |
if (!iSameClient)
|
|
43 |
iPosServer.Close();
|
|
44 |
}
|
|
45 |
|
|
46 |
// ---------------------------------------------------------
|
|
47 |
// CPosClient::ConstructL
|
|
48 |
//
|
|
49 |
// (other items were commented in a header).
|
|
50 |
// ---------------------------------------------------------
|
|
51 |
//
|
|
52 |
void CT_LbsPosClient::ConstructL(TUid aPsy)
|
|
53 |
{
|
|
54 |
//connect to EPos
|
|
55 |
User::LeaveIfError(iPosServer.Connect());
|
|
56 |
iSameClient = EFalse;
|
|
57 |
//Open subsession
|
|
58 |
User::LeaveIfError(iPositioner.Open(iPosServer, aPsy));
|
|
59 |
iModuleInfo = TPositionInfo();
|
|
60 |
}
|
|
61 |
|
|
62 |
// ---------------------------------------------------------
|
|
63 |
// CPosClient::ConstructL
|
|
64 |
//
|
|
65 |
// (other items were commented in a header).
|
|
66 |
// ---------------------------------------------------------
|
|
67 |
//
|
|
68 |
void CT_LbsPosClient::ConstructL(TUid aPsy, RPositionServer& aPositionServer)
|
|
69 |
{
|
|
70 |
//connect to EPos
|
|
71 |
//User::LeaveIfError(iPosServer.Connect());
|
|
72 |
iPosServer = aPositionServer;
|
|
73 |
iSameClient = ETrue;
|
|
74 |
//Open subsession
|
|
75 |
User::LeaveIfError(iPositioner.Open(iPosServer, aPsy));
|
|
76 |
iModuleInfo = TPositionInfo();
|
|
77 |
}
|
|
78 |
// ---------------------------------------------------------
|
|
79 |
// CPosClient::NewL
|
|
80 |
//
|
|
81 |
// (other items were commented in a header).
|
|
82 |
// ---------------------------------------------------------
|
|
83 |
//
|
|
84 |
CT_LbsPosClient* CT_LbsPosClient::NewL(CT_LbsPosClientHolder* aParent, TUid aPsy)
|
|
85 |
{
|
|
86 |
CT_LbsPosClient* self = new (ELeave) CT_LbsPosClient(aParent);
|
|
87 |
CleanupStack::PushL(self);
|
|
88 |
self->ConstructL(aPsy);
|
|
89 |
CleanupStack::Pop(self); // self
|
|
90 |
return self;
|
|
91 |
}
|
|
92 |
|
|
93 |
// ---------------------------------------------------------
|
|
94 |
// CPosClient::NewL
|
|
95 |
//
|
|
96 |
// (other items were commented in a header).
|
|
97 |
// ---------------------------------------------------------
|
|
98 |
//
|
|
99 |
CT_LbsPosClient* CT_LbsPosClient::NewL(CT_LbsPosClientHolder* aParent, TUid aPsy, RPositionServer& aPositionServer)
|
|
100 |
{
|
|
101 |
CT_LbsPosClient* self = new (ELeave) CT_LbsPosClient(aParent);
|
|
102 |
CleanupStack::PushL(self);
|
|
103 |
self->ConstructL(aPsy, aPositionServer);
|
|
104 |
CleanupStack::Pop(self); // self
|
|
105 |
return self;
|
|
106 |
}
|
|
107 |
|
|
108 |
|
|
109 |
// ---------------------------------------------------------
|
|
110 |
// CPosClient::MakeRequest
|
|
111 |
//
|
|
112 |
// (other items were commented in a header).
|
|
113 |
// ---------------------------------------------------------
|
|
114 |
//
|
|
115 |
void CT_LbsPosClient::MakeRequest()
|
|
116 |
{
|
|
117 |
_LIT(KContact, "11111");
|
|
118 |
_LIT(KService, "SAAA");
|
|
119 |
|
|
120 |
//TPositionInfo moduleInfo = TPositionInfo();
|
|
121 |
|
|
122 |
CRequestor* contactId =
|
|
123 |
CRequestor::New(CRequestor::ERequestorContact,
|
|
124 |
CRequestor::EFormatTelephone, KContact);
|
|
125 |
|
|
126 |
CRequestor* servId =
|
|
127 |
CRequestor::New(CRequestor::ERequestorService,
|
|
128 |
CRequestor::EFormatApplication, KService);
|
|
129 |
|
|
130 |
RRequestorStack stack = RRequestorStack();
|
|
131 |
stack.Append(contactId);
|
|
132 |
stack.Append(servId);
|
|
133 |
|
|
134 |
CleanupStack::PushL(contactId);
|
|
135 |
CleanupStack::PushL(servId);
|
|
136 |
|
|
137 |
TInt err = iPositioner.SetRequestor(stack);
|
|
138 |
// what to do with err ???
|
|
139 |
|
|
140 |
if (err)
|
|
141 |
{
|
|
142 |
// Do something here?
|
|
143 |
}
|
|
144 |
stack.Close();
|
|
145 |
|
|
146 |
CleanupStack::PopAndDestroy(servId);
|
|
147 |
CleanupStack::PopAndDestroy(contactId);
|
|
148 |
|
|
149 |
iStartTime.UniversalTime();
|
|
150 |
|
|
151 |
iPositioner.NotifyPositionUpdate(iModuleInfo, iStatus);
|
|
152 |
SetActive();
|
|
153 |
}
|
|
154 |
|
|
155 |
// ---------------------------------------------------------
|
|
156 |
// CPosClient::RunL
|
|
157 |
//
|
|
158 |
// (other items were commented in a header).
|
|
159 |
// ---------------------------------------------------------
|
|
160 |
//
|
|
161 |
void CT_LbsPosClient::RunL()
|
|
162 |
{
|
|
163 |
if (iStatus == KErrNone)
|
|
164 |
{
|
|
165 |
TTime now;
|
|
166 |
now.UniversalTime();
|
|
167 |
iRequestTime = now.MicroSecondsFrom(iStartTime);
|
|
168 |
|
|
169 |
iParent->HandleRequestDone();
|
|
170 |
}
|
|
171 |
else
|
|
172 |
{
|
|
173 |
_LIT(KErr, "iStatus != KErrNone");
|
|
174 |
RDebug::Print(KErr);
|
|
175 |
iParent->HandleRequestDone();
|
|
176 |
}
|
|
177 |
}
|
|
178 |
|
|
179 |
// ---------------------------------------------------------
|
|
180 |
// CPosClient::DoCancel
|
|
181 |
//
|
|
182 |
// (other items were commented in a header).
|
|
183 |
// ---------------------------------------------------------
|
|
184 |
//
|
|
185 |
void CT_LbsPosClient::DoCancel()
|
|
186 |
{
|
|
187 |
iPositioner.CancelRequest(EPositionerNotifyPositionUpdate); // Specified in LbsIpc.h
|
|
188 |
TTime now;
|
|
189 |
now.UniversalTime();
|
|
190 |
iRequestTime = now.MicroSecondsFrom(iStartTime);
|
|
191 |
}
|
|
192 |
|
|
193 |
// ---------------------------------------------------------
|
|
194 |
// CPosClient::GetResult
|
|
195 |
//
|
|
196 |
// (other items were commented in a header).
|
|
197 |
// ---------------------------------------------------------
|
|
198 |
//
|
|
199 |
void CT_LbsPosClient::GetResult(
|
|
200 |
TInt& aStatus,
|
|
201 |
TPositionInfo& aModuleInfo,
|
|
202 |
TTimeIntervalMicroSeconds& aRequestTime)
|
|
203 |
{
|
|
204 |
aStatus = iStatus.Int();
|
|
205 |
aModuleInfo = iModuleInfo;
|
|
206 |
aRequestTime = iRequestTime;
|
|
207 |
}
|
|
208 |
|
|
209 |
// End of File
|