748
|
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
|
872
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
748
|
5 |
// which accompanies this distribution, and is available
|
872
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
748
|
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 |
|
|
20 |
/**
|
|
21 |
@file ctlbsdoposupd.cpp
|
|
22 |
*/
|
|
23 |
|
|
24 |
#include "ctlbsdoposupdate.h"
|
|
25 |
#include "tlbsutils.h"
|
|
26 |
|
|
27 |
|
|
28 |
CT_LbsDoPosUpdate* CT_LbsDoPosUpdate::NewL(MT_LbsDoPosUpdateObserver* aObserver, TPositionModuleInfo::TTechnologyType aTechnologyType)
|
|
29 |
/**
|
|
30 |
* 'public constructor' may leave
|
|
31 |
*/
|
|
32 |
{
|
|
33 |
TPositionCriteria dummyCritera;
|
|
34 |
CT_LbsDoPosUpdate* doPosUpdate = new(ELeave)CT_LbsDoPosUpdate(aObserver);
|
|
35 |
CleanupStack::PushL(doPosUpdate);
|
|
36 |
doPosUpdate->ConstructL(EOpenSubSessionByModuleId,aTechnologyType,dummyCritera);
|
|
37 |
CleanupStack::Pop(doPosUpdate);
|
|
38 |
|
|
39 |
return doPosUpdate;
|
|
40 |
}
|
|
41 |
|
|
42 |
|
|
43 |
CT_LbsDoPosUpdate* CT_LbsDoPosUpdate::NewL(MT_LbsDoPosUpdateObserver* aObserver, const TPositionCriteriaBase& aCriteria)
|
|
44 |
/**
|
|
45 |
* 'public constructor' may leave
|
|
46 |
*/
|
|
47 |
{
|
|
48 |
TUint dummyTechnologyType = TPositionModuleInfo::ETechnologyUnknown;
|
|
49 |
CT_LbsDoPosUpdate* doPosUpdate = new(ELeave)CT_LbsDoPosUpdate(aObserver);
|
|
50 |
CleanupStack::PushL(doPosUpdate);
|
|
51 |
doPosUpdate->ConstructL(EOpenSubSessionByCriteria,dummyTechnologyType,aCriteria);
|
|
52 |
CleanupStack::Pop(doPosUpdate);
|
|
53 |
|
|
54 |
return doPosUpdate;
|
|
55 |
}
|
|
56 |
|
|
57 |
|
|
58 |
CT_LbsDoPosUpdate::CT_LbsDoPosUpdate(MT_LbsDoPosUpdateObserver* aObserver) : CActive(EPriorityStandard), iObserver(aObserver)
|
|
59 |
/**
|
|
60 |
* Constructor - will not leave
|
|
61 |
*/
|
|
62 |
{
|
|
63 |
CActiveScheduler::Add(this);
|
|
64 |
}
|
|
65 |
|
|
66 |
|
|
67 |
void CT_LbsDoPosUpdate::OpenPositioner(TPositionModuleInfo::TTechnologyType aTechnologyType)
|
|
68 |
{
|
|
69 |
// Open the positioner.
|
|
70 |
if(TPositionModuleInfo::ETechnologyUnknown == aTechnologyType) // use default
|
|
71 |
{
|
|
72 |
User::LeaveIfError(iPositioner.Open(iServer));
|
|
73 |
}
|
|
74 |
else if(TPositionModuleInfo::ETechnologyTerminal == aTechnologyType)
|
|
75 |
{
|
|
76 |
T_LbsUtils utils;
|
|
77 |
// Get position using Agps module
|
|
78 |
TPositionModuleId moduleId;
|
|
79 |
moduleId = utils.GetAGpsModuleIdL(iServer);
|
|
80 |
User::LeaveIfError(iPositioner.Open(iServer, moduleId));
|
|
81 |
}
|
|
82 |
else if(TPositionModuleInfo::ETechnologyNetwork == aTechnologyType)
|
|
83 |
{
|
|
84 |
T_LbsUtils utils;
|
|
85 |
// Get position using network module
|
|
86 |
TPositionModuleId moduleId;
|
|
87 |
moduleId = utils.GetNetworkModuleIdL(iServer);
|
|
88 |
User::LeaveIfError(iPositioner.Open(iServer, moduleId));
|
|
89 |
}
|
|
90 |
else
|
|
91 |
{
|
|
92 |
__ASSERT_ALWAYS(EFalse, User::Panic(KCT_LbsDoPosUpdate, KErrNotSupported)); // not supported yet
|
|
93 |
}
|
|
94 |
}
|
|
95 |
|
|
96 |
void CT_LbsDoPosUpdate::ClosePositioner(void)
|
|
97 |
{
|
|
98 |
iPositioner.Close();
|
|
99 |
}
|
|
100 |
|
|
101 |
void CT_LbsDoPosUpdate::ConnectServer()
|
|
102 |
{
|
|
103 |
User::LeaveIfError(iServer.Connect());
|
|
104 |
}
|
|
105 |
|
|
106 |
void CT_LbsDoPosUpdate::CloseServer()
|
|
107 |
{
|
|
108 |
iServer.Close();
|
|
109 |
}
|
|
110 |
|
|
111 |
void CT_LbsDoPosUpdate::ConstructL(TOpenSubSessionType aOpenSubSessionType,TPositionModuleInfo::TTechnologyType aTechnologyType, const TPositionCriteriaBase& aCriteria)
|
|
112 |
{
|
|
113 |
// Connect to the LBS self locate server.
|
|
114 |
User::LeaveIfError(iServer.Connect());
|
|
115 |
|
|
116 |
if(aOpenSubSessionType == EOpenSubSessionByModuleId)
|
|
117 |
{
|
|
118 |
OpenPositioner(aTechnologyType);
|
|
119 |
}
|
|
120 |
|
|
121 |
else if(aOpenSubSessionType == EOpenSubSessionByCriteria)
|
|
122 |
{
|
|
123 |
User::LeaveIfError(iPositioner.Open(iServer, aCriteria));
|
|
124 |
}
|
|
125 |
|
|
126 |
// set requester will be removed, don't forget the pushl above
|
|
127 |
User::LeaveIfError(iPositioner.SetRequestor( CRequestor::ERequestorService,
|
|
128 |
CRequestor::EFormatApplication,
|
|
129 |
_L("Tom Tom")));
|
|
130 |
|
|
131 |
}
|
|
132 |
|
|
133 |
|
|
134 |
CT_LbsDoPosUpdate::~CT_LbsDoPosUpdate()
|
|
135 |
/**
|
|
136 |
* Destructor
|
|
137 |
*/
|
|
138 |
{
|
|
139 |
Cancel();
|
|
140 |
|
|
141 |
iPositioner.Close();
|
|
142 |
iServer.Close();
|
|
143 |
}
|
|
144 |
|
|
145 |
|
|
146 |
TInt CT_LbsDoPosUpdate::SetOptions(const TPositionUpdateOptionsBase& aPosOption)
|
|
147 |
{
|
|
148 |
return iPositioner.SetUpdateOptions(aPosOption);
|
|
149 |
}
|
|
150 |
|
|
151 |
|
|
152 |
void CT_LbsDoPosUpdate::StartL(TPositionInfo& aPosInfo)
|
|
153 |
/**
|
|
154 |
* wrapper for async function RLbsPositionUpdates::NotifyPositionUpdate().
|
|
155 |
* Will panic if there's another outstanding request.
|
|
156 |
*/
|
|
157 |
{
|
|
158 |
__ASSERT_ALWAYS(!IsActive(), User::Panic(KCT_LbsDoPosUpdate, KErrInUse));
|
|
159 |
|
|
160 |
// Invoke the position update.
|
|
161 |
iPositioner.NotifyPositionUpdate(aPosInfo, iStatus);
|
|
162 |
SetActive();
|
|
163 |
}
|
|
164 |
|
|
165 |
void CT_LbsDoPosUpdate::CancelRequest()
|
|
166 |
{
|
|
167 |
// To allow us to cancel the request but not the active object, normally Cancel() would be used.
|
|
168 |
DoCancel();
|
|
169 |
}
|
|
170 |
|
|
171 |
void CT_LbsDoPosUpdate::DoCancel()
|
|
172 |
{
|
|
173 |
iPositioner.CancelRequest(EPositionerNotifyPositionUpdate);
|
|
174 |
}
|
|
175 |
|
|
176 |
|
|
177 |
void CT_LbsDoPosUpdate::RunL()
|
|
178 |
{
|
|
179 |
TInt err = iStatus.Int();
|
|
180 |
|
|
181 |
// iStatus will contain error code
|
|
182 |
// async request completed. Notify caller via callback:
|
|
183 |
if (iObserver)
|
|
184 |
{
|
|
185 |
iObserver->MT_LbsDoPosUpdateCallback(iStatus);
|
|
186 |
}
|
|
187 |
}
|
|
188 |
|
|
189 |
TInt CT_LbsDoPosUpdate::RunError(TInt aError)
|
|
190 |
{
|
|
191 |
return aError;
|
|
192 |
}
|
|
193 |
|
|
194 |
TInt CT_LbsDoPosUpdate::CompleteRequest(TInt aRequestId)
|
|
195 |
{
|
|
196 |
return iPositioner.CompleteRequest(aRequestId);
|
|
197 |
}
|