24
|
1 |
// Copyright (c) 2005-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 : CSatNotifySendSm.cpp
|
|
15 |
// Part of : Common SIM ATK TSY / commonsimatktsy
|
|
16 |
// SendSm notification functionality of Sat Tsy
|
|
17 |
// Version : 1.0
|
|
18 |
//
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
//INCLUDES
|
|
23 |
#include <satcs.h> // Etel SAT IPC definitions
|
|
24 |
#include "CSatTsy.h" // Tsy class header
|
|
25 |
#include "CSatNotifySendSm.h" // Tsy class header
|
|
26 |
#include "CSatNotificationsTsy.h" // Class header
|
|
27 |
#include "CBerTlv.h" // Ber Tlv data handling
|
|
28 |
#include "TTlv.h" // TTlv class
|
|
29 |
#include "CSatDataPackage.h" // Parameter packing
|
|
30 |
#include "TfLogger.h" // For TFLOGSTRING
|
|
31 |
#include "TSatUtility.h" // Utilities
|
|
32 |
#include "CSatTsyReqHandleStore.h" // Request handle class
|
|
33 |
#include "cmmmessagemanagerbase.h" // Message manager class for forwarding req.
|
|
34 |
|
|
35 |
// -----------------------------------------------------------------------------
|
|
36 |
// CSatNotifySendSm::NewL
|
|
37 |
// Two-phased constructor.
|
|
38 |
// -----------------------------------------------------------------------------
|
|
39 |
//
|
|
40 |
CSatNotifySendSm* CSatNotifySendSm::NewL
|
|
41 |
(
|
|
42 |
CSatNotificationsTsy* aNotificationsTsy
|
|
43 |
)
|
|
44 |
{
|
|
45 |
TFLOGSTRING("CSAT: CSatNotifySendSm::NewL");
|
|
46 |
CSatNotifySendSm* const satNotifySendSm =
|
|
47 |
new ( ELeave ) CSatNotifySendSm( aNotificationsTsy );
|
|
48 |
CleanupStack::PushL( satNotifySendSm );
|
|
49 |
satNotifySendSm->ConstructL();
|
|
50 |
CleanupStack::Pop( satNotifySendSm );
|
|
51 |
TFLOGSTRING("CSAT: CSatNotifySendSm::NewL, end of method");
|
|
52 |
return satNotifySendSm;
|
|
53 |
}
|
|
54 |
|
|
55 |
// -----------------------------------------------------------------------------
|
|
56 |
// CSatNotifySendSm::~CSatNotifySendSm
|
|
57 |
// Destructor
|
|
58 |
// -----------------------------------------------------------------------------
|
|
59 |
//
|
|
60 |
CSatNotifySendSm::~CSatNotifySendSm
|
|
61 |
(
|
|
62 |
// None
|
|
63 |
)
|
|
64 |
{
|
|
65 |
TFLOGSTRING("CSAT: CSatNotifySendSm::~CSatNotifySendSm");
|
|
66 |
}
|
|
67 |
|
|
68 |
// -----------------------------------------------------------------------------
|
|
69 |
// CSatNotifySendSm::CSatNotifySendSm
|
|
70 |
// Default C++ constructor
|
|
71 |
// -----------------------------------------------------------------------------
|
|
72 |
//
|
|
73 |
CSatNotifySendSm::CSatNotifySendSm
|
|
74 |
(
|
|
75 |
CSatNotificationsTsy* aNotificationsTsy
|
|
76 |
) : iNotificationsTsy ( aNotificationsTsy )
|
|
77 |
{
|
|
78 |
// None
|
|
79 |
}
|
|
80 |
|
|
81 |
// -----------------------------------------------------------------------------
|
|
82 |
// CSatNotifySendSm::ConstructL
|
|
83 |
// Symbian 2nd phase constructor
|
|
84 |
// -----------------------------------------------------------------------------
|
|
85 |
//
|
|
86 |
void CSatNotifySendSm::ConstructL
|
|
87 |
(
|
|
88 |
// None
|
|
89 |
)
|
|
90 |
{
|
|
91 |
TFLOGSTRING("CSAT: CSatNotifySendSm::ConstructL, does nothing");
|
|
92 |
}
|
|
93 |
|
|
94 |
// -----------------------------------------------------------------------------
|
|
95 |
// CSatNotifySendSm::Notify
|
|
96 |
// This request allows a client to be notified of a Send Sm proactive command.
|
|
97 |
// -----------------------------------------------------------------------------
|
|
98 |
//
|
|
99 |
TInt CSatNotifySendSm::Notify
|
|
100 |
(
|
|
101 |
const TTsyReqHandle aTsyReqHandle,
|
|
102 |
const TDataPackage& aPackage
|
|
103 |
)
|
|
104 |
{
|
|
105 |
TFLOGSTRING("CSAT: CSatNotifySendSm::Notify");
|
|
106 |
// Save data pointer to client side for completion
|
|
107 |
iSendSmV1Pckg = reinterpret_cast<RSat::TSendSmV1Pckg*>(
|
|
108 |
aPackage.Des1n() );
|
|
109 |
// Save the request handle
|
|
110 |
iNotificationsTsy->iSatTsy->SaveReqHandle( aTsyReqHandle,
|
|
111 |
CSatTsy::ESatNotifySendSmPCmdReqType );
|
|
112 |
// Check if requested notification is already pending
|
|
113 |
iNotificationsTsy->NotifySatReadyForNotification( KSendShortMessage );
|
|
114 |
return KErrNone;
|
|
115 |
}
|
|
116 |
|
|
117 |
// -----------------------------------------------------------------------------
|
|
118 |
// CSatNotifySendSm::CancelNotification
|
|
119 |
// This method cancels an outstanding asynchronous NotifySendSm request.
|
|
120 |
// -----------------------------------------------------------------------------
|
|
121 |
//
|
|
122 |
TInt CSatNotifySendSm::CancelNotification
|
|
123 |
(
|
|
124 |
const TTsyReqHandle aTsyReqHandle
|
|
125 |
)
|
|
126 |
{
|
|
127 |
TFLOGSTRING("CSAT: CSatNotifySendSm::CancelNotification");
|
|
128 |
// Reset the request handle
|
|
129 |
TTsyReqHandle reqHandle = iNotificationsTsy->iSatReqHandleStore->
|
|
130 |
ResetTsyReqHandle( CSatTsy::ESatNotifySendSmPCmdReqType );
|
|
131 |
// Reset the data pointer
|
|
132 |
iSendSmV1Pckg = NULL;
|
|
133 |
// Complete the request with KErrCancel
|
|
134 |
iNotificationsTsy->iSatTsy->ReqCompleted( aTsyReqHandle, KErrCancel );
|
|
135 |
|
|
136 |
return KErrNone;
|
|
137 |
}
|
|
138 |
|
|
139 |
// -----------------------------------------------------------------------------
|
|
140 |
// CSatNotifySendSm::CompleteNotifyL
|
|
141 |
// This method completes an outstanding asynchronous NotifySendSm request.
|
|
142 |
// -----------------------------------------------------------------------------
|
|
143 |
//
|
|
144 |
TInt CSatNotifySendSm::CompleteNotifyL
|
|
145 |
(
|
|
146 |
CSatDataPackage* aDataPackage,
|
|
147 |
TInt aErrorCode
|
|
148 |
)
|
|
149 |
{
|
|
150 |
TFLOGSTRING("CSAT: CSatNotifySendSm::CompleteNotifyL");
|
|
151 |
TInt ret( KErrNone );
|
|
152 |
TBuf<1> additionalInfo;
|
|
153 |
// Unpack parameters
|
|
154 |
TPtrC8* data;
|
|
155 |
aDataPackage->UnPackData( &data );
|
|
156 |
// Reset req handle. Returns the deleted req handle
|
|
157 |
TTsyReqHandle reqHandle = iNotificationsTsy->iSatReqHandleStore->
|
|
158 |
ResetTsyReqHandle( CSatTsy::ESatNotifySendSmPCmdReqType );
|
|
159 |
|
|
160 |
// Get ber tlv
|
|
161 |
CBerTlv berTlv;
|
|
162 |
berTlv.SetData( *data );
|
|
163 |
// Get command details tlv
|
|
164 |
CTlv commandDetails;
|
|
165 |
berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
|
|
166 |
// Store command details tlv
|
|
167 |
iNotificationsTsy->iTerminalRespData.iCommandDetails.Copy(
|
|
168 |
commandDetails.Data() );
|
|
169 |
|
|
170 |
TUint8 pCmdNumber( commandDetails.GetShortInfo( ETLV_CommandNumber ) );
|
|
171 |
// In case the request was ongoing, continue..
|
|
172 |
if ( CSatTsy::ESatReqHandleUnknown != reqHandle )
|
|
173 |
{
|
|
174 |
// Complete right away if error has occured, otherwise continue..
|
|
175 |
if ( KErrNone == aErrorCode )
|
|
176 |
{
|
|
177 |
// Fill the send sm structure
|
|
178 |
RSat::TSendSmV1& sendSmV1 = ( *iSendSmV1Pckg )();
|
|
179 |
// Command number
|
|
180 |
sendSmV1.SetPCmdNumber( pCmdNumber );
|
|
181 |
sendSmV1.iSmsTpdu.Zero();
|
|
182 |
CTlv smsTpduTlv;
|
|
183 |
// Get TPdu tlv
|
|
184 |
TInt returnValue( berTlv.TlvByTagValue( &smsTpduTlv,
|
|
185 |
KTlvSmsTpduTag ) );
|
|
186 |
|
|
187 |
if ( KErrNone == returnValue )
|
|
188 |
{
|
|
189 |
// Tpdu TLV length
|
|
190 |
TUint16 smsTpduLength( smsTpduTlv.GetLength() );
|
|
191 |
// Set pointer to Tpdu
|
|
192 |
TPtrC8 smsTpdu = smsTpduTlv.GetData( ETLV_SmsTPdu );
|
|
193 |
// Check that TP-UDL is valid
|
|
194 |
ret = CheckTpdu( smsTpdu );
|
|
195 |
|
|
196 |
if ( KErrCorrupt == ret )
|
|
197 |
{
|
|
198 |
TFLOGSTRING("CSAT: CSatNotifySendSm::CompleteNotifyL,\
|
|
199 |
Invalid data");
|
|
200 |
additionalInfo.Zero();
|
|
201 |
additionalInfo.Append( KNoCause );
|
|
202 |
CreateTerminalRespL( pCmdNumber,
|
|
203 |
RSat::KCmdDataNotUnderstood, additionalInfo );
|
|
204 |
}
|
|
205 |
else if ( KErrNone == ret && smsTpduLength )
|
|
206 |
{
|
|
207 |
// Copying the TTpdu
|
|
208 |
sendSmV1.iSmsTpdu.Append( smsTpdu );
|
|
209 |
}
|
|
210 |
|
|
211 |
// Checking if packing is required for the SMS message or not
|
|
212 |
// Packing: see ETSI 3.38 and 3.40
|
|
213 |
if ( ( KSmsPackingRequiredMask & iNotificationsTsy->
|
|
214 |
iTerminalRespData.iCommandDetails[KCommandQualifier] )
|
|
215 |
&& ( KErrNone == ret ) )
|
|
216 |
{
|
|
217 |
// Packing required
|
|
218 |
if ( smsTpduLength )
|
|
219 |
{
|
|
220 |
// Call method to pack sms
|
|
221 |
ret = PackSms( smsTpdu, sendSmV1.iSmsTpdu );
|
|
222 |
if ( KErrNone != ret )
|
|
223 |
{
|
|
224 |
TFLOGSTRING("CSAT: CSatNotifySendSm::\
|
|
225 |
CompleteNotifyL, Invalid TPDU");
|
|
226 |
// TPDU is invalid or packing cannot be requested
|
|
227 |
// if tpdu is something else than SMS-SUBMIT
|
|
228 |
additionalInfo.Zero();
|
|
229 |
additionalInfo.Append( KNoCause );
|
|
230 |
CreateTerminalRespL( pCmdNumber,
|
|
231 |
RSat::KCmdDataNotUnderstood, additionalInfo );
|
|
232 |
ret = KErrCorrupt;
|
|
233 |
}
|
|
234 |
else
|
|
235 |
{
|
|
236 |
// Do nothing
|
|
237 |
}
|
|
238 |
}
|
|
239 |
else
|
|
240 |
{
|
|
241 |
TFLOGSTRING("CSAT: CSatNotifySendSm::CompleteNotifyL,\
|
|
242 |
Packing not required");
|
|
243 |
}
|
|
244 |
}
|
|
245 |
else
|
|
246 |
{
|
|
247 |
// Do nothing
|
|
248 |
}
|
|
249 |
}
|
|
250 |
else
|
|
251 |
{
|
|
252 |
TFLOGSTRING("CSAT: CSatNotifySendSm::CompleteNotifyL,\
|
|
253 |
Missing TPDU");
|
|
254 |
// TPdu is missing, returning response immediately
|
|
255 |
additionalInfo.Zero();
|
|
256 |
additionalInfo.Append( KNoCause );
|
|
257 |
CreateTerminalRespL( pCmdNumber,
|
|
258 |
RSat::KErrorRequiredValuesMissing, additionalInfo );
|
|
259 |
ret = KErrCorrupt;
|
|
260 |
}
|
|
261 |
|
|
262 |
if ( KErrNone == ret )
|
|
263 |
{
|
|
264 |
SetAlphaIdAndAddressData( &berTlv, sendSmV1 );
|
|
265 |
// Iconid
|
|
266 |
TSatUtility::FillIconStructure( berTlv, sendSmV1.iIconId );
|
|
267 |
}
|
|
268 |
|
|
269 |
} // End of if ( KErrNone == aErrorCode )
|
|
270 |
else
|
|
271 |
{
|
|
272 |
ret = aErrorCode;
|
|
273 |
}
|
|
274 |
|
|
275 |
iNotificationsTsy->iSatTsy->ReqCompleted( reqHandle, ret );
|
|
276 |
|
|
277 |
} // End of if ( CSatTsy::ESatReqHandleUnknown != reqHandle )
|
|
278 |
else
|
|
279 |
{
|
|
280 |
TFLOGSTRING("CSAT: CSatNotifySendSm::CompleteNotifyL,\
|
|
281 |
Request not ongoing");
|
|
282 |
// Request not on, returning response immediately
|
|
283 |
additionalInfo.Zero();
|
|
284 |
additionalInfo.Append( KNoCause );
|
|
285 |
CreateTerminalRespL( pCmdNumber, RSat::KMeUnableToProcessCmd,
|
|
286 |
additionalInfo );
|
|
287 |
}
|
|
288 |
return ret;
|
|
289 |
}
|
|
290 |
|
|
291 |
// -----------------------------------------------------------------------------
|
|
292 |
// CSatNotifySendSm::TerminalResponseL
|
|
293 |
// Called by ETel server, passes terminal response to NAA
|
|
294 |
// -----------------------------------------------------------------------------
|
|
295 |
//
|
|
296 |
TInt CSatNotifySendSm::TerminalResponseL
|
|
297 |
(
|
|
298 |
TDes8* aRsp
|
|
299 |
)
|
|
300 |
{
|
|
301 |
TFLOGSTRING( "CSAT::CSatNotifySendSm::TerminalResponseL" );
|
|
302 |
|
|
303 |
TInt ret( KErrNone );
|
|
304 |
TBuf<1> additionalInfo;
|
|
305 |
RSat::TSendSmRspV1Pckg* aRspPckg =
|
|
306 |
reinterpret_cast<RSat::TSendSmRspV1Pckg*>( aRsp );
|
|
307 |
RSat::TSendSmRspV1& rspV1 = ( *aRspPckg ) ();
|
|
308 |
// Get Proactive command number
|
|
309 |
TUint8 pCmdNumber( rspV1.PCmdNumber() );
|
|
310 |
TFLOGSTRING2( "CSAT::CSatNotifySendSm::TerminalResponseL: GeneralResult: \
|
|
311 |
%d", static_cast<TUint8>( rspV1.iGeneralResult ) );
|
|
312 |
|
|
313 |
// Check that general result value is valid
|
|
314 |
if ( ( RSat::KSuccess != rspV1.iGeneralResult ) &&
|
|
315 |
( RSat::KMeUnableToProcessCmd != rspV1.iGeneralResult ) &&
|
|
316 |
( RSat::KCmdBeyondMeCapabilities != rspV1.iGeneralResult )&&
|
|
317 |
( RSat::KSmsRpError != rspV1.iGeneralResult ) &&
|
|
318 |
( RSat::KInteractionWithCCPermanentError != rspV1.iGeneralResult ) &&
|
|
319 |
( RSat::KModifiedByCallControl != rspV1.iGeneralResult ) &&
|
|
320 |
( RSat::KSuccessRequestedIconNotDisplayed != rspV1.iGeneralResult ) )
|
|
321 |
{
|
|
322 |
TFLOGSTRING( "CSAT::CSatNotifySendSm::TerminalResponseL,\
|
|
323 |
Invalid General result" );
|
|
324 |
// Invalid general result
|
|
325 |
ret = KErrCorrupt;
|
|
326 |
}
|
|
327 |
|
|
328 |
// If there is ME (Mobile Entity) error or network error, additional info
|
|
329 |
// is needed
|
|
330 |
if ( ( RSat::KMeProblem == rspV1.iInfoType ) ||
|
|
331 |
( RSat::KSatNetworkErrorInfo == rspV1.iInfoType ) ||
|
|
332 |
( RSat::KControlInteraction == rspV1.iInfoType ) )
|
|
333 |
{
|
|
334 |
// Check the length of additional info
|
|
335 |
if ( 0 == rspV1.iAdditionalInfo.Length() )
|
|
336 |
{
|
|
337 |
TFLOGSTRING( "CSAT::CSatNotifySendSm::TerminalResponseL,\
|
|
338 |
Invalid Additional Info" );
|
|
339 |
// No info
|
|
340 |
ret = KErrCorrupt;
|
|
341 |
}
|
|
342 |
else
|
|
343 |
{
|
|
344 |
additionalInfo.Append( rspV1.iAdditionalInfo[0] );
|
|
345 |
}
|
|
346 |
}
|
|
347 |
else
|
|
348 |
{
|
|
349 |
// Do nothing
|
|
350 |
}
|
|
351 |
|
|
352 |
// Creating the info message
|
|
353 |
TInt response = CreateTerminalRespL( pCmdNumber, static_cast<TUint8>(
|
|
354 |
rspV1.iGeneralResult ), additionalInfo );
|
|
355 |
|
|
356 |
if(KErrNone == ret)
|
|
357 |
ret = response;
|
|
358 |
return ret;
|
|
359 |
}
|
|
360 |
|
|
361 |
// -----------------------------------------------------------------------------
|
|
362 |
// CSatNotifySendSm::CreateTerminalRespL
|
|
363 |
// Constructs SendSm specific part of terminal response and calls
|
|
364 |
// DOS to send the actual message.
|
|
365 |
// -----------------------------------------------------------------------------
|
|
366 |
//
|
|
367 |
TInt CSatNotifySendSm::CreateTerminalRespL
|
|
368 |
(
|
|
369 |
TUint8 aPCmdNumber,
|
|
370 |
TUint8 aGeneralResult,
|
|
371 |
TDesC16& aAdditionalInfo
|
|
372 |
)
|
|
373 |
{
|
|
374 |
TFLOGSTRING( "CSAT::CSatNotifySendSm::CreateTerminalRespL" );
|
|
375 |
// Create and append response data
|
|
376 |
TTlv tlvSpecificData;
|
|
377 |
// Create General Result TLV here
|
|
378 |
tlvSpecificData.AddTag( KTlvResultTag );
|
|
379 |
// General result
|
|
380 |
tlvSpecificData.AddByte( aGeneralResult );
|
|
381 |
|
|
382 |
if ( ( RSat::KMeUnableToProcessCmd == aGeneralResult ) ||
|
|
383 |
( RSat::KNetworkUnableToProcessCmd == aGeneralResult ) ||
|
|
384 |
( RSat::KSmsRpError == aGeneralResult ) ||
|
|
385 |
( RSat::KInteractionWithCCPermanentError == aGeneralResult ) )
|
|
386 |
{
|
|
387 |
if( aAdditionalInfo.Length() > 0 )
|
|
388 |
{
|
|
389 |
TFLOGSTRING( "CSAT::CSatNotifySendSm::CreateTerminalRespL,\
|
|
390 |
Unsuccessful result" );
|
|
391 |
// If there is ME, Network or SMS error, append additional info
|
|
392 |
tlvSpecificData.AddByte( static_cast<TUint8>( aAdditionalInfo[0] ) );
|
|
393 |
}
|
|
394 |
}
|
|
395 |
else
|
|
396 |
{
|
|
397 |
// Do nothing
|
|
398 |
}
|
|
399 |
|
|
400 |
// Prepare data
|
|
401 |
iNotificationsTsy->iTerminalRespData.iPCmdNumber = aPCmdNumber;
|
|
402 |
TPtrC8 data = tlvSpecificData.GetDataWithoutTopLevelTag();
|
|
403 |
// Pack data
|
|
404 |
CSatDataPackage dataPackage;
|
|
405 |
dataPackage.PackData( &iNotificationsTsy->iTerminalRespData, &data );
|
|
406 |
// Forward request to the DOS
|
|
407 |
return iNotificationsTsy->iSatTsy->MessageManager()->HandleRequestL(
|
|
408 |
ESatTerminalRsp, &dataPackage );
|
|
409 |
}
|
|
410 |
|
|
411 |
// -----------------------------------------------------------------------------
|
|
412 |
// CSatNotifySendSm::SetAlphaIdAndAddressData
|
|
413 |
// Set Alpha id and Address into send sm structure
|
|
414 |
// -----------------------------------------------------------------------------
|
|
415 |
//
|
|
416 |
void CSatNotifySendSm::SetAlphaIdAndAddressData
|
|
417 |
(
|
|
418 |
CBerTlv* aBerTlv,
|
|
419 |
RSat::TSendSmV1& aSendSmV1
|
|
420 |
)
|
|
421 |
{
|
|
422 |
TFLOGSTRING( "CSAT::CSatNotifySendSm::SetAlphaIdAndAddressData" );
|
|
423 |
TInt returnValue;
|
|
424 |
TPtrC8 sourceString; // Used in unicode conversions
|
|
425 |
// Alpha id string (optional)
|
|
426 |
aSendSmV1.iAlphaId.iAlphaId.Zero();
|
|
427 |
CTlv alphaIdTlv;
|
|
428 |
returnValue = aBerTlv->TlvByTagValue( &alphaIdTlv,
|
|
429 |
KTlvAlphaIdentifierTag ) ;
|
|
430 |
|
|
431 |
if ( KErrNone == returnValue )
|
|
432 |
{
|
|
433 |
// Alpha id tlv found
|
|
434 |
if ( alphaIdTlv.GetLength() )
|
|
435 |
{
|
|
436 |
// Get alpha id text
|
|
437 |
sourceString.Set( alphaIdTlv.GetData( ETLV_AlphaIdentifier ) );
|
|
438 |
// Convert and set alpha id
|
|
439 |
TSatUtility::SetAlphaId( sourceString,
|
|
440 |
aSendSmV1.iAlphaId.iAlphaId );
|
|
441 |
}
|
|
442 |
|
|
443 |
// Alpha Tag present
|
|
444 |
if ( aSendSmV1.iAlphaId.iAlphaId.Length() )
|
|
445 |
{
|
|
446 |
aSendSmV1.iAlphaId.iStatus = RSat::EAlphaIdProvided;
|
|
447 |
}
|
|
448 |
else
|
|
449 |
{
|
|
450 |
TFLOGSTRING( "CSAT::CSatNotifySendSm::SetAlphaIdAndAddressData,\
|
|
451 |
Alpha ID is NULL" );
|
|
452 |
aSendSmV1.iAlphaId.iStatus = RSat::EAlphaIdNull;
|
|
453 |
}
|
|
454 |
}
|
|
455 |
else
|
|
456 |
{
|
|
457 |
TFLOGSTRING( "CSAT::CSatNotifySendSm::SetAlphaIdAndAddressData,\
|
|
458 |
Alpha ID not present" );
|
|
459 |
aSendSmV1.iAlphaId.iStatus = RSat::EAlphaIdNotPresent;
|
|
460 |
}
|
|
461 |
// The address data object holds the RP_Destination_Address of the Service
|
|
462 |
// Centre. If no RP_Destination_Address is transferred, then the ME shall
|
|
463 |
// insert the default Service Centre address (below).
|
|
464 |
aSendSmV1.iAddress.iTelNumber.Zero();
|
|
465 |
CTlv addressTlv;
|
|
466 |
// Get address tlv. Includes SCA number. (optional)
|
|
467 |
returnValue = aBerTlv->TlvByTagValue( &addressTlv, KTlvAddressTag );
|
|
468 |
|
|
469 |
if ( KErrNone == returnValue )
|
|
470 |
{
|
|
471 |
if ( 0 < addressTlv.GetLength() )
|
|
472 |
{
|
|
473 |
// Initialize ton and npi
|
|
474 |
RSat::TTypeOfNumber ton;
|
|
475 |
RSat::TNumberingPlan npi;
|
|
476 |
// Call utility function that maps received TON and NPI to
|
|
477 |
// RSat values
|
|
478 |
TSatUtility::TonAndNpi(
|
|
479 |
addressTlv.GetShortInfo( ETLV_TonAndNpi ), &ton, &npi );
|
|
480 |
// Set TON and NPI
|
|
481 |
aSendSmV1.iAddress.iTypeOfNumber = ton;
|
|
482 |
aSendSmV1.iAddress.iNumberPlan = npi;
|
|
483 |
TBuf8<RSat::KMaxMobileTelNumberSize> tempScaNumber;
|
|
484 |
// set pointer to address tlv
|
|
485 |
sourceString.Set( addressTlv.GetData(
|
|
486 |
ETLV_DiallingNumberString ) );
|
|
487 |
|
|
488 |
if ( sourceString.Length() )
|
|
489 |
{
|
|
490 |
// Semi-octet presentation used
|
|
491 |
// Converting back to ASCII format
|
|
492 |
TSatUtility::BCDToAscii( sourceString, tempScaNumber );
|
|
493 |
aSendSmV1.iAddress.iTelNumber.Copy( tempScaNumber );
|
|
494 |
TFLOGSTRING2("CSAT: SendSm, SCA number: %S",
|
|
495 |
&aSendSmV1.iAddress.iTelNumber );
|
|
496 |
}
|
|
497 |
else
|
|
498 |
{
|
|
499 |
TFLOGSTRING( "CSAT::CSatNotifySendSm::SetAlphaIdAndAddressData\
|
|
500 |
Address TLV found, TON/NPI present, but number epmpty" );
|
|
501 |
// Address TLV found, TON/NPI present, but number epmpty.
|
|
502 |
aSendSmV1.iAddress.iTypeOfNumber = RSat::EUnknownNumber;
|
|
503 |
aSendSmV1.iAddress.iNumberPlan = RSat::EUnknownNumberingPlan;
|
|
504 |
}
|
|
505 |
}
|
|
506 |
else
|
|
507 |
{
|
|
508 |
TFLOGSTRING( "CSAT::CSatNotifySendSm::SetAlphaIdAndAddressData\
|
|
509 |
Address TLV found, but the Value part doesn't exist");
|
|
510 |
// Address TLV found, but the Value part doesn't exist
|
|
511 |
aSendSmV1.iAddress.iTypeOfNumber = RSat::EUnknownNumber;
|
|
512 |
aSendSmV1.iAddress.iNumberPlan = RSat::EUnknownNumberingPlan;
|
|
513 |
}
|
|
514 |
}
|
|
515 |
else
|
|
516 |
{
|
|
517 |
TFLOGSTRING( "CSAT::CSatNotifySendSm::SetAlphaIdAndAddressData\
|
|
518 |
Address TLV not found");
|
|
519 |
// Address TLV not found
|
|
520 |
aSendSmV1.iAddress.iTypeOfNumber = RSat::ETypeOfNumberNotSet;
|
|
521 |
aSendSmV1.iAddress.iNumberPlan = RSat::ENumberingPlanNotSet;
|
|
522 |
}
|
|
523 |
}
|
|
524 |
|
|
525 |
// -----------------------------------------------------------------------------
|
|
526 |
// CSatNotifySendSm::CheckTpdu
|
|
527 |
// This method Checks TPDU validity
|
|
528 |
// -----------------------------------------------------------------------------
|
|
529 |
//
|
|
530 |
TInt CSatNotifySendSm::CheckTpdu
|
|
531 |
(
|
|
532 |
TPtrC8 aTpdu
|
|
533 |
)
|
|
534 |
{
|
|
535 |
TFLOGSTRING( "CSAT::CSatNotifySendSm::CheckTpdu");
|
|
536 |
TInt ret( KErrNone );
|
|
537 |
|
|
538 |
if ( KSATSmsMTISubmitOrSubmitReport == ( aTpdu[0] & KMask3 ) )
|
|
539 |
{
|
|
540 |
// SMS-SUBMIT
|
|
541 |
TUint8 tpUdl( GetTpUdl( aTpdu ) ); // TP-User-Data-Length
|
|
542 |
// Get data coding scheme, leave only Alphabet bits
|
|
543 |
TUint8 dcs( GetTpDcs( aTpdu ) );
|
|
544 |
dcs &= KDCSAlphabetMask;
|
|
545 |
|
|
546 |
if ( !dcs && KSmsMaxSize < tpUdl )
|
|
547 |
{
|
|
548 |
TFLOGSTRING( "CSAT::CSatNotifySendSm::CheckTpdu,\
|
|
549 |
False DCS Length");
|
|
550 |
// DCS is 7-bit and message is over 160 bytes, set ret to corrupt
|
|
551 |
ret = KErrCorrupt;
|
|
552 |
}
|
|
553 |
else if ( ( !( KSmsPackingRequiredMask & iNotificationsTsy->
|
|
554 |
iTerminalRespData.iCommandDetails[KCommandQualifier] ) )
|
|
555 |
&& ( KSmsMaxSizeWithoutPacking < tpUdl && dcs ) )
|
|
556 |
{
|
|
557 |
TFLOGSTRING( "CSAT::CSatNotifySendSm::CheckTpdu,\
|
|
558 |
TP-UD Too long without packing");
|
|
559 |
// TP-UD is too long without packing
|
|
560 |
ret = KErrCorrupt;
|
|
561 |
}
|
|
562 |
else if ( ( KSmsMaxSize < tpUdl ) && dcs )
|
|
563 |
{
|
|
564 |
TFLOGSTRING( "CSAT::CSatNotifySendSm::CheckTpdu,\
|
|
565 |
TP-UD is too long even with packing");
|
|
566 |
// TP-UD is too long even with packing
|
|
567 |
ret = KErrCorrupt;
|
|
568 |
}
|
|
569 |
else
|
|
570 |
{
|
|
571 |
// Do nothing
|
|
572 |
}
|
|
573 |
}
|
|
574 |
else
|
|
575 |
{
|
|
576 |
// SMS-COMMAND
|
|
577 |
if ( KSMSCommandMaxSize < GetTpUdl( aTpdu ) )
|
|
578 |
{
|
|
579 |
TFLOGSTRING( "CSAT::CSatNotifySendSm::CheckTpdu,\
|
|
580 |
False SMS Command length");
|
|
581 |
ret = KErrCorrupt;
|
|
582 |
}
|
|
583 |
else
|
|
584 |
{
|
|
585 |
// Do nothing
|
|
586 |
}
|
|
587 |
}
|
|
588 |
|
|
589 |
return ret;
|
|
590 |
}
|
|
591 |
|
|
592 |
// -----------------------------------------------------------------------------
|
|
593 |
// CSatNotifySendSm::GetTpUdl
|
|
594 |
// This method Returns TP-UDL or TP-CDL depending on is sms type SMS-SUBMIT or
|
|
595 |
// SMS-COMMAND.
|
|
596 |
// -----------------------------------------------------------------------------
|
|
597 |
//
|
|
598 |
TUint8 CSatNotifySendSm::GetTpUdl
|
|
599 |
(
|
|
600 |
TPtrC8 aTpdu
|
|
601 |
)
|
|
602 |
{
|
|
603 |
TFLOGSTRING( "CSAT::CSatNotifySendSm::GetTpUdl");
|
|
604 |
TUint8 ret( 0 );
|
|
605 |
if ( KSATSmsMTISubmitOrSubmitReport == ( aTpdu[0] & KMask3 ) )
|
|
606 |
{
|
|
607 |
// SMS-SUBMIT
|
|
608 |
// Calculate the startpos of TP-UD field,
|
|
609 |
// 5 = number of mandatory fields
|
|
610 |
TUint8 startPos( KTPDUFieldStart );
|
|
611 |
|
|
612 |
// Checking the TP-VP field existence
|
|
613 |
// bit4 bit3
|
|
614 |
// 0 0 TP-VP field not present
|
|
615 |
// 1 0 TP-VP field present - relative format
|
|
616 |
// KSmsVPFRelative:0x10:000 10 000
|
|
617 |
// 0 1 TP-VP field present - enhanced format
|
|
618 |
// KSmsVPFEnhanced:0x08:000 01 000
|
|
619 |
// 1 1 TP-VP field present - absolute format
|
|
620 |
// KSmsVPFAbsolute:0x18:000 11 000
|
|
621 |
//
|
|
622 |
if ( KSmsVPFRelative == ( aTpdu[0] & KSmsVPFAbsolute ) )
|
|
623 |
{
|
|
624 |
startPos++;
|
|
625 |
}
|
|
626 |
if ( ( KSmsVPFEnhanced == ( aTpdu[0] & KSmsVPFAbsolute ) )
|
|
627 |
|| ( KSmsVPFAbsolute == ( aTpdu[0] & KSmsVPFAbsolute ) ) )
|
|
628 |
{
|
|
629 |
startPos += 7;
|
|
630 |
}
|
|
631 |
|
|
632 |
// Then the address field length.
|
|
633 |
// Address field length is number of BCD charachters
|
|
634 |
// Two BCD string chars are coded in one byte.
|
|
635 |
// Divide by two to get number of bytes and plus two is
|
|
636 |
// length tag + TON&NPI byte.
|
|
637 |
startPos = TUint8( startPos + aTpdu[2] / 2 + 2 );
|
|
638 |
if ( aTpdu[2] % 2 )
|
|
639 |
{
|
|
640 |
// If odd number of BCD characters
|
|
641 |
// increase position by one
|
|
642 |
startPos++;
|
|
643 |
}
|
|
644 |
|
|
645 |
else
|
|
646 |
{
|
|
647 |
// Do nothing
|
|
648 |
}
|
|
649 |
|
|
650 |
ret = aTpdu[startPos]; // Return TP-UDL
|
|
651 |
}
|
|
652 |
else // SMS-COMMAND
|
|
653 |
{
|
|
654 |
TUint8 startPos( 0x05 );
|
|
655 |
startPos = static_cast<TUint8>( startPos + aTpdu[5] / 2 + 2 );
|
|
656 |
if ( aTpdu[5] % 2 )
|
|
657 |
{
|
|
658 |
// If odd number of characters
|
|
659 |
// increase position by one
|
|
660 |
startPos++;
|
|
661 |
}
|
|
662 |
ret = aTpdu[startPos]; // Return TP-CDL
|
|
663 |
}
|
|
664 |
return ret;
|
|
665 |
}
|
|
666 |
|
|
667 |
// -----------------------------------------------------------------------------
|
|
668 |
// CSatNotifySendSm::GetTpDcs
|
|
669 |
// This method Returns data coding scheme of the SMS. In the case SMS is
|
|
670 |
// SMS-COMMAND then return null.
|
|
671 |
// -----------------------------------------------------------------------------
|
|
672 |
//
|
|
673 |
TUint8 CSatNotifySendSm::GetTpDcs
|
|
674 |
(
|
|
675 |
TPtrC8 aTpdu
|
|
676 |
)
|
|
677 |
{
|
|
678 |
TFLOGSTRING( "CSAT::CSatNotifySendSm::GetTpDcs");
|
|
679 |
TUint8 retValue( NULL );
|
|
680 |
if ( KSATSmsMTISubmitOrSubmitReport == ( aTpdu[0] & KMask3 ) )
|
|
681 |
{
|
|
682 |
// SMS-SUBMIT
|
|
683 |
TUint8 posDCS( 0 );
|
|
684 |
posDCS = static_cast<TUint8>( aTpdu[2] / 2 + 2 );
|
|
685 |
|
|
686 |
if ( aTpdu[2] % 2 )
|
|
687 |
{
|
|
688 |
// If odd number of characters
|
|
689 |
// increase position by one
|
|
690 |
posDCS++;
|
|
691 |
}
|
|
692 |
|
|
693 |
// Add 3 for first octet, message reference and protocol identifier
|
|
694 |
// mandatory fields
|
|
695 |
posDCS += 3;
|
|
696 |
|
|
697 |
retValue = aTpdu[posDCS];
|
|
698 |
}
|
|
699 |
// SMS-COMMAND
|
|
700 |
return retValue;
|
|
701 |
}
|
|
702 |
|
|
703 |
// -----------------------------------------------------------------------------
|
|
704 |
// CSatNotifySendSm::PackSms
|
|
705 |
// This method Pack SMS if it is required by the NAA
|
|
706 |
// -----------------------------------------------------------------------------
|
|
707 |
//
|
|
708 |
TInt CSatNotifySendSm::PackSms
|
|
709 |
(
|
|
710 |
TPtrC8 aTpdu,
|
|
711 |
TTpdu& aSendSm
|
|
712 |
)
|
|
713 |
{
|
|
714 |
TFLOGSTRING( "CSAT::CSatNotifySendSm::PackSms");
|
|
715 |
// See 3GPP TS 23.040 and TS 23.038:
|
|
716 |
// Packing of Basic elements of the SMS SUBMIT type
|
|
717 |
TInt ret( KErrNone );
|
|
718 |
|
|
719 |
// Message is a SMS-SUBMIT message
|
|
720 |
if ( KSATSmsMTISubmitOrSubmitReport == ( aTpdu[0] & KMask3 ) )
|
|
721 |
{
|
|
722 |
TUint8 startPos( KTPDUFieldStart );
|
|
723 |
|
|
724 |
if ( KSmsVPFRelative == ( aTpdu[0] & KSmsVPFAbsolute ) )
|
|
725 |
{
|
|
726 |
startPos++;
|
|
727 |
}
|
|
728 |
|
|
729 |
if ( ( KSmsVPFEnhanced == ( aTpdu[0] & KSmsVPFAbsolute ) ) ||
|
|
730 |
( KSmsVPFAbsolute == ( aTpdu[0] & KSmsVPFAbsolute ) ) )
|
|
731 |
{
|
|
732 |
startPos += 7;
|
|
733 |
}
|
|
734 |
|
|
735 |
// Then the address field length, Address field length in semi-octets
|
|
736 |
startPos = static_cast<TUint8>( startPos + aTpdu[2] / 2 + 2 );
|
|
737 |
|
|
738 |
if ( aTpdu[2] % 2 )
|
|
739 |
{
|
|
740 |
// if odd number of characters, increase position by one
|
|
741 |
startPos++;
|
|
742 |
}
|
|
743 |
else
|
|
744 |
{
|
|
745 |
// Do nothing
|
|
746 |
}
|
|
747 |
|
|
748 |
TInt i( 0 );
|
|
749 |
TInt x = startPos + 1;
|
|
750 |
|
|
751 |
// Checking of there is a header field(s) in the message
|
|
752 |
if ( KSmsHeaderIndicatorMask & aTpdu[0] )
|
|
753 |
{
|
|
754 |
// Has headers, Pack all the characters in SMS message
|
|
755 |
TUint8 move( 0 );
|
|
756 |
TBool endOfTPDU( EFalse );
|
|
757 |
x++;
|
|
758 |
|
|
759 |
for ( i = startPos; i < ( aTpdu[startPos] - aTpdu [startPos + 1] )
|
|
760 |
+ startPos; i++ )
|
|
761 |
{
|
|
762 |
TUint8 char1( static_cast<TUint8> (
|
|
763 |
aTpdu[aTpdu[startPos + 1] + 2 + i] >> move ) );
|
|
764 |
TUint8 char2( 0 );
|
|
765 |
|
|
766 |
if ( ( i + 2 ) <= ( ( aTpdu[startPos] - aTpdu [startPos + 1] )
|
|
767 |
+ startPos ) )
|
|
768 |
{
|
|
769 |
char2 = static_cast<TUint8>(
|
|
770 |
aTpdu[aTpdu[startPos + 1] + 2 + i + 1] << ( 7 - move ) );
|
|
771 |
}
|
|
772 |
else
|
|
773 |
{
|
|
774 |
char2 = 0;
|
|
775 |
endOfTPDU = ETrue;
|
|
776 |
}
|
|
777 |
|
|
778 |
aSendSm[aTpdu[startPos + 1] + x] = static_cast<TUint8>(
|
|
779 |
char1 | char2 );
|
|
780 |
x++;
|
|
781 |
|
|
782 |
if ( ( 6 == move ) && !endOfTPDU )
|
|
783 |
{
|
|
784 |
i++;
|
|
785 |
move = 0;
|
|
786 |
}
|
|
787 |
else
|
|
788 |
{
|
|
789 |
move++;
|
|
790 |
}
|
|
791 |
}
|
|
792 |
// Calculate the new length (in septets)
|
|
793 |
// Old length was in octects
|
|
794 |
aSendSm[startPos] =
|
|
795 |
static_cast<TUint8>( ( aTpdu[startPos + 1] * 8 / 7 )
|
|
796 |
+ ( aTpdu[startPos] - aTpdu[startPos + 1] ) );
|
|
797 |
}
|
|
798 |
else
|
|
799 |
{
|
|
800 |
TFLOGSTRING( "CSAT::CSatNotifySendSm::PackSms, No headers");
|
|
801 |
// No headers, lets pack all the characters in SMS message
|
|
802 |
TBool endOfTPDU( EFalse );
|
|
803 |
TUint8 move( 0 );
|
|
804 |
|
|
805 |
for ( i = startPos; i < aTpdu[startPos] + startPos; i++ )
|
|
806 |
{
|
|
807 |
if ( ( i + 1 ) < aTpdu.Length() )
|
|
808 |
{
|
|
809 |
TUint8 char1( static_cast<TUint8> ( aTpdu[i + 1] >> move ) );
|
|
810 |
TUint8 char2;
|
|
811 |
|
|
812 |
if ( ( i + 2 ) <= ( aTpdu[startPos] + startPos ) )
|
|
813 |
{
|
|
814 |
if ( ( i + 2 ) < aTpdu.Length() )
|
|
815 |
{
|
|
816 |
char2 = static_cast<TUint8>( aTpdu[i + 2] <<
|
|
817 |
( 7 - move ) );
|
|
818 |
}
|
|
819 |
else
|
|
820 |
{
|
|
821 |
ret = KErrCorrupt;
|
|
822 |
break;
|
|
823 |
}
|
|
824 |
}
|
|
825 |
else
|
|
826 |
{
|
|
827 |
endOfTPDU = ETrue;
|
|
828 |
char2 = 0;
|
|
829 |
}
|
|
830 |
|
|
831 |
// Append packed character
|
|
832 |
aSendSm[x++] = static_cast<TUint8>( char1 | char2 );
|
|
833 |
|
|
834 |
if ( ( 6 == move ) && !endOfTPDU )
|
|
835 |
{
|
|
836 |
i++;
|
|
837 |
move = 0;
|
|
838 |
}
|
|
839 |
else
|
|
840 |
{
|
|
841 |
move++;
|
|
842 |
}
|
|
843 |
}
|
|
844 |
else
|
|
845 |
{
|
|
846 |
TFLOGSTRING( "CSAT::CSatNotifySendSm::PackSms, Corrupted");
|
|
847 |
ret = KErrCorrupt;
|
|
848 |
break;
|
|
849 |
}
|
|
850 |
}
|
|
851 |
}
|
|
852 |
|
|
853 |
if ( KErrCorrupt != ret )
|
|
854 |
{
|
|
855 |
// New string length (number of characters)
|
|
856 |
if ( i - ( x - 1 ) )
|
|
857 |
{
|
|
858 |
aSendSm.SetLength( aSendSm.Length() - ( i - ( x - 1 ) ) );
|
|
859 |
}
|
|
860 |
|
|
861 |
// Address field length
|
|
862 |
// Address field length in semi-octets (BCD)
|
|
863 |
TUint8 posDCS( 0 );
|
|
864 |
posDCS = static_cast<TUint8>( aTpdu[2] / 2 + 2 );
|
|
865 |
|
|
866 |
if ( aTpdu[2] % 2 )
|
|
867 |
{
|
|
868 |
// If odd number of characters, increase position by one
|
|
869 |
posDCS++;
|
|
870 |
}
|
|
871 |
|
|
872 |
// Add 3 for first octet, message reference and protocol identifier
|
|
873 |
// mandatory fields
|
|
874 |
posDCS += 3;
|
|
875 |
|
|
876 |
// Change the DCS to default alphabet, Coding: see ETSI 3.38
|
|
877 |
if ( ( aTpdu[posDCS] & KMaskC0 ) == 0 )
|
|
878 |
{
|
|
879 |
aSendSm[posDCS] = static_cast<TUint8>( aSendSm[posDCS] & KMaskF3 );
|
|
880 |
}
|
|
881 |
if ( ( KMaskF0 & aTpdu[posDCS] ) == KMaskF0 )
|
|
882 |
{
|
|
883 |
aSendSm[posDCS] = static_cast<TUint8>( aSendSm[posDCS] & KMaskFB );
|
|
884 |
}
|
|
885 |
else
|
|
886 |
{
|
|
887 |
// Do nothing
|
|
888 |
}
|
|
889 |
}
|
|
890 |
}
|
|
891 |
else
|
|
892 |
{
|
|
893 |
// Packing cannot be requested if tpdu is something else than SMS submit
|
|
894 |
ret = KErrCorrupt;
|
|
895 |
}
|
|
896 |
return ret;
|
|
897 |
}
|
|
898 |
|
|
899 |
// End of file
|