1 /* |
|
2 * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Specific class for NWE tests |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <e32svr.h> |
|
23 #include <stifparser.h> |
|
24 #include <stiftestinterface.h> |
|
25 #include <smsisi.h> |
|
26 #include "sms.h" |
|
27 |
|
28 |
|
29 // Converts semioct-code to character, semioctet can be 0x00 - 0x0F |
|
30 #define gsmSmsSemiOctetToChar( bcd ) gsmSmsSemiOctetToCharTable[bcd] |
|
31 |
|
32 // This table is used when a 03.40 or 04.11 address is converted to Unicode. |
|
33 const TUint gsmSmsSemiOctetToCharTable[16] = |
|
34 { |
|
35 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 0x00, 0x00, 0x00, |
|
36 0x00, 0x00, 0x00 |
|
37 }; |
|
38 |
|
39 |
|
40 // ============================ MEMBER FUNCTIONS =============================== |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CSMS::Delete |
|
43 // Delete here all resources allocated and opened from test methods. |
|
44 // Called from destructor. |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 void CSMS::Delete() |
|
48 { |
|
49 iSmspListArray->ResetAndDestroy(); |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CSMS::RunMethodL |
|
54 // Run specified method. Contains also table of test mothods and their names. |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 TInt CSMS::RunMethodL( |
|
58 CStifItemParser& aItem ) |
|
59 { |
|
60 _LIT8 (KLog, "SMS: RunMethodL" ); |
|
61 iSMSLog->Log((TDesC8)KLog); |
|
62 //iSMSLog->Log(_L("SMS: RunMethodL")); |
|
63 static TStifFunctionInfo const KFunctions[] = |
|
64 { |
|
65 // Copy this line for every implemented function. |
|
66 // First string is the function name used in TestScripter script file. |
|
67 // Second is the actual implementation member function. |
|
68 ENTRY( "RunIscTestCase", CCore::RunIscTestCase), |
|
69 ENTRY( "SyncIscTestCase", CCore::SyncIscTestCase), |
|
70 ENTRY( "RunIscTestCaseIgnoreXMLsWhenRealCellmoInUseFlagIsDefined", |
|
71 CCore::RunIscTestCaseIgnoreXMLsWhenRealCellmoInUseFlagIsDefined), |
|
72 ENTRY( "SyncIscTestCaseDoNotSyncIfRealCellmoInUseFlagIsDefined", |
|
73 CCore::SyncIscTestCaseDoNotSyncIfRealCellmoInUseFlagIsDefined), |
|
74 ENTRY( "SendSMSMessage", CSMS::SendSMSMessageL ), |
|
75 ENTRY( "SendTwoSMSMessages", CSMS::SendTwoSMSMessagesL ), |
|
76 ENTRY( "ReadSMSMessage", CSMS::ReadSMSMessageL ), |
|
77 ENTRY( "DeleteSMSMessage", CSMS::DeleteSMSMessageL ), |
|
78 ENTRY( "DeleteAllSMSMessages", CSMS::DeleteAllSMSMessagesL ), |
|
79 ENTRY( "SetMoSmsBearer", CSMS::SetMoSmsBearerL ), |
|
80 ENTRY( "WriteSMSMessage", CSMS::WriteSMSMessageL ), |
|
81 ENTRY( "ReceiveSMSMessage", CSMS::ReceiveSMSMessageL ), |
|
82 ENTRY( "ActivateSMSRouting", CSMS::ActivateSMSRoutingL ), |
|
83 ENTRY( "AckSMS", CSMS::AckSMSL ), |
|
84 ENTRY( "DeactivateSMSRouting", CSMS::DeactivateSMSRoutingL ), |
|
85 ENTRY( "ResumeSMS", CSMS::ResumeSMSL ), |
|
86 ENTRY( "ReadAllSMSMessage", CSMS::ReadAllSMSMessageL ), |
|
87 ENTRY( "NackSMS", CSMS::NackSMSL ), |
|
88 ENTRY( "SIMMsgStorageInfo", CSMS::SIMMsgStorageInfoL ), |
|
89 ENTRY( "ReadSmsParameters", CSMS::ReadSmsParametersL ), |
|
90 ENTRY( "StoreSmsParameters", CSMS::StoreSmsParametersL ), |
|
91 ENTRY( "SMSCacheInitialization", CSMS::SMSCacheInitializationL ), |
|
92 ENTRY( "HandleSpecifiedRequests", CCore::HandleSpecifiedRequests), |
|
93 ENTRY( "InitializeIPCRequestTable", CCore::InitializeIPCRequestTable), |
|
94 ENTRY( "SetExpectedCompleteIPC", CCore::SetExpectedCompleteIPC), |
|
95 ENTRY( "SetSmsParameterCheck", CSMS::SetSmsParameterCheck), |
|
96 ENTRY( "SetSmsReferenceParameters", CSMS::SetSmsReferenceParameters), |
|
97 ENTRY( "SmsSettingsUpdate", CSMS::SmsSettingsUpdate), |
|
98 }; |
|
99 |
|
100 const TInt count = sizeof( KFunctions ) / |
|
101 sizeof( TStifFunctionInfo ); |
|
102 |
|
103 return RunInternalL( KFunctions, count, aItem ); |
|
104 |
|
105 } |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // CSMS::SetSmsParameterCheck |
|
109 // Sets SMS parameter checking and test case number |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 TInt CSMS::SetSmsParameterCheck( CStifItemParser& aItem ) |
|
113 { |
|
114 TInt ret( KErrNone ); |
|
115 _LIT8(KSetSmsParameterCheck, "SMS::SetSmsParameterCheck"); |
|
116 iSMSLog->Log((TDesC8)KSetSmsParameterCheck); |
|
117 |
|
118 // Is parameter checking required |
|
119 TPtrC string; |
|
120 aItem.GetNextString ( string ); |
|
121 |
|
122 if ( _L("ON") == string ) |
|
123 { |
|
124 iSmsParameterCheck = ETrue; |
|
125 } |
|
126 else |
|
127 { |
|
128 iSmsParameterCheck = EFalse; |
|
129 } |
|
130 |
|
131 // Test case number, used in parameter checking |
|
132 TInt testCaseNumber; |
|
133 aItem.GetNextInt( testCaseNumber ); |
|
134 iTestCaseNumber = (TTestCase) testCaseNumber; |
|
135 |
|
136 return ret; |
|
137 } |
|
138 |
|
139 // ----------------------------------------------------------------------------- |
|
140 // CSMS::SetSmsReferenceParameters |
|
141 // Sets SMS parameter checking and test case number |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 TInt CSMS::SetSmsReferenceParameters( CStifItemParser& aItem ) |
|
145 { |
|
146 TInt ret( KErrNone ); |
|
147 _LIT8(KSetSmsReferenceParameters, "SMS::SetSmsReferenceParameters"); |
|
148 iSMSLog->Log((TDesC8)KSetSmsReferenceParameters); |
|
149 |
|
150 // Set reference parameters depending on test case number |
|
151 if ( ETestCaseSms019 == iTestCaseNumber || |
|
152 ETestCaseSms001 == iTestCaseNumber ) |
|
153 { |
|
154 // Message reference |
|
155 TInt msgRef( 0 ); |
|
156 aItem.GetNextInt( msgRef ); |
|
157 iMsgRef = msgRef; |
|
158 // Length of the PDU string |
|
159 TInt count( 0 ); |
|
160 aItem.GetNextInt( count ); |
|
161 |
|
162 // PDU string |
|
163 TInt value( 0 ); |
|
164 for ( TUint8 i( 0 ); i < count; i++ ) |
|
165 { |
|
166 aItem.GetNextInt( value ); |
|
167 iPdu.Append( value ); |
|
168 } |
|
169 } |
|
170 else if ( ETestCaseSms008 == iTestCaseNumber ) |
|
171 { |
|
172 TInt parameterIndicator; |
|
173 TInt protocolId; |
|
174 TInt dataCodingScheme; |
|
175 TInt validityPeriod; |
|
176 TPtrC destAddress; |
|
177 TPtrC serviceCenterAddress; |
|
178 TPtrC alphaTag; |
|
179 |
|
180 // Number of SMS parameter sets |
|
181 aItem.GetNextInt( iNumOfSmspSets ); |
|
182 |
|
183 for ( TUint8 i( 0 ); i < iNumOfSmspSets; i++ ) |
|
184 { |
|
185 TSmsParameters* smsParam = new ( ELeave ) TSmsParameters(); |
|
186 aItem.GetNextInt( parameterIndicator ); |
|
187 aItem.GetNextInt( protocolId ); |
|
188 aItem.GetNextInt( dataCodingScheme ); |
|
189 aItem.GetNextInt( validityPeriod ); |
|
190 aItem.GetNextString( serviceCenterAddress ); |
|
191 aItem.GetNextString( destAddress ); |
|
192 aItem.GetNextString( alphaTag ); |
|
193 |
|
194 smsParam->iParameterIndicator = parameterIndicator; |
|
195 smsParam->iProtocolId = protocolId; |
|
196 smsParam->iDataCodingScheme = dataCodingScheme; |
|
197 smsParam->iValidityPeriod = validityPeriod; |
|
198 smsParam->iServiceCenterAddress = serviceCenterAddress; |
|
199 smsParam->iDestinationAddress = destAddress; |
|
200 smsParam->iAlphaTagData = alphaTag; |
|
201 |
|
202 iSmspListArray->AppendL( smsParam ); |
|
203 } |
|
204 } |
|
205 |
|
206 return ret; |
|
207 } |
|
208 |
|
209 // ----------------------------------------------------------------------------- |
|
210 // CSMS::SmsSettingsUpdate |
|
211 // Update SMS route settings |
|
212 // ----------------------------------------------------------------------------- |
|
213 // |
|
214 TInt CSMS::SmsSettingsUpdate( CStifItemParser& /*aItem*/ ) |
|
215 { |
|
216 enum TMobileSmsBearer |
|
217 { |
|
218 /** SMS messages will only be sent over a packet-switched (GPRS) network. */ |
|
219 ESmsBearerPacketOnly, |
|
220 /** SMS messages will only be sent over a circuit-switched (GSM) network. */ |
|
221 ESmsBearerCircuitOnly, |
|
222 /** SMS messages will be sent over the packet-switched (GPRS) network if possible, |
|
223 otherwise over circuit-switched (GSM) network. */ |
|
224 ESmsBearerPacketPreferred, |
|
225 /** SMS messages will be sent over the circuit-switched (GSM) network if possible, |
|
226 otherwise over packet-switched (GPRS) network. */ |
|
227 ESmsBearerCircuitPreferred |
|
228 }; |
|
229 |
|
230 TInt ret( KErrNone ); |
|
231 _LIT8( KSmsSettingsUpdate, "SMS::SmsSettingsUpdate"); |
|
232 iSMSLog->Log((TDesC8)KSmsSettingsUpdate); |
|
233 |
|
234 //Create package |
|
235 CMmDataPackage package; |
|
236 TMobileSmsBearer bearer( ESmsBearerPacketOnly ); |
|
237 //Pack parameters |
|
238 package.PackData( &bearer ); |
|
239 |
|
240 ret = HandleRequestL( EMobileSmsMessagingSetMoSmsBearer, &package ); |
|
241 return ret; |
|
242 } |
|
243 |
|
244 // ----------------------------------------------------------------------------- |
|
245 // CSMS::SendSMSMessage |
|
246 // SendSMSMessage method function. |
|
247 // ----------------------------------------------------------------------------- |
|
248 // |
|
249 TInt CSMS::SendSMSMessageL(CStifItemParser& aItem) |
|
250 { |
|
251 _LIT8(KSendSMSMessage, "SMS::SendSMSMessage"); |
|
252 iSMSLog->Log((TDesC8)KSendSMSMessage); |
|
253 |
|
254 TInt ret = KErrNotFound; |
|
255 TPtrC16 string; // Name of the test case |
|
256 TPtrC number; // Number of destination |
|
257 TPtrC messagecenternumber; // Number of MessageCenter |
|
258 TPtrC satoriginated; // SAT ORIGINATED SMS |
|
259 aItem.GetNextString(string); |
|
260 aItem.GetNextString(number); |
|
261 aItem.GetNextString(messagecenternumber); |
|
262 aItem.GetNextString(satoriginated); |
|
263 |
|
264 TBuf8 <260> msgdata; |
|
265 if (string == (_L("SendSMSMessage4"))) |
|
266 { |
|
267 TUint MsgParameters( 0 ); |
|
268 const TUint SmsMsgTypeSubmitOrSubmitR = 0x01; |
|
269 const TUint SmsMsgVPabsolute = 0x34; // absolute format |
|
270 |
|
271 // TSY doesn't handle this information. Destination address goes in PDU. |
|
272 iMsgAttrib.iDestination.iTelNumber = number; //_L("0405431828"); |
|
273 iMsgAttrib.iDestination.iTypeOfNumber = RMobilePhone::ENationalNumber; |
|
274 iMsgAttrib.iDestination.iNumberPlan = RMobilePhone::EIsdnNumberPlan; |
|
275 TBuf8<160> source; |
|
276 TUint8 UD[145]={'t','e','s','t',' ','m','e','s','s','a','g','e',' ', |
|
277 'f','o','u','r',' ','4',' ','*','*','*','*','*','*','*','*','*', |
|
278 '*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*', |
|
279 '*','*','*','*','*','*','*','*','*','*','*','*','*','*', |
|
280 '*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*', |
|
281 '*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*', |
|
282 '*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*', |
|
283 '*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*', |
|
284 '*','*','*','*','*','*','*','*','*','*','*',' ','l','e','n','g', |
|
285 't','h','=','1','4','9'}; |
|
286 |
|
287 source.Append(&UD[0],sizeof(UD)); |
|
288 |
|
289 // If you want to convert user data to 7bit format: |
|
290 TBuf8<140> UserData; |
|
291 TUint16 byte_count = (TUint16)source.Length(); |
|
292 GsmLibCharConversion( TKGsmLibConvertToGsmFormat, source, byte_count ); |
|
293 GsmLibSmsPackMessage( UserData, source, byte_count ); |
|
294 TUint16 charCnt = (TUint16)( (UserData.Length()*8) / 7 ); |
|
295 if ( ( ( ( iGsmMes.Length()*8 ) % 7 ) == 0) && |
|
296 charCnt && charCnt <= iGsmMes.Length() ) |
|
297 { |
|
298 if ( UserData[charCnt-1] == 0 ) |
|
299 // if the last char is NULL, Actual charCnt is charCnt-1 |
|
300 { |
|
301 charCnt--; |
|
302 } |
|
303 } |
|
304 |
|
305 //CASE: SEND SMS MESSAGE |
|
306 iMsgAttrib.iFlags = (RMobileSmsMessaging::KSmsDataFormat + |
|
307 RMobileSmsMessaging::KGsmServiceCentre + |
|
308 RMobileSmsMessaging::KRemotePartyInfo + |
|
309 RMobileSmsMessaging::KMoreToSend); |
|
310 // TSY takes now SC address from front of the TPDU |
|
311 iMsgAttrib.iDataFormat = RMobileSmsMessaging::EFormatGsmTpdu; |
|
312 iMsgAttrib.iGsmServiceCentre.iNumberPlan = |
|
313 RMobilePhone::EIsdnNumberPlan; |
|
314 iMsgAttrib.iGsmServiceCentre.iTypeOfNumber = |
|
315 RMobilePhone::EInternationalNumber; |
|
316 |
|
317 iMsgAttrib.iGsmServiceCentre.iTelNumber = messagecenternumber; |
|
318 iMsgAttrib.iMore = (TBool)(EFalse); |
|
319 |
|
320 MsgParameters = 0; |
|
321 MsgParameters |= SmsMsgTypeSubmitOrSubmitR; |
|
322 MsgParameters |= SmsMsgVPabsolute; |
|
323 TBuf8<7> ValidityPeriod; |
|
324 TUint8 validity[7]={0x00,0x00,0x00,0x00,0x00,0x00,0x00}; |
|
325 ValidityPeriod.Append(&validity[0],sizeof(validity)); |
|
326 TBuf<22> DEtemp = number; |
|
327 TPtrC16 DEnumber = DEtemp; |
|
328 TBuf8<12> DestinationAddress; |
|
329 GsmConvUnicodeTo0340Addr( |
|
330 2, //TON national number |
|
331 1, //NPI isdn numbering plan |
|
332 DestinationAddress, |
|
333 DEnumber ); |
|
334 msgdata.SetLength(0); //reset buffer |
|
335 msgdata.Append(MsgParameters); //Message params |
|
336 msgdata.Append(0x10); //TP-Message-Reference |
|
337 msgdata.Append(DestinationAddress); //TP-Destination-Address |
|
338 msgdata.Append(0x00); //TP-Protocol-Identifier |
|
339 msgdata.Append(0x02); //TP-Data-Coding-Scheme (8bit) |
|
340 msgdata.Append(0xA7); //TP-Validity-Period |
|
341 msgdata.Append(charCnt); //TP-User-Data-Length |
|
342 msgdata.Append(UserData); //TP-User-Data |
|
343 |
|
344 //Create package |
|
345 CMmDataPackage package; |
|
346 |
|
347 //structure for all sms parameters and data |
|
348 TSendSmsDataAndAttributes sendData; |
|
349 |
|
350 sendData.iAttributes = &iMsgAttrib; |
|
351 sendData.iMsgData = &msgdata; |
|
352 if (satoriginated == (_L("SAT_ORIGINATED"))) |
|
353 { |
|
354 sendData.iIpc = EMmTsySmsSendSatMessage; |
|
355 } |
|
356 else if (satoriginated == (_L("NO_FDN_CHECK"))) |
|
357 { |
|
358 sendData.iIpc = EMobileSmsMessagingSendMessageNoFdnCheck; |
|
359 } |
|
360 else |
|
361 { |
|
362 sendData.iIpc = EMobileSmsMessagingSendMessage; |
|
363 } |
|
364 //Pack parameters |
|
365 package.PackData( &sendData ); |
|
366 |
|
367 if (satoriginated == (_L("SAT_ORIGINATED"))) |
|
368 { |
|
369 ret = HandleRequestL( EMmTsySmsSendSatMessage, &package ); |
|
370 } |
|
371 else if (satoriginated == (_L("NO_FDN_CHECK"))) |
|
372 { |
|
373 ret = HandleRequestL( EMobileSmsMessagingSendMessageNoFdnCheck, &package ); |
|
374 } |
|
375 else |
|
376 { |
|
377 ret = HandleRequestL( EMobileSmsMessagingSendMessage, &package ); |
|
378 } |
|
379 |
|
380 // Signal with return status if it is not KErrNone |
|
381 if ( KErrNone != ret ) |
|
382 { |
|
383 Signal ( ret ); |
|
384 ret = KErrNone; |
|
385 } |
|
386 |
|
387 if ( KErrNone == ret ) |
|
388 |
|
389 { |
|
390 _LIT8( KSendOk, "Send SMS Message ok" ); |
|
391 iSMSLog->Log((TDesC8)KSendOk ); |
|
392 iSMSLog->Log( _L("Send SMS Message ok")); |
|
393 } |
|
394 else |
|
395 { |
|
396 _LIT8( KSendFailed, "Send SMS Message failed: %d" ); |
|
397 iSMSLog->Log((TDesC8)KSendFailed, ret ); |
|
398 } |
|
399 } |
|
400 |
|
401 else |
|
402 { |
|
403 ret = KErrNotFound; |
|
404 } |
|
405 |
|
406 return ret; |
|
407 } |
|
408 |
|
409 // ----------------------------------------------------------------------------- |
|
410 // CSMS::CompleteSendSMSMessage |
|
411 // Complete SendSMSMessage method function. |
|
412 // ----------------------------------------------------------------------------- |
|
413 // |
|
414 void CSMS::CompleteSendSMSMessage( TInt aResult ) //return Completion result value |
|
415 { |
|
416 _LIT8( KResult, "CompleteSendSMSMessage result: %d" ); |
|
417 iSMSLog->Log((TDesC8)KResult, aResult ); |
|
418 |
|
419 Signal( aResult ); |
|
420 } |
|
421 |
|
422 // ----------------------------------------------------------------------------- |
|
423 // CSMS::CompleteSendSMSMessage |
|
424 // Complete SendSMSMessage method function. |
|
425 // ----------------------------------------------------------------------------- |
|
426 // |
|
427 void CSMS::CompleteSendSMSMessage( TInt aResult, CMmDataPackage* aDataPackage ) |
|
428 { |
|
429 _LIT8( KResult, "CompleteSendSMSMessage result: %d" ); |
|
430 iSMSLog->Log((TDesC8)KResult, aResult ); |
|
431 |
|
432 // Check parameters depending on the test case |
|
433 if ( iSmsParameterCheck && |
|
434 ( ETestCaseSms019 == iTestCaseNumber || |
|
435 ETestCaseSms001 == iTestCaseNumber ) ) |
|
436 { |
|
437 TUint16 msgRef( 0 ); |
|
438 TBuf8<RMobileSmsMessaging::KGsmTpduSize> pdu; |
|
439 aDataPackage->UnPackData( msgRef, pdu ); |
|
440 |
|
441 if ( msgRef != iMsgRef || pdu != iPdu ) |
|
442 { |
|
443 aResult = KErrGeneral; |
|
444 } |
|
445 } |
|
446 |
|
447 iTestCaseNumber = ETestCaseNotDefined; |
|
448 Signal( aResult ); |
|
449 } |
|
450 |
|
451 // ----------------------------------------------------------------------------- |
|
452 // CSMS::SendTwoSMSMessages |
|
453 // SendTwoSMSMessages method function. |
|
454 // ----------------------------------------------------------------------------- |
|
455 // |
|
456 TInt CSMS::SendTwoSMSMessagesL( CStifItemParser& aItem ) |
|
457 { |
|
458 _LIT8(KSendSMSMessage, "SMS::SendTwoSMSMessages"); |
|
459 iSMSLog->Log((TDesC8)KSendSMSMessage); |
|
460 |
|
461 TInt ret = KErrNotFound; |
|
462 TPtrC16 string; // Name of the test case |
|
463 TPtrC number; // Number of destination |
|
464 TPtrC messagecenternumber; // Number of MessageCenter |
|
465 aItem.GetNextString(string); |
|
466 aItem.GetNextString(number); |
|
467 aItem.GetNextString(messagecenternumber); |
|
468 TBuf8 <260> msgdata; |
|
469 if (string == (_L("SendTwoSMSMessage1"))) |
|
470 { |
|
471 TUint MsgParameters( 0 ); |
|
472 const TUint SmsMsgTypeSubmitOrSubmitR = 0x01; |
|
473 const TUint SmsMsgVPabsolute = 0x34; // absolute format |
|
474 |
|
475 |
|
476 // TSY doesn't handle this information. Destination address goes in PDU. |
|
477 iMsgAttrib.iDestination.iTelNumber = number; |
|
478 |
|
479 |
|
480 iMsgAttrib.iDestination.iTypeOfNumber = RMobilePhone::ENationalNumber; |
|
481 iMsgAttrib.iDestination.iNumberPlan = RMobilePhone::EIsdnNumberPlan; |
|
482 |
|
483 |
|
484 TBuf8<160> source; |
|
485 |
|
486 |
|
487 if (iSecondMessage == EFalse) |
|
488 { |
|
489 TUint8 UD[35]= |
|
490 { |
|
491 'F','i','r','s','t',' ','m','e','s','s','a','g','e', |
|
492 ' ','T','e','s','t',' ','S','e','n','d',' ','t','w','o', |
|
493 ' ','m','e','s','s','a','g','e' |
|
494 }; |
|
495 source.Append(&UD[0],sizeof(UD)); |
|
496 iSecondMessage = ETrue; // First message has been send |
|
497 |
|
498 |
|
499 //CASE: SEND SMS MESSAGE |
|
500 iMsgAttrib.iFlags = (RMobileSmsMessaging::KSmsDataFormat + |
|
501 RMobileSmsMessaging::KGsmServiceCentre + |
|
502 RMobileSmsMessaging::KRemotePartyInfo + |
|
503 RMobileSmsMessaging::KMoreToSend); |
|
504 |
|
505 // TSY takes now SC address from front of the TPDU |
|
506 iMsgAttrib.iDataFormat = RMobileSmsMessaging::EFormatGsmTpdu; |
|
507 iMsgAttrib.iGsmServiceCentre.iNumberPlan = |
|
508 RMobilePhone::EIsdnNumberPlan; |
|
509 |
|
510 iMsgAttrib.iGsmServiceCentre.iTypeOfNumber = |
|
511 RMobilePhone::EInternationalNumber; |
|
512 |
|
513 iMsgAttrib.iGsmServiceCentre.iTelNumber = messagecenternumber; |
|
514 iMsgAttrib.iMore = (TBool)(EFalse); |
|
515 |
|
516 MsgParameters = 0; |
|
517 MsgParameters |= SmsMsgTypeSubmitOrSubmitR; |
|
518 MsgParameters |= SmsMsgVPabsolute; |
|
519 |
|
520 TBuf8<7> ValidityPeriod; |
|
521 TUint8 validity[7]={0x00,0x00,0x00,0x00,0x00,0x00,0x00}; |
|
522 ValidityPeriod.Append(&validity[0],sizeof(validity)); |
|
523 } |
|
524 |
|
525 else |
|
526 { |
|
527 TUint8 UD[36]= |
|
528 { |
|
529 'S','e','c','o','n','d',' ','m','e','s','s','a','g','e', |
|
530 ' ','T','e','s','t',' ','S','e','n','d',' ','t','w','o', |
|
531 ' ','m','e','s','s','a','g','e' |
|
532 }; |
|
533 source.Append(&UD[0],sizeof(UD)); |
|
534 |
|
535 |
|
536 //CASE: SEND SMS MESSAGE |
|
537 iMsgAttrib.iFlags = (RMobileSmsMessaging::KSmsDataFormat + |
|
538 RMobileSmsMessaging::KGsmServiceCentre + |
|
539 RMobileSmsMessaging::KRemotePartyInfo + |
|
540 RMobileSmsMessaging::KMoreToSend); |
|
541 |
|
542 // TSY takes now SC address from front of the TPDU |
|
543 iMsgAttrib.iDataFormat = RMobileSmsMessaging::EFormatGsmTpdu; |
|
544 iMsgAttrib.iGsmServiceCentre.iNumberPlan = |
|
545 RMobilePhone::EIsdnNumberPlan; |
|
546 |
|
547 iMsgAttrib.iGsmServiceCentre.iTypeOfNumber = |
|
548 RMobilePhone::EInternationalNumber; |
|
549 |
|
550 iMsgAttrib.iGsmServiceCentre.iTelNumber = messagecenternumber; |
|
551 iMsgAttrib.iMore = (TBool)(EFalse); |
|
552 MsgParameters = 0; |
|
553 MsgParameters |= SmsMsgTypeSubmitOrSubmitR; |
|
554 MsgParameters |= SmsMsgVPabsolute; |
|
555 |
|
556 //TP-Status-Report-Request |
|
557 const TUint StatusReportRequested = 0x20; // binary 00100000 |
|
558 MsgParameters |= StatusReportRequested; |
|
559 } |
|
560 |
|
561 TBuf8<140> UserData; |
|
562 |
|
563 TUint16 byte_count = (TUint16)source.Length(); |
|
564 GsmLibCharConversion( TKGsmLibConvertToGsmFormat, source, byte_count ); |
|
565 GsmLibSmsPackMessage( UserData, source, byte_count ); |
|
566 TUint16 charCnt = (TUint16)( (UserData.Length()*8) / 7 ); |
|
567 |
|
568 if ( ( ( ( iGsmMes.Length()*8 ) % 7 ) == 0) && |
|
569 charCnt && charCnt <= iGsmMes.Length() ) |
|
570 { |
|
571 if ( UserData[charCnt-1] == 0 ) |
|
572 // if the last char is NULL, Actual charCnt is charCnt-1 |
|
573 { |
|
574 charCnt--; |
|
575 } |
|
576 } |
|
577 |
|
578 TBuf<22> DEtemp = number;//_L("0405431828"); |
|
579 TPtrC16 DEnumber = DEtemp; |
|
580 TBuf8<12> DestinationAddress; |
|
581 GsmConvUnicodeTo0340Addr( |
|
582 2, //TON national number |
|
583 1, //NPI isdn numbering plan |
|
584 DestinationAddress, |
|
585 DEnumber ); |
|
586 |
|
587 msgdata.SetLength(0); //reset buffer |
|
588 msgdata.Append(MsgParameters); //Message params |
|
589 msgdata.Append(0x10); //TP-Message-Reference |
|
590 msgdata.Append(DestinationAddress); //TP-Destination-Address |
|
591 msgdata.Append(0x00); //TP-Protocol-Identifier |
|
592 msgdata.Append(0x02); //TP-Data-Coding-Scheme (8bit) |
|
593 msgdata.Append(0xA7); //TP-Validity-Period |
|
594 msgdata.Append(charCnt); //TP-User-Data-Length |
|
595 msgdata.Append(UserData); //TP-User-Data |
|
596 // MO SMS bearer setting |
|
597 //Create package |
|
598 CMmDataPackage package; |
|
599 |
|
600 //structure for all sms parameters and data |
|
601 TSendSmsDataAndAttributes sendData; |
|
602 |
|
603 sendData.iAttributes = &iMsgAttrib; |
|
604 sendData.iMsgData = &msgdata; |
|
605 sendData.iIpc = EMobileSmsMessagingSendMessage; |
|
606 |
|
607 //Pack parameters |
|
608 package.PackData( &sendData ); |
|
609 |
|
610 ret = HandleRequestL( EMobileSmsMessagingSendMessage, &package ); |
|
611 |
|
612 if ( KErrNone == ret ) |
|
613 |
|
614 { |
|
615 _LIT8( KSendOk, "Send SMS Message ok" ); |
|
616 iSMSLog->Log((TDesC8)KSendOk ); |
|
617 iSMSLog->Log( _L("Send SMS Message ok")); |
|
618 } |
|
619 else |
|
620 { |
|
621 _LIT8( KSendFailed, "Send SMS Message failed: %d" ); |
|
622 iSMSLog->Log((TDesC8)KSendFailed, ret ); |
|
623 } |
|
624 } |
|
625 else |
|
626 { |
|
627 ret = KErrNotFound; |
|
628 } |
|
629 |
|
630 return ret; |
|
631 } |
|
632 |
|
633 // ----------------------------------------------------------------------------- |
|
634 // CSMS::ReadSMSMessage |
|
635 // Reading SMS message for slot |
|
636 // ----------------------------------------------------------------------------- |
|
637 // |
|
638 TInt CSMS::ReadSMSMessageL( CStifItemParser& aItem ) |
|
639 { |
|
640 _LIT8(KReadSMSMessage, "SMS::ReadSMSMessage"); |
|
641 iSMSLog->Log((TDesC8)KReadSMSMessage); |
|
642 TInt ret (KErrNotFound); |
|
643 TInt slot; |
|
644 TPtrC16 msgStatus; |
|
645 TPtrC16 numberingPlan; |
|
646 TPtrC16 typeOfNumber; |
|
647 TPtrC serviceCentreAddress; |
|
648 TPtrC16 isClass2; |
|
649 TInt tpdu; |
|
650 |
|
651 aItem.GetNextInt( slot ); |
|
652 iSmsMsg.iLocation = slot; |
|
653 |
|
654 aItem.GetNextString( msgStatus ); |
|
655 if ( msgStatus == ( _L("KSimSmsMtNotRead" ) ) ) |
|
656 { |
|
657 iSmsMsg.iMessageStatus = KSimSmsMtNotRead; |
|
658 } |
|
659 else if ( msgStatus == ( _L("KSimSmsMtRead" ) ) ) |
|
660 { |
|
661 iSmsMsg.iMessageStatus = KSimSmsMtRead; |
|
662 } |
|
663 else |
|
664 { |
|
665 iSmsMsg.iMessageStatus = KSimSmsNotPresent; |
|
666 } |
|
667 |
|
668 aItem.GetNextString( numberingPlan ); |
|
669 if ( numberingPlan == ( _L("EIsdnNumberPlan" ) ) ) |
|
670 { |
|
671 iSmsMsg.iMobileScNPI = RMobilePhone::EIsdnNumberPlan; |
|
672 } |
|
673 else |
|
674 { |
|
675 iSmsMsg.iMobileScNPI = RMobilePhone::EUnknownNumberingPlan; |
|
676 } |
|
677 |
|
678 aItem.GetNextString( typeOfNumber ); |
|
679 if ( typeOfNumber == ( _L( "EInternationalNumber" ) ) ) |
|
680 { |
|
681 iSmsMsg.iMobileScTON = RMobilePhone::EInternationalNumber; |
|
682 } |
|
683 else |
|
684 { |
|
685 iSmsMsg.iMobileScTON = RMobilePhone::EUnknownNumber; |
|
686 } |
|
687 |
|
688 aItem.GetNextString( serviceCentreAddress ); |
|
689 iSmsMsg.iServiceCentre = serviceCentreAddress; |
|
690 |
|
691 |
|
692 iSmsMsg.iSmsClass2 = EFalse; |
|
693 aItem.GetNextString( isClass2 ); |
|
694 if ( isClass2 == ( _L( "CLASS2" ) ) ) |
|
695 { |
|
696 iSmsMsg.iSmsClass2 = ETrue; |
|
697 } |
|
698 |
|
699 while ( !aItem.GetNextInt( tpdu ) ) |
|
700 { |
|
701 iSmsMsg.iSmsMsg.Append( tpdu ); |
|
702 } |
|
703 |
|
704 CMmDataPackage package; |
|
705 package.PackData( &slot ); |
|
706 ret= HandleRequestL( EMobilePhoneStoreRead, &package ); |
|
707 |
|
708 if ( KErrNone == ret ) |
|
709 { |
|
710 _LIT8( KOk, "Read SMS Message ok: %d" ); |
|
711 iSMSLog->Log((TDesC8)KOk ); |
|
712 } |
|
713 else |
|
714 { |
|
715 _LIT8( KFail, "Read SMS Message fails: %d" ); |
|
716 iSMSLog->Log((TDesC8)KFail, ret ); |
|
717 } |
|
718 |
|
719 return ret; |
|
720 } |
|
721 |
|
722 |
|
723 // ----------------------------------------------------------------------------- |
|
724 // CSMS::CompleteReadSMSMessage |
|
725 // Complete ReadSMSMessage method function. |
|
726 // ----------------------------------------------------------------------------- |
|
727 // |
|
728 void CSMS::CompleteReadSMSMessage( |
|
729 TInt aResult, //Completion result value |
|
730 CMmDataPackage* aDataPackage // pointer to DataPackage |
|
731 ) |
|
732 { |
|
733 // checking results and unpacking message |
|
734 if ( KErrNone == aResult ) |
|
735 { |
|
736 TSmsMsg smsMsg; |
|
737 aDataPackage->UnPackData( smsMsg ); |
|
738 if ( ( smsMsg.iLocation != iSmsMsg.iLocation ) || |
|
739 ( smsMsg.iMessageStatus != iSmsMsg.iMessageStatus ) || |
|
740 ( smsMsg.iMobileScNPI != iSmsMsg.iMobileScNPI ) || |
|
741 ( smsMsg.iMobileScTON != iSmsMsg.iMobileScTON ) || |
|
742 ( smsMsg.iServiceCentre != iSmsMsg.iServiceCentre ) || |
|
743 ( smsMsg.iSmsMsg != iSmsMsg.iSmsMsg ) || |
|
744 ( smsMsg.iSmsClass2 != iSmsMsg.iSmsClass2 ) ) |
|
745 { |
|
746 aResult = KErrGeneral; |
|
747 } |
|
748 } |
|
749 |
|
750 if ( KErrNone == aResult ) |
|
751 { |
|
752 _LIT8( KOk, "Complete Read SMS Message ok: %d" ); |
|
753 iSMSLog->Log((TDesC8)KOk ); |
|
754 } |
|
755 else |
|
756 { |
|
757 _LIT8( KFail, "Compelte Read SMS Message Failed: %d" ); |
|
758 iSMSLog->Log((TDesC8)KFail, aResult ); |
|
759 } |
|
760 |
|
761 Signal( aResult ); |
|
762 |
|
763 } |
|
764 |
|
765 // ----------------------------------------------------------------------------- |
|
766 // CSMS::DeleteSMSMessage |
|
767 // Deletes SMS messages |
|
768 // ----------------------------------------------------------------------------- |
|
769 // |
|
770 TInt CSMS::DeleteSMSMessageL( CStifItemParser& aItem ) |
|
771 { |
|
772 _LIT8(KDeleteSMSMessage, "SMS::DeleteSMSMessage"); |
|
773 iSMSLog->Log((TDesC8)KDeleteSMSMessage); |
|
774 TInt ret (KErrGeneral); |
|
775 TInt slot; |
|
776 aItem.GetNextInt(slot); |
|
777 |
|
778 CMmDataPackage package; |
|
779 package.PackData( &slot ); |
|
780 |
|
781 ret= HandleRequestL( EMobilePhoneStoreDelete, &package ); |
|
782 |
|
783 if ( KErrNone == ret ) |
|
784 { |
|
785 _LIT8(KResultOk, "Delete SMS Message ok" ); |
|
786 iSMSLog->Log((TDesC8)KResultOk); |
|
787 } |
|
788 else |
|
789 { |
|
790 _LIT8(KResultFail, "Delete SMS Message fails: %d" ); |
|
791 iSMSLog->Log((TDesC8)KResultFail, ret ); |
|
792 } |
|
793 |
|
794 return ret; |
|
795 } |
|
796 |
|
797 // ----------------------------------------------------------------------------- |
|
798 // CSMS::CompleteDeleteSMSMessage |
|
799 // Complete DeleteSMSMessage method function. |
|
800 // ----------------------------------------------------------------------------- |
|
801 // |
|
802 void CSMS::CompleteDeleteSMSMessage( TInt aResult ) //Completion result value |
|
803 { |
|
804 _LIT8(KResult, "Complete Delete SMS Message result: %d" ); |
|
805 iSMSLog->Log((TDesC8)KResult, aResult ); |
|
806 |
|
807 Signal( aResult ); |
|
808 } |
|
809 |
|
810 |
|
811 // ----------------------------------------------------------------------------- |
|
812 // CSMS::DeleteAllSMSMessages |
|
813 // Deletes all SMS messages |
|
814 // (other items were commented in a header). |
|
815 // ----------------------------------------------------------------------------- |
|
816 // |
|
817 TInt CSMS::DeleteAllSMSMessagesL( CStifItemParser& ) |
|
818 { |
|
819 _LIT8(KDeleteAllSMSMessages, "SMS::DeleteAllSMSMessages"); |
|
820 iSMSLog->Log((TDesC8)KDeleteAllSMSMessages); |
|
821 TInt ret (KErrGeneral); |
|
822 |
|
823 ret = HandleRequestL( EMobilePhoneStoreDeleteAll ); |
|
824 |
|
825 if ( KErrNone == ret ) |
|
826 { |
|
827 _LIT8(KResultOk, "Delete All SMS Messages ok" ); |
|
828 iSMSLog->Log((TDesC8)KResultOk); |
|
829 } |
|
830 else |
|
831 { |
|
832 _LIT8(KResultFail, "Delete All SMS Messages fails: %d" ); |
|
833 iSMSLog->Log((TDesC8)KResultFail, ret ); |
|
834 } |
|
835 |
|
836 return ret; |
|
837 } |
|
838 |
|
839 // ----------------------------------------------------------------------------- |
|
840 // CSMS::CompleteDeleteAllSMSMessages |
|
841 // Complete DeleteSMSMessage method function. |
|
842 // ----------------------------------------------------------------------------- |
|
843 // |
|
844 void CSMS::CompleteDeleteAllSMSMessages( TInt aResult ) //Completion result value |
|
845 { |
|
846 _LIT8(KResult, "Complete Delete All SMS Messages result: %d" ); |
|
847 iSMSLog->Log((TDesC8)KResult, aResult ); |
|
848 |
|
849 Signal( aResult ); |
|
850 } |
|
851 |
|
852 // ----------------------------------------------------------------------------- |
|
853 // CSMS::SetMoSmsBearer |
|
854 // Sets MO SMS Bearer (packet data or GSM) |
|
855 // ----------------------------------------------------------------------------- |
|
856 // |
|
857 TInt CSMS::SetMoSmsBearerL( CStifItemParser& aItem ) |
|
858 { |
|
859 TInt ret (KErrGeneral); |
|
860 |
|
861 TInt bearerInt; |
|
862 aItem.GetNextInt(bearerInt); |
|
863 |
|
864 _LIT8(KSetMoSmsBearer, "SMS::SetMoSmsBearer, bearer=%d"); |
|
865 iSMSLog->Log((TDesC8)KSetMoSmsBearer, bearerInt); |
|
866 |
|
867 RMobileSmsMessaging::TMobileSmsBearer bearer = |
|
868 static_cast< RMobileSmsMessaging::TMobileSmsBearer >( bearerInt ); |
|
869 |
|
870 CMmDataPackage package; |
|
871 package.PackData( &bearer ); |
|
872 |
|
873 ret = HandleRequestL( EMobileSmsMessagingSetMoSmsBearer, &package ); |
|
874 |
|
875 if ( KErrNone == ret ) |
|
876 { |
|
877 _LIT8(KResultOk, "Set MO SMS Bearer ok" ); |
|
878 iSMSLog->Log((TDesC8)KResultOk); |
|
879 } |
|
880 else |
|
881 { |
|
882 _LIT8(KResultFail, "Set MO SMS Bearer fails: %d" ); |
|
883 iSMSLog->Log((TDesC8)KResultFail, ret ); |
|
884 } |
|
885 |
|
886 return ret; |
|
887 } |
|
888 |
|
889 // ----------------------------------------------------------------------------- |
|
890 // CSMS::CompleteSetMoSmsBearer |
|
891 // Completes SetMoSmsBearer |
|
892 // ----------------------------------------------------------------------------- |
|
893 // |
|
894 void CSMS::CompleteSetMoSmsBearer( TInt aResult ) //Completion result value |
|
895 { |
|
896 _LIT8(KResult, "Complete Set MO SMS Bearer result: %d" ); |
|
897 iSMSLog->Log((TDesC8)KResult, aResult ); |
|
898 |
|
899 Signal( aResult ); |
|
900 } |
|
901 |
|
902 // ----------------------------------------------------------------------------- |
|
903 // CSMS::WriteSMSMessage |
|
904 // Write message to qnted slot |
|
905 // ----------------------------------------------------------------------------- |
|
906 // |
|
907 TInt CSMS::WriteSMSMessageL( CStifItemParser& aItem ) |
|
908 { |
|
909 _LIT8(KWriteSMSMessage, "SMS::WriteSMSMessage"); |
|
910 iSMSLog->Log((TDesC8)KWriteSMSMessage); |
|
911 |
|
912 TInt ret (KErrNotFound); |
|
913 TInt slot; |
|
914 TPtrC number; |
|
915 TPtrC servicecenternumber; |
|
916 aItem.GetNextString(number); |
|
917 aItem.GetNextString(servicecenternumber); |
|
918 aItem.GetNextInt(slot); |
|
919 |
|
920 // TName namee = _L( "SMS_SIM" ); |
|
921 // TBuf8<12> serviceCenterAddress; |
|
922 TBuf8<12> destinationAddress; |
|
923 TBuf8<200> omaPDU; |
|
924 |
|
925 //TUint msgParameters( 0 ); |
|
926 RMobileSmsStore::TMobileGsmSmsEntryV1 smsentry; |
|
927 RMobileSmsStore::TMobileGsmSmsEntryV1Pckg smsentryPckg( smsentry ); |
|
928 |
|
929 TBuf8<7> validityperiod; |
|
930 TUint8 validity[7]={ 0x01,0x02,0x03,0x04,0x05,0x06,0x07 }; |
|
931 validityperiod.Append(&validity[0],sizeof(validity)); |
|
932 |
|
933 TUint MsgParameters( 0 ); |
|
934 const TUint SmsMsgTypeSubmitOrSubmitR = 0x01; |
|
935 const TUint SmsMsgVPabsolute = 0x34; // absolute format |
|
936 |
|
937 // TSY doesn't handle this information. Destination address goes in PDU. |
|
938 iMsgAttrib.iDestination.iTelNumber = number; |
|
939 |
|
940 iMsgAttrib.iDestination.iTypeOfNumber = RMobilePhone::ENationalNumber; |
|
941 iMsgAttrib.iDestination.iNumberPlan = RMobilePhone::EIsdnNumberPlan; |
|
942 |
|
943 TBuf8<160> source; |
|
944 |
|
945 if (-1 == slot) |
|
946 { |
|
947 TUint8 UD[145]={'t','e','s','t',' ','m','e','s','s','a','g','e',' ', |
|
948 'f','o','r',' ','S','M','S',' ','T','e','s','t',' ','C','a','s', |
|
949 'e',' ','T','C','-','S','M','S','-','0','1','6','b',' ','t','h', |
|
950 'i','s',' ','m','e','s','s','a','g','e',' ','i','s',' ', |
|
951 's','t','o','r','e','d',' ','i','n',' ','f','i','r','s','t',' ', |
|
952 'a','v','a','i','l','e','b','l','e',' ','s','l','o','t',' ','b', |
|
953 'y',' ','g','i','v','i','n','g',' ','s','l','o','t',' ','n','u', |
|
954 'm','b','e','r',' ','a','s',' ','-','1','*','*','*','*','*','*', |
|
955 '*','*','*','*','*','*','*','*','*','*','*',' ','l','e','n','g', |
|
956 't','h','=','1','4','9'}; |
|
957 source.Append(&UD[0],sizeof(UD)); |
|
958 } |
|
959 else |
|
960 { |
|
961 TUint8 UD[73]={'t','e','s','t',' ','m','e','s','s','a','g','e',' ', |
|
962 ' ','f','o','r',' ','t','e','s','t',' ','1','6','a',' ','i','n', |
|
963 'S','M','S',' ','T','e','s','t',' ','C','a','s','e','s',' ','*', |
|
964 'h','u','o','m','a','t','t','a','v','a','s','t','i',' ', |
|
965 '*','*','*','*',' ','L','e','n','g','t','h','=','7','5'}; |
|
966 source.Append(&UD[0],sizeof(UD)); |
|
967 } |
|
968 |
|
969 // If you want to convert user data to 7bit format: |
|
970 TBuf8<140> userdata; |
|
971 TUint16 byte_count = ( TUint16 )source.Length(); |
|
972 GsmLibCharConversion( |
|
973 TKGsmLibConvertToGsmFormat, source, byte_count ); |
|
974 GsmLibSmsPackMessage( |
|
975 userdata, source, byte_count ); |
|
976 |
|
977 TBuf<23> detemp = number; |
|
978 TPtrC16 denumber = detemp; |
|
979 GsmConvUnicodeTo0340Addr( |
|
980 1, //TON international number |
|
981 1, //NPI isdn numbering plan |
|
982 destinationAddress, |
|
983 denumber ); |
|
984 |
|
985 omaPDU.Append(0x24); //Message params |
|
986 omaPDU.Append(destinationAddress); //TP-Orginating Address |
|
987 omaPDU.Append(0x00); //TP-Protocol-Identifier |
|
988 omaPDU.Append(0x00); //TP-Data-Coding-Scheme |
|
989 omaPDU.Append(0x10); //TP-Service Centre Time Stamp |
|
990 omaPDU.Append(0x80); //TP-Service Centre Time Stamp |
|
991 omaPDU.Append(0x71); //TP-Service Centre Time Stamp |
|
992 omaPDU.Append(0x41); //TP-Service Centre Time Stamp |
|
993 omaPDU.Append(0x73); //TP-Service Centre Time Stamp |
|
994 omaPDU.Append(0x14); //TP-Service Centre Time Stamp |
|
995 omaPDU.Append(0x80); //TP-Service Centre Time Stamp |
|
996 omaPDU.Append(byte_count); //TP-User-Data-Length |
|
997 omaPDU.Append(userdata); //TP-User-Data |
|
998 |
|
999 smsentry.iMsgData.Copy(omaPDU); |
|
1000 |
|
1001 smsentry.iMsgStatus = RMobileSmsStore::EStoredMessageRead; |
|
1002 smsentry.iIndex = slot; |
|
1003 smsentry.iServiceCentre.iNumberPlan = RMobilePhone::EIsdnNumberPlan; |
|
1004 smsentry.iServiceCentre.iTypeOfNumber = RMobilePhone::EInternationalNumber; |
|
1005 smsentry.iServiceCentre.iTelNumber = servicecenternumber; |
|
1006 |
|
1007 //Create package |
|
1008 CMmDataPackage package; |
|
1009 |
|
1010 RMobileSmsStore::TMobileGsmSmsEntryV1Pckg* smsentryPckgPtr = &smsentryPckg; |
|
1011 |
|
1012 //Pack parameters |
|
1013 package.PackData(&smsentryPckgPtr, &slot); |
|
1014 |
|
1015 ret = HandleRequestL( EMobilePhoneStoreWrite, &package ); |
|
1016 |
|
1017 if ( KErrNone == ret ) |
|
1018 { |
|
1019 _LIT8( KResultOk, "Write SMS Message ok" ); |
|
1020 iSMSLog->Log((TDesC8)KResultOk ); |
|
1021 iSMSLog->Log( _L("Write SMS Message ok")); |
|
1022 } |
|
1023 else |
|
1024 { |
|
1025 _LIT8( KResultFailed, "Write SMS Message failed: %d" ); |
|
1026 iSMSLog->Log((TDesC8)KResultFailed, ret ); |
|
1027 } |
|
1028 |
|
1029 return ret; |
|
1030 } |
|
1031 |
|
1032 // ----------------------------------------------------------------------------- |
|
1033 // CSMS::CompleteWriteSMSMessage |
|
1034 // Complete WriteSMSMessage method function. |
|
1035 // ----------------------------------------------------------------------------- |
|
1036 // |
|
1037 void CSMS::CompleteWriteSMSMessage( |
|
1038 TInt aResult, //Completion result value |
|
1039 CMmDataPackage* aDataPackage // pointer to DataPackage |
|
1040 ) |
|
1041 { |
|
1042 // unpacking message |
|
1043 TSmsMsg* smsMsg; |
|
1044 aDataPackage->UnPackData( smsMsg ); |
|
1045 |
|
1046 _LIT8(KResult, "Complete Write SMS Message: %d" ); |
|
1047 iSMSLog->Log((TDesC8)KResult, aResult ); |
|
1048 |
|
1049 Signal( aResult ); |
|
1050 } |
|
1051 |
|
1052 |
|
1053 // ----------------------------------------------------------------------------- |
|
1054 // CSMS::ReceiveMessage |
|
1055 // Cancels Receive Mode |
|
1056 // (other items were commented in a header). |
|
1057 // ----------------------------------------------------------------------------- |
|
1058 // |
|
1059 TInt CSMS::ReceiveSMSMessageL( CStifItemParser& aItem ) |
|
1060 { |
|
1061 _LIT8(KReceiveSMSMessages, "SMS::ReceiveSMSMessages"); |
|
1062 TInt ret (KErrNone); |
|
1063 |
|
1064 // Save SMS class type for comparison when receivin is completed. |
|
1065 TPtrC string; |
|
1066 aItem.GetNextString ( string ); |
|
1067 |
|
1068 // Set NetworkSelection |
|
1069 if ( _L("Class2") == string ) |
|
1070 { |
|
1071 iSMSLog->Log( _L("Expect class 2 SMS") ); |
|
1072 iReceivedSmsClass2 = ETrue; |
|
1073 } |
|
1074 else |
|
1075 { |
|
1076 iSMSLog->Log( _L("Expect class 1 SMS") ); |
|
1077 iReceivedSmsClass2 = EFalse; |
|
1078 } |
|
1079 |
|
1080 if ( KErrNone == ret ) |
|
1081 { |
|
1082 _LIT8( KResultOk, "Receive SMS Message ok" ); |
|
1083 iSMSLog->Log((TDesC8)KResultOk ); |
|
1084 iSMSLog->Log( _L("Receive SMS Message ok")); |
|
1085 } |
|
1086 else |
|
1087 { |
|
1088 _LIT8( KResultFailed, "Receive SMS Message failed: %d" ); |
|
1089 iSMSLog->Log((TDesC8)KResultFailed, ret ); |
|
1090 } |
|
1091 |
|
1092 return ret; |
|
1093 } |
|
1094 |
|
1095 |
|
1096 // ----------------------------------------------------------------------------- |
|
1097 // CSMS::CompleteReceiveSMSMessage |
|
1098 // Complete Receive SMS Message method function. |
|
1099 // ----------------------------------------------------------------------------- |
|
1100 // |
|
1101 void CSMS::CompleteReceiveSMSMessage( |
|
1102 TInt aResult, //Completion result value |
|
1103 CMmDataPackage* aDataPackage // pointer to DataPackage |
|
1104 ) |
|
1105 { |
|
1106 _LIT8(KResult, "Complete Receive SMS Message result: %d" ); |
|
1107 iSMSLog->Log((TDesC8)KResult, aResult ); |
|
1108 |
|
1109 TBool smsInd; |
|
1110 TSmsMsg* smsMsg; |
|
1111 aDataPackage->UnPackData( smsInd, smsMsg ); |
|
1112 // Is the SMS Class received the same as stored in ReceiveSMSMessageL |
|
1113 if ( smsMsg->iSmsClass2 != iReceivedSmsClass2 ) |
|
1114 { |
|
1115 aResult = KErrGeneral; |
|
1116 } |
|
1117 Signal( aResult ); |
|
1118 } |
|
1119 |
|
1120 |
|
1121 // ----------------------------------------------------------------------------- |
|
1122 // CSMS::ActivateSMSRouting |
|
1123 // Activate SMS routing |
|
1124 // (other items were commented in a header). |
|
1125 // ----------------------------------------------------------------------------- |
|
1126 // |
|
1127 TInt CSMS::ActivateSMSRoutingL( CStifItemParser& ) |
|
1128 { |
|
1129 _LIT8(KActivateSMSRouting, "SMS::ActivateSMsRouting"); |
|
1130 iSMSLog->Log((TDesC8)KActivateSMSRouting); |
|
1131 TInt ret (KErrNone); |
|
1132 |
|
1133 ret= HandleRequestL( EMmTsyActivateSmsRouting ); |
|
1134 |
|
1135 if ( KErrNone == ret ) |
|
1136 { |
|
1137 _LIT8(KResultOk, "Activate SMS routing ok" ); |
|
1138 iSMSLog->Log((TDesC8)KResultOk); |
|
1139 } |
|
1140 else |
|
1141 { |
|
1142 _LIT8(KResultFail, "Activate SMS routing fails: %d" ); |
|
1143 iSMSLog->Log((TDesC8)KResultFail, ret ); |
|
1144 } |
|
1145 |
|
1146 return ret; |
|
1147 } |
|
1148 |
|
1149 // ----------------------------------------------------------------------------- |
|
1150 // CSMS::CompleteActivateSMSRouting |
|
1151 // Complete Activate SMS Routing method function. |
|
1152 // ----------------------------------------------------------------------------- |
|
1153 // |
|
1154 void CSMS::CompleteActivateSMSRouting( TInt aResult ) //Completion result value |
|
1155 { |
|
1156 _LIT8(KResult, "Complete Activate SMS Routing result: %d" ); |
|
1157 iSMSLog->Log((TDesC8)KResult, aResult ); |
|
1158 |
|
1159 Signal( aResult ); |
|
1160 } |
|
1161 |
|
1162 |
|
1163 // ----------------------------------------------------------------------------- |
|
1164 // CSMS::CompleteActivateSMSRouting |
|
1165 // Complete Activate SMS Routing method function. |
|
1166 // ----------------------------------------------------------------------------- |
|
1167 // |
|
1168 void CSMS::CompleteActivateSMSRouting( |
|
1169 TInt aResult, |
|
1170 CMmDataPackage* aDataPackage ) |
|
1171 { |
|
1172 _LIT8(KResult, "Complete Activate SMS Routing result: %d" ); |
|
1173 iSMSLog->Log((TDesC8)KResult, aResult ); |
|
1174 |
|
1175 TUint8 receptionStatus; |
|
1176 aDataPackage->UnPackData( receptionStatus ); |
|
1177 if ( SMS_RECEPTION_INACTIVE == receptionStatus ) |
|
1178 { |
|
1179 aResult = KErrGeneral; |
|
1180 } |
|
1181 Signal( aResult ); |
|
1182 } |
|
1183 |
|
1184 |
|
1185 // ----------------------------------------------------------------------------- |
|
1186 // CSMS::AckSMS |
|
1187 // Acknowledge SMS message |
|
1188 // (other items were commented in a header). |
|
1189 // ----------------------------------------------------------------------------- |
|
1190 // |
|
1191 TInt CSMS::AckSMSL( CStifItemParser& ) |
|
1192 { |
|
1193 _LIT8(KAckSMS, "SMS::Acknowledge SMS"); |
|
1194 iSMSLog->Log((TDesC8)KAckSMS); |
|
1195 TInt ret (KErrNone); |
|
1196 |
|
1197 CMmDataPackage package; |
|
1198 TDesC8 empty = KNullDesC8; |
|
1199 package.PackData( &empty ); |
|
1200 ret= HandleRequestL( EMobileSmsMessagingAckSmsStored, &package ); |
|
1201 |
|
1202 if ( KErrNone == ret ) |
|
1203 { |
|
1204 _LIT8(KResultOk, "Acknowledge SMS ok" ); |
|
1205 iSMSLog->Log((TDesC8)KResultOk); |
|
1206 } |
|
1207 else |
|
1208 { |
|
1209 _LIT8(KResultFail, "Acknowledge SMS fails: %d" ); |
|
1210 iSMSLog->Log((TDesC8)KResultFail, ret ); |
|
1211 } |
|
1212 |
|
1213 return ret; |
|
1214 } |
|
1215 |
|
1216 // ----------------------------------------------------------------------------- |
|
1217 // CSMS::CompleteAckSMS |
|
1218 // Complete AckSMS method function. |
|
1219 // ----------------------------------------------------------------------------- |
|
1220 // |
|
1221 void CSMS::CompleteAckSMS( TInt aResult ) //Completion result value |
|
1222 { |
|
1223 _LIT8(KResult, "Complete Ack SMS result: %d" ); |
|
1224 iSMSLog->Log((TDesC8)KResult, aResult ); |
|
1225 |
|
1226 Signal( aResult ); |
|
1227 } |
|
1228 |
|
1229 // ----------------------------------------------------------------------------- |
|
1230 // CSMS::DeactivateSMSRouting |
|
1231 // Deactivate SMS routing |
|
1232 // (other items were commented in a header). |
|
1233 // ----------------------------------------------------------------------------- |
|
1234 // |
|
1235 TInt CSMS::DeactivateSMSRoutingL( CStifItemParser& ) |
|
1236 { |
|
1237 _LIT8(KDeactivateSMSRouting, "SMS::DeactivateSMSRouting"); |
|
1238 iSMSLog->Log((TDesC8)KDeactivateSMSRouting); |
|
1239 TInt ret (KErrNone); |
|
1240 |
|
1241 ret= HandleRequestL( EMmTsyDeactivateSmsRouting ); |
|
1242 |
|
1243 if ( KErrNone == ret ) |
|
1244 { |
|
1245 _LIT8(KResultOk, "Deactivate SMS routing ok" ); |
|
1246 iSMSLog->Log((TDesC8)KResultOk); |
|
1247 } |
|
1248 else |
|
1249 { |
|
1250 _LIT8(KResultFail, "Deactivate SMS routing fails: %d" ); |
|
1251 iSMSLog->Log((TDesC8)KResultFail, ret ); |
|
1252 } |
|
1253 |
|
1254 return ret; |
|
1255 } |
|
1256 |
|
1257 // ----------------------------------------------------------------------------- |
|
1258 // CSMS::CompleteDeactivateSMSRouting |
|
1259 // Complete Deactivate SMS Routing method function. |
|
1260 // ----------------------------------------------------------------------------- |
|
1261 // |
|
1262 void CSMS::CompleteDeactivateSMSRouting( TInt aResult ) //Completion result value |
|
1263 { |
|
1264 _LIT8(KResult, "Complete Deactivate SMS Routing result: %d" ); |
|
1265 iSMSLog->Log((TDesC8)KResult, aResult ); |
|
1266 |
|
1267 Signal( aResult ); |
|
1268 } |
|
1269 |
|
1270 // ----------------------------------------------------------------------------- |
|
1271 // CSMS::CompleteDeactivateSMSRouting |
|
1272 // Complete Deactivate SMS Routing method function. |
|
1273 // ----------------------------------------------------------------------------- |
|
1274 // |
|
1275 void CSMS::CompleteDeactivateSMSRouting( |
|
1276 TInt aResult, |
|
1277 CMmDataPackage* aDataPackage ) |
|
1278 { |
|
1279 _LIT8(KResult, "Complete Deactivate SMS Routing result: %d" ); |
|
1280 iSMSLog->Log((TDesC8)KResult, aResult ); |
|
1281 |
|
1282 TUint8 receptionStatus; |
|
1283 aDataPackage->UnPackData( receptionStatus ); |
|
1284 if ( SMS_RECEPTION_ACTIVE == receptionStatus ) |
|
1285 { |
|
1286 aResult = KErrGeneral; |
|
1287 } |
|
1288 |
|
1289 Signal( aResult ); |
|
1290 } |
|
1291 |
|
1292 // ----------------------------------------------------------------------------- |
|
1293 // CSMS::ResumeSMS |
|
1294 // Resume SMS |
|
1295 // (other items were commented in a header). |
|
1296 // ----------------------------------------------------------------------------- |
|
1297 // |
|
1298 TInt CSMS::ResumeSMSL( CStifItemParser& ) |
|
1299 { |
|
1300 _LIT8(KResumeSMS, "SMS::ResumeSMS"); |
|
1301 iSMSLog->Log((TDesC8)KResumeSMS); |
|
1302 TInt ret (KErrNone); |
|
1303 |
|
1304 ret= HandleRequestL( EMobileSmsMessagingResumeSmsReception ); |
|
1305 |
|
1306 if ( KErrNone == ret ) |
|
1307 { |
|
1308 _LIT8(KResultOk, "Resume SMS ok" ); |
|
1309 iSMSLog->Log((TDesC8)KResultOk); |
|
1310 } |
|
1311 else |
|
1312 { |
|
1313 _LIT8(KResultFail, "Resume SMS fails: %d" ); |
|
1314 iSMSLog->Log((TDesC8)KResultFail, ret ); |
|
1315 } |
|
1316 |
|
1317 return ret; |
|
1318 } |
|
1319 |
|
1320 // ----------------------------------------------------------------------------- |
|
1321 // CSMS::CompleteResumeSMS |
|
1322 // Complete Resume SMS method function. |
|
1323 // ----------------------------------------------------------------------------- |
|
1324 // |
|
1325 void CSMS::CompleteResumeSMS( TInt aResult ) //Completion result value |
|
1326 { |
|
1327 _LIT8(KResult, "Complete Resume SMS result: %d" ); |
|
1328 iSMSLog->Log((TDesC8)KResult, aResult ); |
|
1329 |
|
1330 Signal( aResult ); |
|
1331 } |
|
1332 |
|
1333 |
|
1334 // ----------------------------------------------------------------------------- |
|
1335 // CSMS::ReadAllSMSMessages |
|
1336 // Reading All SMS message for slot |
|
1337 // ----------------------------------------------------------------------------- |
|
1338 // |
|
1339 TInt CSMS::ReadAllSMSMessageL ( CStifItemParser& aItem ) |
|
1340 { |
|
1341 _LIT8(KReadAllSMSMessage, "SMS::ReadAllSMSMessage"); |
|
1342 iSMSLog->Log((TDesC8)KReadAllSMSMessage); |
|
1343 TInt ret (KErrNotFound); |
|
1344 TPtrC16 msgStatus; |
|
1345 TPtrC16 numberingPlan; |
|
1346 TPtrC16 typeOfNumber; |
|
1347 TPtrC serviceCentreAddress; |
|
1348 TPtrC16 isClass2; |
|
1349 TInt tpdu; |
|
1350 |
|
1351 aItem.GetNextString( msgStatus ); |
|
1352 |
|
1353 if ( msgStatus == ( _L("KSimSmsMtNotRead" ) ) ) |
|
1354 { |
|
1355 iSmsMsg.iMessageStatus = KSimSmsMtNotRead; |
|
1356 } |
|
1357 else if ( msgStatus == ( _L("KSimSmsMtRead" ) ) ) |
|
1358 { |
|
1359 iSmsMsg.iMessageStatus = KSimSmsMtRead; |
|
1360 } |
|
1361 else |
|
1362 { |
|
1363 iSmsMsg.iMessageStatus = KSimSmsNotPresent; |
|
1364 } |
|
1365 |
|
1366 aItem.GetNextString( numberingPlan ); |
|
1367 if ( numberingPlan == ( _L("EIsdnNumberPlan" ) ) ) |
|
1368 { |
|
1369 iSmsMsg.iMobileScNPI = RMobilePhone::EIsdnNumberPlan; |
|
1370 } |
|
1371 else |
|
1372 { |
|
1373 iSmsMsg.iMobileScNPI = RMobilePhone::EUnknownNumberingPlan; |
|
1374 } |
|
1375 |
|
1376 aItem.GetNextString( typeOfNumber ); |
|
1377 if ( typeOfNumber == ( _L( "EInternationalNumber" ) ) ) |
|
1378 { |
|
1379 iSmsMsg.iMobileScTON = RMobilePhone::EInternationalNumber; |
|
1380 } |
|
1381 else |
|
1382 { |
|
1383 iSmsMsg.iMobileScTON = RMobilePhone::EUnknownNumber; |
|
1384 } |
|
1385 |
|
1386 aItem.GetNextString( serviceCentreAddress ); |
|
1387 iSmsMsg.iServiceCentre = serviceCentreAddress; |
|
1388 |
|
1389 |
|
1390 iSmsMsg.iSmsClass2 = EFalse; |
|
1391 aItem.GetNextString( isClass2 ); |
|
1392 if ( isClass2 == ( _L( "CLASS2" ) ) ) |
|
1393 { |
|
1394 iSmsMsg.iSmsClass2 = ETrue; |
|
1395 } |
|
1396 |
|
1397 while ( !aItem.GetNextInt( tpdu ) ) |
|
1398 { |
|
1399 iSmsMsg.iSmsMsg.Append( tpdu ); |
|
1400 } |
|
1401 |
|
1402 ret= HandleRequestL( EMobilePhoneStoreReadAllPhase1 ); |
|
1403 |
|
1404 if ( KErrNotFound == ret ) |
|
1405 { |
|
1406 _LIT8( KOk, "Read All SMS Message ok: %d" ); |
|
1407 iSMSLog->Log((TDesC8)KOk ); |
|
1408 } |
|
1409 else |
|
1410 { |
|
1411 _LIT8( KFail, "Read All SMS Message fails: %d" ); |
|
1412 iSMSLog->Log((TDesC8)KFail, ret ); |
|
1413 } |
|
1414 |
|
1415 return ret; |
|
1416 } |
|
1417 |
|
1418 |
|
1419 // ----------------------------------------------------------------------------- |
|
1420 // CSMS::CompleteReadAllSMSMessage |
|
1421 // Complete ReadAllSMSMessage method function. |
|
1422 // ----------------------------------------------------------------------------- |
|
1423 // |
|
1424 void CSMS::CompleteReadAllSMSMessage( |
|
1425 TInt aResult, //Completion result value |
|
1426 CMmDataPackage* aDataPackage ) // pointer to DataPackage |
|
1427 { |
|
1428 // checking results and unpacking message |
|
1429 if ( KErrNone == aResult ) |
|
1430 { |
|
1431 TSmsMsg* smsMsg; |
|
1432 aDataPackage->UnPackData( iSmspListArray ); |
|
1433 TInt count ( iSmspListArray->Count() ); |
|
1434 |
|
1435 for ( TInt location( 0 ); location < count; location++ ) |
|
1436 { |
|
1437 smsMsg = (TSmsMsg *)iSmspListArray->At( location ); |
|
1438 |
|
1439 if ( ( smsMsg->iLocation != location + 1 ) || |
|
1440 ( smsMsg->iMessageStatus != iSmsMsg.iMessageStatus ) || |
|
1441 ( smsMsg->iMobileScNPI != iSmsMsg.iMobileScNPI ) || |
|
1442 ( smsMsg->iMobileScTON != iSmsMsg.iMobileScTON ) || |
|
1443 ( smsMsg->iServiceCentre != iSmsMsg.iServiceCentre ) || |
|
1444 ( smsMsg->iSmsMsg != iSmsMsg.iSmsMsg ) || |
|
1445 ( smsMsg->iSmsClass2 != iSmsMsg.iSmsClass2 ) ) |
|
1446 { |
|
1447 aResult = KErrGeneral; |
|
1448 break; |
|
1449 } |
|
1450 } |
|
1451 } |
|
1452 |
|
1453 if ( KErrNone == aResult ) |
|
1454 { |
|
1455 _LIT8( KOk, "Complete Read All SMS Message ok: %d" ); |
|
1456 iSMSLog->Log((TDesC8)KOk ); |
|
1457 } |
|
1458 else |
|
1459 { |
|
1460 _LIT8( KFail, "Compelte Read All SMS Message Failed: %d" ); |
|
1461 iSMSLog->Log((TDesC8)KFail, aResult ); |
|
1462 } |
|
1463 |
|
1464 Signal( aResult ); |
|
1465 } |
|
1466 |
|
1467 |
|
1468 // ----------------------------------------------------------------------------- |
|
1469 // CSMS::NackSMS |
|
1470 // Reject Receive SMS message |
|
1471 // (other items were commented in a header). |
|
1472 // ----------------------------------------------------------------------------- |
|
1473 // |
|
1474 TInt CSMS::NackSMSL( CStifItemParser& aItem ) |
|
1475 { |
|
1476 _LIT8(KNackSMS, "SMS::NackSMS"); |
|
1477 iSMSLog->Log((TDesC8)KNackSMS); |
|
1478 TInt ret (KErrNone); |
|
1479 TInt errorvalue; |
|
1480 |
|
1481 aItem.GetNextInt( errorvalue ); |
|
1482 |
|
1483 CMmDataPackage package; |
|
1484 |
|
1485 TDesC8 empty = KNullDesC8; |
|
1486 package.PackData( &empty, &errorvalue); |
|
1487 ret= HandleRequestL( EMobileSmsMessagingNackSmsStored, &package ); |
|
1488 |
|
1489 if ( KErrNone == ret ) |
|
1490 { |
|
1491 _LIT8(KResultOk, "Reject receive SMS ok" ); |
|
1492 iSMSLog->Log((TDesC8)KResultOk); |
|
1493 } |
|
1494 else |
|
1495 { |
|
1496 _LIT8(KResultFail, "Reject receive SMS fails: %d" ); |
|
1497 iSMSLog->Log((TDesC8)KResultFail, ret ); |
|
1498 } |
|
1499 |
|
1500 return ret; |
|
1501 } |
|
1502 |
|
1503 // ----------------------------------------------------------------------------- |
|
1504 // CSMS::CompleteNackSMS |
|
1505 // Complete NackSMS method function. |
|
1506 // ----------------------------------------------------------------------------- |
|
1507 // |
|
1508 void CSMS::CompleteNackSMS( TInt aResult ) //Completion result value |
|
1509 { |
|
1510 _LIT8(KResult, "Complete Reject receive SMS result: %d" ); |
|
1511 iSMSLog->Log((TDesC8)KResult, aResult ); |
|
1512 |
|
1513 Signal( aResult ); |
|
1514 } |
|
1515 |
|
1516 // ----------------------------------------------------------------------------- |
|
1517 // CSMS::SIMMsgStorageInfo |
|
1518 // Get SIM SMS Storage info |
|
1519 // ----------------------------------------------------------------------------- |
|
1520 // |
|
1521 TInt CSMS::SIMMsgStorageInfoL( CStifItemParser& /*aItem*/ ) |
|
1522 { |
|
1523 TInt ret (KErrGeneral); |
|
1524 |
|
1525 _LIT8(KSIMMsgStorageInfo, "SMS::SIMMsgStorageInfo request"); |
|
1526 iSMSLog->Log((TDesC8)KSIMMsgStorageInfo); |
|
1527 iSMSMsgStorageRequestOngoing = ETrue; |
|
1528 |
|
1529 ret = HandleRequestL( EMobileSmsMessagingGetMessageStoreInfo ); |
|
1530 |
|
1531 if ( KErrNone == ret ) |
|
1532 { |
|
1533 _LIT8( KSendOk, "request send ok" ); |
|
1534 iSMSLog->Log((TDesC8)KSendOk ); |
|
1535 } |
|
1536 else |
|
1537 { |
|
1538 _LIT8( KSendFailed, "request failed(Cache not ready): %d" ); //SMS cache not ready |
|
1539 iSMSLog->Log((TDesC8)KSendFailed, ret ); |
|
1540 } |
|
1541 |
|
1542 return ret; |
|
1543 } |
|
1544 |
|
1545 |
|
1546 // ----------------------------------------------------------------------------- |
|
1547 // CSIM::CompleteSIMMsgStorageInfo |
|
1548 // Complete SIMS SMS Storage Info |
|
1549 // ----------------------------------------------------------------------------- |
|
1550 // |
|
1551 void CSMS::CompleteSIMMsgStorageInfo( |
|
1552 TInt aResult, |
|
1553 CMmDataPackage* aDataPackage |
|
1554 ) |
|
1555 { |
|
1556 // If specified requests are handled the signal is always sent. |
|
1557 if ( !iHandleSpecifiedRequests ) |
|
1558 { |
|
1559 if( iSMSMsgStorageRequestOngoing ) |
|
1560 { |
|
1561 _LIT8( KResult, "CompleteSIMMsgStorageInfo result: %d" ); |
|
1562 iSMSLog->Log((TDesC8)KResult, aResult ); |
|
1563 |
|
1564 TUint8 numOfLoc; |
|
1565 TInt usedEntries; |
|
1566 |
|
1567 if( KErrNone == aResult ) |
|
1568 { |
|
1569 aDataPackage->UnPackData ( numOfLoc, usedEntries ); |
|
1570 _LIT8( KResult, "CompleteSIMMsgStorageInfo: Available locations: %d, Used entries: %d" ); |
|
1571 iSMSLog->Log((TDesC8)KResult, (TInt)numOfLoc, (TInt)usedEntries ); |
|
1572 } |
|
1573 else |
|
1574 { |
|
1575 _LIT8( KFail, "CompleteSIMMsgStorageInfo, error: %d" ); |
|
1576 iSMSLog->Log((TDesC8)KFail, aResult ); |
|
1577 } |
|
1578 iSMSMsgStorageRequestOngoing = EFalse; |
|
1579 Signal( aResult ); |
|
1580 } |
|
1581 else |
|
1582 { |
|
1583 _LIT8( KResult, "CompleteSIMMsgStorageInfo - not requested from script (in boot)" ); |
|
1584 iSMSLog->Log((TDesC8)KResult ); |
|
1585 } |
|
1586 } |
|
1587 else |
|
1588 { |
|
1589 _LIT8( KResult, "CompleteSIMMsgStorageInfo / iHandleSpecifiedRequests is set / result: %d" ); |
|
1590 iSMSLog->Log((TDesC8)KResult, aResult ); |
|
1591 |
|
1592 Signal( aResult ); |
|
1593 } |
|
1594 } |
|
1595 |
|
1596 // ----------------------------------------------------------------------------- |
|
1597 // CSMS::ReadSmsParameters |
|
1598 // Reads SMS Parameters from SIM. |
|
1599 // ----------------------------------------------------------------------------- |
|
1600 // |
|
1601 TInt CSMS::ReadSmsParametersL( CStifItemParser& /*aItem*/ ) |
|
1602 { |
|
1603 TInt ret ( KErrGeneral ); |
|
1604 |
|
1605 _LIT8(KReadSmsParameters, "SMS::ReadSmsParameters"); |
|
1606 iSMSLog->Log(KReadSmsParameters ); |
|
1607 |
|
1608 // no parameters |
|
1609 ret = HandleRequestL( EMobileSmsMessagingGetSmspListPhase1 ); |
|
1610 |
|
1611 if ( KErrNone == ret ) |
|
1612 { |
|
1613 _LIT8(KResultOk, "ReadSmsParameters ok" ); |
|
1614 iSMSLog->Log((TDesC8)KResultOk); |
|
1615 } |
|
1616 else |
|
1617 { |
|
1618 _LIT8(KResultFail, "ReadSmsParameters fails: %d" ); |
|
1619 iSMSLog->Log((TDesC8)KResultFail, ret ); |
|
1620 } |
|
1621 |
|
1622 return ret; |
|
1623 } |
|
1624 |
|
1625 // ----------------------------------------------------------------------------- |
|
1626 // CSMS::CompleteReadSmsParameters |
|
1627 // Completes ReadSmsParameters |
|
1628 // ----------------------------------------------------------------------------- |
|
1629 // |
|
1630 void CSMS::CompleteReadSmsParameters( |
|
1631 TInt aResult, //Completion result value |
|
1632 CMmDataPackage* aDataPackage )// SMS Parameters |
|
1633 { |
|
1634 if ( KErrNone == aResult ) |
|
1635 { |
|
1636 CArrayPtrFlat<TSmsParameters>* params; |
|
1637 aDataPackage->UnPackData( ¶ms ); |
|
1638 |
|
1639 TInt numOfSets = params->Count(); |
|
1640 _LIT8( KResultOk, "CSMS::CompleteReadSmsParameters: There are %d SMS parameter sets." ); |
|
1641 iSMSLog->Log((TDesC8)KResultOk, numOfSets ); |
|
1642 |
|
1643 /* SMS parameters, from cmmsmsutility.h |
|
1644 struct TSmsParameters |
|
1645 { |
|
1646 TUint8 iLocationNumber; |
|
1647 TUint8 iParameterIndicator; |
|
1648 TUint8 iProtocolId; |
|
1649 TUint8 iDataCodingScheme; |
|
1650 TUint8 iValidityPeriod; |
|
1651 TBuf<KMaxAddressBufferSize> iServiceCenterAddress; |
|
1652 RMobilePhone::TMobileTON iMobileScTON; |
|
1653 RMobilePhone::TMobileNPI iMobileScNPI; |
|
1654 TBuf<KMaxAddressBufferSize> iDestinationAddress; |
|
1655 RMobilePhone::TMobileTON iMobileDeTON; |
|
1656 RMobilePhone::TMobileNPI iMobileDeNPI; |
|
1657 TBuf<RMobileSmsMessaging::KMaxSmspTextSize> iAlphaTagData; |
|
1658 TBool iAlphaTagPresent; |
|
1659 }; |
|
1660 */ |
|
1661 for ( TInt i = 0; i < numOfSets; i++ ) |
|
1662 { |
|
1663 TSmsParameters* p = params->At( i ); |
|
1664 iSMSLog->Log( _L("SMS Parameter set %d:"), i); |
|
1665 iSMSLog->Log( _L(" parameter indicator = 0x%x"), p->iParameterIndicator ); |
|
1666 iSMSLog->Log( _L(" protocol id = 0x%x"), p->iProtocolId ); |
|
1667 iSMSLog->Log( _L(" data coding scheme = 0x%x"), p->iDataCodingScheme ); |
|
1668 iSMSLog->Log( _L(" validity period = 0x%x"), p->iValidityPeriod ); |
|
1669 iSMSLog->Log( _L(" service center address = %S"), &p->iServiceCenterAddress ); |
|
1670 iSMSLog->Log( _L(" destination address = %S"), &p->iDestinationAddress ); |
|
1671 iSMSLog->Log( _L(" alpha tag = %S"), &p->iAlphaTagData ); |
|
1672 |
|
1673 if ( iSmsParameterCheck && ETestCaseSms008 == iTestCaseNumber ) |
|
1674 { |
|
1675 TSmsParameters* refParams = iSmspListArray->At( i ); |
|
1676 |
|
1677 if ( ( p->iParameterIndicator != refParams->iParameterIndicator ) && |
|
1678 ( 0xff != refParams->iParameterIndicator ) ) |
|
1679 { |
|
1680 aResult = KErrGeneral; |
|
1681 } |
|
1682 if ( ( p->iProtocolId != refParams->iProtocolId ) && |
|
1683 ( 0xff != refParams->iProtocolId ) ) |
|
1684 { |
|
1685 aResult = KErrGeneral; |
|
1686 } |
|
1687 if ( ( p->iDataCodingScheme != refParams->iDataCodingScheme ) && |
|
1688 ( 0xff != refParams->iDataCodingScheme ) ) |
|
1689 { |
|
1690 aResult = KErrGeneral; |
|
1691 } |
|
1692 if ( ( p->iValidityPeriod != refParams->iValidityPeriod ) && |
|
1693 ( 0xff != refParams->iValidityPeriod ) ) |
|
1694 { |
|
1695 aResult = KErrGeneral; |
|
1696 } |
|
1697 if ( ( p->iServiceCenterAddress != refParams->iServiceCenterAddress ) && |
|
1698 ( 0 != refParams->iServiceCenterAddress.Compare( _L( "NA" ) ) ) ) |
|
1699 { |
|
1700 aResult = KErrGeneral; |
|
1701 } |
|
1702 if ( ( p->iDestinationAddress != refParams->iDestinationAddress ) && |
|
1703 ( 0 != refParams->iDestinationAddress.Compare( _L( "NA" ) ) ) ) |
|
1704 { |
|
1705 aResult = KErrGeneral; |
|
1706 } |
|
1707 if ( ( p->iAlphaTagData != refParams->iAlphaTagData ) && |
|
1708 ( 0 != refParams->iAlphaTagData.Compare( _L( "NA" ) ) ) ) |
|
1709 { |
|
1710 aResult = KErrGeneral; |
|
1711 } |
|
1712 } |
|
1713 } |
|
1714 iSMSLog->Log(_L8("CSMS::CompleteReadSmsParameters OK.")); |
|
1715 } |
|
1716 else |
|
1717 { |
|
1718 _LIT8( KResultFailed, "Complete ReadSmsParameters Failed: %d" ); |
|
1719 iSMSLog->Log((TDesC8)KResultFailed, aResult ); |
|
1720 } |
|
1721 |
|
1722 iTestCaseNumber = ETestCaseNotDefined; |
|
1723 Signal( aResult ); |
|
1724 } |
|
1725 |
|
1726 |
|
1727 // ----------------------------------------------------------------------------- |
|
1728 // CSMS::StoreSmsParameters |
|
1729 // Stores SMS parameters to SIM. Parameters from script: SIM slot, |
|
1730 // SC number, alpha tag. |
|
1731 // ----------------------------------------------------------------------------- |
|
1732 // |
|
1733 TInt CSMS::StoreSmsParametersL( CStifItemParser& aItem ) |
|
1734 { |
|
1735 TInt ret ( KErrGeneral ); |
|
1736 |
|
1737 _LIT8(KStoreSmsParameters, "SMS::StoreSmsParameters"); |
|
1738 iSMSLog->Log( KStoreSmsParameters ); |
|
1739 |
|
1740 /* SMS parameters, from etelmm.h |
|
1741 class TMobileSmspEntryV1 : public RMobilePhone::TMultimodeType |
|
1742 The slot index where this SMSP entry is stored in the SIM's SMSP file. |
|
1743 TInt iIndex; |
|
1744 A bit-wise sum of the constants defined in TMobileSmspStoreValidParams, that |
|
1745 specifies which parameters are valid within this entry. |
|
1746 TUint32 iValidParams; |
|
1747 Default protocol ID. Coded according to GSM 03.40. |
|
1748 TUint8 iProtocolId; |
|
1749 Default data coding scheme. Coded according to GSM 03.40. |
|
1750 TUint8 iDcs; |
|
1751 Default validity period, in relative format and coded on 8 bits as defined |
|
1752 by GSM 03.40. |
|
1753 TUint8 iValidityPeriod; |
|
1754 Reserved for future use. |
|
1755 TUint8 iReservedFiller; |
|
1756 Default destination for outgoing SMS. |
|
1757 RMobilePhone::TMobileAddress iDestination; |
|
1758 Default service centre for outgoing SMS. |
|
1759 RMobilePhone::TMobileAddress iServiceCentre; |
|
1760 The alpha-tag associated with this SMSP entry, expressed as Unicode characters. |
|
1761 TBuf<KMaxSmspTextSize> iText; |
|
1762 */ |
|
1763 RMobileSmsMessaging::TMobileSmspEntryV1 smspEntry; |
|
1764 aItem.GetNextInt(smspEntry.iIndex); // SIM location |
|
1765 |
|
1766 TPtrC smsc; // Number of SM Service Center |
|
1767 aItem.GetNextString(smsc); |
|
1768 smspEntry.iServiceCentre.iTelNumber = smsc; |
|
1769 smspEntry.iServiceCentre.iTypeOfNumber = RMobilePhone::EInternationalNumber; |
|
1770 smspEntry.iServiceCentre.iNumberPlan = RMobilePhone::EIsdnNumberPlan; |
|
1771 |
|
1772 TPtrC alphaTag; // Alpha tag |
|
1773 aItem.GetNextString( alphaTag ); |
|
1774 smspEntry.iText = alphaTag; |
|
1775 |
|
1776 smspEntry.iValidParams = RMobileSmsMessaging::KSCAIncluded; |
|
1777 |
|
1778 CMmDataPackage package; |
|
1779 package.PackData( &smspEntry ); |
|
1780 ret = HandleRequestL( EMobileSmsMessagingStoreSmspList, &package ); |
|
1781 |
|
1782 if ( KErrNone == ret ) |
|
1783 { |
|
1784 _LIT8(KResultOk, "StoreSmsParameters ok" ); |
|
1785 iSMSLog->Log((TDesC8)KResultOk); |
|
1786 } |
|
1787 else |
|
1788 { |
|
1789 _LIT8(KResultFail, "StoreSmsParameters fails: %d" ); |
|
1790 iSMSLog->Log((TDesC8)KResultFail, ret ); |
|
1791 } |
|
1792 |
|
1793 return ret; |
|
1794 } |
|
1795 |
|
1796 // ----------------------------------------------------------------------------- |
|
1797 // CSMS::CompleteStoreSmsParameters |
|
1798 // Completes StoreSmsParameters |
|
1799 // ----------------------------------------------------------------------------- |
|
1800 // |
|
1801 void CSMS::CompleteStoreSmsParameters( TInt aResult ) //Completion result value |
|
1802 { |
|
1803 if ( KErrNone == aResult ) |
|
1804 { |
|
1805 iSMSLog->Log(_L8("CSMS::Complete StoreSmsParameters OK.")); |
|
1806 } |
|
1807 else |
|
1808 { |
|
1809 _LIT8( KResultFailed, "Complete StoreSmsParameters Failed: %d" ); |
|
1810 iSMSLog->Log((TDesC8)KResultFailed, aResult ); |
|
1811 } |
|
1812 |
|
1813 Signal( aResult ); |
|
1814 } |
|
1815 |
|
1816 // ----------------------------------------------------------------------------- |
|
1817 // CSMS::SMSCacheInitialization |
|
1818 // SMS cache initialization |
|
1819 // ----------------------------------------------------------------------------- |
|
1820 // |
|
1821 TInt CSMS::SMSCacheInitializationL( CStifItemParser& /* aItem */ ) |
|
1822 { |
|
1823 TInt ret ( KErrGeneral ); |
|
1824 |
|
1825 _LIT8(KSMSCacheInitialization, "SMS::SMSCacheInitialization"); |
|
1826 iSMSLog->Log( KSMSCacheInitialization ); |
|
1827 ret = HandleRequestL( EMmTsyBootNotifySimStatusReadyIPC ); |
|
1828 |
|
1829 if ( KErrNone == ret ) |
|
1830 { |
|
1831 _LIT8(KResultOk, "SMSCacheInitialization OK" ); |
|
1832 iSMSLog->Log((TDesC8)KResultOk); |
|
1833 } |
|
1834 else |
|
1835 { |
|
1836 _LIT8(KResultFail, "SMSCacheInitialization fails: %d" ); |
|
1837 iSMSLog->Log((TDesC8)KResultFail, ret ); |
|
1838 } |
|
1839 |
|
1840 return ret; |
|
1841 } |
|
1842 |
|
1843 // ----------------------------------------------------------------------------- |
|
1844 // CSMS::CompleteSMSCacheInitialization |
|
1845 // Completes SMSCacheInitialization |
|
1846 // ----------------------------------------------------------------------------- |
|
1847 // |
|
1848 void CSMS::CompleteSMSCacheInitialization( TInt aResult ) //Completion result value |
|
1849 { |
|
1850 if ( KErrNone == aResult ) |
|
1851 { |
|
1852 iSMSLog->Log(_L8("CSMS::Complete SMSCacheInitializationL OK.")); |
|
1853 } |
|
1854 else |
|
1855 { |
|
1856 _LIT8( KResultFailed, "Complete SMSCacheInitializationL Failed: %d" ); |
|
1857 iSMSLog->Log((TDesC8)KResultFailed, aResult ); |
|
1858 } |
|
1859 |
|
1860 Signal( aResult ); |
|
1861 } |
|
1862 |
|
1863 // ----------------------------------------------------------------------------- |
|
1864 // CSMS::CompleteMobilePhoneStoreGetInfo |
|
1865 // Completes MobilePhoneStoreGetInfo |
|
1866 // ----------------------------------------------------------------------------- |
|
1867 // |
|
1868 void CSMS::CompleteMobilePhoneStoreGetInfo( TInt aResult ) //Completion result value |
|
1869 { |
|
1870 _LIT8( KResult, "Complete CompleteMobilePhoneStoreGetInfo: %d" ); |
|
1871 iSMSLog->Log((TDesC8)KResult, aResult ); |
|
1872 |
|
1873 Signal( aResult ); |
|
1874 } |
|
1875 |
|
1876 // ----------------------------------------------------------------------------- |
|
1877 // CSMS::GsmConvUnicodeTo0340Addr |
|
1878 // ----------------------------------------------------------------------------- |
|
1879 // |
|
1880 void CSMS::GsmConvUnicodeTo0340Addr( |
|
1881 TUint8 aTon, //Type of number |
|
1882 TUint8 aNpi, //Numbering plan identification |
|
1883 TDes8 &aDest, //Service center address |
|
1884 TDesC16 &aSource //Telephone number |
|
1885 ) |
|
1886 { |
|
1887 if ( aSource.Length() != 0 ) |
|
1888 { |
|
1889 GsmConvUnicodeToAddr( aTon, aNpi, aDest, aSource, ETrue ); |
|
1890 } |
|
1891 else |
|
1892 { |
|
1893 // Address length of 0 is a special case |
|
1894 aDest.Append( 0 ); |
|
1895 |
|
1896 // Type-of-Address: TON = Unknown, NPI = ISDN/telephone num plan |
|
1897 aDest.Append( 0x81 ); |
|
1898 } |
|
1899 } |
|
1900 |
|
1901 // ----------------------------------------------------------------------------- |
|
1902 // ::GsmConvUnicodeToAddr |
|
1903 // Converts type of number, numbering plan identification and |
|
1904 // phone number given in unicode string to the GSM 03.40 or |
|
1905 // 04.11 standard |
|
1906 // ----------------------------------------------------------------------------- |
|
1907 // |
|
1908 void CSMS::GsmConvUnicodeToAddr( |
|
1909 TUint8 aTon, //Type of number |
|
1910 TUint8 aNpi, //Numbering plan identification |
|
1911 TDes8 &aDest, //Service center address |
|
1912 TDesC16 &aSource, //Telephone number |
|
1913 TBool a0340Address //GSM 03.40 address |
|
1914 ) |
|
1915 { |
|
1916 //get address length |
|
1917 TUint numberLength = aSource.Length(); |
|
1918 TUint destLength = numberLength; |
|
1919 TUint i( 0 ); |
|
1920 |
|
1921 /* Solve type of address |
|
1922 Type of Address field format is as follows: |
|
1923 |
|
1924 7 6 5 4 3 2 1 0 bit |
|
1925 | | | | | | | | | |
|
1926 | 1 | Type of number | Numbering-plan-identification| |
|
1927 | | | | | | | | | |
|
1928 */ |
|
1929 |
|
1930 //type of number is three bits from left and fourth bit must be '1' |
|
1931 TUint8 typeOfNumber = TUint8( aTon | 0x08 ); |
|
1932 //move four bit to the left |
|
1933 typeOfNumber = TUint8( typeOfNumber << 4 ); |
|
1934 //numbering plan is four bits from left |
|
1935 TUint8 numberingPlan = TUint8( aNpi & 0x0F ); |
|
1936 //set type of number and numbering plan to the typeOfNumber variable |
|
1937 typeOfNumber = TUint8( typeOfNumber | numberingPlan ); |
|
1938 |
|
1939 if ( 5 == aTon ) //Alphanumeric |
|
1940 { |
|
1941 TBuf8<KMaxLengthOfAddressData> addressData; |
|
1942 TUint8 amountOfsemiOctets( 0 ); |
|
1943 |
|
1944 GsmUnicodeAddrToAlphanumericAddr( aSource, addressData, |
|
1945 amountOfsemiOctets ); |
|
1946 |
|
1947 //fill address length field |
|
1948 if ( a0340Address ) |
|
1949 { |
|
1950 //amount of used semi-octets in address data |
|
1951 aDest.Append( amountOfsemiOctets ); |
|
1952 } |
|
1953 else //0411 address |
|
1954 { |
|
1955 //Actually alphanumeric address data for 0411 address is not |
|
1956 //supported (see GSM 24.011 and 24.008)... |
|
1957 //Length of address data + length of address type field |
|
1958 aDest.Append( addressData.Length() + 1 ); |
|
1959 } |
|
1960 |
|
1961 //add typeOfNumber to the buffer |
|
1962 aDest.Append( typeOfNumber ); |
|
1963 |
|
1964 //add address data to the buffer |
|
1965 aDest.Insert( 2, addressData ); |
|
1966 } |
|
1967 else |
|
1968 { |
|
1969 //number can contain character '+' |
|
1970 if ( '+' == aSource[i] ) |
|
1971 { |
|
1972 i++; |
|
1973 destLength--; |
|
1974 |
|
1975 // Maximum amount of digits is 20 (3GPP TS 23.040) |
|
1976 if ( destLength > KMaxAmountOfDigits ) |
|
1977 { |
|
1978 destLength = KMaxAmountOfDigits; |
|
1979 numberLength = 21; |
|
1980 } |
|
1981 } |
|
1982 else |
|
1983 { |
|
1984 // Maximum amount of digits is 20 (3GPP TS 23.040) |
|
1985 if ( destLength > KMaxAmountOfDigits ) |
|
1986 { |
|
1987 destLength = KMaxAmountOfDigits; |
|
1988 numberLength = 20; |
|
1989 } |
|
1990 } |
|
1991 |
|
1992 // calculate address length in bytes |
|
1993 TUint bufferLength = ( destLength + 1 )/2 + 2; |
|
1994 |
|
1995 //set buffer length |
|
1996 aDest.SetLength( bufferLength ); |
|
1997 |
|
1998 //add length to the buffer |
|
1999 if ( a0340Address ) |
|
2000 { |
|
2001 //amount of used semi-octets in address data |
|
2002 aDest[0] = ( TUint8 )destLength; |
|
2003 } |
|
2004 else |
|
2005 { |
|
2006 //length of whole address data - length of address length field |
|
2007 aDest[0] = ( TUint8 )( bufferLength - 1 ); |
|
2008 } |
|
2009 |
|
2010 //add typeOfNumber to the buffer |
|
2011 aDest[1] = typeOfNumber; |
|
2012 |
|
2013 //needed variables |
|
2014 TUint8 numLsb( 0 ); |
|
2015 TUint8 numMsb( 0 ); |
|
2016 TUint index( 2 ); |
|
2017 |
|
2018 //add numbers to the buffer |
|
2019 for ( ; ( i+1 ) < numberLength ; i+=2 ) |
|
2020 { |
|
2021 numLsb = TUint8( aSource[i] - '0' ); |
|
2022 numMsb = TUint8( ( aSource[i+1] - '0' ) << 4 ); |
|
2023 |
|
2024 aDest[index++] = TUint8( numLsb | numMsb ); |
|
2025 } |
|
2026 |
|
2027 //if numberLength is odd, last number is fixed with 0xF0 |
|
2028 if ( i < numberLength ) |
|
2029 { |
|
2030 aDest[index] = TUint8( 0xF0 | ( aSource[i] - '0' ) ); |
|
2031 } |
|
2032 } |
|
2033 } |
|
2034 |
|
2035 // ----------------------------------------------------------------------------- |
|
2036 // CSMS::GsmConvAddrToUnicode |
|
2037 // Converts GSM 03.40 or 04.11 address to type of number, |
|
2038 // numbering plan identification and phone number given in |
|
2039 // unicode string |
|
2040 // ----------------------------------------------------------------------------- |
|
2041 // |
|
2042 void CSMS::GsmConvAddrToUnicode( |
|
2043 TDes &aDest, //Service center address |
|
2044 TDesC8 &aSource, //Telephone number |
|
2045 RMobilePhone::TMobileTON& aTon, //Type of number |
|
2046 RMobilePhone::TMobileNPI& aNpi, //Telephone number |
|
2047 TBool a0340Address //GSM 03.40 address |
|
2048 ) |
|
2049 { |
|
2050 TUint addrDataLength( 0 ); |
|
2051 TBool halfs = ETrue; |
|
2052 TUint index( 0 ); |
|
2053 TUint num2( 0 ); |
|
2054 |
|
2055 //Get amount of digits in address data |
|
2056 if ( a0340Address ) |
|
2057 { |
|
2058 addrDataLength = aSource[index]; |
|
2059 } |
|
2060 else //04.11 address |
|
2061 { |
|
2062 addrDataLength = 2 * ( aSource[index] - 1 ); |
|
2063 } |
|
2064 |
|
2065 // Check if there are too many digits |
|
2066 // Maximum amount of digits is 20 (3GPP TS 23.040) |
|
2067 if ( addrDataLength > KMaxAmountOfDigits ) |
|
2068 { |
|
2069 addrDataLength = KMaxAmountOfDigits; |
|
2070 } |
|
2071 |
|
2072 index++; |
|
2073 |
|
2074 // Lets take type of number field |
|
2075 TUint8 typeOfNum = aSource[index]; |
|
2076 GsmFindOutTonAndNpi( typeOfNum, &aTon, &aNpi ); |
|
2077 |
|
2078 if ( ( aTon == RMobilePhone::EAlphanumericNumber ) |
|
2079 && ( addrDataLength != 0x00 ) ) |
|
2080 { |
|
2081 //Calculate address length in bytes. If statement above check's that |
|
2082 //addrDataLength is not zero. |
|
2083 TUint addrDataLengthInBytes = ( addrDataLength + 1 ) / 2; |
|
2084 |
|
2085 //Get address data |
|
2086 TPtrC8 addressData = aSource.Mid( 2, addrDataLengthInBytes); |
|
2087 |
|
2088 //amountOfCharsInAddrData = amount of used bits / length of char |
|
2089 TUint amountOfCharsInAddrData = ( addrDataLength * 4 ) / 7; |
|
2090 |
|
2091 GsmAlphanumericAddrToUnicodeAddr( addressData, amountOfCharsInAddrData, |
|
2092 aDest ); |
|
2093 } |
|
2094 else |
|
2095 { |
|
2096 // Check if number is international number and addrDataLength is |
|
2097 // bigger than zero |
|
2098 if ( ( aTon == RMobilePhone::EInternationalNumber ) |
|
2099 && ( addrDataLength != 0x00 ) ) |
|
2100 { |
|
2101 aDest.Append( '+' ); |
|
2102 } |
|
2103 |
|
2104 index++; |
|
2105 |
|
2106 while ( addrDataLength-- ) |
|
2107 { |
|
2108 if ( halfs ) |
|
2109 { // Lets take only four bits from right |
|
2110 num2 = gsmSmsSemiOctetToChar( aSource[index] & 0x0F ); |
|
2111 aDest.Append( num2 ); |
|
2112 halfs = EFalse; |
|
2113 } |
|
2114 else |
|
2115 { |
|
2116 if ( ( ( aSource[index] >> 4 ) == 0x0F ) && !a0340Address ) |
|
2117 { |
|
2118 //If 04.11 address contains odd number of digits, |
|
2119 //bits 5 to 8 of the last octet shall be filled with an |
|
2120 //end mark coded as "1111". |
|
2121 break; |
|
2122 } |
|
2123 |
|
2124 halfs = ETrue; // Lets take only four bits from left |
|
2125 num2 = gsmSmsSemiOctetToChar( aSource[index] >> 4 ); |
|
2126 aDest.Append( num2 ); |
|
2127 index++; |
|
2128 } |
|
2129 } |
|
2130 } |
|
2131 } |
|
2132 |
|
2133 //----------------------------------------------------------------------------- |
|
2134 // CSMS::GsmLibCharConversion |
|
2135 // |
|
2136 // The character codes supported by the MS (the NMP character set) are |
|
2137 // not the same as 'defined in GSM 03.40. The former is 8-bit set and |
|
2138 // the latter is a 7-bit set. Therefore, the characters must be converted |
|
2139 // by using this function. However, characters having the same code in |
|
2140 // both sets are not converted. |
|
2141 // |
|
2142 // Note that all handset characters are not supported by the GSM 03.40. |
|
2143 // Such characters are converted to spaces or to the nearest substitute |
|
2144 // (generally the acute/grave marks are removed). |
|
2145 // Control characters and Japanese characters are converted to spaces. |
|
2146 // |
|
2147 // For the NMP character set, see "Nokia Character Set (Final version)", |
|
2148 // v1.0, in /user/cui2/. |
|
2149 |
|
2150 //----------------------------------------------------------------------------- |
|
2151 // |
|
2152 void CSMS::GsmLibCharConversion( |
|
2153 TUint aDirection, //directions |
|
2154 TDes8& aString, //string |
|
2155 TUint16 aLength ) //length |
|
2156 { |
|
2157 TUint16 j = 0; |
|
2158 TUint16 i = 0; |
|
2159 |
|
2160 TBuf8<180> aDestination; |
|
2161 |
|
2162 if ( aDirection == TKGsmLibConvertToNmpFormat ) |
|
2163 { |
|
2164 for ( i = 0; i < aLength; i++) |
|
2165 { |
|
2166 if ( aString[i] == 0xFF ) // This ends the string in SIM card |
|
2167 { |
|
2168 aDestination.Append( '\0' ); // This ends the string in |
|
2169 // NMP format |
|
2170 break; |
|
2171 } |
|
2172 |
|
2173 aString[i] &= 0x7F; // only 7 bits used in GSM character set |
|
2174 |
|
2175 //Conversion made using GSM 7 bit default alphabet extension |
|
2176 //table. |
|
2177 if ( ( aString[i] > 0x5A) && ( aString[i] < 0x5F ) || |
|
2178 ( aString[i] > 0x7A ) && ( aString[i] < 0x7F ) ) |
|
2179 { |
|
2180 for ( j = 0 ; j < TKGsmLibConvTableSize; j++ ) |
|
2181 { |
|
2182 if ( aString[i] == TKGsmExtensionConvTable[j]. |
|
2183 iHandsetChar ) |
|
2184 { |
|
2185 aDestination.Append( 0x1B );//extension table flag |
|
2186 aDestination.Append( |
|
2187 TKGsmExtensionConvTable[j].iSmsChar ); |
|
2188 break; |
|
2189 } |
|
2190 else if ( aString[i] == 0x20A0 ) //Euro |
|
2191 { |
|
2192 aDestination.Append( 0x65 ); |
|
2193 } |
|
2194 } // end of for loop |
|
2195 |
|
2196 } |
|
2197 |
|
2198 // Conversion could be done only taking out the most significant |
|
2199 // bit from Unicode characters between 0x25 - 0x5A or 0x61 - 0x7A. |
|
2200 // We should be used KGsmLibConvTable if it is outside that are |
|
2201 // or it is 0x40 ( @ ). |
|
2202 else if ( ( aString[i] < 0x20 ) |
|
2203 || ( ( aString[i] > 0x5A ) && ( aString[i] < 0x61 ) ) |
|
2204 || ( aString[i] > 0x7A ) |
|
2205 || ( aString[i] == 0x40 ) ) |
|
2206 { |
|
2207 |
|
2208 for ( j = 0 ; j < TKGsmLibBidirTableSize; j++ ) |
|
2209 { |
|
2210 if ( aString[i] == TKGsmLibConvTable[j].iSmsChar ) |
|
2211 { |
|
2212 aDestination.Append( |
|
2213 TKGsmLibConvTable[j].iHandsetChar ); |
|
2214 break; |
|
2215 } |
|
2216 } // end of for loop |
|
2217 } |
|
2218 else |
|
2219 { |
|
2220 aDestination.Append( aString[i] ); |
|
2221 } |
|
2222 } // end of for loop |
|
2223 |
|
2224 } |
|
2225 else // aDirection = KGsmLibConvertToGsmFormat |
|
2226 { |
|
2227 for ( i = 0; i < aLength; i++ ) |
|
2228 { |
|
2229 if ( aString[i] == '\0' ) // End of string in NMP format |
|
2230 { |
|
2231 aDestination.Append( 0xFF ); // End of string in SIM |
|
2232 } |
|
2233 |
|
2234 else if ( ( ( aString[i] < 0x10 ) && ( aString[i] != 0x0A ) |
|
2235 && ( aString[i] != 0x0D ) ) || |
|
2236 ( ( aString[i] > 0x7F ) && ( aString[i] < 0xC0 ) ) ) |
|
2237 { |
|
2238 // Convert to SPACE if control character or Japanese character |
|
2239 // NOTE (CR (0x0D) and LF (0x0A) are not converted. |
|
2240 aDestination.Append( 0x20 ); |
|
2241 } |
|
2242 else |
|
2243 { |
|
2244 //Conversion made using GSM 7 bit default alphabet extension |
|
2245 //table. |
|
2246 if ( ( aString[i] > 0x5A) && ( aString[i] < 0x5F ) || |
|
2247 ( aString[i] > 0x7A ) && ( aString[i] < 0x7F ) ) |
|
2248 |
|
2249 { |
|
2250 for ( j = 0 ; j < TKGsmLibConvTableSize; j++ ) |
|
2251 { |
|
2252 if ( aString[i] == TKGsmExtensionConvTable[j]. |
|
2253 iHandsetChar ) |
|
2254 { |
|
2255 aDestination.Append( 0x1B );// extension table flag |
|
2256 aDestination.Append( |
|
2257 TKGsmExtensionConvTable[j].iSmsChar ); |
|
2258 break; |
|
2259 } |
|
2260 else if ( aString[i] == 0x20A0 ) //Euro |
|
2261 { |
|
2262 aDestination.Append( 0x65 ); |
|
2263 } |
|
2264 } // end of for loop |
|
2265 } |
|
2266 |
|
2267 // Conversion could be done only taking out the most significant |
|
2268 // bit from Unicode characters between 0x25 - 0x5A or 0x61 - 0x7A. |
|
2269 // We should be used KGsmLibConvTable if it is outside that are |
|
2270 // or it is 0x40 ( @ ). |
|
2271 |
|
2272 else if ( ( aString[i] < 0x25 ) |
|
2273 || ( ( aString[i] > 0x5A ) && ( aString[i] < 0x61 ) ) |
|
2274 || ( aString[i] > 0x7A ) |
|
2275 || ( aString[i] == 0x40 ) ) |
|
2276 { |
|
2277 for ( j = 0; j < TKGsmLibConvTableSize; j++ ) |
|
2278 { |
|
2279 if ( aString[i] == TKGsmLibConvTable[j].iHandsetChar ) |
|
2280 { |
|
2281 aDestination.Append( |
|
2282 TKGsmLibConvTable[j].iSmsChar ); |
|
2283 break; |
|
2284 } |
|
2285 } // end of for loop |
|
2286 } |
|
2287 else |
|
2288 { |
|
2289 aDestination.Append( aString[i] ); |
|
2290 } |
|
2291 } // end of else |
|
2292 } // end of for loop |
|
2293 } // end of else |
|
2294 aString.Copy( aDestination ); |
|
2295 } |
|
2296 |
|
2297 |
|
2298 //----------------------------------------------------------------------------- |
|
2299 // CSMS::GsmLibSmsPackMessage |
|
2300 // This function packs a given text string consisting of 7-bit |
|
2301 // characters into 8 bit bytes in such a way that a 160-character |
|
2302 // message takes only 140 bytes of memory after the compression. |
|
2303 //----------------------------------------------------------------------------- |
|
2304 // |
|
2305 TUint16 CSMS::GsmLibSmsPackMessage( |
|
2306 TDes8 &aDest,//destination |
|
2307 TDes8 &aSrc, //source |
|
2308 TUint16 aByte_count ) //Byte counting |
|
2309 { |
|
2310 TUint16 si, di; // Indexes |
|
2311 TInt tmp_modulo; // Temporary; to improve efficiency |
|
2312 |
|
2313 // Reset the indexes. |
|
2314 si = 0; |
|
2315 di = 0; |
|
2316 tmp_modulo = di % 7; |
|
2317 |
|
2318 while ( si < aByte_count ) |
|
2319 { |
|
2320 // Is this the last character of the message |
|
2321 // If it is, just shift it to the right. Otherwise, |
|
2322 // fill the rest of the byte with the bits of the next source character. |
|
2323 |
|
2324 if ( si == (aByte_count - 1) ) |
|
2325 { |
|
2326 TUint num2 = (aSrc[si] >> tmp_modulo); |
|
2327 aDest.Append(num2); |
|
2328 } |
|
2329 else |
|
2330 { |
|
2331 TUint num2 = (aSrc[si] >> tmp_modulo) | |
|
2332 (aSrc[si + 1] << (7 - tmp_modulo)); |
|
2333 aDest.Append(num2); |
|
2334 } |
|
2335 |
|
2336 di++; |
|
2337 tmp_modulo = di % 7; |
|
2338 |
|
2339 // Check if the destination byte could take the entire source character. |
|
2340 // In that case, the source character does not have to be divided and |
|
2341 // the next source character can be taken. |
|
2342 |
|
2343 if ( tmp_modulo == 0) |
|
2344 { |
|
2345 si += 2; |
|
2346 } |
|
2347 else |
|
2348 { |
|
2349 si++; |
|
2350 } |
|
2351 } |
|
2352 |
|
2353 // Return the length of the coded message. |
|
2354 return( di ); |
|
2355 } |
|
2356 |
|
2357 // ----------------------------------------------------------------------------- |
|
2358 // CSMS::GsmUnicodeAddrToAlphanumericAddr |
|
2359 // Converts Unicode characters to GSM 7-bit bit Default Alphabet |
|
2360 // characters (Defined in GSM 23.038). Note that all Unicode characters |
|
2361 // are not supported by the GSM 7-bit bit Default Alphabet set. Such |
|
2362 // characters are converted to spaces or to the nearest substitute |
|
2363 // (generally the acute/grave marks are removed). Control characters and |
|
2364 // special characters are converted to spaces. This method supports GSM |
|
2365 // 7-bit bit Default Alphabet extension table |
|
2366 // mechanism. |
|
2367 |
|
2368 // After character conversion this method packs address data by calling |
|
2369 // GsmLibSmsPackMessage method*/ |
|
2370 // ----------------------------------------------------------------------------- |
|
2371 // |
|
2372 void CSMS::GsmUnicodeAddrToAlphanumericAddr( |
|
2373 TDesC16& aSource, // Source address data |
|
2374 TDes8& aDestination, // Destination data |
|
2375 TUint8& aAmountOfSemiOctets // Amount of semi-octets |
|
2376 ) |
|
2377 { |
|
2378 TUint16 j = 0; |
|
2379 TUint16 i = 0; |
|
2380 |
|
2381 TBuf8<RMobilePhone::KMaxMobileTelNumberSize> alphaChars; |
|
2382 for ( i = 0; i < aSource.Length(); i++ ) |
|
2383 { |
|
2384 if ( ( aSource[i] > 0x24 ) && ( aSource[i] < 0x5B ) && |
|
2385 ( aSource[i] != 0x40 ) || |
|
2386 ( aSource[i] > 0x60 ) && ( aSource[i] < 0x7B ) ) |
|
2387 { |
|
2388 // Conversion could be done only taking out the most significant |
|
2389 // bit from Unicode characters between 0x25 - 0x5A or 0x61 - 0x7A |
|
2390 // excluding '@' (0x40). |
|
2391 alphaChars.Append(aSource[i]); |
|
2392 } |
|
2393 else if ( ( aSource[i] > 0x5A) && ( aSource[i] < 0x5F ) || |
|
2394 ( aSource[i] > 0x7A ) && ( aSource[i] < 0x7F ) || |
|
2395 ( aSource[i] == 0x20AC ) ) |
|
2396 { |
|
2397 //Conversion made using GSM 7 bit default alphabet extension |
|
2398 //table. Characters: [,\,],^,{,|,},~,&euro |
|
2399 for ( j = 0 ; j < KGsmLibConvTableSize; j++ ) |
|
2400 { |
|
2401 if ( aSource[i] == KGsmExtensionConvTable[j].iUnicodeChar ) |
|
2402 { |
|
2403 alphaChars.Append( 0x1B );// extension table flag |
|
2404 alphaChars.Append( |
|
2405 KGsmExtensionConvTable[j].iGsmChar ); |
|
2406 break; |
|
2407 } |
|
2408 } // end of for loop |
|
2409 } |
|
2410 else |
|
2411 { |
|
2412 //Try to find character from conversion table. |
|
2413 TBool notFound( ETrue ); |
|
2414 for ( j = 0; j < KGsmLibConvTableSize; j++ ) |
|
2415 { |
|
2416 if ( aSource[i] == KGsmLibConvTable[j].iUnicodeChar ) |
|
2417 { |
|
2418 alphaChars.Append( |
|
2419 KGsmLibConvTable[j].iGsmChar ); |
|
2420 notFound = EFalse; |
|
2421 break; |
|
2422 } |
|
2423 } // end of for loop |
|
2424 |
|
2425 if( notFound ) |
|
2426 { |
|
2427 //Couldn't found similar character. Convert to SPACE. |
|
2428 alphaChars.Append( 0x20 ); |
|
2429 } |
|
2430 } |
|
2431 } |
|
2432 |
|
2433 TUint8 packedChars = GsmLibPackAlphanumericAddress |
|
2434 ( aDestination, alphaChars ); |
|
2435 |
|
2436 //How many unused bits packed address contains |
|
2437 TUint8 unusedBits = (TUint8)( ( aDestination.Length() * 8 ) - |
|
2438 ( packedChars * 7 ) ); |
|
2439 |
|
2440 //How many semi-octets is used in packed address. |
|
2441 if ( unusedBits >= 4 ) |
|
2442 { |
|
2443 //Last semi-octet doesn't contain address data |
|
2444 aAmountOfSemiOctets = (TUint8)( ( aDestination.Length() * 2 ) - 1 ); |
|
2445 } |
|
2446 else |
|
2447 { |
|
2448 //All semi-octets are used |
|
2449 aAmountOfSemiOctets = (TUint8)( aDestination.Length() * 2 ); |
|
2450 } |
|
2451 } |
|
2452 |
|
2453 // ----------------------------------------------------------------------------- |
|
2454 // CSMS::GsmFindOutTonAndNpi |
|
2455 // Converts type of number and numbering plan identification |
|
2456 // information from the type of address parameter to the |
|
2457 // RMobilePhone::TMobileTON and RMobilePhone::TMobileNPI format |
|
2458 // ----------------------------------------------------------------------------- |
|
2459 // |
|
2460 void CSMS::GsmFindOutTonAndNpi( |
|
2461 TUint8 typeOfAddress, //Type of address |
|
2462 RMobilePhone::TMobileTON* ton, //Type of number |
|
2463 RMobilePhone::TMobileNPI* npi //Numbering plan identification |
|
2464 ) |
|
2465 { |
|
2466 TUint8 numberingPlanIdentification = ( TUint8 )( typeOfAddress & 0x0F ); |
|
2467 TUint8 temp = ( TUint8 )( typeOfAddress >> 4 ); |
|
2468 TUint8 typeOfNumber = ( TUint8 )( temp & 0x07 ); |
|
2469 |
|
2470 switch ( typeOfNumber ) |
|
2471 { |
|
2472 case KInternationalNumber: |
|
2473 { |
|
2474 *ton = ( RMobilePhone::EInternationalNumber ); |
|
2475 break; |
|
2476 } |
|
2477 case KNationalNumber: |
|
2478 { |
|
2479 *ton = ( RMobilePhone::ENationalNumber ); |
|
2480 break; |
|
2481 } |
|
2482 case KNetworkSpecificNumber: |
|
2483 { |
|
2484 *ton = ( RMobilePhone::ENetworkSpecificNumber ); |
|
2485 break; |
|
2486 } |
|
2487 case KSubscriberNumber: |
|
2488 { |
|
2489 *ton = ( RMobilePhone::ESubscriberNumber ); |
|
2490 break; |
|
2491 } |
|
2492 case KAlphanumeric: |
|
2493 { |
|
2494 *ton = ( RMobilePhone::EAlphanumericNumber ); |
|
2495 break; |
|
2496 } |
|
2497 case KAbbreviatedNumber: |
|
2498 { |
|
2499 *ton = ( RMobilePhone::EAbbreviatedNumber ); |
|
2500 break; |
|
2501 } |
|
2502 default: |
|
2503 { |
|
2504 *ton = ( RMobilePhone::EUnknownNumber ); |
|
2505 break; |
|
2506 } |
|
2507 } |
|
2508 |
|
2509 switch ( numberingPlanIdentification ) |
|
2510 { |
|
2511 case KIsdnTelephoneNumPlan: |
|
2512 { |
|
2513 *npi = ( RMobilePhone::EIsdnNumberPlan ); |
|
2514 break; |
|
2515 } |
|
2516 case KDataNumPlan: |
|
2517 { |
|
2518 *npi = ( RMobilePhone::EDataNumberPlan ); |
|
2519 break; |
|
2520 } |
|
2521 case KTelexNumPlan: |
|
2522 { |
|
2523 *npi = ( RMobilePhone::ETelexNumberPlan ); |
|
2524 break; |
|
2525 } |
|
2526 case KServiceCentreSpecificPlan1: |
|
2527 { |
|
2528 *npi = ( RMobilePhone::EServiceCentreSpecificPlan1 ); |
|
2529 break; |
|
2530 } |
|
2531 case KServiceCentreSpecificPlan2: |
|
2532 { |
|
2533 *npi = ( RMobilePhone::EServiceCentreSpecificPlan2 ); |
|
2534 break; |
|
2535 } |
|
2536 case KNationalNumPlan: |
|
2537 { |
|
2538 *npi = ( RMobilePhone::ENationalNumberPlan ); |
|
2539 break; |
|
2540 } |
|
2541 case KPrivateNumPlan: |
|
2542 { |
|
2543 *npi = ( RMobilePhone::EPrivateNumberPlan ); |
|
2544 break; |
|
2545 } |
|
2546 case KErmesNumPlan: |
|
2547 { |
|
2548 *npi = ( RMobilePhone::EERMESNumberPlan ); |
|
2549 break; |
|
2550 } |
|
2551 default: |
|
2552 { |
|
2553 *npi = ( RMobilePhone::EUnknownNumberingPlan ); |
|
2554 break; |
|
2555 } |
|
2556 } |
|
2557 } |
|
2558 |
|
2559 // ----------------------------------------------------------------------------- |
|
2560 // CSMS::GsmAlphanumericAddrToUnicodeAddr |
|
2561 // This method first decodes a address data that has been |
|
2562 // coded using the algorithm described in GSM 03.40 annex 2 by calling |
|
2563 // GsmLibUnpackAlphanumericAddress method. After that this method |
|
2564 // converts GSM 7-bit default alphabet characters to Unicode format. |
|
2565 // This method supports GSM 7-bit bit Default Alphabet extension table |
|
2566 // mechanism |
|
2567 // ----------------------------------------------------------------------------- |
|
2568 // |
|
2569 void CSMS::GsmAlphanumericAddrToUnicodeAddr( |
|
2570 TDesC8& aSource, // Source address data |
|
2571 TUint& aAmountOfChars, // Amount of characters in address data |
|
2572 TDes16& aDestination // Destination data |
|
2573 ) |
|
2574 { |
|
2575 //Maximum length of address data is 10 bytes. These bytes can contain |
|
2576 //11 packed 7-bit characters. |
|
2577 TBuf8<(KMaxLengthOfAddressData + 1)> unpackedSrc; |
|
2578 GsmLibUnpackAlphanumericAddress(aSource, aAmountOfChars, unpackedSrc); |
|
2579 |
|
2580 TUint8 unpackedLength = (TUint8)unpackedSrc.Length(); |
|
2581 TUint8 j( 0 ); |
|
2582 TUint8 i( 0 ); |
|
2583 |
|
2584 for ( i = 0; i < unpackedLength; i++) |
|
2585 { |
|
2586 unpackedSrc[i] &= 0x7F; // only 7 bits used in GSM character set |
|
2587 |
|
2588 if ( ( unpackedSrc[i] > 0x24 ) && ( unpackedSrc[i] < 0x5B ) && |
|
2589 ( unpackedSrc[i] != 0x40 ) || |
|
2590 ( unpackedSrc[i] > 0x60 ) && ( unpackedSrc[i] < 0x7B ) ) |
|
2591 { |
|
2592 // Character codes in Unicode and GSM 7-bit default alphabet |
|
2593 // are same between 0x25 - 0x5A and 0x61 - 0x7A |
|
2594 // excluding 0x40. |
|
2595 aDestination.Append(unpackedSrc[i]); |
|
2596 } |
|
2597 else if ( unpackedSrc[i] == 0x1B ) |
|
2598 { |
|
2599 //0x1B is an escape code to the extension table. Code after escape |
|
2600 //code should been found from extension table. |
|
2601 |
|
2602 i++; |
|
2603 |
|
2604 //It is possible that extension table contains escape code to |
|
2605 //another extension table. Increase index i until we find something |
|
2606 //else than another escape code. |
|
2607 for (; i < unpackedLength; i++) |
|
2608 { |
|
2609 if ( unpackedSrc[i] != 0x1B ) |
|
2610 { |
|
2611 //Found something else than escape code. Let's convert |
|
2612 //character from extension table to Unicode character. |
|
2613 TBool notFound( ETrue ); |
|
2614 |
|
2615 for ( j = 0 ; j < KGsmExtensionConvTableSize; j++ ) |
|
2616 { |
|
2617 if ( unpackedSrc[i] == |
|
2618 KGsmExtensionConvTable[j].iGsmChar ) |
|
2619 { |
|
2620 aDestination.Append( |
|
2621 KGsmExtensionConvTable[j].iUnicodeChar ); |
|
2622 notFound = EFalse; |
|
2623 break; |
|
2624 } |
|
2625 } |
|
2626 |
|
2627 if ( notFound ) |
|
2628 { |
|
2629 //Couldn't find character from extension table. |
|
2630 //Convert to SPACE. |
|
2631 aDestination.Append( 0x20 ); |
|
2632 } |
|
2633 |
|
2634 break; |
|
2635 } |
|
2636 else |
|
2637 { |
|
2638 //Found escape code to another to another extension table. |
|
2639 //On receipt of this code, a receiving entity shall display |
|
2640 //a space until another extension table is defined. |
|
2641 aDestination.Append( 0x20 ); |
|
2642 } |
|
2643 } // end of for loop |
|
2644 } // end of else if |
|
2645 else |
|
2646 { |
|
2647 //Find character from conversion table. |
|
2648 for ( j = 0; j < KGsmLibConvTableSize; j++ ) |
|
2649 { |
|
2650 if ( unpackedSrc[i] == KGsmLibConvTable[j].iGsmChar ) |
|
2651 { |
|
2652 aDestination.Append( |
|
2653 KGsmLibConvTable[j].iUnicodeChar ); |
|
2654 break; |
|
2655 } |
|
2656 } // end of for loop |
|
2657 } // end of else |
|
2658 } // end of for loop |
|
2659 } |
|
2660 |
|
2661 // ----------------------------------------------------------------------------- |
|
2662 // CSMS::GsmLibPackAlphanumericAddress |
|
2663 // This function packs a given text string consisting of 7-bit |
|
2664 // characters into 8 bit bytes in such a way that a 11-character |
|
2665 // address takes only 10 bytes of memory after the compression |
|
2666 // ----------------------------------------------------------------------------- |
|
2667 // |
|
2668 TUint8 CSMS::GsmLibPackAlphanumericAddress( |
|
2669 TDes8 &aDest, // Packed address |
|
2670 TDes8 &aSource // Unpacked address |
|
2671 ) |
|
2672 { |
|
2673 TUint8 si( 0 ); |
|
2674 TUint8 di( 0 ); |
|
2675 TUint tempModulo; |
|
2676 |
|
2677 // Set tempModulo and byteCount |
|
2678 tempModulo = di % 7; |
|
2679 TUint8 byteCount = (TUint8)aSource.Length(); |
|
2680 |
|
2681 // Maximum length of address data field is 10 bytes. 10 bytes can contain |
|
2682 // 11 compressed 7-bit characters. Because of this maximum |
|
2683 // amount of characters in alphanumeric address is 11. |
|
2684 if ( byteCount > ( KMaxLengthOfAddressData + 1 ) ) |
|
2685 { |
|
2686 byteCount = KMaxLengthOfAddressData + 1; |
|
2687 } |
|
2688 |
|
2689 while ( si < byteCount ) |
|
2690 { |
|
2691 // Is this the last character of the message |
|
2692 // If it is, just shift it to the right. Otherwise, |
|
2693 // fill the rest of the byte with the bits of the next |
|
2694 // source character. |
|
2695 |
|
2696 if ( si == (byteCount - 1) ) |
|
2697 { |
|
2698 TUint num2 = ( aSource[si] >> tempModulo ); |
|
2699 aDest.Append( num2 ); |
|
2700 } |
|
2701 else |
|
2702 { |
|
2703 TUint num2 = ( aSource[si] >> tempModulo ) | |
|
2704 ( aSource[si + 1] << ( 7 - tempModulo ) ); |
|
2705 aDest.Append( num2 ); |
|
2706 } |
|
2707 |
|
2708 di++; |
|
2709 tempModulo = di % 7; |
|
2710 |
|
2711 // Check if the destination byte could take the entire source character. |
|
2712 // In that case, the source character does not have to be divided and |
|
2713 // the next source character can be taken. |
|
2714 |
|
2715 if ( tempModulo == 0) |
|
2716 { |
|
2717 si += 2; |
|
2718 } |
|
2719 else |
|
2720 { |
|
2721 si++; |
|
2722 } |
|
2723 } |
|
2724 |
|
2725 // Return the length of the coded message. |
|
2726 return byteCount; |
|
2727 } |
|
2728 |
|
2729 // ----------------------------------------------------------------------------- |
|
2730 // CSMS::GsmLibUnpackAlphanumericAddress |
|
2731 // This function decodes a address that has been coded using |
|
2732 // the algorithm described in GSM 03.40 annex 2. The result string will |
|
2733 // consist of bytes that contain a 7-bit character each |
|
2734 // ----------------------------------------------------------------------------- |
|
2735 // |
|
2736 void CSMS::GsmLibUnpackAlphanumericAddress( |
|
2737 TDesC8 &aSource, // Packed address data |
|
2738 TUint aAmountOfChars, // Amount of characters in address data |
|
2739 TDes8 &aDest // Unpacked address data |
|
2740 ) |
|
2741 { |
|
2742 TUint8 di( 0 ); |
|
2743 TUint8 si( 0 ); |
|
2744 TUint tempModulo; |
|
2745 |
|
2746 // Maximum length of address data field is 10 bytes. 10 bytes can contain |
|
2747 // 11 compressed 7-bit characters. Because of this maximum |
|
2748 // amount of characters in alphanumeric address is 11. |
|
2749 if ( aAmountOfChars > ( KMaxLengthOfAddressData + 1 ) ) |
|
2750 { |
|
2751 aAmountOfChars = KMaxLengthOfAddressData + 1; |
|
2752 } |
|
2753 |
|
2754 // The location of the current 7-bit character determines the |
|
2755 // action to be taken. Only every 7th character is not divided into |
|
2756 // two bytes. All other characters will have to be contructed by |
|
2757 // combining bits of two consequent bytes. |
|
2758 |
|
2759 for ( di = 0; di < aAmountOfChars; di++ ) |
|
2760 { |
|
2761 TUint num2 = 0; |
|
2762 tempModulo = di % 8; |
|
2763 switch ( tempModulo ) |
|
2764 { |
|
2765 case 0: |
|
2766 num2 = aSource[si] & 0x7F; |
|
2767 break; |
|
2768 case 7: |
|
2769 num2 = ( aSource[si] >> 1 ) & 0x7F; |
|
2770 si++; |
|
2771 break; |
|
2772 default: |
|
2773 num2 = aSource[si] >> ( 8 - tempModulo ); |
|
2774 num2 &= KGsmLibSmsUnpackMaskTable[ tempModulo ]; |
|
2775 num2 |= aSource[si+1] << ( tempModulo ); |
|
2776 num2 &= 0x7F; |
|
2777 si++; |
|
2778 break; |
|
2779 } |
|
2780 aDest.Append( num2 ); |
|
2781 } |
|
2782 } |
|
2783 |
|
2784 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
2785 // None |
|
2786 |
|
2787 // End of File |
|