|
1 // Copyright (c) 2002-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 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 */ |
|
19 |
|
20 #include <sacls.h> |
|
21 #include <smspver.h> |
|
22 #include "WapProtSuiteStepBase.h" |
|
23 #include "WapProtSuiteDefs.h" |
|
24 |
|
25 /** |
|
26 Utility for setting the test number used by SIM TSY |
|
27 */ |
|
28 void CWapProtSuiteStepBase::SetTestNumberL() |
|
29 { |
|
30 TInt testNumber; |
|
31 GetIntFromConfig(ConfigSection(), _L("testNumber"), testNumber); |
|
32 |
|
33 RProperty testNumberProperty; |
|
34 User::LeaveIfError(testNumberProperty.Attach(KUidPSSimTsyCategory, KPSSimTsyTestNumber)); |
|
35 CleanupClosePushL(testNumberProperty); |
|
36 |
|
37 TRequestStatus status; |
|
38 testNumberProperty.Subscribe(status); |
|
39 INFO_PRINTF1(_L("Setting Sim.Tsy test number P&S property")); |
|
40 User::LeaveIfError(testNumberProperty.Set(KUidPSSimTsyCategory,KPSSimTsyTestNumber,testNumber)); |
|
41 User::WaitForRequest(status); |
|
42 |
|
43 TEST(status.Int() == KErrNone); |
|
44 TInt testNumberCheck; |
|
45 User::LeaveIfError(testNumberProperty.Get(testNumberCheck)); |
|
46 if (testNumber != testNumberCheck) |
|
47 { |
|
48 INFO_PRINTF3(_L("Test number property set to [%d], but value returned is [%d]"),testNumber,testNumberCheck); |
|
49 User::Leave(KErrNotFound); |
|
50 } |
|
51 |
|
52 CleanupStack::PopAndDestroy(&testNumberProperty); |
|
53 |
|
54 } |
|
55 |
|
56 |
|
57 void CWapProtSuiteStepBase::WaitForRecvL(RSocket& aSocket) |
|
58 /** |
|
59 * Wait for an Sms to be received |
|
60 * @param aSocket The status is return to this socket |
|
61 * @leave Leaves if receiving is completed with error code |
|
62 */ |
|
63 { |
|
64 TPckgBuf<TUint> sbuf; |
|
65 sbuf()=KSockSelectRead; |
|
66 TRequestStatus status; |
|
67 aSocket.Ioctl(KIOctlSelect,status,&sbuf,KSOLSocket); |
|
68 User::WaitForRequest(status); |
|
69 TEST(status.Int() == KErrNone); |
|
70 } |
|
71 |
|
72 |
|
73 CSmsMessage* CWapProtSuiteStepBase::RecvSmsL(RSocket& aSocket, TInt aIoctl) |
|
74 /** |
|
75 * Receive an Sms |
|
76 * @param aSocket is used to stream the sms message from the socket server |
|
77 * @return CSmsMessage* :Sms message from Sms stack |
|
78 * @leave Leaves if streaming the message from the socket server doesn't succeed |
|
79 */ |
|
80 { |
|
81 |
|
82 RFs lFs; |
|
83 User::LeaveIfError(lFs.Connect()); |
|
84 |
|
85 CSmsBuffer* buffer=CSmsBuffer::NewL(); |
|
86 CSmsMessage* smsMessage=CSmsMessage::NewL(lFs, CSmsPDU::ESmsSubmit,buffer); |
|
87 CleanupStack::PushL(smsMessage); |
|
88 |
|
89 RSmsSocketReadStream readstream(aSocket); |
|
90 TRAPD(ret,readstream >> *smsMessage); |
|
91 TEST(ret == KErrNone); |
|
92 |
|
93 TPckgBuf<TUint> sbuf; |
|
94 TRequestStatus status; |
|
95 aSocket.Ioctl(aIoctl, status, &sbuf, KSolSmsProv); |
|
96 User::WaitForRequest(status); |
|
97 |
|
98 CleanupStack::Pop(smsMessage); |
|
99 |
|
100 lFs.Close(); |
|
101 |
|
102 return smsMessage; |
|
103 } |
|
104 |
|
105 |
|
106 |
|
107 /** |
|
108 Utility for setting up the WAP address - Port number and service center address |
|
109 */ |
|
110 void CWapProtSuiteStepBase::SetWapAddrL() |
|
111 { |
|
112 TInt port; |
|
113 |
|
114 //Get the port number from the ini file |
|
115 GetIntFromConfig(ConfigSection(),_L("port"), port); |
|
116 |
|
117 iWapAddr.SetWapPort(TWapPortNumber(port)); |
|
118 |
|
119 //Get the service center number |
|
120 TPtrC telNumber; |
|
121 GetStringFromConfig(ConfigSection(),_L("telNumber"), telNumber); |
|
122 TBuf8<100> scNumber; |
|
123 scNumber.Copy(telNumber); |
|
124 TPtrC8 scAddr(scNumber); |
|
125 iWapAddr.SetWapAddress(scAddr); |
|
126 |
|
127 // Bind |
|
128 User::LeaveIfError(iSocket.Bind(iWapAddr)); |
|
129 } |
|
130 |
|
131 |
|
132 /** |
|
133 Setup a socket for receiving status repots |
|
134 */ |
|
135 void CWapProtSuiteStepBase::SetupStatusReportSocketL() |
|
136 { |
|
137 // Open the socket for receiving status reports |
|
138 User::LeaveIfError(iStatusReportSocket.Open(iSocketServer,KSMSAddrFamily,KSockDatagram,KSMSDatagramProtocol)); |
|
139 |
|
140 //Bind to the socket |
|
141 //TSmsAddr smsAddr; |
|
142 iSmsAddr.SetSmsAddrFamily(ESmsAddrStatusReport); |
|
143 TInt ret=iStatusReportSocket.Bind(iSmsAddr); |
|
144 INFO_PRINTF2(_L("Socket Bind Return Value : %d"),ret); |
|
145 TESTL(ret == KErrNone); |
|
146 |
|
147 // Waiting for the phone to be initialised |
|
148 //WaitForInitializeL(); |
|
149 } |
|
150 |
|
151 |
|
152 /** |
|
153 Get the coding of the message |
|
154 */ |
|
155 void CWapProtSuiteStepBase::SetCodingSchemeL() |
|
156 { |
|
157 TInt dataCoding; |
|
158 |
|
159 //Get the port number from the ini file |
|
160 GetIntFromConfig(ConfigSection(),_L("dataCoding"), dataCoding); |
|
161 |
|
162 if(dataCoding==8) |
|
163 iCodingScheme = EWapSms8BitDCS; |
|
164 else |
|
165 iCodingScheme = EWapSms7BitDCS; |
|
166 |
|
167 if(iCodingScheme==EWapSms8BitDCS) |
|
168 User::LeaveIfError(iSocket.SetOpt(KWapSmsOptionNameDCS,KWapSmsOptionLevel,EWapSms8BitDCS)); |
|
169 else |
|
170 User::LeaveIfError(iSocket.SetOpt(KWapSmsOptionNameDCS,KWapSmsOptionLevel,EWapSms7BitDCS)); |
|
171 } |
|
172 |
|
173 void CWapProtSuiteStepBase::SetMessageTypeL() |
|
174 { |
|
175 //Get the type of message |
|
176 TPtrC messageType; |
|
177 GetStringFromConfig(ConfigSection(),_L("type"), messageType); |
|
178 |
|
179 //Set the message type to WapDatagram |
|
180 if(messageType.Compare(_L("Datagram")) ==0) |
|
181 User::LeaveIfError(iSocket.SetOpt(KWapSmsOptionWapDatagram,KWapSmsOptionLevel)); |
|
182 // else |
|
183 // User::LeaveIfError(iSocket.SetOpt(KWapSmsOptionSmartMessage,KWapSmsOptionLevel)); |
|
184 |
|
185 //The creation of the message will set the type to SMART by default |
|
186 } |
|
187 |
|
188 |
|
189 |
|
190 TVerdict CWapProtSuiteStepBase::doTestStepPreambleL() |
|
191 /** |
|
192 * @return - TVerdict |
|
193 * Implementation of CTestStep base class virtual |
|
194 * Load serial drivers |
|
195 * Do all initialisation common to derived classes in here. |
|
196 */ |
|
197 { |
|
198 __UHEAP_MARK; |
|
199 |
|
200 iScheduler = new(ELeave) CActiveScheduler; |
|
201 CActiveScheduler::Install(iScheduler); |
|
202 |
|
203 iSecureBackupEngine = CSBEClient::NewL(); |
|
204 iSecureBackupEngine->SetBURModeL(TDriveList(_L8("C")), |
|
205 EBURNormal, ENoBackup); |
|
206 |
|
207 TInt err; |
|
208 err=User::LoadPhysicalDevice(PDD_NAME); |
|
209 TESTL(err == KErrNone || err == KErrAlreadyExists); |
|
210 |
|
211 err=User::LoadLogicalDevice(LDD_NAME ); |
|
212 TESTL(err == KErrNone || err == KErrAlreadyExists); |
|
213 |
|
214 err = StartC32(); |
|
215 if(err != KErrNone && err != KErrAlreadyExists) |
|
216 { |
|
217 ERR_PRINTF2(TRefByValue<const TDesC>(_L("Start Comms Process Status = %d")), err); |
|
218 SetTestStepResult(EFail); |
|
219 } |
|
220 |
|
221 INFO_PRINTF1(_L("Deleting segmentation and reassembly stores...")); |
|
222 |
|
223 RFs fileServer; |
|
224 User::LeaveIfError(fileServer.Connect()); |
|
225 |
|
226 // delete segmentation and reassembly store files before the test |
|
227 _LIT(KReassemblyStoreName,"C:\\Private\\101F7989\\sms\\smsreast.dat"); |
|
228 _LIT(KSegmentationStoreName,"C:\\Private\\101F7989\\sms\\smssegst.dat"); |
|
229 _LIT(KWapReassemblyStoreName,"C:\\Private\\101F7989\\sms\\wapreast.dat"); |
|
230 |
|
231 fileServer.Delete(KWapReassemblyStoreName); |
|
232 fileServer.Delete(KReassemblyStoreName); |
|
233 fileServer.Delete(KSegmentationStoreName); |
|
234 |
|
235 fileServer.Close(); |
|
236 |
|
237 return TestStepResult(); |
|
238 } |
|
239 |
|
240 TVerdict CWapProtSuiteStepBase::doTestStepPostambleL() |
|
241 { |
|
242 delete iSecureBackupEngine; |
|
243 iSecureBackupEngine = NULL; |
|
244 |
|
245 delete iScheduler; |
|
246 iScheduler = NULL; |
|
247 |
|
248 __UHEAP_MARKEND; |
|
249 |
|
250 return TestStepResult(); |
|
251 } |
|
252 |
|
253 void CWapProtSuiteStepBase::WaitForInitializeL() |
|
254 { |
|
255 TName tsy(KTSY); |
|
256 RTelServer serverT; |
|
257 User::LeaveIfError(serverT.Connect()); |
|
258 CleanupClosePushL(serverT); |
|
259 User::LeaveIfError(serverT.LoadPhoneModule(tsy)); |
|
260 |
|
261 // Find the phone corresponding to this TSY and open a number of handles on it |
|
262 TInt numPhones; |
|
263 User::LeaveIfError(serverT.EnumeratePhones(numPhones)); |
|
264 RPhone phone; |
|
265 |
|
266 while (numPhones--) |
|
267 { |
|
268 TName phoneTsy; |
|
269 User::LeaveIfError(serverT.GetTsyName(numPhones,phoneTsy)); |
|
270 if (phoneTsy.CompareF(tsy)==KErrNone) |
|
271 { |
|
272 RTelServer::TPhoneInfo info; |
|
273 User::LeaveIfError(serverT.GetPhoneInfo(numPhones,info)); |
|
274 User::LeaveIfError(phone.Open(serverT,info.iName)); |
|
275 CleanupClosePushL(phone); |
|
276 const TInt err = phone.Initialise(); |
|
277 User::LeaveIfError(err); |
|
278 CleanupStack::PopAndDestroy(&phone); |
|
279 break; |
|
280 } |
|
281 } |
|
282 |
|
283 CleanupStack::PopAndDestroy(&serverT); |
|
284 } |
|
285 |
|
286 |
|
287 |
|
288 /** |
|
289 * Set high and low limits in .RSC file. When the SMS Stack starts the limits |
|
290 * will be loaded as if set by the licensee. |
|
291 * |
|
292 * @param aLowLimit Low limit value. |
|
293 * @param aHighLimit High limit value. |
|
294 * |
|
295 * @note Only works in debug mode for security reasons. |
|
296 */ |
|
297 void CWapProtSuiteStepBase::SetLowHighLimitsInSmsuRscL(TInt64 aLowLimit, TInt64 aHighLimit) |
|
298 { |
|
299 INFO_PRINTF3(_L("Setting high and low .RSC limits to %ld and %ld."), |
|
300 aHighLimit, aLowLimit); |
|
301 |
|
302 __ASSERT_ALWAYS(aLowLimit < 0x7fffffff, User::Leave(KErrArgument)); |
|
303 __ASSERT_ALWAYS(aHighLimit < 0x7fffffff, User::Leave(KErrArgument)); |
|
304 __ASSERT_ALWAYS(aLowLimit < aHighLimit, User::Leave(KErrArgument)); |
|
305 |
|
306 RFs lFs; |
|
307 User::LeaveIfError(lFs.Connect()); |
|
308 |
|
309 // |
|
310 // Data for the SMSU resource file. The low limit is written at position |
|
311 // 20 and the high limit at position 24. |
|
312 // |
|
313 const TInt smsuRscSize = 34; |
|
314 TChar smsuRscData[smsuRscSize] = |
|
315 {0x6b, 0x4a, 0x1f, 0x10, 0x00, 0x00, 0x00, 0x00, |
|
316 0x00, 0x00, 0x00, 0x00, 0x19, 0xfd, 0x48, 0xe8, |
|
317 0x01, 0x04, 0x00, 0x00, 0x78, 0x56, 0x34, 0x12, |
|
318 0x87, 0x65, 0x43, 0x21, 0x14, 0x00, 0x18, 0x00, |
|
319 0x1c, 0x00}; |
|
320 |
|
321 smsuRscData[20] = (aLowLimit >> 0) & 0xff; |
|
322 smsuRscData[21] = (aLowLimit >> 8) & 0xff; |
|
323 smsuRscData[22] = (aLowLimit >> 16) & 0xff; |
|
324 smsuRscData[23] = (aLowLimit >> 24) & 0xff; |
|
325 smsuRscData[24] = (aHighLimit >> 0) & 0xff; |
|
326 smsuRscData[25] = (aHighLimit >> 8) & 0xff; |
|
327 smsuRscData[26] = (aHighLimit >> 16) & 0xff; |
|
328 smsuRscData[27] = (aHighLimit >> 24) & 0xff; |
|
329 |
|
330 TBuf8<smsuRscSize> smsuRscBuffer; |
|
331 |
|
332 for (TInt index = 0; index < smsuRscSize; index++) |
|
333 { |
|
334 smsuRscBuffer.Append(smsuRscData[index]); |
|
335 } |
|
336 |
|
337 // |
|
338 // Ensure the target directory exists... |
|
339 // |
|
340 TInt ret; |
|
341 |
|
342 ret = lFs.MkDir(KSMSUResourceDir); |
|
343 if (ret != KErrNone && ret != KErrAlreadyExists) |
|
344 { |
|
345 User::Leave(ret); |
|
346 } |
|
347 |
|
348 // |
|
349 // Write the RSC file to the private C:\ directory... |
|
350 // |
|
351 RFile file; |
|
352 |
|
353 User::LeaveIfError(file.Replace(lFs, KSMSUResourceFile, EFileWrite)); |
|
354 CleanupClosePushL(file); |
|
355 User::LeaveIfError(file.Write(smsuRscSize, smsuRscBuffer)); |
|
356 CleanupStack::PopAndDestroy(&file); |
|
357 |
|
358 lFs.Close(); |
|
359 } |
|
360 |
|
361 /** |
|
362 * Sets high and low limits in .RSC file and then reserves disk space to match requested levels. |
|
363 * |
|
364 * Checks the current free space and then sets the high and low marks |
|
365 * to be aHighDrop MB and aLowDrop MB below the current free space |
|
366 * level. |
|
367 * |
|
368 * Then diskspace is reserved to aFreeDrop MB below the current free |
|
369 * space level. |
|
370 * |
|
371 * If the current free space level is greater then aMax then the |
|
372 * current free space level is set to aMax |
|
373 * |
|
374 * If the current free space level is less than aLowDrop MB then this |
|
375 * method leaves with KErrArgument. |
|
376 * |
|
377 * @param aHighDrop The number of MB below the current free space level for the high level mark (in the .RSC file) |
|
378 * @param aLowDrop The number of MB below the current free space level for the low level mark (in the .RSC file) |
|
379 * @param aFreeDrop The number of MB below the current free space level to set the free space to ; |
|
380 * if aFreeDrop == 0, then SetFreeDiskSpaceL() is not called |
|
381 * @param aMax The maximum level for the high limit allowed |
|
382 * |
|
383 * @return The max current free space level used. |
|
384 * |
|
385 * @leave KErrArgument if the current free diskspace level is less than aLowDrop MB |
|
386 * @leave KErrArgument if aMax is not greater than aLowDrop MB |
|
387 * @leave KErrArgument if aHighDrop >= aLowDrop |
|
388 */ |
|
389 TUint64 CWapProtSuiteStepBase::SetHighLowLimitsAndDiskSpaceLevelL(TUint aHighDrop, TUint aLowDrop, TUint aFreeDrop, TUint64 aMax/*=0x7fffffff*/) |
|
390 { |
|
391 INFO_PRINTF5(_L("Setting High-Low limits and Diskspace levels [aHighDrop=%u, aLowDrop=%u, aFreeDrop=%u, aMax=%ld]"), |
|
392 aHighDrop, aLowDrop, aFreeDrop, aMax); |
|
393 |
|
394 __ASSERT_ALWAYS( (aMax > (aLowDrop*1024*1024)), User::Leave(KErrArgument)); |
|
395 __ASSERT_ALWAYS( (aLowDrop > aHighDrop), User::Leave(KErrArgument)); |
|
396 |
|
397 ReleaseDiskSpaceL(); |
|
398 |
|
399 TVolumeInfo volumeInfo; |
|
400 RFs fs; |
|
401 User::LeaveIfError(fs.Connect()); |
|
402 CleanupClosePushL(fs); |
|
403 User::LeaveIfError(fs.Volume(volumeInfo, EDriveC)); |
|
404 INFO_PRINTF2(_L(" Drive C currently has %ld bytes free."), volumeInfo.iFree); |
|
405 |
|
406 TUint64 current = volumeInfo.iFree; |
|
407 if( current < (aLowDrop*1024*1024) ) |
|
408 { |
|
409 INFO_PRINTF1(_L(" Drive C already has too little free space!")); |
|
410 User::Leave(KErrArgument); |
|
411 } |
|
412 if( current > aMax ) |
|
413 { |
|
414 current = aMax; |
|
415 } |
|
416 TUint64 high = current - (aHighDrop*1024*1024); |
|
417 TUint64 low = current - (aLowDrop*1024*1024); |
|
418 |
|
419 SetLowHighLimitsInSmsuRscL(low, high); |
|
420 |
|
421 if( aFreeDrop > 0 ) |
|
422 { |
|
423 TUint64 free = current - (aFreeDrop*1024*1024); |
|
424 SetFreeDiskSpaceL(free); |
|
425 } |
|
426 |
|
427 CleanupStack::PopAndDestroy(&fs); |
|
428 return current; |
|
429 } |
|
430 |
|
431 void CWapProtSuiteStepBase::SetFreeDiskSpaceFromDropLevelL(TUint aFreeDrop) |
|
432 { |
|
433 if( aFreeDrop == 0) |
|
434 { |
|
435 return; |
|
436 } |
|
437 |
|
438 RFs fs; |
|
439 User::LeaveIfError(fs.Connect()); |
|
440 CleanupClosePushL(fs); |
|
441 |
|
442 TVolumeInfo volumeInfo; |
|
443 User::LeaveIfError(fs.Volume(volumeInfo, EDriveC)); |
|
444 TUint64 current = volumeInfo.iFree; |
|
445 if( current > 0x7fffffff ) |
|
446 { |
|
447 current = 0x7fffffff; |
|
448 } |
|
449 TUint64 free = current - (aFreeDrop*1024*1024); |
|
450 SetFreeDiskSpaceL(free); |
|
451 CleanupStack::PopAndDestroy(&fs); |
|
452 } |
|
453 /** |
|
454 * Reserves disk space so that a specified amount of free disk space is |
|
455 * available. |
|
456 * |
|
457 * @param aNewFreeValue Amount of free space required. |
|
458 */ |
|
459 void CWapProtSuiteStepBase::SetFreeDiskSpaceL(TInt64 aNewFreeValue) |
|
460 { |
|
461 |
|
462 #ifndef _DEBUG |
|
463 ERR_PRINTF1(_L("Unexpected call: CWapProtSuiteStepBase::SetFreeDiskSpaceL() is expected to be called only in DEBUG mode.")); |
|
464 User::Leave(KErrNotSupported); |
|
465 #else |
|
466 |
|
467 INFO_PRINTF2(_L("Setting Drive C free disk space to %ld bytes."), aNewFreeValue); |
|
468 |
|
469 __ASSERT_DEBUG( (aNewFreeValue <= 0x7fffffff), User::Leave(KErrArgument)); |
|
470 |
|
471 TInt err = RProperty::Set(KUidPSSMSStackCategory, KUidPSSMSStackFreeDiskSpaceKey, (TInt)aNewFreeValue); |
|
472 if (err != KErrNone) |
|
473 { |
|
474 ERR_PRINTF2(_L("RProperty::Set() failure [err=%d]"), err); |
|
475 User::Leave(err); |
|
476 } |
|
477 #endif |
|
478 } // CSMSTestSteps::SetFreeDiskSpaceL |
|
479 |
|
480 /** |
|
481 * Release all reserved disk space. |
|
482 */ |
|
483 void CWapProtSuiteStepBase::ReleaseDiskSpaceL() |
|
484 { |
|
485 |
|
486 #ifndef _DEBUG |
|
487 ERR_PRINTF1(_L("Unexpected call: CWapProtSuiteStepBase::ReleaseDiskSpaceL() is expected to be called only in DEBUG mode.")); |
|
488 User::Leave(KErrNotSupported); |
|
489 #else |
|
490 |
|
491 INFO_PRINTF1(_L("CWapProtSuiteStepBase::ReleaseDiskSpaceL()")); |
|
492 |
|
493 RFs fs; |
|
494 User::LeaveIfError(fs.Connect()); |
|
495 CleanupClosePushL(fs); |
|
496 |
|
497 TVolumeInfo volumeInfo; |
|
498 User::LeaveIfError(fs.Volume(volumeInfo, EDriveC)); |
|
499 TUint64 current = volumeInfo.iFree; |
|
500 if( current > 0x7fffffff ) |
|
501 { |
|
502 current = 0x7fffffff; |
|
503 } |
|
504 |
|
505 SetFreeDiskSpaceL(current); |
|
506 CleanupStack::PopAndDestroy(&fs); |
|
507 #endif |
|
508 } // CSMSTestSteps::ReleaseDiskSpaceL |
|
509 |
|
510 |
|
511 /** |
|
512 Get WAP Address from INI file |
|
513 */ |
|
514 void CWapProtSuiteStepBase::ReadWapPortSettingsL(TWapAddr &aWapAddr) |
|
515 { |
|
516 //Local vars |
|
517 TPtrC16 telNumber; |
|
518 TInt port; |
|
519 |
|
520 //Read Port and SC number from INI file |
|
521 if(!GetStringFromConfig(ConfigSection(),KSCNumber,telNumber) || |
|
522 !GetIntFromConfig(ConfigSection(),KWapPort,port) |
|
523 ) |
|
524 { |
|
525 // Leave if there's any error. |
|
526 User::Leave(KErrNotFound); |
|
527 } |
|
528 |
|
529 |
|
530 aWapAddr.SetWapPort(TWapPortNumber(port)); |
|
531 TBuf8<100> scNumber; |
|
532 scNumber.Copy(telNumber); |
|
533 TPtrC8 scAddr(scNumber); |
|
534 aWapAddr.SetWapAddress(scAddr); |
|
535 } |
|
536 |
|
537 |
|
538 |
|
539 /** |
|
540 Used to check the CSmsMessage, will also print details of values in CSmsMessage |
|
541 */ |
|
542 void CWapProtSuiteStepBase::CheckSmsMessageL(CSmsMessage& aSmsmessagebuf, TPtrC8& aScnumber) |
|
543 { |
|
544 TPtrC toFromAddress = aSmsmessagebuf.ToFromAddress(); |
|
545 TBuf<0x10> date; |
|
546 TBuf<0x10> timestring; |
|
547 TTime time = aSmsmessagebuf.Time(); |
|
548 time.FormatL(date,(_L("%D%M%Y%/0%1%/1%2%/2%3%/3"))); |
|
549 TDateTime dateTime(time.DateTime()); |
|
550 INFO_PRINTF2(_L("Value for toFromAddress: %S"), &toFromAddress); |
|
551 INFO_PRINTF2(_L("Value for date: %S"), &date); |
|
552 INFO_PRINTF5(_L("TimeStamp=%02d:%02d:%02d.%06d"), dateTime.Hour(), dateTime.Minute(), dateTime.Second(), dateTime.MicroSecond()); |
|
553 HBufC16* scnumber16 = HBufC16::NewLC(aScnumber.Length()); |
|
554 TPtr16 scnumber16mod = scnumber16->Des(); |
|
555 scnumber16mod.Copy(aScnumber); |
|
556 INFO_PRINTF2(_L("Value for Service Centre number: %S"), &scnumber16mod); |
|
557 TESTL(scnumber16mod.Compare(aSmsmessagebuf.ServiceCenterAddress())==0); |
|
558 CleanupStack::PopAndDestroy(scnumber16); |
|
559 } |
|
560 |
|
561 /** |
|
562 Used to make call to get message parameters length via Ioctl |
|
563 */ |
|
564 TInt CWapProtSuiteStepBase::GetMessageParameterLengthL(RSocket& aSock) |
|
565 { |
|
566 TRequestStatus getParamStatus; |
|
567 TPckgBuf<TInt> paramLength; |
|
568 |
|
569 // Get the length of the message parameter value |
|
570 INFO_PRINTF1(_L("Issue of IOCTL for KSOGetMessageParametersLength")); |
|
571 aSock.Ioctl(KSOGetMessageParametersLength, getParamStatus, ¶mLength, KSolWapProv); |
|
572 User::WaitForRequest(getParamStatus); |
|
573 INFO_PRINTF1(_L("KSOGetMessageParametersLength on Ioctl completed")); |
|
574 TESTL(getParamStatus.Int()==KErrNone); |
|
575 |
|
576 // Return the message parameter length |
|
577 return paramLength(); |
|
578 } |
|
579 |
|
580 /** |
|
581 Used to make call to get message parameters via Ioctl |
|
582 */ |
|
583 void CWapProtSuiteStepBase::GetMessageParameterL(RSocket& aSock, TPtr8& aParameterStorePtr) |
|
584 { |
|
585 TRequestStatus getParamStatus; |
|
586 |
|
587 // Get the message parameter and assign to TPtr8 |
|
588 INFO_PRINTF1(_L("Issue of IOCTL for KSOGetMessageParameters")); |
|
589 aSock.Ioctl(KSOGetMessageParameters, getParamStatus, &aParameterStorePtr, KSolWapProv); |
|
590 User::WaitForRequest(getParamStatus); |
|
591 INFO_PRINTF1(_L("KSOGetMessageParameters on Ioctl completed")); |
|
592 TESTL(getParamStatus.Int()==KErrNone); |
|
593 } |
|
594 |
|
595 /** |
|
596 Used to internalise the TDes8 and check the resultant CSmsMessage |
|
597 */ |
|
598 void CWapProtSuiteStepBase::InternaliseSmsDataAndCheckL(TDes8& aBuffer, TPtrC8& aScnumber) |
|
599 { |
|
600 CSmsMessage* smsMessageBuf = NULL; |
|
601 |
|
602 RDesReadStream reader(aBuffer); |
|
603 reader.PushL(); |
|
604 |
|
605 RFs rFs; |
|
606 User::LeaveIfError(rFs.Connect()); |
|
607 CleanupClosePushL(rFs); |
|
608 |
|
609 smsMessageBuf = CSmsMessage::NewL(rFs, CSmsPDU::ESmsStatusReport, CSmsBuffer::NewL()); |
|
610 smsMessageBuf->InternalizeWithoutBufferL(reader); |
|
611 |
|
612 INFO_PRINTF1(_L("Check the contents of the internalized sms message")); |
|
613 CheckSmsMessageL(*smsMessageBuf, aScnumber); |
|
614 |
|
615 rFs.Close(); |
|
616 delete smsMessageBuf; |
|
617 CleanupStack::PopAndDestroy(); // rFs.Close() |
|
618 CleanupStack::PopAndDestroy(&reader); |
|
619 } |
|
620 |
|
621 void CWapProtSuiteStepBase::OpenSocketL(RSocketServ& aSocketServer, RSocket& aSocket, TUint aAddrFamily,TUint aProtocol) |
|
622 { |
|
623 OpenSocketLC(aSocketServer, aSocket, aAddrFamily, aProtocol); |
|
624 CleanupStack::Pop(&aSocket); |
|
625 } |
|
626 |
|
627 void CWapProtSuiteStepBase::OpenSocketLC(RSocketServ& aSocketServer, RSocket& aSocket, TUint aAddrFamily, TUint aProtocol) |
|
628 { |
|
629 TInt error = aSocket.Open(aSocketServer,aAddrFamily,KSockDatagram,aProtocol); |
|
630 if(error != KErrNone) |
|
631 { |
|
632 //If error == KErrNone, do nothing. |
|
633 //If error == KErrServerBusy, change the leave code to "84" to imply the failure otherwise the failed step will be started again. |
|
634 //Any other errors will leave with the error code. |
|
635 |
|
636 |
|
637 if(error == KErrServerBusy) |
|
638 { |
|
639 error = TEST_ERROR_CODE; |
|
640 ERR_PRINTF2(_L("Open socket failed - error is KErrServerBusy, changing to TEST_ERROR_CODE (=%d)"), error); |
|
641 } |
|
642 else |
|
643 { |
|
644 ERR_PRINTF2(_L("Open socket failed - error=%d"), error); |
|
645 } |
|
646 User::Leave(error); |
|
647 } |
|
648 |
|
649 CleanupClosePushL(aSocket); |
|
650 } |
|
651 |