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 : CSatNotifySendDtmf.cpp
|
|
15 |
// Part of : Common SIM ATK TSY / commonsimatktsy
|
|
16 |
// Send dtmf 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 "CSatNotifySendDtmf.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 |
// CSatNotifyTimerMgmt::NewL
|
|
37 |
// Two-phased constructor.
|
|
38 |
// -----------------------------------------------------------------------------
|
|
39 |
//
|
|
40 |
CSatNotifySendDtmf* CSatNotifySendDtmf::NewL
|
|
41 |
(
|
|
42 |
CSatNotificationsTsy* aNotificationsTsy
|
|
43 |
)
|
|
44 |
{
|
|
45 |
TFLOGSTRING("CSAT: CSatNotifySendDtmf::NewL");
|
|
46 |
CSatNotifySendDtmf* const satNotifySendDtmf =
|
|
47 |
new ( ELeave ) CSatNotifySendDtmf( aNotificationsTsy );
|
|
48 |
CleanupStack::PushL( satNotifySendDtmf );
|
|
49 |
satNotifySendDtmf->ConstructL();
|
|
50 |
CleanupStack::Pop( satNotifySendDtmf );
|
|
51 |
TFLOGSTRING("CSAT: CSatNotifySendDtmf::NewL, end of method");
|
|
52 |
return satNotifySendDtmf;
|
|
53 |
}
|
|
54 |
|
|
55 |
// -----------------------------------------------------------------------------
|
|
56 |
// CSatNotifySendDtmf::~CSatNotifySendDtmf
|
|
57 |
// Destructor
|
|
58 |
// -----------------------------------------------------------------------------
|
|
59 |
//
|
|
60 |
CSatNotifySendDtmf::~CSatNotifySendDtmf
|
|
61 |
(
|
|
62 |
// None
|
|
63 |
)
|
|
64 |
{
|
|
65 |
TFLOGSTRING("CSAT: CSatNotifySendDtmf::~CSatNotifySendDtmf");
|
|
66 |
}
|
|
67 |
|
|
68 |
// -----------------------------------------------------------------------------
|
|
69 |
// CSatNotifySendDtmf::CSatNotifySendDtmf
|
|
70 |
// Default C++ constructor
|
|
71 |
// -----------------------------------------------------------------------------
|
|
72 |
//
|
|
73 |
CSatNotifySendDtmf::CSatNotifySendDtmf
|
|
74 |
(
|
|
75 |
CSatNotificationsTsy* aNotificationsTsy
|
|
76 |
) : iNotificationsTsy ( aNotificationsTsy )
|
|
77 |
{
|
|
78 |
// None
|
|
79 |
}
|
|
80 |
|
|
81 |
// -----------------------------------------------------------------------------
|
|
82 |
// CSatNotifySendDtmf::ConstructL
|
|
83 |
// Symbian 2nd phase constructor
|
|
84 |
// -----------------------------------------------------------------------------
|
|
85 |
//
|
|
86 |
void CSatNotifySendDtmf::ConstructL
|
|
87 |
(
|
|
88 |
// None
|
|
89 |
)
|
|
90 |
{
|
|
91 |
TFLOGSTRING("CSAT: CSatNotifySendDtmf::ConstructL, does nothing");
|
|
92 |
}
|
|
93 |
|
|
94 |
// -----------------------------------------------------------------------------
|
|
95 |
// CSatNotifySendDtmf::Notify
|
|
96 |
// Save the request handle type for notification requested by ETel server
|
|
97 |
// -----------------------------------------------------------------------------
|
|
98 |
//
|
|
99 |
TInt CSatNotifySendDtmf::Notify
|
|
100 |
(
|
|
101 |
const TTsyReqHandle aTsyReqHandle,
|
|
102 |
const TDataPackage& aPackage
|
|
103 |
)
|
|
104 |
{
|
|
105 |
TFLOGSTRING("CSAT: CSatNotifySendDtmf::Notify");
|
|
106 |
// Save data pointer to client side for completion
|
|
107 |
iSendDtmfV1Pckg = reinterpret_cast<RSat::TSendDtmfV1Pckg*>(
|
|
108 |
aPackage.Des1n() );
|
|
109 |
// Save the request handle
|
|
110 |
iNotificationsTsy->iSatTsy->SaveReqHandle( aTsyReqHandle,
|
|
111 |
CSatTsy::ESatNotifySendDtmfPCmdReqType );
|
|
112 |
// Check if requested notification is already pending
|
|
113 |
iNotificationsTsy->NotifySatReadyForNotification( KSendDtmf );
|
|
114 |
|
|
115 |
return KErrNone;
|
|
116 |
}
|
|
117 |
|
|
118 |
|
|
119 |
|
|
120 |
// -----------------------------------------------------------------------------
|
|
121 |
// CSatNotifySendDtmf::CancelNotification
|
|
122 |
// This method cancels an outstanding asynchronous
|
|
123 |
// NotifySetUpCall request.
|
|
124 |
// -----------------------------------------------------------------------------
|
|
125 |
//
|
|
126 |
TInt CSatNotifySendDtmf::CancelNotification
|
|
127 |
(
|
|
128 |
const TTsyReqHandle aTsyReqHandle
|
|
129 |
)
|
|
130 |
{
|
|
131 |
TFLOGSTRING("CSAT: CSatNotifySendDtmf::CancelNotification");
|
|
132 |
// Reset the request handle
|
|
133 |
iNotificationsTsy->iSatReqHandleStore->ResetTsyReqHandle(
|
|
134 |
CSatTsy::ESatNotifySendDtmfPCmdReqType );
|
|
135 |
// Reset the data pointer
|
|
136 |
iSendDtmfV1Pckg = NULL;
|
|
137 |
// Complete the request with KErrCancel
|
|
138 |
iNotificationsTsy->iSatTsy->ReqCompleted( aTsyReqHandle, KErrCancel );
|
|
139 |
|
|
140 |
return KErrNone;
|
|
141 |
}
|
|
142 |
|
|
143 |
// -----------------------------------------------------------------------------
|
|
144 |
// CSatNotifySendDtmf::CompleteNotifyL
|
|
145 |
// This method completes an outstanding asynchronous
|
|
146 |
// SetUpCall request.
|
|
147 |
// -----------------------------------------------------------------------------
|
|
148 |
//
|
|
149 |
TInt CSatNotifySendDtmf::CompleteNotifyL
|
|
150 |
(
|
|
151 |
CSatDataPackage* aDataPackage,
|
|
152 |
TInt aErrorCode
|
|
153 |
)
|
|
154 |
{
|
|
155 |
TFLOGSTRING("CSAT: CSatNotifySendDtmf::CompleteNotifyL");
|
|
156 |
TInt returnValue( KErrNone );
|
|
157 |
TInt ret( KErrNone );
|
|
158 |
// Unpack parameters
|
|
159 |
TPtrC8* data;
|
|
160 |
aDataPackage->UnPackData( &data );
|
|
161 |
TBuf<1> additionalInfo;
|
|
162 |
// Reset req handle. Returns the deleted req handle
|
|
163 |
TTsyReqHandle reqHandle =
|
|
164 |
iNotificationsTsy->iSatReqHandleStore->ResetTsyReqHandle(
|
|
165 |
CSatTsy::ESatNotifySendDtmfPCmdReqType );
|
|
166 |
|
|
167 |
// Get ber tlv
|
|
168 |
CBerTlv berTlv;
|
|
169 |
berTlv.SetData( *data );
|
|
170 |
// Get command details tlv
|
|
171 |
CTlv commandDetails;
|
|
172 |
berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
|
|
173 |
|
|
174 |
// Store command details tlv
|
|
175 |
iNotificationsTsy->iTerminalRespData.iCommandDetails.Copy( commandDetails.Data() );
|
|
176 |
|
|
177 |
TUint8 pCmdNumber( commandDetails.GetShortInfo( ETLV_CommandNumber ) );
|
|
178 |
|
|
179 |
// In case the request was ongoing, continue..
|
|
180 |
if ( CSatTsy::ESatReqHandleUnknown != reqHandle )
|
|
181 |
{
|
|
182 |
// Complete right away if error has occured, otherwise continue..
|
|
183 |
if ( KErrNone == aErrorCode )
|
|
184 |
{
|
|
185 |
RSat::TSendDtmfV1& sendDtmfV1 = ( *iSendDtmfV1Pckg )();
|
|
186 |
|
|
187 |
// Command number
|
|
188 |
sendDtmfV1.SetPCmdNumber( pCmdNumber );
|
|
189 |
// Alpha id string (optional)
|
|
190 |
sendDtmfV1.iAlphaId.iAlphaId.Zero();
|
|
191 |
CTlv alphaIdentifier;
|
|
192 |
returnValue = berTlv.TlvByTagValue( &alphaIdentifier,
|
|
193 |
KTlvAlphaIdentifierTag );
|
|
194 |
// If alpha id string exist
|
|
195 |
if( KErrNone == returnValue )
|
|
196 |
{
|
|
197 |
TUint16 alphaIdLength = alphaIdentifier.GetLength();
|
|
198 |
|
|
199 |
if ( RSat::KAlphaIdMaxSize < alphaIdLength )
|
|
200 |
{
|
|
201 |
TFLOGSTRING("CSAT: CSatNotifySendDtmf::CompleteNotifyL,\
|
|
202 |
Alpha ID length exceeded");
|
|
203 |
// String too long
|
|
204 |
additionalInfo.Zero();
|
|
205 |
additionalInfo.Append( KNoCause );
|
|
206 |
CreateTerminalRespL( pCmdNumber,
|
|
207 |
RSat::KCmdBeyondMeCapabilities, additionalInfo );
|
|
208 |
ret = KErrCorrupt;
|
|
209 |
}
|
|
210 |
else if ( alphaIdLength )
|
|
211 |
{
|
|
212 |
TPtrC8 temp;
|
|
213 |
// Get the alpha id
|
|
214 |
temp.Set( alphaIdentifier.GetData(
|
|
215 |
ETLV_AlphaIdentifier ) );
|
|
216 |
// Convert and set the alpha id
|
|
217 |
TSatUtility::SetAlphaId( temp,
|
|
218 |
sendDtmfV1.iAlphaId.iAlphaId );
|
|
219 |
sendDtmfV1.iAlphaId.iStatus = RSat::EAlphaIdProvided;
|
|
220 |
}
|
|
221 |
else
|
|
222 |
{
|
|
223 |
TFLOGSTRING("CSAT: CSatNotifySendDtmf::CompleteNotifyL,\
|
|
224 |
Alpha ID is NULL");
|
|
225 |
sendDtmfV1.iAlphaId.iStatus = RSat::EAlphaIdNull;
|
|
226 |
}
|
|
227 |
}
|
|
228 |
// Alpha id not present
|
|
229 |
else
|
|
230 |
{
|
|
231 |
TFLOGSTRING("CSAT: CSatNotifySendDtmf::CompleteNotifyL,\
|
|
232 |
Alpha ID not present");
|
|
233 |
sendDtmfV1.iAlphaId.iStatus = RSat::EAlphaIdNotPresent;
|
|
234 |
}
|
|
235 |
|
|
236 |
// Dtmf string length, 8-bit string, mandatory
|
|
237 |
sendDtmfV1.iDtmfString.Zero();
|
|
238 |
CTlv sendDtmf;
|
|
239 |
returnValue = berTlv.TlvByTagValue( &sendDtmf,
|
|
240 |
KTlvDtmfStringTag );
|
|
241 |
|
|
242 |
if ( KErrNone == returnValue )
|
|
243 |
{
|
|
244 |
TUint8 generalResult( RSat::KSuccess );
|
|
245 |
// length - 1 for string
|
|
246 |
TUint16 dtmfStringLength = (TUint16) ( sendDtmf.GetLength() );
|
|
247 |
|
|
248 |
// If first byte of the dtmf string is 0xFF it means that dtmf string
|
|
249 |
// is empty and we have to return general result
|
|
250 |
if ( ( dtmfStringLength && ( sendDtmf.Data()[2] == 0xFF ) ) ||
|
|
251 |
!dtmfStringLength )
|
|
252 |
{
|
|
253 |
TFLOGSTRING("CSAT: CSatNotifySendDtmf::CompleteNotifyL,\
|
|
254 |
Data not understood");
|
|
255 |
generalResult = RSat::KCmdDataNotUnderstood;
|
|
256 |
ret = KErrCorrupt;
|
|
257 |
}
|
|
258 |
else if( RSat::KDtmfStringMaxSize < dtmfStringLength )
|
|
259 |
{
|
|
260 |
TFLOGSTRING("CSAT: CSatNotifySendDtmf::CompleteNotifyL,\
|
|
261 |
Cmd beyond ME capabilities");
|
|
262 |
generalResult = RSat::KCmdBeyondMeCapabilities;
|
|
263 |
ret = KErrCorrupt;
|
|
264 |
}
|
|
265 |
else
|
|
266 |
{
|
|
267 |
sendDtmfV1.iDtmfString.Append( sendDtmf.GetData( ETLV_DtmfString ) );
|
|
268 |
}
|
|
269 |
|
|
270 |
if( KErrCorrupt == ret )
|
|
271 |
{
|
|
272 |
TFLOGSTRING("CSAT: CSatNotifySendDtmf::CompleteNotifyL,\
|
|
273 |
DTMF length exceeded");
|
|
274 |
// String too long
|
|
275 |
additionalInfo.Zero();
|
|
276 |
additionalInfo.Append( KNoCause );
|
|
277 |
CreateTerminalRespL( pCmdNumber, generalResult,
|
|
278 |
additionalInfo );
|
|
279 |
}
|
|
280 |
}
|
|
281 |
else
|
|
282 |
{
|
|
283 |
additionalInfo.Zero();
|
|
284 |
additionalInfo.Append( KNoCause );
|
|
285 |
CreateTerminalRespL( pCmdNumber, RSat::KErrorRequiredValuesMissing,
|
|
286 |
additionalInfo );
|
|
287 |
ret = KErrCorrupt;
|
|
288 |
}
|
|
289 |
|
|
290 |
// Iconid
|
|
291 |
if ( KErrNone == ret )
|
|
292 |
{
|
|
293 |
TSatUtility::FillIconStructure( berTlv, sendDtmfV1.iIconId );
|
|
294 |
}
|
|
295 |
}
|
|
296 |
else
|
|
297 |
{
|
|
298 |
ret = aErrorCode;
|
|
299 |
}
|
|
300 |
iNotificationsTsy->iSatTsy->ReqCompleted( reqHandle, ret );
|
|
301 |
}
|
|
302 |
else
|
|
303 |
{
|
|
304 |
additionalInfo.Zero();
|
|
305 |
additionalInfo.Append( KNoCause );
|
|
306 |
CreateTerminalRespL( pCmdNumber, RSat::KMeUnableToProcessCmd,
|
|
307 |
additionalInfo );
|
|
308 |
}
|
|
309 |
return ret;
|
|
310 |
}
|
|
311 |
|
|
312 |
// -----------------------------------------------------------------------------
|
|
313 |
// CSatNotifySendDtmf::TerminalResponseL
|
|
314 |
// Called by ETel server, passes terminal response to SIM card
|
|
315 |
// -----------------------------------------------------------------------------
|
|
316 |
//
|
|
317 |
TInt CSatNotifySendDtmf::TerminalResponseL
|
|
318 |
(
|
|
319 |
TDes8* aRsp
|
|
320 |
)
|
|
321 |
{
|
|
322 |
TFLOGSTRING("CSAT:CSatNotifySendDtmf::TerminalResponseL");
|
|
323 |
|
|
324 |
TInt ret( KErrNone );
|
|
325 |
TBuf<1> additionalInfo;
|
|
326 |
|
|
327 |
RSat::TSendDtmfRspV1Pckg* aRspPckg =
|
|
328 |
reinterpret_cast<RSat::TSendDtmfRspV1Pckg*>( aRsp );
|
|
329 |
RSat::TSendDtmfRspV1& rspV1 = ( *aRspPckg ) ();
|
|
330 |
|
|
331 |
TUint8 pCmdNumber( rspV1.PCmdNumber() );
|
|
332 |
|
|
333 |
// Check that general result values are valid
|
|
334 |
if ( ( RSat::KSuccess != rspV1.iGeneralResult ) &&
|
|
335 |
( RSat::KMeUnableToProcessCmd != rspV1.iGeneralResult ) &&
|
|
336 |
( RSat::KCmdTypeNotUnderstood != rspV1.iGeneralResult ) &&
|
|
337 |
( RSat::KCmdDataNotUnderstood != rspV1.iGeneralResult ) &&
|
|
338 |
( RSat::KCmdNumberNotKnown != rspV1.iGeneralResult ) &&
|
|
339 |
( RSat::KCmdBeyondMeCapabilities != rspV1.iGeneralResult ) &&
|
|
340 |
( RSat::KPartialComprehension != rspV1.iGeneralResult ) &&
|
|
341 |
( RSat::KMissingInformation != rspV1.iGeneralResult ) &&
|
|
342 |
( RSat::KSuccessRequestedIconNotDisplayed != rspV1.iGeneralResult ) &&
|
|
343 |
( RSat::KPSessionTerminatedByUser != rspV1.iGeneralResult ) &&
|
|
344 |
( RSat::KErrorRequiredValuesMissing != rspV1.iGeneralResult ) )
|
|
345 |
{
|
|
346 |
TFLOGSTRING("CSAT:CSatNotifySendDtmf::TerminalResponseL,\
|
|
347 |
Invalid General result");
|
|
348 |
ret = KErrCorrupt;
|
|
349 |
}
|
|
350 |
|
|
351 |
if( RSat::KMeProblem == rspV1.iInfoType )
|
|
352 |
{
|
|
353 |
if ( rspV1.iAdditionalInfo.Length() )
|
|
354 |
{
|
|
355 |
additionalInfo.Zero();
|
|
356 |
additionalInfo.Append( rspV1.iAdditionalInfo[0] );
|
|
357 |
}
|
|
358 |
else
|
|
359 |
{
|
|
360 |
TFLOGSTRING("CSAT:CSatNotifySendDtmf::TerminalResponseL,\
|
|
361 |
Invalid Info Type");
|
|
362 |
ret = KErrCorrupt;
|
|
363 |
}
|
|
364 |
}
|
|
365 |
|
|
366 |
// Creating the terminal response message
|
|
367 |
TInt response = CreateTerminalRespL( pCmdNumber, ( TUint8 )rspV1.iGeneralResult,
|
|
368 |
additionalInfo );
|
|
369 |
|
|
370 |
if( KErrNone == ret )
|
|
371 |
{
|
|
372 |
ret = response;
|
|
373 |
}
|
|
374 |
|
|
375 |
return ret;
|
|
376 |
}
|
|
377 |
|
|
378 |
// -----------------------------------------------------------------------------
|
|
379 |
// CSatNotifySendDtmf::CreateTerminalRespL
|
|
380 |
// Constructs SendDtmf specific part of terminal response and calls
|
|
381 |
// DOS to send the actual message.
|
|
382 |
// -----------------------------------------------------------------------------
|
|
383 |
//
|
|
384 |
TInt CSatNotifySendDtmf::CreateTerminalRespL
|
|
385 |
(
|
|
386 |
TUint8 aPCmdNumber,
|
|
387 |
TUint8 aGeneralResult,
|
|
388 |
TDesC16& aAdditionalInfo
|
|
389 |
)
|
|
390 |
{
|
|
391 |
TFLOGSTRING("CSAT: CSatNotifySendDtmf::CreateTerminalRespL");
|
|
392 |
|
|
393 |
TTlv tlvSpecificData;
|
|
394 |
// Append general result tag
|
|
395 |
tlvSpecificData.AddTag( KTlvResultTag );
|
|
396 |
// Append general result
|
|
397 |
tlvSpecificData.AddByte( aGeneralResult );
|
|
398 |
|
|
399 |
if ( RSat::KMeUnableToProcessCmd == aGeneralResult )
|
|
400 |
{
|
|
401 |
// UnSuccessful result neccessitating additional info byte
|
|
402 |
if ( aAdditionalInfo.Length() )
|
|
403 |
{
|
|
404 |
tlvSpecificData.AddByte( static_cast<TUint8>( aAdditionalInfo[0] ) );
|
|
405 |
}
|
|
406 |
}
|
|
407 |
// Prepare data
|
|
408 |
iNotificationsTsy->iTerminalRespData.iPCmdNumber = aPCmdNumber;
|
|
409 |
TPtrC8 data = tlvSpecificData.GetDataWithoutTopLevelTag();
|
|
410 |
// Pack data
|
|
411 |
CSatDataPackage dataPackage;
|
|
412 |
dataPackage.PackData( &iNotificationsTsy->iTerminalRespData, &data );
|
|
413 |
|
|
414 |
// Forward request to the DOS
|
|
415 |
return iNotificationsTsy->iSatTsy->MessageManager()->HandleRequestL(
|
|
416 |
ESatTerminalRsp, &dataPackage );
|
|
417 |
}
|
|
418 |
|
|
419 |
// End of file
|
|
420 |
|