24
|
1 |
// Copyright (c) 2003-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:
|
|
14 |
// Utility functions for Sms Stack test harnesses
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
/**
|
|
19 |
@file
|
|
20 |
*/
|
|
21 |
|
|
22 |
#include "smsstacktestutilities.h"
|
|
23 |
|
|
24 |
#include <commsdattypesv1_1.h>
|
|
25 |
#include <commsdattypesv1_1_internal.h>
|
|
26 |
#include <logcli.h>
|
|
27 |
#include <e32math.h>
|
|
28 |
#include <e32test.h>
|
|
29 |
#include <f32file.h>
|
|
30 |
#include <logwraplimits.h>
|
|
31 |
|
|
32 |
#include "smsustrm.h"
|
|
33 |
#include "Gsmumsg.h"
|
|
34 |
#include "smsuaddr.H"
|
|
35 |
#include "gsmubuf.h"
|
|
36 |
#include "smspdudb.h"
|
|
37 |
#include "SmsuTimer.h"
|
|
38 |
#include "smsstacklog.h"
|
|
39 |
|
|
40 |
using namespace CommsDat;
|
|
41 |
|
|
42 |
// Check a boolean is true
|
|
43 |
#define LOCAL_CHECKPOINT(a) iTestStep->testBooleanTrue((a), (TText8*)__FILE__, __LINE__)
|
|
44 |
|
|
45 |
// Check a boolean is true if not return error code b
|
|
46 |
#define LOCAL_CHECKPOINT_CODE(a, b) iTestStep->testBooleanTrueWithErrorCode((a), (b), (TText8*)__FILE__, __LINE__)
|
|
47 |
#define LOCAL_CHECKPOINT_COMPAREL(p1, p2, p3) iTestStep->TestCheckPointCompareL((p1), (p2), (p3), (TText8*)__FILE__, __LINE__)
|
|
48 |
|
|
49 |
// TestExecute style Printf
|
|
50 |
#define PRINTF1(p1) iTestStep->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1))
|
|
51 |
#define PRINTF2(p1, p2) iTestStep->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2))
|
|
52 |
#define PRINTF3(p1, p2, p3) iTestStep->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3))
|
|
53 |
#define PRINTF4(p1, p2, p3, p4) iTestStep->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4))
|
|
54 |
#define PRINTF5(p1, p2, p3, p4, p5) iTestStep->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4), (p5))
|
|
55 |
#define PRINTF6(p1, p2, p3, p4, p5, p6) iTestStep->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4), (p5), (p6))
|
|
56 |
#define PRINTF7(p1, p2, p3, p4, p5, p6, p7) iTestStep->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4), (p5), (p6), (p7))
|
|
57 |
|
|
58 |
class CTSmsRegTstActive : public CActive
|
|
59 |
{
|
|
60 |
public:
|
|
61 |
CTSmsRegTstActive();
|
|
62 |
~CTSmsRegTstActive();
|
|
63 |
void StartL();
|
|
64 |
protected:
|
|
65 |
void DoCancel();
|
|
66 |
void RunL();
|
|
67 |
};
|
|
68 |
|
|
69 |
CTSmsRegTstActive::CTSmsRegTstActive():
|
|
70 |
CActive(0)
|
|
71 |
{
|
|
72 |
CActiveScheduler::Add(this);
|
|
73 |
}
|
|
74 |
|
|
75 |
CTSmsRegTstActive::~CTSmsRegTstActive()
|
|
76 |
{
|
|
77 |
Cancel();
|
|
78 |
}
|
|
79 |
|
|
80 |
void CTSmsRegTstActive::DoCancel()
|
|
81 |
{
|
|
82 |
TRequestStatus* s=&iStatus;
|
|
83 |
User::RequestComplete(s, KErrNone);
|
|
84 |
}
|
|
85 |
|
|
86 |
void CTSmsRegTstActive::StartL()
|
|
87 |
{
|
|
88 |
SetActive();
|
|
89 |
}
|
|
90 |
|
|
91 |
void CTSmsRegTstActive::RunL()
|
|
92 |
{
|
|
93 |
CActiveScheduler::Stop();
|
|
94 |
}
|
|
95 |
|
|
96 |
|
|
97 |
EXPORT_C CSmsStackTestUtils* CSmsStackTestUtils::NewL(CTestStep* aTestStep, RFs& aFs)
|
|
98 |
{
|
|
99 |
CSmsStackTestUtils* self = new (ELeave) CSmsStackTestUtils(aTestStep, aFs);
|
|
100 |
CleanupStack::PushL(self);
|
|
101 |
self->ConstructL();
|
|
102 |
CleanupStack::Pop(self);
|
|
103 |
return self;
|
|
104 |
}
|
|
105 |
|
|
106 |
void CSmsStackTestUtils::ConstructL()
|
|
107 |
{
|
|
108 |
iCharConv = CCnvCharacterSetConverter::NewL();
|
|
109 |
}
|
|
110 |
|
|
111 |
EXPORT_C CSmsStackTestUtils::~CSmsStackTestUtils()
|
|
112 |
{
|
|
113 |
delete iCharConv;
|
|
114 |
}
|
|
115 |
|
|
116 |
CSmsStackTestUtils::CSmsStackTestUtils(CTestStep* aTestStep, RFs& aFs)
|
|
117 |
: iTestStep(aTestStep), iFs(aFs)
|
|
118 |
{
|
|
119 |
}
|
|
120 |
|
|
121 |
|
|
122 |
EXPORT_C void CSmsStackTestUtils::OpenSmsSocketLC(RSocketServ& aSocketServer, RSocket& aSocket, TSmsAddrFamily aFamily)
|
|
123 |
/**
|
|
124 |
* Initialise an RSocket for SMS
|
|
125 |
* @note aSocket is pushed to CleanupStack.
|
|
126 |
* @param aSocketServer reference to the socket server object
|
|
127 |
* @param aSocket The socket that will be opened
|
|
128 |
* @param aFamily The sms address family
|
|
129 |
*/
|
|
130 |
{
|
|
131 |
OpenSmsSocketL(aSocketServer, aSocket, aFamily);
|
|
132 |
CleanupClosePushL(aSocket);
|
|
133 |
}
|
|
134 |
|
|
135 |
EXPORT_C void CSmsStackTestUtils::OpenSmsSocketL(RSocketServ& aSocketServer, RSocket& aSocket, TSmsAddrFamily aFamily)
|
|
136 |
/**
|
|
137 |
* Initialise an RSocket for SMS, aSocket is NOT pushed to CleanupStack.
|
|
138 |
* @param aSocketServer reference to the socket server object
|
|
139 |
* @param aSocket The socket that will be opened
|
|
140 |
* @param aFamily The sms address family
|
|
141 |
*/
|
|
142 |
{
|
|
143 |
TSmsAddr smsaddr;
|
|
144 |
smsaddr.SetSmsAddrFamily(aFamily);
|
|
145 |
OpenSmsSocketL(aSocketServer, aSocket, smsaddr);
|
|
146 |
}
|
|
147 |
|
|
148 |
EXPORT_C void CSmsStackTestUtils::OpenSmsSocketLC(RSocketServ& aSocketServer, RSocket& aSocket, TSmsAddr& aSmsAddr)
|
|
149 |
/**
|
|
150 |
* Initialise an RSocket for SMS.
|
|
151 |
* @note aSocket is pushed to CleanupStack
|
|
152 |
* @param aSocketServer reference to the socket server object
|
|
153 |
* @param aSocket The socket that will be opened
|
|
154 |
* @param aSmsAddr The sms address to bind to
|
|
155 |
*/
|
|
156 |
{
|
|
157 |
OpenSmsSocketL(aSocketServer, aSocket, aSmsAddr);
|
|
158 |
CleanupClosePushL(aSocket);
|
|
159 |
}
|
|
160 |
|
|
161 |
EXPORT_C void CSmsStackTestUtils::OpenSmsSocketL(RSocketServ& aSocketServer, RSocket& aSocket, TSmsAddr& aSmsAddr)
|
|
162 |
/**
|
|
163 |
* Initialise an RSocket for SMS, aSocket is NOT pushed to CleanupStack.
|
|
164 |
* @param aSocketServer reference to the socket server object
|
|
165 |
* @param aSocket The socket that will be opened
|
|
166 |
* @param aSmsAddr The sms address to bind to
|
|
167 |
*/
|
|
168 |
{
|
|
169 |
TInt ret=aSocket.Open(aSocketServer,KSMSAddrFamily,KSockDatagram,KSMSDatagramProtocol);
|
|
170 |
PRINTF2(_L("Socket Open Return Value : %d"),ret);
|
|
171 |
LOCAL_CHECKPOINT(ret == KErrNone);
|
|
172 |
CleanupClosePushL(aSocket);
|
|
173 |
ret=aSocket.Bind(aSmsAddr);
|
|
174 |
PRINTF2(_L("Socket Bind Return Value : %d"),ret);
|
|
175 |
LOCAL_CHECKPOINT(ret == KErrNone);
|
|
176 |
|
|
177 |
TProtocolDesc desc;
|
|
178 |
aSocket.Info(desc);
|
|
179 |
PRINTF2(_L("Protocol name: %S"), &desc.iName);
|
|
180 |
|
|
181 |
TTimeIntervalMicroSeconds32 InitPause=9000000; //Required Pause to Allow SMSStack to Complete its Async Init
|
|
182 |
User::After(InitPause); //call to the TSY and finish its StartUp.
|
|
183 |
|
|
184 |
CleanupStack::Pop(&aSocket);
|
|
185 |
}
|
|
186 |
|
|
187 |
EXPORT_C void CSmsStackTestUtils::SendSmsAndChangeBearerL(CSmsMessage* aSms, RSocket& aSocket, RMobileSmsMessaging::TMobileSmsBearer aBearer)
|
|
188 |
/**
|
|
189 |
* Stream aSms out to the socket server. The idea is to change bearer midway through
|
|
190 |
* sending the PDUs making up the complete message.
|
|
191 |
* @param aSms contains the sms tpdu that will be streamed to the sms stack
|
|
192 |
* @param aSocket is used to stream the aSms to the sms stack
|
|
193 |
* @param aBearer Bearer setting that is changed to CommDb
|
|
194 |
* @leave Leaves if streaming the message to the socket server doesn't succeed
|
|
195 |
* @leave Leaves if sending is completed with error code
|
|
196 |
*/
|
|
197 |
{
|
|
198 |
RSmsSocketWriteStream writestream(aSocket);
|
|
199 |
TRAPD(ret,writestream << *aSms);
|
|
200 |
LOCAL_CHECKPOINT(ret == KErrNone);
|
|
201 |
TRAP(ret,writestream.CommitL());
|
|
202 |
LOCAL_CHECKPOINT(ret == KErrNone);
|
|
203 |
|
|
204 |
// Create comms database object
|
|
205 |
CMDBSession* db = CMDBSession::NewL(KCDVersion1_1);
|
|
206 |
CleanupStack::PushL(db);
|
|
207 |
|
|
208 |
//Send message and change bearer
|
|
209 |
TPckgBuf<TUint> sbuf;
|
|
210 |
TRequestStatus status;
|
|
211 |
aSocket.Ioctl(KIoctlSendSmsMessage, status, &sbuf, KSolSmsProv);
|
|
212 |
|
|
213 |
//Wait couple of seconds to ensure first pdus of message have been sent
|
|
214 |
User::After(2500000);
|
|
215 |
|
|
216 |
// Change bearer
|
|
217 |
CMDBField<TUint32>* smsBearerField = new(ELeave) CMDBField<TUint32>(KCDTIdSMSBearer);
|
|
218 |
CleanupStack::PushL(smsBearerField);
|
|
219 |
smsBearerField->SetRecordId(1); //it's GlobalSettingsRecord
|
|
220 |
*smsBearerField = aBearer;
|
|
221 |
smsBearerField->ModifyL(*db);
|
|
222 |
CleanupStack::PopAndDestroy(smsBearerField);
|
|
223 |
CleanupStack::PopAndDestroy(db);
|
|
224 |
|
|
225 |
User::WaitForRequest(status);
|
|
226 |
PRINTF2(_L("SendSmsL - sendSmsMessage returned %d"), status.Int());
|
|
227 |
LOCAL_CHECKPOINT(status.Int() == KErrNone);
|
|
228 |
|
|
229 |
CSmsBuffer& smsbuffer = (CSmsBuffer&)aSms->Buffer();
|
|
230 |
TInt len = smsbuffer.Length();
|
|
231 |
HBufC* hbuf = HBufC::NewL(len);
|
|
232 |
TPtr ptr = hbuf->Des();
|
|
233 |
smsbuffer.Extract(ptr,0,len);
|
|
234 |
PRINTF2(_L("SMS contains %d characters"),len);
|
|
235 |
delete hbuf;
|
|
236 |
}
|
|
237 |
|
|
238 |
EXPORT_C void CSmsStackTestUtils::ChangeBearerL(RMobileSmsMessaging::TMobileSmsBearer aBearer)
|
|
239 |
/**
|
|
240 |
Change the bearer in CommDB global settings.
|
|
241 |
|
|
242 |
@param aBearer The new bearer setting.
|
|
243 |
@return none
|
|
244 |
*/
|
|
245 |
{
|
|
246 |
// Start a CommDB session
|
|
247 |
#ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
|
|
248 |
CMDBSession* db = CMDBSession::NewL(KCDVersion1_2);
|
|
249 |
#else
|
|
250 |
CMDBSession* db = CMDBSession::NewL(KCDVersion1_1);
|
|
251 |
#endif
|
|
252 |
CleanupStack::PushL(db);
|
|
253 |
|
|
254 |
// Change bearer in global settings
|
|
255 |
CMDBRecordSet<CCDGlobalSettingsRecord> globalSettingsRecord(KCDTIdGlobalSettingsRecord);
|
|
256 |
TRAPD(err, globalSettingsRecord.LoadL(*db));
|
|
257 |
if (err != KErrNone)
|
|
258 |
{
|
|
259 |
PRINTF2(_L("Could not load global settings. Error = %d\n"), err);
|
|
260 |
User::Leave(err);
|
|
261 |
}
|
|
262 |
((CCDGlobalSettingsRecord*)globalSettingsRecord.iRecords[0])->iSMSBearer = aBearer;
|
|
263 |
globalSettingsRecord.ModifyL(*db);
|
|
264 |
|
|
265 |
PRINTF2(_L("Setting bearer in global settings to %d\n"), aBearer);
|
|
266 |
|
|
267 |
CleanupStack::PopAndDestroy(db);
|
|
268 |
}
|
|
269 |
|
|
270 |
EXPORT_C void CSmsStackTestUtils::GetBearerL(RMobileSmsMessaging::TMobileSmsBearer& aBearer)
|
|
271 |
/**
|
|
272 |
Get the bearer from CommDB global settings.
|
|
273 |
|
|
274 |
@param aBearer The bearer setting retrieved from global settings.
|
|
275 |
@return none
|
|
276 |
*/
|
|
277 |
{
|
|
278 |
// Start a CommDB session
|
|
279 |
#ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
|
|
280 |
CMDBSession* db = CMDBSession::NewL(KCDVersion1_2);
|
|
281 |
#else
|
|
282 |
CMDBSession* db = CMDBSession::NewL(KCDVersion1_1);
|
|
283 |
#endif
|
|
284 |
CleanupStack::PushL(db);
|
|
285 |
|
|
286 |
// Load global settings
|
|
287 |
CMDBRecordSet<CCDGlobalSettingsRecord> globalSettingsRecord(KCDTIdGlobalSettingsRecord);
|
|
288 |
TRAPD(err, globalSettingsRecord.LoadL(*db));
|
|
289 |
if (err != KErrNone)
|
|
290 |
{
|
|
291 |
PRINTF2(_L("Could not load global settings. Error = %d\n"), err);
|
|
292 |
User::Leave(err);
|
|
293 |
}
|
|
294 |
TInt tempBearer = ((CCDGlobalSettingsRecord*)globalSettingsRecord.iRecords[0])->iSMSBearer;
|
|
295 |
aBearer = static_cast<RMobileSmsMessaging::TMobileSmsBearer>(tempBearer);
|
|
296 |
PRINTF2(_L("Got bearer from CommDB. Bearer = %d\n"), aBearer);
|
|
297 |
|
|
298 |
CleanupStack::PopAndDestroy(db);
|
|
299 |
}
|
|
300 |
|
|
301 |
EXPORT_C void CSmsStackTestUtils::DisableLogging()
|
|
302 |
{
|
|
303 |
CTSmsRegTstActive* testActive = new(ELeave)CTSmsRegTstActive();
|
|
304 |
CleanupStack::PushL(testActive);
|
|
305 |
testActive->StartL();
|
|
306 |
|
|
307 |
CLogWrapper* logWrapper=CLogWrapper::NewL(iFs);
|
|
308 |
CleanupStack::PushL(logWrapper);
|
|
309 |
CLogClient& logClient = static_cast<CLogClient&>(logWrapper->Log());
|
|
310 |
TLogConfig config;
|
|
311 |
logClient.GetConfig(config, testActive->iStatus);
|
|
312 |
CActiveScheduler::Start();
|
|
313 |
LOCAL_CHECKPOINT(testActive->iStatus.Int() == KErrNone);
|
|
314 |
|
|
315 |
// Disable logging
|
|
316 |
config.iMaxEventAge = 0;
|
|
317 |
config.iMaxLogSize = 0;
|
|
318 |
config.iMaxRecentLogSize = 0;
|
|
319 |
|
|
320 |
testActive->StartL();
|
|
321 |
logClient.ChangeConfig(config, testActive->iStatus);
|
|
322 |
CActiveScheduler::Start();
|
|
323 |
LOCAL_CHECKPOINT(testActive->iStatus.Int() == KErrNone);
|
|
324 |
|
|
325 |
CleanupStack::PopAndDestroy(2, testActive); // testActive, logWrapper
|
|
326 |
}
|
|
327 |
|
|
328 |
EXPORT_C void CSmsStackTestUtils::EnableLogging()
|
|
329 |
{
|
|
330 |
CTSmsRegTstActive* testActive = new(ELeave)CTSmsRegTstActive();
|
|
331 |
CleanupStack::PushL(testActive);
|
|
332 |
testActive->StartL();
|
|
333 |
|
|
334 |
CLogWrapper* logWrapper=CLogWrapper::NewL(iFs);
|
|
335 |
CleanupStack::PushL(logWrapper);
|
|
336 |
CLogClient& logClient = static_cast<CLogClient&> (logWrapper->Log());
|
|
337 |
TLogConfig config;
|
|
338 |
logClient.GetConfig(config, testActive->iStatus);
|
|
339 |
CActiveScheduler::Start();
|
|
340 |
LOCAL_CHECKPOINT(testActive->iStatus.Int() == KErrNone);
|
|
341 |
|
|
342 |
// Enable logging - default values
|
|
343 |
config.iMaxEventAge = 2592000;
|
|
344 |
config.iMaxLogSize = 1000;
|
|
345 |
config.iMaxRecentLogSize = 20;
|
|
346 |
|
|
347 |
testActive->StartL();
|
|
348 |
logClient.ChangeConfig(config, testActive->iStatus);
|
|
349 |
CActiveScheduler::Start();
|
|
350 |
LOCAL_CHECKPOINT(testActive->iStatus.Int() == KErrNone);
|
|
351 |
|
|
352 |
CleanupStack::PopAndDestroy(2, testActive); // testActive, logWrapper
|
|
353 |
}
|
|
354 |
|
|
355 |
EXPORT_C void CSmsStackTestUtils::GetLogEventL(CLogEvent& aLogEvent, TInt aLogServerId)
|
|
356 |
/**
|
|
357 |
* Get SMS log event from event logger.
|
|
358 |
* @param aLogEvent reference to the CLogEvent object
|
|
359 |
* @param aLogServerId number of log event
|
|
360 |
*/
|
|
361 |
{
|
|
362 |
CTSmsRegTstActive* testActive = new(ELeave)CTSmsRegTstActive();
|
|
363 |
CleanupStack::PushL(testActive);
|
|
364 |
|
|
365 |
CLogWrapper* logWrapper=CLogWrapper::NewL(iFs);
|
|
366 |
CleanupStack::PushL(logWrapper);
|
|
367 |
|
|
368 |
aLogEvent.SetId(aLogServerId);
|
|
369 |
testActive->StartL();
|
|
370 |
logWrapper->Log().GetEvent(aLogEvent,testActive->iStatus);
|
|
371 |
CActiveScheduler::Start();
|
|
372 |
LOCAL_CHECKPOINT(testActive->iStatus.Int() == KErrNone);
|
|
373 |
|
|
374 |
CleanupStack::PopAndDestroy(2, testActive); // testActive, logWrapper
|
|
375 |
}
|
|
376 |
|
|
377 |
EXPORT_C TLogId CSmsStackTestUtils::AddLogEventL(CSmsMessage& aSmsMessage,TLogSmsPduData& aSmsPDUData)
|
|
378 |
/**
|
|
379 |
* Add SMS log event to the event logger.
|
|
380 |
* @param aSmsMessage SM mesage
|
|
381 |
* @param aLogSmsPduData initialised structure with data relevant to logging
|
|
382 |
*/
|
|
383 |
{
|
|
384 |
CTSmsRegTstActive* testActive = new(ELeave)CTSmsRegTstActive();
|
|
385 |
CleanupStack::PushL(testActive);
|
|
386 |
|
|
387 |
CLogWrapper* logWrapper=CLogWrapper::NewL(iFs);
|
|
388 |
CleanupStack::PushL(logWrapper);
|
|
389 |
|
|
390 |
TLogId id=NULL;
|
|
391 |
|
|
392 |
if(logWrapper->ClientAvailable())
|
|
393 |
{
|
|
394 |
testActive->StartL();
|
|
395 |
|
|
396 |
|
|
397 |
CLogEvent* logevent=CLogEvent::NewL();
|
|
398 |
CleanupStack::PushL(logevent);
|
|
399 |
|
|
400 |
TBuf<KLogMaxDirectionLength> direction;
|
|
401 |
User::LeaveIfError(logWrapper->Log().GetString(direction,R_LOG_DIR_OUT));
|
|
402 |
|
|
403 |
|
|
404 |
logevent->SetDirection(direction);
|
|
405 |
logevent->SetEventType(KLogShortMessageEventTypeUid);
|
|
406 |
logevent->SetNumber(aSmsMessage.ToFromAddress());
|
|
407 |
|
|
408 |
logevent->SetSubject(_L("test"));
|
|
409 |
logevent->SetStatus(_L("status"));
|
|
410 |
TPckg<TLogSmsPduData> packeddata(aSmsPDUData);
|
|
411 |
logevent->SetDataL(packeddata);
|
|
412 |
|
|
413 |
PRINTF2(_L("iStatus is %d"), testActive->iStatus.Int());
|
|
414 |
logWrapper->Log().AddEvent(*logevent,testActive->iStatus);
|
|
415 |
CActiveScheduler::Start();
|
|
416 |
PRINTF2(_L("iStatus is %d"), testActive->iStatus.Int());
|
|
417 |
LOCAL_CHECKPOINT(testActive->iStatus.Int() == KErrNone);
|
|
418 |
id=logevent->Id();
|
|
419 |
CleanupStack::PopAndDestroy(logevent);
|
|
420 |
}
|
|
421 |
|
|
422 |
CleanupStack::PopAndDestroy(2, testActive); // testActive, logWrapper
|
|
423 |
return id;
|
|
424 |
}
|
|
425 |
|
|
426 |
|
|
427 |
EXPORT_C void CSmsStackTestUtils::CopyConfigFileL(const TDesC& aFromSmsConfigFile, CSmsPduDatabase* aPduDb)
|
|
428 |
{
|
|
429 |
PRINTF3(_L("Copying %S to %S..."), &aFromSmsConfigFile, &KSimTsyConfigFileName);
|
|
430 |
TBool createdDb = EFalse;
|
|
431 |
|
|
432 |
if (aPduDb == NULL)
|
|
433 |
{
|
|
434 |
aPduDb = CSmsPduDatabase::NewL(iFs);
|
|
435 |
CleanupStack::PushL(aPduDb);
|
|
436 |
createdDb = ETrue;
|
|
437 |
}
|
|
438 |
|
|
439 |
aPduDb->RewriteFileL(aFromSmsConfigFile, KGmsSmsConfigFileDir, KSimTsyConfigFileName);
|
|
440 |
PRINTF1(_L("done"));
|
|
441 |
|
|
442 |
if (createdDb)
|
|
443 |
CleanupStack::PopAndDestroy(aPduDb);
|
|
444 |
}
|
|
445 |
|
|
446 |
|
|
447 |
EXPORT_C CSmsMessage* CSmsStackTestUtils::CreateSmsMessageLC(CSmsPDU::TSmsPDUType aType, const TDesC& aDestination, const TDesC& aMessage)
|
|
448 |
{
|
|
449 |
CSmsBuffer* buffer = CSmsBuffer::NewL();
|
|
450 |
buffer->InsertL(0, aMessage);
|
|
451 |
|
|
452 |
CSmsMessage* message = CSmsMessage::NewL(iFs, aType, buffer);
|
|
453 |
CleanupStack::PushL(message);
|
|
454 |
|
|
455 |
message->SetToFromAddressL(aDestination);
|
|
456 |
|
|
457 |
return message;
|
|
458 |
}
|
|
459 |
|
|
460 |
EXPORT_C void CSmsStackTestUtils::AddSmsRxL(CTestConfig& aConfigFile, TInt aTestNumber, CSmsMessage& aMessage, const TDesC& aServiceCenter) const
|
|
461 |
{
|
|
462 |
_LIT8(KSmspTestUtilsSmsRx, "SmsRx");
|
|
463 |
_LIT8(KSmspTestUtilsSmsRxFormat, "%S, %S");
|
|
464 |
|
|
465 |
CTestConfigSection& section = GetSectionL(aConfigFile, aTestNumber);
|
|
466 |
|
|
467 |
CArrayFixFlat<TGsmSms>* pdus = EncodeMessageLC(aMessage);
|
|
468 |
|
|
469 |
const TInt pduCount = pdus->Count();
|
|
470 |
|
|
471 |
for (TInt i = 0; i < pduCount; i++)
|
|
472 |
{
|
|
473 |
const TGsmSms& pdu = (*pdus)[i];
|
|
474 |
|
|
475 |
HBufC8* pduBuf = ConvertToHexLC(pdu.Pdu());
|
|
476 |
|
|
477 |
HBufC8* sc = HBufC8::NewLC(aServiceCenter.Length());
|
|
478 |
sc->Des().Copy(aServiceCenter);
|
|
479 |
|
|
480 |
const TInt maxLen = KSmspTestUtilsSmsRxFormat().Length() + pduBuf->Length() + sc->Length();
|
|
481 |
HBufC8* smsRx = HBufC8::NewLC(maxLen);
|
|
482 |
|
|
483 |
smsRx->Des().AppendFormat(KSmspTestUtilsSmsRxFormat, pduBuf, sc);
|
|
484 |
|
|
485 |
CTestConfigItem* item = CTestConfigItem::NewLC(section, KSmspTestUtilsSmsRx, *smsRx);
|
|
486 |
|
|
487 |
User::LeaveIfError(section.Items().Append(item));
|
|
488 |
|
|
489 |
CleanupStack::Pop(item);
|
|
490 |
CleanupStack::PopAndDestroy(smsRx);
|
|
491 |
CleanupStack::PopAndDestroy(sc);
|
|
492 |
CleanupStack::PopAndDestroy(pduBuf);
|
|
493 |
}
|
|
494 |
|
|
495 |
CleanupStack::PopAndDestroy(pdus);
|
|
496 |
}
|
|
497 |
|
|
498 |
EXPORT_C CTestConfigSection& CSmsStackTestUtils::GetSectionL(CTestConfig& aConfigFile, TInt aTestNumber) const
|
|
499 |
{
|
|
500 |
_LIT8(KSmspTestUtilsTest, "test%d");
|
|
501 |
|
|
502 |
TBuf8<16> test;
|
|
503 |
test.AppendFormat(KSmspTestUtilsTest, aTestNumber);
|
|
504 |
CTestConfigSection* section = aConfigFile.Section(test);
|
|
505 |
|
|
506 |
if (section == NULL)
|
|
507 |
{
|
|
508 |
User::Leave(KErrNotFound);
|
|
509 |
}
|
|
510 |
|
|
511 |
return *section;
|
|
512 |
}
|
|
513 |
|
|
514 |
EXPORT_C void CSmsStackTestUtils::AddSmsTxL(CTestConfig& aConfigFile, TInt aTestNumber, CSmsMessage& aMessage, const TDesC& aServiceCenter, TInt aMsgRef, CSmsMessage* aSubmitReport, TInt aExpectedError) const
|
|
515 |
{
|
|
516 |
_LIT8(KSmspTestUtilsSmsTx, "SmsTx");
|
|
517 |
_LIT8(KSmspTestUtilsSmsTxFormat, "%S, %S, %d, %S, %d");
|
|
518 |
|
|
519 |
CTestConfigSection& section = GetSectionL(aConfigFile, aTestNumber);
|
|
520 |
CArrayFixFlat<TGsmSms>* pdus = EncodeMessageLC(aMessage);
|
|
521 |
|
|
522 |
HBufC8* submitReport = NULL;
|
|
523 |
|
|
524 |
if (aSubmitReport == NULL)
|
|
525 |
{
|
|
526 |
submitReport = KNullDesC8().AllocLC();
|
|
527 |
}
|
|
528 |
else
|
|
529 |
{
|
|
530 |
CArrayFixFlat<TGsmSms>* srPdus = EncodeMessageLC(*aSubmitReport);
|
|
531 |
const TGsmSms& pdu = (*srPdus)[0];
|
|
532 |
submitReport = ConvertToHexLC(pdu.Pdu());
|
|
533 |
CleanupStack::Pop(submitReport);
|
|
534 |
CleanupStack::PopAndDestroy(srPdus);
|
|
535 |
CleanupStack::PushL(submitReport);
|
|
536 |
}
|
|
537 |
|
|
538 |
const TInt pduCount = pdus->Count();
|
|
539 |
|
|
540 |
for (TInt i = 0; i < pduCount; i++)
|
|
541 |
{
|
|
542 |
const TGsmSms& pdu = (*pdus)[i];
|
|
543 |
HBufC8* pduBuf = ConvertToHexLC(pdu.Pdu());
|
|
544 |
|
|
545 |
HBufC8* sc = HBufC8::NewLC(aServiceCenter.Length());
|
|
546 |
sc->Des().Copy(aServiceCenter);
|
|
547 |
|
|
548 |
const TInt maxLen = KSmspTestUtilsSmsTxFormat().Length() + pduBuf->Length() + sc->Length() + submitReport->Length();
|
|
549 |
HBufC8* smsTx = HBufC8::NewLC(maxLen);
|
|
550 |
|
|
551 |
smsTx->Des().AppendFormat(KSmspTestUtilsSmsTxFormat, pduBuf, sc, aMsgRef, submitReport, aExpectedError);
|
|
552 |
|
|
553 |
CTestConfigItem* item = CTestConfigItem::NewLC(section, KSmspTestUtilsSmsTx, *smsTx);
|
|
554 |
|
|
555 |
User::LeaveIfError(section.Items().Append(item));
|
|
556 |
|
|
557 |
CleanupStack::Pop(item);
|
|
558 |
CleanupStack::PopAndDestroy(3, pduBuf); // smsTx, sc, pduBuf
|
|
559 |
}
|
|
560 |
|
|
561 |
CleanupStack::PopAndDestroy(2, pdus); // pdus, submitReport
|
|
562 |
}
|
|
563 |
|
|
564 |
EXPORT_C HBufC8* CSmsStackTestUtils::ConvertToHexLC(const TDesC8& aDes) const
|
|
565 |
{
|
|
566 |
const TInt len = aDes.Length();
|
|
567 |
|
|
568 |
HBufC8* hBuf = HBufC8::NewLC(len*2);
|
|
569 |
TPtr8 value(hBuf->Des());
|
|
570 |
|
|
571 |
for (TInt i = 0; i < len; i++)
|
|
572 |
{
|
|
573 |
value.AppendFormat(_L8("%02X"), aDes[i]);
|
|
574 |
}
|
|
575 |
return hBuf;
|
|
576 |
}
|
|
577 |
|
|
578 |
CArrayFixFlat<TGsmSms>* CSmsStackTestUtils::EncodeMessageLC(CSmsMessage& aMessage) const
|
|
579 |
{
|
|
580 |
CArrayFixFlat<TGsmSms>* array = new (ELeave) CArrayFixFlat<TGsmSms>(1);
|
|
581 |
CleanupStack::PushL(array);
|
|
582 |
aMessage.EncodeMessagePDUsL(*array);
|
|
583 |
return array;
|
|
584 |
}
|
|
585 |
|
|
586 |
EXPORT_C TSmsFirstOctet CSmsStackTestUtils::FirstDeliverOctet(TBool aMMS, TBool aRP, TBool aUDHI, TBool aSRI)
|
|
587 |
{
|
|
588 |
TSmsFirstOctet firstOctet(0);
|
|
589 |
|
|
590 |
if (!aMMS)
|
|
591 |
firstOctet = firstOctet | TSmsFirstOctet::ESmsNoMoreMessagesToSend;
|
|
592 |
|
|
593 |
if (aRP)
|
|
594 |
firstOctet = firstOctet | TSmsFirstOctet::ESmsReplyPathExists;
|
|
595 |
|
|
596 |
if (aUDHI)
|
|
597 |
firstOctet = firstOctet | TSmsFirstOctet::ESmsUDHIHeaderPresent;
|
|
598 |
|
|
599 |
if (aSRI)
|
|
600 |
firstOctet = firstOctet | TSmsFirstOctet::ESmsStatusReportRequested;
|
|
601 |
|
|
602 |
return firstOctet;
|
|
603 |
}
|
|
604 |
|
|
605 |
EXPORT_C void CSmsStackTestUtils::DeliverWithoutUserDataL(TGsmSms& aPdu, TSmsFirstOctet aFO, const TGsmSmsTelNumber& aOA, TSmsProtocolIdentifier aPID, TSmsDataCodingScheme aDCS, const TTime& aSCTS, TInt aUTCOffset)
|
|
606 |
{
|
|
607 |
RMobileSmsMessaging::TMobileSmsGsmTpdu pdu;
|
|
608 |
pdu.SetLength(pdu.MaxLength());
|
|
609 |
TUint8* ptr0 = &pdu[0];
|
|
610 |
TUint8* ptr1 = ptr0;
|
|
611 |
|
|
612 |
//Prepare the OA
|
|
613 |
CSmsAddress* addr = CSmsAddress::NewL(*iCharConv, iFs);
|
|
614 |
CleanupStack::PushL(addr);
|
|
615 |
addr->SetParsedAddressL(aOA);
|
|
616 |
|
|
617 |
//Prepare the service center time stamp
|
|
618 |
TSmsServiceCenterTimeStamp time;
|
|
619 |
time.SetTime(aSCTS);
|
|
620 |
time.SetTimeOffset(aUTCOffset);
|
|
621 |
|
|
622 |
//Encode the PDU. Unfortunately this relies on GSMU.
|
|
623 |
ptr1 = aFO.EncodeL(ptr1);
|
|
624 |
ptr1 = addr->EncodeL(ptr1);
|
|
625 |
ptr1 = aPID.EncodeL(ptr1);
|
|
626 |
ptr1 = aDCS.EncodeL(ptr1);
|
|
627 |
ptr1 = time.EncodeL(ptr1);
|
|
628 |
pdu.SetLength(ptr1 - ptr0);
|
|
629 |
aPdu.SetPdu(pdu);
|
|
630 |
|
|
631 |
CleanupStack::PopAndDestroy(addr);
|
|
632 |
}
|
|
633 |
|
|
634 |
/**
|
|
635 |
* This is a unit test for class TSmsServiceCenterTimeStamp. It is added to this utility
|
|
636 |
* class because it has access to TSmsServiceCenterTimeStamp. TSmsServiceCenterTimeStamp is not exported
|
|
637 |
* out of the gsmsu.dll. This is why this project compiles with gsmsuelem.cpp.
|
|
638 |
*/
|
|
639 |
EXPORT_C void CSmsStackTestUtils::CreateTSmsServiceCenterTimeStampL()
|
|
640 |
{
|
|
641 |
//Prepare the service center time stamp
|
|
642 |
TSmsServiceCenterTimeStamp serviceCenterTime;
|
|
643 |
TTime utcTime;
|
|
644 |
TInt offset=0;
|
|
645 |
utcTime.UniversalTime();
|
|
646 |
|
|
647 |
// Set and Get
|
|
648 |
serviceCenterTime.SetTime(utcTime);
|
|
649 |
serviceCenterTime.SetTimeOffset(offset);
|
|
650 |
|
|
651 |
TTime testTimeValue=serviceCenterTime.Time();
|
|
652 |
TInt testOffsetValue=serviceCenterTime.TimeOffset();
|
|
653 |
|
|
654 |
LOCAL_CHECKPOINT(testTimeValue==utcTime);
|
|
655 |
LOCAL_CHECKPOINT(testOffsetValue==offset);
|
|
656 |
|
|
657 |
//boundary value checks
|
|
658 |
//Offset is stored in number of quarter hours.
|
|
659 |
//Max/Min value = +/- 79
|
|
660 |
//This is the maximum value specified in the spec 3GPP TS23.040
|
|
661 |
//The biggest value allowed by the production code is KSmsMaxTimeZoneNumQuarterHours=79
|
|
662 |
//This is the maximum value that can be stored in the PDU when encoded. Actual max byte
|
|
663 |
//storage space available. The test will check that this maximum will be allowable.
|
|
664 |
//Values beyond 79 will cause the thread to panic
|
|
665 |
TInt positiveValue=79;
|
|
666 |
TInt negativeValue=-79;
|
|
667 |
|
|
668 |
serviceCenterTime.SetTimeOffset(positiveValue);
|
|
669 |
testOffsetValue=serviceCenterTime.TimeOffset();
|
|
670 |
LOCAL_CHECKPOINT(testOffsetValue==positiveValue);
|
|
671 |
|
|
672 |
serviceCenterTime.SetTimeOffset(negativeValue);
|
|
673 |
testOffsetValue=serviceCenterTime.TimeOffset();
|
|
674 |
LOCAL_CHECKPOINT(testOffsetValue==negativeValue);
|
|
675 |
|
|
676 |
//Try past the end. This panics the test case. It has been done as a check to test
|
|
677 |
// a panic will be raised.
|
|
678 |
/* TInt overFlowValue=80;
|
|
679 |
serviceCenterTime.SetTimeOffset(overFlowValue);
|
|
680 |
|
|
681 |
TInt underFlowValue=-99;
|
|
682 |
serviceCenterTime.SetTimeOffset(underFlowValue);
|
|
683 |
*/
|
|
684 |
}
|
|
685 |
|
|
686 |
EXPORT_C void CSmsStackTestUtils::DecodeTSmsServiceCenterTimeStampL()
|
|
687 |
{
|
|
688 |
//Decode timestamp
|
|
689 |
TTimeIntervalSeconds oneSecond(1);
|
|
690 |
const TInt KTimeStampSize=7;
|
|
691 |
TInt ret=0;
|
|
692 |
TBuf8<KTimeStampSize> encodedPdu;
|
|
693 |
encodedPdu.SetLength(encodedPdu.MaxLength());
|
|
694 |
|
|
695 |
//---------------------------------------------------
|
|
696 |
//Decode a valid service center time stamp
|
|
697 |
//Expected UTC = 29/02/2004, 15h30m0s, offset=3hrs
|
|
698 |
//Local Time = 29/02/2004, 18h30m0s
|
|
699 |
TDateTime utcDateTime(2004,EFebruary,28,15,30,0,0);
|
|
700 |
TTime expectedDecodedTime(utcDateTime);
|
|
701 |
|
|
702 |
encodedPdu[0]=0x40; //year=2004
|
|
703 |
encodedPdu[1]=0x20; //month=Feb
|
|
704 |
encodedPdu[2]=0x92; //day=29th
|
|
705 |
encodedPdu[3]=0x81; //hour=18h
|
|
706 |
encodedPdu[4]=0x03; //minute=30min
|
|
707 |
encodedPdu[5]=0x00; //second=0
|
|
708 |
encodedPdu[6]=0x21; //timeZone=12x15min=3hrs
|
|
709 |
|
|
710 |
//Decode the service center time stamp. This must equal the expected
|
|
711 |
TGsmuLex8 pduTime(encodedPdu);
|
|
712 |
TSmsServiceCenterTimeStamp serviceCenterTimeStamp;
|
|
713 |
serviceCenterTimeStamp.DecodeL(pduTime,ret);
|
|
714 |
LOCAL_CHECKPOINT(ret==KErrNone);
|
|
715 |
|
|
716 |
//Compare the times
|
|
717 |
TTime time=serviceCenterTimeStamp.Time();
|
|
718 |
LOCAL_CHECKPOINT(time==expectedDecodedTime);
|
|
719 |
|
|
720 |
//Check the offset
|
|
721 |
TInt offset=serviceCenterTimeStamp.TimeOffset();
|
|
722 |
LOCAL_CHECKPOINT(offset==12);
|
|
723 |
|
|
724 |
//---------------------------------------------------
|
|
725 |
//Decode a negative offset
|
|
726 |
//Expected UTC = 29/02/2004, 15h30m0s, offset=-5hrs
|
|
727 |
//Local Time = 29/02/2004, 10h30m0s
|
|
728 |
|
|
729 |
encodedPdu[0]=0x40; //year=2004
|
|
730 |
encodedPdu[1]=0x20; //month=Feb
|
|
731 |
encodedPdu[2]=0x92; //day=29
|
|
732 |
encodedPdu[3]=0x01; //hour=10
|
|
733 |
encodedPdu[4]=0x03; //minute=30
|
|
734 |
encodedPdu[5]=0x00; //second
|
|
735 |
encodedPdu[6]=0x0A; //timeZone=-5hrs=15minx20, 4th bit is 1 for negative
|
|
736 |
|
|
737 |
|
|
738 |
//Decode the service center time stamp. This must equal the expected
|
|
739 |
pduTime=TGsmuLex8(encodedPdu);
|
|
740 |
serviceCenterTimeStamp.DecodeL(pduTime,ret);
|
|
741 |
LOCAL_CHECKPOINT(ret==KErrNone);
|
|
742 |
|
|
743 |
//Compare the times
|
|
744 |
time=serviceCenterTimeStamp.Time();
|
|
745 |
LOCAL_CHECKPOINT(time==expectedDecodedTime);
|
|
746 |
|
|
747 |
//Check the offset
|
|
748 |
offset=serviceCenterTimeStamp.TimeOffset();
|
|
749 |
LOCAL_CHECKPOINT(offset==-20);
|
|
750 |
|
|
751 |
//---------------------------------------------------
|
|
752 |
//Decode time stamp over new year
|
|
753 |
//
|
|
754 |
//Expected UTC = 01/01/2005, 00h15m0s, offset=-1h15m
|
|
755 |
//Local Time = 31/12/2004, 23h00m0s
|
|
756 |
utcDateTime=TDateTime(2005,EJanuary,0,0,15,0,0);
|
|
757 |
expectedDecodedTime=TTime(utcDateTime);
|
|
758 |
|
|
759 |
encodedPdu[0]=0x40; //year=2004
|
|
760 |
encodedPdu[1]=0x21; //month=December=12
|
|
761 |
encodedPdu[2]=0x13; //day=31
|
|
762 |
encodedPdu[3]=0x32; //hour=23hrs
|
|
763 |
encodedPdu[4]=0x00; //minute=0
|
|
764 |
encodedPdu[5]=0x00; //second=0
|
|
765 |
encodedPdu[6]=0x58; //timeZone is -5.
|
|
766 |
// -5x15min=-1hr15min
|
|
767 |
|
|
768 |
//Decode the service center time stamp. This must equal the expected
|
|
769 |
pduTime=TGsmuLex8(encodedPdu);
|
|
770 |
serviceCenterTimeStamp.DecodeL(pduTime,ret);
|
|
771 |
LOCAL_CHECKPOINT(ret==KErrNone);
|
|
772 |
|
|
773 |
//Compare the times
|
|
774 |
time=serviceCenterTimeStamp.Time();
|
|
775 |
LOCAL_CHECKPOINT(time==expectedDecodedTime);
|
|
776 |
|
|
777 |
//Check the offset
|
|
778 |
offset=serviceCenterTimeStamp.TimeOffset();
|
|
779 |
LOCAL_CHECKPOINT(offset==-5);
|
|
780 |
|
|
781 |
//---------------------------------------------------
|
|
782 |
//Decode over leap year
|
|
783 |
|
|
784 |
//Expected UTC = 29/02/2004, 21h00m0s, offset=+5h 30min 0s
|
|
785 |
//Local Time = 01/03/2004, 02h30m0s
|
|
786 |
utcDateTime=TDateTime(2004,EFebruary,28,21,0,0,0);
|
|
787 |
expectedDecodedTime=TTime(utcDateTime);
|
|
788 |
|
|
789 |
// local time is 01/03/2004 2hrs 30
|
|
790 |
encodedPdu[0]=0x40; //year=2004
|
|
791 |
encodedPdu[1]=0x30; //month=March
|
|
792 |
encodedPdu[2]=0x10; //day=1st
|
|
793 |
encodedPdu[3]=0x20; //hour=2hrs
|
|
794 |
encodedPdu[4]=0x03; //minute=30min
|
|
795 |
encodedPdu[5]=0x00; //second=0
|
|
796 |
encodedPdu[6]=0x22; //timeZone is 5hrs30min.
|
|
797 |
// 22x15min=5hr30min
|
|
798 |
|
|
799 |
pduTime=TGsmuLex8(encodedPdu);
|
|
800 |
serviceCenterTimeStamp.DecodeL(pduTime,ret);
|
|
801 |
LOCAL_CHECKPOINT(ret==KErrNone);
|
|
802 |
|
|
803 |
//Compare the times
|
|
804 |
time=serviceCenterTimeStamp.Time();
|
|
805 |
LOCAL_CHECKPOINT(time==expectedDecodedTime);
|
|
806 |
|
|
807 |
//Check the offset
|
|
808 |
offset=serviceCenterTimeStamp.TimeOffset();
|
|
809 |
LOCAL_CHECKPOINT(offset==22);
|
|
810 |
|
|
811 |
//---------------------------------------------------
|
|
812 |
//DecodeL a corrupt time stamp
|
|
813 |
encodedPdu[0]=0x40; //year
|
|
814 |
encodedPdu[1]=0x02; //month = 20
|
|
815 |
encodedPdu[2]=0x96; //day = 69
|
|
816 |
encodedPdu[3]=0x51; //hour
|
|
817 |
encodedPdu[4]=0x03; //minute
|
|
818 |
encodedPdu[5]=0; //second
|
|
819 |
encodedPdu[6]=0x20; //timezone=12
|
|
820 |
|
|
821 |
//Decode should fail trying to recreate the time.
|
|
822 |
pduTime=TGsmuLex8(encodedPdu);
|
|
823 |
serviceCenterTimeStamp.DecodeL(pduTime,ret);
|
|
824 |
LOCAL_CHECKPOINT(ret==KErrGeneral);
|
|
825 |
|
|
826 |
//---------------------------------------------------
|
|
827 |
//DecodeL a zero offset
|
|
828 |
|
|
829 |
//Expected UTC = 15/06/2004, 14h20, offset = 0
|
|
830 |
//Local Time = 15/06/2004, 14h20
|
|
831 |
utcDateTime=TDateTime(2004,EJune,14,14,20,0,0);
|
|
832 |
expectedDecodedTime=TTime(utcDateTime);
|
|
833 |
|
|
834 |
encodedPdu[0]=0x40; //year=2004
|
|
835 |
encodedPdu[1]=0x60; //month=06
|
|
836 |
encodedPdu[2]=0x51; //day=15
|
|
837 |
encodedPdu[3]=0x41; //hour=14
|
|
838 |
encodedPdu[4]=0x02; //minute=20
|
|
839 |
encodedPdu[5]=0x00; //second=0
|
|
840 |
encodedPdu[6]=0x00; //timezone=0
|
|
841 |
|
|
842 |
//Decode should bring back the same date. ie. local time==utc time
|
|
843 |
pduTime=TGsmuLex8(encodedPdu);
|
|
844 |
serviceCenterTimeStamp.DecodeL(pduTime,ret);
|
|
845 |
LOCAL_CHECKPOINT(ret==KErrNone);
|
|
846 |
|
|
847 |
//Compare the times
|
|
848 |
time=serviceCenterTimeStamp.Time();
|
|
849 |
LOCAL_CHECKPOINT(time==expectedDecodedTime);
|
|
850 |
|
|
851 |
//Check the offset
|
|
852 |
offset=serviceCenterTimeStamp.TimeOffset();
|
|
853 |
LOCAL_CHECKPOINT(offset==0);
|
|
854 |
|
|
855 |
//---------------------------------------------------
|
|
856 |
//DecodeL a maximum possitive offset
|
|
857 |
|
|
858 |
//Expected UTC = 15/06/2004, 01h20, offset = 19h45min
|
|
859 |
//Local Time = 15/06/2004, 21h05
|
|
860 |
utcDateTime=TDateTime(2004,EJune,14,01,20,0,0);
|
|
861 |
expectedDecodedTime=TTime(utcDateTime);
|
|
862 |
|
|
863 |
encodedPdu[0]=0x40; //year=2004
|
|
864 |
encodedPdu[1]=0x60; //month=06
|
|
865 |
encodedPdu[2]=0x51; //day=15
|
|
866 |
encodedPdu[3]=0x12; //hour=21
|
|
867 |
encodedPdu[4]=0x50; //minute=05
|
|
868 |
encodedPdu[5]=0x00; //second=0
|
|
869 |
encodedPdu[6]=0x97; //timezone=79x15min=19h45
|
|
870 |
//offset = 1185 minutes = 19h45min
|
|
871 |
|
|
872 |
//Decode should bring back the same date. ie. local time==utc time
|
|
873 |
pduTime=TGsmuLex8(encodedPdu);
|
|
874 |
serviceCenterTimeStamp.DecodeL(pduTime,ret);
|
|
875 |
LOCAL_CHECKPOINT(ret==KErrNone);
|
|
876 |
|
|
877 |
//Compare the times
|
|
878 |
time=serviceCenterTimeStamp.Time();
|
|
879 |
LOCAL_CHECKPOINT(time==expectedDecodedTime);
|
|
880 |
|
|
881 |
//Check the offset
|
|
882 |
offset=serviceCenterTimeStamp.TimeOffset();
|
|
883 |
LOCAL_CHECKPOINT(offset==79);
|
|
884 |
|
|
885 |
//---------------------------------------------------
|
|
886 |
//DecodeL a maximum negative offset
|
|
887 |
|
|
888 |
//Expected UTC = 15/06/2004, 23h45, offset = -19h45min
|
|
889 |
//Local Time = 15/06/2004, 04h00
|
|
890 |
utcDateTime=TDateTime(2004,EJune,14,23,45,0,0);
|
|
891 |
expectedDecodedTime=TTime(utcDateTime);
|
|
892 |
|
|
893 |
encodedPdu[0]=0x40; //year=2004
|
|
894 |
encodedPdu[1]=0x60; //month=06
|
|
895 |
encodedPdu[2]=0x51; //day=15
|
|
896 |
encodedPdu[3]=0x40; //hour=4
|
|
897 |
encodedPdu[4]=0x00; //minute=0
|
|
898 |
encodedPdu[5]=0x00; //second=0
|
|
899 |
encodedPdu[6]=0x9F; //timezone=-79x15min=-19h45
|
|
900 |
//offset = -1185 minutes = 19h45min
|
|
901 |
|
|
902 |
//Decode should bring back the same date. ie. local time==utc time
|
|
903 |
pduTime=TGsmuLex8(encodedPdu);
|
|
904 |
serviceCenterTimeStamp.DecodeL(pduTime,ret);
|
|
905 |
LOCAL_CHECKPOINT(ret==KErrNone);
|
|
906 |
|
|
907 |
//Compare the times
|
|
908 |
time=serviceCenterTimeStamp.Time();
|
|
909 |
LOCAL_CHECKPOINT(time==expectedDecodedTime);
|
|
910 |
|
|
911 |
//Check the offset
|
|
912 |
offset=serviceCenterTimeStamp.TimeOffset();
|
|
913 |
LOCAL_CHECKPOINT(offset==-79);
|
|
914 |
|
|
915 |
//---------------------------------------------------
|
|
916 |
//DecodeL a timestamp with an invalid offset 0xFF.
|
|
917 |
|
|
918 |
//Expected UTC = 15/06/2004, 14h20, offset = 0
|
|
919 |
//Local Time = 15/06/2004, 14h20
|
|
920 |
utcDateTime=TDateTime(2004,EJune,14,14,20,0,0);
|
|
921 |
expectedDecodedTime=TTime(utcDateTime);
|
|
922 |
|
|
923 |
encodedPdu[0]=0x40; //year=2004
|
|
924 |
encodedPdu[1]=0x60; //month=06
|
|
925 |
encodedPdu[2]=0x51; //day=15
|
|
926 |
encodedPdu[3]=0x41; //hour=14
|
|
927 |
encodedPdu[4]=0x02; //minute=20
|
|
928 |
encodedPdu[5]=0x00; //second=0
|
|
929 |
encodedPdu[6]=0xFF; //timezone off set is invalid, so set to zero
|
|
930 |
|
|
931 |
//Decode should bring back the same date. ie. local time==utc time
|
|
932 |
pduTime=TGsmuLex8(encodedPdu);
|
|
933 |
serviceCenterTimeStamp.DecodeL(pduTime,ret);
|
|
934 |
LOCAL_CHECKPOINT(ret==KErrNone);
|
|
935 |
|
|
936 |
//Compare the times
|
|
937 |
time=serviceCenterTimeStamp.Time();
|
|
938 |
LOCAL_CHECKPOINT(time==expectedDecodedTime);
|
|
939 |
|
|
940 |
//Check the offset
|
|
941 |
offset=serviceCenterTimeStamp.TimeOffset();
|
|
942 |
LOCAL_CHECKPOINT(offset==0);
|
|
943 |
|
|
944 |
//---------------------------------------------------
|
|
945 |
//DecodeL a timestamp with an invalid offset 0xAF
|
|
946 |
|
|
947 |
//Expected UTC = 15/06/2004, 14h20, offset = 0
|
|
948 |
//Local Time = 15/06/2004, 14h20
|
|
949 |
utcDateTime=TDateTime(2004,EJune,14,14,20,0,0);
|
|
950 |
expectedDecodedTime=TTime(utcDateTime);
|
|
951 |
|
|
952 |
encodedPdu[0]=0x40; //year=2004
|
|
953 |
encodedPdu[1]=0x60; //month=06
|
|
954 |
encodedPdu[2]=0x51; //day=15
|
|
955 |
encodedPdu[3]=0x41; //hour=14
|
|
956 |
encodedPdu[4]=0x02; //minute=20
|
|
957 |
encodedPdu[5]=0x00; //second=0
|
|
958 |
encodedPdu[6]=0xAF; //timezone off set is invalid, so set to zero
|
|
959 |
|
|
960 |
//Decode should bring back the same date. ie. local time==utc time
|
|
961 |
pduTime=TGsmuLex8(encodedPdu);
|
|
962 |
serviceCenterTimeStamp.DecodeL(pduTime,ret);
|
|
963 |
LOCAL_CHECKPOINT(ret==KErrNone);
|
|
964 |
|
|
965 |
//Compare the times
|
|
966 |
time=serviceCenterTimeStamp.Time();
|
|
967 |
LOCAL_CHECKPOINT(time==expectedDecodedTime);
|
|
968 |
|
|
969 |
//Check the offset
|
|
970 |
offset=serviceCenterTimeStamp.TimeOffset();
|
|
971 |
LOCAL_CHECKPOINT(offset==0);
|
|
972 |
}
|
|
973 |
|
|
974 |
|
|
975 |
EXPORT_C void CSmsStackTestUtils::EncodeTSmsServiceCenterTimeStampL()
|
|
976 |
{
|
|
977 |
//Encode timestamp
|
|
978 |
const TInt KServiceCenterBuffSizeInPDU=7; //Buffer is a 14 semi-octet buffer, 7 byte
|
|
979 |
TBuf8<KServiceCenterBuffSizeInPDU> encodedPdu;
|
|
980 |
encodedPdu.SetLength(encodedPdu.MaxLength());
|
|
981 |
TUint8* ptr = &encodedPdu[0];
|
|
982 |
|
|
983 |
//---------------------------------------------------
|
|
984 |
//Expected UTC = 03/03/2005, 12h00, offset = 3hrs
|
|
985 |
//Local Time = 03/03/2005, 15h00
|
|
986 |
TMonth month=EMarch;
|
|
987 |
TDateTime utcDateTime(2005,month,2,12,0,0,0);
|
|
988 |
TTime expectedDecodedTime(utcDateTime);
|
|
989 |
|
|
990 |
//Prepare the service center time stamp
|
|
991 |
TSmsServiceCenterTimeStamp time;
|
|
992 |
time.SetTime(expectedDecodedTime);
|
|
993 |
|
|
994 |
//Set offset=+12, +3hrs
|
|
995 |
time.SetTimeOffset(12);
|
|
996 |
|
|
997 |
//Encode the PDU.
|
|
998 |
time.EncodeL(ptr);
|
|
999 |
|
|
1000 |
// This is the expected structure in bytes for the time above
|
|
1001 |
TUint8 semioctet = encodedPdu[0]; //2005
|
|
1002 |
LOCAL_CHECKPOINT(semioctet==0x50);
|
|
1003 |
semioctet = encodedPdu[1]; //March
|
|
1004 |
LOCAL_CHECKPOINT(semioctet==0x30);
|
|
1005 |
semioctet = encodedPdu[2]; //3rd
|
|
1006 |
LOCAL_CHECKPOINT(semioctet==0x30);
|
|
1007 |
semioctet = encodedPdu[3]; //15h
|
|
1008 |
LOCAL_CHECKPOINT(semioctet==0x51);
|
|
1009 |
semioctet = encodedPdu[4]; //min
|
|
1010 |
LOCAL_CHECKPOINT(semioctet==0x00);
|
|
1011 |
semioctet = encodedPdu[5]; //sec
|
|
1012 |
LOCAL_CHECKPOINT(semioctet==0x00);
|
|
1013 |
semioctet = encodedPdu[6]; //offset
|
|
1014 |
LOCAL_CHECKPOINT(semioctet==0x21);
|
|
1015 |
|
|
1016 |
|
|
1017 |
//---------------------------------------------------
|
|
1018 |
//Expected UTC = 01/03/2005, 01h00, offset = -3hrs
|
|
1019 |
//Local Time = 28/02/2005, 22h00
|
|
1020 |
encodedPdu.Delete(0,encodedPdu.MaxLength());
|
|
1021 |
encodedPdu.SetLength(encodedPdu.MaxLength());
|
|
1022 |
ptr = &encodedPdu[0];
|
|
1023 |
|
|
1024 |
utcDateTime=TDateTime(2005,month,0,1,0,0,0);
|
|
1025 |
expectedDecodedTime=TTime(utcDateTime);
|
|
1026 |
|
|
1027 |
//Prepare the service center time stamp
|
|
1028 |
time.SetTime(expectedDecodedTime);
|
|
1029 |
|
|
1030 |
//Set offset=-12, -3hrs
|
|
1031 |
time.SetTimeOffset(-12);
|
|
1032 |
|
|
1033 |
//Encode the PDU.
|
|
1034 |
time.EncodeL(ptr);
|
|
1035 |
|
|
1036 |
// This is the expected structure in bytes for the time above
|
|
1037 |
semioctet = encodedPdu[0]; //2005
|
|
1038 |
LOCAL_CHECKPOINT(semioctet==0x50);
|
|
1039 |
semioctet = encodedPdu[1]; //Feb
|
|
1040 |
LOCAL_CHECKPOINT(semioctet==0x20);
|
|
1041 |
semioctet = encodedPdu[2]; //28th
|
|
1042 |
LOCAL_CHECKPOINT(semioctet==0x82);
|
|
1043 |
semioctet = encodedPdu[3]; //22h
|
|
1044 |
LOCAL_CHECKPOINT(semioctet==0x22);
|
|
1045 |
semioctet = encodedPdu[4]; //min
|
|
1046 |
LOCAL_CHECKPOINT(semioctet==0x00);
|
|
1047 |
semioctet = encodedPdu[5]; //sec
|
|
1048 |
LOCAL_CHECKPOINT(semioctet==0x00);
|
|
1049 |
semioctet = encodedPdu[6]; //offset
|
|
1050 |
LOCAL_CHECKPOINT(semioctet==0x29);
|
|
1051 |
|
|
1052 |
|
|
1053 |
//---------------------------------------------------
|
|
1054 |
//Expected UTC = 31/12/2005, 23h45min55s, offset = +3h15min
|
|
1055 |
//Local Time = 01/01/2006, 03h00min55s
|
|
1056 |
encodedPdu.Delete(0,encodedPdu.MaxLength());
|
|
1057 |
encodedPdu.SetLength(encodedPdu.MaxLength());
|
|
1058 |
ptr = &encodedPdu[0];
|
|
1059 |
month=EDecember;
|
|
1060 |
utcDateTime=TDateTime(2005,month,30,23,45,55,0);
|
|
1061 |
expectedDecodedTime=TTime(utcDateTime);
|
|
1062 |
|
|
1063 |
//Prepare the service center time stamp
|
|
1064 |
time.SetTime(expectedDecodedTime);
|
|
1065 |
|
|
1066 |
//Set offset=13, 3hrs15min
|
|
1067 |
time.SetTimeOffset(13);
|
|
1068 |
|
|
1069 |
//Encode the PDU.
|
|
1070 |
time.EncodeL(ptr);
|
|
1071 |
|
|
1072 |
// This is the expected structure in bytes for the time above
|
|
1073 |
semioctet = encodedPdu[0]; //2006
|
|
1074 |
LOCAL_CHECKPOINT(semioctet==0x60);
|
|
1075 |
semioctet = encodedPdu[1]; //Jan
|
|
1076 |
LOCAL_CHECKPOINT(semioctet==0x10);
|
|
1077 |
semioctet = encodedPdu[2]; //1st
|
|
1078 |
LOCAL_CHECKPOINT(semioctet==0x10);
|
|
1079 |
semioctet = encodedPdu[3]; //3h
|
|
1080 |
LOCAL_CHECKPOINT(semioctet==0x30);
|
|
1081 |
semioctet = encodedPdu[4]; //00min
|
|
1082 |
LOCAL_CHECKPOINT(semioctet==0x00);
|
|
1083 |
semioctet = encodedPdu[5]; //55sec
|
|
1084 |
LOCAL_CHECKPOINT(semioctet==0x55);
|
|
1085 |
semioctet = encodedPdu[6]; //offset = 13 x 15min bocks
|
|
1086 |
LOCAL_CHECKPOINT(semioctet==0x31);
|
|
1087 |
|
|
1088 |
//---------------------------------------------------
|
|
1089 |
//Check zero offset
|
|
1090 |
|
|
1091 |
//Expected UTC = 12/07/2005, 01h00, offset = 0hrs
|
|
1092 |
//Local Time = 12/07/2005, 01h00
|
|
1093 |
encodedPdu.Delete(0,encodedPdu.MaxLength());
|
|
1094 |
encodedPdu.SetLength(encodedPdu.MaxLength());
|
|
1095 |
ptr = &encodedPdu[0];
|
|
1096 |
|
|
1097 |
month=EJuly;
|
|
1098 |
utcDateTime=TDateTime(2005,month,11,1,0,0,0);
|
|
1099 |
expectedDecodedTime=TTime(utcDateTime);
|
|
1100 |
|
|
1101 |
//Prepare the service center time stamp
|
|
1102 |
time.SetTime(expectedDecodedTime);
|
|
1103 |
|
|
1104 |
//Set offset=0
|
|
1105 |
time.SetTimeOffset(0);
|
|
1106 |
|
|
1107 |
//Encode the PDU.
|
|
1108 |
time.EncodeL(ptr);
|
|
1109 |
|
|
1110 |
// This is the expected structure in bytes for the time above
|
|
1111 |
semioctet = encodedPdu[0]; //2005
|
|
1112 |
LOCAL_CHECKPOINT(semioctet==0x50);
|
|
1113 |
semioctet = encodedPdu[1]; //July
|
|
1114 |
LOCAL_CHECKPOINT(semioctet==0x70);
|
|
1115 |
semioctet = encodedPdu[2]; //12th
|
|
1116 |
LOCAL_CHECKPOINT(semioctet==0x21);
|
|
1117 |
semioctet = encodedPdu[3]; //01h
|
|
1118 |
LOCAL_CHECKPOINT(semioctet==0x10);
|
|
1119 |
semioctet = encodedPdu[4]; //min
|
|
1120 |
LOCAL_CHECKPOINT(semioctet==0x00);
|
|
1121 |
semioctet = encodedPdu[5]; //sec
|
|
1122 |
LOCAL_CHECKPOINT(semioctet==0x00);
|
|
1123 |
semioctet = encodedPdu[6]; //offset
|
|
1124 |
LOCAL_CHECKPOINT(semioctet==0x00);
|
|
1125 |
|
|
1126 |
//---------------------------------------------------
|
|
1127 |
//Check boundary value, maximum positive
|
|
1128 |
|
|
1129 |
//Expected UTC = 12/07/2005, 01h00, offset = 19h45min
|
|
1130 |
//Local Time = 12/07/2005, 20h45
|
|
1131 |
encodedPdu.Delete(0,encodedPdu.MaxLength());
|
|
1132 |
encodedPdu.SetLength(encodedPdu.MaxLength());
|
|
1133 |
ptr = &encodedPdu[0];
|
|
1134 |
|
|
1135 |
month=EJuly;
|
|
1136 |
utcDateTime=TDateTime(2005,month,11,1,0,0,0);
|
|
1137 |
expectedDecodedTime=TTime(utcDateTime);
|
|
1138 |
|
|
1139 |
//Prepare the service center time stamp
|
|
1140 |
time.SetTime(expectedDecodedTime);
|
|
1141 |
|
|
1142 |
//Set offset=0
|
|
1143 |
time.SetTimeOffset(79);
|
|
1144 |
|
|
1145 |
//Encode the PDU.
|
|
1146 |
time.EncodeL(ptr);
|
|
1147 |
|
|
1148 |
// This is the expected structure in bytes for the time above
|
|
1149 |
semioctet = encodedPdu[0]; //2005
|
|
1150 |
LOCAL_CHECKPOINT(semioctet==0x50);
|
|
1151 |
semioctet = encodedPdu[1]; //July
|
|
1152 |
LOCAL_CHECKPOINT(semioctet==0x70);
|
|
1153 |
semioctet = encodedPdu[2]; //12th
|
|
1154 |
LOCAL_CHECKPOINT(semioctet==0x21);
|
|
1155 |
semioctet = encodedPdu[3]; //20h
|
|
1156 |
LOCAL_CHECKPOINT(semioctet==0x02);
|
|
1157 |
semioctet = encodedPdu[4]; //45min
|
|
1158 |
LOCAL_CHECKPOINT(semioctet==0x54);
|
|
1159 |
semioctet = encodedPdu[5]; //sec
|
|
1160 |
LOCAL_CHECKPOINT(semioctet==0x00);
|
|
1161 |
semioctet = encodedPdu[6]; //offset
|
|
1162 |
LOCAL_CHECKPOINT(semioctet==0x97);
|
|
1163 |
|
|
1164 |
|
|
1165 |
//---------------------------------------------------
|
|
1166 |
//Check boundary value, maximum positive
|
|
1167 |
|
|
1168 |
//Expected UTC = 12/07/2005, 01h00, offset = -19h45min
|
|
1169 |
//Local Time = 11/07/2005, 05h15
|
|
1170 |
encodedPdu.Delete(0,encodedPdu.MaxLength());
|
|
1171 |
encodedPdu.SetLength(encodedPdu.MaxLength());
|
|
1172 |
ptr = &encodedPdu[0];
|
|
1173 |
|
|
1174 |
month=EJuly;
|
|
1175 |
utcDateTime=TDateTime(2005,month,11,1,0,0,0);
|
|
1176 |
expectedDecodedTime=TTime(utcDateTime);
|
|
1177 |
|
|
1178 |
//Prepare the service center time stamp
|
|
1179 |
time.SetTime(expectedDecodedTime);
|
|
1180 |
|
|
1181 |
//Set offset=0
|
|
1182 |
time.SetTimeOffset(-79);
|
|
1183 |
|
|
1184 |
//Encode the PDU.
|
|
1185 |
time.EncodeL(ptr);
|
|
1186 |
|
|
1187 |
// This is the expected structure in bytes for the time above
|
|
1188 |
semioctet = encodedPdu[0]; //2005
|
|
1189 |
LOCAL_CHECKPOINT(semioctet==0x50);
|
|
1190 |
semioctet = encodedPdu[1]; //July
|
|
1191 |
LOCAL_CHECKPOINT(semioctet==0x70);
|
|
1192 |
semioctet = encodedPdu[2]; //11th
|
|
1193 |
LOCAL_CHECKPOINT(semioctet==0x11);
|
|
1194 |
semioctet = encodedPdu[3]; //05h
|
|
1195 |
LOCAL_CHECKPOINT(semioctet==0x50);
|
|
1196 |
semioctet = encodedPdu[4]; //15min
|
|
1197 |
LOCAL_CHECKPOINT(semioctet==0x51);
|
|
1198 |
semioctet = encodedPdu[5]; //sec
|
|
1199 |
LOCAL_CHECKPOINT(semioctet==0x00);
|
|
1200 |
semioctet = encodedPdu[6]; //offset
|
|
1201 |
LOCAL_CHECKPOINT(semioctet==0x9F);
|
|
1202 |
}
|
|
1203 |
|
|
1204 |
/**
|
|
1205 |
* This is a unit test for class TSmsValidityPeriod.
|
|
1206 |
* TSmsValidityPeriod is not exported out of the gsmsu.dll.
|
|
1207 |
* We build gsmuelem.cpp to get access.
|
|
1208 |
*/
|
|
1209 |
EXPORT_C void CSmsStackTestUtils::CreateTSmsValidityPeriodL()
|
|
1210 |
{
|
|
1211 |
//Get the current UTC offset
|
|
1212 |
TTime currUTCTime;
|
|
1213 |
currUTCTime.UniversalTime();
|
|
1214 |
TTimeIntervalSeconds currUTCOffset=User::UTCOffset();
|
|
1215 |
|
|
1216 |
//---------------------------------------------------
|
|
1217 |
//Time()
|
|
1218 |
//setup expected time for this validity period
|
|
1219 |
//UTC = 2005/03/31 10hr45min55sec, offset=135sec
|
|
1220 |
//Validity period = 3days
|
|
1221 |
TMonth month=EMarch;
|
|
1222 |
TDateTime utcDateTime(2005,month,30,10,45,55,0);
|
|
1223 |
TTime utcTime(utcDateTime);
|
|
1224 |
TInt offset=135; // 135 seconds
|
|
1225 |
TTimeIntervalSeconds utcOffset(offset);
|
|
1226 |
User::SetUTCTimeAndOffset(utcTime,utcOffset);
|
|
1227 |
|
|
1228 |
//---------------------------------------------------
|
|
1229 |
//Create
|
|
1230 |
//Format is set to an absolute format
|
|
1231 |
TSmsFirstOctet validityPeriodFormat=TSmsFirstOctet::ESmsVPFSemiOctet;
|
|
1232 |
TSmsValidityPeriod validityPeriod(validityPeriodFormat);
|
|
1233 |
|
|
1234 |
//---------------------------------------------------
|
|
1235 |
//Set the validity period
|
|
1236 |
TInt expectedIntervalPeriod(3*24*60+15); // 3days15min=4320 minutes
|
|
1237 |
TTimeIntervalMinutes validityTimeInterval(expectedIntervalPeriod);
|
|
1238 |
validityPeriod.SetTimeIntervalMinutes(validityTimeInterval);
|
|
1239 |
TTimeIntervalMinutes actualInterval=validityPeriod.TimeIntervalMinutes();
|
|
1240 |
LOCAL_CHECKPOINT(expectedIntervalPeriod==actualInterval.Int());
|
|
1241 |
|
|
1242 |
//update utc, validity period is unchanged.
|
|
1243 |
TDateTime nextDateTime(2005,month,30,12,45,55,0);
|
|
1244 |
TTime nextTime(nextDateTime);
|
|
1245 |
User::SetUTCTime(nextTime);
|
|
1246 |
|
|
1247 |
TTime actualValidityTime=validityPeriod.Time();
|
|
1248 |
LOCAL_CHECKPOINT(actualValidityTime!=nextTime);
|
|
1249 |
|
|
1250 |
User::SetUTCTimeAndOffset(currUTCTime,currUTCOffset);
|
|
1251 |
}
|
|
1252 |
|
|
1253 |
/**
|
|
1254 |
* Test ability to encode a TSmsValidityPeriod inside a validity period inside a pdu
|
|
1255 |
*/
|
|
1256 |
EXPORT_C void CSmsStackTestUtils::EncodeTSmsValidityPeriodL()
|
|
1257 |
{
|
|
1258 |
//Get the current UTC offset
|
|
1259 |
TTime currUTCTime;
|
|
1260 |
currUTCTime.UniversalTime();
|
|
1261 |
TTimeIntervalSeconds currUTCOffset=User::UTCOffset();
|
|
1262 |
|
|
1263 |
//Encode
|
|
1264 |
const TInt KServiceCenterBuffSizeInPDU=7; //Buffer is a 14 semi-octet buffer, 7 byte
|
|
1265 |
TBuf8<KServiceCenterBuffSizeInPDU> serviceCenterBuffer;
|
|
1266 |
serviceCenterBuffer.SetLength(serviceCenterBuffer.MaxLength());
|
|
1267 |
TUint8* ptr = &serviceCenterBuffer[0];
|
|
1268 |
|
|
1269 |
//---------------------------------------------------
|
|
1270 |
//Set the UTC time
|
|
1271 |
//UTC = 03/03/2005, 12h00min30sec, offset = +3hrs = 10800 seconds
|
|
1272 |
//Validity = 2hrs
|
|
1273 |
//Expected local time = 03/03/2005, 17h00min30sec
|
|
1274 |
TTimeIntervalSeconds utcOffset(10800);
|
|
1275 |
TMonth month=EMarch;
|
|
1276 |
TDateTime utcDateTime(2005,month,2,12,0,30,0);
|
|
1277 |
TTime utcTime(utcDateTime);
|
|
1278 |
User::SetUTCTimeAndOffset(utcTime,utcOffset);
|
|
1279 |
|
|
1280 |
//Create the validity period
|
|
1281 |
TSmsFirstOctet validityPeriodFormat=TSmsFirstOctet::ESmsVPFSemiOctet;
|
|
1282 |
TSmsValidityPeriod validityPeriod(validityPeriodFormat);
|
|
1283 |
|
|
1284 |
//Set the validity period to 2hrs, = 120 minutes
|
|
1285 |
TInt expectedIntervalPeriod=120;
|
|
1286 |
TTimeIntervalMinutes validityTimeInterval(expectedIntervalPeriod);
|
|
1287 |
validityPeriod.SetTimeIntervalMinutes(validityTimeInterval);
|
|
1288 |
|
|
1289 |
//Encode the PDU.
|
|
1290 |
validityPeriod.EncodeL(ptr);
|
|
1291 |
|
|
1292 |
// This is the expected structure in bytes for the time above
|
|
1293 |
TUint8 semioctet = serviceCenterBuffer[0]; //2005
|
|
1294 |
LOCAL_CHECKPOINT(semioctet==0x50);
|
|
1295 |
semioctet = serviceCenterBuffer[1]; //March
|
|
1296 |
LOCAL_CHECKPOINT(semioctet==0x30);
|
|
1297 |
semioctet = serviceCenterBuffer[2]; //3rd
|
|
1298 |
LOCAL_CHECKPOINT(semioctet==0x30);
|
|
1299 |
semioctet = serviceCenterBuffer[3]; //17h
|
|
1300 |
LOCAL_CHECKPOINT(semioctet==0x71);
|
|
1301 |
semioctet = serviceCenterBuffer[4]; //0min
|
|
1302 |
LOCAL_CHECKPOINT(semioctet==0x00);
|
|
1303 |
semioctet = serviceCenterBuffer[5]; //30sec
|
|
1304 |
LOCAL_CHECKPOINT(semioctet>=2 && semioctet<=4); // 1 second window each side of 3
|
|
1305 |
semioctet = serviceCenterBuffer[6]; //offset
|
|
1306 |
LOCAL_CHECKPOINT(semioctet==0x21); //3hrs=15minx12
|
|
1307 |
|
|
1308 |
//Try a negative offset
|
|
1309 |
//UTC = 03/03/2005, 12h00min30sec, offset = -6hrs = -21600 seconds
|
|
1310 |
//Validity = 5days
|
|
1311 |
//Expected local time = 08/03/2005, 06h00min30sec
|
|
1312 |
|
|
1313 |
utcOffset=TTimeIntervalSeconds(-21600); // -6hrs validity
|
|
1314 |
month=EMarch;
|
|
1315 |
utcDateTime=TDateTime(2005,month,2,12,0,30,0);
|
|
1316 |
utcTime=TTime(utcDateTime);
|
|
1317 |
User::SetUTCTimeAndOffset(utcTime,utcOffset);
|
|
1318 |
|
|
1319 |
//Create the validity period
|
|
1320 |
//validityPeriodFormat=TSmsFirstOctet::ESmsVPFSemiOctet;
|
|
1321 |
//validityPeriod=TSmsValidityPeriod(validityPeriodFormat);
|
|
1322 |
|
|
1323 |
//Set the validity period to 5days, = 5*24*60=7200 minutes
|
|
1324 |
expectedIntervalPeriod=7200;
|
|
1325 |
validityTimeInterval=TTimeIntervalMinutes(expectedIntervalPeriod);
|
|
1326 |
validityPeriod.SetTimeIntervalMinutes(validityTimeInterval);
|
|
1327 |
|
|
1328 |
//Encode the PDU
|
|
1329 |
validityPeriod.EncodeL(ptr);
|
|
1330 |
|
|
1331 |
// This is the expected structure in bytes for the time above
|
|
1332 |
semioctet = serviceCenterBuffer[0]; //2005
|
|
1333 |
LOCAL_CHECKPOINT(semioctet==0x50);
|
|
1334 |
semioctet = serviceCenterBuffer[1]; //March
|
|
1335 |
LOCAL_CHECKPOINT(semioctet==0x30);
|
|
1336 |
semioctet = serviceCenterBuffer[2]; //3rd
|
|
1337 |
LOCAL_CHECKPOINT(semioctet==0x80);
|
|
1338 |
semioctet = serviceCenterBuffer[3]; //6h
|
|
1339 |
LOCAL_CHECKPOINT(semioctet==0x60);
|
|
1340 |
semioctet = serviceCenterBuffer[4]; //0min
|
|
1341 |
LOCAL_CHECKPOINT(semioctet==0);
|
|
1342 |
semioctet = serviceCenterBuffer[5]; //30sec
|
|
1343 |
LOCAL_CHECKPOINT(semioctet>=2 && semioctet<=4); // 1 second window each side of 3
|
|
1344 |
semioctet = serviceCenterBuffer[6]; //offset
|
|
1345 |
LOCAL_CHECKPOINT(semioctet==0x4A); //-6hrs = -6*60=360 minutes 15x24 minutes
|
|
1346 |
|
|
1347 |
User::SetUTCTimeAndOffset(currUTCTime,currUTCOffset);
|
|
1348 |
}
|
|
1349 |
|
|
1350 |
/**
|
|
1351 |
* Test ability to decode a validity period inside a pdu into a TSmsValidityPeriod.
|
|
1352 |
*/
|
|
1353 |
EXPORT_C void CSmsStackTestUtils::DecodeTSmsValidityPeriodL()
|
|
1354 |
{
|
|
1355 |
//Get the current UTC offset
|
|
1356 |
TTime currUTCTime;
|
|
1357 |
currUTCTime.UniversalTime();
|
|
1358 |
TTimeIntervalSeconds currUTCOffset=User::UTCOffset();
|
|
1359 |
|
|
1360 |
//Decode timestamp
|
|
1361 |
const TInt KTimeStampSize=7;
|
|
1362 |
//TInt ret=0;
|
|
1363 |
TBuf8<KTimeStampSize> timeStamp;
|
|
1364 |
timeStamp.SetLength(timeStamp.MaxLength());
|
|
1365 |
|
|
1366 |
//---------------------------------------------------
|
|
1367 |
// In integer values - local time
|
|
1368 |
timeStamp[0]=64; //year=2004
|
|
1369 |
timeStamp[1]=32; //month=Feb
|
|
1370 |
timeStamp[2]=146; //day=29th
|
|
1371 |
timeStamp[3]=81; //hour=15h
|
|
1372 |
timeStamp[4]=3; //minute=30min
|
|
1373 |
timeStamp[5]=0; //second=0
|
|
1374 |
timeStamp[6]=33; //timeZone=12x15min=3hrs
|
|
1375 |
|
|
1376 |
//UTC time is 29 January 2004, 12.30
|
|
1377 |
//This should give a TTimeIntervalMinutes of 31 Days = 44640 minutes
|
|
1378 |
TMonth month=EJanuary;
|
|
1379 |
TDateTime utcDateTime(2004,month,28,12,30,0,0);
|
|
1380 |
//Setup UTC time and offset
|
|
1381 |
TTime utcTime(utcDateTime);
|
|
1382 |
//+3hrs offset = 10800 seconds
|
|
1383 |
TTimeIntervalSeconds utcOffset(10800);
|
|
1384 |
User::SetUTCTimeAndOffset(utcTime,utcOffset);
|
|
1385 |
|
|
1386 |
//Create buffer
|
|
1387 |
TGsmuLex8 timeStampPosOffsetBuffer(timeStamp);
|
|
1388 |
//Create validity period
|
|
1389 |
TSmsFirstOctet validityPeriodFormat=TSmsFirstOctet::ESmsVPFSemiOctet;
|
|
1390 |
TSmsValidityPeriod validityPeriod(validityPeriodFormat);
|
|
1391 |
|
|
1392 |
//Decode
|
|
1393 |
validityPeriod.DecodeL(timeStampPosOffsetBuffer);
|
|
1394 |
|
|
1395 |
//Now I have a TValidityPeriod
|
|
1396 |
//Check validity period format
|
|
1397 |
//ValidityPeriodFormat
|
|
1398 |
LOCAL_CHECKPOINT(validityPeriod.ValidityPeriodFormat()==TSmsFirstOctet::ESmsVPFSemiOctet);
|
|
1399 |
|
|
1400 |
//Check the expected Interval
|
|
1401 |
TTimeIntervalMinutes expectedInterval(44640);
|
|
1402 |
//Give or take a minute
|
|
1403 |
TTimeIntervalMinutes actualInterval=validityPeriod.TimeIntervalMinutes();
|
|
1404 |
LOCAL_CHECKPOINT(actualInterval.Int()==expectedInterval.Int()+1||actualInterval.Int()==expectedInterval.Int()-1||actualInterval.Int()==expectedInterval.Int());
|
|
1405 |
User::SetUTCTimeAndOffset(currUTCTime,currUTCOffset);
|
|
1406 |
}
|
|
1407 |
|
|
1408 |
|
|
1409 |
EXPORT_C void CSmsStackTestUtils::AppendUserDataL(TGsmSms& aPdu, const CSmsUserData& aUD, TInt aUDL /* = KErrNotFound */)
|
|
1410 |
/**
|
|
1411 |
* Appends an encoded CSmsUserData to the PDU
|
|
1412 |
*
|
|
1413 |
* @pre aPdu contains an appropriate Data Coding Scheme
|
|
1414 |
* @param aPdu Partially constructed TGsmSms, lacking the user data
|
|
1415 |
* @param aUD The User Data to append to aPdu
|
|
1416 |
* @param aUDL OPTIONAL Value to set the TP-UDL in the PDU. Only used if >= 0
|
|
1417 |
*/
|
|
1418 |
{
|
|
1419 |
RMobileSmsMessaging::TMobileSmsGsmTpdu pdu(aPdu.Pdu());
|
|
1420 |
const TInt origLen = pdu.Length();
|
|
1421 |
pdu.SetLength(pdu.MaxLength());
|
|
1422 |
TUint8* ptr0 = &pdu[origLen];
|
|
1423 |
TUint8* ptr1 = ptr0;
|
|
1424 |
|
|
1425 |
ptr1 = aUD.EncodeL(ptr1);
|
|
1426 |
|
|
1427 |
if (aUDL >= 0 && aUDL <= 0x99)
|
|
1428 |
{
|
|
1429 |
*ptr0 = static_cast<TInt8>(aUDL);
|
|
1430 |
}
|
|
1431 |
|
|
1432 |
pdu.SetLength((ptr1 - ptr0) + origLen);
|
|
1433 |
aPdu.SetPdu(pdu);
|
|
1434 |
}
|
|
1435 |
|
|
1436 |
EXPORT_C void CSmsStackTestUtils::CompareDCSL(const CSmsPDU& aPdu, TSmsDataCodingScheme aDCS)
|
|
1437 |
/**
|
|
1438 |
* TODO
|
|
1439 |
*/
|
|
1440 |
{
|
|
1441 |
LOCAL_CHECKPOINT(aPdu.DataCodingSchemePresent());
|
|
1442 |
LOCAL_CHECKPOINT(aPdu.Alphabet() == aDCS.Alphabet());
|
|
1443 |
LOCAL_CHECKPOINT(aPdu.Bits7To4() == aDCS.Bits7To4());
|
|
1444 |
|
|
1445 |
TSmsDataCodingScheme::TSmsClass class1, class2;
|
|
1446 |
const TBool hasClass1 = aPdu.Class(class1);
|
|
1447 |
const TBool hasClass2 = aPdu.Class(class2);
|
|
1448 |
|
|
1449 |
LOCAL_CHECKPOINT((hasClass1 && hasClass2) || (!hasClass1 && !hasClass2));
|
|
1450 |
|
|
1451 |
if (hasClass1)
|
|
1452 |
{
|
|
1453 |
LOCAL_CHECKPOINT(class1 == class2);
|
|
1454 |
}
|
|
1455 |
}
|
|
1456 |
|
|
1457 |
EXPORT_C void CSmsStackTestUtils::ComparePIDL(const CSmsPDU& aPDU, TSmsProtocolIdentifier aPID)
|
|
1458 |
/**
|
|
1459 |
* TODO
|
|
1460 |
*/
|
|
1461 |
{
|
|
1462 |
LOCAL_CHECKPOINT(aPDU.ProtocolIdentifierPresent());
|
|
1463 |
LOCAL_CHECKPOINT(aPDU.PIDType() == aPID.PIDType());
|
|
1464 |
LOCAL_CHECKPOINT(aPDU.TelematicDeviceIndicator() == aPID.TelematicDeviceIndicator());
|
|
1465 |
|
|
1466 |
if (aPDU.TelematicDeviceIndicator()==TSmsProtocolIdentifier::ESmsTelematicDevice)
|
|
1467 |
{
|
|
1468 |
LOCAL_CHECKPOINT(aPDU.TelematicDeviceType() == aPID.TelematicDeviceType());
|
|
1469 |
}
|
|
1470 |
}
|
|
1471 |
|
|
1472 |
EXPORT_C void CSmsStackTestUtils::CompareUDL(const CSmsPDU& aPDU, const CSmsUserData& aUD)
|
|
1473 |
/**
|
|
1474 |
* TODO
|
|
1475 |
*/
|
|
1476 |
{
|
|
1477 |
LOCAL_CHECKPOINT(aPDU.UserDataPresent());
|
|
1478 |
const CSmsUserData& pduUD = aPDU.UserData();
|
|
1479 |
|
|
1480 |
TInt count = pduUD.NumInformationElements();
|
|
1481 |
|
|
1482 |
LOCAL_CHECKPOINT(count == aUD.NumInformationElements());
|
|
1483 |
|
|
1484 |
while (count--)
|
|
1485 |
{
|
|
1486 |
const CSmsInformationElement& ie1 = pduUD.InformationElement(count);
|
|
1487 |
const CSmsInformationElement& ie2 = aUD.InformationElement(count);
|
|
1488 |
LOCAL_CHECKPOINT(ie1.Identifier() == ie2.Identifier());
|
|
1489 |
LOCAL_CHECKPOINT(ie1.Data() == ie2.Data());
|
|
1490 |
}
|
|
1491 |
|
|
1492 |
LOCAL_CHECKPOINT(pduUD.Body() == aUD.Body());
|
|
1493 |
}
|
|
1494 |
|
|
1495 |
EXPORT_C void CSmsStackTestUtils::PrintAndTestDecodeL(const TGsmSms& aPdu, TSmsDataCodingScheme aExpectedDCS, TSmsProtocolIdentifier aExpectedPID, const CSmsUserData& aExpectedUD, TBool aIsMobileTerminated, TInt aExpectedError)
|
|
1496 |
/**
|
|
1497 |
* TODO
|
|
1498 |
*/
|
|
1499 |
{
|
|
1500 |
LOGSMSIFPDU(_L8("TestPduDbToolsL PDU: "), aPdu.Pdu(), EFalse);
|
|
1501 |
LOGSMSIFTIMESTAMP();
|
|
1502 |
|
|
1503 |
CSmsPDU* pdu = NULL;
|
|
1504 |
TRAPD(err, pdu = CSmsPDU::NewL(aPdu, *iCharConv, iFs, aIsMobileTerminated));
|
|
1505 |
|
|
1506 |
if (err == KErrNone)
|
|
1507 |
CleanupStack::PushL(pdu);
|
|
1508 |
|
|
1509 |
LOCAL_CHECKPOINT(err == aExpectedError);
|
|
1510 |
|
|
1511 |
if (err == KErrNone)
|
|
1512 |
{
|
|
1513 |
CompareDCSL(*pdu, aExpectedDCS);
|
|
1514 |
ComparePIDL(*pdu, aExpectedPID);
|
|
1515 |
CompareUDL(*pdu, aExpectedUD);
|
|
1516 |
}
|
|
1517 |
|
|
1518 |
if (err == KErrNone)
|
|
1519 |
CleanupStack::PopAndDestroy(pdu);
|
|
1520 |
}
|
|
1521 |
|
|
1522 |
EXPORT_C TInt CSmsStackTestUtils::StoreParamsL(CMobilePhoneSmspList& aSmspList, RSocket& aSocket, TBool aCancelAfterRequest)
|
|
1523 |
/**
|
|
1524 |
* Stream Sms parameters out to the socket server
|
|
1525 |
* @param aSmspList has Sms parameters list that is streamed to the socket server
|
|
1526 |
* @param aSocket is used to stream the aSmspList to the socket server
|
|
1527 |
* @param aCancelAfterRequest Boolean parameter tells if the request is wanted to be canceled
|
|
1528 |
* @return TInt : The completing status of the request
|
|
1529 |
*/
|
|
1530 |
{
|
|
1531 |
// Write parameters
|
|
1532 |
RSmsSocketWriteStream writestream(aSocket);
|
|
1533 |
TRAPD(ret,writestream << aSmspList);
|
|
1534 |
LOCAL_CHECKPOINT(ret == KErrNone);
|
|
1535 |
TRAP(ret,writestream.CommitL());
|
|
1536 |
LOCAL_CHECKPOINT(ret == KErrNone);
|
|
1537 |
|
|
1538 |
TRequestStatus status;
|
|
1539 |
aSocket.Ioctl(KIoctlWriteSmsParams,status,NULL, KSolSmsProv);
|
|
1540 |
if(aCancelAfterRequest)
|
|
1541 |
aSocket.CancelIoctl();
|
|
1542 |
User::WaitForRequest(status);
|
|
1543 |
|
|
1544 |
PRINTF2(_L("StoreParamsL - storeSmsParams returned %d"), status.Int());
|
|
1545 |
return status.Int();
|
|
1546 |
}
|
|
1547 |
|
|
1548 |
EXPORT_C TInt CSmsStackTestUtils::RetrieveParamsL(CMobilePhoneSmspList& aSmspList, RSocket& aSocket, TBool aCancelAfterRequest)
|
|
1549 |
/**
|
|
1550 |
* Retrieve Sms parameters
|
|
1551 |
* @param aSmspList pointer to the Sms parameters list to be read into
|
|
1552 |
* @param aSocket is used to stream the aSmspList from the socket server
|
|
1553 |
* @param aCancelAfterRequest Boolean parameter tells if the request is wanted to be canceled
|
|
1554 |
* @return TInt : The completing status of the request
|
|
1555 |
*/
|
|
1556 |
{
|
|
1557 |
TInt ret;
|
|
1558 |
TRequestStatus status;
|
|
1559 |
|
|
1560 |
//
|
|
1561 |
// Retrieve Sms parameters from Phone
|
|
1562 |
//
|
|
1563 |
aSocket.Ioctl(KIoctlReadSmsParams,status,NULL, KSolSmsProv);
|
|
1564 |
if(aCancelAfterRequest)
|
|
1565 |
aSocket.CancelIoctl();
|
|
1566 |
User::WaitForRequest(status);
|
|
1567 |
|
|
1568 |
if(status.Int() == KErrNone && !aCancelAfterRequest)
|
|
1569 |
{
|
|
1570 |
RSmsSocketReadStream readstream(aSocket);
|
|
1571 |
TRAP(ret,readstream >> aSmspList);
|
|
1572 |
LOCAL_CHECKPOINT(ret == KErrNone);
|
|
1573 |
}
|
|
1574 |
|
|
1575 |
return status.Int();
|
|
1576 |
}
|
|
1577 |
|
|
1578 |
EXPORT_C void CSmsStackTestUtils::MakeParametersReadRequestL(RSocket& aSocket)
|
|
1579 |
/**
|
|
1580 |
* Make SMS parameters read request to the SMS Stack.
|
|
1581 |
* @param aSocket that is used to make request to the stack.
|
|
1582 |
*/
|
|
1583 |
{
|
|
1584 |
TRequestStatus status;
|
|
1585 |
|
|
1586 |
// Make read SMS params request to the SMS Stack
|
|
1587 |
aSocket.Ioctl(KIoctlReadSmsParams,status,NULL, KSolSmsProv);
|
|
1588 |
User::WaitForRequest(status);
|
|
1589 |
PRINTF2(_L("Retrieve SMS parameters returned %d"), status.Int());
|
|
1590 |
if(status.Int() != KErrNone)
|
|
1591 |
{
|
|
1592 |
User::Leave(status.Int());
|
|
1593 |
}
|
|
1594 |
}
|
|
1595 |
|
|
1596 |
EXPORT_C void CSmsStackTestUtils::StoreParamsLeaveIfErrorL(CMobilePhoneSmspList& aSmspList,RSocket& aSocket)
|
|
1597 |
/**
|
|
1598 |
* Stream Sms parameters out to the socket server and make request.
|
|
1599 |
* @param aSmspList has Sms parameters list that is streamed to the socket server
|
|
1600 |
* @param aSocket is used to stream the aSmspList to the socket server
|
|
1601 |
*/
|
|
1602 |
{
|
|
1603 |
// Write parameters
|
|
1604 |
RSmsSocketWriteStream writestream(aSocket);
|
|
1605 |
writestream << aSmspList;
|
|
1606 |
writestream.CommitL();
|
|
1607 |
|
|
1608 |
TRequestStatus status;
|
|
1609 |
aSocket.Ioctl(KIoctlWriteSmsParams,status,NULL, KSolSmsProv);
|
|
1610 |
User::WaitForRequest(status);
|
|
1611 |
PRINTF2(_L("Store SMS parameters returned %d"), status.Int());
|
|
1612 |
if(status.Int() != KErrNone)
|
|
1613 |
{
|
|
1614 |
User::Leave(status.Int());
|
|
1615 |
}
|
|
1616 |
}
|
|
1617 |
|
|
1618 |
EXPORT_C TInt CSmsStackTestUtils::TestParameters(CMobilePhoneSmspList& aLeft,CMobilePhoneSmspList& aRight)
|
|
1619 |
/**
|
|
1620 |
* Compare sms parameters taken from chunk to parameters retrieved from SIM
|
|
1621 |
* @param aLeft sms parameters taken from the Dummychunk
|
|
1622 |
* @param aRight sms parameters retrieved from the SIM
|
|
1623 |
* @return TInt : The error code
|
|
1624 |
*/
|
|
1625 |
{
|
|
1626 |
TInt ret(KErrNone);
|
|
1627 |
|
|
1628 |
if(aLeft.Enumerate() == aRight.Enumerate())
|
|
1629 |
{
|
|
1630 |
for(TInt storeIndex=0; storeIndex<aLeft.Enumerate(); storeIndex++)
|
|
1631 |
{
|
|
1632 |
const RMobileSmsMessaging::TMobileSmspEntryV1* leftEntry(NULL);
|
|
1633 |
TBool found=EFalse;
|
|
1634 |
|
|
1635 |
TRAPD(myLeftErr, leftEntry = &aLeft.GetEntryL(storeIndex));
|
|
1636 |
if (myLeftErr != KErrNone)
|
|
1637 |
{
|
|
1638 |
return myLeftErr;
|
|
1639 |
}
|
|
1640 |
if (leftEntry == NULL)
|
|
1641 |
{
|
|
1642 |
return KErrArgument;
|
|
1643 |
}
|
|
1644 |
|
|
1645 |
for(TInt writeIndex=0; writeIndex<aRight.Enumerate(); writeIndex++)
|
|
1646 |
{
|
|
1647 |
const RMobileSmsMessaging::TMobileSmspEntryV1* rightEntry(NULL);
|
|
1648 |
|
|
1649 |
TRAPD(myRightErr, rightEntry = &aRight.GetEntryL(writeIndex));
|
|
1650 |
if (myRightErr != KErrNone)
|
|
1651 |
{
|
|
1652 |
return myRightErr;
|
|
1653 |
}
|
|
1654 |
if (rightEntry == NULL)
|
|
1655 |
{
|
|
1656 |
return KErrArgument;
|
|
1657 |
}
|
|
1658 |
|
|
1659 |
if(leftEntry->iIndex == rightEntry->iIndex)
|
|
1660 |
{
|
|
1661 |
found=ETrue;
|
|
1662 |
if((leftEntry->iValidParams != rightEntry->iValidParams) ||
|
|
1663 |
(leftEntry->iText != rightEntry->iText))
|
|
1664 |
{
|
|
1665 |
ret = KErrCorrupt;
|
|
1666 |
break;
|
|
1667 |
}
|
|
1668 |
if(leftEntry->iValidParams & RMobileSmsMessaging::KDestinationIncluded)
|
|
1669 |
{
|
|
1670 |
ret = TestPhoneNumbers(leftEntry->iDestination,rightEntry->iDestination);
|
|
1671 |
if(ret)
|
|
1672 |
break;
|
|
1673 |
}
|
|
1674 |
if(leftEntry->iValidParams & RMobileSmsMessaging::KSCAIncluded)
|
|
1675 |
{
|
|
1676 |
ret = TestPhoneNumbers(leftEntry->iServiceCentre,rightEntry->iServiceCentre);
|
|
1677 |
if(ret)
|
|
1678 |
break;
|
|
1679 |
}
|
|
1680 |
if((leftEntry->iValidParams & RMobileSmsMessaging::KProtocolIdIncluded) &&
|
|
1681 |
(leftEntry->iProtocolId != rightEntry->iProtocolId))
|
|
1682 |
ret = KErrCorrupt;
|
|
1683 |
if((leftEntry->iValidParams & RMobileSmsMessaging::KValidityPeriodIncluded) &&
|
|
1684 |
(leftEntry->iValidityPeriod != rightEntry->iValidityPeriod))
|
|
1685 |
ret = KErrCorrupt;
|
|
1686 |
if((leftEntry->iValidParams & RMobileSmsMessaging::KDcsIncluded) &&
|
|
1687 |
(leftEntry->iDcs != rightEntry->iDcs))
|
|
1688 |
ret = KErrCorrupt;
|
|
1689 |
break;
|
|
1690 |
}
|
|
1691 |
}
|
|
1692 |
|
|
1693 |
if(!found || ret != KErrNone)
|
|
1694 |
{
|
|
1695 |
ret = KErrCorrupt;
|
|
1696 |
break;
|
|
1697 |
}
|
|
1698 |
}
|
|
1699 |
}
|
|
1700 |
else
|
|
1701 |
ret = KErrCorrupt;
|
|
1702 |
|
|
1703 |
if(ret == KErrNone)
|
|
1704 |
PRINTF1(_L("SMS Parameters Ok!") );
|
|
1705 |
else
|
|
1706 |
PRINTF2(_L("ERROR: SMSP lists doesn't match: %d"), ret );
|
|
1707 |
|
|
1708 |
return ret;
|
|
1709 |
}
|
|
1710 |
|
|
1711 |
EXPORT_C TInt CSmsStackTestUtils::TestPhoneNumbers(const RMobilePhone::TMobileAddress& aLeftNumber,const RMobilePhone::TMobileAddress& aRightNumber)
|
|
1712 |
/**
|
|
1713 |
* Compare phone numbers
|
|
1714 |
* @param aLeftNumber reference to TMobileAddress object
|
|
1715 |
* @param aRightNumber reference to TMobileAddress object
|
|
1716 |
*/
|
|
1717 |
{
|
|
1718 |
TInt ret(KErrNone);
|
|
1719 |
TBuf<TGsmSmsTelNumberMaxLen> leftNumber;
|
|
1720 |
TBuf<TGsmSmsTelNumberMaxLen> rightNumber;
|
|
1721 |
|
|
1722 |
//Take '+' sign away first
|
|
1723 |
leftNumber.Copy(aLeftNumber.iTelNumber);
|
|
1724 |
if(leftNumber.Length() > 0 && leftNumber[0] == '+')
|
|
1725 |
{
|
|
1726 |
// Remove "+" sign from telephony number
|
|
1727 |
leftNumber.Delete(0,1);
|
|
1728 |
leftNumber.Trim();
|
|
1729 |
}
|
|
1730 |
//Take '+' sign away first
|
|
1731 |
rightNumber.Copy(aRightNumber.iTelNumber);
|
|
1732 |
if(rightNumber.Length() > 0 && rightNumber[0] == '+')
|
|
1733 |
{
|
|
1734 |
// Remove "+" sign from telephony number
|
|
1735 |
rightNumber.Delete(0,1);
|
|
1736 |
rightNumber.Trim();
|
|
1737 |
}
|
|
1738 |
if((leftNumber.Compare(rightNumber) != 0) ||
|
|
1739 |
(aLeftNumber.iTypeOfNumber != aRightNumber.iTypeOfNumber) ||
|
|
1740 |
(aLeftNumber.iNumberPlan != aRightNumber.iNumberPlan))
|
|
1741 |
{
|
|
1742 |
ret = KErrCorrupt;
|
|
1743 |
}
|
|
1744 |
return(ret);
|
|
1745 |
}
|
|
1746 |
|
|
1747 |
EXPORT_C void CSmsStackTestUtils::PrintSmspEntry(RMobileSmsMessaging::TMobileSmspEntryV1& aEntryToTsy)
|
|
1748 |
/**
|
|
1749 |
* Print a single SMS parameter entry, induvidual content depends on valid flags
|
|
1750 |
* @param aEntryToTsy reference to TMobileSmspEntryV1 object
|
|
1751 |
*/
|
|
1752 |
{
|
|
1753 |
PRINTF2( _L("Index %d"), aEntryToTsy.iIndex);
|
|
1754 |
PRINTF2( _L("Text %S"), &aEntryToTsy.iText);
|
|
1755 |
PRINTF2( _L("Validity Flags %d"), aEntryToTsy.iValidParams);
|
|
1756 |
|
|
1757 |
// Protocol ID
|
|
1758 |
if (aEntryToTsy.iValidParams & RMobileSmsMessaging::KProtocolIdIncluded)
|
|
1759 |
{
|
|
1760 |
PRINTF2( _L("Protocol ID is %d"),
|
|
1761 |
aEntryToTsy.iProtocolId);
|
|
1762 |
}
|
|
1763 |
|
|
1764 |
//DCS
|
|
1765 |
if (aEntryToTsy.iValidParams & RMobileSmsMessaging::KDcsIncluded)
|
|
1766 |
{
|
|
1767 |
PRINTF2( _L("Default Ccding Scheme is %d"),
|
|
1768 |
aEntryToTsy.iDcs);
|
|
1769 |
}
|
|
1770 |
|
|
1771 |
//validity
|
|
1772 |
if (aEntryToTsy.iValidParams & RMobileSmsMessaging::KValidityPeriodIncluded)
|
|
1773 |
{
|
|
1774 |
PRINTF2( _L("Validity Period is %d"),
|
|
1775 |
aEntryToTsy.iValidityPeriod);
|
|
1776 |
}
|
|
1777 |
|
|
1778 |
// destination number
|
|
1779 |
if (aEntryToTsy.iValidParams & RMobileSmsMessaging::KDestinationIncluded)
|
|
1780 |
{
|
|
1781 |
PRINTF2( _L("Destination Type Number is %d"),
|
|
1782 |
aEntryToTsy.iDestination.iTypeOfNumber);
|
|
1783 |
PRINTF2( _L("Destination Number Plan is %d"),
|
|
1784 |
aEntryToTsy.iDestination.iNumberPlan);
|
|
1785 |
PRINTF2( _L("Destination Number is %S"),
|
|
1786 |
&aEntryToTsy.iDestination.iTelNumber);
|
|
1787 |
}
|
|
1788 |
// service center number
|
|
1789 |
if (aEntryToTsy.iValidParams & RMobileSmsMessaging::KSCAIncluded)
|
|
1790 |
{
|
|
1791 |
PRINTF2( _L("Service Center Type Number is %d"),
|
|
1792 |
aEntryToTsy.iServiceCentre.iTypeOfNumber);
|
|
1793 |
PRINTF2( _L("Service Center Number Plan is %d"),
|
|
1794 |
aEntryToTsy.iServiceCentre.iNumberPlan);
|
|
1795 |
PRINTF2( _L("Service Center Number is %S"),
|
|
1796 |
&aEntryToTsy.iServiceCentre.iTelNumber);
|
|
1797 |
}
|
|
1798 |
}
|
|
1799 |
|
|
1800 |
EXPORT_C void CSmsStackTestUtils::PrintSmspList(CMobilePhoneSmspList& aSmspList)
|
|
1801 |
/**
|
|
1802 |
* Print a SMS parameter list
|
|
1803 |
* @param aSmspList reference to CMobilePhoneSmspList object
|
|
1804 |
*/
|
|
1805 |
{
|
|
1806 |
TInt entries;
|
|
1807 |
entries = aSmspList.Enumerate();
|
|
1808 |
|
|
1809 |
if (entries != 1)
|
|
1810 |
{
|
|
1811 |
PRINTF2(_L("The Sms Parameter List has %d parameter entries "), entries );
|
|
1812 |
}
|
|
1813 |
else
|
|
1814 |
{
|
|
1815 |
PRINTF2(_L("The Sms Parameter List has %d parameter entry "), entries );
|
|
1816 |
}
|
|
1817 |
|
|
1818 |
RMobileSmsMessaging::TMobileSmspEntryV1 entryToTsy;
|
|
1819 |
|
|
1820 |
for (TInt i = 0; i < entries; i++)
|
|
1821 |
{
|
|
1822 |
PRINTF1(_L(""));
|
|
1823 |
TRAPD(err, entryToTsy = aSmspList.GetEntryL(i));
|
|
1824 |
|
|
1825 |
if (err == KErrNone)
|
|
1826 |
{
|
|
1827 |
PrintSmspEntry(entryToTsy);
|
|
1828 |
}
|
|
1829 |
else
|
|
1830 |
{
|
|
1831 |
//if leave occurs print to the console
|
|
1832 |
PRINTF2(_L("SmspList.GetEntryL() left: possible cause memory allocation %d"), err);
|
|
1833 |
break;
|
|
1834 |
}
|
|
1835 |
}
|
|
1836 |
}
|
|
1837 |
|
|
1838 |
//
|
|
1839 |
// CTestGetSmsList
|
|
1840 |
//
|
|
1841 |
|
|
1842 |
EXPORT_C CTestGetSmsList* CTestGetSmsList::NewL(TInt aPriority, RSocketServ& aSocketServer, CSmsStackTestUtils& aTestUtils)
|
|
1843 |
{
|
|
1844 |
CTestGetSmsList* smsListGetter = new(ELeave) CTestGetSmsList(aPriority, aSocketServer, aTestUtils);
|
|
1845 |
CleanupStack::PushL(smsListGetter);
|
|
1846 |
smsListGetter->ConstructL();
|
|
1847 |
CleanupStack::Pop(smsListGetter);
|
|
1848 |
return smsListGetter;
|
|
1849 |
}
|
|
1850 |
|
|
1851 |
EXPORT_C CTestGetSmsList::CTestGetSmsList(TInt aPriority, RSocketServ& aSocketServer, CSmsStackTestUtils& aTestUtils)
|
|
1852 |
: CSmsuActiveBase(aPriority), //parent construction
|
|
1853 |
iSocketServer(aSocketServer),
|
|
1854 |
iTestUtils(aTestUtils)
|
|
1855 |
{
|
|
1856 |
}
|
|
1857 |
|
|
1858 |
|
|
1859 |
void CTestGetSmsList::ConstructL()
|
|
1860 |
{
|
|
1861 |
iTestUtils.OpenSmsSocketLC(iSocketServer,iSocket,ESmsAddrLocalOperation);
|
|
1862 |
CleanupStack::Pop(&iSocket);
|
|
1863 |
}
|
|
1864 |
|
|
1865 |
EXPORT_C void CTestGetSmsList::GetSmsList(TRequestStatus& aStatus)
|
|
1866 |
/**
|
|
1867 |
* Starts the active object: Puts a Ioctl request on a socket to enumerate the number
|
|
1868 |
* of messsages in the store
|
|
1869 |
* @param aStatus, copied to iStatus of this active object
|
|
1870 |
*
|
|
1871 |
* *
|
|
1872 |
*/
|
|
1873 |
{
|
|
1874 |
Queue(aStatus);
|
|
1875 |
iMessageCount()=0;
|
|
1876 |
iSocket.Ioctl(KIoctlEnumerateSmsMessages, iStatus,&iMessageCount, KSolSmsProv);
|
|
1877 |
SetActive();
|
|
1878 |
iState = EEnuming;
|
|
1879 |
}
|
|
1880 |
|
|
1881 |
void CTestGetSmsList::DoRunL()
|
|
1882 |
/**
|
|
1883 |
* Active object completion function
|
|
1884 |
* Active while there are still messages to read from the socket
|
|
1885 |
*/
|
|
1886 |
{
|
|
1887 |
iTestUtils.PRINTF1(_L("Messages enumerated"));
|
|
1888 |
User::LeaveIfError(iStatus.Int());
|
|
1889 |
|
|
1890 |
switch (iState)
|
|
1891 |
{
|
|
1892 |
case EEnuming:
|
|
1893 |
{
|
|
1894 |
iRemainingMessages = iMessageCount();
|
|
1895 |
iTestUtils.PRINTF2(_L("%d messages in the store"), iRemainingMessages);
|
|
1896 |
}
|
|
1897 |
|
|
1898 |
case EReading:
|
|
1899 |
{
|
|
1900 |
if (iRemainingMessages > 0)
|
|
1901 |
{
|
|
1902 |
iRemainingMessages--;
|
|
1903 |
CSmsBuffer* buffer=CSmsBuffer::NewL();
|
|
1904 |
CSmsMessage* smsMessage=CSmsMessage::NewL(iTestUtils.iFs, CSmsPDU::ESmsDeliver,buffer);
|
|
1905 |
CleanupStack::PushL(smsMessage);
|
|
1906 |
|
|
1907 |
RSmsSocketReadStream readstream(iSocket);
|
|
1908 |
readstream >> *smsMessage;
|
|
1909 |
CleanupStack::PopAndDestroy(smsMessage);//operation was done only to clear the socket, we are not interested in the message content
|
|
1910 |
|
|
1911 |
iSocket.Ioctl(KIoctlReadMessageSucceeded, iStatus, NULL, KSolSmsProv);
|
|
1912 |
SetActive();
|
|
1913 |
iState = EReading;
|
|
1914 |
}
|
|
1915 |
}
|
|
1916 |
}
|
|
1917 |
}
|
|
1918 |
|
|
1919 |
void CTestGetSmsList::DoCancel()
|
|
1920 |
{
|
|
1921 |
iSocket.CancelIoctl();
|
|
1922 |
Complete(KErrCancel);
|
|
1923 |
}
|
|
1924 |
|
|
1925 |
|
|
1926 |
//
|
|
1927 |
// SmsReceiver AO
|
|
1928 |
//
|
|
1929 |
|
|
1930 |
EXPORT_C CTestReceiveMessages* CTestReceiveMessages::NewL(TInt aPriority, RSocketServ& aSocketServer, CSmsStackTestUtils& aTestUtils)
|
|
1931 |
{
|
|
1932 |
CTestReceiveMessages* smsReceiver = new(ELeave) CTestReceiveMessages(aPriority, aSocketServer, aTestUtils);
|
|
1933 |
CleanupStack::PushL(smsReceiver);
|
|
1934 |
smsReceiver->ConstructL();
|
|
1935 |
CleanupStack::Pop(smsReceiver);
|
|
1936 |
return smsReceiver;
|
|
1937 |
}
|
|
1938 |
|
|
1939 |
CTestReceiveMessages::CTestReceiveMessages(TInt aPriority, RSocketServ& aSocketServer, CSmsStackTestUtils& aTestUtils)
|
|
1940 |
/**
|
|
1941 |
* Constructor
|
|
1942 |
*/
|
|
1943 |
: CSmsuActiveBase(aPriority), //parent construction
|
|
1944 |
iSocketServer(aSocketServer),
|
|
1945 |
iTestUtils(aTestUtils)
|
|
1946 |
{
|
|
1947 |
}
|
|
1948 |
|
|
1949 |
|
|
1950 |
void CTestReceiveMessages::ConstructL()
|
|
1951 |
{
|
|
1952 |
iTestUtils.OpenSmsSocketLC(iSocketServer,iSocket,ESmsAddrRecvAny);
|
|
1953 |
CleanupStack::Pop(&iSocket);
|
|
1954 |
}
|
|
1955 |
|
|
1956 |
EXPORT_C void CTestReceiveMessages::Receive(TRequestStatus& aStatus, TInt aNumberOfMessages)
|
|
1957 |
/**
|
|
1958 |
* Starts the AO by putting a request on the socket receive sms messages
|
|
1959 |
* This function will normally be used when we start using the active object
|
|
1960 |
* Active while the number of received messages is > aNumberOfmessages
|
|
1961 |
* @param aNumberOfMessages the number of messages to be received
|
|
1962 |
*/
|
|
1963 |
{
|
|
1964 |
Queue(aStatus);
|
|
1965 |
if (iNumberOfReceivedMessages >= aNumberOfMessages)
|
|
1966 |
Complete(KErrNone);
|
|
1967 |
else
|
|
1968 |
{
|
|
1969 |
iNumberOfMessagesToReceive=aNumberOfMessages;
|
|
1970 |
if (!IsActive())
|
|
1971 |
Receive();
|
|
1972 |
}
|
|
1973 |
}
|
|
1974 |
|
|
1975 |
EXPORT_C void CTestReceiveMessages::Receive()
|
|
1976 |
/**
|
|
1977 |
* Reposts the receive request -note Receive(aStatus, aNunmberOfMessages) has to be called prior to this one
|
|
1978 |
*
|
|
1979 |
*/
|
|
1980 |
{
|
|
1981 |
iMessageBuf()=KSockSelectRead;
|
|
1982 |
iSocket.Ioctl(KIOctlSelect,iStatus,&iMessageBuf,KSOLSocket);
|
|
1983 |
iState = EReceiving;
|
|
1984 |
SetActive();
|
|
1985 |
}
|
|
1986 |
|
|
1987 |
|
|
1988 |
void CTestReceiveMessages::DoRunL()
|
|
1989 |
/**
|
|
1990 |
* Active object completion function.completes once in each state for each message received
|
|
1991 |
*
|
|
1992 |
*/
|
|
1993 |
{
|
|
1994 |
User::LeaveIfError(iStatus.Int());
|
|
1995 |
|
|
1996 |
switch(iState)
|
|
1997 |
{
|
|
1998 |
case (EReceiving):
|
|
1999 |
{
|
|
2000 |
iTestUtils.PRINTF1(_L(" Message received"));
|
|
2001 |
|
|
2002 |
CSmsBuffer* buffer=CSmsBuffer::NewL();
|
|
2003 |
CSmsMessage* smsMessage=CSmsMessage::NewL(iTestUtils.iFs, CSmsPDU::ESmsSubmit,buffer);
|
|
2004 |
CleanupStack::PushL(smsMessage);
|
|
2005 |
RSmsSocketReadStream readstream(iSocket);
|
|
2006 |
readstream >> *smsMessage;
|
|
2007 |
CleanupStack::PopAndDestroy(smsMessage);//operation was done only to clear the socket, we are not interested in the message content
|
|
2008 |
iSocket.Ioctl(KIoctlReadMessageSucceeded, iStatus, NULL, KSolSmsProv);
|
|
2009 |
SetActive();
|
|
2010 |
iState = EReceived;
|
|
2011 |
break;
|
|
2012 |
}
|
|
2013 |
case (EReceived):
|
|
2014 |
{
|
|
2015 |
iNumberOfReceivedMessages++;
|
|
2016 |
iTestUtils.PRINTF2(_L("%d Messages received"), iNumberOfReceivedMessages);
|
|
2017 |
iState=EReceiving;
|
|
2018 |
|
|
2019 |
if (iNumberOfMessagesToReceive!=iNumberOfReceivedMessages || iReport == NULL)
|
|
2020 |
Receive();
|
|
2021 |
|
|
2022 |
break;
|
|
2023 |
}
|
|
2024 |
}
|
|
2025 |
}
|
|
2026 |
|
|
2027 |
void CTestReceiveMessages::DoCancel()
|
|
2028 |
{
|
|
2029 |
iSocket.CancelIoctl();
|
|
2030 |
Complete(KErrCancel);
|
|
2031 |
}
|
|
2032 |
|
|
2033 |
|
|
2034 |
TInt CTestReceiveMessages::NumberReceived()
|
|
2035 |
/**
|
|
2036 |
* Returns the number of received sms messages
|
|
2037 |
*/
|
|
2038 |
{
|
|
2039 |
return iNumberOfReceivedMessages;
|
|
2040 |
}
|
|
2041 |
|
|
2042 |
//
|
|
2043 |
// SmsReceiverEnumerator wrapping AO
|
|
2044 |
//
|
|
2045 |
|
|
2046 |
|
|
2047 |
EXPORT_C CTestReceiveEnumerateMessages* CTestReceiveEnumerateMessages::NewL(TInt aPriority, RSocketServ& aSocketServer, CSmsStackTestUtils& aTestUtils)
|
|
2048 |
{
|
|
2049 |
CTestReceiveEnumerateMessages* smsReceiverEnumerator = new(ELeave) CTestReceiveEnumerateMessages(aPriority, aSocketServer, aTestUtils);
|
|
2050 |
CleanupStack::PushL(smsReceiverEnumerator);
|
|
2051 |
smsReceiverEnumerator->ConstructL();
|
|
2052 |
CleanupStack::Pop(smsReceiverEnumerator);
|
|
2053 |
return smsReceiverEnumerator;
|
|
2054 |
}
|
|
2055 |
|
|
2056 |
CTestReceiveEnumerateMessages::CTestReceiveEnumerateMessages(TInt aPriority, RSocketServ& aSocketServer, CSmsStackTestUtils& aTestUtils)
|
|
2057 |
/**
|
|
2058 |
* Constructor
|
|
2059 |
* *
|
|
2060 |
*/
|
|
2061 |
: CSmsuActiveBase(aPriority), //parent construction
|
|
2062 |
iSocketServer(aSocketServer),
|
|
2063 |
iTestUtils(aTestUtils)
|
|
2064 |
{
|
|
2065 |
}
|
|
2066 |
|
|
2067 |
|
|
2068 |
void CTestReceiveEnumerateMessages::ConstructL()
|
|
2069 |
{
|
|
2070 |
iEnumerator = CTestGetSmsList::NewL(KActiveObjectPriority, iSocketServer, iTestUtils);
|
|
2071 |
iReceiver = CTestReceiveMessages::NewL(KActiveObjectPriority, iSocketServer, iTestUtils);
|
|
2072 |
ConstructTimeoutL();
|
|
2073 |
}
|
|
2074 |
|
|
2075 |
EXPORT_C void CTestReceiveEnumerateMessages::Start(TInt aEnumExpected, TInt aRecvExpected, TInt aRecvInitial)
|
|
2076 |
/**
|
|
2077 |
* Starts the active object state machine in order to have the following
|
|
2078 |
* -receive iRecvExpected messages
|
|
2079 |
* -Enumerate messages in store and verify there are iEnumExpected and continue receiving
|
|
2080 |
* -Receive the rest of the messages (iRecvExpected in total)
|
|
2081 |
* -Request to receive another message that should time out as only 5 messages are received
|
|
2082 |
* -Flag error if that last message is received
|
|
2083 |
*/
|
|
2084 |
{
|
|
2085 |
iEnumExpected=aEnumExpected;
|
|
2086 |
iRecvExpected=aRecvExpected;
|
|
2087 |
iRecvInitial=aRecvInitial;
|
|
2088 |
|
|
2089 |
iReceiver->Receive(iStatus, aRecvInitial);
|
|
2090 |
iState = ERecvInitial;
|
|
2091 |
SetActive();
|
|
2092 |
CActiveScheduler::Start();
|
|
2093 |
}
|
|
2094 |
|
|
2095 |
void CTestReceiveEnumerateMessages::Complete(TInt aErr)
|
|
2096 |
{
|
|
2097 |
iStatus=aErr;
|
|
2098 |
CActiveScheduler::Stop();
|
|
2099 |
}
|
|
2100 |
|
|
2101 |
void CTestReceiveEnumerateMessages::DoRunL()
|
|
2102 |
{
|
|
2103 |
User::LeaveIfError(iStatus.Int());
|
|
2104 |
|
|
2105 |
switch(iState)
|
|
2106 |
{
|
|
2107 |
case ERecvInitial:
|
|
2108 |
{
|
|
2109 |
iEnumerator->GetSmsList(iStatus);
|
|
2110 |
iReceiver->Receive();
|
|
2111 |
iState=EEnumerating;
|
|
2112 |
SetActive();
|
|
2113 |
break;
|
|
2114 |
}
|
|
2115 |
case EEnumerating:
|
|
2116 |
{
|
|
2117 |
if(iEnumerator->iMessageCount()==TUint(iEnumExpected))
|
|
2118 |
iTestUtils.PRINTF1(_L("**enumerated the right number of messages"));
|
|
2119 |
else
|
|
2120 |
User::Leave(KErrCorrupt);
|
|
2121 |
iReceiver->Receive(iStatus, 5);
|
|
2122 |
SetActive();
|
|
2123 |
iState=ESecondReceiving;
|
|
2124 |
break;
|
|
2125 |
}
|
|
2126 |
case ESecondReceiving:
|
|
2127 |
{
|
|
2128 |
iReceiver->Receive(iStatus, 1 + iRecvExpected);
|
|
2129 |
iState=ETryingToReceiveOneMore;
|
|
2130 |
TimedSetActive(15000000);
|
|
2131 |
break;
|
|
2132 |
}
|
|
2133 |
|
|
2134 |
case ETryingToReceiveOneMore:
|
|
2135 |
{
|
|
2136 |
User::Leave(KErrOverflow);
|
|
2137 |
break;
|
|
2138 |
}
|
|
2139 |
|
|
2140 |
}
|
|
2141 |
|
|
2142 |
}
|
|
2143 |
|
|
2144 |
void CTestReceiveEnumerateMessages::DoCancel()
|
|
2145 |
/**
|
|
2146 |
* Calls cancel on the active objects this owns
|
|
2147 |
*
|
|
2148 |
*/
|
|
2149 |
{
|
|
2150 |
TimedSetActiveCancel();
|
|
2151 |
TInt err = KErrCancel;
|
|
2152 |
|
|
2153 |
switch(iState)
|
|
2154 |
{
|
|
2155 |
case ERecvInitial:
|
|
2156 |
iReceiver->Cancel();
|
|
2157 |
break;
|
|
2158 |
case EEnumerating:
|
|
2159 |
iEnumerator->Cancel();
|
|
2160 |
break;
|
|
2161 |
case ESecondReceiving:
|
|
2162 |
|
|
2163 |
iReceiver->Cancel();
|
|
2164 |
break;
|
|
2165 |
|
|
2166 |
case ETryingToReceiveOneMore:
|
|
2167 |
|
|
2168 |
iReceiver->Cancel();
|
|
2169 |
|
|
2170 |
if (TimedOut())
|
|
2171 |
err = KErrNone;
|
|
2172 |
|
|
2173 |
break;
|
|
2174 |
}
|
|
2175 |
|
|
2176 |
Complete(err);
|
|
2177 |
}
|
|
2178 |
|
|
2179 |
|
|
2180 |
EXPORT_C CTestReceiveEnumerateMessages::~CTestReceiveEnumerateMessages()
|
|
2181 |
/**
|
|
2182 |
* destructor
|
|
2183 |
*/
|
|
2184 |
{
|
|
2185 |
delete iReceiver;
|
|
2186 |
delete iEnumerator;
|
|
2187 |
}
|