24
|
1 |
// Copyright (c) 2007-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 |
#include "tsmsstoretsytesthelper.h"
|
|
17 |
#include "cctsyinidata.h"
|
|
18 |
|
|
19 |
|
|
20 |
TSmsStoreTsyTestHelper::TSmsStoreTsyTestHelper(CCTSYIntegrationTestSuiteStepBase& aTestStep)
|
|
21 |
: TTsyTestHelperBase( aTestStep )
|
|
22 |
/**
|
|
23 |
* Constructor
|
|
24 |
*/
|
|
25 |
|
|
26 |
{
|
|
27 |
}
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
void TSmsStoreTsyTestHelper::WaitForSmsStoreNotifyStoreEvent(RMobileSmsStore& aStore,
|
|
32 |
TEtelRequestBase& aRequestStatus,
|
|
33 |
TUint32 aEvent,
|
|
34 |
TUint32 aExpectedEvent,
|
|
35 |
TInt aIndex,
|
|
36 |
TInt aExpectedStatus)
|
|
37 |
/**
|
|
38 |
* Wait for store event
|
|
39 |
*
|
|
40 |
* @param aStore is a subsession handle to the sms store
|
|
41 |
* @param aRequestStatus is a reference to the request
|
|
42 |
* @param aEvent is the event which occured
|
|
43 |
* @param aExpectedEvent is the event which is expected
|
|
44 |
* @param aIndex is the index of the changed slot
|
|
45 |
* @param aExpectedStatus is the expected value of the completed status request
|
|
46 |
*/
|
|
47 |
{
|
|
48 |
|
|
49 |
// Wait for the request to complete
|
|
50 |
TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeMedium);
|
|
51 |
ASSERT_EQUALS(err, KErrNone, _L("RMobileSmsStore::NotifyStoreEvent did not complete"));
|
|
52 |
|
|
53 |
while ( err == KErrNone &&
|
|
54 |
aRequestStatus.Int() & aExpectedStatus &&
|
|
55 |
aEvent != aExpectedEvent)
|
|
56 |
{
|
|
57 |
// Request has completed with incorrect result.
|
|
58 |
// Maybe there are more notifications to consume before we get
|
|
59 |
// the one we want.
|
|
60 |
|
|
61 |
// Repost notification until it either times out or we get
|
|
62 |
// the right result.
|
|
63 |
aStore.NotifyStoreEvent(aRequestStatus, aEvent, aIndex);
|
|
64 |
err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeMedium);
|
|
65 |
}
|
|
66 |
|
|
67 |
ASSERT_EQUALS(aRequestStatus.Int(), aExpectedStatus, _L("RMobileSmsStore::NotifyStoreEvent wrong completion status"));
|
|
68 |
ASSERT_BITS_SET(aEvent, aExpectedEvent,0, _L("RMobileSmsStore::NotifyStoreEvent incorrect store event"));
|
|
69 |
|
|
70 |
// Cancel request if it is still pending
|
|
71 |
if (aRequestStatus.Int() == KRequestPending)
|
|
72 |
{
|
|
73 |
aRequestStatus.Cancel();
|
|
74 |
}
|
|
75 |
} // TSmsStoreTsyTestHelper::WaitForSmsStoreNotifyStoreEvent
|
|
76 |
|
|
77 |
|
|
78 |
void TSmsStoreTsyTestHelper::CreateValidSmsPdu(TDes8& aString, TDesC16& aPhoneNumber, TDes8& aPdu,
|
|
79 |
TDataCodingScheme aDataCodingScheme, TBool aStatusReportRequest)
|
|
80 |
/**
|
|
81 |
* Create a Sms PDU
|
|
82 |
*
|
|
83 |
* @param aString is the text of the message
|
|
84 |
* @param aPhoneNumber is the destination phone number
|
|
85 |
* @param aPdu is the PDU which will be sent
|
|
86 |
* @param aDataCodingScheme is the coding schemem of the text of the message inside the PDU
|
|
87 |
* @param aStatusReportRequest will be true if the TP-SRI bit (status request indicator) should be on.
|
|
88 |
*/
|
|
89 |
{
|
|
90 |
// If you want to convert user data to 7bit format:
|
|
91 |
TBuf8<140> userData;
|
|
92 |
TUint16 byteCount = ( TUint16 )aString.Length();
|
|
93 |
|
|
94 |
GsmLibCharConversion( TKGsmLibConvertToGsmFormat, aString,
|
|
95 |
byteCount );
|
|
96 |
GsmLibSmsPackMessage( userData, aString, byteCount );
|
|
97 |
|
|
98 |
/**
|
|
99 |
* Holds Sms Gsm Tdpu variable
|
|
100 |
*/
|
|
101 |
RMobileSmsMessaging::TMobileSmsGsmTpdu gsmPdu;
|
|
102 |
|
|
103 |
TUint16 charCnt = ( TUint16 )( ( userData.Length()*8 ) / 7 );
|
|
104 |
if ( ( ( ( gsmPdu.Length()*8 ) % 7 ) == 0) &&
|
|
105 |
charCnt && charCnt <= gsmPdu.Length() )
|
|
106 |
{
|
|
107 |
if ( userData[charCnt-1] == 0 )
|
|
108 |
// if the last char is NULL, Actual charCnt is charCnt-1
|
|
109 |
{
|
|
110 |
charCnt--;
|
|
111 |
}
|
|
112 |
else
|
|
113 |
{
|
|
114 |
// No implementation
|
|
115 |
}
|
|
116 |
}
|
|
117 |
|
|
118 |
// Some code from STIF test
|
|
119 |
const TUint smsMsgTypeSubmitOrSubmitR = 0x01;
|
|
120 |
const TUint smsMsgVPabsolute = 0x14; // absolute format
|
|
121 |
TUint msgParameters( 0 );
|
|
122 |
msgParameters = 0;
|
|
123 |
msgParameters |= smsMsgTypeSubmitOrSubmitR;
|
|
124 |
msgParameters |= smsMsgVPabsolute;
|
|
125 |
if(aStatusReportRequest)
|
|
126 |
{
|
|
127 |
const TUint smsMsgTypeStatusReportRequest = 0x20;
|
|
128 |
msgParameters |= smsMsgTypeStatusReportRequest;
|
|
129 |
}
|
|
130 |
|
|
131 |
|
|
132 |
TBuf8<12> destinationAddress;
|
|
133 |
GsmConvUnicodeTo0340Addr(
|
|
134 |
2, //TON national number
|
|
135 |
1, //NPI isdn numbering plan
|
|
136 |
destinationAddress,
|
|
137 |
aPhoneNumber );
|
|
138 |
|
|
139 |
aPdu.SetLength( 0 ); //reset buffer
|
|
140 |
aPdu.Append( msgParameters ); //Message params
|
|
141 |
aPdu.Append( 0x00 ); //TP-Message-Reference
|
|
142 |
aPdu.Append( destinationAddress ); //TP-Destination-Address
|
|
143 |
aPdu.Append( 0x00 ); //TP-Protocol-Identifier
|
|
144 |
aPdu.Append( (TUint8)aDataCodingScheme ); //TP-Data-Coding-Scheme (8bit)
|
|
145 |
aPdu.Append( 0xA7 ); //TP-Validity-Period
|
|
146 |
aPdu.Append( charCnt ); //TP-User-Data-Length
|
|
147 |
aPdu.Append( userData ); //TP-User-Data
|
|
148 |
} // TSmsStoreTsyTestHelper::CreateValidSmsPdu
|
|
149 |
|
|
150 |
void TSmsStoreTsyTestHelper::GsmLibCharConversion( TUint aDirection,
|
|
151 |
TDes8& aString,
|
|
152 |
TUint16 aLength )
|
|
153 |
/**
|
|
154 |
* TSmsStoreTsyTestHelper::GsmLibCharConversion
|
|
155 |
* The character codes supported by the MS
|
|
156 |
* The former is 8-bit set and
|
|
157 |
* the latter is a 7-bit set. Therefore, the characters must be converted
|
|
158 |
* by using this function. However, characters having the same code in
|
|
159 |
* both sets are not converted.
|
|
160 |
* (other items were commented in a header).
|
|
161 |
*
|
|
162 |
* @param aDirection this is the format of the conversion, TKGsmLibConvertToGsmFormat or TKGsmLibConvertToNmpFormat
|
|
163 |
* @param aString is the string to be converted
|
|
164 |
* @param aLength is the length of the string
|
|
165 |
*/
|
|
166 |
{
|
|
167 |
TUint16 j( 0 );
|
|
168 |
TUint16 i( 0 );
|
|
169 |
|
|
170 |
TBuf8<180> aDestination;
|
|
171 |
|
|
172 |
if ( aDirection == TKGsmLibConvertToNmpFormat )
|
|
173 |
{
|
|
174 |
for ( i = 0; i < aLength; i++ )
|
|
175 |
{
|
|
176 |
if ( aString[i] == 0xFF ) // This ends the string in SIM card
|
|
177 |
{
|
|
178 |
aDestination.Append( '\0' );
|
|
179 |
break;
|
|
180 |
}
|
|
181 |
|
|
182 |
aString[i] &= 0x7F; // only 7 bits used in GSM character set
|
|
183 |
|
|
184 |
//Conversion made using GSM 7 bit default alphabet extension
|
|
185 |
//table.
|
|
186 |
if ( ( aString[i] > 0x5A) && ( aString[i] < 0x5F ) ||
|
|
187 |
( aString[i] > 0x7A ) && ( aString[i] < 0x7F ) )
|
|
188 |
{
|
|
189 |
for ( j = 0 ; j < TKGsmLibConvTableSize; j++ )
|
|
190 |
{
|
|
191 |
if ( aString[i] == TKGsmExtensionConvTable[j].iHandsetChar )
|
|
192 |
{
|
|
193 |
aDestination.Append( 0x1B );//extension table flag
|
|
194 |
aDestination.Append(
|
|
195 |
TKGsmExtensionConvTable[j].iSmsChar );
|
|
196 |
break;
|
|
197 |
}
|
|
198 |
else if ( aString[i] == 0x20A0 ) //Euro
|
|
199 |
{
|
|
200 |
aDestination.Append( 0x65 );
|
|
201 |
}
|
|
202 |
}
|
|
203 |
|
|
204 |
}
|
|
205 |
|
|
206 |
// Conversion could be done only taking out the most significant
|
|
207 |
// bit from Unicode characters between 0x25 - 0x5A or 0x61 - 0x7A.
|
|
208 |
// We should be used KGsmLibConvTable if it is outside that are
|
|
209 |
// or it is 0x40 ( @ ).
|
|
210 |
else if ( ( aString[i] < 0x20 )
|
|
211 |
|| ( ( aString[i] > 0x5A ) && ( aString[i] < 0x61 ) )
|
|
212 |
|| ( aString[i] > 0x7A )
|
|
213 |
|| ( aString[i] == 0x40 ) )
|
|
214 |
{
|
|
215 |
|
|
216 |
for ( j = 0 ; j < TKGsmLibBidirTableSize; j++ )
|
|
217 |
{
|
|
218 |
if ( aString[i] == TKGsmLibConvTable[j].iSmsChar )
|
|
219 |
{
|
|
220 |
aDestination.Append(
|
|
221 |
TKGsmLibConvTable[j].iHandsetChar );
|
|
222 |
break;
|
|
223 |
}
|
|
224 |
}
|
|
225 |
}
|
|
226 |
else
|
|
227 |
{
|
|
228 |
aDestination.Append( aString[i] );
|
|
229 |
}
|
|
230 |
}
|
|
231 |
|
|
232 |
}
|
|
233 |
else // aDirection = KGsmLibConvertToGsmFormat
|
|
234 |
{
|
|
235 |
for ( i = 0; i < aLength; i++ )
|
|
236 |
{
|
|
237 |
if ( aString[i] == '\0' ) // End of string in NMP format
|
|
238 |
{
|
|
239 |
aDestination.Append( 0xFF ); // End of string in SIM
|
|
240 |
}
|
|
241 |
|
|
242 |
else if ( ( ( aString[i] < 0x10 ) && ( aString[i] != 0x0A )
|
|
243 |
&& ( aString[i] != 0x0D ) ) ||
|
|
244 |
( ( aString[i] > 0x7F ) && ( aString[i] < 0xC0 ) ) )
|
|
245 |
{
|
|
246 |
// Convert to SPACE if control character or Japanese character
|
|
247 |
// NOTE! (CR (0x0D) and LF (0x0A) are not converted.
|
|
248 |
aDestination.Append( 0x20 );
|
|
249 |
}
|
|
250 |
else
|
|
251 |
{
|
|
252 |
//Conversion made using GSM 7 bit default alphabet extension
|
|
253 |
//table.
|
|
254 |
if ( ( aString[i] > 0x5A ) && ( aString[i] < 0x5F ) ||
|
|
255 |
( aString[i] > 0x7A ) && ( aString[i] < 0x7F ) )
|
|
256 |
|
|
257 |
{
|
|
258 |
for ( j = 0 ; j < TKGsmLibConvTableSize; j++ )
|
|
259 |
{
|
|
260 |
if ( aString[i] == TKGsmExtensionConvTable[j].
|
|
261 |
iHandsetChar )
|
|
262 |
{
|
|
263 |
aDestination.Append( 0x1B );//extension table flag
|
|
264 |
aDestination.Append(
|
|
265 |
TKGsmExtensionConvTable[j].iSmsChar );
|
|
266 |
break;
|
|
267 |
}
|
|
268 |
else if ( aString[i] == 0x20A0 ) //Euro
|
|
269 |
{
|
|
270 |
aDestination.Append( 0x65 );
|
|
271 |
}
|
|
272 |
}
|
|
273 |
|
|
274 |
}
|
|
275 |
|
|
276 |
// Conversion could be done only taking out the most
|
|
277 |
// significant bit from Unicode characters between 0x25 - 0x5A
|
|
278 |
// or 0x61 - 0x7A. We should be used KGsmLibConvTable if it is
|
|
279 |
// outside that are or it is 0x40 ( @ ).
|
|
280 |
|
|
281 |
else if ( ( aString[i] < 0x25 )
|
|
282 |
|| ( ( aString[i] > 0x5A ) && ( aString[i] < 0x61 ) )
|
|
283 |
|| ( aString[i] > 0x7A )
|
|
284 |
|| ( aString[i] == 0x40 ) )
|
|
285 |
{
|
|
286 |
|
|
287 |
for ( j = 0; j < TKGsmLibConvTableSize; j++ )
|
|
288 |
{
|
|
289 |
if ( aString[i] == TKGsmLibConvTable[j].iHandsetChar )
|
|
290 |
{
|
|
291 |
aDestination.Append(
|
|
292 |
TKGsmLibConvTable[j].iSmsChar );
|
|
293 |
break;
|
|
294 |
}
|
|
295 |
}
|
|
296 |
|
|
297 |
}
|
|
298 |
else
|
|
299 |
{
|
|
300 |
aDestination.Append( aString[i] );
|
|
301 |
}
|
|
302 |
}
|
|
303 |
}
|
|
304 |
}
|
|
305 |
aString.Copy( aDestination );
|
|
306 |
}// TSmsStoreTsyTestHelper::TSmsStoreTsyTestHelper
|
|
307 |
|
|
308 |
|
|
309 |
TUint16 TSmsStoreTsyTestHelper::GsmLibSmsPackMessage( TDes8& aDest,
|
|
310 |
TDes8& aSrc,
|
|
311 |
TUint16 aByteCount )
|
|
312 |
/**
|
|
313 |
* TSmsStoreTsyTestHelper::GsmLibSmsPackMessage
|
|
314 |
* This function packs a given text string consisting of 7-bit
|
|
315 |
* characters into 8 bit bytes in such a way that a 160-character
|
|
316 |
* message takes only 140 bytes of memory after the compression.
|
|
317 |
* (other items were commented in a header).
|
|
318 |
*
|
|
319 |
* @param aDest is the packaged message
|
|
320 |
* @param aSrc is the original unpackaged message
|
|
321 |
* @param aByteCount is the number of bytes in the src msg
|
|
322 |
*
|
|
323 |
* @return length of the coded message
|
|
324 |
*/
|
|
325 |
{
|
|
326 |
TUint16 si, di; // Indexes
|
|
327 |
TInt tmpModulo; // Temporary; to improve efficiency
|
|
328 |
|
|
329 |
// Reset the indexes.
|
|
330 |
si = 0;
|
|
331 |
di = 0;
|
|
332 |
tmpModulo = di % 7;
|
|
333 |
|
|
334 |
while ( si < aByteCount )
|
|
335 |
{
|
|
336 |
// Is this the last character of the message?
|
|
337 |
// If it is, just shift it to the right. Otherwise, fill the rest of
|
|
338 |
// the byte with the bits of the next source character.
|
|
339 |
|
|
340 |
if ( si == ( aByteCount - 1 ) )
|
|
341 |
{
|
|
342 |
TUint num2 = (aSrc[si] >> tmpModulo);
|
|
343 |
aDest.Append(num2);
|
|
344 |
}
|
|
345 |
else
|
|
346 |
{
|
|
347 |
TUint num2 = (aSrc[si] >> tmpModulo) |
|
|
348 |
( aSrc[si + 1] << ( 7 - tmpModulo ) );
|
|
349 |
aDest.Append( num2 );
|
|
350 |
|
|
351 |
}
|
|
352 |
|
|
353 |
di++;
|
|
354 |
tmpModulo = di % 7;
|
|
355 |
|
|
356 |
// Check if the destination byte could take the entire source
|
|
357 |
// character. In that case, the source character does not have to be
|
|
358 |
// divided and the next source character can be taken.
|
|
359 |
|
|
360 |
if ( KErrNone == tmpModulo )
|
|
361 |
{
|
|
362 |
si += 2;
|
|
363 |
}
|
|
364 |
else
|
|
365 |
{
|
|
366 |
si++;
|
|
367 |
}
|
|
368 |
}
|
|
369 |
|
|
370 |
// Return the length of the coded message.
|
|
371 |
return( di );
|
|
372 |
}
|
|
373 |
|
|
374 |
void TSmsStoreTsyTestHelper::GsmConvUnicodeTo0340Addr( TUint8 aTon,
|
|
375 |
TUint8 aNpi,
|
|
376 |
TDes8& aDest,
|
|
377 |
TDesC16& aSource )
|
|
378 |
/**
|
|
379 |
* TSmsStoreTsyTestHelper::GsmConvUnicodeTo0340Addr
|
|
380 |
* Converts type of number, numbering plan identification and
|
|
381 |
* phone number given in unicode string
|
|
382 |
* (other items were commented in a header).
|
|
383 |
*
|
|
384 |
* @param aTon is the Type of Number (national, international, etc)TMobileTON
|
|
385 |
* @param aNpi is the Number Plan Indicator (TMobileNPI)
|
|
386 |
* @param aDest is the converted unicode
|
|
387 |
* @param aSource is the descriptor for conversion
|
|
388 |
*/
|
|
389 |
{
|
|
390 |
|
|
391 |
if ( KErrNone != aSource.Length() )
|
|
392 |
{
|
|
393 |
GsmConvUnicodeToAddr( aTon, aNpi, aDest, aSource, ETrue );
|
|
394 |
}
|
|
395 |
else
|
|
396 |
{
|
|
397 |
// Address length of 0 is a special case
|
|
398 |
aDest.Append( 0 );
|
|
399 |
|
|
400 |
// Type-of-Address: TON = Unknown, NPI = ISDN/telephone num plan
|
|
401 |
aDest.Append( 0x81 );
|
|
402 |
}
|
|
403 |
}
|
|
404 |
|
|
405 |
void TSmsStoreTsyTestHelper::GsmConvUnicodeToAddr( TUint8 aTon,
|
|
406 |
TUint8 aNpi,
|
|
407 |
TDes8& aDest,
|
|
408 |
TDesC16& aSource,
|
|
409 |
TBool aAddress )
|
|
410 |
/**
|
|
411 |
* TSmsStoreTsyTestHelper::GsmConvUnicodeToAddr
|
|
412 |
* Converts type of number, numbering plan identification and
|
|
413 |
* phone number given in unicode string
|
|
414 |
* (other items were commented in a header).
|
|
415 |
*/
|
|
416 |
{
|
|
417 |
//get address length
|
|
418 |
TUint numberLength = aSource.Length();
|
|
419 |
TUint destLength = numberLength;
|
|
420 |
TUint i( 0 );
|
|
421 |
|
|
422 |
/* Solve type of address
|
|
423 |
Type of Address field format is as follows:
|
|
424 |
|
|
425 |
7 6 5 4 3 2 1 0 bit
|
|
426 |
| | | | | | | | |
|
|
427 |
| 1 | Type of number | Numbering-plan-identification|
|
|
428 |
| | | | | | | | |
|
|
429 |
*/
|
|
430 |
|
|
431 |
//type of number is three bits from left and fourth bit must be '1'
|
|
432 |
TUint8 typeOfNumber = TUint8( aTon | 0x08 );
|
|
433 |
//move four bit to the left
|
|
434 |
typeOfNumber = TUint8( typeOfNumber << 4 );
|
|
435 |
//numbering plan is four bits from left
|
|
436 |
TUint8 numberingPlan = TUint8( aNpi & 0x0F );
|
|
437 |
//set type of number and numbering plan to the typeOfNumber variable
|
|
438 |
typeOfNumber = TUint8( typeOfNumber | numberingPlan );
|
|
439 |
|
|
440 |
if ( 5 == aTon ) //Alphanumeric
|
|
441 |
{
|
|
442 |
TBuf8<KMaxLengthOfAddressData> addressData;
|
|
443 |
TUint8 amountOfsemiOctets( 0 );
|
|
444 |
|
|
445 |
GsmUnicodeAddrToAlphanumericAddr( aSource, addressData, amountOfsemiOctets );
|
|
446 |
|
|
447 |
//fill address length field
|
|
448 |
if ( aAddress )
|
|
449 |
{
|
|
450 |
//amount of used semi-octets in address data
|
|
451 |
aDest.Append( amountOfsemiOctets );
|
|
452 |
}
|
|
453 |
else //0411 address
|
|
454 |
{
|
|
455 |
//Actually alphanumeric address data for 0411 address is not
|
|
456 |
//supported (see GSM 24.011 and 24.008)...
|
|
457 |
//Length of address data + length of address type field
|
|
458 |
aDest.Append( addressData.Length() + 1 );
|
|
459 |
}
|
|
460 |
|
|
461 |
//add typeOfNumber to the buffer
|
|
462 |
aDest.Append( typeOfNumber );
|
|
463 |
//aDest.Append( 0x81 );
|
|
464 |
|
|
465 |
//add address data to the buffer
|
|
466 |
aDest.Insert( 2, addressData );
|
|
467 |
}
|
|
468 |
else
|
|
469 |
{
|
|
470 |
//number can contain character '+'
|
|
471 |
if ( '+' == aSource[i] )
|
|
472 |
{
|
|
473 |
i++;
|
|
474 |
destLength--;
|
|
475 |
|
|
476 |
// Maximum amount of digits is 20 (3GPP TS 23.040)
|
|
477 |
if ( destLength > KMaxAmountOfDigits )
|
|
478 |
{
|
|
479 |
destLength = KMaxAmountOfDigits;
|
|
480 |
numberLength = 21;
|
|
481 |
}
|
|
482 |
}
|
|
483 |
else
|
|
484 |
{
|
|
485 |
// Maximum amount of digits is 20 (3GPP TS 23.040)
|
|
486 |
if ( destLength > KMaxAmountOfDigits )
|
|
487 |
{
|
|
488 |
destLength = KMaxAmountOfDigits;
|
|
489 |
numberLength = 20;
|
|
490 |
}
|
|
491 |
}
|
|
492 |
|
|
493 |
// calculate address length in bytes
|
|
494 |
TUint bufferLength = ( destLength + 1 )/2 + 2;
|
|
495 |
|
|
496 |
//set buffer length
|
|
497 |
aDest.SetLength( bufferLength );
|
|
498 |
|
|
499 |
//add length to the buffer
|
|
500 |
if ( aAddress )
|
|
501 |
{
|
|
502 |
//amount of used semi-octets in address data
|
|
503 |
aDest[0] = ( TUint8 )destLength;
|
|
504 |
}
|
|
505 |
else
|
|
506 |
{
|
|
507 |
//length of whole address data - length of address length field
|
|
508 |
aDest[0] = ( TUint8 )( bufferLength - 1 );
|
|
509 |
}
|
|
510 |
|
|
511 |
//add typeOfNumber to the buffer
|
|
512 |
aDest[1] = typeOfNumber;
|
|
513 |
|
|
514 |
//needed variables
|
|
515 |
TUint8 numLsb( 0 );
|
|
516 |
TUint8 numMsb( 0 );
|
|
517 |
TUint index( 2 );
|
|
518 |
|
|
519 |
//add numbers to the buffer
|
|
520 |
for ( ; ( i+1 ) < numberLength ; i+=2 )
|
|
521 |
{
|
|
522 |
numLsb = TUint8( aSource[i] - '0' );
|
|
523 |
numMsb = TUint8( ( aSource[i+1] - '0' ) << 4 );
|
|
524 |
|
|
525 |
aDest[index++] = TUint8( numLsb | numMsb );
|
|
526 |
}
|
|
527 |
|
|
528 |
//if numberLength is odd, last number is fixed with 0xF0
|
|
529 |
if ( i < numberLength )
|
|
530 |
{
|
|
531 |
aDest[index] = TUint8( 0xF0 | ( aSource[i] - '0' ) );
|
|
532 |
}
|
|
533 |
}
|
|
534 |
}
|
|
535 |
|
|
536 |
void TSmsStoreTsyTestHelper::GsmUnicodeAddrToAlphanumericAddr( TDesC16& aSource,
|
|
537 |
TDes8& aDestination,
|
|
538 |
TUint8& aAmountOfSemiOctets )
|
|
539 |
/**
|
|
540 |
* TSmsStoreTsyTestHelper::GsmUnicodeAddrToAlphanumericAddr
|
|
541 |
* Converts Unicode characters to GSM 7-bit bit Default Alphabet
|
|
542 |
* characters. Note that all Unicode characters
|
|
543 |
* are not supported by the GSM 7-bit bit Default Alphabet set. Such
|
|
544 |
* characters are converted to spaces or to the nearest substitute
|
|
545 |
* (generally the acute/grave marks are removed). Control characters and
|
|
546 |
* special characters are converted to spaces. This method supports GSM
|
|
547 |
* 7-bit bit Default Alphabet extension table
|
|
548 |
* mechanism.
|
|
549 |
|
|
550 |
* After character conversion this method packs address data by calling
|
|
551 |
* GsmLibSmsPackMessage method
|
|
552 |
* (other items were commented in a header).
|
|
553 |
*
|
|
554 |
* @param aSource the original address to be converted
|
|
555 |
* @param aDestination is the converted address
|
|
556 |
* @param aAmountOfSemiOctets is how many semi-octets is used in packed address
|
|
557 |
*/
|
|
558 |
{
|
|
559 |
TUint16 j( 0 );
|
|
560 |
TUint16 i( 0 );
|
|
561 |
|
|
562 |
TBuf8<RMobilePhone::KMaxMobileTelNumberSize> alphaChars;
|
|
563 |
for ( i = 0; i < aSource.Length(); i++ )
|
|
564 |
{
|
|
565 |
if ( ( aSource[i] > 0x24 ) && ( aSource[i] < 0x5B ) &&
|
|
566 |
( aSource[i] != 0x40 ) ||
|
|
567 |
( aSource[i] > 0x60 ) && ( aSource[i] < 0x7B ) )
|
|
568 |
{
|
|
569 |
// Conversion could be done only taking out the most significant
|
|
570 |
// bit from Unicode characters between 0x25 - 0x5A or 0x61 - 0x7A
|
|
571 |
// excluding '@' (0x40).
|
|
572 |
alphaChars.Append(aSource[i]);
|
|
573 |
}
|
|
574 |
else if ( ( aSource[i] > 0x5A) && ( aSource[i] < 0x5F ) ||
|
|
575 |
( aSource[i] > 0x7A ) && ( aSource[i] < 0x7F ) ||
|
|
576 |
( aSource[i] == 0x20AC ) )
|
|
577 |
{
|
|
578 |
//Conversion made using GSM 7 bit default alphabet extension
|
|
579 |
//table. Characters: [,\,],^,{,|,},~,&euro
|
|
580 |
for ( j = 0 ; j < KGsmLibConvTableSize; j++ )
|
|
581 |
{
|
|
582 |
if ( aSource[i] == KGsmExtensionConvTable[j].iUnicodeChar )
|
|
583 |
{
|
|
584 |
alphaChars.Append( 0x1B );// extension table flag
|
|
585 |
alphaChars.Append(
|
|
586 |
KGsmExtensionConvTable[j].iGsmChar );
|
|
587 |
break;
|
|
588 |
}
|
|
589 |
}
|
|
590 |
}
|
|
591 |
else
|
|
592 |
{
|
|
593 |
//Try to find character from conversion table.
|
|
594 |
TBool notFound( ETrue );
|
|
595 |
for ( j = 0; j < KGsmLibConvTableSize; j++ )
|
|
596 |
{
|
|
597 |
if ( aSource[i] == KGsmLibConvTable[j].iUnicodeChar )
|
|
598 |
{
|
|
599 |
alphaChars.Append(
|
|
600 |
KGsmLibConvTable[j].iGsmChar );
|
|
601 |
notFound = EFalse;
|
|
602 |
break;
|
|
603 |
}
|
|
604 |
}
|
|
605 |
|
|
606 |
if( notFound )
|
|
607 |
{
|
|
608 |
//Couldn't found similar character. Convert to SPACE.
|
|
609 |
alphaChars.Append( 0x20 );
|
|
610 |
}
|
|
611 |
}
|
|
612 |
}
|
|
613 |
|
|
614 |
TUint8 packedChars = GsmLibPackAlphanumericAddress( aDestination, alphaChars );
|
|
615 |
|
|
616 |
//How many unused bits packed address contains
|
|
617 |
TUint8 unusedBits = (TUint8)( ( aDestination.Length() * 8 ) -
|
|
618 |
( packedChars * 7 ) );
|
|
619 |
|
|
620 |
//How many semi-octets is used in packed address.
|
|
621 |
if ( unusedBits >= 4 )
|
|
622 |
{
|
|
623 |
//Last semi-octet doesn't contain address data
|
|
624 |
aAmountOfSemiOctets = (TUint8)( ( aDestination.Length() * 2 ) - 1 );
|
|
625 |
}
|
|
626 |
else
|
|
627 |
{
|
|
628 |
//All semi-octets are used
|
|
629 |
aAmountOfSemiOctets = (TUint8)( aDestination.Length() * 2 );
|
|
630 |
}
|
|
631 |
}
|
|
632 |
|
|
633 |
TUint8 TSmsStoreTsyTestHelper::GsmLibPackAlphanumericAddress( TDes8& aDest, TDes8& aSource )
|
|
634 |
/**
|
|
635 |
* TSmsStoreTsyTestHelper::GsmLibPackAlphanumericAddress
|
|
636 |
* This function packs a given text string consisting of 7-bit
|
|
637 |
* characters into 8 bit bytes in such a way that a 11-character
|
|
638 |
* address takes only 10 bytes of memory after the compression
|
|
639 |
* (other items were commented in a header).
|
|
640 |
*
|
|
641 |
* @param aDest is the retultant string after packing
|
|
642 |
* @param aSource is the 7 bit character string to be packed
|
|
643 |
*
|
|
644 |
* @return the length of the coded message.
|
|
645 |
*/
|
|
646 |
{
|
|
647 |
TUint8 si( 0 );
|
|
648 |
TUint8 di( 0 );
|
|
649 |
TUint tempModulo;
|
|
650 |
|
|
651 |
// Set tempModulo and byteCount
|
|
652 |
tempModulo = di % 7;
|
|
653 |
TUint8 byteCount = (TUint8)aSource.Length();
|
|
654 |
|
|
655 |
// Maximum length of address data field is 10 bytes. 10 bytes can contain
|
|
656 |
// 11 compressed 7-bit characters. Because of this maximum
|
|
657 |
// amount of characters in alphanumeric address is 11.
|
|
658 |
if ( byteCount > ( KMaxLengthOfAddressData + 1 ) )
|
|
659 |
{
|
|
660 |
byteCount = KMaxLengthOfAddressData + 1;
|
|
661 |
}
|
|
662 |
|
|
663 |
while ( si < byteCount )
|
|
664 |
{
|
|
665 |
// Is this the last character of the message?
|
|
666 |
// If it is, just shift it to the right. Otherwise,
|
|
667 |
// fill the rest of the byte with the bits of the next
|
|
668 |
// source character.
|
|
669 |
|
|
670 |
if ( si == (byteCount - 1) )
|
|
671 |
{
|
|
672 |
TUint num2 = ( aSource[si] >> tempModulo );
|
|
673 |
aDest.Append( num2 );
|
|
674 |
}
|
|
675 |
else
|
|
676 |
{
|
|
677 |
TUint num2 = ( aSource[si] >> tempModulo ) |
|
|
678 |
( aSource[si + 1] << ( 7 - tempModulo ) );
|
|
679 |
aDest.Append( num2 );
|
|
680 |
}
|
|
681 |
|
|
682 |
di++;
|
|
683 |
tempModulo = di % 7;
|
|
684 |
|
|
685 |
// Check if the destination byte could take the entire source
|
|
686 |
// character. In that case, the source character does not have to be
|
|
687 |
// divided and the next source character can be taken.
|
|
688 |
|
|
689 |
if ( KErrNone == tempModulo )
|
|
690 |
{
|
|
691 |
si += 2;
|
|
692 |
}
|
|
693 |
else
|
|
694 |
{
|
|
695 |
si++;
|
|
696 |
}
|
|
697 |
}
|
|
698 |
|
|
699 |
// Return the length of the coded message.
|
|
700 |
return byteCount;
|
|
701 |
}
|
|
702 |
|
|
703 |
|
|
704 |
TBool TSmsStoreTsyTestHelper::ToText(TDes &aRet,const TDesC8 &aOrigin,TBool aIsRecv)
|
|
705 |
/*
|
|
706 |
* Helper function, which will extract the sms messege actual text from an sms PDU.
|
|
707 |
* The text is decoded in a 7 bits caracters, and this methos convert it them to 8 bit characters and then 16 bit string.
|
|
708 |
*
|
|
709 |
* @param aRet The String that will hold the message text.
|
|
710 |
* @param aOrigin the actual PDU.
|
|
711 |
* @param aIsRecv a boolean argument that is ETrue for a Receive PDU and EFalse if this is a send PDU.
|
|
712 |
*
|
|
713 |
* @return ETrue if succesful, EFalse if not.
|
|
714 |
*
|
|
715 |
*
|
|
716 |
*/
|
|
717 |
{
|
|
718 |
aRet.Zero();
|
|
719 |
TUint first;
|
|
720 |
if(aIsRecv)
|
|
721 |
{
|
|
722 |
if(aOrigin.Length()<2)
|
|
723 |
{
|
|
724 |
return EFalse;
|
|
725 |
}
|
|
726 |
first = (TUint)aOrigin[1]/2 + 13;
|
|
727 |
}
|
|
728 |
else
|
|
729 |
{
|
|
730 |
if(aOrigin.Length()<3)
|
|
731 |
{
|
|
732 |
return EFalse;
|
|
733 |
}
|
|
734 |
first = (TUint)aOrigin[2]/2 + 8;
|
|
735 |
}
|
|
736 |
if(aOrigin.Length()<first+1)
|
|
737 |
{
|
|
738 |
return EFalse;
|
|
739 |
}
|
|
740 |
|
|
741 |
TUint8 temp1=0;
|
|
742 |
TUint shift=0;
|
|
743 |
for(TInt i=first;i<aOrigin.Length();++i)
|
|
744 |
{
|
|
745 |
TUint16 maskLeft=(1<<(8-shift-1))-1;
|
|
746 |
TUint16 maskRight=255-maskLeft;
|
|
747 |
TUint8 left=aOrigin[i]&maskLeft;
|
|
748 |
TUint right=aOrigin[i]&maskRight;
|
|
749 |
left=left<<(shift);
|
|
750 |
left = left | temp1;
|
|
751 |
right=right>>(8-shift-1);
|
|
752 |
aRet.Append(left);
|
|
753 |
temp1=right;
|
|
754 |
shift++;
|
|
755 |
if(shift==7)
|
|
756 |
{
|
|
757 |
aRet.Append(right);
|
|
758 |
shift=0;
|
|
759 |
temp1=0;
|
|
760 |
}
|
|
761 |
}
|
|
762 |
return ETrue;
|
|
763 |
}
|
|
764 |
|
|
765 |
TBool TSmsStoreTsyTestHelper::EnsureStoreFullL(RMobileSmsStore& aSmsStore)
|
|
766 |
/*
|
|
767 |
* Helper function, which make check if the sms store is full, and if not, fill all the empty slots in the store.
|
|
768 |
*
|
|
769 |
* @param aSmsStore A reference to the store session
|
|
770 |
*
|
|
771 |
* @return ETrue if succesful and the store is full, EFalse if not.
|
|
772 |
*
|
|
773 |
*/
|
|
774 |
{
|
|
775 |
// Get SMS store info.
|
|
776 |
TExtEtelRequestStatus getInfoStatus (aSmsStore,EMobilePhoneStoreGetInfo);
|
|
777 |
CleanupStack::PushL(getInfoStatus);
|
|
778 |
RMobilePhoneStore::TMobilePhoneStoreInfoV1 storeInfo;
|
|
779 |
RMobileSmsStore::TMobilePhoneStoreInfoV1Pckg storeInfoPckg (storeInfo);
|
|
780 |
aSmsStore.GetInfo(getInfoStatus,storeInfoPckg);
|
|
781 |
CHECK_EQUALS_L(iTestStep.WaitForRequestWithTimeOut(getInfoStatus, ETimeMedium), KErrNone,_L("RMobileSmsStore::GetInfo timed out"));
|
|
782 |
CHECK_EQUALS_L(getInfoStatus.Int(), KErrNone, _L("RMobileSmsStore::GetInfo returned an error"));
|
|
783 |
|
|
784 |
// Write a valid entries with into the sms store till it full
|
|
785 |
RMobileSmsStore::TMobileGsmSmsEntryV1 entry;
|
|
786 |
RMobileSmsStore::TMobileGsmSmsEntryV1Pckg pckgEntry(entry);
|
|
787 |
entry.iServiceCentre.iTypeOfNumber = RMobilePhone::EUnknownNumber;
|
|
788 |
entry.iServiceCentre.iNumberPlan = RMobilePhone::EUnknownNumberingPlan;
|
|
789 |
entry.iServiceCentre.iTelNumber =_L("01234");
|
|
790 |
entry.iMsgStatus = RMobileSmsStore::EStoredMessageUnread;
|
|
791 |
entry.iMsgData=KValidSmsPdu1;
|
|
792 |
TExtEtelRequestStatus writeStatus (aSmsStore,EMobilePhoneStoreWrite);
|
|
793 |
CleanupStack::PushL(writeStatus);
|
|
794 |
for (TInt i = storeInfo.iUsedEntries; i < storeInfo.iTotalEntries; i++)
|
|
795 |
{
|
|
796 |
entry.iIndex = -1; // need to reset this every time
|
|
797 |
aSmsStore.Write(writeStatus,pckgEntry);
|
|
798 |
CHECK_EQUALS_L(iTestStep.WaitForRequestWithTimeOut(writeStatus, ETimeMedium), KErrNone, _L("RMobileSmsStore::Write timed out"));
|
|
799 |
CHECK_EQUALS_L(writeStatus.Int(), KErrNone, _L("RMobileSmsStore::Write returned an error"));
|
|
800 |
}
|
|
801 |
|
|
802 |
// Get SMS store info.
|
|
803 |
aSmsStore.GetInfo(getInfoStatus,storeInfoPckg);
|
|
804 |
CHECK_EQUALS_L(iTestStep.WaitForRequestWithTimeOut(getInfoStatus, ETimeMedium), KErrNone, _L("RMobileSmsStore::GetInfo, timed out"));
|
|
805 |
CHECK_EQUALS_L(getInfoStatus.Int(), KErrNone, _L("RMobileSmsStore::GetInfo returned an error"));
|
|
806 |
|
|
807 |
// Pop:
|
|
808 |
// writeStatus
|
|
809 |
// getInfoStatus
|
|
810 |
CleanupStack::PopAndDestroy(2,&getInfoStatus);
|
|
811 |
|
|
812 |
// Validate that the sms store is full
|
|
813 |
return (storeInfo.iUsedEntries == storeInfo.iTotalEntries);
|
|
814 |
}
|