24
|
1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// Name : CSatDataDownloadTsy.cpp
|
|
15 |
// Part of : Common SIM ATK TSY / commonsimatktsy
|
|
16 |
// DataDownload-related functionality of Sat Tsy
|
|
17 |
// Version : 1.0
|
|
18 |
//
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
#include <satcs.h> // Etel SAT IPC definitions
|
|
23 |
#include <etelmm.h> // Etel MM Definitions
|
|
24 |
#include "CSatDataPackage.h" // Parameter packing
|
|
25 |
#include "CSatDataDownloadTsy.h" // Class header
|
|
26 |
#include "CSatTsy.h" // Sat Tsy class
|
|
27 |
#include "TSatUtility.h" // Utilities
|
|
28 |
#include "cmmmessagemanagerbase.h" // Message manager class for forwarding req.
|
|
29 |
#include "TfLogger.h" // For TFLOGSTRING
|
|
30 |
#include "CBerTlv.h" // Ber Tlv
|
|
31 |
#include "TTlv.h" // TTlv class
|
|
32 |
#include "MSatTsy_IPCDefs.h" // Sat Tsy internal request types
|
|
33 |
|
|
34 |
// -----------------------------------------------------------------------------
|
|
35 |
// CSatDataDownloadTsy::NewL
|
|
36 |
// Two-phased constructor.
|
|
37 |
// -----------------------------------------------------------------------------
|
|
38 |
//
|
|
39 |
CSatDataDownloadTsy* CSatDataDownloadTsy::NewL
|
|
40 |
(
|
|
41 |
CSatTsy* aSatTsy
|
|
42 |
)
|
|
43 |
{
|
|
44 |
TFLOGSTRING( "CSAT: CSatDataDownloadTsy::NewL" );
|
|
45 |
CSatDataDownloadTsy* const satDataDownloadTsy =
|
|
46 |
new ( ELeave ) CSatDataDownloadTsy();
|
|
47 |
CleanupStack::PushL( satDataDownloadTsy );
|
|
48 |
satDataDownloadTsy->iSatTsy = aSatTsy;
|
|
49 |
satDataDownloadTsy->ConstructL();
|
|
50 |
CleanupStack::Pop( satDataDownloadTsy );
|
|
51 |
TFLOGSTRING( "CSAT: CSatDataDownloadTsy::NewL, end of method" );
|
|
52 |
return satDataDownloadTsy;
|
|
53 |
}
|
|
54 |
|
|
55 |
// -----------------------------------------------------------------------------
|
|
56 |
// CSatDataDownloadTsy::~CSatDataDownloadTsy
|
|
57 |
// Destructor
|
|
58 |
// -----------------------------------------------------------------------------
|
|
59 |
//
|
|
60 |
CSatDataDownloadTsy::~CSatDataDownloadTsy
|
|
61 |
(
|
|
62 |
void
|
|
63 |
)
|
|
64 |
{
|
|
65 |
TFLOGSTRING( "CSAT: CSatDataDownloadTsy::~CSatDataDownloadTsy" );
|
|
66 |
// Unregister
|
|
67 |
iSatTsy->MessageManager()->RegisterTsyObject(
|
|
68 |
CMmMessageManagerBase::ESatDataDownloadTsyObjType, NULL );
|
|
69 |
}
|
|
70 |
|
|
71 |
// -----------------------------------------------------------------------------
|
|
72 |
// CSatDataDownloadTsy::CSatDataDownloadTsy
|
|
73 |
// C++ constructor
|
|
74 |
// -----------------------------------------------------------------------------
|
|
75 |
//
|
|
76 |
CSatDataDownloadTsy::CSatDataDownloadTsy
|
|
77 |
(
|
|
78 |
void
|
|
79 |
)
|
|
80 |
{
|
|
81 |
// None
|
|
82 |
}
|
|
83 |
|
|
84 |
// -----------------------------------------------------------------------------
|
|
85 |
// CSatDataDownloadTsy::ConstructL
|
|
86 |
// Symbian 2nd phase constructor. Initialises internal attributes.
|
|
87 |
// -----------------------------------------------------------------------------
|
|
88 |
//
|
|
89 |
void CSatDataDownloadTsy::ConstructL
|
|
90 |
(
|
|
91 |
void
|
|
92 |
)
|
|
93 |
{
|
|
94 |
TFLOGSTRING( "CSAT: CSatDataDownloadTsy::ConstructL" );
|
|
95 |
// Register
|
|
96 |
iSatTsy->MessageManager()->RegisterTsyObject(
|
|
97 |
CMmMessageManagerBase::ESatDataDownloadTsyObjType, this );
|
|
98 |
// Initialize as not supported
|
|
99 |
iIsSmsPpDdlSupported = EFalse;
|
|
100 |
}
|
|
101 |
|
|
102 |
// -----------------------------------------------------------------------------
|
|
103 |
// CSatDataDownloadTsy::CompleteCellBroadcastDdlL
|
|
104 |
// Prepare the envelope to be sent to DOS after a Cell
|
|
105 |
// Broadcast message has been received, without request, by the mobile equipment.
|
|
106 |
// -----------------------------------------------------------------------------
|
|
107 |
//
|
|
108 |
void CSatDataDownloadTsy::CompleteCellBroadcastDdlL
|
|
109 |
(
|
|
110 |
const CSatDataPackage* aDataPackage
|
|
111 |
)
|
|
112 |
{
|
|
113 |
TFLOGSTRING( "CSAT:CSatDataDownloadTsy::CompleteCellBroadcastDdlL" );
|
|
114 |
|
|
115 |
TBuf8<KCbsMsgMaxLength> aPdu;
|
|
116 |
aDataPackage->UnPackData( aPdu );
|
|
117 |
TTlv envelope;
|
|
118 |
// Tag
|
|
119 |
envelope.Begin( KBerTlvCellBroadcastTag );
|
|
120 |
// Device identities
|
|
121 |
envelope.AddTag( KTlvDeviceIdentityTag );
|
|
122 |
envelope.AddByte( KNetwork );
|
|
123 |
envelope.AddByte( KSim );
|
|
124 |
// Cell broadcast page
|
|
125 |
envelope.AddTag( KTlvCellBroadcastPageTag );
|
|
126 |
envelope.AddData( aPdu );
|
|
127 |
// Prepare data
|
|
128 |
TPtrC8 data = envelope.End();
|
|
129 |
// Pack data
|
|
130 |
CSatDataPackage dataPackage;
|
|
131 |
dataPackage.PackData( &data );
|
|
132 |
// Forward request to the DOS
|
|
133 |
iSatTsy->MessageManager()->HandleRequestL(
|
|
134 |
ESatTsyCellBroadcast, &dataPackage ) ;
|
|
135 |
}
|
|
136 |
|
|
137 |
// -----------------------------------------------------------------------------
|
|
138 |
// CSatDataDownloadTsy::CompleteSmsPpDdlL
|
|
139 |
// Completes the SMS-PP by sending the envelope if SMS-PP is supported.
|
|
140 |
// Otherwise requests saving of the SMS to EFsms (only class 2 sms)
|
|
141 |
// 3GPP TS 11.14, 7 Data download to SIM: If the service "data download via SMS
|
|
142 |
// Point-to-point" is allocated and activated in the SIM Service Table, the ME
|
|
143 |
// shall pass the message transparently to the SIM using the ENVELOPE. If the
|
|
144 |
// service "data download via SMS-PP" is not allocated and activated in the SIM
|
|
145 |
// Service Table, and the ME receives a Short Message with the protocol
|
|
146 |
// identifier = SIM data download and data coding scheme = class 2 message,
|
|
147 |
// then the ME shall store the message in EFSMS in accordance with TS 11.11.
|
|
148 |
// -----------------------------------------------------------------------------
|
|
149 |
//
|
|
150 |
void CSatDataDownloadTsy::CompleteSmsPpDdlL
|
|
151 |
(
|
|
152 |
const CSatDataPackage* aDataPackage
|
|
153 |
)
|
|
154 |
{
|
|
155 |
TFLOGSTRING( "CSAT:CSatDataDownloadTsy::CompleteSmsPpDdlL" );
|
|
156 |
TBuf8<KAddrMaxLength> smsScAddress;
|
|
157 |
TBuf8<RMobileSmsMessaging::KGsmTpduSize> smsTpdu;
|
|
158 |
|
|
159 |
// Unpack data
|
|
160 |
aDataPackage->UnPackData( smsScAddress, smsTpdu );
|
|
161 |
|
|
162 |
// Check if SMS PP Data Download is supported in NAA, then send envelope
|
|
163 |
if ( iIsSmsPpDdlSupported )
|
|
164 |
{
|
|
165 |
CreateSmsPpDdlEnvelopeL( smsScAddress, smsTpdu );
|
|
166 |
}
|
|
167 |
// Otherwise parse TPDU data and check if SMS must be saved
|
|
168 |
else
|
|
169 |
{
|
|
170 |
// Check if the SMS should be saved to EFsms (see method descr.)
|
|
171 |
if ( KErrNone == ParseSmsTpdu( smsTpdu ) &&
|
|
172 |
KSmsTpduProtcolIdUSimDdl == iSmsTpdu.iProtocolId &&
|
|
173 |
( !( iSmsTpdu.iDcs & 0x01 ) ) && ( iSmsTpdu.iDcs & 0x02 ) )
|
|
174 |
{
|
|
175 |
TFLOGSTRING( "CSAT:CSatDataDownloadTsy::CompleteSmsPpDdlL,\
|
|
176 |
SMS PP DDL is not supported, Store SMS to EFsms" );
|
|
177 |
CreateEntryForSavingSmsL( smsScAddress, smsTpdu );
|
|
178 |
}
|
|
179 |
}
|
|
180 |
}
|
|
181 |
|
|
182 |
// -----------------------------------------------------------------------------
|
|
183 |
// CSatDataDownloadTsy::CreateEntryForSavingSmsL
|
|
184 |
// Creates the TMobileGsmSmsEntryV1Pckg and makes a request to DOS to save the
|
|
185 |
// SMS to EFsms
|
|
186 |
// -----------------------------------------------------------------------------
|
|
187 |
//
|
|
188 |
void CSatDataDownloadTsy::CreateEntryForSavingSmsL
|
|
189 |
(
|
|
190 |
const TDesC8& aSmsScAddress,
|
|
191 |
const TDesC8& aSmsTpdu
|
|
192 |
)
|
|
193 |
{
|
|
194 |
TFLOGSTRING2( "CSAT:CSatDataDownloadTsy::CreateEntryForSavingSms\
|
|
195 |
SC Addr. length: %d", aSmsScAddress.Length() );
|
|
196 |
TInt offset = 0;
|
|
197 |
|
|
198 |
// Check that the SC address length contains the length in
|
|
199 |
// addition to the address.
|
|
200 |
if ( ( aSmsScAddress[offset] + 1 ) == aSmsScAddress.Length() )
|
|
201 |
{
|
|
202 |
RMobileSmsStore::TMobileGsmSmsEntryV1 smsEntry;
|
|
203 |
RMobileSmsStore::TMobileGsmSmsEntryV1Pckg smsEntryPckg( smsEntry );
|
|
204 |
|
|
205 |
// Set the Type of number: bits 6,5,4
|
|
206 |
smsEntry.iServiceCentre.iTypeOfNumber =
|
|
207 |
static_cast<RMobilePhone::TMobileTON>(
|
|
208 |
( aSmsScAddress[++offset] >> 4 ) & 0x07 );
|
|
209 |
// Set the Numbering plan identification: bits 3,2,1,0
|
|
210 |
smsEntry.iServiceCentre.iNumberPlan =
|
|
211 |
static_cast<RMobilePhone::TMobileNPI>(
|
|
212 |
aSmsScAddress[offset] & 0x0F );
|
|
213 |
|
|
214 |
// Set data
|
|
215 |
TBuf8<RSat::KMaxMobileTelNumberSize> scAddress;
|
|
216 |
TBuf16<RSat::KMaxMobileTelNumberSize> scAddress16;
|
|
217 |
|
|
218 |
// First convert the number to ASCII
|
|
219 |
TSatUtility::BCDToAscii( aSmsScAddress.Mid( ++offset ), scAddress );
|
|
220 |
|
|
221 |
// Then set the 8 bit data to 16 bit data buffer
|
|
222 |
for ( TInt i = 0; i < scAddress.Length(); i++ )
|
|
223 |
{
|
|
224 |
scAddress16.Append( static_cast<TUint16>(
|
|
225 |
scAddress[i] ) );
|
|
226 |
}
|
|
227 |
|
|
228 |
// Copy the Service Centre address and TPDU data
|
|
229 |
smsEntry.iServiceCentre.iTelNumber.Copy( scAddress16 );
|
|
230 |
|
|
231 |
TFLOGSTRING2("CSAT:CSatDataDownloadTsy::CreateEntryForSavingSms,\
|
|
232 |
iTelNumber: %S", &smsEntry.iServiceCentre.iTelNumber );
|
|
233 |
|
|
234 |
smsEntry.iMsgData.Copy( aSmsTpdu );
|
|
235 |
|
|
236 |
// We set the index to point -1, since it means we use the 1st free
|
|
237 |
// slot. See Etel MM API Specification, 8.1.4 Write Entry.
|
|
238 |
smsEntry.iIndex = -1;
|
|
239 |
|
|
240 |
// Pack data and forward request to DOS
|
|
241 |
TDesC8* data = reinterpret_cast<TDesC8*>( &smsEntryPckg );
|
|
242 |
CMmDataPackage package;
|
|
243 |
package.PackData( &data, &smsEntry.iIndex );
|
|
244 |
iSatTsy->MessageManager()->HandleRequestL( EMobilePhoneStoreWrite,
|
|
245 |
&package );
|
|
246 |
}
|
|
247 |
}
|
|
248 |
|
|
249 |
// -----------------------------------------------------------------------------
|
|
250 |
// CSatDataDownloadTsy::CreateSmsDeliverReportL
|
|
251 |
// Completes the writing of the SMS to EFsms by creating the resulting report
|
|
252 |
// (see 3GPP TS 23.040, 9.2.2.1a). See also 3GPP TS 23.038 "When a mobile
|
|
253 |
// terminated message is Class 2 ((U)SIM-specific), an MS shall ensure that
|
|
254 |
// the message has been transferred to the SMS data field in the (U)SIM before
|
|
255 |
// sending an acknowledgement to the SC"
|
|
256 |
// -----------------------------------------------------------------------------
|
|
257 |
//
|
|
258 |
void CSatDataDownloadTsy::CreateSmsDeliverReportL
|
|
259 |
(
|
|
260 |
TInt aResult
|
|
261 |
)
|
|
262 |
{
|
|
263 |
TFLOGSTRING("CSAT: CSatDataDownloadTsy::CreateSmsDeliverReportL");
|
|
264 |
TBuf8<KTpduMaxSize> reportData;
|
|
265 |
|
|
266 |
// Get User Data length
|
|
267 |
TUint8 userDataLength = iSmsTpdu.iUserData.Length();
|
|
268 |
|
|
269 |
// Check that SMS TPDU data exists by checking the last mandatory item
|
|
270 |
if ( KSmsTpduByteUnknownOrReserved != iSmsTpdu.iDcs )
|
|
271 |
{
|
|
272 |
TFLOGSTRING("CSAT: CSatDataDownloadTsy::CreateSmsDeliverReportL,\
|
|
273 |
SMS TPDU OK");
|
|
274 |
reportData.Zero();
|
|
275 |
reportData.Append( iSmsTpdu.iParameters ); // 1st byte -> parameters
|
|
276 |
reportData.Append( KAllOptParamsPresent ); // TP-Parameter-Indicator
|
|
277 |
reportData.Append( iSmsTpdu.iProtocolId ); // TP-Protocol-Identifier
|
|
278 |
reportData.Append( iSmsTpdu.iDcs ); // TP-Data-Coding-Scheme
|
|
279 |
reportData.Append( userDataLength ); // TP-User-Data-Length
|
|
280 |
|
|
281 |
// If user data exists, add it to the end of buffer
|
|
282 |
if ( userDataLength )
|
|
283 |
{
|
|
284 |
reportData.Append( iSmsTpdu.iUserData );
|
|
285 |
}
|
|
286 |
|
|
287 |
// If saving went OK it means that RP-ACK must to be sent and data is
|
|
288 |
// ready, otherwise RP-ERROR must to be sent, which means that TP Failure
|
|
289 |
// Cause must be inserted after the parameters
|
|
290 |
if ( KErrNone != aResult )
|
|
291 |
{
|
|
292 |
TFLOGSTRING("CSAT: CSatDataDownloadTsy::CreateSmsDeliverReportL,\
|
|
293 |
Add TP Failure Cause: KDataDownloadError");
|
|
294 |
TBuf8<1> failureCause;
|
|
295 |
failureCause.Zero();
|
|
296 |
failureCause.Append( KDataDownloadError );
|
|
297 |
reportData.Insert( 1, failureCause );
|
|
298 |
}
|
|
299 |
|
|
300 |
// Pack data and forward request to DOS
|
|
301 |
CMmDataPackage package;
|
|
302 |
package.PackData( &reportData );
|
|
303 |
iSatTsy->MessageManager()->HandleRequestL( ESatTsySmsDeliverReport,
|
|
304 |
&package );
|
|
305 |
}
|
|
306 |
|
|
307 |
}
|
|
308 |
|
|
309 |
|
|
310 |
// -----------------------------------------------------------------------------
|
|
311 |
// CSatDataDownloadTsy::CreateSmsPpDdlEnvelopeL
|
|
312 |
// Prepare the envelope to be sent to DOS after a SMS-PP
|
|
313 |
// message has been received, without request, by the mobile equipment.
|
|
314 |
// -----------------------------------------------------------------------------
|
|
315 |
//
|
|
316 |
void CSatDataDownloadTsy::CreateSmsPpDdlEnvelopeL
|
|
317 |
(
|
|
318 |
const TDesC8& aSmsScAddress,
|
|
319 |
const TDesC8& aSmsTpdu
|
|
320 |
)
|
|
321 |
{
|
|
322 |
TFLOGSTRING( "CSAT:CSatDataDownloadTsy::CreateSmsPpDdlEnvelopeL" );
|
|
323 |
// Check that the data exists
|
|
324 |
if ( aSmsScAddress.Length() && aSmsTpdu.Length() )
|
|
325 |
{
|
|
326 |
TFLOGSTRING( "CSAT:CSatDataDownloadTsy::CreateSmsPpDdlEnvelopeL,\
|
|
327 |
Data Ok" );
|
|
328 |
TTlv envelope;
|
|
329 |
|
|
330 |
envelope.Begin( KBerTlvSmsPpDownloadTag );
|
|
331 |
envelope.AddTag( KTlvDeviceIdentityTag );
|
|
332 |
envelope.AddByte( KNetwork );
|
|
333 |
envelope.AddByte( KSim );
|
|
334 |
envelope.AddTag( KTlvAddressTag );
|
|
335 |
envelope.AddData( aSmsScAddress.Mid( 1, aSmsScAddress[0] ) );
|
|
336 |
envelope.AddTag( KTlvSmsTpduTag );
|
|
337 |
envelope.AddData( aSmsTpdu );
|
|
338 |
|
|
339 |
// Prepare data
|
|
340 |
TPtrC8 data = envelope.End();
|
|
341 |
// Pack data
|
|
342 |
CSatDataPackage dataPackage;
|
|
343 |
dataPackage.PackData( &data );
|
|
344 |
// Forward request to the DOS
|
|
345 |
iSatTsy->MessageManager()->HandleRequestL( ESatTsySmsPpDdl,
|
|
346 |
&dataPackage );
|
|
347 |
}
|
|
348 |
}
|
|
349 |
|
|
350 |
// -----------------------------------------------------------------------------
|
|
351 |
// CSatDataDownloadTsy::CompleteReadCbmidsL
|
|
352 |
// Request to read Cbmids from the elementary file EFcbmids.
|
|
353 |
// -----------------------------------------------------------------------------
|
|
354 |
//
|
|
355 |
void CSatDataDownloadTsy::CompleteReadCbmidsL
|
|
356 |
(
|
|
357 |
void
|
|
358 |
)
|
|
359 |
{
|
|
360 |
TFLOGSTRING( "CSAT: CSatDataDownloadTsy::CompleteReadCbmids" );
|
|
361 |
// Convert constants and append to simFilePath
|
|
362 |
TBuf8<KMaxFilePath> simFilePath;
|
|
363 |
// Append data
|
|
364 |
simFilePath.Append( TUint8( KMasterFileCbmids >> 8 ) );
|
|
365 |
//lint -e{778} Constant expression evaluates to 0 in operation
|
|
366 |
simFilePath.Append( TUint8( KMasterFileCbmids & 0xFF ) );
|
|
367 |
|
|
368 |
simFilePath.Append( TUint8( KDedicatedFileCbmids >> 8 ) );
|
|
369 |
simFilePath.Append( TUint8( KDedicatedFileCbmids & 0xFF ) );
|
|
370 |
|
|
371 |
simFilePath.Append( TUint8( KElementaryFileCbmids >> 8 ) );
|
|
372 |
simFilePath.Append( TUint8( KElementaryFileCbmids & 0xFF ) );
|
|
373 |
|
|
374 |
// Pack data
|
|
375 |
CSatDataPackage dataPackage;
|
|
376 |
dataPackage.PackData( &simFilePath );
|
|
377 |
// Forward request to the DOS
|
|
378 |
iSatTsy->MessageManager()->HandleRequestL(
|
|
379 |
ESatTsyReadCbmids, &dataPackage );
|
|
380 |
}
|
|
381 |
|
|
382 |
// -----------------------------------------------------------------------------
|
|
383 |
// CSatDataDownloadTsy::SetSmsPpDdlStatus
|
|
384 |
// Sets the support status of SMS PP Data Download in NAA
|
|
385 |
// -----------------------------------------------------------------------------
|
|
386 |
//
|
|
387 |
void CSatDataDownloadTsy::SetSmsPpDdlStatus
|
|
388 |
(
|
|
389 |
const CSatDataPackage* aDataPackage
|
|
390 |
)
|
|
391 |
{
|
|
392 |
aDataPackage->UnPackData( iIsSmsPpDdlSupported );
|
|
393 |
TFLOGSTRING2("CSAT: CSatNotifyMoSmControlRequest::SetActivationStatus, %d",
|
|
394 |
iIsSmsPpDdlSupported );
|
|
395 |
}
|
|
396 |
|
|
397 |
// -----------------------------------------------------------------------------
|
|
398 |
// CSatDataDownloadTsy::ParseSmsTpdu
|
|
399 |
// Interprets the given TPDU data and sets the results to internal data member
|
|
400 |
// -----------------------------------------------------------------------------
|
|
401 |
//
|
|
402 |
TInt CSatDataDownloadTsy::ParseSmsTpdu
|
|
403 |
(
|
|
404 |
const TDesC8& aSmsTpdu
|
|
405 |
)
|
|
406 |
{
|
|
407 |
TFLOGSTRING("CSAT: CSatDataDownloadTsy::ParseSmsTpdu");
|
|
408 |
TInt ret( KErrCorrupt );
|
|
409 |
|
|
410 |
// Initialize values
|
|
411 |
iSmsTpdu.iParameters = KSmsTpduByteUnknownOrReserved;
|
|
412 |
iSmsTpdu.iProtocolId = KSmsTpduByteUnknownOrReserved;
|
|
413 |
iSmsTpdu.iDcs = KSmsTpduByteUnknownOrReserved;
|
|
414 |
iSmsTpdu.iUserData.Zero();
|
|
415 |
|
|
416 |
// Check first that the TPdu data and SC address exist before parsing
|
|
417 |
if ( KSmsTpduMinLength < aSmsTpdu.Length() )
|
|
418 |
{
|
|
419 |
// Set parameters
|
|
420 |
iSmsTpdu.iParameters = aSmsTpdu[0];
|
|
421 |
// Then we need to get Protocol ID and DCS..
|
|
422 |
// ..the length of address in chars is in the 1st byte of Addr. string
|
|
423 |
TUint8 chars = aSmsTpdu[KSmsTpduAddrOffset];
|
|
424 |
TUint8 addrLengthInBytes( 0 );
|
|
425 |
|
|
426 |
if ( chars % 2 )
|
|
427 |
{
|
|
428 |
addrLengthInBytes = chars / 2 + 1;
|
|
429 |
}
|
|
430 |
else
|
|
431 |
{
|
|
432 |
addrLengthInBytes = chars / 2;
|
|
433 |
}
|
|
434 |
|
|
435 |
// Then add two in order to point to the protocol ID (the order is:
|
|
436 |
// address length, type of address, address data, protocol id...
|
|
437 |
TUint8 offset = KSmsTpduAddrOffset + 2 + addrLengthInBytes;
|
|
438 |
|
|
439 |
// Just to be on the safe side, check that the offset is not too big
|
|
440 |
if ( aSmsTpdu.Length() > ( offset + 1 + KSmsTpduSctsLength ) )
|
|
441 |
{
|
|
442 |
TFLOGSTRING( "CSAT:CSatDataDownloadTsy::ParseSmsTpdu,\
|
|
443 |
SmsTpdu length Ok" );
|
|
444 |
// Set protocol id and data coding shceme
|
|
445 |
iSmsTpdu.iProtocolId = aSmsTpdu[offset];
|
|
446 |
iSmsTpdu.iDcs = aSmsTpdu[++offset] ;
|
|
447 |
|
|
448 |
// Update offset to point the TP-UDL (skip TP-SCTS, not needed)
|
|
449 |
offset = offset + KSmsTpduSctsLength + 1;
|
|
450 |
TUint8 tpduUserDataLength = aSmsTpdu[offset];
|
|
451 |
|
|
452 |
// If user data exists, add it to the end of buffer
|
|
453 |
if ( tpduUserDataLength )
|
|
454 |
{
|
|
455 |
iSmsTpdu.iUserData.Copy( aSmsTpdu.Mid( ++offset ) );
|
|
456 |
TFLOGSTRING2( "CSAT:CSatDataDownloadTsy::ParseSmsTpdu,\
|
|
457 |
iUserData length: %d", iSmsTpdu.iUserData.Length() );
|
|
458 |
}
|
|
459 |
|
|
460 |
ret = KErrNone;
|
|
461 |
}
|
|
462 |
} // TPDU reaches the minimum length
|
|
463 |
|
|
464 |
return ret;
|
|
465 |
}
|
|
466 |
|
|
467 |
// End of file
|
|
468 |
|