36
|
1 |
// Copyright (c) 2008-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: Stores information for a MOLR test sequence
|
|
14 |
//
|
|
15 |
//
|
|
16 |
|
|
17 |
#include "clbstestmolrsessionsequence.h"
|
|
18 |
|
|
19 |
/** 2nd Phase constructor
|
|
20 |
*/
|
|
21 |
CTestMolrSessionSequence* CTestMolrSessionSequence::NewL(CLbsTestNgMessageHandler& aNgProxy, MHybridMultipleTestCallBack& aTestCallback,
|
|
22 |
TInt aSequenceNum, const TDesC& aConfigFileName, const TDesC& aConfigSection)
|
|
23 |
{
|
|
24 |
CTestMolrSessionSequence* self = new (ELeave) CTestMolrSessionSequence(aNgProxy, aTestCallback);
|
|
25 |
CleanupStack::PushL(self);
|
|
26 |
self->ConstructL(aSequenceNum, aConfigFileName, aConfigSection);
|
|
27 |
CleanupStack::Pop(self);
|
|
28 |
return self;
|
|
29 |
}
|
|
30 |
|
|
31 |
/** Destructor
|
|
32 |
*/
|
|
33 |
CTestMolrSessionSequence::~CTestMolrSessionSequence()
|
|
34 |
{
|
|
35 |
if(iSetupPsy)
|
|
36 |
{
|
|
37 |
iPos.Close();
|
|
38 |
iPosServer.Close();
|
|
39 |
delete iPosWatcher;
|
|
40 |
}
|
|
41 |
}
|
|
42 |
|
|
43 |
/** Standard C Constructor
|
|
44 |
*/
|
|
45 |
CTestMolrSessionSequence::CTestMolrSessionSequence(CLbsTestNgMessageHandler& aNgProxy, MHybridMultipleTestCallBack& aTestCallback)
|
|
46 |
: CTestSessionSequence(aNgProxy, aTestCallback),
|
|
47 |
iSetupPsy(EFalse)
|
|
48 |
{
|
|
49 |
}
|
|
50 |
|
|
51 |
/** Second phase construction
|
|
52 |
*/
|
|
53 |
void CTestMolrSessionSequence::ConstructL(TInt aSequenceNum, const TDesC& aConfigFileName, const TDesC& aConfigSection)
|
|
54 |
{
|
|
55 |
CTestSessionSequence::ConstructL(aSequenceNum, aConfigFileName, aConfigSection);
|
|
56 |
iTestCallback.LogTestStatement(_L("Type = MOLR"));
|
|
57 |
|
|
58 |
// Default to NULL
|
|
59 |
iPsyUid = TUid::Null();
|
|
60 |
|
|
61 |
const TInt KMaxHexStringSize = 10;// enough for 0x12345678
|
|
62 |
TBuf<KMaxHexStringSize> hexBuffer;
|
|
63 |
TPtrC ptr;
|
|
64 |
ptr.Set(hexBuffer);
|
|
65 |
|
|
66 |
// Find out what PSY to use
|
|
67 |
TBuf<10> psyUidName;
|
|
68 |
psyUidName.Format(_L("PsyUid%d"), iSequenceId);
|
|
69 |
if (iIniFile->FindVar(aConfigSection, psyUidName, ptr))
|
|
70 |
{
|
|
71 |
// strip any leading "0x" or "0X"
|
|
72 |
if(ptr[0] == TChar('0') && (ptr[1] == TChar('X') || ptr[1] == TChar('x')))
|
|
73 |
{
|
|
74 |
// leading "0x" encoded. So strip
|
|
75 |
hexBuffer = ptr.Right(ptr.Length()-2);
|
|
76 |
}
|
|
77 |
else
|
|
78 |
{
|
|
79 |
hexBuffer = ptr;
|
|
80 |
}
|
|
81 |
TLex lex(hexBuffer);
|
|
82 |
TUint32 uid;
|
|
83 |
if (lex.Val(uid, EHex) == KErrNone)
|
|
84 |
{
|
|
85 |
iPsyUid = TUid::Uid(uid);
|
|
86 |
}
|
|
87 |
else
|
|
88 |
{
|
|
89 |
LogTestStatement(_L("Invalid PsyUid setting: %s"),1,&ptr);
|
|
90 |
}
|
|
91 |
}
|
|
92 |
|
|
93 |
if (iPsyUid == TUid::Null())
|
|
94 |
{
|
|
95 |
iTestCallback.LogTestStatement(_L("Using default PSY"));
|
|
96 |
}
|
|
97 |
else
|
|
98 |
{
|
|
99 |
LogTestStatement(_L("Using PSY %x"), 1, iPsyUid.iUid);
|
|
100 |
}
|
|
101 |
|
|
102 |
iTestCallback.LogTestStatement(_L("-----------------------------------------------------------------------"));
|
|
103 |
}
|
|
104 |
|
|
105 |
/** Sets up the PSY (RPositioner)
|
|
106 |
*/
|
|
107 |
void CTestMolrSessionSequence::SetupPsy()
|
|
108 |
{
|
|
109 |
TInt err = iPosServer.Connect();
|
|
110 |
|
|
111 |
if (iPsyUid == TUid::Null())
|
|
112 |
{
|
|
113 |
err = iPos.Open(iPosServer);
|
|
114 |
}
|
|
115 |
else
|
|
116 |
{
|
|
117 |
err = iPos.Open(iPosServer, TPositionModuleId(iPsyUid));
|
|
118 |
}
|
|
119 |
|
|
120 |
TPositionUpdateOptions posOpts(TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(240 * 1000 * 1000));
|
|
121 |
iPos.SetUpdateOptions(posOpts);
|
|
122 |
|
|
123 |
iPosWatcher = CPosServerWatcher::NewLC(iPos, *this);
|
|
124 |
CleanupStack::Pop(iPosWatcher);
|
|
125 |
|
|
126 |
iSetupPsy = ETrue;
|
|
127 |
}
|
|
128 |
|
|
129 |
/* << Request Location Update
|
|
130 |
*/
|
|
131 |
void CTestMolrSessionSequence::RequestLocationUpdate()
|
|
132 |
{
|
|
133 |
if(!iSetupPsy)
|
|
134 |
{
|
|
135 |
SetupPsy();
|
|
136 |
}
|
|
137 |
|
|
138 |
iPosWatcher->IssueNotifyPositionUpdate();
|
|
139 |
}
|
|
140 |
|
|
141 |
/* << ProcessLocationRequest()
|
|
142 |
*/
|
|
143 |
void CTestMolrSessionSequence::SendProcessLocationRequest()
|
|
144 |
{
|
|
145 |
TBool emergency = EFalse;
|
|
146 |
MLbsNetworkProtocolObserver::TLbsNetProtocolService service = MLbsNetworkProtocolObserver::EServiceSelfLocation;
|
|
147 |
TLbsNetPosRequestQuality quality = ArgUtils::Quality();
|
|
148 |
TLbsNetPosRequestMethod method = ArgUtils::RequestHybridMethod();
|
|
149 |
iNgProxy.ProtocolProxy()->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method);
|
|
150 |
}
|
|
151 |
|
|
152 |
/* << ProcessStatusUpdate()
|
|
153 |
*/
|
|
154 |
void CTestMolrSessionSequence::SendProcessStatusUpdate()
|
|
155 |
{
|
|
156 |
MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask = MLbsNetworkProtocolObserver::EServiceSelfLocation;
|
|
157 |
iNgProxy.ProtocolProxy()->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask);
|
|
158 |
}
|
|
159 |
|
|
160 |
/* >> SelfLocationRequest()
|
|
161 |
*/
|
|
162 |
void CTestMolrSessionSequence::CheckSelfLocationRequest(TLbsNetSessionId* aSessionId)
|
|
163 |
{
|
|
164 |
//Extract the Session ID and assign it to this sequence
|
|
165 |
iSessionId.SetSessionNum(aSessionId->SessionNum());
|
|
166 |
iSessionId.SetSessionOwner(aSessionId->SessionOwner());
|
|
167 |
}
|
|
168 |
|
|
169 |
|
|
170 |
/* >> NetworkLocationRequest()
|
|
171 |
*/
|
|
172 |
void CTestMolrSessionSequence::CheckNetworkLocationRequest(TLbsNetSessionId* aSessionId)
|
|
173 |
{
|
|
174 |
//Extract the Session ID and assign it to this sequence
|
|
175 |
iSessionId.SetSessionNum(aSessionId->SessionNum());
|
|
176 |
iSessionId.SetSessionOwner(aSessionId->SessionOwner());
|
|
177 |
}
|
|
178 |
|
|
179 |
|
|
180 |
/** MPosServerObserver callback when LastKnownPosition is called
|
|
181 |
*/
|
|
182 |
void CTestMolrSessionSequence::OnGetLastKnownPosition(TInt32 aErr, const TPositionInfoBase& /*aPosInfo*/)
|
|
183 |
{
|
|
184 |
LogTestStatement(_L("-> LastKnownPosition(%d) [5001] Sq: %d"), 2, aErr, iSequenceId);
|
|
185 |
|
|
186 |
//Check to see whether this was required in the current sequence
|
|
187 |
if(iStateSequence[iCurrentPosition] == EGetLastKnownLocation)
|
|
188 |
{
|
|
189 |
SignalCallbackIdleStart();
|
|
190 |
}
|
|
191 |
}
|
|
192 |
|
|
193 |
/** MPosServerObserver callback when NotifyPositionUpdate is called
|
|
194 |
*/
|
|
195 |
void CTestMolrSessionSequence::OnNotifyPositionUpdate(TInt32 aErr, const TPositionInfoBase& /*aPosInfo*/)
|
|
196 |
{
|
|
197 |
LogTestStatement(_L("-> NotifyPositionUpdate(%d) [5000] Sq: %d"), 2, aErr, iSequenceId);
|
|
198 |
|
|
199 |
//Check to see whether this was required in the current sequence
|
|
200 |
if(iStateSequence[iCurrentPosition] == ENotifyPositionUpdate)
|
|
201 |
{
|
|
202 |
SignalCallbackIdleStart();
|
|
203 |
}
|
|
204 |
}
|